2010-11-09 16:00:51 -08:00
|
|
|
|
using Orchard.ContentManagement;
|
|
|
|
|
using Orchard.ContentManagement.Drivers;
|
2010-11-08 17:44:43 -08:00
|
|
|
|
using Orchard.ContentManagement.Handlers;
|
2010-11-08 15:33:56 -08:00
|
|
|
|
using Orchard.Core.Containers.Models;
|
2010-11-08 17:44:43 -08:00
|
|
|
|
using Orchard.Data;
|
2010-11-08 15:33:56 -08:00
|
|
|
|
|
|
|
|
|
namespace Orchard.Core.Containers.Drivers {
|
2010-11-08 17:44:43 -08:00
|
|
|
|
public class ContainerPartDriver : ContentPartDriver<ContainerPart> {
|
|
|
|
|
protected override DriverResult Editor(ContainerPart part, dynamic shapeHelper) {
|
|
|
|
|
return Editor(part, null, shapeHelper);
|
|
|
|
|
}
|
|
|
|
|
protected override DriverResult Editor(ContainerPart part, ContentManagement.IUpdateModel updater, dynamic shapeHelper) {
|
|
|
|
|
return ContentShape(
|
|
|
|
|
"Parts_Container_Edit",
|
|
|
|
|
() => {
|
|
|
|
|
if (updater != null)
|
|
|
|
|
updater.TryUpdateModel(part, "Container", null, null);
|
|
|
|
|
|
|
|
|
|
return shapeHelper.EditorTemplate(TemplateName: "Container", Model: part, Prefix: "Container");
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class ContainerPartHandler : ContentHandler {
|
2010-11-09 16:00:51 -08:00
|
|
|
|
public ContainerPartHandler(IRepository<ContainerPartRecord> repository, IOrchardServices orchardServices) {
|
2010-11-08 17:44:43 -08:00
|
|
|
|
Filters.Add(StorageFilter.For(repository));
|
2010-11-09 16:00:51 -08:00
|
|
|
|
OnInitializing<ContainerPart>((context, part) => {
|
|
|
|
|
var containerSiteSettings = orchardServices.WorkContext.CurrentSite.As<ContainerSettingsPart>().Record;
|
|
|
|
|
part.Record.PageSize = containerSiteSettings.DefaultPageSize;
|
|
|
|
|
});
|
2010-11-08 17:44:43 -08:00
|
|
|
|
}
|
2010-11-08 15:33:56 -08:00
|
|
|
|
}
|
2010-11-08 17:44:43 -08:00
|
|
|
|
}
|