Starting to get some content localization hooked up.

- can create new translations and content items (in manage content) link to other localizations of the content
- still a bit buggy when creating a new translation to override an existing translation
- the ux is still, definately, a bid ol' wip

--HG--
branch : dev
This commit is contained in:
Nathan Heskew
2010-07-12 03:03:18 -07:00
parent 801c46ea04
commit 23b101a644
21 changed files with 222 additions and 42 deletions

View File

@@ -1,35 +1,50 @@
using JetBrains.Annotations;
using Orchard.ContentManagement;
using System.Linq;
using System.Web;
using JetBrains.Annotations;
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;
namespace Orchard.Core.Localization.Drivers {
[UsedImplicitly]
public class LocalizationDriver : ContentPartDriver<Localized> {
public LocalizationDriver(IOrchardServices services) {
private readonly ICultureManager _cultureManager;
private readonly ILocalizationService _localizationService;
public LocalizationDriver(IOrchardServices services, ICultureManager cultureManager, ILocalizationService localizationService) {
_cultureManager = cultureManager;
_localizationService = localizationService;
Services = services;
}
public IOrchardServices Services { get; set; }
protected override DriverResult Display(Localized part, string displayType) {
// for viewing or adding translation
if (!Services.Authorizer.Authorize(Permissions.ChangeOwner)) {
return null;
}
var model = new ContentTranslationsViewModel(part);
var model = new ContentLocalizationsViewModel(part) {
CanLocalize = _cultureManager.ListCultures()
.Where(s => s != _cultureManager.GetCurrentCulture(new HttpContextWrapper(HttpContext.Current)) && s != _localizationService.GetContentCulture(part.ContentItem))
.Count() > 0,
Localizations = _localizationService.GetLocalizations(part.ContentItem)
};
return ContentPartTemplate(model, "Parts/Localization.ContentTranslations").LongestMatch(displayType, "Summary", "SummaryAdmin").Location("primary", "5");
}
protected override DriverResult Editor(Localized part) {
var model = new LocalizationEditorViewModel();
// ContentTranslations: for when there are drafts of translations
// CultureSelection: for a new translation
//var model = new SelectTranslationsViewModel(part);
//if (part.ContentItem.Is<Localized>())
return ContentPartTemplate(model, "Parts/Localization.IsLocalized").Location("primary", "before.3");
return ContentPartTemplate(new SelectLocalizationsViewModel(part), "Parts/Localization.ContentTranslations").Location("secondary", "5");
}
}
public class LocalizationEditorViewModel {}
}