diff --git a/src/Orchard/ContentManagement/DefaultContentDisplay.cs b/src/Orchard/ContentManagement/DefaultContentDisplay.cs index 76064b9ea..b042612e4 100644 --- a/src/Orchard/ContentManagement/DefaultContentDisplay.cs +++ b/src/Orchard/ContentManagement/DefaultContentDisplay.cs @@ -93,7 +93,12 @@ namespace Orchard.ContentManagement { dynamic itemShape = CreateItemShape(actualShapeType); itemShape.ContentItem = content.ContentItem; - var context = new UpdateEditorContext(itemShape, content, updater, groupInfoId, _shapeFactory); + var workContext = _workContextAccessor.GetContext(_requestContext.HttpContext); + + var theme = workContext.CurrentTheme; + var shapeTable = _shapeTableLocator.Value.Lookup(theme.Id); + + var context = new UpdateEditorContext(itemShape, content, updater, groupInfoId, _shapeFactory, shapeTable); BindPlacement(context, null, stereotype); _handlers.Value.Invoke(handler => handler.UpdateEditor(context), Logger); diff --git a/src/Orchard/ContentManagement/Drivers/ContentPartDriver.cs b/src/Orchard/ContentManagement/Drivers/ContentPartDriver.cs index eb343c40b..17beef8cc 100644 --- a/src/Orchard/ContentManagement/Drivers/ContentPartDriver.cs +++ b/src/Orchard/ContentManagement/Drivers/ContentPartDriver.cs @@ -4,6 +4,7 @@ using System.Globalization; using Orchard.ContentManagement.Handlers; using Orchard.ContentManagement.MetaData; using Orchard.DisplayManagement; +using Orchard.DisplayManagement.Descriptors; using Orchard.DisplayManagement.Shapes; namespace Orchard.ContentManagement.Drivers { @@ -55,6 +56,26 @@ namespace Orchard.ContentManagement.Drivers { return null; } + // checking if the editor needs to be updated (e.g. if it was not hidden) + var editor = Editor(part, context.New) as ContentShapeResult; + + if(editor != null) { + ShapeDescriptor descriptor; + if(context.ShapeTable.Descriptors.TryGetValue(editor.GetShapeType(), out descriptor)) { + var placementContext = new ShapePlacementContext { + ContentType = part.ContentItem.ContentType, + Differentiator = editor.GetDifferentiator(), + DisplayType = null + }; + + var location = descriptor.Placement(placementContext).Location; + + if(String.IsNullOrEmpty(location) || location == "-") { + return editor; + } + } + } + DriverResult result = Editor(part, context.Updater, context.New); if (result != null) { diff --git a/src/Orchard/ContentManagement/Handlers/UpdateEditorContext.cs b/src/Orchard/ContentManagement/Handlers/UpdateEditorContext.cs index f9408e2bf..47eee487e 100644 --- a/src/Orchard/ContentManagement/Handlers/UpdateEditorContext.cs +++ b/src/Orchard/ContentManagement/Handlers/UpdateEditorContext.cs @@ -1,12 +1,17 @@ using Orchard.DisplayManagement; +using Orchard.DisplayManagement.Descriptors; namespace Orchard.ContentManagement.Handlers { public class UpdateEditorContext : BuildEditorContext { - public UpdateEditorContext(IShape model, IContent content, IUpdateModel updater, string groupInfoId, IShapeFactory shapeFactory) + + public UpdateEditorContext(IShape model, IContent content, IUpdateModel updater, string groupInfoId, IShapeFactory shapeFactory, ShapeTable shapeTable) : base(model, content, groupInfoId, shapeFactory) { + + ShapeTable = shapeTable; Updater = updater; } public IUpdateModel Updater { get; private set; } + public ShapeTable ShapeTable { get; private set; } } } \ No newline at end of file