mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Fixing multi tenant content culture lookup - thanks to Mr Spits for the patch.
This commit is contained in:
@@ -5,6 +5,7 @@ using Orchard.Alias;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Environment.Extensions;
|
||||
using Orchard.Localization.Services;
|
||||
using Orchard.Environment.Configuration;
|
||||
|
||||
namespace Orchard.Localization.Selectors {
|
||||
[OrchardFeature("Orchard.Localization.CultureSelector")]
|
||||
@@ -12,14 +13,17 @@ namespace Orchard.Localization.Selectors {
|
||||
private readonly IAliasService _aliasService;
|
||||
private readonly IContentManager _contentManager;
|
||||
private readonly Lazy<ILocalizationService> _localizationService;
|
||||
private readonly ShellSettings _shellSettings;
|
||||
|
||||
public ContentCultureSelector(
|
||||
IAliasService aliasService,
|
||||
IContentManager contentManager,
|
||||
Lazy<ILocalizationService> localizationService) {
|
||||
Lazy<ILocalizationService> localizationService,
|
||||
ShellSettings shellSettings) {
|
||||
_aliasService = aliasService;
|
||||
_contentManager = contentManager;
|
||||
_localizationService = localizationService;
|
||||
_shellSettings = shellSettings;
|
||||
}
|
||||
|
||||
public CultureSelectorResult GetCulture(HttpContextBase context) {
|
||||
@@ -40,6 +44,11 @@ namespace Orchard.Localization.Selectors {
|
||||
var appPath = context.Request.ApplicationPath ?? "/";
|
||||
var requestUrl = (path.StartsWith(appPath) ? path.Substring(appPath.Length) : path).TrimStart('/');
|
||||
|
||||
var prefix = _shellSettings.RequestUrlPrefix;
|
||||
if (!string.IsNullOrEmpty(prefix)) {
|
||||
requestUrl = (requestUrl.StartsWith(prefix) ? requestUrl.Substring(prefix.Length) : requestUrl).TrimStart('/');
|
||||
}
|
||||
|
||||
var content = GetByPath(requestUrl);
|
||||
if (content != null) {
|
||||
return new CultureSelectorResult { Priority = -2, CultureName = _localizationService.Value.GetContentCulture(content) };
|
||||
|
Reference in New Issue
Block a user