Fixing that Path Placement Matches couldn't be used for editor templates when being updated.

This commit is contained in:
Lombiq
2015-03-01 02:01:11 +01:00
committed by Zoltán Lehóczky
parent 27a01fb11e
commit 53cd06e63e
4 changed files with 23 additions and 8 deletions

View File

@@ -95,7 +95,7 @@ namespace Orchard.Layouts.Services {
// Adding an alternate for [Stereotype]_Edit__[ContentType] e.g. Content-Menu.Edit.
((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);
return context;
@@ -121,7 +121,7 @@ namespace Orchard.Layouts.Services {
Stereotype = stereotype,
DisplayType = displayType,
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
@@ -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));
}
}
}

View File

@@ -103,7 +103,7 @@ namespace Orchard.ContentManagement {
// adding an alternate for [Stereotype]_Edit__[ContentType] e.g. Content-Menu.Edit
((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);
_handlers.Value.Invoke(handler => handler.UpdateEditor(context), Logger);
@@ -123,8 +123,6 @@ namespace Orchard.ContentManagement {
var theme = workContext.CurrentTheme;
var shapeTable = _shapeTableLocator.Value.Lookup(theme.Id);
var request = _requestContext.HttpContext.Request;
ShapeDescriptor descriptor;
if (shapeTable.Descriptors.TryGetValue(partShapeType, out descriptor)) {
var placementContext = new ShapePlacementContext {
@@ -133,7 +131,7 @@ namespace Orchard.ContentManagement {
Stereotype = stereotype,
DisplayType = displayType,
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
@@ -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));
}
}
}

View File

@@ -69,7 +69,7 @@ namespace Orchard.ContentManagement.Drivers {
ContentType = part.ContentItem.ContentType,
Differentiator = editor.GetDifferentiator(),
DisplayType = null,
Path = String.Empty
Path = context.Path
};
var location = descriptor.Placement(placementContext).Location;

View File

@@ -4,14 +4,16 @@ using Orchard.DisplayManagement.Descriptors;
namespace Orchard.ContentManagement.Handlers {
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) {
ShapeTable = shapeTable;
Updater = updater;
Path = path;
}
public IUpdateModel Updater { get; private set; }
public ShapeTable ShapeTable { get; private set; }
public string Path { get; private set; }
}
}