mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-26 03:40:56 +08:00
Merge remote-tracking branch 'refs/remotes/origin/1.10.x' into 1.10.2
This commit is contained in:
@@ -397,7 +397,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="App_Data\" />
|
||||
<Folder Include="Views\Gamma\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Contents\Views\Content.cshtml" />
|
||||
|
||||
@@ -51,10 +51,10 @@ namespace Orchard.Localization.Controllers {
|
||||
}
|
||||
|
||||
var contentItemTranslation = _contentManager.New<LocalizationPart>(masterContentItem.ContentType);
|
||||
contentItemTranslation.MasterContentItem = masterContentItem;
|
||||
contentItemTranslation.MasterContentItem = masterLocalizationPart.MasterContentItem == null ? masterContentItem : masterLocalizationPart.MasterContentItem;
|
||||
|
||||
var content = _contentManager.BuildEditor(contentItemTranslation);
|
||||
|
||||
|
||||
return View(content);
|
||||
}
|
||||
|
||||
@@ -89,14 +89,14 @@ namespace Orchard.Localization.Controllers {
|
||||
if (existingTranslation != null) {
|
||||
var existingTranslationMetadata = _contentManager.GetItemMetadata(existingTranslation);
|
||||
return RedirectToAction(
|
||||
Convert.ToString(existingTranslationMetadata.EditorRouteValues["action"]),
|
||||
Convert.ToString(existingTranslationMetadata.EditorRouteValues["action"]),
|
||||
existingTranslationMetadata.EditorRouteValues);
|
||||
}
|
||||
|
||||
var contentItemTranslation = _contentManager
|
||||
.Create<LocalizationPart>(masterContentItem.ContentType, VersionOptions.Draft, part => {
|
||||
part.MasterContentItem = masterContentItem;
|
||||
});
|
||||
part.MasterContentItem = masterLocalizationPart.MasterContentItem == null ? masterContentItem : masterLocalizationPart.MasterContentItem;
|
||||
});
|
||||
|
||||
var content = _contentManager.UpdateEditor(contentItemTranslation, this);
|
||||
|
||||
|
||||
@@ -20,35 +20,45 @@ namespace Orchard.Localization.Drivers {
|
||||
}
|
||||
|
||||
protected override DriverResult Display(LocalizationPart part, string displayType, dynamic shapeHelper) {
|
||||
var masterId = part.HasTranslationGroup
|
||||
? part.Record.MasterContentItemId
|
||||
: part.Id;
|
||||
|
||||
return Combined(
|
||||
ContentShape("Parts_Localization_ContentTranslations",
|
||||
() => shapeHelper.Parts_Localization_ContentTranslations(Id: part.ContentItem.Id, MasterId: masterId, Culture: GetCulture(part), Localizations: GetDisplayLocalizations(part, VersionOptions.Published))),
|
||||
() => shapeHelper.Parts_Localization_ContentTranslations(Id: part.ContentItem.Id, MasterId: ActualMasterId(part), Culture: GetCulture(part), Localizations: GetDisplayLocalizations(part, VersionOptions.Published))),
|
||||
ContentShape("Parts_Localization_ContentTranslations_Summary",
|
||||
() => shapeHelper.Parts_Localization_ContentTranslations_Summary(Id: part.ContentItem.Id, MasterId: masterId, Culture: GetCulture(part), Localizations: GetDisplayLocalizations(part, VersionOptions.Published))),
|
||||
() => shapeHelper.Parts_Localization_ContentTranslations_Summary(Id: part.ContentItem.Id, MasterId: ActualMasterId(part), Culture: GetCulture(part), Localizations: GetDisplayLocalizations(part, VersionOptions.Published))),
|
||||
ContentShape("Parts_Localization_ContentTranslations_SummaryAdmin", () => {
|
||||
var siteCultures = _cultureManager.ListCultures();
|
||||
|
||||
return shapeHelper.Parts_Localization_ContentTranslations_SummaryAdmin(Id: part.ContentItem.Id, MasterId: masterId, Culture: GetCulture(part), Localizations: GetDisplayLocalizations(part, VersionOptions.Latest), SiteCultures: siteCultures);
|
||||
return shapeHelper.Parts_Localization_ContentTranslations_SummaryAdmin(Id: part.ContentItem.Id, MasterId: ActualMasterId(part), Culture: GetCulture(part), Localizations: GetDisplayLocalizations(part, VersionOptions.Latest), SiteCultures: siteCultures);
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
private int ActualMasterId(LocalizationPart part) {
|
||||
var masterId = part.HasTranslationGroup
|
||||
? part.Record.MasterContentItemId
|
||||
: part.Id;
|
||||
if (_contentManager.Get(masterId, VersionOptions.Latest) == null) {
|
||||
//the original MasterContentItem has been deleted
|
||||
masterId = part.Id;
|
||||
}
|
||||
return masterId;
|
||||
}
|
||||
|
||||
protected override DriverResult Editor(LocalizationPart part, dynamic shapeHelper) {
|
||||
var localizations = GetEditorLocalizations(part).ToList();
|
||||
|
||||
var missingCultures = part.HasTranslationGroup ?
|
||||
RetrieveMissingCultures(part.MasterContentItem.As<LocalizationPart>(), true) :
|
||||
var masterContentItem = _contentManager.Get(part.Record.MasterContentItemId, VersionOptions.Latest);
|
||||
|
||||
var missingCultures = part.HasTranslationGroup && masterContentItem != null ?
|
||||
RetrieveMissingCultures(masterContentItem.As<LocalizationPart>(), true) :
|
||||
RetrieveMissingCultures(part, part.Culture != null);
|
||||
|
||||
var model = new EditLocalizationViewModel {
|
||||
SelectedCulture = GetCulture(part),
|
||||
MissingCultures = missingCultures,
|
||||
ContentItem = part,
|
||||
MasterContentItem = part.HasTranslationGroup ? part.MasterContentItem : null,
|
||||
MasterContentItem = masterContentItem,
|
||||
ContentLocalizations = new ContentLocalizationsViewModel(part) { Localizations = localizations }
|
||||
};
|
||||
|
||||
@@ -69,7 +79,7 @@ namespace Orchard.Localization.Drivers {
|
||||
}
|
||||
|
||||
private List<string> RetrieveMissingCultures(LocalizationPart part, bool excludePartCulture) {
|
||||
var editorLocalizations = GetEditorLocalizations(part);
|
||||
var editorLocalizations = GetEditorLocalizations(part.MasterContentItem != null ? part.MasterContentItem.As<LocalizationPart>() : part);
|
||||
|
||||
var cultures = _cultureManager
|
||||
.ListCultures()
|
||||
|
||||
@@ -16,7 +16,7 @@ var localizationLinks = Html.UnorderedList(localizations, (c, i) => Html.ItemEdi
|
||||
}
|
||||
@if (Model.Culture != null && !((IEnumerable<string>)Model.SiteCultures).All(c => c == Model.Culture || localizations.Any(l => c == l.Culture.Culture)))
|
||||
{
|
||||
<div class="add-localization">@Html.ActionLink(T("+ New translation").Text, "Translate", "Admin", new { area = "Orchard.Localization", id = Model.Id }, null)</div>
|
||||
<div class="add-localization">@Html.ActionLink(T("+ New translation").Text, "Translate", "Admin", new { area = "Orchard.Localization", id = Model.MasterId }, null)</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
@@ -58,7 +58,7 @@ namespace Orchard.Redis.Caching {
|
||||
}
|
||||
|
||||
public void Clear() {
|
||||
Database.KeyDeleteWithPrefix(GetLocalizedKey("*"));
|
||||
_connectionMultiplexer.KeyDeleteWithPrefix(GetLocalizedKey("*"));
|
||||
}
|
||||
|
||||
private string GetLocalizedKey(string key) {
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
using System;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace Orchard.Redis.Extensions {
|
||||
public static class RedisDatabaseExtensions {
|
||||
|
||||
public static void KeyDeleteWithPrefix(this IDatabase database, string prefix) {
|
||||
if (database == null) {
|
||||
throw new ArgumentException("Database cannot be null", "database");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(prefix)) {
|
||||
throw new ArgumentException("Prefix cannot be empty", "database");
|
||||
}
|
||||
|
||||
database.ScriptEvaluate(@"
|
||||
local keys = redis.call('keys', ARGV[1])
|
||||
for i=1,#keys,5000 do
|
||||
redis.call('del', unpack(keys, i, math.min(i+4999, #keys)))
|
||||
end", values: new RedisValue[] { prefix });
|
||||
}
|
||||
|
||||
public static int KeyCount(this IDatabase database, string prefix) {
|
||||
if (database == null) {
|
||||
throw new ArgumentException("Database cannot be null", "database");
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(prefix)) {
|
||||
throw new ArgumentException("Prefix cannot be empty", "database");
|
||||
}
|
||||
|
||||
var retVal = database.ScriptEvaluate("return table.getn(redis.call('keys', ARGV[1]))", values: new RedisValue[] { prefix });
|
||||
|
||||
if (retVal.IsNull) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (int)retVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -110,7 +110,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Caching\RedisCacheStorageProvider.cs" />
|
||||
<Compile Include="Extensions\RedisDatabaseExtensions.cs" />
|
||||
<Compile Include="Extensions\RedisConnectionExtensions.cs" />
|
||||
<Compile Include="Configuration\IRedisConnectionProvider.cs" />
|
||||
<Compile Include="Configuration\RedisConnectionProvider.cs" />
|
||||
<Compile Include="MessageBus\RedisMessageBusBroker.cs" />
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace Orchard.Redis.OutputCache {
|
||||
}
|
||||
|
||||
public void Set(string key, CacheItem cacheItem) {
|
||||
if(cacheItem == null) {
|
||||
if (cacheItem == null) {
|
||||
throw new ArgumentNullException("cacheItem");
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Orchard.Redis.OutputCache {
|
||||
}
|
||||
|
||||
public void RemoveAll() {
|
||||
Database.KeyDeleteWithPrefix(GetLocalizedKey("*"));
|
||||
Database.KeyDelete(GetPrefixedKeys().Select(key => (RedisKey)key).ToArray());
|
||||
}
|
||||
|
||||
public CacheItem GetCacheItem(string key) {
|
||||
@@ -85,11 +85,11 @@ namespace Orchard.Redis.OutputCache {
|
||||
}
|
||||
|
||||
using (var compressedStream = new MemoryStream(value)) {
|
||||
if(compressedStream.Length == 0) {
|
||||
if (compressedStream.Length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
using(var decompressedStream = Decompress(compressedStream)) {
|
||||
using (var decompressedStream = Decompress(compressedStream)) {
|
||||
return Deserialize(decompressedStream);
|
||||
}
|
||||
}
|
||||
@@ -106,7 +106,7 @@ namespace Orchard.Redis.OutputCache {
|
||||
}
|
||||
|
||||
public int GetCacheItemsCount() {
|
||||
return Database.KeyCount(GetLocalizedKey("*"));
|
||||
return GetPrefixedKeys().Count();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -123,19 +123,19 @@ namespace Orchard.Redis.OutputCache {
|
||||
/// </summary>
|
||||
/// <returns>The keys for the current tenant.</returns>
|
||||
private IEnumerable<string> GetAllKeys() {
|
||||
var prefix = GetLocalizedKey("");
|
||||
return GetPrefixedKeys().Select(x => x.Substring(prefix.Length));
|
||||
}
|
||||
|
||||
private IEnumerable<string> GetPrefixedKeys() {
|
||||
// prevent the same request from computing the list twice (count + list)
|
||||
if (_keysCache == null) {
|
||||
_keysCache = new HashSet<string>();
|
||||
var prefix = GetLocalizedKey("");
|
||||
|
||||
foreach (var endPoint in _connectionMultiplexer.GetEndPoints()) {
|
||||
var server = _connectionMultiplexer.GetServer(endPoint);
|
||||
foreach (var key in server.Keys(pattern: GetLocalizedKey("*"))) {
|
||||
_keysCache.Add(key.ToString().Substring(prefix.Length));
|
||||
}
|
||||
var keys = _connectionMultiplexer.GetKeys(GetLocalizedKey("*"));
|
||||
foreach (var key in keys) {
|
||||
_keysCache.Add(key);
|
||||
}
|
||||
}
|
||||
|
||||
return _keysCache;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.Users.Models;
|
||||
|
||||
namespace Orchard.Gallery.Services {
|
||||
public class PackageIdentityResolverSelector : IIdentityResolverSelector {
|
||||
private readonly IContentManager _contentManager;
|
||||
|
||||
public PackageIdentityResolverSelector(IContentManager contentManager) {
|
||||
_contentManager = contentManager;
|
||||
}
|
||||
|
||||
public IdentityResolverSelectorResult GetResolver(ContentIdentity contentIdentity) {
|
||||
if (contentIdentity.Has("User.UserName")) {
|
||||
return new IdentityResolverSelectorResult {
|
||||
Priority = 0,
|
||||
Resolve = ResolveIdentity
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private IEnumerable<ContentItem> ResolveIdentity(ContentIdentity identity) {
|
||||
var identifier = identity.Get("User.UserName");
|
||||
|
||||
if (identifier == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return _contentManager
|
||||
.Query<UserPart, UserPartRecord>()
|
||||
.Where(p => p.NormalizedUserName == identifier)
|
||||
.List<ContentItem>();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
using System;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Orchard.ContentManagement.Handlers {
|
||||
public class IdentifyDependenciesContext {
|
||||
|
||||
public IdentifyDependenciesContext(XElement contentElement, ImportContentSession importContentSession) {
|
||||
ContentElement = contentElement;
|
||||
ImportContentSession = importContentSession;
|
||||
}
|
||||
|
||||
public XElement ContentElement { get; set; }
|
||||
private ImportContentSession ImportContentSession { get; }
|
||||
|
||||
public void RegisterDependency(string id) {
|
||||
if(!String.IsNullOrWhiteSpace(id))
|
||||
ImportContentSession.RegisterDependency(new ContentIdentity(id));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,8 +22,8 @@
|
||||
</ToolsOptionsCategory>
|
||||
<ToolsOptionsCategory name="TextEditor">
|
||||
<ToolsOptionsSubCategory name="CSharp-Specific">
|
||||
<PropertyValue name="AddImport_SuggestForTypesInNuGetPackages">0</PropertyValue>
|
||||
<PropertyValue name="AddImport_SuggestForTypesInReferenceAssemblies">0</PropertyValue>
|
||||
<PropertyValue name="AddImport_SuggestForTypesInNuGetPackages">1</PropertyValue>
|
||||
<PropertyValue name="AddImport_SuggestForTypesInReferenceAssemblies">1</PropertyValue>
|
||||
<PropertyValue name="AutoComment">1</PropertyValue>
|
||||
<PropertyValue name="AutoInsertAsteriskForNewLinesOfBlockComments">1</PropertyValue>
|
||||
<PropertyValue name="CSharpClosedFileDiagnostics">-1</PropertyValue>
|
||||
@@ -141,10 +141,10 @@
|
||||
<PropertyValue name="EnableExpandPrecedence">false</PropertyValue>
|
||||
<PropertyValue name="EnableExpandScopes">false</PropertyValue>
|
||||
<PropertyValue name="EnableExtractFunction">false</PropertyValue>
|
||||
<PropertyValue name="EnableSQLiteStoreEngine">false</PropertyValue>
|
||||
<PropertyValue name="EnableSQLiteStoreEngine">true</PropertyValue>
|
||||
<PropertyValue name="EnableSingleFileISense">true</PropertyValue>
|
||||
<PropertyValue name="EnableSingleFileISenseSquiggles">false</PropertyValue>
|
||||
<PropertyValue name="EnumerateCommentTasks">false</PropertyValue>
|
||||
<PropertyValue name="EnumerateCommentTasks">true</PropertyValue>
|
||||
<PropertyValue name="GroupBrackets">true</PropertyValue>
|
||||
<PropertyValue name="HideExperimentalAd">true</PropertyValue>
|
||||
<PropertyValue name="HighlightMatchingTokens">true</PropertyValue>
|
||||
|
||||
Reference in New Issue
Block a user