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