mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-14 10:54:50 +08:00

- also removing the default (Core.Contents specific) metadata from Orchard.ContentManagement.ContentItemMetadata work items: 16683, 16791 --HG-- branch : dev
42 lines
1.6 KiB
C#
42 lines
1.6 KiB
C#
using System.Web.Routing;
|
|
using JetBrains.Annotations;
|
|
using Orchard.ContentManagement;
|
|
using Orchard.ContentManagement.Handlers;
|
|
using Orchard.Data;
|
|
using Orchard.Widgets.Models;
|
|
|
|
namespace Orchard.Widgets.Handlers {
|
|
[UsedImplicitly]
|
|
public class WidgetPartHandler : ContentHandler {
|
|
public WidgetPartHandler(IRepository<WidgetPartRecord> widgetsRepository) {
|
|
Filters.Add(StorageFilter.For(widgetsRepository));
|
|
}
|
|
|
|
protected override void GetItemMetadata(GetContentItemMetadataContext context) {
|
|
var widget = context.ContentItem.As<WidgetPart>();
|
|
|
|
if (widget == null)
|
|
return;
|
|
|
|
// create needs to go through the add widget flow (index -> [select layer -> ] add [widget type] to layer)
|
|
context.Metadata.CreateRouteValues = new RouteValueDictionary {
|
|
{"Area", "Orchard.Widgets"},
|
|
{"Controller", "Admin"},
|
|
{"Action", "Index"}
|
|
};
|
|
context.Metadata.EditorRouteValues = new RouteValueDictionary {
|
|
{"Area", "Orchard.Widgets"},
|
|
{"Controller", "Admin"},
|
|
{"Action", "EditWidget"},
|
|
{"Id", context.ContentItem.Id}
|
|
};
|
|
// remove goes through edit widget...
|
|
context.Metadata.RemoveRouteValues = new RouteValueDictionary {
|
|
{"Area", "Orchard.Widgets"},
|
|
{"Controller", "Admin"},
|
|
{"Action", "EditWidget"},
|
|
{"Id", context.ContentItem.Id}
|
|
};
|
|
}
|
|
}
|
|
} |