mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Merge branch 'dev' of https://github.com/OrchardCMS/Orchard into dev
This commit is contained in:
@@ -8,6 +8,7 @@ using Orchard.ContentManagement.MetaData;
|
|||||||
using Orchard.DisplayManagement;
|
using Orchard.DisplayManagement;
|
||||||
using Orchard.DisplayManagement.Descriptors;
|
using Orchard.DisplayManagement.Descriptors;
|
||||||
using Orchard.DisplayManagement.Shapes;
|
using Orchard.DisplayManagement.Shapes;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Orchard.ContentManagement.Drivers {
|
namespace Orchard.ContentManagement.Drivers {
|
||||||
public abstract class ContentPartDriver<TContent> : IContentPartDriver where TContent : ContentPart, new() {
|
public abstract class ContentPartDriver<TContent> : IContentPartDriver where TContent : ContentPart, new() {
|
||||||
@@ -58,42 +59,62 @@ namespace Orchard.ContentManagement.Drivers {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// checking if the editor needs to be updated (e.g. if it was not hidden)
|
// checking if the editor needs to be updated (e.g. if any of the shapes were not hidden)
|
||||||
var editor = Editor(part, context.New) as ContentShapeResult;
|
DriverResult editor = Editor(part, context.New);
|
||||||
|
IEnumerable<ContentShapeResult> contentShapeResults = GetShapeResults(editor);
|
||||||
|
|
||||||
|
if (contentShapeResults.Any(contentShapeResult => {
|
||||||
|
if (contentShapeResult == null) return true;
|
||||||
|
|
||||||
if (editor != null) {
|
|
||||||
ShapeDescriptor descriptor;
|
ShapeDescriptor descriptor;
|
||||||
if (context.ShapeTable.Descriptors.TryGetValue(editor.GetShapeType(), out descriptor)) {
|
if (context.ShapeTable.Descriptors.TryGetValue(contentShapeResult.GetShapeType(), out descriptor)) {
|
||||||
var placementContext = new ShapePlacementContext {
|
var placementContext = new ShapePlacementContext {
|
||||||
Content = part.ContentItem,
|
Content = part.ContentItem,
|
||||||
ContentType = part.ContentItem.ContentType,
|
ContentType = part.ContentItem.ContentType,
|
||||||
Differentiator = editor.GetDifferentiator(),
|
Differentiator = contentShapeResult.GetDifferentiator(),
|
||||||
DisplayType = null,
|
DisplayType = null,
|
||||||
Path = context.Path
|
Path = context.Path
|
||||||
};
|
};
|
||||||
|
|
||||||
var location = descriptor.Placement(placementContext).Location;
|
var placementInfo = descriptor.Placement(placementContext);
|
||||||
|
|
||||||
|
var location = placementInfo.Location;
|
||||||
|
|
||||||
if (String.IsNullOrEmpty(location) || location == "-") {
|
if (String.IsNullOrEmpty(location) || location == "-") {
|
||||||
return editor;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var editorGroup = editor.GetGroup() ?? "";
|
var editorGroup = editor.GetGroup();
|
||||||
|
if (string.IsNullOrEmpty(editorGroup)) {
|
||||||
|
editorGroup = placementInfo.GetGroup() ?? "";
|
||||||
|
}
|
||||||
var contextGroup = context.GroupId ?? "";
|
var contextGroup = context.GroupId ?? "";
|
||||||
|
|
||||||
if (!String.Equals(editorGroup, contextGroup, StringComparison.OrdinalIgnoreCase)) {
|
if (!String.Equals(editorGroup, contextGroup, StringComparison.OrdinalIgnoreCase)) {
|
||||||
return editor;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
})) {
|
||||||
|
DriverResult result = Editor(part, context.Updater, context.New);
|
||||||
|
|
||||||
|
if (result != null) {
|
||||||
|
result.ContentPart = part;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
DriverResult result = Editor(part, context.Updater, context.New);
|
return editor;
|
||||||
|
}
|
||||||
|
|
||||||
if (result != null) {
|
private static IEnumerable<ContentShapeResult> GetShapeResults(DriverResult driverResult) {
|
||||||
result.ContentPart = part;
|
if (driverResult is CombinedResult) {
|
||||||
|
return ((CombinedResult)driverResult).GetResults().Select(result => result as ContentShapeResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return new[] { driverResult as ContentShapeResult };
|
||||||
}
|
}
|
||||||
|
|
||||||
void IContentPartDriver.Importing(ImportContentContext context) {
|
void IContentPartDriver.Importing(ImportContentContext context) {
|
||||||
|
|||||||
Reference in New Issue
Block a user