Changes Content.Names to Content.CultureNames and Content.PublishNames to Content.PublishCultureNames
This commit is contained in:
@@ -232,7 +232,7 @@ namespace Umbraco.Core.Models
|
||||
|
||||
/// <inheritdoc/>
|
||||
[IgnoreDataMember]
|
||||
public IReadOnlyDictionary<string, string> PublishNames => _publishInfos?.ToDictionary(x => x.Key, x => x.Value.Name, StringComparer.OrdinalIgnoreCase) ?? NoNames;
|
||||
public IReadOnlyDictionary<string, string> PublishCultureNames => _publishInfos?.ToDictionary(x => x.Key, x => x.Value.Name, StringComparer.OrdinalIgnoreCase) ?? NoNames;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string GetPublishName(string culture)
|
||||
@@ -300,10 +300,10 @@ namespace Umbraco.Core.Models
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<string> EditedCultures => Names.Keys.Where(IsCultureEdited);
|
||||
public IEnumerable<string> EditedCultures => CultureNames.Keys.Where(IsCultureEdited);
|
||||
|
||||
/// <inheritdoc />
|
||||
public IEnumerable<string> AvailableCultures => Names.Keys;
|
||||
public IEnumerable<string> AvailableCultures => CultureNames.Keys;
|
||||
|
||||
[IgnoreDataMember]
|
||||
public int PublishedVersionId { get; internal set; }
|
||||
@@ -324,7 +324,7 @@ namespace Umbraco.Core.Models
|
||||
throw new InvalidOperationException($"Cannot publish invariant culture without a name.");
|
||||
PublishName = Name;
|
||||
var now = DateTime.Now;
|
||||
foreach (var (culture, name) in Names)
|
||||
foreach (var (culture, name) in CultureNames)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
return false; //fixme this should return an attempt with error results
|
||||
@@ -479,7 +479,7 @@ namespace Umbraco.Core.Models
|
||||
|
||||
// copy names
|
||||
ClearNames();
|
||||
foreach (var (culture, name) in other.Names)
|
||||
foreach (var (culture, name) in other.CultureNames)
|
||||
SetName(name, culture);
|
||||
Name = other.Name;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Umbraco.Core.Models
|
||||
public readonly PropertyInfo DefaultContentTypeIdSelector = ExpressionHelper.GetPropertyInfo<ContentBase, int>(x => x.ContentTypeId);
|
||||
public readonly PropertyInfo PropertyCollectionSelector = ExpressionHelper.GetPropertyInfo<ContentBase, PropertyCollection>(x => x.Properties);
|
||||
public readonly PropertyInfo WriterSelector = ExpressionHelper.GetPropertyInfo<ContentBase, int>(x => x.WriterId);
|
||||
public readonly PropertyInfo NamesSelector = ExpressionHelper.GetPropertyInfo<ContentBase, IReadOnlyDictionary<string, string>>(x => x.Names);
|
||||
public readonly PropertyInfo NamesSelector = ExpressionHelper.GetPropertyInfo<ContentBase, IReadOnlyDictionary<string, string>>(x => x.CultureNames);
|
||||
}
|
||||
|
||||
protected void PropertiesChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
@@ -141,7 +141,7 @@ namespace Umbraco.Core.Models
|
||||
|
||||
/// <inheritdoc />
|
||||
[DataMember]
|
||||
public virtual IReadOnlyDictionary<string, string> Names => _cultureInfos?.ToDictionary(x => x.Key, x => x.Value.Name, StringComparer.OrdinalIgnoreCase) ?? NoNames;
|
||||
public virtual IReadOnlyDictionary<string, string> CultureNames => _cultureInfos?.ToDictionary(x => x.Key, x => x.Value.Name, StringComparer.OrdinalIgnoreCase) ?? NoNames;
|
||||
|
||||
// sets culture infos
|
||||
// internal for repositories
|
||||
|
||||
@@ -121,7 +121,7 @@ namespace Umbraco.Core.Models
|
||||
/// <para>Because a dictionary key cannot be <c>null</c> this cannot get the invariant
|
||||
/// name, which must be get via the <see cref="PublishName"/> property.</para>
|
||||
/// </remarks>
|
||||
IReadOnlyDictionary<string, string> PublishNames { get; }
|
||||
IReadOnlyDictionary<string, string> PublishCultureNames { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the available cultures.
|
||||
|
||||
@@ -53,7 +53,7 @@ namespace Umbraco.Core.Models
|
||||
/// <para>Because a dictionary key cannot be <c>null</c> this cannot get the invariant
|
||||
/// name, which must be get or set via the <see cref="TreeEntityBase.Name"/> property.</para>
|
||||
/// </remarks>
|
||||
IReadOnlyDictionary<string, string> Names { get; }
|
||||
IReadOnlyDictionary<string, string> CultureNames { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether a given culture is available.
|
||||
|
||||
@@ -343,7 +343,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
if (content.ContentType.Variations.DoesSupportCulture())
|
||||
{
|
||||
// names also impact 'edited'
|
||||
foreach (var (culture, name) in content.Names)
|
||||
foreach (var (culture, name) in content.CultureNames)
|
||||
if (name != content.GetPublishName(culture))
|
||||
(editedCultures ?? (editedCultures = new HashSet<string>(StringComparer.OrdinalIgnoreCase))).Add(culture);
|
||||
|
||||
@@ -498,7 +498,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
if (content.ContentType.Variations.DoesSupportCulture())
|
||||
{
|
||||
// names also impact 'edited'
|
||||
foreach (var (culture, name) in content.Names)
|
||||
foreach (var (culture, name) in content.CultureNames)
|
||||
if (name != content.GetPublishName(culture))
|
||||
(editedCultures ?? (editedCultures = new HashSet<string>(StringComparer.OrdinalIgnoreCase))).Add(culture);
|
||||
|
||||
@@ -1031,7 +1031,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
private IEnumerable<ContentVersionCultureVariationDto> GetContentVariationDtos(IContent content, bool publishing)
|
||||
{
|
||||
// create dtos for the 'current' (non-published) version, all cultures
|
||||
foreach (var (culture, name) in content.Names)
|
||||
foreach (var (culture, name) in content.CultureNames)
|
||||
yield return new ContentVersionCultureVariationDto
|
||||
{
|
||||
VersionId = content.VersionId,
|
||||
@@ -1046,7 +1046,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
if (!publishing) yield break;
|
||||
|
||||
// create dtos for the 'published' version, for published cultures (those having a name)
|
||||
foreach (var (culture, name) in content.PublishNames)
|
||||
foreach (var (culture, name) in content.PublishCultureNames)
|
||||
yield return new ContentVersionCultureVariationDto
|
||||
{
|
||||
VersionId = content.PublishedVersionId,
|
||||
@@ -1059,7 +1059,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
|
||||
private IEnumerable<DocumentCultureVariationDto> GetDocumentVariationDtos(IContent content, bool publishing, HashSet<string> editedCultures)
|
||||
{
|
||||
foreach (var (culture, name) in content.Names)
|
||||
foreach (var (culture, name) in content.CultureNames)
|
||||
yield return new DocumentCultureVariationDto
|
||||
{
|
||||
NodeId = content.Id,
|
||||
@@ -1097,7 +1097,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
if (content.ContentType.Variations.DoesSupportCulture())
|
||||
{
|
||||
// no variant name = error
|
||||
if (content.Names.Count == 0)
|
||||
if (content.CultureNames.Count == 0)
|
||||
throw new InvalidOperationException("Cannot save content with an empty name.");
|
||||
|
||||
// sync the invariant name to the default culture name if it's empty since we can't save with an empty invariant name.
|
||||
@@ -1105,10 +1105,10 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
if (string.IsNullOrWhiteSpace(content.Name))
|
||||
{
|
||||
var defaultCulture = LanguageRepository.GetDefaultIsoCode();
|
||||
if (defaultCulture != null && content.Names.TryGetValue(defaultCulture, out var cultureName))
|
||||
if (defaultCulture != null && content.CultureNames.TryGetValue(defaultCulture, out var cultureName))
|
||||
content.Name = cultureName;
|
||||
else
|
||||
content.Name = content.Names.First().Value; // only option is to take the first
|
||||
content.Name = content.CultureNames.First().Value; // only option is to take the first
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1116,7 +1116,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
if (publishing && string.IsNullOrWhiteSpace(content.PublishName))
|
||||
{
|
||||
// no variant name = error
|
||||
if (content.PublishNames.Count == 0)
|
||||
if (content.PublishCultureNames.Count == 0)
|
||||
throw new InvalidOperationException("Cannot publish content with an empty name.");
|
||||
|
||||
// else... we cannot deal with it here because PublishName is readonly, so in reality, PublishName
|
||||
@@ -1132,7 +1132,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
|
||||
private void EnsureUniqueVariationNames(IContent content)
|
||||
{
|
||||
if (!EnsureUniqueNaming || content.Names.Count == 0) return;
|
||||
if (!EnsureUniqueNaming || content.CultureNames.Count == 0) return;
|
||||
|
||||
//Get all culture names at the same level
|
||||
|
||||
@@ -1156,7 +1156,7 @@ namespace Umbraco.Core.Persistence.Repositories.Implement
|
||||
|
||||
if (names.Count == 0) return;
|
||||
|
||||
foreach(var n in content.Names)
|
||||
foreach(var n in content.CultureNames)
|
||||
{
|
||||
var langId = LanguageRepository.GetIdByIsoCode(n.Key);
|
||||
if (!langId.HasValue) continue;
|
||||
|
||||
@@ -184,11 +184,11 @@ namespace Umbraco.Tests.Models
|
||||
Assert.AreEqual("name-uk", content.GetName(langUk));
|
||||
|
||||
// variant dictionary of names work
|
||||
Assert.AreEqual(2, content.Names.Count);
|
||||
Assert.IsTrue(content.Names.ContainsKey(langFr));
|
||||
Assert.AreEqual("name-fr", content.Names[langFr]);
|
||||
Assert.IsTrue(content.Names.ContainsKey(langUk));
|
||||
Assert.AreEqual("name-uk", content.Names[langUk]);
|
||||
Assert.AreEqual(2, content.CultureNames.Count);
|
||||
Assert.IsTrue(content.CultureNames.ContainsKey(langFr));
|
||||
Assert.AreEqual("name-fr", content.CultureNames[langFr]);
|
||||
Assert.IsTrue(content.CultureNames.ContainsKey(langUk));
|
||||
Assert.AreEqual("name-uk", content.CultureNames[langUk]);
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
@@ -752,7 +752,7 @@ namespace Umbraco.Tests.Persistence.Repositories
|
||||
foreach (var r in result)
|
||||
{
|
||||
var isInvariant = r.ContentType.Alias == "umbInvariantTextpage";
|
||||
var name = isInvariant ? r.Name : r.Names["en-US"];
|
||||
var name = isInvariant ? r.Name : r.CultureNames["en-US"];
|
||||
var namePrefix = isInvariant ? "INV" : "VAR";
|
||||
|
||||
//ensure the correct name (invariant vs variant) is in the result
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace Umbraco.Web.Models.Mapping
|
||||
.ForMember(dest => dest.CreatorId, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Level, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Name, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Names, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.CultureNames, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.ParentId, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.Path, opt => opt.Ignore())
|
||||
.ForMember(dest => dest.SortOrder, opt => opt.Ignore())
|
||||
|
||||
@@ -1188,9 +1188,9 @@ namespace Umbraco.Web.PublishedCache.NuCache
|
||||
|
||||
var names = content is IContent document
|
||||
? (published
|
||||
? document.PublishNames
|
||||
: document.Names)
|
||||
: content.Names;
|
||||
? document.PublishCultureNames
|
||||
: document.CultureNames)
|
||||
: content.CultureNames;
|
||||
|
||||
foreach (var (culture, name) in names)
|
||||
{
|
||||
|
||||
@@ -484,7 +484,7 @@ namespace umbraco
|
||||
if (_cultureInfos != null)
|
||||
return _cultureInfos;
|
||||
|
||||
return _cultureInfos = _inner.PublishNames
|
||||
return _cultureInfos = _inner.PublishCultureNames
|
||||
.ToDictionary(x => x.Key, x => new PublishedCultureInfo(x.Key, x.Value, _inner.GetCulturePublishDate(x.Key)));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user