Revert "Fixing ShapeDesigner"

This reverts commit 6eb32a93df.
This commit is contained in:
Sebastien Ros
2015-09-04 16:20:02 -07:00
parent a1d06ec89e
commit 3f5c6e49ef

View File

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