mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 03:25:23 +08:00
@@ -2,6 +2,7 @@
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web.Routing;
|
||||
using System.Xml.Linq;
|
||||
using Orchard.DisplayManagement.Descriptors;
|
||||
using Orchard.DisplayManagement.Implementation;
|
||||
using Orchard.DisplayManagement.Shapes;
|
||||
@@ -11,15 +12,16 @@ using Orchard.Security;
|
||||
using Orchard.Themes;
|
||||
using Orchard.UI;
|
||||
using Orchard.UI.Admin;
|
||||
using System.Web;
|
||||
|
||||
namespace Orchard.DesignerTools.Services {
|
||||
[OrchardFeature("Orchard.DesignerTools")]
|
||||
public class ShapeTracingFactory : IShapeFactoryEvents, IShapeDisplayEvents {
|
||||
private readonly WorkContext _workContext;
|
||||
private readonly IShapeTableManager _shapeTableManager;
|
||||
private readonly IThemeManager _themeManager;
|
||||
private readonly IWebSiteFolder _webSiteFolder;
|
||||
private readonly IAuthorizer _authorizer;
|
||||
private readonly IWorkContextAccessor _workContextAccessor;
|
||||
private bool _processing;
|
||||
|
||||
private int _shapeId;
|
||||
@@ -31,7 +33,7 @@ namespace Orchard.DesignerTools.Services {
|
||||
IWebSiteFolder webSiteFolder,
|
||||
IAuthorizer authorizer
|
||||
) {
|
||||
_workContextAccessor = workContextAccessor;
|
||||
_workContext = workContextAccessor.GetContext();
|
||||
_shapeTableManager = shapeTableManager;
|
||||
_themeManager = themeManager;
|
||||
_webSiteFolder = webSiteFolder;
|
||||
@@ -39,17 +41,13 @@ namespace Orchard.DesignerTools.Services {
|
||||
}
|
||||
|
||||
private bool IsActivable() {
|
||||
var workContext = _workContextAccessor.GetContext();
|
||||
|
||||
// activate on front-end only
|
||||
if (AdminFilter.IsApplied(new RequestContext(workContext.HttpContext, new RouteData())))
|
||||
if (AdminFilter.IsApplied(new RequestContext(_workContext.HttpContext, new RouteData())))
|
||||
return false;
|
||||
|
||||
// if not logged as a site owner, still activate if it's a local request (development machine)
|
||||
if (!_authorizer.Authorize(StandardPermissions.SiteOwner)) {
|
||||
|
||||
return workContext.HttpContext.Request.IsLocal;
|
||||
}
|
||||
if (!_authorizer.Authorize(StandardPermissions.SiteOwner))
|
||||
return _workContext.HttpContext.Request.IsLocal;
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -78,8 +76,7 @@ namespace Orchard.DesignerTools.Services {
|
||||
&& context.ShapeType != "DateTimeRelative") {
|
||||
|
||||
var shapeMetadata = (ShapeMetadata)context.Shape.Metadata;
|
||||
var workContext = _workContextAccessor.GetContext();
|
||||
var currentTheme = workContext.CurrentTheme;
|
||||
var currentTheme = _workContext.CurrentTheme;
|
||||
var shapeTable = _shapeTableManager.GetShapeTable(currentTheme.Id);
|
||||
|
||||
if (!shapeTable.Descriptors.ContainsKey(shapeMetadata.Type)) {
|
||||
@@ -102,8 +99,7 @@ namespace Orchard.DesignerTools.Services {
|
||||
|
||||
var shape = context.Shape;
|
||||
var shapeMetadata = (ShapeMetadata) context.Shape.Metadata;
|
||||
var workContext = _workContextAccessor.GetContext();
|
||||
var currentTheme = _themeManager.GetRequestTheme(workContext.HttpContext.Request.RequestContext);
|
||||
var currentTheme = _themeManager.GetRequestTheme(_workContext.HttpContext.Request.RequestContext);
|
||||
var shapeTable = _shapeTableManager.GetShapeTable(currentTheme.Id);
|
||||
|
||||
if (!shapeMetadata.Wrappers.Contains("ShapeTracingWrapper")) {
|
||||
|
Reference in New Issue
Block a user