2009-12-22 01:31:55 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Web.Routing;
|
|
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
using Orchard.ContentManagement;
|
|
|
|
|
using Orchard.ContentManagement.Drivers;
|
2010-01-05 10:54:12 +00:00
|
|
|
|
using Orchard.Mvc.ViewModels;
|
2009-12-22 01:31:55 +00:00
|
|
|
|
using Orchard.Sandbox.Models;
|
|
|
|
|
|
2010-03-03 23:31:42 -08:00
|
|
|
|
namespace Orchard.Sandbox.Drivers {
|
2009-12-22 01:31:55 +00:00
|
|
|
|
[UsedImplicitly]
|
2010-01-05 21:49:48 +00:00
|
|
|
|
public class SandboxPageDriver : ContentItemDriver<SandboxPage> {
|
2009-12-22 01:55:34 +00:00
|
|
|
|
public readonly static ContentType ContentType = new ContentType {
|
2010-03-03 23:31:42 -08:00
|
|
|
|
Name = "sandboxpage",
|
|
|
|
|
DisplayName = "Sandbox Page"
|
|
|
|
|
};
|
2009-12-22 01:31:55 +00:00
|
|
|
|
|
2009-12-22 01:55:34 +00:00
|
|
|
|
protected override ContentType GetContentType() {
|
|
|
|
|
return ContentType;
|
|
|
|
|
}
|
2009-12-22 01:31:55 +00:00
|
|
|
|
protected override string GetDisplayText(SandboxPage item) {
|
|
|
|
|
return item.Record.Name;
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-08 02:39:41 -08:00
|
|
|
|
public override RouteValueDictionary GetDisplayRouteValues(SandboxPage item) {
|
2009-12-22 01:31:55 +00:00
|
|
|
|
return new RouteValueDictionary(
|
|
|
|
|
new {
|
2010-03-03 23:31:42 -08:00
|
|
|
|
area = "Orchard.Sandbox",
|
|
|
|
|
controller = "Page",
|
|
|
|
|
action = "Show",
|
|
|
|
|
id = item.ContentItem.Id,
|
|
|
|
|
});
|
2009-12-22 01:31:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-03-08 02:39:41 -08:00
|
|
|
|
public override RouteValueDictionary GetEditorRouteValues(SandboxPage item) {
|
2009-12-22 01:31:55 +00:00
|
|
|
|
return new RouteValueDictionary(
|
|
|
|
|
new {
|
2010-03-03 23:31:42 -08:00
|
|
|
|
area = "Orchard.Sandbox",
|
|
|
|
|
controller = "Page",
|
|
|
|
|
action = "Edit",
|
|
|
|
|
id = item.ContentItem.Id,
|
|
|
|
|
});
|
2009-12-22 01:31:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override DriverResult Display(SandboxPage part, string displayType) {
|
|
|
|
|
return Combined(
|
2010-01-05 21:49:48 +00:00
|
|
|
|
ContentItemTemplate("Items/Sandbox.Page").LongestMatch(displayType, "Summary"),
|
|
|
|
|
ContentPartTemplate(part, "Parts/Sandbox.Page.Title").Location("title"));
|
2009-12-22 01:31:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-01-05 21:49:48 +00:00
|
|
|
|
protected override DriverResult Editor(ContentItemViewModel<SandboxPage> model) {
|
|
|
|
|
return ContentItemTemplate("Items/Sandbox.Page");
|
2009-12-22 01:31:55 +00:00
|
|
|
|
}
|
|
|
|
|
|
2010-01-05 21:49:48 +00:00
|
|
|
|
protected override DriverResult Editor(ContentItemViewModel<SandboxPage> model, IUpdateModel updater) {
|
2009-12-22 01:31:55 +00:00
|
|
|
|
updater.TryUpdateModel(model, Prefix, null, null);
|
2010-01-05 21:49:48 +00:00
|
|
|
|
return ContentItemTemplate("Items/Sandbox.Page");
|
2009-12-22 01:31:55 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2010-03-03 23:31:42 -08:00
|
|
|
|
}
|