mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-26 20:16:15 +08:00
DisplayManagement: Fixing that stylesheets that don't exist shouldn't create shapes (#8199)
This commit is contained in:
committed by
Benedek Farkas
parent
b64280174c
commit
ecc089a7a6
@@ -92,16 +92,29 @@ namespace Orchard.DisplayManagement.Descriptors.ResourceBindingStrategy {
|
||||
var shape = ((dynamic)displayContext.Value);
|
||||
var output = displayContext.ViewContext.Writer;
|
||||
ResourceDefinition resource = shape.Resource;
|
||||
string url = shape.Url;
|
||||
var url = GetResourceUrl(shape.Url, hit.fileVirtualPath);
|
||||
string condition = shape.Condition;
|
||||
Dictionary<string, string> attributes = shape.TagAttributes;
|
||||
ResourceManager.WriteResource(output, resource, url ?? hit.fileVirtualPath, condition, attributes);
|
||||
ResourceManager.WriteResource(output, resource, url, condition, attributes);
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string GetResourceUrl(string shapeUrl, string fileVirtualPath) {
|
||||
if (string.IsNullOrEmpty(shapeUrl)) return fileVirtualPath;
|
||||
|
||||
return GetPathFromRelativeUrl(shapeUrl) == GetPathFromRelativeUrl(fileVirtualPath) ? shapeUrl : fileVirtualPath;
|
||||
}
|
||||
|
||||
private string GetPathFromRelativeUrl(string url) {
|
||||
var path = url.TrimStart('~');
|
||||
var indexOfQueryString = path.IndexOf('?');
|
||||
|
||||
return indexOfQueryString >= 0 ? path.Substring(0, indexOfQueryString) : path;
|
||||
}
|
||||
|
||||
private bool FeatureIsEnabled(FeatureDescriptor fd) {
|
||||
return (DefaultExtensionTypes.IsTheme(fd.Extension.ExtensionType) && (fd.Id == "TheAdmin" || fd.Id == "SafeMode")) ||
|
||||
_shellDescriptor.Features.Any(sf => sf.Name == fd.Id);
|
||||
|
||||
Reference in New Issue
Block a user