--HG--
branch : dev
This commit is contained in:
Sebastien Ros
2011-02-25 13:36:14 -08:00
3 changed files with 8 additions and 6 deletions

View File

@@ -48,7 +48,7 @@ namespace Orchard.ContentManagement {
itemShape.Metadata.DisplayType = actualDisplayType;
var context = new BuildDisplayContext(itemShape, content, actualDisplayType, _shapeFactory);
BindPlacement(context, actualDisplayType);
BindPlacement(context, actualDisplayType, stereotype);
_handlers.Value.Invoke(handler => handler.BuildDisplay(context), Logger);
return context.Shape;
@@ -66,7 +66,7 @@ namespace Orchard.ContentManagement {
itemShape.ContentItem = content.ContentItem;
var context = new BuildEditorContext(itemShape, content, groupInfoId, _shapeFactory);
BindPlacement(context, null);
BindPlacement(context, null, stereotype);
_handlers.Value.Invoke(handler => handler.BuildEditor(context), Logger);
@@ -85,7 +85,7 @@ namespace Orchard.ContentManagement {
itemShape.ContentItem = content.ContentItem;
var context = new UpdateEditorContext(itemShape, content, updater, groupInfoId, _shapeFactory);
BindPlacement(context, null);
BindPlacement(context, null, stereotype);
_handlers.Value.Invoke(handler => handler.UpdateEditor(context), Logger);
@@ -97,7 +97,7 @@ namespace Orchard.ContentManagement {
return _shapeFactory.Create(actualShapeType, Arguments.Empty(), new[] { zoneHoldingBehavior });
}
private void BindPlacement(BuildShapeContext context, string displayType) {
private void BindPlacement(BuildShapeContext context, string displayType, string stereotype) {
context.FindPlacement = (partShapeType, differentiator, defaultLocation) => {
var theme = _themeService.Value.GetRequestTheme(_requestContext);
@@ -108,6 +108,7 @@ namespace Orchard.ContentManagement {
if (shapeTable.Descriptors.TryGetValue(partShapeType, out descriptor)) {
var placementContext = new ShapePlacementContext {
ContentType = context.ContentItem.ContentType,
Stereotype = stereotype,
DisplayType = displayType,
Differentiator = differentiator,
Path = VirtualPathUtility.AppendTrailingSlash(VirtualPathUtility.ToAppRelative(request.Path)) // get the current app-relative path, i.e. ~/my-blog/foo

View File

@@ -109,6 +109,7 @@ namespace Orchard.DisplayManagement.Descriptors {
public class ShapePlacementContext {
public string ContentType { get; set; }
public string Stereotype { get; set; }
public string DisplayType { get; set; }
public string Differentiator { get; set; }
public string Path { get; set; }

View File

@@ -98,9 +98,9 @@ namespace Orchard.DisplayManagement.Descriptors.ShapePlacementStrategy {
case "ContentType":
if (expression.EndsWith("*")) {
var prefix = expression.Substring(0, expression.Length - 1);
return ctx => (ctx.ContentType ?? "").StartsWith(prefix) && predicate(ctx);
return ctx => ((ctx.ContentType ?? "").StartsWith(prefix) || (ctx.Stereotype ?? "").StartsWith(prefix)) && predicate(ctx);
}
return ctx => (ctx.ContentType == expression) && predicate(ctx);
return ctx => ((ctx.ContentType == expression) || (ctx.Stereotype == expression)) && predicate(ctx);
case "DisplayType":
if (expression.EndsWith("*")) {
var prefix = expression.Substring(0, expression.Length - 1);