--HG--
branch : dev
This commit is contained in:
Renaud Paquay
2010-07-14 14:43:20 -07:00
15 changed files with 1397 additions and 1753 deletions

View File

@@ -6,9 +6,9 @@ html.dyn input.hinted {
color:#ccc;
font-style:italic;
}
input#ScheduledPublishUtcDate {
input#CommonAspect_ScheduledPublishUtcDate {
width:56%;
}
input#ScheduledPublishUtcTime {
input#CommonAspect_ScheduledPublishUtcTime {
width:36%;
}

View File

@@ -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,20 +23,21 @@ 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");
}
protected override DriverResult Editor(Localized part) {
return ContentPartTemplate(new SelectLocalizationsViewModel(part), "Parts/Localization.ContentTranslations").Location("secondary", "5");
}
}
}

View File

@@ -8,4 +8,4 @@ description: The localization module enables the localization of content items.
features:
Localization:
Description: Localize content items.
Category: Core
Category: Content

View File

@@ -6,6 +6,6 @@ namespace Orchard.Core.Localization.Services {
public interface ILocalizationService : IDependency {
Localized GetLocalizedContentItem(IContent masterContentItem, string culture);
string GetContentCulture(IContent contentItem);
IEnumerable<IContent> GetLocalizations(IContent contentItem);
IEnumerable<Localized> GetLocalizations(IContent contentItem);
}
}

View File

@@ -30,21 +30,23 @@ namespace Orchard.Core.Localization.Services {
: _cultureManager.GetSiteCulture();
}
IEnumerable<IContent> ILocalizationService.GetLocalizations(IContent content) {
IEnumerable<Localized> ILocalizationService.GetLocalizations(IContent content) {
var localized = content.As<Localized>();
//todo: (heskew) get scheduled content as well
if (localized.MasterContentItem != null)
return _contentManager.Query(VersionOptions.Latest, content.ContentItem.ContentType).Join<LocalizedRecord>()
return _contentManager.Query(VersionOptions.Latest, localized.ContentItem.ContentType).Join<LocalizedRecord>()
.List()
.Select(i => i.As<Localized>())
.Where(l => l.Id != content.ContentItem.Id && (l.Id == localized.MasterContentItem.ContentItem.Id || l.MasterContentItem != null && l.MasterContentItem.ContentItem.Id == localized.MasterContentItem.ContentItem.Id));
.Where(l => l.Id != localized.ContentItem.Id
&& (l.Id == localized.MasterContentItem.ContentItem.Id
|| l.MasterContentItem != null && l.MasterContentItem.ContentItem.Id == localized.MasterContentItem.ContentItem.Id));
return _contentManager.Query(VersionOptions.Latest, content.ContentItem.ContentType).Join<LocalizedRecord>()
return _contentManager.Query(VersionOptions.Latest, localized.ContentItem.ContentType).Join<LocalizedRecord>()
.List()
.Select(i => i.As<Localized>())
.Where(l => l.MasterContentItem != null && l.MasterContentItem.ContentItem.Id == content.ContentItem.Id);
.Where(l => l.MasterContentItem != null && l.MasterContentItem.ContentItem.Id == localized.ContentItem.Id);
}
}
}

View File

@@ -1,5 +1,6 @@
using System.Collections.Generic;
using Orchard.ContentManagement;
using Orchard.Core.Localization.Models;
namespace Orchard.Core.Localization.ViewModels {
public class ContentLocalizationsViewModel {
@@ -8,7 +9,6 @@ namespace Orchard.Core.Localization.ViewModels {
}
public int Id { get; private set; }
public bool CanLocalize { get; set; }
public IEnumerable<IContent> Localizations { get; set; }
public IEnumerable<Localized> Localizations { get; set; }
}
}

View File

@@ -1,16 +1,10 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.Core.Localization.ViewModels.ContentLocalizationsViewModel>" %>
<%@ Import Namespace="Orchard.Core.Localization.Models" %>
<%@ Import Namespace="Orchard.ContentManagement" %>
<%
Html.RegisterStyle("admin.css"); %>
<% if (Model.Localizations.Count() > 0 || Model.CanLocalize) { %>
<div class="content-localization"><%
if (Model.Localizations.Count() > 0) { %>
<%--//todo: need this info in the view model--%>
<div class="content-localizations"><h4><%:T("Other localizations:") %></h4><%:Html.UnorderedList(Model.Localizations, (c, i) => Html.ItemDisplayLink(c.ContentItem.As<Localized>().Culture != null ? c.ContentItem.As<Localized>().Culture.Culture : "[site's default culture]", c), "localizations") %></div><%
}
if (Model.CanLocalize) { %>
<div class="add-localization"><%:Html.ActionLink(T("+ New translation").Text, "translate", "admin", new { area = "Localization", id = Model.Id }, null)%></div><%
<div class="content-localizations"><h4><%:T("Translations:") %></h4><%:Html.UnorderedList(Model.Localizations, (c, i) => Html.ItemDisplayLink(c.Culture.Culture, c), "localizations") %></div><%
} %>
</div><%
} %>
<div class="add-localization"><%:Html.ActionLink(T("+ New translation").Text, "translate", "admin", new { area = "Localization", id = Model.Id }, null)%></div>
</div>

View File

@@ -1,16 +1,10 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.Core.Localization.ViewModels.ContentLocalizationsViewModel>" %>
<%@ Import Namespace="Orchard.Core.Localization.Models" %>
<%@ Import Namespace="Orchard.ContentManagement" %>
<%
Html.RegisterStyle("base.css"); %>
<% if (Model.Localizations.Count() > 0 || Model.CanLocalize) { %>
<div class="content-localization"><%
if (Model.Localizations.Count() > 0) { %>
<%--//todo: need this info in the view model--%>
<div class="content-localizations"><%:Html.UnorderedList(Model.Localizations, (c, i) => Html.ItemDisplayLink(c.ContentItem.As<Localized>().Culture != null ? c.ContentItem.As<Localized>().Culture.Culture : "[site's default culture]", c), "localizations") %></div><%
}
if (Model.CanLocalize) { %>
<div class="add-localization"><%:Html.ActionLink(T("+ New translation").Text, "translate", "admin", new { area = "Localization", id = Model.Id }, null)%></div><%
<div class="content-localizations"><%:Html.UnorderedList(Model.Localizations, (c, i) => Html.ItemDisplayLink(c.Culture.Culture, c), "localizations") %></div><%
} %>
</div><%
} %>
<div class="add-localization"><%:Html.ActionLink(T("+ New translation").Text, "translate", "admin", new { area = "Localization", id = Model.Id }, null)%></div>
</div>

View File

@@ -1,5 +0,0 @@
<%@ Control Language="C#" Inherits="Orchard.Mvc.ViewUserControl<Orchard.Core.Localization.ViewModels.SelectLocalizationsViewModel>" %>
<fieldset class="localization translations">
<legend>Publish also in</legend>
[translations to publish]
</fieldset>

View File

@@ -266,7 +266,6 @@
<Content Include="Localization\Styles\base.css" />
<Content Include="Localization\Views\DisplayTemplates\Parts\Localization.ContentTranslations.Summary.ascx" />
<Content Include="Localization\Views\DisplayTemplates\Parts\Localization.ContentTranslations.ascx" />
<Content Include="Localization\Views\EditorTemplates\Parts\Localization.ContentTranslations.ascx" />
<Content Include="Reports\Module.txt" />
<Content Include="Reports\Views\Admin\Display.aspx" />
<Content Include="Reports\Views\Admin\Index.aspx" />