mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Fixed handling of multiple URL hosts in multi tenancy UI.
This commit is contained in:
@@ -1,26 +1,30 @@
|
|||||||
using System.Web.Mvc;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web.Mvc;
|
||||||
using Orchard.Environment.Configuration;
|
using Orchard.Environment.Configuration;
|
||||||
|
|
||||||
namespace Orchard.MultiTenancy.Extensions {
|
namespace Orchard.MultiTenancy.Extensions {
|
||||||
public static class UrlHelperExtensions {
|
public static class UrlHelperExtensions {
|
||||||
public static string Tenant(this UrlHelper urlHelper, ShellSettings tenantShellSettings) {
|
public static string Tenant(this UrlHelper urlHelper, ShellSettings tenantShellSettings) {
|
||||||
|
|
||||||
|
var requestUrlHost = tenantShellSettings.RequestUrlHost.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries).First();
|
||||||
|
|
||||||
//info: (heskew) might not keep the port/vdir insertion around beyond...
|
//info: (heskew) might not keep the port/vdir insertion around beyond...
|
||||||
var port = string.Empty;
|
var port = string.Empty;
|
||||||
string host = urlHelper.RequestContext.HttpContext.Request.Headers["Host"];
|
var host = urlHelper.RequestContext.HttpContext.Request.Headers["Host"];
|
||||||
|
|
||||||
if (host.Contains(":"))
|
if (host.Contains(":"))
|
||||||
port = host.Substring(host.IndexOf(":"));
|
port = host.Substring(host.IndexOf(":"));
|
||||||
|
|
||||||
var result = string.Format("{0}://{1}",
|
var result = String.Format("{0}://{1}",
|
||||||
urlHelper.RequestContext.HttpContext.Request.Url.Scheme,
|
urlHelper.RequestContext.HttpContext.Request.Url.Scheme,
|
||||||
!string.IsNullOrEmpty(tenantShellSettings.RequestUrlHost)
|
!String.IsNullOrEmpty(requestUrlHost) ? requestUrlHost + port : host);
|
||||||
? tenantShellSettings.RequestUrlHost + port : host);
|
|
||||||
|
|
||||||
var applicationPath = urlHelper.RequestContext.HttpContext.Request.ApplicationPath;
|
var applicationPath = urlHelper.RequestContext.HttpContext.Request.ApplicationPath;
|
||||||
if (!string.IsNullOrEmpty(applicationPath) && !string.Equals(applicationPath, "/"))
|
if (!String.IsNullOrEmpty(applicationPath) && applicationPath != "/")
|
||||||
result += applicationPath;
|
result += applicationPath;
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(tenantShellSettings.RequestUrlPrefix))
|
if (!String.IsNullOrEmpty(tenantShellSettings.RequestUrlPrefix))
|
||||||
result += "/" + tenantShellSettings.RequestUrlPrefix;
|
result += "/" + tenantShellSettings.RequestUrlPrefix;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
Layout.Title = T("Edit Tenant").ToString();
|
Layout.Title = T("Edit Tenant").ToString();
|
||||||
|
|
||||||
Script.Require("jQuery").AtFoot();
|
Script.Require("jQuery").AtFoot();
|
||||||
Script.Include(Url.Content("~/Themes/TheAdmin/Scripts/admin.js")).AtFoot();
|
Script.Include(Url.Content("~/Themes/TheAdmin/Scripts/admin.js")).AtFoot();
|
||||||
Script.Include("multi-tenancy.admin.js").AtFoot();
|
Script.Include("multi-tenancy.admin.js").AtFoot();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -16,9 +16,9 @@
|
|||||||
<h2>@Model.Name</h2>
|
<h2>@Model.Name</h2>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label for="@Html.FieldIdFor(m => m.RequestUrlHost)">@T("Host")</label>
|
<label for="@Html.FieldIdFor(m => m.RequestUrlHost)">@T("URL host")</label>
|
||||||
@Html.TextBoxFor(m => m.RequestUrlHost, new { @class = "text medium" })
|
@Html.TextBoxFor(m => m.RequestUrlHost, new { @class = "text medium" })
|
||||||
<span class="hint">@T("Example: If host is \"orchardproject.net\", the tenant site URL is \"http://orchardproject.net/\"")</span>
|
<span class="hint">@T("Example: If host is \"orchardproject.net\", the tenant site URL is \"http://orchardproject.net/\". Multiple hosts can be separated by a comma.")</span>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label for="@Html.FieldIdFor(m => m.RequestUrlPrefix)">@T("URL prefix")</label>
|
<label for="@Html.FieldIdFor(m => m.RequestUrlPrefix)">@T("URL prefix")</label>
|
||||||
@@ -56,8 +56,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset class="available-extensions">
|
<fieldset class="available-extensions">
|
||||||
<label for="@Html.FieldIdFor(m => m.Themes)">@T("Available Themes")</label>
|
<label for="@Html.FieldIdFor(m => m.Themes)">@T("Available Themes")</label>
|
||||||
<div>
|
<div>
|
||||||
<span class="hint">@T("Select the Themes which should be available for this tenant. If none is selected, they will all be available.")</span>
|
<span class="hint">@T("Select the Themes which should be available for this tenant. If none is selected, they will all be available.")</span>
|
||||||
|
|
||||||
@@ -83,8 +83,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
<fieldset class="available-extensions">
|
<fieldset class="available-extensions">
|
||||||
<label for="@Html.FieldIdFor(m => m.Modules)">@T("Available Modules")</label>
|
<label for="@Html.FieldIdFor(m => m.Modules)">@T("Available Modules")</label>
|
||||||
<div>
|
<div>
|
||||||
<span class="hint">@T("Select the Modules which should be available for this tenant. If none is selected, they will all be available.")</span>
|
<span class="hint">@T("Select the Modules which should be available for this tenant. If none is selected, they will all be available.")</span>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user