diff --git a/src/Umbraco.Core/XmlExtensions.cs b/src/Umbraco.Core/XmlExtensions.cs index ec53f0521a..4781871cc2 100644 --- a/src/Umbraco.Core/XmlExtensions.cs +++ b/src/Umbraco.Core/XmlExtensions.cs @@ -13,37 +13,132 @@ namespace Umbraco.Core /// internal static class XmlExtensions { - static XPathNodeIterator Select(string expression, XPathNavigator source, params XPathVariable[] variables) - { - var expr = source.Compile(expression); - var context = new DynamicContext(); - foreach (var variable in variables) - context.AddVariable(variable.Name, variable.Value); - expr.SetContext(context); - return source.Select(expr); - } - + /// + /// Selects a list of XmlNode matching an XPath expression. + /// + /// A source XmlNode. + /// An XPath expression. + /// A set of XPathVariables. + /// The list of XmlNode matching the XPath expression. + /// + /// If is null, or is empty, or contains only one single + /// value which itself is null, then variables are ignored. + /// The XPath expression should reference variables as $var. + /// public static XmlNodeList SelectNodes(this XmlNode source, string expression, IEnumerable variables) { var av = variables == null ? null : variables.ToArray(); return SelectNodes(source, expression, av); } + /// + /// Selects a list of XmlNode matching an XPath expression. + /// + /// A source XmlNode. + /// An XPath expression. + /// A set of XPathVariables. + /// The list of XmlNode matching the XPath expression. + /// + /// If is null, or is empty, or contains only one single + /// value which itself is null, then variables are ignored. + /// The XPath expression should reference variables as $var. + /// + public static XmlNodeList SelectNodes(this XmlNode source, XPathExpression expression, IEnumerable variables) + { + var av = variables == null ? null : variables.ToArray(); + return SelectNodes(source, expression, av); + } + + /// + /// Selects a list of XmlNode matching an XPath expression. + /// + /// A source XmlNode. + /// An XPath expression. + /// A set of XPathVariables. + /// The list of XmlNode matching the XPath expression. + /// + /// If is null, or is empty, or contains only one single + /// value which itself is null, then variables are ignored. + /// The XPath expression should reference variables as $var. + /// public static XmlNodeList SelectNodes(this XmlNode source, string expression, params XPathVariable[] variables) { if (variables == null || variables.Length == 0 || variables[0] == null) return source.SelectNodes(expression); - var iterator = Select(expression, source.CreateNavigator(), variables); + var iterator = source.CreateNavigator().Select(expression, variables); return XmlNodeListFactory.CreateNodeList(iterator); } + /// + /// Selects a list of XmlNode matching an XPath expression. + /// + /// A source XmlNode. + /// An XPath expression. + /// A set of XPathVariables. + /// The list of XmlNode matching the XPath expression. + /// + /// If is null, or is empty, or contains only one single + /// value which itself is null, then variables are ignored. + /// The XPath expression should reference variables as $var. + /// + public static XmlNodeList SelectNodes(this XmlNode source, XPathExpression expression, params XPathVariable[] variables) + { + if (variables == null || variables.Length == 0 || variables[0] == null) + return source.SelectNodes(expression); + + var iterator = source.CreateNavigator().Select(expression, variables); + return XmlNodeListFactory.CreateNodeList(iterator); + } + + /// + /// Selects the first XmlNode that matches an XPath expression. + /// + /// A source XmlNode. + /// An XPath expression. + /// A set of XPathVariables. + /// The first XmlNode that matches the XPath expression. + /// + /// If is null, or is empty, or contains only one single + /// value which itself is null, then variables are ignored. + /// The XPath expression should reference variables as $var. + /// public static XmlNode SelectSingleNode(this XmlNode source, string expression, IEnumerable variables) { var av = variables == null ? null : variables.ToArray(); return SelectSingleNode(source, expression, av); } + /// + /// Selects the first XmlNode that matches an XPath expression. + /// + /// A source XmlNode. + /// An XPath expression. + /// A set of XPathVariables. + /// The first XmlNode that matches the XPath expression. + /// + /// If is null, or is empty, or contains only one single + /// value which itself is null, then variables are ignored. + /// The XPath expression should reference variables as $var. + /// + public static XmlNode SelectSingleNode(this XmlNode source, XPathExpression expression, IEnumerable variables) + { + var av = variables == null ? null : variables.ToArray(); + return SelectSingleNode(source, expression, av); + } + + /// + /// Selects the first XmlNode that matches an XPath expression. + /// + /// A source XmlNode. + /// An XPath expression. + /// A set of XPathVariables. + /// The first XmlNode that matches the XPath expression. + /// + /// If is null, or is empty, or contains only one single + /// value which itself is null, then variables are ignored. + /// The XPath expression should reference variables as $var. + /// public static XmlNode SelectSingleNode(this XmlNode source, string expression, params XPathVariable[] variables) { if (variables == null || variables.Length == 0 || variables[0] == null) @@ -52,6 +147,26 @@ namespace Umbraco.Core return SelectNodes(source, expression, variables).Cast().FirstOrDefault(); } + /// + /// Selects the first XmlNode that matches an XPath expression. + /// + /// A source XmlNode. + /// An XPath expression. + /// A set of XPathVariables. + /// The first XmlNode that matches the XPath expression. + /// + /// If is null, or is empty, or contains only one single + /// value which itself is null, then variables are ignored. + /// The XPath expression should reference variables as $var. + /// + public static XmlNode SelectSingleNode(this XmlNode source, XPathExpression expression, params XPathVariable[] variables) + { + if (variables == null || variables.Length == 0 || variables[0] == null) + return source.SelectSingleNode(expression); + + return SelectNodes(source, expression, variables).Cast().FirstOrDefault(); + } + /// /// Converts from an XDocument to an XmlDocument /// diff --git a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedContentCache.cs b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedContentCache.cs index 88c8f3801e..df143ed8e3 100644 --- a/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedContentCache.cs +++ b/src/Umbraco.Web/PublishedCache/XmlPublishedCache/PublishedContentCache.cs @@ -6,6 +6,7 @@ using System.Text; using System.Xml; using System.Xml.XPath; using Umbraco.Core.Logging; +using Umbraco.Core; using Umbraco.Core.Models; using Umbraco.Core.Xml; using Umbraco.Web.Routing; diff --git a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/moveOrCopy.aspx.cs b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/moveOrCopy.aspx.cs index 2cff12eb51..ba48e944fa 100644 --- a/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/moveOrCopy.aspx.cs +++ b/src/Umbraco.Web/umbraco.presentation/umbraco/dialogs/moveOrCopy.aspx.cs @@ -97,12 +97,12 @@ namespace umbraco.dialogs if (Request.GetItemAsString("mode") == "cut") { - pane_form.Text = ui.Text("moveOrCopy", "moveTo", cmsNode.Text, UmbracoUser); + pane_form.Text = ui.Text("moveOrCopy", "moveTo", currContent.Name, UmbracoUser); pp_relate.Visible = false; } else { - pane_form.Text = ui.Text("moveOrCopy", "copyTo", cmsNode.Text, UmbracoUser); + pane_form.Text = ui.Text("moveOrCopy", "copyTo", currContent.Name, UmbracoUser); pp_relate.Visible = true; } diff --git a/src/umbraco.businesslogic/BasePages/BasePage.cs b/src/umbraco.businesslogic/BasePages/BasePage.cs index ba48699705..99c1172b1c 100644 --- a/src/umbraco.businesslogic/BasePages/BasePage.cs +++ b/src/umbraco.businesslogic/BasePages/BasePage.cs @@ -56,31 +56,7 @@ namespace umbraco.BasePages protected static ISqlHelper SqlHelper { get { return BusinessLogic.Application.SqlHelper; } - } - - /// - /// Returns the current ApplicationContext - /// - public ApplicationContext ApplicationContext - { - get { return ApplicationContext.Current; } - } - - /// - /// Returns a ServiceContext - /// - public ServiceContext Services - { - get { return ApplicationContext.Services; } - } - - /// - /// Returns a DatabaseContext - /// - public DatabaseContext DatabaseContext - { - get { return ApplicationContext.DatabaseContext; } - } + } /// /// Returns the current ApplicationContext