mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-23 21:13:35 +08:00
Adding I/E handlers for the last few types.
--HG-- branch : dev
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Web.Mvc;
|
||||
using System.Web.Routing;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Aspects;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.ContentManagement.Handlers;
|
||||
using Orchard.ContentManagement.MetaData;
|
||||
@@ -54,7 +52,7 @@ namespace Orchard.Core.Containers.Drivers {
|
||||
"Parts_Container_Edit",
|
||||
() => {
|
||||
var model = new ContainerViewModel { Part = part };
|
||||
// todo: is there a non-string comparison way to find ConaintableParts?
|
||||
// todo: is there a non-string comparison way to find ContainableParts?
|
||||
var containables = _contentDefinitionManager.ListTypeDefinitions().Where(td => td.Parts.Any(p => p.PartDefinition.Name == "ContainablePart")).ToList();
|
||||
var listItems = new[] { new SelectListItem { Text = T("(Any)").Text, Value = "" } }
|
||||
.Concat(containables.Select(x => new SelectListItem {
|
||||
@@ -73,6 +71,43 @@ namespace Orchard.Core.Containers.Drivers {
|
||||
return shapeHelper.EditorTemplate(TemplateName: "Container", Model: model, Prefix: "Container");
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Importing(ContainerPart part, ImportContentContext context) {
|
||||
var itemContentType = context.Attribute(part.PartDefinition.Name, "ItemContentType");
|
||||
if (itemContentType != null) {
|
||||
if (_contentDefinitionManager.GetTypeDefinition(itemContentType) != null) {
|
||||
part.Record.ItemContentType = itemContentType;
|
||||
}
|
||||
}
|
||||
|
||||
var paginated = context.Attribute(part.PartDefinition.Name, "Paginated");
|
||||
if (paginated != null) {
|
||||
part.Record.Paginated = Convert.ToBoolean(paginated);
|
||||
}
|
||||
|
||||
var pageSize = context.Attribute(part.PartDefinition.Name, "PageSize");
|
||||
if (pageSize != null) {
|
||||
part.Record.PageSize = Convert.ToInt32(pageSize);
|
||||
}
|
||||
|
||||
var orderByProperty = context.Attribute(part.PartDefinition.Name, "OrderByProperty");
|
||||
if (orderByProperty != null) {
|
||||
part.Record.OrderByProperty = orderByProperty;
|
||||
}
|
||||
|
||||
var orderByDirection = context.Attribute(part.PartDefinition.Name, "OrderByDirection");
|
||||
if (orderByDirection != null) {
|
||||
part.Record.OrderByDirection = Convert.ToInt32(orderByDirection);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Exporting(ContainerPart part, ExportContentContext context) {
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("ItemContentType", part.Record.ItemContentType);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("Paginated", part.Record.Paginated);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("PageSize", part.Record.PageSize);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("OrderByProperty", part.Record.OrderByProperty);
|
||||
context.Element(part.PartDefinition.Name).SetAttributeValue("OrderByDirection", part.Record.OrderByDirection);
|
||||
}
|
||||
}
|
||||
|
||||
public class ContainerPartHandler : ContentHandler {
|
||||
|
Reference in New Issue
Block a user