From 3f7a5d18f8a225b1144416f7ab5e3da3ad11faa6 Mon Sep 17 00:00:00 2001 From: Anthony Date: Fri, 27 Jul 2018 14:17:41 +0100 Subject: [PATCH 1/2] Refactored out some obsolete methods --- src/Umbraco.Core/Services/IFileService.cs | 15 --------- .../Services/Implement/FileService.cs | 31 ------------------- .../Templates/TemplateUtilities.cs | 17 +--------- src/Umbraco.Web/UmbracoComponentRenderer.cs | 2 +- .../umbraco.presentation/default.aspx.cs | 2 +- 5 files changed, 3 insertions(+), 64 deletions(-) diff --git a/src/Umbraco.Core/Services/IFileService.cs b/src/Umbraco.Core/Services/IFileService.cs index a61faa10c7..76e850beb2 100644 --- a/src/Umbraco.Core/Services/IFileService.cs +++ b/src/Umbraco.Core/Services/IFileService.cs @@ -169,21 +169,6 @@ namespace Umbraco.Core.Services /// IEnumerable GetTemplateChildren(int masterTemplateId); - /// - /// Returns a template as a template node which can be traversed (parent, children) - /// - /// - /// - TemplateNode GetTemplateNode(string alias); - - /// - /// Given a template node in a tree, this will find the template node with the given alias if it is found in the hierarchy, otherwise null - /// - /// - /// - /// - TemplateNode FindTemplateInTree(TemplateNode anyNode, string alias); - /// /// Saves a /// diff --git a/src/Umbraco.Core/Services/Implement/FileService.cs b/src/Umbraco.Core/Services/Implement/FileService.cs index 4b95a0c1c3..554dacd50d 100644 --- a/src/Umbraco.Core/Services/Implement/FileService.cs +++ b/src/Umbraco.Core/Services/Implement/FileService.cs @@ -503,37 +503,6 @@ namespace Umbraco.Core.Services.Implement } } - /// - /// Returns a template as a template node which can be traversed (parent, children) - /// - /// - /// - [Obsolete("Use GetDescendants instead")] - [EditorBrowsable(EditorBrowsableState.Never)] - public TemplateNode GetTemplateNode(string alias) - { - using (var scope = ScopeProvider.CreateScope(autoComplete: true)) - { - return _templateRepository.GetTemplateNode(alias); - } - } - - /// - /// Given a template node in a tree, this will find the template node with the given alias if it is found in the hierarchy, otherwise null - /// - /// - /// - /// - [Obsolete("Use GetDescendants instead")] - [EditorBrowsable(EditorBrowsableState.Never)] - public TemplateNode FindTemplateInTree(TemplateNode anyNode, string alias) - { - using (var scope = ScopeProvider.CreateScope(autoComplete: true)) - { - return _templateRepository.FindTemplateInTree(anyNode, alias); - } - } - /// /// Saves a /// diff --git a/src/Umbraco.Web/Templates/TemplateUtilities.cs b/src/Umbraco.Web/Templates/TemplateUtilities.cs index 1b76a738af..c14b34c13f 100644 --- a/src/Umbraco.Web/Templates/TemplateUtilities.cs +++ b/src/Umbraco.Web/Templates/TemplateUtilities.cs @@ -22,7 +22,7 @@ namespace Umbraco.Web.Templates { using (UmbracoContext.Current.ForcedPreview(preview)) // force for url provider { - text = ParseInternalLinks(text); + text = ParseInternalLinks(text, UmbracoContext.Current.UrlProvider); } return text; @@ -69,21 +69,6 @@ namespace Umbraco.Web.Templates return text; } - /// - /// Parses the string looking for the {localLink} syntax and updates them to their correct links. - /// - /// - /// - [Obsolete("Use the overload specifying all dependencies instead")] - public static string ParseInternalLinks(string text) - { - //don't attempt to proceed without a context as we cannot lookup urls without one - if (UmbracoContext.Current == null) - return text; - - var urlProvider = UmbracoContext.Current.UrlProvider; - return ParseInternalLinks(text, urlProvider); - } // static compiled regex for faster performance private static readonly Regex LocalLinkPattern = new Regex(@"href=""[/]?(?:\{|\%7B)localLink:([a-zA-Z0-9-://]+)(?:\}|\%7D)", diff --git a/src/Umbraco.Web/UmbracoComponentRenderer.cs b/src/Umbraco.Web/UmbracoComponentRenderer.cs index b23f38fcde..64e8663df6 100644 --- a/src/Umbraco.Web/UmbracoComponentRenderer.cs +++ b/src/Umbraco.Web/UmbracoComponentRenderer.cs @@ -180,7 +180,7 @@ namespace Umbraco.Web _umbracoContext.HttpContext.Response.ContentType = contentType; //Now, we need to ensure that local links are parsed - html = TemplateUtilities.ParseInternalLinks(output.ToString()); + html = TemplateUtilities.ParseInternalLinks(output.ToString(), UmbracoContext.Current.UrlProvider); } } diff --git a/src/Umbraco.Web/umbraco.presentation/default.aspx.cs b/src/Umbraco.Web/umbraco.presentation/default.aspx.cs index 8093b05841..25dcae7a4e 100644 --- a/src/Umbraco.Web/umbraco.presentation/default.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/default.aspx.cs @@ -128,7 +128,7 @@ namespace umbraco string text = sw.ToString(); // filter / parse internal links - although this should be done elsewhere! - text = TemplateUtilities.ParseInternalLinks(text); + text = TemplateUtilities.ParseInternalLinks(text, UmbracoContext.Current.UrlProvider); // filter / add preview banner if (UmbracoContext.Current.InPreviewMode) From 2613d0b5ace0f81301965423fb5022aacc545ffd Mon Sep 17 00:00:00 2001 From: Sebastiaan Janssen Date: Mon, 30 Jul 2018 16:18:59 +0200 Subject: [PATCH 2/2] Pass UrlProvider in from grid editor too --- src/Umbraco.Web.UI/Views/Partials/Grid/Editors/Rte.cshtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI/Views/Partials/Grid/Editors/Rte.cshtml b/src/Umbraco.Web.UI/Views/Partials/Grid/Editors/Rte.cshtml index d132e10017..04123128c9 100644 --- a/src/Umbraco.Web.UI/Views/Partials/Grid/Editors/Rte.cshtml +++ b/src/Umbraco.Web.UI/Views/Partials/Grid/Editors/Rte.cshtml @@ -1,4 +1,4 @@ @model dynamic @using Umbraco.Web.Templates -@Html.Raw(TemplateUtilities.ParseInternalLinks(Model.value.ToString())) +@Html.Raw(TemplateUtilities.ParseInternalLinks(Model.value.ToString(), UmbracoContext.Current.UrlProvider))