mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-19 18:27:55 +08:00
Merge
--HG-- branch : dev
This commit is contained in:
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
@@ -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%;
|
||||
}
|
@@ -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");
|
||||
return ContentPartTemplate(model, "Parts/Localization.ContentTranslations").LongestMatch(displayType, "Summary", "SummaryAdmin").Location("primary", "5");
|
||||
}
|
||||
}
|
||||
}
|
@@ -8,4 +8,4 @@ description: The localization module enables the localization of content items.
|
||||
features:
|
||||
Localization:
|
||||
Description: Localize content items.
|
||||
Category: Core
|
||||
Category: Content
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
@@ -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; }
|
||||
}
|
||||
}
|
@@ -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>
|
@@ -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>
|
@@ -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>
|
@@ -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" />
|
||||
|
@@ -20,7 +20,6 @@ namespace Orchard.Data.Migration.Interpreters {
|
||||
private readonly ISession _session;
|
||||
private readonly Dialect _dialect;
|
||||
private readonly List<string> _sqlStatements;
|
||||
private readonly IDataServicesProviderFactory _dataServicesProviderFactory;
|
||||
private readonly ISessionFactoryHolder _sessionFactoryHolder;
|
||||
private readonly IReportsCoordinator _reportsCoordinator;
|
||||
|
||||
@@ -30,21 +29,18 @@ namespace Orchard.Data.Migration.Interpreters {
|
||||
ShellSettings shellSettings,
|
||||
ISessionLocator sessionLocator,
|
||||
IEnumerable<ICommandInterpreter> commandInterpreters,
|
||||
IDataServicesProviderFactory dataServicesProviderFactory,
|
||||
ISessionFactoryHolder sessionFactoryHolder,
|
||||
IReportsCoordinator reportsCoordinator) {
|
||||
_shellSettings = shellSettings;
|
||||
_commandInterpreters = commandInterpreters;
|
||||
_session = sessionLocator.For(typeof(DefaultDataMigrationInterpreter));
|
||||
_sqlStatements = new List<string>();
|
||||
_dataServicesProviderFactory = dataServicesProviderFactory;
|
||||
_sessionFactoryHolder = sessionFactoryHolder;
|
||||
_reportsCoordinator = reportsCoordinator;
|
||||
|
||||
Logger = NullLogger.Instance;
|
||||
|
||||
var parameters = _sessionFactoryHolder.GetSessionFactoryParameters();
|
||||
var configuration = _dataServicesProviderFactory.CreateProvider(parameters).BuildConfiguration(parameters);
|
||||
var configuration = _sessionFactoryHolder.GetConfiguration();
|
||||
_dialect = Dialect.GetDialect(configuration.Properties);
|
||||
}
|
||||
|
||||
|
@@ -1,4 +1,7 @@
|
||||
using NHibernate;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
using NHibernate;
|
||||
using NHibernate.Cfg;
|
||||
using Orchard.Data.Providers;
|
||||
using Orchard.Environment.Configuration;
|
||||
using Orchard.Environment.ShellBuilders.Models;
|
||||
@@ -9,6 +12,7 @@ using Orchard.Logging;
|
||||
namespace Orchard.Data {
|
||||
public interface ISessionFactoryHolder : ISingletonDependency {
|
||||
ISessionFactory GetSessionFactory();
|
||||
Configuration GetConfiguration();
|
||||
SessionFactoryParameters GetSessionFactoryParameters();
|
||||
}
|
||||
|
||||
@@ -19,6 +23,7 @@ namespace Orchard.Data {
|
||||
private readonly IAppDataFolder _appDataFolder;
|
||||
|
||||
private ISessionFactory _sessionFactory;
|
||||
private Configuration _configuration;
|
||||
|
||||
public SessionFactoryHolder(
|
||||
ShellSettings shellSettings,
|
||||
@@ -46,17 +51,46 @@ namespace Orchard.Data {
|
||||
return _sessionFactory;
|
||||
}
|
||||
|
||||
public Configuration GetConfiguration() {
|
||||
lock ( this ) {
|
||||
if ( _configuration == null ) {
|
||||
_configuration = BuildConfiguration();
|
||||
}
|
||||
}
|
||||
return _configuration;
|
||||
}
|
||||
|
||||
private ISessionFactory BuildSessionFactory() {
|
||||
Logger.Debug("Building session factory");
|
||||
|
||||
var config = GetConfiguration();
|
||||
return config.BuildSessionFactory();
|
||||
}
|
||||
|
||||
private Configuration BuildConfiguration() {
|
||||
var parameters = GetSessionFactoryParameters();
|
||||
|
||||
var sessionFactory = _dataServicesProviderFactory
|
||||
.CreateProvider(parameters)
|
||||
.BuildConfiguration(parameters)
|
||||
.BuildSessionFactory();
|
||||
Configuration config = null;
|
||||
var bf = new BinaryFormatter();
|
||||
|
||||
return sessionFactory;
|
||||
var filename = _appDataFolder.MapPath(_appDataFolder.Combine("Sites", "mappings.bin"));
|
||||
if(_appDataFolder.FileExists(filename)) {
|
||||
Logger.Debug("Loading mappings from cached file");
|
||||
using ( var stream = File.OpenRead(filename) ) {
|
||||
config = bf.Deserialize(stream) as Configuration;
|
||||
}
|
||||
}
|
||||
else {
|
||||
Logger.Debug("Generating mappings and cached file");
|
||||
config = _dataServicesProviderFactory
|
||||
.CreateProvider(parameters)
|
||||
.BuildConfiguration(parameters);
|
||||
|
||||
using ( var stream = File.OpenWrite(filename) ) {
|
||||
bf.Serialize(stream, config);
|
||||
}
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
public SessionFactoryParameters GetSessionFactoryParameters() {
|
||||
|
Reference in New Issue
Block a user