mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-24 21:43:37 +08:00
More work towards wrapping up the initial content localization experience
- moved the Localization feature into the Content category - cleaned up the UI a bit --HG-- branch : dev
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using JetBrains.Annotations;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement.Drivers;
|
||||
using Orchard.Core.Common;
|
||||
using Orchard.Core.Localization.Models;
|
||||
using Orchard.Core.Localization.Services;
|
||||
using Orchard.Core.Localization.ViewModels;
|
||||
using Orchard.Localization.Services;
|
||||
using Orchard.Settings;
|
||||
|
||||
namespace Orchard.Core.Localization.Drivers {
|
||||
[UsedImplicitly]
|
||||
@@ -20,15 +23,20 @@ namespace Orchard.Core.Localization.Drivers {
|
||||
Services = services;
|
||||
}
|
||||
|
||||
protected virtual ISite CurrentSite { get; private set; }
|
||||
public IOrchardServices Services { get; set; }
|
||||
|
||||
protected override DriverResult Display(Localized part, string displayType) {
|
||||
var model = new ContentLocalizationsViewModel(part) {
|
||||
CanLocalize = Services.Authorizer.Authorize(Permissions.ChangeOwner) && _cultureManager.ListCultures()
|
||||
.Where(s => s != _cultureManager.GetCurrentCulture(new HttpContextWrapper(HttpContext.Current)) && s != _localizationService.GetContentCulture(part.ContentItem))
|
||||
.Count() > 0,
|
||||
Localizations = _localizationService.GetLocalizations(part.ContentItem)
|
||||
.Select(c => {
|
||||
var localized = c.ContentItem.As<Localized>();
|
||||
if (localized.Culture == null)
|
||||
localized.Culture = _cultureManager.GetCultureByName(_cultureManager.GetCurrentCulture(new HttpContextWrapper(HttpContext.Current)));
|
||||
return c;
|
||||
}).ToList()
|
||||
};
|
||||
|
||||
return ContentPartTemplate(model, "Parts/Localization.ContentTranslations").LongestMatch(displayType, "Summary", "SummaryAdmin").Location("primary", "5");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user