mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-04-05 21:01:35 +08:00
Moving Rules remainings from Core
This commit is contained in:
parent
0ea0077fa3
commit
5add094502
@ -112,7 +112,6 @@
|
||||
<Compile Include="Containers\ViewModels\ContainerWidgetViewModel.cs" />
|
||||
<Compile Include="Containers\ViewModels\ContainerViewModel.cs" />
|
||||
<Compile Include="Contents\ControlWrapper.cs" />
|
||||
<Compile Include="Contents\Handlers\RulesHandler.cs" />
|
||||
<Compile Include="Contents\Security\AuthorizationEventHandler.cs" />
|
||||
<Compile Include="Common\Services\BbcodeFilter.cs" />
|
||||
<Compile Include="Common\Services\ICommonService.cs" />
|
||||
|
@ -1,39 +1,33 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Events;
|
||||
|
||||
namespace Orchard.Core.Contents.Handlers {
|
||||
|
||||
public interface IRulesManager : IEventHandler {
|
||||
void TriggerEvent(string category, string type, Func<Dictionary<string, object>> tokensContext);
|
||||
}
|
||||
|
||||
public class RulePartHandler : ContentHandler {
|
||||
public RulePartHandler(IRulesManager rulesManager) {
|
||||
|
||||
OnPublished<ContentPart>(
|
||||
(context, part) =>
|
||||
rulesManager.TriggerEvent("Content", "Published",
|
||||
() => new Dictionary<string, object> { { "Content", context.ContentItem } }));
|
||||
|
||||
OnRemoved<ContentPart>(
|
||||
(context, part) =>
|
||||
rulesManager.TriggerEvent("Content", "Removed",
|
||||
() => new Dictionary<string, object> { { "Content", context.ContentItem } }));
|
||||
|
||||
OnVersioned<ContentPart>(
|
||||
(context, part1, part2) =>
|
||||
rulesManager.TriggerEvent("Content", "Versioned",
|
||||
() => new Dictionary<string, object> { { "Content", part1.ContentItem } }));
|
||||
|
||||
OnCreated<ContentPart>(
|
||||
(context, part) =>
|
||||
rulesManager.TriggerEvent("Content", "Created",
|
||||
() => new Dictionary<string, object> { { "Content", context.ContentItem } }));
|
||||
|
||||
}
|
||||
}
|
||||
using System.Collections.Generic;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.Rules.Services;
|
||||
|
||||
namespace Orchard.Rules.Handlers {
|
||||
|
||||
public class RulePartHandler : ContentHandler {
|
||||
public RulePartHandler(IRulesManager rulesManager) {
|
||||
|
||||
OnPublished<ContentPart>(
|
||||
(context, part) =>
|
||||
rulesManager.TriggerEvent("Content", "Published",
|
||||
() => new Dictionary<string, object> { { "Content", context.ContentItem } }));
|
||||
|
||||
OnRemoved<ContentPart>(
|
||||
(context, part) =>
|
||||
rulesManager.TriggerEvent("Content", "Removed",
|
||||
() => new Dictionary<string, object> { { "Content", context.ContentItem } }));
|
||||
|
||||
OnVersioned<ContentPart>(
|
||||
(context, part1, part2) =>
|
||||
rulesManager.TriggerEvent("Content", "Versioned",
|
||||
() => new Dictionary<string, object> { { "Content", part1.ContentItem } }));
|
||||
|
||||
OnCreated<ContentPart>(
|
||||
(context, part) =>
|
||||
rulesManager.TriggerEvent("Content", "Created",
|
||||
() => new Dictionary<string, object> { { "Content", context.ContentItem } }));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -82,6 +82,7 @@
|
||||
<Content Include="Views\Web.config" />
|
||||
<Content Include="Scripts\Web.config" />
|
||||
<Content Include="Styles\Web.config" />
|
||||
<Compile Include="Handlers\ContentHandler.cs" />
|
||||
<Compile Include="ImportExport\RulesExportEventHandler.cs" />
|
||||
<Compile Include="ImportExport\RulesCustomExportStep.cs" />
|
||||
<Compile Include="ImportExport\RulesRecipeHandler.cs" />
|
||||
|
@ -17,14 +17,14 @@ namespace Orchard.Rules.Providers {
|
||||
Func<dynamic, bool> contentHasPart = ContentHasPart;
|
||||
|
||||
describe.For("Content", T("Content Items"), T("Content Items"))
|
||||
.Element("Created", T("Content Created"), T("Content is actually created."), contentHasPart, (Func<dynamic, LocalizedString>)(context => T("When content with types ({0}) is created.", FormatPartsList(context))), "SelectContentTypes")
|
||||
.Element("Versioned", T("Content Versioned"), T("Content is actually versioned."), contentHasPart, (Func<dynamic, LocalizedString>)(context => T("When content with types ({0}) is versioned.", FormatPartsList(context))), "SelectContentTypes")
|
||||
.Element("Published", T("Content Published"), T("Content is actually published."), contentHasPart, (Func<dynamic, LocalizedString>)(context => T("When content with types ({0}) is published.", FormatPartsList(context))), "SelectContentTypes")
|
||||
.Element("Removed", T("Content Removed"), T("Content is actually removed."), contentHasPart, (Func<dynamic, LocalizedString>)(context => T("When content with types ({0}) is removed.", FormatPartsList(context))), "SelectContentTypes");
|
||||
.Element("Created", T("Content Created"), T("Content is actually created."), contentHasPart, context => T("When content with types ({0}) is created.", FormatPartsList(context)), "SelectContentTypes")
|
||||
.Element("Versioned", T("Content Versioned"), T("Content is actually versioned."), contentHasPart, context => T("When content with types ({0}) is versioned.", FormatPartsList(context)), "SelectContentTypes")
|
||||
.Element("Published", T("Content Published"), T("Content is actually published."), contentHasPart, context => T("When content with types ({0}) is published.", FormatPartsList(context)), "SelectContentTypes")
|
||||
.Element("Removed", T("Content Removed"), T("Content is actually removed."), contentHasPart, context => T("When content with types ({0}) is removed.", FormatPartsList(context)), "SelectContentTypes");
|
||||
}
|
||||
|
||||
private string FormatPartsList(dynamic context) {
|
||||
var contenttypes = context.Properties["ContentTypes"];
|
||||
private string FormatPartsList(EventContext context) {
|
||||
var contenttypes = context.Properties.ContainsKey("ContentTypes") ? context.Properties["ContentTypes"] : context.Properties["contenttypes"];
|
||||
|
||||
if (String.IsNullOrEmpty(contenttypes)) {
|
||||
return T("Any").Text;
|
||||
|
Loading…
Reference in New Issue
Block a user