mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-23 12:53:33 +08:00
Fixing feature name for RulesHandler
--HG-- branch : 1.x
This commit is contained in:
@@ -7,16 +7,13 @@ using Orchard.Events;
|
|||||||
|
|
||||||
namespace Orchard.Core.Contents.Handlers {
|
namespace Orchard.Core.Contents.Handlers {
|
||||||
|
|
||||||
public interface IRulesManager : IEventHandler
|
public interface IRulesManager : IEventHandler {
|
||||||
{
|
|
||||||
void TriggerEvent(string category, string type, Func<Dictionary<string, object>> tokensContext);
|
void TriggerEvent(string category, string type, Func<Dictionary<string, object>> tokensContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
[OrchardFeature("Orchard.Core.Contents.Rules")]
|
[OrchardFeature("Contents.Rules")]
|
||||||
public class RulePartHandler : ContentHandler
|
public class RulePartHandler : ContentHandler {
|
||||||
{
|
public RulePartHandler(IRulesManager rulesManager) {
|
||||||
public RulePartHandler(IRulesManager rulesManager)
|
|
||||||
{
|
|
||||||
|
|
||||||
OnPublished<ContentPart>(
|
OnPublished<ContentPart>(
|
||||||
(context, part) =>
|
(context, part) =>
|
||||||
|
@@ -14,4 +14,4 @@ Features:
|
|||||||
Name: Contents Rules
|
Name: Contents Rules
|
||||||
Description: Rules for the Contents modules
|
Description: Rules for the Contents modules
|
||||||
Category: Rules
|
Category: Rules
|
||||||
Dependency: Rules
|
Dependency: Orchard.Rules, Contents
|
||||||
|
@@ -5,20 +5,16 @@ using Orchard.Environment.Extensions;
|
|||||||
using Orchard.Events;
|
using Orchard.Events;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
|
|
||||||
namespace Orchard.Core.Contents.Rules
|
namespace Orchard.Core.Contents.Rules {
|
||||||
{
|
public interface IEventProvider : IEventHandler {
|
||||||
public interface IEventProvider : IEventHandler
|
|
||||||
{
|
|
||||||
void Describe(dynamic describe);
|
void Describe(dynamic describe);
|
||||||
}
|
}
|
||||||
|
|
||||||
[OrchardFeature("Contents.Rules")]
|
[OrchardFeature("Contents.Rules")]
|
||||||
public class ContentEvents : IEventProvider
|
public class ContentEvents : IEventProvider {
|
||||||
{
|
|
||||||
public Localizer T { get; set; }
|
public Localizer T { get; set; }
|
||||||
|
|
||||||
public void Describe(dynamic describe)
|
public void Describe(dynamic describe) {
|
||||||
{
|
|
||||||
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"))
|
||||||
@@ -28,31 +24,26 @@ namespace Orchard.Core.Contents.Rules
|
|||||||
.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, (Func<dynamic, LocalizedString>)(context => T("When content with types ({0}) is removed.", FormatPartsList(context))), "SelectContentTypes");
|
||||||
}
|
}
|
||||||
|
|
||||||
private string FormatPartsList(dynamic context)
|
private string FormatPartsList(dynamic context) {
|
||||||
{
|
|
||||||
var contenttypes = context.Properties["contenttypes"];
|
var contenttypes = context.Properties["contenttypes"];
|
||||||
|
|
||||||
if(String.IsNullOrEmpty(contenttypes))
|
if (String.IsNullOrEmpty(contenttypes)) {
|
||||||
{
|
|
||||||
return T("Any").Text;
|
return T("Any").Text;
|
||||||
}
|
}
|
||||||
|
|
||||||
return contenttypes;
|
return contenttypes;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool ContentHasPart(dynamic context)
|
private static bool ContentHasPart(dynamic context) {
|
||||||
{
|
|
||||||
string contenttypes = context.Properties["contenttypes"];
|
string contenttypes = context.Properties["contenttypes"];
|
||||||
var content = context.Tokens["Content"] as IContent;
|
var content = context.Tokens["Content"] as IContent;
|
||||||
|
|
||||||
// "" means 'any'
|
// "" means 'any'
|
||||||
if(String.IsNullOrEmpty(contenttypes))
|
if (String.IsNullOrEmpty(contenttypes)) {
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(content == null)
|
if (content == null) {
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -6,30 +6,25 @@ using Orchard.Environment.Extensions;
|
|||||||
using Orchard.Events;
|
using Orchard.Events;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
|
|
||||||
namespace Orchard.Core.Contents.Rules
|
namespace Orchard.Core.Contents.Rules {
|
||||||
{
|
public interface IFormProvider : IEventHandler {
|
||||||
public interface IFormProvider : IEventHandler
|
|
||||||
{
|
|
||||||
void Describe(dynamic context);
|
void Describe(dynamic context);
|
||||||
}
|
}
|
||||||
|
|
||||||
[OrchardFeature("Contents.Rules")]
|
[OrchardFeature("Contents.Rules")]
|
||||||
public class ContentForms : IFormProvider
|
public class ContentForms : IFormProvider {
|
||||||
{
|
|
||||||
private readonly IContentDefinitionManager _contentDefinitionManager;
|
private readonly IContentDefinitionManager _contentDefinitionManager;
|
||||||
protected dynamic Shape { get; set; }
|
protected dynamic Shape { get; set; }
|
||||||
public Localizer T { get; set; }
|
public Localizer T { get; set; }
|
||||||
|
|
||||||
public ContentForms(
|
public ContentForms(
|
||||||
IShapeFactory shapeFactory,
|
IShapeFactory shapeFactory,
|
||||||
IContentDefinitionManager contentDefinitionManager)
|
IContentDefinitionManager contentDefinitionManager) {
|
||||||
{
|
|
||||||
_contentDefinitionManager = contentDefinitionManager;
|
_contentDefinitionManager = contentDefinitionManager;
|
||||||
Shape = shapeFactory;
|
Shape = shapeFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Describe(dynamic context)
|
public void Describe(dynamic context) {
|
||||||
{
|
|
||||||
Func<IShapeFactory, dynamic> form =
|
Func<IShapeFactory, dynamic> form =
|
||||||
shape => {
|
shape => {
|
||||||
|
|
||||||
@@ -46,8 +41,7 @@ namespace Orchard.Core.Contents.Rules
|
|||||||
|
|
||||||
f._Parts.Add(new SelectListItem { Value = "", Text = T("Any").Text });
|
f._Parts.Add(new SelectListItem { Value = "", Text = T("Any").Text });
|
||||||
|
|
||||||
foreach (var contentType in _contentDefinitionManager.ListTypeDefinitions())
|
foreach (var contentType in _contentDefinitionManager.ListTypeDefinitions()) {
|
||||||
{
|
|
||||||
f._Parts.Add(new SelectListItem { Value = contentType.Name, Text = contentType.DisplayName });
|
f._Parts.Add(new SelectListItem { Value = contentType.Name, Text = contentType.DisplayName });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -15,4 +15,4 @@ Features:
|
|||||||
Name: Comments Rules
|
Name: Comments Rules
|
||||||
Description: Rules for the Comments modules
|
Description: Rules for the Comments modules
|
||||||
Category: Rules
|
Category: Rules
|
||||||
Dependency: Rules
|
Dependency: Orchard.Comments, Orchard.Rules
|
Reference in New Issue
Block a user