mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-12-22 03:57:14 +08:00
7919: The Alias UI links for sites using UrlPrefix are broken (#7930)
* AliasUI: removing UrlPrefix addition to url. Fixing issue in Href() that strips first / in urls for sites using UrlPrefix * Simplifying fix for WebViewPage.Href for tenants with URL prefix * Code styling WebViewPage --------- Co-authored-by: Benedek Farkas <benedek.farkas@lombiq.com>
This commit is contained in:
@@ -6,8 +6,6 @@
|
|||||||
@using Orchard.Utility.Extensions
|
@using Orchard.Utility.Extensions
|
||||||
|
|
||||||
@{
|
@{
|
||||||
var urlPrefix = WorkContext.Resolve<ShellSettings>().RequestUrlPrefix;
|
|
||||||
|
|
||||||
Layout.Title = T("Manage Aliases").Text;
|
Layout.Title = T("Manage Aliases").Text;
|
||||||
var aliasService = WorkContext.Resolve<IAliasService>();
|
var aliasService = WorkContext.Resolve<IAliasService>();
|
||||||
AdminIndexOptions options = Model.Options;
|
AdminIndexOptions options = Model.Options;
|
||||||
@@ -59,10 +57,10 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<input type="hidden" value="@alias.Path" name="@Html.FieldNameFor(m => Model.AliasEntries[index].Alias.Path)" />
|
<input type="hidden" value="@alias.Path" name="@Html.FieldNameFor(m => Model.AliasEntries[index].Alias.Path)" />
|
||||||
@Html.Link(alias.Path == String.Empty ? "/" : alias.Path, Href("~/" + urlPrefix + alias.Path))
|
@Html.Link(alias.Path == String.Empty ? "/" : alias.Path, Href("~/" + alias.Path))
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@Html.Link(url, Href("~/" + urlPrefix + "/" + url))
|
@Html.Link(url, Href("~/" + url))
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,6 @@
|
|||||||
@using Orchard.Utility.Extensions
|
@using Orchard.Utility.Extensions
|
||||||
|
|
||||||
@{
|
@{
|
||||||
var urlPrefix = WorkContext.Resolve<ShellSettings>().RequestUrlPrefix;
|
|
||||||
|
|
||||||
Layout.Title = T("Manage Aliases").Text;
|
Layout.Title = T("Manage Aliases").Text;
|
||||||
var aliasService = WorkContext.Resolve<IAliasService>();
|
var aliasService = WorkContext.Resolve<IAliasService>();
|
||||||
AdminIndexOptions options = Model.Options;
|
AdminIndexOptions options = Model.Options;
|
||||||
@@ -73,10 +71,10 @@
|
|||||||
<input type="checkbox" value="true" name="@Html.FieldNameFor(m => Model.AliasEntries[index].IsChecked)" />
|
<input type="checkbox" value="true" name="@Html.FieldNameFor(m => Model.AliasEntries[index].IsChecked)" />
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@Html.Link(alias.Path == String.Empty ? "/" : alias.Path, Href("~/" + urlPrefix + alias.Path))
|
@Html.Link(alias.Path == String.Empty ? "/" : alias.Path, Href("~/" + alias.Path))
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@Html.Link(url, Href("~/" + urlPrefix + "/" + url))
|
@Html.Link(url, Href("~/" + url))
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
@Html.ActionLink(T("Edit").Text, "Edit", new { path = alias.Path == String.Empty ? "/" : alias.Path })@T(" | ")
|
@Html.ActionLink(T("Edit").Text, "Edit", new { path = alias.Path == String.Empty ? "/" : alias.Path })@T(" | ")
|
||||||
|
|||||||
@@ -23,22 +23,22 @@ namespace Orchard.Mvc.ViewEngines.Razor {
|
|||||||
private object _display;
|
private object _display;
|
||||||
private object _layout;
|
private object _layout;
|
||||||
|
|
||||||
public Localizer T {
|
public Localizer T {
|
||||||
get {
|
get {
|
||||||
// first time used, create it
|
// first time used, create it
|
||||||
if(_localizer == NullLocalizer.Instance) {
|
if (_localizer == NullLocalizer.Instance) {
|
||||||
|
|
||||||
// if the Model is a shape, get localization scopes from binding sources
|
// if the Model is a shape, get localization scopes from binding sources
|
||||||
// e.g., Logon.cshtml in a theme, overriging Users/Logon.cshtml, needs T to
|
// e.g., Logon.cshtml in a theme, overriging Users/Logon.cshtml, needs T to
|
||||||
// fallback to the one in Users
|
// fallback to the one in Users
|
||||||
var shape = Model as IShape;
|
var shape = Model as IShape;
|
||||||
if(shape != null && shape.Metadata.BindingSources.Count > 1) {
|
if (shape != null && shape.Metadata.BindingSources.Count > 1) {
|
||||||
var localizers = shape.Metadata.BindingSources.Reverse().Select(scope => LocalizationUtilities.Resolve(ViewContext, scope)).ToList();
|
var localizers = shape.Metadata.BindingSources.Reverse().Select(scope => LocalizationUtilities.Resolve(ViewContext, scope)).ToList();
|
||||||
_localizer = (text, args) => {
|
_localizer = (text, args) => {
|
||||||
foreach(var localizer in localizers) {
|
foreach (var localizer in localizers) {
|
||||||
var hint = localizer(text, args);
|
var hint = localizer(text, args);
|
||||||
// if not localized using this scope, use next scope
|
// if not localized using this scope, use next scope
|
||||||
if(hint.Text != text) {
|
if (hint.Text != text) {
|
||||||
return hint;
|
return hint;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,7 +54,7 @@ namespace Orchard.Mvc.ViewEngines.Razor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return _localizer;
|
return _localizer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public dynamic Display { get { return _display; } }
|
public dynamic Display { get { return _display; } }
|
||||||
@@ -79,7 +79,7 @@ namespace Orchard.Mvc.ViewEngines.Razor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private IAuthorizer _authorizer;
|
private IAuthorizer _authorizer;
|
||||||
public IAuthorizer Authorizer {
|
public IAuthorizer Authorizer {
|
||||||
get {
|
get {
|
||||||
return _authorizer ?? (_authorizer = WorkContext.Resolve<IAuthorizer>());
|
return _authorizer ?? (_authorizer = WorkContext.Resolve<IAuthorizer>());
|
||||||
}
|
}
|
||||||
@@ -114,7 +114,7 @@ namespace Orchard.Mvc.ViewEngines.Razor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private string[] _commonLocations;
|
private string[] _commonLocations;
|
||||||
public string[] CommonLocations { get { return _commonLocations ?? (_commonLocations = WorkContext.Resolve<ExtensionLocations>().CommonLocations); } }
|
public string[] CommonLocations { get { return _commonLocations ?? (_commonLocations = WorkContext.Resolve<ExtensionLocations>().CommonLocations); } }
|
||||||
|
|
||||||
public void RegisterImageSet(string imageSet, string style = "", int size = 16) {
|
public void RegisterImageSet(string imageSet, string style = "", int size = 16) {
|
||||||
// hack to fake the style "alternate" for now so we don't have to change stylesheet names when this is hooked up
|
// hack to fake the style "alternate" for now so we don't have to change stylesheet names when this is hooked up
|
||||||
@@ -150,7 +150,7 @@ namespace Orchard.Mvc.ViewEngines.Razor {
|
|||||||
base.InitHelpers();
|
base.InitHelpers();
|
||||||
|
|
||||||
WorkContext = ViewContext.GetWorkContext();
|
WorkContext = ViewContext.GetWorkContext();
|
||||||
|
|
||||||
_display = DisplayHelperFactory.CreateHelper(ViewContext, this);
|
_display = DisplayHelperFactory.CreateHelper(ViewContext, this);
|
||||||
_layout = WorkContext.Layout;
|
_layout = WorkContext.Layout;
|
||||||
}
|
}
|
||||||
@@ -190,11 +190,10 @@ namespace Orchard.Mvc.ViewEngines.Razor {
|
|||||||
_tenantPrefix = WorkContext.Resolve<ShellSettings>().RequestUrlPrefix ?? "";
|
_tenantPrefix = WorkContext.Resolve<ShellSettings>().RequestUrlPrefix ?? "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!String.IsNullOrEmpty(_tenantPrefix)
|
if (!string.IsNullOrWhiteSpace(_tenantPrefix)
|
||||||
&& path.StartsWith("~/")
|
&& path.StartsWith("~/")
|
||||||
&& !CommonLocations.Any(gpp=>path.StartsWith(gpp, StringComparison.OrdinalIgnoreCase))
|
&& !CommonLocations.Any(gpp => path.StartsWith(gpp, StringComparison.OrdinalIgnoreCase))) {
|
||||||
) {
|
return base.Href("~/" + _tenantPrefix + path.Substring(1), pathParts);
|
||||||
return base.Href("~/" + _tenantPrefix + path.Substring(2), pathParts);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return base.Href(path, pathParts);
|
return base.Href(path, pathParts);
|
||||||
|
|||||||
Reference in New Issue
Block a user