mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
@@ -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")) {
|
||||
|
Reference in New Issue
Block a user