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:
Louis DeJardin
2010-10-11 16:13:22 -07:00
parent 71d3c9c32a
commit 097d936a83
8 changed files with 41 additions and 23 deletions

View File

@@ -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;
}
}
}

View File

@@ -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");

View File

@@ -70,7 +70,7 @@ namespace Orchard.Widgets {
.WithPart("WidgetPart")
.WithPart("BodyPart")
.WithPart("CommonPart")
.WithSetting("stereotype", "widget")
.WithSetting("Stereotype", "Widget")
);
CreateDefaultLayers();

View File

@@ -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);
}

View File

@@ -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();

View File

@@ -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 {

View File

@@ -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; }