mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Merge
--HG-- branch : dev
This commit is contained in:
@@ -1,15 +1,27 @@
|
|||||||
using Orchard.DisplayManagement.Implementation;
|
using System;
|
||||||
|
using Orchard.ContentManagement;
|
||||||
|
using Orchard.DisplayManagement.Descriptors;
|
||||||
|
using Orchard.DisplayManagement.Implementation;
|
||||||
using Orchard.UI.Zones;
|
using Orchard.UI.Zones;
|
||||||
|
|
||||||
namespace Orchard.Core.Contents {
|
namespace Orchard.Core.Contents {
|
||||||
public class Shapes : IShapeFactoryEvents {
|
public class Shapes : IShapeTableProvider {
|
||||||
|
public void Discover(ShapeTableBuilder builder) {
|
||||||
public void Creating(ShapeCreatingContext creating) {
|
builder.Describe("Items_Content")
|
||||||
if (creating.ShapeType.StartsWith("Items_Content"))
|
.OnCreating(creating => creating.Behaviors.Add(new ZoneHoldingBehavior(name => ContentZone(creating, name))))
|
||||||
creating.Behaviors.Add(new ZoneHoldingBehavior(name => creating.New.ContentZone()));
|
.OnDisplaying(displaying => {
|
||||||
|
ContentItem contentItem = displaying.Shape.ContentItem;
|
||||||
|
if (contentItem != null) {
|
||||||
|
displaying.ShapeMetadata.Alternates.Add("Items_Content__" + contentItem.ContentType);
|
||||||
|
displaying.ShapeMetadata.Alternates.Add("Items_Content__" + contentItem.Id);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Created(ShapeCreatedContext created) {
|
private static object ContentZone(ShapeCreatingContext creating, string name) {
|
||||||
|
var zone = creating.New.ContentZone();
|
||||||
|
zone.ZoneName = name;
|
||||||
|
return zone;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -45,7 +45,7 @@ namespace Orchard.Core.Routable.Drivers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected override DriverResult Display(RoutePart part, string displayType, dynamic shapeHelper) {
|
protected override DriverResult Display(RoutePart part, string displayType, dynamic shapeHelper) {
|
||||||
var routePart = shapeHelper.Parts_Routable_RoutePart(ContentPart: part, Title: part.Title);
|
var routePart = shapeHelper.Parts_RoutableTitle(ContentPart: part, Title: part.Title);
|
||||||
if (!string.IsNullOrWhiteSpace(displayType))
|
if (!string.IsNullOrWhiteSpace(displayType))
|
||||||
routePart.Metadata.Type = string.Format("{0}.{1}", routePart.Metadata.Type, displayType);
|
routePart.Metadata.Type = string.Format("{0}.{1}", routePart.Metadata.Type, displayType);
|
||||||
var location = part.GetLocation(displayType, "Header", "5");
|
var location = part.GetLocation(displayType, "Header", "5");
|
||||||
|
@@ -378,23 +378,28 @@ namespace Orchard.ContentManagement {
|
|||||||
new[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
|
new[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
|
||||||
|
|
||||||
|
|
||||||
public dynamic BuildDisplay(dynamic content, string displayType = "") {
|
public dynamic BuildDisplay(IContent content, string displayType = "") {
|
||||||
var shapeHelper = _shapeHelperFactory.CreateHelper();
|
var contentTypeDefinition = content.ContentItem.TypeDefinition;
|
||||||
|
string stereotype;
|
||||||
|
if (!contentTypeDefinition.Settings.TryGetValue("Stereotype", out stereotype))
|
||||||
|
stereotype = "Content";
|
||||||
|
|
||||||
var shapeTypeName = string.IsNullOrEmpty(displayType) ? "Items_Content" : ("Items_Content_" + displayType);
|
var shapeTypeName = "Items_" + stereotype;
|
||||||
|
var shapeDisplayType = string.IsNullOrWhiteSpace(displayType) ? "Detail" : displayType;
|
||||||
|
|
||||||
|
var shapeHelper = _shapeHelperFactory.CreateHelper();
|
||||||
var itemShape = _shapeHelperCalls.Invoke(shapeHelper, shapeTypeName);
|
var itemShape = _shapeHelperCalls.Invoke(shapeHelper, shapeTypeName);
|
||||||
|
|
||||||
IContent iContent = content;
|
itemShape.ContentItem = content.ContentItem;
|
||||||
if (iContent != null)
|
itemShape.Metadata.DisplayType = shapeDisplayType;
|
||||||
itemShape.ContentItem = iContent.ContentItem;
|
|
||||||
|
|
||||||
var context = new BuildDisplayContext(itemShape, content, displayType, _shapeHelperFactory);
|
var context = new BuildDisplayContext(itemShape, content, shapeDisplayType, _shapeHelperFactory);
|
||||||
Handlers.Invoke(handler => handler.BuildDisplay(context), Logger);
|
Handlers.Invoke(handler => handler.BuildDisplay(context), Logger);
|
||||||
return context.Shape;
|
return context.Shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public dynamic BuildEditor(dynamic content) {
|
public dynamic BuildEditor(IContent content) {
|
||||||
var shapeHelper = _shapeHelperFactory.CreateHelper();
|
var shapeHelper = _shapeHelperFactory.CreateHelper();
|
||||||
var itemShape = shapeHelper.Items_Content_Edit();
|
var itemShape = shapeHelper.Items_Content_Edit();
|
||||||
|
|
||||||
@@ -407,7 +412,7 @@ namespace Orchard.ContentManagement {
|
|||||||
return context.Shape;
|
return context.Shape;
|
||||||
}
|
}
|
||||||
|
|
||||||
public dynamic UpdateEditor(dynamic content, IUpdateModel updater) {
|
public dynamic UpdateEditor(IContent content, IUpdateModel updater) {
|
||||||
var shapeHelper = _shapeHelperFactory.CreateHelper();
|
var shapeHelper = _shapeHelperFactory.CreateHelper();
|
||||||
var itemShape = shapeHelper.Items_Content_Edit();
|
var itemShape = shapeHelper.Items_Content_Edit();
|
||||||
|
|
||||||
|
@@ -26,9 +26,9 @@ namespace Orchard.ContentManagement {
|
|||||||
|
|
||||||
ContentItemMetadata GetItemMetadata(IContent contentItem);
|
ContentItemMetadata GetItemMetadata(IContent contentItem);
|
||||||
|
|
||||||
dynamic BuildDisplay(dynamic content, string displayType = "");
|
dynamic BuildDisplay(IContent content, string displayType = "");
|
||||||
dynamic BuildEditor(dynamic content);
|
dynamic BuildEditor(IContent content);
|
||||||
dynamic UpdateEditor(dynamic content, IUpdateModel updater);
|
dynamic UpdateEditor(IContent content, IUpdateModel updater);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class VersionOptions {
|
public class VersionOptions {
|
||||||
|
@@ -9,6 +9,7 @@ namespace Orchard.DisplayManagement.Shapes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public string Type { get; set; }
|
public string Type { get; set; }
|
||||||
|
public string DisplayType { get; set; }
|
||||||
public string Position { get; set; }
|
public string Position { get; set; }
|
||||||
public string Prefix { get; set; }
|
public string Prefix { get; set; }
|
||||||
public IList<string> Wrappers { get; set; }
|
public IList<string> Wrappers { get; set; }
|
||||||
|
Reference in New Issue
Block a user