From 82bb410f4f690c85dbab0af057275d809c2b5b30 Mon Sep 17 00:00:00 2001 From: Shannon Deminick Date: Mon, 8 Oct 2012 21:55:03 +0500 Subject: [PATCH] Changed @Model.CurrentContent to @Model.Content, updated some ext methods for IPublishedContent. --- src/Umbraco.Web/Mvc/RenderModel.cs | 2 +- src/Umbraco.Web/Mvc/RenderRouteHandler.cs | 2 +- src/Umbraco.Web/Mvc/RenderViewPage.cs | 2 +- src/Umbraco.Web/PublishedContentExtensions.cs | 25 ++++++++++++++----- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/Umbraco.Web/Mvc/RenderModel.cs b/src/Umbraco.Web/Mvc/RenderModel.cs index 9e53e10f43..215a160a9e 100644 --- a/src/Umbraco.Web/Mvc/RenderModel.cs +++ b/src/Umbraco.Web/Mvc/RenderModel.cs @@ -14,7 +14,7 @@ namespace Umbraco.Web.Mvc /// /// Returns the current IPublishedContent object /// - public IPublishedContent CurrentContent { get; internal set; } + public IPublishedContent Content { get; internal set; } /// /// Returns the current Culture assigned to the page being rendered diff --git a/src/Umbraco.Web/Mvc/RenderRouteHandler.cs b/src/Umbraco.Web/Mvc/RenderRouteHandler.cs index 352fa11f49..ab2573d131 100644 --- a/src/Umbraco.Web/Mvc/RenderRouteHandler.cs +++ b/src/Umbraco.Web/Mvc/RenderRouteHandler.cs @@ -44,7 +44,7 @@ namespace Umbraco.Web.Mvc var renderModel = new RenderModel() { - CurrentContent = docRequest.PublishedContent, + Content = docRequest.PublishedContent, CurrentCulture = docRequest.Culture }; diff --git a/src/Umbraco.Web/Mvc/RenderViewPage.cs b/src/Umbraco.Web/Mvc/RenderViewPage.cs index d161da0d23..36ad6d51d4 100644 --- a/src/Umbraco.Web/Mvc/RenderViewPage.cs +++ b/src/Umbraco.Web/Mvc/RenderViewPage.cs @@ -25,7 +25,7 @@ namespace Umbraco.Web.Mvc { ////this.ViewData.Model = Model; //var backingItem = new DynamicBackingItem(Model.CurrentNode); - var dynamicNode = new DynamicPublishedContent(Model.CurrentContent); + var dynamicNode = new DynamicPublishedContent(Model.Content); CurrentPage = dynamicNode.AsDynamic(); } PublishedContentRequest = (PublishedContentRequest)ViewContext.RouteData.DataTokens.GetRequiredObject("umbraco-doc-request"); diff --git a/src/Umbraco.Web/PublishedContentExtensions.cs b/src/Umbraco.Web/PublishedContentExtensions.cs index 27e3b4e1a0..4d87f13c55 100644 --- a/src/Umbraco.Web/PublishedContentExtensions.cs +++ b/src/Umbraco.Web/PublishedContentExtensions.cs @@ -408,7 +408,7 @@ namespace Umbraco.Web { return content.Ancestors(n => true); } - public static IEnumerable Ancestors(this IPublishedContent content, Func func) + private static IEnumerable Ancestors(this IPublishedContent content, Func func) { var ancestorList = new List(); var node = content; @@ -450,7 +450,7 @@ namespace Umbraco.Web { return content.AncestorOrSelf(node => node.DocumentTypeAlias == nodeTypeAlias); } - public static IPublishedContent AncestorOrSelf(this IPublishedContent content, Func func) + private static IPublishedContent AncestorOrSelf(this IPublishedContent content, Func func) { var node = content; while (node != null) @@ -473,7 +473,7 @@ namespace Umbraco.Web return null; } - public static IEnumerable AncestorsOrSelf(this IPublishedContent content, Func func) + internal static IEnumerable AncestorsOrSelf(this IPublishedContent content, Func func) { var ancestorList = new List(); var node = content; @@ -510,7 +510,7 @@ namespace Umbraco.Web { return content.AncestorsOrSelf(n => n.DocumentTypeAlias == nodeTypeAlias); } - public static IEnumerable AncestorsOrSelf(this IPublishedContent content, int level) + private static IEnumerable AncestorsOrSelf(this IPublishedContent content, int level) { return content.AncestorsOrSelf(n => n.Level <= level); } @@ -530,7 +530,7 @@ namespace Umbraco.Web { return content.Descendants(n => true); } - internal static IEnumerable Descendants(this IPublishedContent content, Func func) + private static IEnumerable Descendants(this IPublishedContent content, Func func) { return content.Children.Map(func, (IPublishedContent n) => n.Children); } @@ -546,7 +546,7 @@ namespace Umbraco.Web { return content.DescendantsOrSelf(p => true); } - internal static IEnumerable DescendantsOrSelf(this IPublishedContent content, Func func) + private static IEnumerable DescendantsOrSelf(this IPublishedContent content, Func func) { if (content != null) { @@ -739,6 +739,19 @@ namespace Umbraco.Web } #endregion + /// + /// Method to return the Children of the content item + /// + /// + /// + /// + /// This method exists for consistency, it is the same as calling content.Children as a property. + /// + public static IEnumerable Children(this IPublishedContent p) + { + return p.Children; + } + /// /// Returns a DataTable object for the IPublishedContent ///