mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-21 11:17:28 +08:00
Merge
--HG-- branch : dev
This commit is contained in:
@@ -37,6 +37,7 @@
|
|||||||
Definition: @descriptor.BindingSource <br />
|
Definition: @descriptor.BindingSource <br />
|
||||||
Display Type: @(Model.Metadata.DisplayType ?? "n/a")<br />
|
Display Type: @(Model.Metadata.DisplayType ?? "n/a")<br />
|
||||||
Position: @(Model.Metadata.Position ?? "n/a") <br />
|
Position: @(Model.Metadata.Position ?? "n/a") <br />
|
||||||
|
Placement Source: @(Model.Metadata.PlacementSource ?? "n/a") <br />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="alternates">
|
<div class="alternates">
|
||||||
|
@@ -112,10 +112,19 @@ namespace Orchard.ContentManagement {
|
|||||||
Differentiator = differentiator,
|
Differentiator = differentiator,
|
||||||
Path = VirtualPathUtility.AppendTrailingSlash(VirtualPathUtility.ToAppRelative(request.Path)) // get the current app-relative path, i.e. ~/my-blog/foo
|
Path = VirtualPathUtility.AppendTrailingSlash(VirtualPathUtility.ToAppRelative(request.Path)) // get the current app-relative path, i.e. ~/my-blog/foo
|
||||||
};
|
};
|
||||||
|
|
||||||
var location = descriptor.Placement(placementContext);
|
var location = descriptor.Placement(placementContext);
|
||||||
return location ?? defaultLocation;
|
if (location != null) {
|
||||||
|
return new PlacementInfo {
|
||||||
|
Location = location,
|
||||||
|
Source = placementContext.Source
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return defaultLocation;
|
return new PlacementInfo {
|
||||||
|
Location = defaultLocation,
|
||||||
|
Source = String.Empty
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,8 +25,8 @@ namespace Orchard.ContentManagement.Drivers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void ApplyImplementation(BuildShapeContext context, string displayType) {
|
private void ApplyImplementation(BuildShapeContext context, string displayType) {
|
||||||
var location = context.FindPlacement(_shapeType, _differentiator, _defaultLocation);
|
var placement = context.FindPlacement(_shapeType, _differentiator, _defaultLocation);
|
||||||
if (string.IsNullOrEmpty(location) || location == "-")
|
if (string.IsNullOrEmpty(placement.Location) || placement.Location == "-")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
dynamic parentShape = context.Shape;
|
dynamic parentShape = context.Shape;
|
||||||
@@ -34,14 +34,15 @@ namespace Orchard.ContentManagement.Drivers {
|
|||||||
ShapeMetadata newShapeMetadata = newShape.Metadata;
|
ShapeMetadata newShapeMetadata = newShape.Metadata;
|
||||||
newShapeMetadata.Prefix = _prefix;
|
newShapeMetadata.Prefix = _prefix;
|
||||||
newShapeMetadata.DisplayType = displayType;
|
newShapeMetadata.DisplayType = displayType;
|
||||||
|
newShapeMetadata.PlacementSource = placement.Source;
|
||||||
|
|
||||||
var delimiterIndex = location.IndexOf(':');
|
var delimiterIndex = placement.Location.IndexOf(':');
|
||||||
if (delimiterIndex < 0) {
|
if (delimiterIndex < 0) {
|
||||||
parentShape.Zones[location].Add(newShape);
|
parentShape.Zones[placement.Location].Add(newShape);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var zoneName = location.Substring(0, delimiterIndex);
|
var zoneName = placement.Location.Substring(0, delimiterIndex);
|
||||||
var position = location.Substring(delimiterIndex + 1);
|
var position = placement.Location.Substring(delimiterIndex + 1);
|
||||||
parentShape.Zones[zoneName].Add(newShape, position);
|
parentShape.Zones[zoneName].Add(newShape, position);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using Orchard.DisplayManagement;
|
using Orchard.DisplayManagement;
|
||||||
|
using Orchard.DisplayManagement.Descriptors;
|
||||||
|
using Orchard.DisplayManagement.Descriptors.ShapePlacementStrategy;
|
||||||
|
|
||||||
namespace Orchard.ContentManagement.Handlers {
|
namespace Orchard.ContentManagement.Handlers {
|
||||||
public class BuildShapeContext {
|
public class BuildShapeContext {
|
||||||
@@ -7,13 +9,13 @@ namespace Orchard.ContentManagement.Handlers {
|
|||||||
Shape = shape;
|
Shape = shape;
|
||||||
ContentItem = content.ContentItem;
|
ContentItem = content.ContentItem;
|
||||||
New = shapeFactory;
|
New = shapeFactory;
|
||||||
FindPlacement = (partType, differentiator, defaultLocation) => defaultLocation;
|
FindPlacement = (partType, differentiator, defaultLocation) => new PlacementInfo {Location = defaultLocation, Source = String.Empty};
|
||||||
}
|
}
|
||||||
|
|
||||||
public dynamic Shape { get; private set; }
|
public dynamic Shape { get; private set; }
|
||||||
public ContentItem ContentItem { get; private set; }
|
public ContentItem ContentItem { get; private set; }
|
||||||
public dynamic New { get; private set; }
|
public dynamic New { get; private set; }
|
||||||
|
|
||||||
public Func<string, string, string, string> FindPlacement { get; set; }
|
public Func<string, string, string, PlacementInfo> FindPlacement { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Orchard.DisplayManagement.Descriptors {
|
||||||
|
public class PlacementInfo {
|
||||||
|
public string Location { get; set; }
|
||||||
|
public string Source { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@@ -112,5 +112,6 @@ namespace Orchard.DisplayManagement.Descriptors {
|
|||||||
public string DisplayType { get; set; }
|
public string DisplayType { get; set; }
|
||||||
public string Differentiator { get; set; }
|
public string Differentiator { get; set; }
|
||||||
public string Path { get; set; }
|
public string Path { get; set; }
|
||||||
|
public string Source { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -65,12 +65,20 @@ namespace Orchard.DisplayManagement.Descriptors.ShapePlacementStrategy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (matches.Any()) {
|
if (matches.Any()) {
|
||||||
predicate = matches.SelectMany(match => match.Terms).Aggregate(predicate, BuildPredicate);
|
predicate = matches.SelectMany(match => match.Terms).Aggregate(predicate, BuildPredicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.Describe(shapeType)
|
builder.Describe(shapeType)
|
||||||
.From(feature)
|
.From(feature)
|
||||||
.Placement(predicate, shapeLocation.Location);
|
.Placement(ctx => {
|
||||||
|
var hit = predicate(ctx);
|
||||||
|
// generate 'debugging' information to trace which file originated the actual location
|
||||||
|
if (hit) {
|
||||||
|
var virtualPath = featureDescriptor.Extension.Location + "/" + featureDescriptor.Extension.Id + "/Placement.info";
|
||||||
|
ctx.Source = virtualPath;
|
||||||
|
}
|
||||||
|
return hit;
|
||||||
|
}, shapeLocation.Location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,6 +16,7 @@ namespace Orchard.DisplayManagement.Shapes {
|
|||||||
public string Type { get; set; }
|
public string Type { get; set; }
|
||||||
public string DisplayType { get; set; }
|
public string DisplayType { get; set; }
|
||||||
public string Position { get; set; }
|
public string Position { get; set; }
|
||||||
|
public string PlacementSource { get; set; }
|
||||||
public string Prefix { get; set; }
|
public string Prefix { get; set; }
|
||||||
public IList<string> Wrappers { get; set; }
|
public IList<string> Wrappers { get; set; }
|
||||||
public IList<string> Alternates { get; set; }
|
public IList<string> Alternates { get; set; }
|
||||||
|
@@ -158,6 +158,7 @@
|
|||||||
<Compile Include="ContentManagement\Handlers\BuildShapeContext.cs" />
|
<Compile Include="ContentManagement\Handlers\BuildShapeContext.cs" />
|
||||||
<Compile Include="ContentManagement\IContentBehavior.cs" />
|
<Compile Include="ContentManagement\IContentBehavior.cs" />
|
||||||
<Compile Include="ContentManagement\Utilities\ComputedField.cs" />
|
<Compile Include="ContentManagement\Utilities\ComputedField.cs" />
|
||||||
|
<Compile Include="DisplayManagement\Descriptors\PlacementInfo.cs" />
|
||||||
<Compile Include="DisplayManagement\Descriptors\ResourceBindingStrategy\StylesheetBindingStrategy.cs" />
|
<Compile Include="DisplayManagement\Descriptors\ResourceBindingStrategy\StylesheetBindingStrategy.cs" />
|
||||||
<Compile Include="DisplayManagement\Descriptors\ShapeDescriptor.cs" />
|
<Compile Include="DisplayManagement\Descriptors\ShapeDescriptor.cs" />
|
||||||
<Compile Include="DisplayManagement\Descriptors\ShapeAlteration.cs" />
|
<Compile Include="DisplayManagement\Descriptors\ShapeAlteration.cs" />
|
||||||
|
Reference in New Issue
Block a user