diff --git a/src/Umbraco.Core/Models/PublishedContent/IPublishedContent.cs b/src/Umbraco.Core/Models/PublishedContent/IPublishedContent.cs index 93487b6492..1c0d39a8b8 100644 --- a/src/Umbraco.Core/Models/PublishedContent/IPublishedContent.cs +++ b/src/Umbraco.Core/Models/PublishedContent/IPublishedContent.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; namespace Umbraco.Core.Models.PublishedContent { - /// /// /// Represents a published content item. @@ -27,16 +26,14 @@ namespace Umbraco.Core.Models.PublishedContent int Id { get; } /// - /// Gets the name of the content item. + /// Gets the name of the content item for the current culture. /// - /// The specific culture to get the name for. If null is used the current culture is used (Default is null). - string Name(string culture = null); + string Name { get; } /// - /// Gets the url segment of the content item. + /// Gets the url segment of the content item for the current culture. /// - /// The specific culture to get the url segment for. If null is used the current culture is used (Default is null). - string UrlSegment(string culture = null); + string UrlSegment { get; } /// /// Gets the sort order of the content item. @@ -94,20 +91,29 @@ namespace Umbraco.Core.Models.PublishedContent DateTime UpdateDate { get; } /// - /// Gets the culture date of the content item. + /// Gets the url of the content item for the current culture. /// - /// The specific culture to get the name for. If null is used the current culture is used (Default is null). - DateTime CultureDate(string culture = null); + /// + /// The value of this property is contextual. It depends on the 'current' request uri, + /// if any. + /// + string Url { get; } /// - /// Gets all available cultures. + /// Gets available culture infos. /// /// /// Contains only those culture that are available. For a published content, these are /// the cultures that are published. For a draft content, those that are 'available' ie /// have a non-empty content name. + /// Does not contain the invariant culture. // fixme? /// - IReadOnlyCollection Cultures { get; } + IReadOnlyDictionary Cultures { get; } + + /// + /// Gets the type of the content item (document, media...). + /// + PublishedItemType ItemType { get; } /// /// Gets a value indicating whether the content is draft. @@ -145,18 +151,17 @@ namespace Umbraco.Core.Models.PublishedContent /// Gets the parent of the content item. /// /// The parent of root content is null. - IPublishedContent Parent(); + IPublishedContent Parent { get; } /// - /// Gets the children of the content item. + /// Gets the children of the content item that are available for the current culture. /// - /// The specific culture to get the url children for. If null is used the current culture is used (Default is null). - /// - /// Gets children that are available for the specified culture. - /// Children are sorted by their sortOrder. - /// The '*' culture and supported and returns everything. - /// - IEnumerable Children(string culture = null); + IEnumerable Children { get; } + + /// + /// Gets all the children of the content item, regardless of whether they are available for the current culture. + /// + IEnumerable ChildrenForAllCultures { get; } #endregion } diff --git a/src/Umbraco.Core/Models/PublishedContent/PublishedContentWrapped.cs b/src/Umbraco.Core/Models/PublishedContent/PublishedContentWrapped.cs index 3da690a7e2..fb41c95419 100644 --- a/src/Umbraco.Core/Models/PublishedContent/PublishedContentWrapped.cs +++ b/src/Umbraco.Core/Models/PublishedContent/PublishedContentWrapped.cs @@ -58,10 +58,10 @@ namespace Umbraco.Core.Models.PublishedContent public virtual int Id => _content.Id; /// - public virtual string Name(string culture = null) => _content.Name(culture); + public virtual string Name => _content.Name; /// - public virtual string UrlSegment(string culture = null) => _content.UrlSegment(culture); + public virtual string UrlSegment => _content.UrlSegment; /// public virtual int SortOrder => _content.SortOrder; @@ -94,10 +94,13 @@ namespace Umbraco.Core.Models.PublishedContent public virtual DateTime UpdateDate => _content.UpdateDate; /// - public DateTime CultureDate(string culture = null) => _content.CultureDate(culture); + public virtual string Url => _content.Url; /// - public IReadOnlyCollection Cultures => _content.Cultures; + public IReadOnlyDictionary Cultures => _content.Cultures; + + /// + public virtual PublishedItemType ItemType => _content.ItemType; /// public virtual bool IsDraft(string culture = null) => _content.IsDraft(culture); @@ -110,10 +113,13 @@ namespace Umbraco.Core.Models.PublishedContent #region Tree /// - public virtual IPublishedContent Parent() => _content.Parent(); + public virtual IPublishedContent Parent => _content.Parent; /// - public virtual IEnumerable Children(string culture = null) => _content.Children(culture); + public virtual IEnumerable Children => _content.Children; + + /// + public virtual IEnumerable ChildrenForAllCultures => _content.ChildrenForAllCultures; #endregion diff --git a/src/Umbraco.Core/PublishedContentExtensions.cs b/src/Umbraco.Core/PublishedContentExtensions.cs new file mode 100644 index 0000000000..a8cb0cdaf2 --- /dev/null +++ b/src/Umbraco.Core/PublishedContentExtensions.cs @@ -0,0 +1,128 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using Umbraco.Core.Composing; +using Umbraco.Core.Models.PublishedContent; + +namespace Umbraco.Core +{ + public static class PublishedContentExtensions + { + private static IVariationContextAccessor VariationContextAccessor => Current.VariationContextAccessor; + + /// + /// Determines whether the content has a culture. + /// + /// Culture is case-insensitive. + public static bool HasCulture(this IPublishedContent content, string culture) + => content.Cultures.ContainsKey(culture ?? string.Empty); + + /// + /// Determines whether the content is invariant, or has a culture. + /// + /// Culture is case-insensitive. + public static bool IsInvariantOrHasCulture(this IPublishedContent content, string culture) + => !content.ContentType.VariesByCulture() || content.Cultures.ContainsKey(culture ?? ""); + + /// + /// Filters a sequence of to return invariant items, and items that are published for the specified culture. + /// + /// The content items. + /// The specific culture to filter for. If null is used the current culture is used. (Default is null). + internal static IEnumerable WhereIsInvariantOrHasCulture(this IEnumerable contents, string culture = null) + where T : class, IPublishedContent + { + if (contents == null) throw new ArgumentNullException(nameof(contents)); + + culture = culture ?? Current.VariationContextAccessor.VariationContext?.Culture ?? ""; + + // either does not vary by culture, or has the specified culture + return contents.Where(x => !ContentVariationExtensions.VariesByCulture((IPublishedContentType) x.ContentType) || HasCulture(x, culture)); + } + + /// + /// Gets the name of the content item. + /// + /// The content item. + /// The specific culture to get the name for. If null is used the current culture is used (Default is null). + public static string Name(this IPublishedContent content, string culture = null) + { + // invariant has invariant value (whatever the requested culture) + if (!content.ContentType.VariesByCulture()) + return "NAME??"; // fixme where should the invariant one come from? should Cultures contain it? + + // handle context culture for variant + if (culture == null) + culture = VariationContextAccessor?.VariationContext?.Culture ?? ""; + + // get + return culture != "" && content.Cultures.TryGetValue(culture, out var infos) ? infos.Name : null; + } + + + /// + /// Gets the url segment of the content item. + /// + /// The content item. + /// The specific culture to get the url segment for. If null is used the current culture is used (Default is null). + public static string UrlSegment(this IPublishedContent content, string culture = null) + { + // invariant has invariant value (whatever the requested culture) + if (!content.ContentType.VariesByCulture()) + return "URLSEGMENT??"; // fixme where should the invariant one come from? should Cultures contain it? + + // handle context culture for variant + if (culture == null) + culture = VariationContextAccessor?.VariationContext?.Culture ?? ""; + + // get + return culture != "" && content.Cultures.TryGetValue(culture, out var infos) ? infos.UrlSegment : null; + } + + /// + /// Gets the culture date of the content item. + /// + /// The content item. + /// The specific culture to get the name for. If null is used the current culture is used (Default is null). + public static DateTime CultureDate(this IPublishedContent content, string culture = null) + { + // invariant has invariant value (whatever the requested culture) + if (!content.ContentType.VariesByCulture()) + return content.UpdateDate; + + // handle context culture for variant + if (culture == null) + culture = VariationContextAccessor?.VariationContext?.Culture ?? ""; + + // get + return culture != "" && content.Cultures.TryGetValue(culture, out var infos) ? infos.Date : DateTime.MinValue; + } + + + /// + /// Gets the children of the content item. + /// + /// The content item. + /// The specific culture to get the url children for. If null is used the current culture is used (Default is null). + /// + /// Gets children that are available for the specified culture. + /// Children are sorted by their sortOrder. + /// The '*' culture and supported and returns everything. + /// + public static IEnumerable Children(this IPublishedContent content, string culture = null) + { + // invariant has invariant value (whatever the requested culture) + if (!content.ContentType.VariesByCulture() && culture != "*") + culture = ""; + + // handle context culture for variant + if (culture == null) + culture = VariationContextAccessor?.VariationContext?.Culture ?? ""; + + var children = content.ChildrenForAllCultures; + return culture == "*" + ? children + : children.Where(x => x.IsInvariantOrHasCulture(culture)); + } + } +} \ No newline at end of file diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj index ae1c643b2b..d923065438 100755 --- a/src/Umbraco.Core/Umbraco.Core.csproj +++ b/src/Umbraco.Core/Umbraco.Core.csproj @@ -252,6 +252,7 @@ + diff --git a/src/Umbraco.Tests/Cache/PublishedCache/PublishedMediaCacheTests.cs b/src/Umbraco.Tests/Cache/PublishedCache/PublishedMediaCacheTests.cs index d31401c725..f3d9f895ef 100644 --- a/src/Umbraco.Tests/Cache/PublishedCache/PublishedMediaCacheTests.cs +++ b/src/Umbraco.Tests/Cache/PublishedCache/PublishedMediaCacheTests.cs @@ -108,10 +108,10 @@ namespace Umbraco.Tests.Cache.PublishedCache Assert.AreEqual(mRoot.ContentType.Alias, publishedMedia.ContentType.Alias); Assert.AreEqual(mRoot.ContentType.Id, publishedMedia.ContentType.Id); Assert.AreEqual(mRoot.Level, publishedMedia.Level); - Assert.AreEqual(mRoot.Name, publishedMedia.Name()); + Assert.AreEqual(mRoot.Name, publishedMedia.Name); Assert.AreEqual(mRoot.Path, publishedMedia.Path); Assert.AreEqual(mRoot.SortOrder, publishedMedia.SortOrder); - Assert.IsNull(publishedMedia.Parent()); + Assert.IsNull(publishedMedia.Parent); } [TestCase("id")] @@ -172,9 +172,9 @@ namespace Umbraco.Tests.Cache.PublishedCache child1, child2 }); - Assert.AreEqual(2, dicDoc.Children().Count()); - Assert.AreEqual(222333, dicDoc.Children().ElementAt(0).Id); - Assert.AreEqual(444555, dicDoc.Children().ElementAt(1).Id); + Assert.AreEqual(2, dicDoc.Children.Count()); + Assert.AreEqual(222333, dicDoc.Children.ElementAt(0).Id); + Assert.AreEqual(444555, dicDoc.Children.ElementAt(1).Id); } [Test] @@ -212,7 +212,7 @@ namespace Umbraco.Tests.Cache.PublishedCache var doc = store.CreateFromCacheValues(store.ConvertFromSearchResult(result)); DoAssert(doc, 1234, key, null, 0, "/media/test.jpg", "Image", 23, "Shannon", "Shannon", 0, 0, "-1,1234", DateTime.Parse("2012-07-17T10:34:09"), DateTime.Parse("2012-07-16T10:34:09"), 2); - Assert.AreEqual(null, doc.Parent()); + Assert.AreEqual(null, doc.Parent); } [Test] @@ -228,10 +228,10 @@ namespace Umbraco.Tests.Cache.PublishedCache var doc = cache.CreateFromCacheValues(cache.ConvertFromXPathNavigator(navigator, true)); DoAssert(doc, 2000, key, null, 2, "image1", "Image", 23, "Shannon", "Shannon", 33, 33, "-1,2000", DateTime.Parse("2012-06-12T14:13:17"), DateTime.Parse("2012-07-20T18:50:43"), 1); - Assert.AreEqual(null, doc.Parent()); - Assert.AreEqual(2, doc.Children().Count()); - Assert.AreEqual(2001, doc.Children().ElementAt(0).Id); - Assert.AreEqual(2002, doc.Children().ElementAt(1).Id); + Assert.AreEqual(null, doc.Parent); + Assert.AreEqual(2, doc.Children.Count()); + Assert.AreEqual(2001, doc.Children.ElementAt(0).Id); + Assert.AreEqual(2002, doc.Children.ElementAt(1).Id); } private XmlDocument GetMediaXml() @@ -395,7 +395,7 @@ namespace Umbraco.Tests.Cache.PublishedCache Assert.AreEqual(keyVal, doc.Key); Assert.AreEqual(templateIdVal, doc.TemplateId); Assert.AreEqual(sortOrderVal, doc.SortOrder); - Assert.AreEqual(urlNameVal, doc.UrlSegment()); + Assert.AreEqual(urlNameVal, doc.UrlSegment); Assert.AreEqual(nodeTypeAliasVal, doc.ContentType.Alias); Assert.AreEqual(nodeTypeIdVal, doc.ContentType.Id); Assert.AreEqual(writerNameVal, doc.WriterName); diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/DictionaryPublishedContent.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/DictionaryPublishedContent.cs index 3a39d23ccb..db8dc38d6d 100644 --- a/src/Umbraco.Tests/LegacyXmlPublishedCache/DictionaryPublishedContent.cs +++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/DictionaryPublishedContent.cs @@ -136,7 +136,12 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache private readonly Func _getProperty; private readonly IAppCache _appCache; - public override IPublishedContent Parent() => _getParent.Value; + /// + /// Returns 'Media' as the item type + /// + public override PublishedItemType ItemType => PublishedItemType.Media; + + public override IPublishedContent Parent => _getParent.Value; public int ParentId { get; private set; } @@ -148,15 +153,12 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache public override int SortOrder => _sortOrder; - public override string Name(string culture = null) => _name; + public override string Name => _name; - public override DateTime CultureDate(string culture = null) => UpdateDate; + private static readonly Lazy> NoCultures = new Lazy>(() => new Dictionary()); + public override IReadOnlyDictionary Cultures => NoCultures.Value; - // ReSharper disable once CollectionNeverUpdated.Local - private static readonly List EmptyListOfString = new List(); - public override IReadOnlyCollection Cultures => EmptyListOfString; - - public override string UrlSegment(string culture = null) => _urlName; + public override string UrlSegment => _urlName; public override string WriterName => _creatorName; @@ -180,7 +182,9 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache public override IEnumerable Properties => _properties; - public override IEnumerable Children(string culture = null) => _getChildren.Value; + public override IEnumerable Children => _getChildren.Value; + + public override IEnumerable ChildrenForAllCultures => Children; public override IPublishedProperty GetProperty(string alias) { diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedContentCache.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedContentCache.cs index 33348d071a..8de0209c69 100644 --- a/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedContentCache.cs +++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/PublishedContentCache.cs @@ -268,14 +268,14 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache pathParts.Add(urlName); // move to parent node - n = n.Parent(); + n = n.Parent; hasDomains = n != null && _domainCache.HasAssigned(n.Id); } // no domain, respect HideTopLevelNodeFromPath for legacy purposes if (hasDomains == false && _globalSettings.HideTopLevelNodeFromPath) { - if (node.Parent() == null) + if (node.Parent == null) { var rootNode = GetByRoute(preview, "/", true); if (rootNode == null) diff --git a/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedContent.cs b/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedContent.cs index 2edb2bae32..4a60912757 100644 --- a/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedContent.cs +++ b/src/Umbraco.Tests/LegacyXmlPublishedCache/XmlPublishedContent.cs @@ -71,12 +71,17 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache private bool _isDraft; - public override IEnumerable Children(string culture = null) + public override IEnumerable Children { - EnsureNodeInitialized(andChildren: true); - return _children; + get + { + EnsureNodeInitialized(andChildren: true); + return _children; + } } + public override IEnumerable ChildrenForAllCultures => Children; + public override IPublishedProperty GetProperty(string alias) { EnsureNodeInitialized(); @@ -84,10 +89,15 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache return _properties.TryGetValue(alias, out property) ? property : null; } - public override IPublishedContent Parent() + public override PublishedItemType ItemType => PublishedItemType.Content; + + public override IPublishedContent Parent { - EnsureNodeInitialized(andParent: true); - return _parent; + get + { + EnsureNodeInitialized(andParent: true); + return _parent; + } } public override int Id @@ -126,17 +136,17 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache } } - public override string Name(string culture = null) + public override string Name { - EnsureNodeInitialized(); - return _name; + get + { + EnsureNodeInitialized(); + return _name; + } } - public override DateTime CultureDate(string culture = null) => UpdateDate; - - // ReSharper disable once CollectionNeverUpdated.Local - private static readonly List EmptyListOfString = new List(); - public override IReadOnlyCollection Cultures => EmptyListOfString; + private static readonly Lazy> NoCultures = new Lazy>(() => new Dictionary()); + public override IReadOnlyDictionary Cultures => NoCultures.Value; public override string WriterName { @@ -201,10 +211,13 @@ namespace Umbraco.Tests.LegacyXmlPublishedCache } } - public override string UrlSegment(string culture = null) + public override string UrlSegment { - EnsureNodeInitialized(); - return _urlName; + get + { + EnsureNodeInitialized(); + return _urlName; + } } public override int Level diff --git a/src/Umbraco.Tests/Published/NestedContentTests.cs b/src/Umbraco.Tests/Published/NestedContentTests.cs index a1b736ae90..432247b09f 100644 --- a/src/Umbraco.Tests/Published/NestedContentTests.cs +++ b/src/Umbraco.Tests/Published/NestedContentTests.cs @@ -271,10 +271,12 @@ namespace Umbraco.Tests.Published } // ReSharper disable UnassignedGetOnlyAutoProperty + public override PublishedItemType ItemType { get; } public override bool IsDraft(string culture = null) => false; public override bool IsPublished(string culture = null) => true; - public override IPublishedContent Parent() => null; - public override IEnumerable Children(string culture = null) => Enumerable.Empty(); + public override IPublishedContent Parent { get; } + public override IEnumerable Children { get; } + public override IEnumerable ChildrenForAllCultures => Children; public override IPublishedContentType ContentType { get; } // ReSharper restore UnassignedGetOnlyAutoProperty @@ -282,10 +284,9 @@ namespace Umbraco.Tests.Published public override int Id { get; } public override int? TemplateId { get; } public override int SortOrder { get; } - public override string Name(string culture = null) => default; - public override DateTime CultureDate(string culture = null) => throw new NotSupportedException(); - public override IReadOnlyCollection Cultures => throw new NotSupportedException(); - public override string UrlSegment(string culture = null) => default; + public override string Name { get; } + public override IReadOnlyDictionary Cultures => throw new NotSupportedException(); + public override string UrlSegment { get; } public override string WriterName { get; } public override string CreatorName { get; } public override int WriterId { get; } diff --git a/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs b/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs index d9cb8dbbc2..d77d1e4701 100644 --- a/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs +++ b/src/Umbraco.Tests/PublishedContent/NuCacheChildrenTests.cs @@ -231,22 +231,22 @@ namespace Umbraco.Tests.PublishedContent var snapshot = _snapshotService.CreatePublishedSnapshot(previewToken: null); _snapshotAccessor.PublishedSnapshot = snapshot; - Assert.IsNull(snapshot.Content.GetById(1).Parent()); - Assert.IsNull(snapshot.Content.GetById(2).Parent()); - Assert.IsNull(snapshot.Content.GetById(3).Parent()); + Assert.IsNull(snapshot.Content.GetById(1).Parent); + Assert.IsNull(snapshot.Content.GetById(2).Parent); + Assert.IsNull(snapshot.Content.GetById(3).Parent); - Assert.AreEqual(1, snapshot.Content.GetById(4).Parent()?.Id); - Assert.AreEqual(1, snapshot.Content.GetById(5).Parent()?.Id); - Assert.AreEqual(1, snapshot.Content.GetById(6).Parent()?.Id); + Assert.AreEqual(1, snapshot.Content.GetById(4).Parent?.Id); + Assert.AreEqual(1, snapshot.Content.GetById(5).Parent?.Id); + Assert.AreEqual(1, snapshot.Content.GetById(6).Parent?.Id); - Assert.AreEqual(2, snapshot.Content.GetById(7).Parent()?.Id); - Assert.AreEqual(2, snapshot.Content.GetById(8).Parent()?.Id); - Assert.AreEqual(2, snapshot.Content.GetById(9).Parent()?.Id); + Assert.AreEqual(2, snapshot.Content.GetById(7).Parent?.Id); + Assert.AreEqual(2, snapshot.Content.GetById(8).Parent?.Id); + Assert.AreEqual(2, snapshot.Content.GetById(9).Parent?.Id); - Assert.AreEqual(3, snapshot.Content.GetById(10).Parent()?.Id); + Assert.AreEqual(3, snapshot.Content.GetById(10).Parent?.Id); - Assert.AreEqual(4, snapshot.Content.GetById(11).Parent()?.Id); - Assert.AreEqual(4, snapshot.Content.GetById(12).Parent()?.Id); + Assert.AreEqual(4, snapshot.Content.GetById(11).Parent?.Id); + Assert.AreEqual(4, snapshot.Content.GetById(12).Parent?.Id); } [Test] @@ -288,7 +288,7 @@ namespace Umbraco.Tests.PublishedContent documents = snapshot.Content.GetById(3).Children().ToArray(); AssertDocuments(documents); - Assert.IsNull(snapshot.Content.GetById(10).Parent()); + Assert.IsNull(snapshot.Content.GetById(10).Parent); } [Test] @@ -330,7 +330,7 @@ namespace Umbraco.Tests.PublishedContent documents = snapshot.Content.GetById(10).Children().ToArray(); AssertDocuments(documents, "N1"); - Assert.AreEqual(10, snapshot.Content.GetById(1).Parent()?.Id); + Assert.AreEqual(10, snapshot.Content.GetById(1).Parent?.Id); } [Test] @@ -509,7 +509,7 @@ namespace Umbraco.Tests.PublishedContent documents = snapshot.Content.GetById(2).Children().ToArray(); AssertDocuments(documents, "N9", "N8"); - Assert.AreEqual(1, snapshot.Content.GetById(7).Parent()?.Id); + Assert.AreEqual(1, snapshot.Content.GetById(7).Parent?.Id); } private void AssertDocuments(IPublishedContent[] documents, params string[] names) diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentDataTableTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentDataTableTests.cs index e4bf02fec0..5c22295547 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentDataTableTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentDataTableTests.cs @@ -10,9 +10,9 @@ using Umbraco.Core.Logging; using Umbraco.Core.Models; using Umbraco.Core.Models.PublishedContent; using Umbraco.Core.PropertyEditors; -using Umbraco.Core.Services; using Umbraco.Tests.TestHelpers; using Umbraco.Web; +using PublishedContentExtensions = Umbraco.Web.PublishedContentExtensions; namespace Umbraco.Tests.PublishedContent { @@ -97,7 +97,7 @@ namespace Umbraco.Tests.PublishedContent { var doc = GetContent(true, 1); //change a doc type alias - var c = (TestPublishedContent)doc.Children().ElementAt(0); + var c = (TestPublishedContent)doc.Children.ElementAt(0); c.ContentType = new PublishedContentType(22, "DontMatch", PublishedItemType.Content, Enumerable.Empty(), Enumerable.Empty(), ContentVariation.Nothing); var dt = doc.ChildrenAsTable(Current.Services, "Child"); @@ -139,6 +139,8 @@ namespace Umbraco.Tests.PublishedContent TemplateId = 5, UpdateDate = DateTime.Now, Path = "-1,3", + UrlSegment = "home-page", + Name = "Page" + Guid.NewGuid().ToString(), Version = Guid.NewGuid(), WriterId = 1, WriterName = "Shannon", @@ -146,8 +148,6 @@ namespace Umbraco.Tests.PublishedContent Level = 1, Children = new List() }; - d.SetName("Page" + Guid.NewGuid()); - d.SetUrlSegment("home-page"); d.Properties = new Collection(new List { new RawValueProperty(factory.CreatePropertyType("property1", 1), d, "value" + indexVals), @@ -183,26 +183,16 @@ namespace Umbraco.Tests.PublishedContent // l8tr... private class TestPublishedContent : IPublishedContent { - private readonly Dictionary _names = new Dictionary(); - private readonly Dictionary _urlSegments = new Dictionary(); - - public string Url(string culture = null, UrlMode mode = UrlMode.Auto) => default; - - IPublishedContent IPublishedContent.Parent() => Parent; - - IEnumerable IPublishedContent.Children(string culture = null) => Children; - + public string Url { get; set; } + public PublishedItemType ItemType { get; set; } public IPublishedContent Parent { get; set; } public int Id { get; set; } public Guid Key { get; set; } public int? TemplateId { get; set; } public int SortOrder { get; set; } - public string Name(string culture = null) => _names.TryGetValue(culture ?? "", out var name) ? name : null; - public void SetName(string name, string culture = null) => _names[culture ?? ""] = name; - public DateTime CultureDate(string culture = null) => throw new NotSupportedException(); - public IReadOnlyCollection Cultures => throw new NotSupportedException(); - public string UrlSegment(string culture = null) => _urlSegments.TryGetValue(culture ?? "", out var urlSegment) ? urlSegment : null; - public void SetUrlSegment(string urlSegment, string culture = null) => _urlSegments[culture ?? ""] = urlSegment; + public string Name { get; set; } + public IReadOnlyDictionary Cultures => throw new NotSupportedException(); + public string UrlSegment { get; set; } public string WriterName { get; set; } public string CreatorName { get; set; } public int WriterId { get; set; } @@ -218,6 +208,7 @@ namespace Umbraco.Tests.PublishedContent public IEnumerable Properties { get; set; } public IEnumerable Children { get; set; } + public IEnumerable ChildrenForAllCultures => Children; public IPublishedProperty GetProperty(string alias) { @@ -232,7 +223,7 @@ namespace Umbraco.Tests.PublishedContent IPublishedContent content = this; while (content != null && (property == null || property.HasValue() == false)) { - content = content.Parent(); + content = content.Parent; property = content == null ? null : content.GetProperty(alias); } diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentLanguageVariantTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentLanguageVariantTests.cs index dc726c5748..62447742ff 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentLanguageVariantTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentLanguageVariantTests.cs @@ -122,8 +122,11 @@ namespace Umbraco.Tests.PublishedContent { Id = 1, SortOrder = 0, + Name = "Content 1", + UrlSegment = "content-1", Path = "/1", Level = 1, + Url = "/content-1", ParentId = -1, ChildIds = new[] { 2 }, Properties = new Collection @@ -131,16 +134,16 @@ namespace Umbraco.Tests.PublishedContent prop1, prop2, noprop } }; - item1.SetName("Content 1"); - item1.SetUrlSegment("content-1"); - item1.SetUrl("/content-1"); var item2 = new SolidPublishedContent(contentType1) { Id = 2, SortOrder = 0, + Name = "Content 2", + UrlSegment = "content-2", Path = "/1/2", Level = 2, + Url = "/content-1/content-2", ParentId = 1, ChildIds = new int[] { 3 }, Properties = new Collection @@ -148,9 +151,6 @@ namespace Umbraco.Tests.PublishedContent prop3 } }; - item2.SetName("Content 2"); - item2.SetUrlSegment("content-2"); - item2.SetUrl("/content-1/content-2"); var prop4 = new SolidPublishedPropertyWithLanguageVariants { @@ -164,8 +164,11 @@ namespace Umbraco.Tests.PublishedContent { Id = 3, SortOrder = 0, + Name = "Content 3", + UrlSegment = "content-3", Path = "/1/2/3", Level = 3, + Url = "/content-1/content-2/content-3", ParentId = 2, ChildIds = new int[] { }, Properties = new Collection @@ -173,15 +176,12 @@ namespace Umbraco.Tests.PublishedContent prop4 } }; - item3.SetName("Content 3"); - item3.SetUrlSegment("content-3"); - item3.SetUrl("/content-1/content-2/content-3"); - item1.SetChildren(new List { item2 }); - item2.SetParent(item1); + item1.Children = new List { item2 }; + item2.Parent = item1; - item2.SetChildren(new List { item3 }); - item3.SetParent(item2); + item2.Children = new List { item3 }; + item3.Parent = item2; cache.Add(item1); cache.Add(item2); @@ -247,7 +247,7 @@ namespace Umbraco.Tests.PublishedContent [Test] public void Do_Not_Get_Content_Recursively_Unless_Requested() { - var content = Current.UmbracoContext.Content.GetAtRoot().First().Children().First(); + var content = Current.UmbracoContext.Content.GetAtRoot().First().Children.First(); var value = content.Value("welcomeText2"); Assert.IsNull(value); } @@ -255,7 +255,7 @@ namespace Umbraco.Tests.PublishedContent [Test] public void Can_Get_Content_Recursively() { - var content = Current.UmbracoContext.Content.GetAtRoot().First().Children().First(); + var content = Current.UmbracoContext.Content.GetAtRoot().First().Children.First(); var value = content.Value("welcomeText2", fallback: Fallback.ToAncestors); Assert.AreEqual("Welcome", value); } @@ -263,7 +263,7 @@ namespace Umbraco.Tests.PublishedContent [Test] public void Do_Not_Get_Content_Recursively_Unless_Requested2() { - var content = Current.UmbracoContext.Content.GetAtRoot().First().Children().First().Children().First(); + var content = Current.UmbracoContext.Content.GetAtRoot().First().Children.First().Children.First(); Assert.IsNull(content.GetProperty("welcomeText2")); var value = content.Value("welcomeText2"); Assert.IsNull(value); @@ -272,7 +272,7 @@ namespace Umbraco.Tests.PublishedContent [Test] public void Can_Get_Content_Recursively2() { - var content = Current.UmbracoContext.Content.GetAtRoot().First().Children().First().Children().First(); + var content = Current.UmbracoContext.Content.GetAtRoot().First().Children.First().Children.First(); Assert.IsNull(content.GetProperty("welcomeText2")); var value = content.Value("welcomeText2", fallback: Fallback.ToAncestors); Assert.AreEqual("Welcome", value); @@ -281,7 +281,7 @@ namespace Umbraco.Tests.PublishedContent [Test] public void Can_Get_Content_Recursively3() { - var content = Current.UmbracoContext.Content.GetAtRoot().First().Children().First().Children().First(); + var content = Current.UmbracoContext.Content.GetAtRoot().First().Children.First().Children.First(); Assert.IsNull(content.GetProperty("noprop")); var value = content.Value("noprop", fallback: Fallback.ToAncestors); // property has no value but we still get the value (ie, the converter would do something) @@ -292,7 +292,7 @@ namespace Umbraco.Tests.PublishedContent public void Can_Get_Content_With_Recursive_Priority() { Current.VariationContextAccessor.VariationContext = new VariationContext("nl"); - var content = Current.UmbracoContext.Content.GetAtRoot().First().Children().First(); + var content = Current.UmbracoContext.Content.GetAtRoot().First().Children.First(); var value = content.Value("welcomeText", "nl", fallback: Fallback.To(Fallback.Ancestors, Fallback.Language)); @@ -303,7 +303,7 @@ namespace Umbraco.Tests.PublishedContent [Test] public void Can_Get_Content_With_Fallback_Language_Priority() { - var content = Current.UmbracoContext.Content.GetAtRoot().First().Children().First(); + var content = Current.UmbracoContext.Content.GetAtRoot().First().Children.First(); var value = content.Value("welcomeText", "nl", fallback: Fallback.ToLanguage); // No Dutch value is directly assigned. Check has fallen back to English value from language variant. @@ -313,14 +313,14 @@ namespace Umbraco.Tests.PublishedContent [Test] public void Throws_For_Non_Supported_Fallback() { - var content = Current.UmbracoContext.Content.GetAtRoot().First().Children().First(); + var content = Current.UmbracoContext.Content.GetAtRoot().First().Children.First(); Assert.Throws(() => content.Value("welcomeText", "nl", fallback: Fallback.To(999))); } [Test] public void Can_Fallback_To_Default_Value() { - var content = Current.UmbracoContext.Content.GetAtRoot().First().Children().First(); + var content = Current.UmbracoContext.Content.GetAtRoot().First().Children.First(); // no Dutch value is assigned, so getting null var value = content.Value("welcomeText", "nl"); @@ -338,7 +338,7 @@ namespace Umbraco.Tests.PublishedContent [Test] public void Can_Have_Custom_Default_Value() { - var content = Current.UmbracoContext.Content.GetAtRoot().First().Children().First(); + var content = Current.UmbracoContext.Content.GetAtRoot().First().Children.First(); // HACK: the value, pretend the converter would return something var prop = content.GetProperty("welcomeText") as SolidPublishedPropertyWithLanguageVariants; diff --git a/src/Umbraco.Tests/PublishedContent/PublishedContentMoreTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedContentMoreTests.cs index abd4771547..440474ae74 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedContentMoreTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedContentMoreTests.cs @@ -29,8 +29,11 @@ namespace Umbraco.Tests.PublishedContent { Id = 1, SortOrder = 0, + Name = "Content 1", + UrlSegment = "content-1", Path = "/1", Level = 1, + Url = "/content-1", ParentId = -1, ChildIds = new int[] { }, Properties = new Collection @@ -44,17 +47,17 @@ namespace Umbraco.Tests.PublishedContent } } }; - content.SetName("Content 1"); - content.SetUrlSegment("content-1"); - content.SetUrl("/content-1"); cache.Add(content); content = new SolidPublishedContent(contentType2) { Id = 2, SortOrder = 1, + Name = "Content 2", + UrlSegment = "content-2", Path = "/2", Level = 1, + Url = "/content-2", ParentId = -1, ChildIds = new int[] { }, Properties = new Collection @@ -68,17 +71,17 @@ namespace Umbraco.Tests.PublishedContent } } }; - content.SetName("Content 2"); - content.SetUrlSegment("content-2"); - content.SetUrl("/content-2"); cache.Add(content); content = new SolidPublishedContent(contentType2Sub) { Id = 3, SortOrder = 2, + Name = "Content 2Sub", + UrlSegment = "content-2sub", Path = "/3", Level = 1, + Url = "/content-2sub", ParentId = -1, ChildIds = new int[] { }, Properties = new Collection @@ -92,9 +95,6 @@ namespace Umbraco.Tests.PublishedContent } } }; - content.SetName("Content 2Sub"); - content.SetUrlSegment("content-2sub"); - content.SetUrl("/content-2sub"); cache.Add(content); } @@ -114,17 +114,17 @@ namespace Umbraco.Tests.PublishedContent .ToIndexedArray(); var item = items[0]; - Assert.AreEqual("Content 1", item.Content.Name()); + Assert.AreEqual("Content 1", item.Content.Name); Assert.IsTrue(item.IsFirst()); Assert.IsFalse(item.IsLast()); item = items[1]; - Assert.AreEqual("Content 2", item.Content.Name()); + Assert.AreEqual("Content 2", item.Content.Name); Assert.IsFalse(item.IsFirst()); Assert.IsFalse(item.IsLast()); item = items[2]; - Assert.AreEqual("Content 2Sub", item.Content.Name()); + Assert.AreEqual("Content 2Sub", item.Content.Name); Assert.IsFalse(item.IsFirst()); Assert.IsTrue(item.IsLast()); } @@ -157,7 +157,7 @@ namespace Umbraco.Tests.PublishedContent var content = Current.UmbracoContext.Content.GetAtRoot() .OfType() .First(x => x.Prop1 == 1234); - Assert.AreEqual("Content 2", content.Name()); + Assert.AreEqual("Content 2", content.Name); Assert.AreEqual(1234, content.Prop1); } diff --git a/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs index c2cf22f85f..b789eb0ef8 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedMediaTests.cs @@ -416,13 +416,13 @@ namespace Umbraco.Tests.PublishedContent var mSubChild3 = MakeNewMedia("SubChild3", mType, user, mChild1.Id); var publishedRoot = GetNode(mRoot.Id); - Assert.AreEqual(null, publishedRoot.Parent()); + Assert.AreEqual(null, publishedRoot.Parent); var publishedChild1 = GetNode(mChild1.Id); - Assert.AreEqual(mRoot.Id, publishedChild1.Parent().Id); + Assert.AreEqual(mRoot.Id, publishedChild1.Parent.Id); var publishedSubChild1 = GetNode(mSubChild1.Id); - Assert.AreEqual(mChild1.Id, publishedSubChild1.Parent().Id); + Assert.AreEqual(mChild1.Id, publishedSubChild1.Parent.Id); } [Test] diff --git a/src/Umbraco.Tests/PublishedContent/PublishedRouterTests.cs b/src/Umbraco.Tests/PublishedContent/PublishedRouterTests.cs index ea3a00371a..d8dbabb569 100644 --- a/src/Umbraco.Tests/PublishedContent/PublishedRouterTests.cs +++ b/src/Umbraco.Tests/PublishedContent/PublishedRouterTests.cs @@ -58,13 +58,13 @@ namespace Umbraco.Tests.PublishedContent { var pc = new Mock(); pc.Setup(content => content.Id).Returns(1); - pc.Setup(content => content.Name(It.IsAny())).Returns("test"); + pc.Setup(content => content.Name).Returns("test"); pc.Setup(content => content.WriterName).Returns("admin"); pc.Setup(content => content.CreatorName).Returns("admin"); pc.Setup(content => content.CreateDate).Returns(DateTime.Now); pc.Setup(content => content.UpdateDate).Returns(DateTime.Now); pc.Setup(content => content.Path).Returns("-1,1"); - pc.Setup(content => content.Parent()).Returns(() => null); + pc.Setup(content => content.Parent).Returns(() => null); pc.Setup(content => content.Properties).Returns(new Collection()); pc.Setup(content => content.ContentType).Returns(new PublishedContentType(22, "anything", PublishedItemType.Content, Enumerable.Empty(), Enumerable.Empty(), ContentVariation.Nothing)); return pc; diff --git a/src/Umbraco.Tests/PublishedContent/RootNodeTests.cs b/src/Umbraco.Tests/PublishedContent/RootNodeTests.cs index be94923ad0..4aad3d0acb 100644 --- a/src/Umbraco.Tests/PublishedContent/RootNodeTests.cs +++ b/src/Umbraco.Tests/PublishedContent/RootNodeTests.cs @@ -20,7 +20,7 @@ namespace Umbraco.Tests.PublishedContent content = ctx.Content.GetById(1046); Assert.IsNotNull(content); Assert.AreEqual(1, content.Level); - Assert.IsNull(content.Parent()); + Assert.IsNull(content.Parent); // non-existing content is null content = ctx.Content.GetById(666); diff --git a/src/Umbraco.Tests/PublishedContent/SolidPublishedSnapshot.cs b/src/Umbraco.Tests/PublishedContent/SolidPublishedSnapshot.cs index fbb2a7549b..ab5a65146a 100644 --- a/src/Umbraco.Tests/PublishedContent/SolidPublishedSnapshot.cs +++ b/src/Umbraco.Tests/PublishedContent/SolidPublishedSnapshot.cs @@ -102,7 +102,7 @@ namespace Umbraco.Tests.PublishedContent public override IEnumerable GetAtRoot(bool preview) { - return _content.Values.Where(x => x.Parent() == null); + return _content.Values.Where(x => x.Parent == null); } public override IPublishedContent GetSingleByXPath(bool preview, string xpath, Core.Xml.XPathVariable[] vars) @@ -158,10 +158,6 @@ namespace Umbraco.Tests.PublishedContent internal class SolidPublishedContent : IPublishedContent { - private readonly Dictionary _names = new Dictionary(); - private readonly Dictionary _urlSegments = new Dictionary(); - private readonly Dictionary _urls = new Dictionary(); - #region Constructor public SolidPublishedContent(IPublishedContentType contentType) @@ -184,12 +180,10 @@ namespace Umbraco.Tests.PublishedContent public Guid Key { get; set; } public int? TemplateId { get; set; } public int SortOrder { get; set; } - public string Name(string culture = null) => _names.TryGetValue(culture ?? "", out var name) ? name : null; - public void SetName(string name, string culture = null) => _names[culture ?? ""] = name; - public DateTime CultureDate(string culture = null) => throw new NotSupportedException(); - public IReadOnlyCollection Cultures => throw new NotSupportedException(); - public string UrlSegment(string culture = null) => _urlSegments.TryGetValue(culture ?? "", out var urlSegment) ? urlSegment : null; - public void SetUrlSegment(string urlSegment, string culture = null) => _urlSegments[culture ?? ""] = urlSegment; + public string Name { get; set; } + public PublishedCultureInfo GetCulture(string culture = null) => throw new NotSupportedException(); + public IReadOnlyDictionary Cultures => throw new NotSupportedException(); + public string UrlSegment { get; set; } public string WriterName { get; set; } public string CreatorName { get; set; } public int WriterId { get; set; } @@ -199,9 +193,9 @@ namespace Umbraco.Tests.PublishedContent public DateTime UpdateDate { get; set; } public Guid Version { get; set; } public int Level { get; set; } - public string Url(string culture = null, UrlMode mode = UrlMode.Auto) => _urls.TryGetValue(culture ?? "", out var url) ? url : null; - public void SetUrl(string url, string culture = null) => _urls[culture ?? ""] = url; + public string Url { get; set; } + public PublishedItemType ItemType { get { return PublishedItemType.Content; } } public bool IsDraft(string culture = null) => false; public bool IsPublished(string culture = null) => true; @@ -212,12 +206,9 @@ namespace Umbraco.Tests.PublishedContent public int ParentId { get; set; } public IEnumerable ChildIds { get; set; } - private IPublishedContent _parent; - public IPublishedContent Parent() => _parent; - public void SetParent(IPublishedContent parent) => _parent = parent; - private IEnumerable _children; - public IEnumerable Children(string culture = null) => _children; - public void SetChildren(IEnumerable children) => _children = children; + public IPublishedContent Parent { get; set; } + public IEnumerable Children { get; set; } + public IEnumerable ChildrenForAllCultures => Children; #endregion @@ -244,7 +235,7 @@ namespace Umbraco.Tests.PublishedContent IPublishedContent content = this; while (content != null && (property == null || property.HasValue() == false)) { - content = content.Parent(); + content = content.Parent; property = content == null ? null : content.GetProperty(alias); } diff --git a/src/Umbraco.Tests/TestHelpers/Stubs/TestPublishedContent.cs b/src/Umbraco.Tests/TestHelpers/Stubs/TestPublishedContent.cs index 1fb090e220..62f93d106f 100644 --- a/src/Umbraco.Tests/TestHelpers/Stubs/TestPublishedContent.cs +++ b/src/Umbraco.Tests/TestHelpers/Stubs/TestPublishedContent.cs @@ -7,38 +7,20 @@ namespace Umbraco.Tests.TestHelpers.Stubs { internal class TestPublishedContent : PublishedElement, IPublishedContent { - private readonly Dictionary _names = new Dictionary(); - private readonly Dictionary _urlSegments = new Dictionary(); - private readonly Dictionary _cultures; - - public TestPublishedContent(IPublishedContentType contentType, int id, Guid key, Dictionary values, bool previewing, Dictionary cultures = null) + public TestPublishedContent(IPublishedContentType contentType, int id, Guid key, Dictionary values, bool previewing, Dictionary cultures = null) : base(contentType, key, values, previewing) { Id = id; - _cultures = cultures ?? new Dictionary(); + Cultures = cultures ?? new Dictionary(); } public int Id { get; } public int? TemplateId { get; set; } public int SortOrder { get; set; } - public string Name(string culture = null) => _names.TryGetValue(culture ?? "", out var name) ? name : null; - public void SetName(string name, string culture = null) => _names[culture ?? ""] = name; + public string Name { get; set; } public IVariationContextAccessor VariationContextAccessor { get; set; } - public DateTime CultureDate(string culture = null) - { - // handle context culture - if (culture == null) - culture = VariationContextAccessor?.VariationContext?.Culture; - - // no invariant culture infos - if (culture == "" || Cultures == null) return UpdateDate; - - // get - return _cultures.TryGetValue(culture, out var date) ? date : DateTime.MinValue; - } - public IReadOnlyCollection Cultures { get; set; } - public string UrlSegment(string culture = null) => _urlSegments.TryGetValue(culture ?? "", out var urlSegment) ? urlSegment : null; - public void SetUrlSegment(string urlSegment, string culture = null) => _urlSegments[culture ?? ""] = urlSegment; + public IReadOnlyDictionary Cultures { get; set; } + public string UrlSegment { get; set; } public string DocumentTypeAlias => ContentType.Alias; public int DocumentTypeId { get; set; } public string WriterName { get; set; } @@ -50,15 +32,13 @@ namespace Umbraco.Tests.TestHelpers.Stubs public DateTime UpdateDate { get; set; } public Guid Version { get; set; } public int Level { get; set; } - public string Url(string culture = null, UrlMode mode = UrlMode.Auto) => throw new NotSupportedException(); + public string Url { get; set; } + public PublishedItemType ItemType => ContentType.ItemType; public bool IsDraft(string culture = null) => false; public bool IsPublished(string culture = null) => true; - private IPublishedContent _parent; - public IPublishedContent Parent() => _parent; - public void SetParent(IPublishedContent parent) => _parent = parent; - private IEnumerable _children; - public IEnumerable Children(string culture = null) => _children; - public void SetChildren(IEnumerable children) => _children = children; + public IPublishedContent Parent { get; set; } + public IEnumerable Children { get; set; } + public IEnumerable ChildrenForAllCultures => Children; // copied from PublishedContentBase public IPublishedProperty GetProperty(string alias, bool recurse) @@ -70,7 +50,7 @@ namespace Umbraco.Tests.TestHelpers.Stubs var firstNonNullProperty = property; while (content != null && (property == null || property.HasValue() == false)) { - content = content.Parent(); + content = content.Parent; property = content?.GetProperty(alias); if (firstNonNullProperty == null && property != null) firstNonNullProperty = property; } diff --git a/src/Umbraco.Tests/Web/TemplateUtilitiesTests.cs b/src/Umbraco.Tests/Web/TemplateUtilitiesTests.cs index c0a6e97dda..3a5405548b 100644 --- a/src/Umbraco.Tests/Web/TemplateUtilitiesTests.cs +++ b/src/Umbraco.Tests/Web/TemplateUtilitiesTests.cs @@ -99,7 +99,7 @@ namespace Umbraco.Tests.Web var snapshotService = Mock.Of(); Mock.Get(snapshotService).Setup(x => x.CreatePublishedSnapshot(It.IsAny())).Returns(snapshot); var media = Mock.Of(); - Mock.Get(media).Setup(x => x.Url(It.IsAny(), It.IsAny())).Returns("/media/1001/my-image.jpg"); + Mock.Get(media).Setup(x => x.Url).Returns("/media/1001/my-image.jpg"); var mediaCache = Mock.Of(); Mock.Get(mediaCache).Setup(x => x.GetById(It.IsAny())).Returns(media); diff --git a/src/Umbraco.Web.UI.Client/package-lock.json b/src/Umbraco.Web.UI.Client/package-lock.json index c1c85a9688..e8a9d6b1f7 100644 --- a/src/Umbraco.Web.UI.Client/package-lock.json +++ b/src/Umbraco.Web.UI.Client/package-lock.json @@ -1222,7 +1222,7 @@ "arraybuffer.slice": { "version": "0.0.7", "resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz", - "integrity": "sha512-wGUIVQXuehL5TCqQun8OW81jGzAWycqzFF8lFp+GOM5BXLYj3bKNsYC4daB7n6XjCqxQA/qgTJ+8ANR3acjrog==", + "integrity": "sha1-O7xCdd1YTMGxCAm4nU6LY6aednU=", "dev": true }, "asap": { @@ -1284,7 +1284,7 @@ "async-limiter": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.0.tgz", - "integrity": "sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg==", + "integrity": "sha1-ePrtjD0HSrgfIrTphdeehzj3IPg=", "dev": true }, "asynckit": { @@ -1536,7 +1536,7 @@ "bl": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/bl/-/bl-1.2.2.tgz", - "integrity": "sha512-e8tQYnZodmebYDWGH7KMRvtzKXaJHx3BbilrgZCfvyLUYdKpK1t5PSPmpkny/SgiTSCnjfLW7v5rlONXVFkQEA==", + "integrity": "sha1-oWCRFxcQPAdBDO9j71Gzl8Alr5w=", "dev": true, "requires": { "readable-stream": "^2.3.5", @@ -1551,7 +1551,7 @@ }, "readable-stream": { "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, "requires": { @@ -1566,7 +1566,7 @@ }, "string_decoder": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", + "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", "dev": true, "requires": { @@ -1740,7 +1740,7 @@ "buffer-alloc": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/buffer-alloc/-/buffer-alloc-1.2.0.tgz", - "integrity": "sha512-CFsHQgjtW1UChdXgbyJGtnm+O/uLQeZdtbDo8mfUgYXCHSM1wgrVxXm6bSyrUuErEb+4sYVGCzASBRot7zyrow==", + "integrity": "sha1-iQ3ZDZI6hz4I4Q5f1RpX5bfM4Ow=", "dev": true, "requires": { "buffer-alloc-unsafe": "^1.1.0", @@ -1750,7 +1750,7 @@ "buffer-alloc-unsafe": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/buffer-alloc-unsafe/-/buffer-alloc-unsafe-1.1.0.tgz", - "integrity": "sha512-TEM2iMIEQdJ2yjPJoSIsldnleVaAk1oW3DBVUykyOLsEsFmEc9kn+SFFPz+gl54KQNxlDnAwCXosOS9Okx2xAg==", + "integrity": "sha1-vX3CauKXLQ7aJTvgYdupkjScGfA=", "dev": true }, "buffer-crc32": { @@ -2516,7 +2516,7 @@ "content-type": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", - "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==", + "integrity": "sha1-4TjMdeBAxyexlm/l5fjJruJW/js=", "dev": true }, "continuable-cache": { @@ -4045,7 +4045,7 @@ "debug": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "integrity": "sha1-W7WgZyYotkFJVmuhaBnmFRjGcmE=", "dev": true, "requires": { "ms": "2.0.0" @@ -4061,7 +4061,7 @@ }, "engine.io-client": { "version": "3.2.1", - "resolved": "https://registry.npmjs.org/engine.io-client/-/engine.io-client-3.2.1.tgz", + "resolved": "http://registry.npmjs.org/engine.io-client/-/engine.io-client-3.2.1.tgz", "integrity": "sha512-y5AbkytWeM4jQr7m/koQLc5AxpRKC1hEVUb/s1FUAWEJq5AzJJ4NLvzuKPuxtDi5Mq755WuDvZ6Iv2rXj4PTzw==", "dev": true, "requires": { @@ -4081,7 +4081,7 @@ "debug": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "integrity": "sha1-W7WgZyYotkFJVmuhaBnmFRjGcmE=", "dev": true, "requires": { "ms": "2.0.0" @@ -4476,13 +4476,13 @@ "eventemitter3": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.1.0.tgz", - "integrity": "sha512-ivIvhpq/Y0uSjcHDcOIccjmYjGLcP09MFGE7ysAwkAvkXfpZlC985pH2/ui64DKazbTW/4kN3yqozUxlXzI6cA==", + "integrity": "sha1-CQtNbNvWRe0Qv3UNS1QHlC17oWM=", "dev": true }, "exec-buffer": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/exec-buffer/-/exec-buffer-3.2.0.tgz", - "integrity": "sha512-wsiD+2Tp6BWHoVv3B+5Dcx6E7u5zky+hUwOHjuH2hKSLR3dvRmX8fk8UD8uqQixHs4Wk6eDmiegVrMPjKj7wpA==", + "integrity": "sha1-sWhtvZBMfPmC5lLB9aebHlVzCCs=", "dev": true, "optional": true, "requires": { @@ -5244,7 +5244,7 @@ "fs-constants": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", - "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==", + "integrity": "sha1-a+Dem+mYzhavivwkSXue6bfM2a0=", "dev": true }, "fs-extra": { @@ -5309,8 +5309,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -5331,14 +5330,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -5353,20 +5350,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -5483,8 +5477,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -5496,7 +5489,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -5511,7 +5503,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -5519,14 +5510,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.2.4", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -5545,7 +5534,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -5626,8 +5614,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -5639,7 +5626,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -5725,8 +5711,7 @@ "safe-buffer": { "version": "5.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -5762,7 +5747,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -5782,7 +5766,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -5826,14 +5809,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, @@ -7575,7 +7556,7 @@ "has-binary2": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has-binary2/-/has-binary2-1.0.3.tgz", - "integrity": "sha512-G1LWKhDSvhGeAQ8mPVQlqNcOB2sJdwATtZKl2pDKKHfpf/rYj24lkinxf69blJbnsvtqqNU+L3SL50vzZhXOnw==", + "integrity": "sha1-d3asYn8+p3JQz8My2rfd9eT10R0=", "dev": true, "requires": { "isarray": "2.0.1" @@ -7778,7 +7759,7 @@ "http-proxy": { "version": "1.17.0", "resolved": "https://registry.npmjs.org/http-proxy/-/http-proxy-1.17.0.tgz", - "integrity": "sha512-Taqn+3nNvYRfJ3bGvKfBSRwy1v6eePlm3oc/aWVxZp57DQr5Eq3xhKJi7Z4hZpS8PC3H4qI+Yly5EmFacGuA/g==", + "integrity": "sha1-etOElGWPhGBeL220Q230EPTlvpo=", "dev": true, "requires": { "eventemitter3": "^3.0.0", @@ -9335,7 +9316,7 @@ "lowercase-keys": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/lowercase-keys/-/lowercase-keys-1.0.1.tgz", - "integrity": "sha512-G2Lj61tXDnVFFOi8VZds+SoQjtQC3dgokKdDG2mTm1tx4m50NUHBOZSBwQQHyy0V12A0JTG4icfZQH+xPyh8VA==", + "integrity": "sha1-b54wtHCE2XGnyCD/FabFFnt0wm8=", "dev": true }, "lpad-align": { @@ -9369,7 +9350,7 @@ "make-dir": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-1.3.0.tgz", - "integrity": "sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ==", + "integrity": "sha1-ecEDO4BRW9bSTsmTPoYMp17ifww=", "dev": true, "requires": { "pify": "^3.0.0" @@ -12735,7 +12716,7 @@ "dependencies": { "minimist": { "version": "0.0.10", - "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", + "resolved": "http://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=", "dev": true }, @@ -13616,7 +13597,7 @@ "qjobs": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/qjobs/-/qjobs-1.2.0.tgz", - "integrity": "sha512-8YOJEHtxpySA3fFDyCRxA+UUV+fA+rTWnuWvylOK/NCjhY+b4ocCtmu8TtsWb+mYeU+GCHf/S66KZF/AsteKHg==", + "integrity": "sha1-xF6cYYAL0IfviNfiVkI73Unl0HE=", "dev": true }, "qs": { @@ -14775,7 +14756,7 @@ }, "socket.io-parser": { "version": "3.2.0", - "resolved": "https://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.2.0.tgz", + "resolved": "http://registry.npmjs.org/socket.io-parser/-/socket.io-parser-3.2.0.tgz", "integrity": "sha512-FYiBx7rc/KORMJlgsXysflWx/RIvtqZbyGLlHZvjfmPTPeuD/I8MaW7cfFrj5tRltICJdgwflhfZ3NVVbVLFQA==", "dev": true, "requires": { @@ -14787,7 +14768,7 @@ "debug": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", - "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "integrity": "sha1-W7WgZyYotkFJVmuhaBnmFRjGcmE=", "dev": true, "requires": { "ms": "2.0.0" @@ -14920,7 +14901,7 @@ }, "chalk": { "version": "1.1.3", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", + "resolved": "http://registry.npmjs.org/chalk/-/chalk-1.1.3.tgz", "integrity": "sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg=", "dev": true, "optional": true, @@ -15328,7 +15309,7 @@ "strip-outer": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/strip-outer/-/strip-outer-1.0.1.tgz", - "integrity": "sha512-k55yxKHwaXnpYGsOzg4Vl8+tDrWylxDEpknGjhTiZB8dFRU5rTo9CAzeycivxV3s+zlTKwrs6WxMxR95n26kwg==", + "integrity": "sha1-sv0qv2YEudHmATBXGV34Nrip1jE=", "dev": true, "requires": { "escape-string-regexp": "^1.0.2" @@ -15488,7 +15469,7 @@ }, "readable-stream": { "version": "2.3.6", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", + "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", "dev": true, "requires": { @@ -15731,7 +15712,7 @@ "to-buffer": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/to-buffer/-/to-buffer-1.1.1.tgz", - "integrity": "sha512-lx9B5iv7msuFYE3dytT+KE5tap+rNYw+K4jVkb9R/asAb+pbBSM17jtunHplhBe6RRJdZx3Pn2Jph24O32mOVg==", + "integrity": "sha1-STvUj2LXxD/N7TE6A9ytsuEhOoA=", "dev": true }, "to-fast-properties": { @@ -15860,7 +15841,7 @@ "type-is": { "version": "1.6.16", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.16.tgz", - "integrity": "sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q==", + "integrity": "sha1-+JzjQVQcZysl7nrjxz3uOyvlAZQ=", "dev": true, "requires": { "media-typer": "0.3.0", @@ -15902,7 +15883,7 @@ "ultron": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/ultron/-/ultron-1.1.1.tgz", - "integrity": "sha512-UIEXBNeYmKptWH6z8ZnqTeS8fV74zG0/eRU9VGkpzz+LIJNs8W/zM/L+7ctCkRrgbNnnR0xxw4bKOr0cW0N0Og==", + "integrity": "sha1-n+FTahCmZKZSZqHjzPhf02MCvJw=", "dev": true }, "unc-path-regex": { @@ -16505,7 +16486,7 @@ "ws": { "version": "3.3.3", "resolved": "https://registry.npmjs.org/ws/-/ws-3.3.3.tgz", - "integrity": "sha512-nnWLa/NwZSt4KQJu51MYlCcSQ5g7INpOrOMt4XV8j4dqTXdmlUmSHQ8/oLC069ckre0fRsgfvsKwbTdtKLCDkA==", + "integrity": "sha1-8c+E/i1ekB686U767OeF8YeiKPI=", "dev": true, "requires": { "async-limiter": "~1.0.0", diff --git a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesFromChangeableSource.cshtml b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesFromChangeableSource.cshtml index 495141f821..46c8de695c 100755 --- a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesFromChangeableSource.cshtml +++ b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesFromChangeableSource.cshtml @@ -19,7 +19,7 @@ { @* Get the starting page *@ var startNode = Umbraco.Content(startNodeId); - var selection = startNode.Children().Where(x => x.IsVisible()).ToArray(); + var selection = startNode.Children.Where(x => x.IsVisible()).ToArray(); if (selection.Length > 0) { diff --git a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesFromCurrentPage.cshtml b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesFromCurrentPage.cshtml index 6ba7471899..e6606d6204 100755 --- a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesFromCurrentPage.cshtml +++ b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesFromCurrentPage.cshtml @@ -9,7 +9,7 @@ - It then generates links so the visitor can go to each page *@ -@{ var selection = Model.Content.Children().Where(x => x.IsVisible()).ToArray(); } +@{ var selection = Model.Content.Children.Where(x => x.IsVisible()).ToArray(); } @if (selection.Length > 0) { diff --git a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByDate.cshtml b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByDate.cshtml index 4ace3da7d1..2c2cc4422b 100755 --- a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByDate.cshtml +++ b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByDate.cshtml @@ -10,7 +10,7 @@ - It then generates links so the visitor can go to each page *@ -@{ var selection = Model.Content.Children().Where(x => x.IsVisible()).OrderByDescending(x => x.CreateDate).ToArray(); } +@{ var selection = Model.Content.Children.Where(x => x.IsVisible()).OrderByDescending(x => x.CreateDate).ToArray(); } @if (selection.Length > 0) { diff --git a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByName.cshtml b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByName.cshtml index ecfd8ebe9d..d0398e7272 100755 --- a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByName.cshtml +++ b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByName.cshtml @@ -10,7 +10,7 @@ - It then generates links so the visitor can go to each page *@ -@{ var selection = Model.Content.Children().Where(x => x.IsVisible()).OrderBy(x => x.Name).ToArray(); } +@{ var selection = Model.Content.Children.Where(x => x.IsVisible()).OrderBy(x => x.Name).ToArray(); } @if (selection.Length > 0) { diff --git a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByProperty.cshtml b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByProperty.cshtml index 667a384dfe..1bffae04c4 100755 --- a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByProperty.cshtml +++ b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListChildPagesOrderedByProperty.cshtml @@ -17,7 +17,7 @@ @if (propertyAlias != null) { - var selection = Model.Content.Children().Where(x => x.IsVisible()).OrderBy(x => x.Value(propertyAlias.ToString())).ToArray(); + var selection = Model.Content.Children.Where(x => x.IsVisible()).OrderBy(x => x.Value(propertyAlias.ToString())).ToArray(); if (selection.Length > 0) { diff --git a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListDescendantsFromCurrentPage.cshtml b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListDescendantsFromCurrentPage.cshtml index 196db52d92..7ae917b41d 100755 --- a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListDescendantsFromCurrentPage.cshtml +++ b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListDescendantsFromCurrentPage.cshtml @@ -7,7 +7,7 @@ the page currently being viewed by the website visitor, displayed as nested unordered HTML lists. *@ -@{ var selection = Model.Content.Children().Where(x => x.IsVisible()).ToArray(); } +@{ var selection = Model.Content.Children.Where(x => x.IsVisible()).ToArray(); } @* Ensure that the Current Page has children *@ @if (selection.Length > 0) @@ -25,7 +25,7 @@ @* if this child page has any children, where the property umbracoNaviHide is not True *@ @{ - var children = item.Children().Where(x => x.IsVisible()).ToArray(); + var children = item.Children.Where(x => x.IsVisible()).ToArray(); if (children.Length > 0) { @* Call our helper to display the children *@ @@ -54,7 +54,7 @@ @* if the page has any children, where the property umbracoNaviHide is not True *@ @{ - var children = item.Children().Where(x => x.IsVisible()).ToArray(); + var children = item.Children.Where(x => x.IsVisible()).ToArray(); if (children.Length > 0) { @* Recurse and call our helper to display the children *@ diff --git a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListImagesFromMediaFolder.cshtml b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListImagesFromMediaFolder.cshtml index b6067ff93a..51fdbadb00 100755 --- a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListImagesFromMediaFolder.cshtml +++ b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/ListImagesFromMediaFolder.cshtml @@ -18,7 +18,7 @@ { @* Get the media item associated with the id passed in *@ var media = Umbraco.Media(mediaId); - var selection = media.Children().ToArray(); + var selection = media.Children.ToArray(); if (selection.Length > 0) { diff --git a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/Navigation.cshtml b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/Navigation.cshtml index 733c6be801..1c01eeb855 100755 --- a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/Navigation.cshtml +++ b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/Navigation.cshtml @@ -7,7 +7,7 @@ It also highlights the current active page/section in the navigation with the CSS class "current". *@ -@{ var selection = Model.Content.Root().Children().Where(x => x.IsVisible()).ToArray(); } +@{ var selection = Model.Content.Root().Children.Where(x => x.IsVisible()).ToArray(); } @if (selection.Length > 0) { diff --git a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/SiteMap.cshtml b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/SiteMap.cshtml index a14d6fdc09..567ed5d07d 100755 --- a/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/SiteMap.cshtml +++ b/src/Umbraco.Web.UI/Umbraco/PartialViewMacros/Templates/SiteMap.cshtml @@ -23,7 +23,7 @@ const int maxLevelForSitemap = 4; @* Select visible children *@ - var selection = node.Children().Where(x => x.IsVisible() && x.Level <= maxLevelForSitemap).ToArray(); + var selection = node.Children.Where(x => x.IsVisible() && x.Level <= maxLevelForSitemap).ToArray(); @* If any items are returned, render a list *@ if (selection.Length > 0) diff --git a/src/Umbraco.Web/Controllers/UmbLoginController.cs b/src/Umbraco.Web/Controllers/UmbLoginController.cs index 02130da8b5..2980b4a4c0 100644 --- a/src/Umbraco.Web/Controllers/UmbLoginController.cs +++ b/src/Umbraco.Web/Controllers/UmbLoginController.cs @@ -45,7 +45,7 @@ namespace Umbraco.Web.Controllers // if it's not a local url we'll redirect to the root of the current site return Redirect(Url.IsLocalUrl(model.RedirectUrl) ? model.RedirectUrl - : CurrentPage.AncestorOrSelf(1).Url()); + : CurrentPage.AncestorOrSelf(1).Url); } //redirect to current page by default diff --git a/src/Umbraco.Web/Editors/TemplateQueryController.cs b/src/Umbraco.Web/Editors/TemplateQueryController.cs index b252f51fae..ed737e7749 100644 --- a/src/Umbraco.Web/Editors/TemplateQueryController.cs +++ b/src/Umbraco.Web/Editors/TemplateQueryController.cs @@ -71,7 +71,7 @@ namespace Umbraco.Web.Editors QueryExpression = queryExpression.ToString(), ResultCount = results.Count, ExecutionTime = timer.ElapsedMilliseconds, - SampleResults = results.Take(20).Select(x => new TemplateQueryResult { Icon = "icon-file", Name = x.Name() }) + SampleResults = results.Take(20).Select(x => new TemplateQueryResult { Icon = "icon-file", Name = x.Name }) }; } @@ -186,12 +186,12 @@ namespace Umbraco.Web.Editors : contents.OrderByDescending(x => x.UpdateDate); case "name": return sortExpression.Direction == "ascending" - ? contents.OrderBy(x => x.Name()) - : contents.OrderByDescending(x => x.Name()); + ? contents.OrderBy(x => x.Name) + : contents.OrderByDescending(x => x.Name); default: return sortExpression.Direction == "ascending" - ? contents.OrderBy(x => x.Name()) - : contents.OrderByDescending(x => x.Name()); + ? contents.OrderBy(x => x.Name) + : contents.OrderByDescending(x => x.Name); } } diff --git a/src/Umbraco.Web/Macros/PublishedContentHashtableConverter.cs b/src/Umbraco.Web/Macros/PublishedContentHashtableConverter.cs index f641d6ca21..41f0e2fb65 100644 --- a/src/Umbraco.Web/Macros/PublishedContentHashtableConverter.cs +++ b/src/Umbraco.Web/Macros/PublishedContentHashtableConverter.cs @@ -35,9 +35,9 @@ namespace Umbraco.Web.Macros throw new ArgumentException("Document request has no node.", nameof(frequest)); PopulatePageData(frequest.PublishedContent.Id, - frequest.PublishedContent.Name(), frequest.PublishedContent.ContentType.Id, frequest.PublishedContent.ContentType.Alias, + frequest.PublishedContent.Name, frequest.PublishedContent.ContentType.Id, frequest.PublishedContent.ContentType.Alias, frequest.PublishedContent.WriterName, frequest.PublishedContent.CreatorName, frequest.PublishedContent.CreateDate, frequest.PublishedContent.UpdateDate, - frequest.PublishedContent.Path, frequest.PublishedContent.Parent()?.Id ?? -1); + frequest.PublishedContent.Path, frequest.PublishedContent.Parent?.Id ?? -1); if (frequest.HasTemplate) { @@ -57,9 +57,9 @@ namespace Umbraco.Web.Macros if (doc == null) throw new ArgumentNullException(nameof(doc)); PopulatePageData(doc.Id, - doc.Name(), doc.ContentType.Id, doc.ContentType.Alias, + doc.Name, doc.ContentType.Id, doc.ContentType.Alias, doc.WriterName, doc.CreatorName, doc.CreateDate, doc.UpdateDate, - doc.Path, doc.Parent()?.Id ?? -1); + doc.Path, doc.Parent?.Id ?? -1); if (doc.TemplateId.HasValue) { @@ -182,8 +182,8 @@ namespace Umbraco.Web.Macros { private readonly IContent _inner; private readonly IPublishedProperty[] _properties; + private IReadOnlyDictionary _cultureInfos; private readonly IVariationContextAccessor _variationContextAccessor; - private readonly IPublishedContent _parent; private static readonly IReadOnlyDictionary NoCultureInfos = new Dictionary(); @@ -215,7 +215,7 @@ namespace Umbraco.Web.Macros .Cast() .ToArray(); - _parent = new PagePublishedContent(_inner.ParentId); + Parent = new PagePublishedContent(_inner.ParentId); } public IPublishedContentType ContentType { get; } @@ -228,37 +228,25 @@ namespace Umbraco.Web.Macros public int SortOrder => _inner.SortOrder; - public string Name(string culture = null) => _inner.GetCultureName(culture); + public string Name => _inner.Name; - public DateTime CultureDate(string culture = null) - { - // invariant has invariant value (whatever the requested culture) - if (!ContentType.VariesByCulture()) - return UpdateDate; - - // handle context culture for variant - if (culture == null) - culture = _variationContextAccessor.VariationContext.Culture; - - // get - return culture != "" && _inner.PublishCultureInfos.TryGetValue(culture, out var infos) ? infos.Date : DateTime.MinValue; - } - - // ReSharper disable once CollectionNeverUpdated.Local - private static readonly List EmptyListOfString = new List(); - private IReadOnlyList _cultures; - - public IReadOnlyCollection Cultures + public IReadOnlyDictionary Cultures { get { if (!_inner.ContentType.VariesByCulture()) - return EmptyListOfString; - return _cultures ?? (_cultures = _inner.PublishCultureInfos.Values.Select(x => x.Culture).ToList()); + return NoCultureInfos; + + if (_cultureInfos != null) + return _cultureInfos; + + var urlSegmentProviders = Current.UrlSegmentProviders; // TODO inject + return _cultureInfos = _inner.PublishCultureInfos.Values + .ToDictionary(x => x.Culture, x => new PublishedCultureInfo(x.Culture, x.Name, _inner.GetUrlSegment(urlSegmentProviders, x.Culture), x.Date)); } } - public string UrlSegment(string culture = null) => throw new NotImplementedException(); + public string UrlSegment => throw new NotImplementedException(); public string WriterName { get; } @@ -276,7 +264,9 @@ namespace Umbraco.Web.Macros public int Level => _inner.Level; - public string Url(string culture = null, UrlMode mode = UrlMode.Auto) => throw new NotSupportedException(); + public string Url => throw new NotImplementedException(); + + public PublishedItemType ItemType => PublishedItemType.Content; public bool IsDraft(string culture = null) { @@ -288,9 +278,11 @@ namespace Umbraco.Web.Macros throw new NotImplementedException(); } - public IPublishedContent Parent() => _parent; + public IPublishedContent Parent { get; } - public IEnumerable Children(string culture = null) => throw new NotImplementedException(); + public IEnumerable Children => throw new NotImplementedException(); + + public IEnumerable ChildrenForAllCultures => throw new NotImplementedException(); public IEnumerable Properties => _properties; diff --git a/src/Umbraco.Web/Models/PublishedContent/PublishedValueFallback.cs b/src/Umbraco.Web/Models/PublishedContent/PublishedValueFallback.cs index 6e0246f416..7b467b6d15 100644 --- a/src/Umbraco.Web/Models/PublishedContent/PublishedValueFallback.cs +++ b/src/Umbraco.Web/Models/PublishedContent/PublishedValueFallback.cs @@ -160,7 +160,7 @@ namespace Umbraco.Web.Models.PublishedContent IPublishedProperty property; // if we are here, content's property has no value do { - content = content.Parent(); + content = content.Parent; var propertyType = content?.ContentType.GetPropertyType(alias); diff --git a/src/Umbraco.Web/Models/PublishedContentBase.cs b/src/Umbraco.Web/Models/PublishedContentBase.cs index 935c594285..cfc4fd1106 100644 --- a/src/Umbraco.Web/Models/PublishedContentBase.cs +++ b/src/Umbraco.Web/Models/PublishedContentBase.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Diagnostics; using Umbraco.Core; using Umbraco.Core.Models.PublishedContent; -using Umbraco.Core.PropertyEditors.ValueConverters; namespace Umbraco.Web.Models { @@ -34,10 +33,10 @@ namespace Umbraco.Web.Models public abstract int Id { get; } /// - public abstract string Name(string culture = null); + public virtual string Name => this.Name(); /// - public abstract string UrlSegment(string culture = null); + public virtual string UrlSegment => this.UrlSegment(); /// public abstract int SortOrder { get; } @@ -70,10 +69,13 @@ namespace Umbraco.Web.Models public abstract DateTime UpdateDate { get; } /// - public abstract DateTime CultureDate(string culture = null); + public virtual string Url => this.Url(); /// - public abstract IReadOnlyCollection Cultures { get; } + public abstract IReadOnlyDictionary Cultures { get; } + + /// + public abstract PublishedItemType ItemType { get; } /// public abstract bool IsDraft(string culture = null); @@ -86,10 +88,13 @@ namespace Umbraco.Web.Models #region Tree /// - public abstract IPublishedContent Parent(); + public abstract IPublishedContent Parent { get; } /// - public abstract IEnumerable Children(string culture = null); + public virtual IEnumerable Children => this.Children(); + + /// + public abstract IEnumerable ChildrenForAllCultures { get; } #endregion diff --git a/src/Umbraco.Web/PublishedCache/NuCache/ContentCache.cs b/src/Umbraco.Web/PublishedCache/NuCache/ContentCache.cs index c4277d6a79..4dcee5eb24 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/ContentCache.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/ContentCache.cs @@ -157,7 +157,7 @@ namespace Umbraco.Web.PublishedCache.NuCache pathParts.Add(urlSegment); // move to parent node - n = n.Parent(); + n = n.Parent; if (n != null) urlSegment = n.UrlSegment(culture); @@ -206,7 +206,7 @@ namespace Umbraco.Web.PublishedCache.NuCache // "/foo" fails (looking for "/*/foo") we try also "/foo". // this does not make much sense anyway esp. if both "/foo/" and "/bar/foo" exist, but // that's the way it works pre-4.10 and we try to be backward compat for the time being - if (content.Parent() == null) + if (content.Parent == null) { var rootNode = GetByRoute(preview, "/", true); if (rootNode == null) diff --git a/src/Umbraco.Web/PublishedCache/NuCache/Navigable/NavigableContent.cs b/src/Umbraco.Web/PublishedCache/NuCache/Navigable/NavigableContent.cs index c9dd493ee6..51badc8b9a 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/Navigable/NavigableContent.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/Navigable/NavigableContent.cs @@ -18,7 +18,7 @@ namespace Umbraco.Web.PublishedCache.NuCache.Navigable var i = 0; _builtInValues = new [] { - XmlString(i++, _content.Name()), + XmlString(i++, _content.Name), XmlString(i++, _content.ParentId), XmlString(i++, _content.CreateDate), XmlString(i++, _content.UpdateDate), @@ -28,7 +28,7 @@ namespace Umbraco.Web.PublishedCache.NuCache.Navigable XmlString(i++, _content.TemplateId), XmlString(i++, _content.WriterId), XmlString(i++, _content.CreatorId), - XmlString(i++, _content.UrlSegment()), + XmlString(i++, _content.UrlSegment), XmlString(i, _content.IsDraft()) }; } diff --git a/src/Umbraco.Web/PublishedCache/NuCache/PublishedContent.cs b/src/Umbraco.Web/PublishedCache/NuCache/PublishedContent.cs index c227c75952..67f219be21 100644 --- a/src/Umbraco.Web/PublishedCache/NuCache/PublishedContent.cs +++ b/src/Umbraco.Web/PublishedCache/NuCache/PublishedContent.cs @@ -110,7 +110,7 @@ namespace Umbraco.Web.PublishedCache.NuCache internal static Func GetMediaByIdFunc { get; set; } = (publishedShapshot, previewing, id) => publishedShapshot.Media.GetById(previewing, id); - private Func GetGetterById(PublishedItemType itemType) + private Func GetGetterById() { switch (ContentType.ItemType) { @@ -147,36 +147,6 @@ namespace Umbraco.Web.PublishedCache.NuCache /// public override int Id => _contentNode.Id; - /// - public override string Name(string culture = null) - { - // invariant has invariant value (whatever the requested culture) - if (!ContentType.VariesByCulture()) - return ContentData.Name; - - // handle context culture for variant - if (culture == null) - culture = VariationContextAccessor?.VariationContext?.Culture ?? ""; - - // get - return culture != "" && ContentData.CultureInfos.TryGetValue(culture, out var infos) ? infos.Name : null; - } - - /// - public override string UrlSegment(string culture = null) - { - // invariant has invariant value (whatever the requested culture) - if (!ContentType.VariesByCulture()) - return _urlSegment; - - // handle context culture for variant - if (culture == null) - culture = VariationContextAccessor?.VariationContext?.Culture ?? ""; - - // get - return ContentData.CultureInfos.TryGetValue(culture, out var infos) ? infos.UrlSegment : null; - } - /// public override int SortOrder => _contentNode.SortOrder; @@ -207,37 +177,31 @@ namespace Umbraco.Web.PublishedCache.NuCache /// public override DateTime UpdateDate => ContentData.VersionDate; - /// - public override DateTime CultureDate(string culture = null) - { - // invariant has invariant value (whatever the requested culture) - if (!ContentType.VariesByCulture()) - return UpdateDate; - - // handle context culture for variant - if (culture == null) - culture = VariationContextAccessor?.VariationContext?.Culture ?? ""; - - // get - return culture != "" && ContentData.CultureInfos.TryGetValue(culture, out var infos) ? infos.Date : DateTime.MinValue; - } - // ReSharper disable once CollectionNeverUpdated.Local - private static readonly List EmptyListOfString = new List(); - private IReadOnlyCollection _cultures; + private static readonly IReadOnlyDictionary EmptyCultures = new Dictionary(); + private IReadOnlyDictionary _cultures; /// - public override IReadOnlyCollection Cultures + public override IReadOnlyDictionary Cultures { get { if (!ContentType.VariesByCulture()) - return EmptyListOfString; + return EmptyCultures; - return _cultures ?? (_cultures = new HashSet(ContentData.CultureInfos.Keys, StringComparer.OrdinalIgnoreCase)); + if (_cultures != null) return _cultures; + + if (ContentData.CultureInfos == null) + throw new Exception("panic: _contentDate.CultureInfos is null."); + + return _cultures = ContentData.CultureInfos + .ToDictionary(x => x.Key, x => new PublishedCultureInfo(x.Key, x.Value.Name, x.Value.UrlSegment, x.Value.Date), StringComparer.OrdinalIgnoreCase); } } + /// + public override PublishedItemType ItemType => _contentNode.ContentType.ItemType; + /// public override bool IsDraft(string culture = null) { @@ -288,38 +252,35 @@ namespace Umbraco.Web.PublishedCache.NuCache #region Tree /// - public override IPublishedContent Parent() + public override IPublishedContent Parent { - var getById = GetGetterById(ContentType.ItemType); - var publishedSnapshot = _publishedSnapshotAccessor.PublishedSnapshot; - return getById(publishedSnapshot, IsPreviewing, ParentId); + get + { + var getById = GetGetterById(); + var publishedSnapshot = _publishedSnapshotAccessor.PublishedSnapshot; + return getById(publishedSnapshot, IsPreviewing, ParentId); + } } /// - public override IEnumerable Children(string culture = null) + public override IEnumerable ChildrenForAllCultures { - // invariant has invariant value (whatever the requested culture) - if (!ContentType.VariesByCulture() && culture != "*") - culture = ""; - - // handle context culture for variant - if (culture == null) - culture = VariationContextAccessor?.VariationContext?.Culture ?? ""; - - var getById = GetGetterById(ContentType.ItemType); - var publishedSnapshot = _publishedSnapshotAccessor.PublishedSnapshot; - var id = _contentNode.FirstChildContentId; - - while (id > 0) + get { - var content = getById(publishedSnapshot, IsPreviewing, id); - if (content == null) - throw new Exception("panic: failed to get content"); + var getById = GetGetterById(); + var publishedSnapshot = _publishedSnapshotAccessor.PublishedSnapshot; + var id = _contentNode.FirstChildContentId; + + while (id > 0) + { + var content = getById(publishedSnapshot, IsPreviewing, id); + if (content == null) + throw new Exception("panic: failed to get content"); - if (culture == "*" || content.IsInvariantOrHasCulture(culture)) yield return content; - id = UnwrapIPublishedContent(content)._contentNode.NextSiblingContentId; + id = UnwrapIPublishedContent(content)._contentNode.NextSiblingContentId; + } } } @@ -381,7 +342,7 @@ namespace Umbraco.Web.PublishedCache.NuCache // includes all children, published or unpublished // NavigableNavigator takes care of selecting those it wants // note: this is not efficient - we do not try to be (would require a double-linked list) - internal IList ChildIds => Children().Select(x => x.Id).ToList(); + internal IList ChildIds => Children.Select(x => x.Id).ToList(); // used by Property // gets a value indicating whether the content or media exists in diff --git a/src/Umbraco.Web/PublishedCache/PublishedMember.cs b/src/Umbraco.Web/PublishedCache/PublishedMember.cs index 9c6f60da97..6e9ec61c62 100644 --- a/src/Umbraco.Web/PublishedCache/PublishedMember.cs +++ b/src/Umbraco.Web/PublishedCache/PublishedMember.cs @@ -73,13 +73,17 @@ namespace Umbraco.Web.PublishedCache #region IPublishedContent + public override PublishedItemType ItemType => PublishedItemType.Member; + public override bool IsDraft(string culture = null) => false; public override bool IsPublished(string culture = null) => true; - public override IPublishedContent Parent() => null; + public override IPublishedContent Parent => null; - public override IEnumerable Children(string culture = null) => Enumerable.Empty(); + public override IEnumerable Children => Enumerable.Empty(); + + public override IEnumerable ChildrenForAllCultures => Enumerable.Empty(); public override IEnumerable Properties => _properties; @@ -129,17 +133,11 @@ namespace Umbraco.Web.PublishedCache public override int SortOrder => 0; - public override string Name(string culture = null) - { - // member name does not vary, ignore culture - return _member.Name; - } + public override string Name => _member.Name; - public override DateTime CultureDate(string culture = null) => throw new NotSupportedException(); + public override IReadOnlyDictionary Cultures => throw new NotSupportedException(); - public override IReadOnlyCollection Cultures => throw new NotSupportedException(); - - public override string UrlSegment(string culture = null) => throw new NotSupportedException(); + public override string UrlSegment => throw new NotSupportedException(); // TODO: ARGH! need to fix this - this is not good because it uses ApplicationContext.Current public override string WriterName => _member.GetCreatorProfile().Name; diff --git a/src/Umbraco.Web/PublishedContentExtensions.cs b/src/Umbraco.Web/PublishedContentExtensions.cs index eb38826193..fbfc52f4d8 100644 --- a/src/Umbraco.Web/PublishedContentExtensions.cs +++ b/src/Umbraco.Web/PublishedContentExtensions.cs @@ -167,36 +167,6 @@ namespace Umbraco.Web #region Variations - /// - /// Determines whether the content has a culture. - /// - /// Culture is case-insensitive. - public static bool HasCulture(this IPublishedContent content, string culture) - => content.Cultures.Contains(culture ?? string.Empty); - - /// - /// Determines whether the content is invariant, or has a culture. - /// - /// Culture is case-insensitive. - public static bool IsInvariantOrHasCulture(this IPublishedContent content, string culture) - => !content.ContentType.VariesByCulture() || content.Cultures.Contains(culture ?? ""); - - /// - /// Filters a sequence of to return invariant items, and items that are published for the specified culture. - /// - /// The content items. - /// The specific culture to filter for. If null is used the current culture is used. (Default is null). - internal static IEnumerable WhereIsInvariantOrHasCulture(this IEnumerable contents, string culture = null) - where T : class, IPublishedContent - { - if (contents == null) throw new ArgumentNullException(nameof(contents)); - - culture = culture ?? Current.VariationContextAccessor.VariationContext?.Culture ?? ""; - - // either does not vary by culture, or has the specified culture - return contents.Where(x => !x.ContentType.VariesByCulture() || x.HasCulture(culture)); - } - /// /// Gets the culture assigned to a document by domains, in the context of a current Uri. /// @@ -555,7 +525,7 @@ namespace Umbraco.Web /// This method is here for consistency purposes but does not make much sense. public static IPublishedContent Ancestor(this IPublishedContent content) { - return content.Parent(); + return content.Parent; } /// @@ -687,7 +657,7 @@ namespace Umbraco.Web { if (content == null) throw new ArgumentNullException(nameof(content)); if (orSelf) yield return content; - while ((content = content.Parent()) != null) + while ((content = content.Parent) != null) yield return content; } @@ -891,7 +861,7 @@ namespace Umbraco.Web where T : class, IPublishedContent { if (content == null) throw new ArgumentNullException(nameof(content)); - return content.Parent() as T; + return content.Parent as T; } #endregion @@ -1111,8 +1081,8 @@ namespace Umbraco.Web /// The siblings of the content including the node itself. public static IEnumerable SiblingsAndSelf(this IPublishedContent content, string culture = null) { - return content.Parent() != null - ? content.Parent().Children(culture) + return content.Parent != null + ? content.Parent.Children(culture) : PublishedSnapshot.Content.GetAtRoot().WhereIsInvariantOrHasCulture(culture); } @@ -1125,8 +1095,8 @@ namespace Umbraco.Web /// The siblings of the content including the node itself, of the given content type. public static IEnumerable SiblingsAndSelfOfType(this IPublishedContent content, string contentTypeAlias, string culture = null) { - return content.Parent() != null - ? content.Parent().ChildrenOfType(contentTypeAlias, culture) + return content.Parent != null + ? content.Parent.ChildrenOfType(contentTypeAlias, culture) : PublishedSnapshot.Content.GetAtRoot().OfTypes(contentTypeAlias).WhereIsInvariantOrHasCulture(culture); } @@ -1140,8 +1110,8 @@ namespace Umbraco.Web public static IEnumerable SiblingsAndSelf(this IPublishedContent content, string culture = null) where T : class, IPublishedContent { - return content.Parent() != null - ? content.Parent().Children(culture) + return content.Parent != null + ? content.Parent.Children(culture) : PublishedSnapshot.Content.GetAtRoot().OfType().WhereIsInvariantOrHasCulture(culture); } diff --git a/src/Umbraco.Web/Routing/AliasUrlProvider.cs b/src/Umbraco.Web/Routing/AliasUrlProvider.cs index 354c315202..efd48af2d4 100644 --- a/src/Umbraco.Web/Routing/AliasUrlProvider.cs +++ b/src/Umbraco.Web/Routing/AliasUrlProvider.cs @@ -65,7 +65,7 @@ namespace Umbraco.Web.Routing while (domainUris == null && n != null) // n is null at root { // move to parent node - n = n.Parent(); + n = n.Parent; domainUris = n == null ? null : DomainUtilities.DomainsForNode(umbracoContext.PublishedSnapshot.Domains, _siteDomainHelper, n.Id, current, excludeDefault: false); } diff --git a/src/Umbraco.Web/Routing/DefaultUrlProvider.cs b/src/Umbraco.Web/Routing/DefaultUrlProvider.cs index 4e9944a808..4092538481 100644 --- a/src/Umbraco.Web/Routing/DefaultUrlProvider.cs +++ b/src/Umbraco.Web/Routing/DefaultUrlProvider.cs @@ -87,7 +87,7 @@ namespace Umbraco.Web.Routing var domainUris = DomainUtilities.DomainsForNode(umbracoContext.PublishedSnapshot.Domains, _siteDomainHelper, n.Id, current, false); while (domainUris == null && n != null) // n is null at root { - n = n.Parent(); // move to parent node + n = n.Parent; // move to parent node domainUris = n == null ? null : DomainUtilities.DomainsForNode(umbracoContext.PublishedSnapshot.Domains, _siteDomainHelper, n.Id, current, excludeDefault: true); } diff --git a/src/Umbraco.Web/Routing/PublishedRouter.cs b/src/Umbraco.Web/Routing/PublishedRouter.cs index 1f15967996..6e768c28b6 100644 --- a/src/Umbraco.Web/Routing/PublishedRouter.cs +++ b/src/Umbraco.Web/Routing/PublishedRouter.cs @@ -276,7 +276,7 @@ namespace Umbraco.Web.Routing return true; // variant, ensure that the culture corresponding to the domain's language is published - return domainDocument.Cultures.Contains(domain.Culture.Name); + return domainDocument.Cultures.ContainsKey(domain.Culture.Name); } domains = domains.Where(IsPublishedContentDomain).ToList(); diff --git a/src/Umbraco.Web/Routing/RedirectTrackingComponent.cs b/src/Umbraco.Web/Routing/RedirectTrackingComponent.cs index 9c6459da62..77aa3c65a1 100644 --- a/src/Umbraco.Web/Routing/RedirectTrackingComponent.cs +++ b/src/Umbraco.Web/Routing/RedirectTrackingComponent.cs @@ -171,12 +171,12 @@ namespace Umbraco.Web.Routing if (entityContent == null) continue; // get the default affected cultures by going up the tree until we find the first culture variant entity (default to no cultures) - var defaultCultures = entityContent.AncestorsOrSelf()?.FirstOrDefault(a => a.Cultures.Any())?.Cultures.ToArray() + var defaultCultures = entityContent.AncestorsOrSelf()?.FirstOrDefault(a => a.Cultures.Any())?.Cultures.Keys.ToArray() ?? new[] {(string) null}; foreach (var x in entityContent.DescendantsOrSelf()) { // if this entity defines specific cultures, use those instead of the default ones - var cultures = x.Cultures.Any() ? x.Cultures : defaultCultures; + var cultures = x.Cultures.Any() ? x.Cultures.Keys : defaultCultures; foreach (var culture in cultures) { diff --git a/src/Umbraco.Web/Routing/UrlProviderExtensions.cs b/src/Umbraco.Web/Routing/UrlProviderExtensions.cs index 27a27399bf..077680d2e2 100644 --- a/src/Umbraco.Web/Routing/UrlProviderExtensions.cs +++ b/src/Umbraco.Web/Routing/UrlProviderExtensions.cs @@ -188,7 +188,7 @@ namespace Umbraco.Web.Routing while (o != null) { l.Add(o.Name()); - o = o.Parent(); + o = o.Parent; } l.Reverse(); var s = "/" + string.Join("/", l) + " (id=" + pcr.PublishedContent.Id + ")"; diff --git a/src/Umbraco.Web/Templates/TemplateUtilities.cs b/src/Umbraco.Web/Templates/TemplateUtilities.cs index 06706e475b..c3a1fb128f 100644 --- a/src/Umbraco.Web/Templates/TemplateUtilities.cs +++ b/src/Umbraco.Web/Templates/TemplateUtilities.cs @@ -60,7 +60,7 @@ namespace Umbraco.Web.Templates if (guidUdi.EntityType == Constants.UdiEntityType.Document) newLink = urlProvider.GetUrl(guidUdi.Guid); else if (guidUdi.EntityType == Constants.UdiEntityType.Media) - newLink = mediaCache.GetById(guidUdi.Guid)?.Url(); + newLink = mediaCache.GetById(guidUdi.Guid)?.Url; if (newLink == null) newLink = "#"; @@ -171,7 +171,7 @@ namespace Umbraco.Web.Templates return match.Value; } - var url = media.Url(); + var url = media.Url; return $"{match.Groups[1].Value}{url}{match.Groups[3].Value}{udi}{match.Groups[5].Value}"; }); }