mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Starting to transition onto different displaytype/location architecture
Introducing branch to avoid pushing a known broken state onto dev --HG-- branch : composition
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;
|
||||
|
||||
namespace Orchard.Core.Contents {
|
||||
public class Shapes : IShapeFactoryEvents {
|
||||
|
||||
public void Creating(ShapeCreatingContext creating) {
|
||||
if (creating.ShapeType.StartsWith("Items_Content"))
|
||||
creating.Behaviors.Add(new ZoneHoldingBehavior(name => creating.New.ContentZone()));
|
||||
public class Shapes : IShapeTableProvider {
|
||||
public void Discover(ShapeTableBuilder builder) {
|
||||
builder.Describe("Items_Content")
|
||||
.OnCreating(creating => creating.Behaviors.Add(new ZoneHoldingBehavior(name => ContentZone(creating, name))))
|
||||
.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) {
|
||||
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))
|
||||
routePart.Metadata.Type = string.Format("{0}.{1}", routePart.Metadata.Type, displayType);
|
||||
var location = part.GetLocation(displayType, "Header", "5");
|
||||
|
@@ -70,7 +70,7 @@ namespace Orchard.Widgets {
|
||||
.WithPart("WidgetPart")
|
||||
.WithPart("BodyPart")
|
||||
.WithPart("CommonPart")
|
||||
.WithSetting("stereotype", "widget")
|
||||
.WithSetting("Stereotype", "Widget")
|
||||
);
|
||||
|
||||
CreateDefaultLayers();
|
||||
|
@@ -23,7 +23,7 @@ namespace Orchard.Widgets.Services {
|
||||
|
||||
public IEnumerable<string> GetWidgetTypes() {
|
||||
return _contentManager.GetContentTypeDefinitions()
|
||||
.Where(contentTypeDefinition => contentTypeDefinition.Settings.ContainsKey("stereotype") && contentTypeDefinition.Settings["stereotype"] == "widget")
|
||||
.Where(contentTypeDefinition => contentTypeDefinition.Settings.ContainsKey("Stereotype") && contentTypeDefinition.Settings["Stereotype"] == "Widget")
|
||||
.Select(contentTypeDefinition => contentTypeDefinition.Name);
|
||||
}
|
||||
|
||||
|
@@ -378,23 +378,28 @@ namespace Orchard.ContentManagement {
|
||||
new[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) }));
|
||||
|
||||
|
||||
public dynamic BuildDisplay(dynamic content, string displayType = "") {
|
||||
public dynamic BuildDisplay(IContent content, string displayType = "") {
|
||||
var contentTypeDefinition = content.ContentItem.TypeDefinition;
|
||||
string stereotype;
|
||||
if (!contentTypeDefinition.Settings.TryGetValue("Stereotype", out stereotype))
|
||||
stereotype = "Content";
|
||||
|
||||
var shapeTypeName = "Items_" + stereotype;
|
||||
var shapeDisplayType = string.IsNullOrWhiteSpace(displayType) ? "Detail" : displayType;
|
||||
|
||||
var shapeHelper = _shapeHelperFactory.CreateHelper();
|
||||
|
||||
var shapeTypeName = string.IsNullOrEmpty(displayType) ? "Items_Content" : ("Items_Content_" + displayType);
|
||||
var itemShape = _shapeHelperCalls.Invoke(shapeHelper, shapeTypeName);
|
||||
|
||||
itemShape.ContentItem = content.ContentItem;
|
||||
itemShape.Metadata.DisplayType = shapeDisplayType;
|
||||
|
||||
IContent iContent = content;
|
||||
if (iContent != null)
|
||||
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);
|
||||
return context.Shape;
|
||||
}
|
||||
|
||||
|
||||
public dynamic BuildEditor(dynamic content) {
|
||||
public dynamic BuildEditor(IContent content) {
|
||||
var shapeHelper = _shapeHelperFactory.CreateHelper();
|
||||
var itemShape = shapeHelper.Items_Content_Edit();
|
||||
|
||||
@@ -407,7 +412,7 @@ namespace Orchard.ContentManagement {
|
||||
return context.Shape;
|
||||
}
|
||||
|
||||
public dynamic UpdateEditor(dynamic content, IUpdateModel updater) {
|
||||
public dynamic UpdateEditor(IContent content, IUpdateModel updater) {
|
||||
var shapeHelper = _shapeHelperFactory.CreateHelper();
|
||||
var itemShape = shapeHelper.Items_Content_Edit();
|
||||
|
||||
|
@@ -26,9 +26,9 @@ namespace Orchard.ContentManagement {
|
||||
|
||||
ContentItemMetadata GetItemMetadata(IContent contentItem);
|
||||
|
||||
dynamic BuildDisplay(dynamic content, string displayType = "");
|
||||
dynamic BuildEditor(dynamic content);
|
||||
dynamic UpdateEditor(dynamic content, IUpdateModel updater);
|
||||
dynamic BuildDisplay(IContent content, string displayType = "");
|
||||
dynamic BuildEditor(IContent content);
|
||||
dynamic UpdateEditor(IContent content, IUpdateModel updater);
|
||||
}
|
||||
|
||||
public class VersionOptions {
|
||||
|
@@ -9,6 +9,7 @@ namespace Orchard.DisplayManagement.Shapes {
|
||||
}
|
||||
|
||||
public string Type { get; set; }
|
||||
public string DisplayType { get; set; }
|
||||
public string Position { get; set; }
|
||||
public string Prefix { get; set; }
|
||||
public IList<string> Wrappers { get; set; }
|
||||
|
Reference in New Issue
Block a user