2010-03-03 06:07:58 +08:00
|
|
|
|
using Orchard.ContentManagement;
|
|
|
|
|
using Orchard.ContentManagement.Drivers;
|
2010-01-06 04:58:50 +08:00
|
|
|
|
using Orchard.Core.Common.Models;
|
|
|
|
|
using Orchard.Core.Common.ViewModels;
|
|
|
|
|
|
|
|
|
|
namespace Orchard.Core.Common.Controllers {
|
2010-03-03 06:07:58 +08:00
|
|
|
|
public class BodyDriver : ContentPartDriver<BodyAspect> {
|
|
|
|
|
public IOrchardServices Services { get; set; }
|
2010-01-06 04:58:50 +08:00
|
|
|
|
private const string TemplateName = "Parts/Common.Body";
|
|
|
|
|
private const string DefaultTextEditorTemplate = "TinyMceTextEditor";
|
2010-03-03 06:07:58 +08:00
|
|
|
|
|
|
|
|
|
public BodyDriver(IOrchardServices services) {
|
|
|
|
|
Services = services;
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-06 04:58:50 +08:00
|
|
|
|
protected override string Prefix {
|
|
|
|
|
get {return "Body";}
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-03 06:07:58 +08:00
|
|
|
|
// \/\/ Haackalicious on many accounts - don't copy what has been done here for the wrapper \/\/
|
2010-01-06 04:58:50 +08:00
|
|
|
|
protected override DriverResult Display(BodyAspect part, string displayType) {
|
|
|
|
|
var model = new BodyDisplayViewModel { BodyAspect = part };
|
2010-03-03 06:07:58 +08:00
|
|
|
|
return Combined(
|
|
|
|
|
Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/ManageWrapperPre").Location("primary", "5") : null,
|
|
|
|
|
Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/Manage").Location("primary", "5") : null,
|
|
|
|
|
ContentPartTemplate(model, TemplateName, Prefix).Location("primary", "5"),
|
|
|
|
|
Services.Authorizer.Authorize(Permissions.ChangeOwner) ? ContentPartTemplate(model, "Parts/ManageWrapperPost").Location("primary", "5") : null);
|
2010-01-06 04:58:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override DriverResult Editor(BodyAspect part) {
|
|
|
|
|
var model = new BodyEditorViewModel { BodyAspect = part, TextEditorTemplate = DefaultTextEditorTemplate };
|
2010-01-07 08:12:56 +08:00
|
|
|
|
return ContentPartTemplate(model, TemplateName, Prefix).Location("primary", "5");
|
2010-01-06 04:58:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2010-03-03 06:07:58 +08:00
|
|
|
|
protected override DriverResult Editor(BodyAspect part, IUpdateModel updater) {
|
2010-01-06 04:58:50 +08:00
|
|
|
|
var model = new BodyEditorViewModel { BodyAspect = part, TextEditorTemplate = DefaultTextEditorTemplate };
|
|
|
|
|
updater.TryUpdateModel(model, Prefix, null, null);
|
2010-01-07 08:12:56 +08:00
|
|
|
|
return ContentPartTemplate(model, TemplateName, Prefix).Location("primary", "5");
|
2010-01-06 04:58:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|