mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Fixing that Path Placement Matches couldn't be used for editor templates when being updated.
This commit is contained in:
@@ -95,7 +95,7 @@ namespace Orchard.Layouts.Services {
|
|||||||
// Adding an alternate for [Stereotype]_Edit__[ContentType] e.g. Content-Menu.Edit.
|
// Adding an alternate for [Stereotype]_Edit__[ContentType] e.g. Content-Menu.Edit.
|
||||||
((IShape)itemShape).Metadata.Alternates.Add(actualShapeType + "__" + content.ContentItem.ContentType);
|
((IShape)itemShape).Metadata.Alternates.Add(actualShapeType + "__" + content.ContentItem.ContentType);
|
||||||
|
|
||||||
var context = new UpdateEditorContext(itemShape, content, updater, groupInfoId, _shapeFactory, shapeTable);
|
var context = new UpdateEditorContext(itemShape, content, updater, groupInfoId, _shapeFactory, shapeTable, GetPath());
|
||||||
BindPlacement(context, null, stereotype);
|
BindPlacement(context, null, stereotype);
|
||||||
|
|
||||||
return context;
|
return context;
|
||||||
@@ -121,7 +121,7 @@ namespace Orchard.Layouts.Services {
|
|||||||
Stereotype = stereotype,
|
Stereotype = stereotype,
|
||||||
DisplayType = displayType,
|
DisplayType = displayType,
|
||||||
Differentiator = differentiator,
|
Differentiator = differentiator,
|
||||||
Path = VirtualPathUtility.AppendTrailingSlash(_virtualPathProvider.ToAppRelative(request.Path)) // get the current app-relative path, i.e. ~/my-blog/foo
|
Path = GetPath()
|
||||||
};
|
};
|
||||||
|
|
||||||
// define which location should be used if none placement is hit
|
// define which location should be used if none placement is hit
|
||||||
@@ -140,5 +140,12 @@ namespace Orchard.Layouts.Services {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the current app-relative path, i.e. ~/my-blog/foo.
|
||||||
|
/// </summary>
|
||||||
|
private string GetPath() {
|
||||||
|
return VirtualPathUtility.AppendTrailingSlash(_virtualPathProvider.ToAppRelative(_requestContext.HttpContext.Request.Path));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -103,7 +103,7 @@ namespace Orchard.ContentManagement {
|
|||||||
// adding an alternate for [Stereotype]_Edit__[ContentType] e.g. Content-Menu.Edit
|
// adding an alternate for [Stereotype]_Edit__[ContentType] e.g. Content-Menu.Edit
|
||||||
((IShape)itemShape).Metadata.Alternates.Add(actualShapeType + "__" + content.ContentItem.ContentType);
|
((IShape)itemShape).Metadata.Alternates.Add(actualShapeType + "__" + content.ContentItem.ContentType);
|
||||||
|
|
||||||
var context = new UpdateEditorContext(itemShape, content, updater, groupInfoId, _shapeFactory, shapeTable);
|
var context = new UpdateEditorContext(itemShape, content, updater, groupInfoId, _shapeFactory, shapeTable, GetPath());
|
||||||
BindPlacement(context, null, stereotype);
|
BindPlacement(context, null, stereotype);
|
||||||
|
|
||||||
_handlers.Value.Invoke(handler => handler.UpdateEditor(context), Logger);
|
_handlers.Value.Invoke(handler => handler.UpdateEditor(context), Logger);
|
||||||
@@ -123,8 +123,6 @@ namespace Orchard.ContentManagement {
|
|||||||
var theme = workContext.CurrentTheme;
|
var theme = workContext.CurrentTheme;
|
||||||
var shapeTable = _shapeTableLocator.Value.Lookup(theme.Id);
|
var shapeTable = _shapeTableLocator.Value.Lookup(theme.Id);
|
||||||
|
|
||||||
var request = _requestContext.HttpContext.Request;
|
|
||||||
|
|
||||||
ShapeDescriptor descriptor;
|
ShapeDescriptor descriptor;
|
||||||
if (shapeTable.Descriptors.TryGetValue(partShapeType, out descriptor)) {
|
if (shapeTable.Descriptors.TryGetValue(partShapeType, out descriptor)) {
|
||||||
var placementContext = new ShapePlacementContext {
|
var placementContext = new ShapePlacementContext {
|
||||||
@@ -133,7 +131,7 @@ namespace Orchard.ContentManagement {
|
|||||||
Stereotype = stereotype,
|
Stereotype = stereotype,
|
||||||
DisplayType = displayType,
|
DisplayType = displayType,
|
||||||
Differentiator = differentiator,
|
Differentiator = differentiator,
|
||||||
Path = VirtualPathUtility.AppendTrailingSlash(_virtualPathProvider.ToAppRelative(request.Path)) // get the current app-relative path, i.e. ~/my-blog/foo
|
Path = GetPath()
|
||||||
};
|
};
|
||||||
|
|
||||||
// define which location should be used if none placement is hit
|
// define which location should be used if none placement is hit
|
||||||
@@ -152,5 +150,13 @@ namespace Orchard.ContentManagement {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the current app-relative path, i.e. ~/my-blog/foo.
|
||||||
|
/// </summary>
|
||||||
|
private string GetPath()
|
||||||
|
{
|
||||||
|
return VirtualPathUtility.AppendTrailingSlash(_virtualPathProvider.ToAppRelative(_requestContext.HttpContext.Request.Path));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -69,7 +69,7 @@ namespace Orchard.ContentManagement.Drivers {
|
|||||||
ContentType = part.ContentItem.ContentType,
|
ContentType = part.ContentItem.ContentType,
|
||||||
Differentiator = editor.GetDifferentiator(),
|
Differentiator = editor.GetDifferentiator(),
|
||||||
DisplayType = null,
|
DisplayType = null,
|
||||||
Path = String.Empty
|
Path = context.Path
|
||||||
};
|
};
|
||||||
|
|
||||||
var location = descriptor.Placement(placementContext).Location;
|
var location = descriptor.Placement(placementContext).Location;
|
||||||
|
@@ -4,14 +4,16 @@ using Orchard.DisplayManagement.Descriptors;
|
|||||||
namespace Orchard.ContentManagement.Handlers {
|
namespace Orchard.ContentManagement.Handlers {
|
||||||
public class UpdateEditorContext : BuildEditorContext {
|
public class UpdateEditorContext : BuildEditorContext {
|
||||||
|
|
||||||
public UpdateEditorContext(IShape model, IContent content, IUpdateModel updater, string groupInfoId, IShapeFactory shapeFactory, ShapeTable shapeTable)
|
public UpdateEditorContext(IShape model, IContent content, IUpdateModel updater, string groupInfoId, IShapeFactory shapeFactory, ShapeTable shapeTable, string path)
|
||||||
: base(model, content, groupInfoId, shapeFactory) {
|
: base(model, content, groupInfoId, shapeFactory) {
|
||||||
|
|
||||||
ShapeTable = shapeTable;
|
ShapeTable = shapeTable;
|
||||||
Updater = updater;
|
Updater = updater;
|
||||||
|
Path = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IUpdateModel Updater { get; private set; }
|
public IUpdateModel Updater { get; private set; }
|
||||||
public ShapeTable ShapeTable { get; private set; }
|
public ShapeTable ShapeTable { get; private set; }
|
||||||
|
public string Path { get; private set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user