Adding ContentItemMetadata route values for widgets, blogs and blog posts

- also removing the default (Core.Contents specific) metadata from Orchard.ContentManagement.ContentItemMetadata

work items: 16683, 16791

--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2010-11-22 21:45:33 -08:00
parent 1918a78646
commit a70c5ad4ea
7 changed files with 90 additions and 65 deletions

View File

@@ -1,4 +1,6 @@
using JetBrains.Annotations;
using System.Web.Routing;
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.Data;
using Orchard.Widgets.Models;
@@ -9,5 +11,32 @@ namespace Orchard.Widgets.Handlers {
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}
};
}
}
}