From 6eb32a93df3c3874f6ab05213cdf43f7bf217a08 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Thu, 27 Aug 2015 11:30:52 -0700 Subject: [PATCH] Fixing ShapeDesigner Fixes #5647 --- .../Services/ShapeTracingFactory.cs | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/Orchard.Web/Modules/Orchard.DesignerTools/Services/ShapeTracingFactory.cs b/src/Orchard.Web/Modules/Orchard.DesignerTools/Services/ShapeTracingFactory.cs index ae80ad879..cec0f009a 100644 --- a/src/Orchard.Web/Modules/Orchard.DesignerTools/Services/ShapeTracingFactory.cs +++ b/src/Orchard.Web/Modules/Orchard.DesignerTools/Services/ShapeTracingFactory.cs @@ -2,7 +2,6 @@ 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; @@ -12,16 +11,15 @@ 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; @@ -33,7 +31,7 @@ namespace Orchard.DesignerTools.Services { IWebSiteFolder webSiteFolder, IAuthorizer authorizer ) { - _workContext = workContextAccessor.GetContext(); + _workContextAccessor = workContextAccessor; _shapeTableManager = shapeTableManager; _themeManager = themeManager; _webSiteFolder = webSiteFolder; @@ -41,13 +39,17 @@ 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; } @@ -76,7 +78,8 @@ namespace Orchard.DesignerTools.Services { && context.ShapeType != "DateTimeRelative") { var shapeMetadata = (ShapeMetadata)context.Shape.Metadata; - var currentTheme = _workContext.CurrentTheme; + var workContext = _workContextAccessor.GetContext(); + var currentTheme = workContext.CurrentTheme; var shapeTable = _shapeTableManager.GetShapeTable(currentTheme.Id); if (!shapeTable.Descriptors.ContainsKey(shapeMetadata.Type)) { @@ -99,7 +102,8 @@ namespace Orchard.DesignerTools.Services { var shape = context.Shape; var shapeMetadata = (ShapeMetadata) context.Shape.Metadata; - var currentTheme = _themeManager.GetRequestTheme(_workContext.HttpContext.Request.RequestContext); + var workContext = _workContextAccessor.GetContext(); + var currentTheme = _themeManager.GetRequestTheme(workContext.HttpContext.Request.RequestContext); var shapeTable = _shapeTableManager.GetShapeTable(currentTheme.Id); if (!shapeMetadata.Wrappers.Contains("ShapeTracingWrapper")) {