mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Adding WorkContext to view pages
Including in IOrchardViewPage to ensure it's present in all locations --HG-- branch : theming
This commit is contained in:
@@ -10,5 +10,6 @@ namespace Orchard.Mvc {
|
||||
Localizer T { get; }
|
||||
dynamic Display { get; }
|
||||
IHtmlString DisplayChildren(object shape);
|
||||
WorkContext WorkContext { get; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -13,10 +13,12 @@ namespace Orchard.Mvc.ViewEngines.Razor {
|
||||
private object _display;
|
||||
private object _new;
|
||||
private Localizer _localizer = NullLocalizer.Instance;
|
||||
private WorkContext _workContext;
|
||||
|
||||
|
||||
public Localizer T { get { return _localizer; } }
|
||||
public dynamic Display { get { return _display; } }
|
||||
public WorkContext WorkContext { get { return _workContext; } }
|
||||
|
||||
|
||||
public dynamic New { get { return _new; } }
|
||||
@@ -28,8 +30,8 @@ namespace Orchard.Mvc.ViewEngines.Razor {
|
||||
public override void InitHelpers() {
|
||||
base.InitHelpers();
|
||||
|
||||
var workContext = ViewContext.GetWorkContext();
|
||||
workContext.Resolve<IComponentContext>().InjectUnsetProperties(this);
|
||||
_workContext = ViewContext.GetWorkContext();
|
||||
_workContext.Resolve<IComponentContext>().InjectUnsetProperties(this);
|
||||
|
||||
_localizer = LocalizationUtilities.Resolve(ViewContext, VirtualPath);
|
||||
_display = DisplayHelperFactory.CreateHelper(ViewContext, this);
|
||||
@@ -48,6 +50,7 @@ namespace Orchard.Mvc.ViewEngines.Razor {
|
||||
}
|
||||
return writer;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public abstract class WebViewPage : WebViewPage<dynamic> {
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using System.Web;
|
||||
using System;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using Autofac;
|
||||
using Orchard.DisplayManagement;
|
||||
@@ -13,9 +14,11 @@ namespace Orchard.Mvc {
|
||||
public class ViewPage<TModel> : System.Web.Mvc.ViewPage<TModel>, IOrchardViewPage {
|
||||
private object _display;
|
||||
private Localizer _localizer = NullLocalizer.Instance;
|
||||
private WorkContext _workContext;
|
||||
|
||||
public Localizer T { get { return _localizer; } }
|
||||
public dynamic Display { get { return _display; } }
|
||||
public WorkContext WorkContext { get { return _workContext; } }
|
||||
public IDisplayHelperFactory DisplayHelperFactory { get; set; }
|
||||
|
||||
public IAuthorizer Authorizer { get; set; }
|
||||
@@ -23,8 +26,8 @@ namespace Orchard.Mvc {
|
||||
public override void InitHelpers() {
|
||||
base.InitHelpers();
|
||||
|
||||
var workContext = ViewContext.GetWorkContext();
|
||||
workContext.Resolve<IComponentContext>().InjectUnsetProperties(this);
|
||||
_workContext = ViewContext.GetWorkContext();
|
||||
_workContext.Resolve<IComponentContext>().InjectUnsetProperties(this);
|
||||
|
||||
_localizer = LocalizationUtilities.Resolve(ViewContext, AppRelativeVirtualPath);
|
||||
_display = DisplayHelperFactory.CreateHelper(ViewContext, this);
|
||||
@@ -45,6 +48,7 @@ namespace Orchard.Mvc {
|
||||
}
|
||||
return writer;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class ViewPage : ViewPage<dynamic> {
|
||||
|
@@ -12,18 +12,20 @@ namespace Orchard.Mvc {
|
||||
private object _display;
|
||||
private object _new;
|
||||
private Localizer _localizer = NullLocalizer.Instance;
|
||||
private WorkContext _workContext;
|
||||
|
||||
public Localizer T { get { return _localizer; } }
|
||||
public dynamic Display { get { return _display; } }
|
||||
public dynamic New { get { return _new; } }
|
||||
public WorkContext WorkContext { get { return _workContext; } }
|
||||
public IDisplayHelperFactory DisplayHelperFactory { get; set; }
|
||||
public IShapeHelperFactory ShapeHelperFactory { get; set; }
|
||||
|
||||
public IAuthorizer Authorizer { get; set; }
|
||||
|
||||
public override void RenderView(ViewContext viewContext) {
|
||||
var workContext = viewContext.GetWorkContext();
|
||||
workContext.Resolve<IComponentContext>().InjectUnsetProperties(this);
|
||||
_workContext = viewContext.GetWorkContext();
|
||||
_workContext.Resolve<IComponentContext>().InjectUnsetProperties(this);
|
||||
|
||||
_localizer = LocalizationUtilities.Resolve(viewContext, AppRelativeVirtualPath);
|
||||
_display = DisplayHelperFactory.CreateHelper(viewContext, this);
|
||||
|
Reference in New Issue
Block a user