--HG--
branch : dev
This commit is contained in:
Sebastien Ros
2010-10-11 18:05:11 -07:00
6 changed files with 39 additions and 21 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

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