mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
#21391: Fixed layout and shape rendering from background processes.
This commit is contained in:
@@ -109,9 +109,9 @@ namespace Orchard.Layouts.Services {
|
||||
private void BindPlacement(BuildShapeContext context, string displayType, string stereotype) {
|
||||
context.FindPlacement = (partShapeType, differentiator, defaultLocation) => {
|
||||
var workContext = _workContextAccessor.GetContext(_requestContext.HttpContext);
|
||||
var theme = workContext.CurrentTheme;
|
||||
var shapeTable = _shapeTableLocator.Value.Lookup(theme.Id);
|
||||
var request = _requestContext.HttpContext.Request;
|
||||
var shapeTable = workContext.HttpContext != null
|
||||
? _shapeTableLocator.Value.Lookup(workContext.CurrentTheme.Id)
|
||||
: _shapeTableLocator.Value.Lookup(null);
|
||||
|
||||
ShapeDescriptor descriptor;
|
||||
if (shapeTable.Descriptors.TryGetValue(partShapeType, out descriptor)) {
|
||||
|
||||
@@ -154,8 +154,7 @@ namespace Orchard.ContentManagement {
|
||||
/// <summary>
|
||||
/// Gets the current app-relative path, i.e. ~/my-blog/foo.
|
||||
/// </summary>
|
||||
private string GetPath()
|
||||
{
|
||||
private string GetPath() {
|
||||
return VirtualPathUtility.AppendTrailingSlash(_virtualPathProvider.ToAppRelative(_requestContext.HttpContext.Request.Path));
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -169,6 +169,8 @@ namespace Orchard.DisplayManagement.Descriptors.ShapeTemplateStrategy {
|
||||
context.ViewContext.ViewData = new ViewDataDictionary(context.Value);
|
||||
context.ViewContext.TempData = new TempDataDictionary();
|
||||
context.ViewContext.View = viewResult.View;
|
||||
context.ViewContext.RouteData = controllerContext.RouteData;
|
||||
context.ViewContext.RequestContext.RouteData = controllerContext.RouteData;
|
||||
viewResult.View.Render(context.ViewContext, sw);
|
||||
viewResult.ViewEngine.ReleaseView(controllerContext, viewResult.View);
|
||||
return new HtmlString(sw.GetStringBuilder().ToString());
|
||||
|
||||
@@ -83,7 +83,7 @@ namespace Orchard.Mvc {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// standin context for background tasks.
|
||||
/// Standin context for background tasks.
|
||||
/// </summary>
|
||||
class HttpContextPlaceholder : HttpContextBase {
|
||||
private readonly Lazy<string> _baseUrl;
|
||||
@@ -124,6 +124,12 @@ namespace Orchard.Mvc {
|
||||
public override string ApplyAppPathModifier(string virtualPath) {
|
||||
return virtualPath;
|
||||
}
|
||||
|
||||
public override HttpCookieCollection Cookies {
|
||||
get {
|
||||
return new HttpCookieCollection();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -158,7 +164,7 @@ namespace Orchard.Mvc {
|
||||
|
||||
public override NameValueCollection Headers {
|
||||
get {
|
||||
return new NameValueCollection {{"Host", _uri.Authority}};
|
||||
return new NameValueCollection { { "Host", _uri.Authority } };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,10 +190,44 @@ namespace Orchard.Mvc {
|
||||
}
|
||||
}
|
||||
|
||||
public override HttpCookieCollection Cookies {
|
||||
get {
|
||||
return new HttpCookieCollection();
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsLocal {
|
||||
get { return true; }
|
||||
}
|
||||
|
||||
public override string Path {
|
||||
get { return "/"; }
|
||||
}
|
||||
|
||||
public override string UserAgent {
|
||||
get {
|
||||
return "Placeholder";
|
||||
}
|
||||
}
|
||||
|
||||
public override HttpBrowserCapabilitiesBase Browser {
|
||||
get {
|
||||
return new HttpBrowserCapabilitiesPlaceholder();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class HttpBrowserCapabilitiesPlaceholder : HttpBrowserCapabilitiesBase {
|
||||
public override string this[string key] {
|
||||
get {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsMobileDevice { get { return false; } }
|
||||
public override string Browser { get { return "Placeholder"; } }
|
||||
public override bool Cookies { get { return true; } }
|
||||
public override ArrayList Browsers { get { return new ArrayList(); } }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user