diff --git a/components/editorControls/MultiNodeTreePicker/FilteredContentTree.cs b/components/editorControls/MultiNodeTreePicker/FilteredContentTree.cs index fc92e8582f..4ac1a37147 100644 --- a/components/editorControls/MultiNodeTreePicker/FilteredContentTree.cs +++ b/components/editorControls/MultiNodeTreePicker/FilteredContentTree.cs @@ -74,9 +74,9 @@ namespace umbraco.editorControls.MultiNodeTreePicker case NodeSelectionType.Picker: //if it is a picker, then find the start node id var definedId = this.GetPersistedCookieValue( - x => x.MntpGetStartNodeId(this.GetDataTypeId()), uQuery.RootNodeId); + x => x.MntpGetStartNodeId(this.GetDataTypeId()), uQuery.RootNodeId); //return a document with id -1 (don't set this up as it will exception!) - m_DefinedStartNodeDoc = (definedId > 0) ? new Document(definedId) : new Document(uQuery.RootNodeId, true); + m_DefinedStartNodeDoc = (definedId > 0) ? new Document(definedId) : new Document(uQuery.RootNodeId, true); break; case NodeSelectionType.XPathExpression: //if it is an expression, then we need to find the start node based on the xpression type, etc... @@ -106,7 +106,7 @@ namespace umbraco.editorControls.MultiNodeTreePicker //if it's a FromCurrent expression, then we need to run the xpath from this node and below var currId = this.GetPersistedCookieValue( - x => x.MntpGetCurrentEditingNode(this.GetDataTypeId()), uQuery.RootNodeId); + x => x.MntpGetCurrentEditingNode(this.GetDataTypeId()), uQuery.RootNodeId); var currNode = umbraco.library.GetXmlNodeById(currId.ToString()); if (currNode.MoveNext()) { @@ -177,7 +177,7 @@ namespace umbraco.editorControls.MultiNodeTreePicker var startNode = new Document(StartNodeID); rootNode.Text = startNode.Text; rootNode.Icon = startNode.ContentTypeIcon; - } + } } } @@ -190,12 +190,12 @@ namespace umbraco.editorControls.MultiNodeTreePicker { base.OnRenderNode(ref xNode, doc); - var dataTypeId = this.GetDataTypeId(); - var xpath = this.GetXPathFromCookie(dataTypeId); - var xPathType = this.GetXPathFilterTypeFromCookie(dataTypeId); + var dataTypeId = this.GetDataTypeId(); + var xpath = this.GetXPathFromCookie(dataTypeId); + var xPathType = this.GetXPathFilterTypeFromCookie(dataTypeId); - // resolves any Umbraco params in the XPath - xpath = uQuery.ResolveXPath(xpath); + // resolves any Umbraco params in the XPath + xpath = uQuery.ResolveXPath(xpath); var xDoc = new XmlDocument(); XmlNode xmlDoc; @@ -214,8 +214,8 @@ namespace umbraco.editorControls.MultiNodeTreePicker xNode.DetermineClickable(xpath, xPathType, xml); //ensure that the NodeKey is passed through - xNode.Source = this.GetTreeServiceUrlWithParams(int.Parse(xNode.NodeID), dataTypeId); - } + xNode.Source = this.GetTreeServiceUrlWithParams(int.Parse(xNode.NodeID), dataTypeId); + } #endregion } } diff --git a/components/editorControls/MultiNodeTreePicker/FilteredMediaTree.cs b/components/editorControls/MultiNodeTreePicker/FilteredMediaTree.cs index 235ca30493..764d7ee522 100644 --- a/components/editorControls/MultiNodeTreePicker/FilteredMediaTree.cs +++ b/components/editorControls/MultiNodeTreePicker/FilteredMediaTree.cs @@ -6,29 +6,29 @@ using umbraco.cms.presentation.Trees; namespace umbraco.editorControls.MultiNodeTreePicker { - /// - /// FilteredMediaTree for the MultiNodeTreePicker. - /// + /// + /// FilteredMediaTree for the MultiNodeTreePicker. + /// public class FilteredMediaTree : BaseMediaTree { - /// - /// Initializes a new instance of the class. - /// - /// The app. + /// + /// Initializes a new instance of the class. + /// + /// The app. public FilteredMediaTree(string app) : base(app) { } - /// - /// - /// + /// + /// + /// private Media m_UserStartNodeMedia; - /// - /// - /// - private Media m_DefinedStartNodeMedia; + /// + /// + /// + private Media m_DefinedStartNodeMedia; /// /// Returns the Media object of the starting node for the current User. This ensures @@ -112,7 +112,7 @@ namespace umbraco.editorControls.MultiNodeTreePicker var startNode = new Media(StartNodeID); rootNode.Text = startNode.Text; rootNode.Icon = startNode.ContentTypeIcon; - } + } } } @@ -140,7 +140,7 @@ namespace umbraco.editorControls.MultiNodeTreePicker node.Source = this.GetTreeServiceUrlWithParams(int.Parse(node.NodeID), this.GetDataTypeId()); base.OnBeforeNodeRender(ref sender, ref node, e); - } + } #endregion } } diff --git a/components/editorControls/MultiNodeTreePicker/MNTPResources.Designer.cs b/components/editorControls/MultiNodeTreePicker/MNTPResources.Designer.cs index e49d834df5..b5a6344eae 100644 --- a/components/editorControls/MultiNodeTreePicker/MNTPResources.Designer.cs +++ b/components/editorControls/MultiNodeTreePicker/MNTPResources.Designer.cs @@ -39,7 +39,7 @@ namespace umbraco.editorControls.MultiNodeTreePicker public static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("uComponents.DataTypes.MultiNodeTreePicker.MNTPResources", typeof(MNTPResources).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("umbraco.editorControls.MultiNodeTreePicker.MNTPResources", typeof(MNTPResources).Assembly); resourceMan = temp; } return resourceMan; diff --git a/components/editorControls/MultiNodeTreePicker/MNTPResources.resx b/components/editorControls/MultiNodeTreePicker/MNTPResources.resx index ebb91472b1..e3e9167bc1 100644 --- a/components/editorControls/MultiNodeTreePicker/MNTPResources.resx +++ b/components/editorControls/MultiNodeTreePicker/MNTPResources.resx @@ -112,10 +112,10 @@ 2.0 - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 The maximum number of items that are allowed to be selected by a content editor. If an unlimited number of node selections should be allowed, then enter -1 as the value @@ -124,7 +124,7 @@ The minimum number of items that are allowed to be selected by a content editor. - Nodes can be selected from a parent node (Node Picker) or by an XPath expression. NOTE:When using an XPath expression, only published nodes can be shown. + Nodes can be selected from a parent node (Node Picker) or by an XPath expression. NOTE: When using an XPath expression, only published nodes can be shown. If enabled and 'media' is selected as the tree type then a thumbnail will be rendered for each item selected. @@ -139,13 +139,13 @@ You can specify to store the data in Umbraco as comma seperated or as XML. By default it is stored as XML which makes it easier to use the saved value in XSLT, however, storing it as comma seperated makes it easier to work with the data using the API such as Node factory. - This XPath expression is used to select a starting node and depends on the XPath expression type chosen (global or from current). IMPORTANT: This XPath expression should be written to match ONE node, if the expression matches more than one node, then the first node matched will be used as the start node. + This XPath expression is used to select a starting node and depends on the XPath expression type chosen (global or from current). <u>IMPORTANT</u>: This XPath expression should be written to match <b>ONE</b> node, if the expression matches more than one node, then the first node matched will be used as the start node. The XPath expression that is evaluated to match a start node can be evaluated at a global tree level, or matched from the current node being edited. - An xpath filter to match nodes that will be either enabled or disabled from being clicked (depending on what is selected for the XPath filter type). This XPath filter is for one node only so it should be formatted to select only one node. The XML to XPath against is the same as the Umbraco XML for one node.<br/><br/>Example: /*[name()='myNodeType' or name()='yourNodeType'] <br/><br/>The above would make all nodes of types: myNodeType or yourNodeType not selectable in the tree + An xpath filter to match nodes that will be either enabled or disabled from being clicked (depending on what is selected for the XPath filter type). This XPath filter is for one node only so it should be formatted to select only one node. The XML to XPath against is the same as the Umbraco XML for one node.<br/><br/>Example: <code>/*[self::'myNodeType or self::yourNodeType]</code><br/><br/>The above would make all nodes of types: myNodeType or yourNodeType not selectable in the tree Should the XPath filter match nodes to enable nodes or disable nodes. If Enable is selected, this means that only nodes that match the XPath filter will be allowed to be selected in the tree picker and vise versa for Disabled diff --git a/components/editorControls/MultiNodeTreePicker/MNTP_DataEditor.cs b/components/editorControls/MultiNodeTreePicker/MNTP_DataEditor.cs index 601ec12ae7..a36b93e5f9 100644 --- a/components/editorControls/MultiNodeTreePicker/MNTP_DataEditor.cs +++ b/components/editorControls/MultiNodeTreePicker/MNTP_DataEditor.cs @@ -12,6 +12,9 @@ using umbraco.controls.Images; using umbraco.controls.Tree; using umbraco.IO; +[assembly: WebResource("umbraco.editorControls.MultiNodeTreePicker.MultiNodePickerStyles.css", "text/css")] +[assembly: WebResource("umbraco.editorControls.MultiNodeTreePicker.MultiNodePickerScripts.js", "application/x-javascript")] + namespace umbraco.editorControls.MultiNodeTreePicker { /// @@ -53,8 +56,8 @@ namespace umbraco.editorControls.MultiNodeTreePicker contentTree.Tree.Title, contentTree.Tree.IconClosed, contentTree.Tree.IconOpened, - "uComponents.Core", - "DataTypes.MultiNodeTreePicker.FilteredContentTree", + "umbraco.editorControls", + "MultiNodeTreePicker.FilteredContentTree", contentTree.Tree.Action), contentTree.App); @@ -67,8 +70,8 @@ namespace umbraco.editorControls.MultiNodeTreePicker contentTree.Tree.Title, contentTree.Tree.IconClosed, contentTree.Tree.IconOpened, - "uComponents.Core", - "DataTypes.MultiNodeTreePicker.FilteredMediaTree", + "umbraco.editorControls", + "MultiNodeTreePicker.FilteredMediaTree", contentTree.Tree.Action), contentTree.App); @@ -561,7 +564,7 @@ namespace umbraco.editorControls.MultiNodeTreePicker writer.RenderEndTag(); //end multiNodePicker div - var tooltipAjaxUrl = IOHelper.ResolveUrl(SystemDirectories.Umbraco) + @"/plugins/MultiNodePicker/CustomTreeService.asmx/GetNodeInfo"; + var tooltipAjaxUrl = IOHelper.ResolveUrl(SystemDirectories.Umbraco) + @"/controls/Tree/CustomTreeService.asmx/GetNodeInfo"; //add jquery window load event to create the js tree picker var jsMethod = string.Format("jQuery('#{0}').MultiNodeTreePicker('{1}', {2}, '{3}', {4}, {5}, '{6}', '{7}');", diff --git a/components/editorControls/MultiNodeTreePicker/MNTP_PrevalueEditor.cs b/components/editorControls/MultiNodeTreePicker/MNTP_PrevalueEditor.cs index f1b2700166..a44678175b 100644 --- a/components/editorControls/MultiNodeTreePicker/MNTP_PrevalueEditor.cs +++ b/components/editorControls/MultiNodeTreePicker/MNTP_PrevalueEditor.cs @@ -3,8 +3,6 @@ using System.Collections; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; -// using uComponents.Core; -// using uComponents.DataTypes.Shared.Extensions; using umbraco.cms.businesslogic.datatype; using umbraco.interfaces; using umbraco.uicontrols.TreePicker; @@ -506,7 +504,7 @@ namespace umbraco.editorControls.MultiNodeTreePicker { var desc = new HtmlGenericControl("div"); var descSpan = new HtmlGenericControl("span"); - descSpan.InnerText = description; + descSpan.InnerHtml = description; desc.Attributes.Add("class", "description"); desc.Controls.Add(descSpan); div.Controls.Add(desc); @@ -577,12 +575,12 @@ namespace umbraco.editorControls.MultiNodeTreePicker /// The object that receives the server control content. protected override void Render(HtmlTextWriter writer) { - writer.AddAttribute(HtmlTextWriterAttribute.Class, "uComponents"); - writer.RenderBeginTag(HtmlTextWriterTag.Div); //start 'uComponents' + writer.AddAttribute(HtmlTextWriterAttribute.Class, "PrevalueEditor"); + writer.RenderBeginTag(HtmlTextWriterTag.Div); //start 'PrevalueEditor' base.Render(writer); - writer.RenderEndTag(); //end 'uComponents' + writer.RenderEndTag(); //end 'PrevalueEditor' } diff --git a/components/editorControls/MultiNodeTreePicker/SelectedItemsTemplate.cs b/components/editorControls/MultiNodeTreePicker/SelectedItemsTemplate.cs index 9020ebed01..92b999457d 100644 --- a/components/editorControls/MultiNodeTreePicker/SelectedItemsTemplate.cs +++ b/components/editorControls/MultiNodeTreePicker/SelectedItemsTemplate.cs @@ -12,7 +12,6 @@ namespace umbraco.editorControls.MultiNodeTreePicker /// internal class SelectedItemsTemplate : ITemplate { - #region ITemplate Members /// diff --git a/components/editorControls/MultiNodeTreePicker/XmlTreeNodeExtensions.cs b/components/editorControls/MultiNodeTreePicker/XmlTreeNodeExtensions.cs index 64bd4e4640..95814aa855 100644 --- a/components/editorControls/MultiNodeTreePicker/XmlTreeNodeExtensions.cs +++ b/components/editorControls/MultiNodeTreePicker/XmlTreeNodeExtensions.cs @@ -5,9 +5,9 @@ using umbraco.cms.presentation.Trees; namespace umbraco.editorControls.MultiNodeTreePicker { - /// - /// XmlTreeNode extensions for the MultiNodeTreePicker. - /// + /// + /// XmlTreeNode extensions for the MultiNodeTreePicker. + /// public static class XmlTreeNodeExtensions { //public static void DetermineSelected(this XmlTreeNode node) @@ -52,12 +52,12 @@ namespace umbraco.editorControls.MultiNodeTreePicker { //ensure the individual node is the correct color node.Style.AddCustom("uc-treenode-noclick"); - } + } } } catch (XPathException) { - node.Text = "uComponents: XPath Error!"; + node.Text = "umbraco.editorControls: MNTP: XPath Error!"; } } else @@ -71,7 +71,7 @@ namespace umbraco.editorControls.MultiNodeTreePicker { //ensure the individual node is the correct color node.Style.AddCustom("uc-treenode-noclick"); - } + } } } } diff --git a/components/editorControls/MultipleTextstring/MultipleTextstringPrevalueEditor.cs b/components/editorControls/MultipleTextstring/MultipleTextstringPrevalueEditor.cs index 1912601e2a..6d0833f4af 100644 --- a/components/editorControls/MultipleTextstring/MultipleTextstringPrevalueEditor.cs +++ b/components/editorControls/MultipleTextstring/MultipleTextstringPrevalueEditor.cs @@ -1,118 +1,116 @@ using System; using System.Web.UI; using System.Web.UI.WebControls; -// using uComponents.DataTypes.Shared.Extensions; -// using uComponents.DataTypes.Shared.PrevalueEditors; using umbraco.cms.businesslogic.datatype; namespace umbraco.editorControls.MultipleTextstring { - /// - /// The PreValue Editor for the Multiple Textstring data-type. - /// - public class MultipleTextstringPrevalueEditor : AbstractJsonPrevalueEditor - { - /// - /// The TextBox control for the maximum value of the control. - /// - private TextBox TextBoxMaximum; + /// + /// The PreValue Editor for the Multiple Textstring data-type. + /// + public class MultipleTextstringPrevalueEditor : AbstractJsonPrevalueEditor + { + /// + /// The TextBox control for the maximum value of the control. + /// + private TextBox TextBoxMaximum; - /// - /// The TextBox control for the minimum value of the control. - /// - private TextBox TextBoxMinimum; + /// + /// The TextBox control for the minimum value of the control. + /// + private TextBox TextBoxMinimum; - /// - /// Initializes a new instance of the class. - /// - /// Type of the data. + /// + /// Initializes a new instance of the class. + /// + /// Type of the data. public MultipleTextstringPrevalueEditor(umbraco.cms.businesslogic.datatype.BaseDataType dataType) : base(dataType, umbraco.cms.businesslogic.datatype.DBTypes.Ntext) - { - } + { + } - /// - /// Saves this instance. - /// - public override void Save() - { - // set the options - var options = new MultipleTextstringOptions(true); + /// + /// Saves this instance. + /// + public override void Save() + { + // set the options + var options = new MultipleTextstringOptions(true); - // parse the maximum - int maximum; - if (int.TryParse(this.TextBoxMaximum.Text, out maximum)) - { - if (maximum == 0) - { - maximum = -1; - } + // parse the maximum + int maximum; + if (int.TryParse(this.TextBoxMaximum.Text, out maximum)) + { + if (maximum == 0) + { + maximum = -1; + } - options.Maximum = maximum; - } + options.Maximum = maximum; + } - // parse the minimum - int minimum; - if (int.TryParse(this.TextBoxMinimum.Text, out minimum)) - { - if (minimum == 0) - { - minimum = -1; - } + // parse the minimum + int minimum; + if (int.TryParse(this.TextBoxMinimum.Text, out minimum)) + { + if (minimum == 0) + { + minimum = -1; + } - options.Minimum = minimum; - } + options.Minimum = minimum; + } - // save the options as JSON - this.SaveAsJson(options); - } + // save the options as JSON + this.SaveAsJson(options); + } - /// - /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering. - /// - protected override void CreateChildControls() - { - base.CreateChildControls(); + /// + /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering. + /// + protected override void CreateChildControls() + { + base.CreateChildControls(); - // set-up child controls - this.TextBoxMaximum = new TextBox() { ID = "Maximum", CssClass = "guiInputText" }; - this.TextBoxMinimum = new TextBox() { ID = "Minimum", CssClass = "guiInputText" }; + // set-up child controls + this.TextBoxMaximum = new TextBox() { ID = "Maximum", CssClass = "guiInputText" }; + this.TextBoxMinimum = new TextBox() { ID = "Minimum", CssClass = "guiInputText" }; - // add the child controls - this.Controls.AddPrevalueControls(this.TextBoxMaximum, this.TextBoxMinimum); - } + // add the child controls + this.Controls.AddPrevalueControls(this.TextBoxMaximum, this.TextBoxMinimum); + } - /// - /// Raises the event. - /// - /// The object that contains the event data. - protected override void OnLoad(EventArgs e) - { - base.OnLoad(e); + /// + /// Raises the event. + /// + /// The object that contains the event data. + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); - // get PreValues, load them into the controls. - var options = this.GetPreValueOptions(); + // get PreValues, load them into the controls. + var options = this.GetPreValueOptions(); - // no options? use the default ones. - if (options == null) - { - options = new MultipleTextstringOptions(true); - } + // no options? use the default ones. + if (options == null) + { + options = new MultipleTextstringOptions(true); + } - // set the values - this.TextBoxMaximum.Text = options.Maximum.ToString(); - this.TextBoxMinimum.Text = options.Minimum.ToString(); - } + // set the values + this.TextBoxMaximum.Text = options.Maximum.ToString(); + this.TextBoxMinimum.Text = options.Minimum.ToString(); + } - /// - /// Renders the contents of the control to the specified writer. This method is used primarily by control developers. - /// - /// A that represents the output stream to render HTML content on the client. - protected override void RenderContents(HtmlTextWriter writer) - { - // add property fields - writer.AddPrevalueRow("Minimum:", "Minimum number of rows to display.", this.TextBoxMinimum); - writer.AddPrevalueRow("Maximum:", "Maximum number of rows to display.", this.TextBoxMaximum); - } - } + /// + /// Renders the contents of the control to the specified writer. This method is used primarily by control developers. + /// + /// A that represents the output stream to render HTML content on the client. + protected override void RenderContents(HtmlTextWriter writer) + { + // add property fields + writer.AddPrevalueRow("Minimum:", "Minimum number of rows to display.", this.TextBoxMinimum); + writer.AddPrevalueRow("Maximum:", "Maximum number of rows to display.", this.TextBoxMaximum); + } + } } diff --git a/components/editorControls/PrevalueEditorExtensions.cs b/components/editorControls/PrevalueEditorExtensions.cs index 12a4d66067..38d1eacaa8 100644 --- a/components/editorControls/PrevalueEditorExtensions.cs +++ b/components/editorControls/PrevalueEditorExtensions.cs @@ -93,7 +93,7 @@ namespace umbraco.editorControls writer.AddAttribute(HtmlTextWriterAttribute.Class, "description"); writer.RenderBeginTag(HtmlTextWriterTag.Div); // start 'description' - Label desc = new Label() { Text = description }; + var desc = new Literal() { Text = description }; desc.RenderControl(writer); writer.RenderEndTag(); // end 'description' diff --git a/components/editorControls/Slider/SliderDataType.cs b/components/editorControls/Slider/SliderDataType.cs index 460befb8d6..d3d02cc151 100644 --- a/components/editorControls/Slider/SliderDataType.cs +++ b/components/editorControls/Slider/SliderDataType.cs @@ -1,5 +1,4 @@ using System; -// using uComponents.Core; using umbraco.cms.businesslogic.datatype; using umbraco.interfaces; diff --git a/components/editorControls/Slider/SliderOptions.cs b/components/editorControls/Slider/SliderOptions.cs index 8551d5d518..4d628d2779 100644 --- a/components/editorControls/Slider/SliderOptions.cs +++ b/components/editorControls/Slider/SliderOptions.cs @@ -1,5 +1,4 @@ using System.ComponentModel; -// using uComponents.DataTypes.Shared.PrevalueEditors; using umbraco.cms.businesslogic.datatype; namespace umbraco.editorControls.Slider diff --git a/components/editorControls/Slider/SliderPrevalueEditor.cs b/components/editorControls/Slider/SliderPrevalueEditor.cs index 26964b0e26..fd95b67a9d 100644 --- a/components/editorControls/Slider/SliderPrevalueEditor.cs +++ b/components/editorControls/Slider/SliderPrevalueEditor.cs @@ -1,8 +1,6 @@ using System; using System.Web.UI; using System.Web.UI.WebControls; -// using uComponents.DataTypes.Shared.Extensions; -// using uComponents.DataTypes.Shared.PrevalueEditors; using umbraco.cms.businesslogic.datatype; namespace umbraco.editorControls.Slider diff --git a/components/editorControls/XPathCheckBoxList/XPathCheckBoxListDataEditor.cs b/components/editorControls/XPathCheckBoxList/XPathCheckBoxListDataEditor.cs index 88b050027c..5ef6c8f343 100644 --- a/components/editorControls/XPathCheckBoxList/XPathCheckBoxListDataEditor.cs +++ b/components/editorControls/XPathCheckBoxList/XPathCheckBoxListDataEditor.cs @@ -4,7 +4,6 @@ using System.Linq; using System.Web.UI; using System.Web.UI.WebControls; using System.Xml.Linq; -// using uComponents.Core; using umbraco.interfaces; namespace umbraco.editorControls.XPathCheckBoxList diff --git a/components/editorControls/XPathCheckBoxList/XPathCheckBoxListPreValueEditor.cs b/components/editorControls/XPathCheckBoxList/XPathCheckBoxListPreValueEditor.cs index aacb9d4284..e6e585426a 100644 --- a/components/editorControls/XPathCheckBoxList/XPathCheckBoxListPreValueEditor.cs +++ b/components/editorControls/XPathCheckBoxList/XPathCheckBoxListPreValueEditor.cs @@ -2,8 +2,6 @@ using System.Web.UI; using System.Web.UI.WebControls; using System.Xml.XPath; -// using uComponents.DataTypes.Shared.Extensions; -// using uComponents.DataTypes.Shared.PrevalueEditors; using umbraco.cms.businesslogic.datatype; namespace umbraco.editorControls.XPathCheckBoxList diff --git a/components/editorControls/XPathDropDownList/XPathDropDownListDataEditor.cs b/components/editorControls/XPathDropDownList/XPathDropDownListDataEditor.cs index fe7078c8ed..0cdade3486 100644 --- a/components/editorControls/XPathDropDownList/XPathDropDownListDataEditor.cs +++ b/components/editorControls/XPathDropDownList/XPathDropDownListDataEditor.cs @@ -12,138 +12,138 @@ using umbraco.interfaces; namespace umbraco.editorControls.XPathDropDownList { - /// - /// XPath configurabale DropDownList Data Type - /// - public class XPathDropDownListDataEditor : CompositeControl, IDataEditor - { - /// - /// Field for the data. - /// - private IData m_Data; + /// + /// XPath configurabale DropDownList Data Type + /// + public class XPathDropDownListDataEditor : CompositeControl, IDataEditor + { + /// + /// Field for the data. + /// + private IData m_Data; - /// - /// Field for the options. - /// - private XPathDropDownListOptions m_Options; + /// + /// Field for the options. + /// + private XPathDropDownListOptions m_Options; - /// - /// Field for the CustomValidator. - /// - private CustomValidator m_CustomValidator = new CustomValidator(); + /// + /// Field for the CustomValidator. + /// + private CustomValidator m_CustomValidator = new CustomValidator(); - /// - /// Field for the DropDownList. - /// - private DropDownList m_DropDownList = new DropDownList(); + /// + /// Field for the DropDownList. + /// + private DropDownList m_DropDownList = new DropDownList(); - /// - /// Gets a value indicating whether [treat as rich text editor]. - /// - /// - /// true if [treat as rich text editor]; otherwise, false. - /// - public virtual bool TreatAsRichTextEditor - { - get - { - return false; - } - } + /// + /// Gets a value indicating whether [treat as rich text editor]. + /// + /// + /// true if [treat as rich text editor]; otherwise, false. + /// + public virtual bool TreatAsRichTextEditor + { + get + { + return false; + } + } - /// - /// Gets a value indicating whether [show label]. - /// - /// true if [show label]; otherwise, false. - public virtual bool ShowLabel - { - get - { - return true; - } - } + /// + /// Gets a value indicating whether [show label]. + /// + /// true if [show label]; otherwise, false. + public virtual bool ShowLabel + { + get + { + return true; + } + } - /// - /// Gets the editor. - /// - /// The editor. - public Control Editor - { - get - { - return this; - } - } + /// + /// Gets the editor. + /// + /// The editor. + public Control Editor + { + get + { + return this; + } + } - /// - /// Initializes a new instance of XPathCheckBoxListDataEditor - /// - /// - /// - internal XPathDropDownListDataEditor(IData data, XPathDropDownListOptions options) - { - this.m_Data = data; - this.m_Options = options; - } + /// + /// Initializes a new instance of XPathCheckBoxListDataEditor + /// + /// + /// + internal XPathDropDownListDataEditor(IData data, XPathDropDownListOptions options) + { + this.m_Data = data; + this.m_Options = options; + } - /// - /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering. - /// - protected override void CreateChildControls() - { - this.m_DropDownList.DataSource = uQuery.GetNodesByXPath(this.m_Options.XPath).ToNameIds(); - this.m_DropDownList.DataTextField = "Value"; - this.m_DropDownList.DataValueField = this.m_Options.UseId ? "Key" : "Value"; - this.m_DropDownList.DataBind(); + /// + /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering. + /// + protected override void CreateChildControls() + { + this.m_DropDownList.DataSource = uQuery.GetNodesByXPath(this.m_Options.XPath).ToNameIds(); + this.m_DropDownList.DataTextField = "Value"; + this.m_DropDownList.DataValueField = this.m_Options.UseId ? "Key" : "Value"; + this.m_DropDownList.DataBind(); - // Add a default please select value - this.m_DropDownList.Items.Insert(0, new ListItem(string.Empty, "-1")); + // Add a default please select value + this.m_DropDownList.Items.Insert(0, new ListItem(string.Concat(ui.Text("choose"), "..."), "-1")); - this.Controls.Add(this.m_CustomValidator); - this.Controls.Add(this.m_DropDownList); - } + this.Controls.Add(this.m_CustomValidator); + this.Controls.Add(this.m_DropDownList); + } - /// - /// Raises the event. - /// - /// The object that contains the event data. - protected override void OnLoad(EventArgs e) - { - base.OnLoad(e); - this.EnsureChildControls(); + /// + /// Raises the event. + /// + /// The object that contains the event data. + protected override void OnLoad(EventArgs e) + { + base.OnLoad(e); + this.EnsureChildControls(); - if (!this.Page.IsPostBack) - { - // Get selected items from Node Name or Node Id - var dropDownListItem = this.m_DropDownList.Items.FindByValue(this.m_Data.Value.ToString()); - if (dropDownListItem != null) - { - dropDownListItem.Selected = true; - } - } - } + if (!this.Page.IsPostBack) + { + // Get selected items from Node Name or Node Id + var dropDownListItem = this.m_DropDownList.Items.FindByValue(this.m_Data.Value.ToString()); + if (dropDownListItem != null) + { + dropDownListItem.Selected = true; + } + } + } - /// - /// Called by Umbraco when saving the node - /// - public void Save() - { - Property property = new Property(((DefaultData)this.m_Data).PropertyId); - if (property.PropertyType.Mandatory && this.m_DropDownList.SelectedValue == "-1") - { - // Property is mandatory, but no value selected in the DropDownList - this.m_CustomValidator.IsValid = false; + /// + /// Called by Umbraco when saving the node + /// + public void Save() + { + Property property = new Property(((umbraco.cms.businesslogic.datatype.DefaultData)this.m_Data).PropertyId); + if (property.PropertyType.Mandatory && this.m_DropDownList.SelectedValue == "-1") + { + // Property is mandatory, but no value selected in the DropDownList + this.m_CustomValidator.IsValid = false; - DocumentType documentType = new DocumentType(property.PropertyType.ContentTypeId); - ContentType.TabI tab = documentType.getVirtualTabs.Where(x => x.Id == property.PropertyType.TabId).FirstOrDefault(); + DocumentType documentType = new DocumentType(property.PropertyType.ContentTypeId); + ContentType.TabI tab = documentType.getVirtualTabs.Where(x => x.Id == property.PropertyType.TabId).FirstOrDefault(); - if (tab != null) - { - this.m_CustomValidator.ErrorMessage = ui.Text("errorHandling", "errorMandatory", new string[] { property.PropertyType.Alias, tab.Caption }, User.GetCurrent()); - } - } + if (tab != null) + { + this.m_CustomValidator.ErrorMessage = ui.Text("errorHandling", "errorMandatory", new string[] { property.PropertyType.Alias, tab.Caption }, User.GetCurrent()); + } + } - this.m_Data.Value = this.m_DropDownList.SelectedValue; - } - } + this.m_Data.Value = this.m_DropDownList.SelectedValue; + } + } } diff --git a/components/editorControls/XPathDropDownList/XPathDropDownListPreValueEditor.cs b/components/editorControls/XPathDropDownList/XPathDropDownListPreValueEditor.cs index ea64d8f4a4..cb67106f07 100644 --- a/components/editorControls/XPathDropDownList/XPathDropDownListPreValueEditor.cs +++ b/components/editorControls/XPathDropDownList/XPathDropDownListPreValueEditor.cs @@ -2,8 +2,6 @@ using System.Web.UI; using System.Web.UI.WebControls; using System.Xml.XPath; -// using uComponents.DataTypes.Shared.Extensions; -// using uComponents.DataTypes.Shared.PrevalueEditors; using umbraco.cms.businesslogic.datatype; namespace umbraco.editorControls.XPathDropDownList diff --git a/umbraco/presentation/umbraco.presentation.csproj b/umbraco/presentation/umbraco.presentation.csproj index 2ede531ad4..f293c54587 100644 --- a/umbraco/presentation/umbraco.presentation.csproj +++ b/umbraco/presentation/umbraco.presentation.csproj @@ -520,7 +520,6 @@ Component - @@ -1702,6 +1701,8 @@ + + @@ -3224,7 +3225,6 @@ welcome.ascx.cs Designer - language.aspx.cs Designer diff --git a/umbraco/presentation/umbraco/controls/Tree/CustomTreeControl.cs b/umbraco/presentation/umbraco/controls/Tree/CustomTreeControl.cs index eb284314e9..89eeaa74d2 100644 --- a/umbraco/presentation/umbraco/controls/Tree/CustomTreeControl.cs +++ b/umbraco/presentation/umbraco/controls/Tree/CustomTreeControl.cs @@ -8,117 +8,83 @@ using umbraco.IO; namespace umbraco.controls.Tree { - /// - /// A custom tree control that uses a custom web service to return the initial node, this is required - /// due to a bug that exists in Umbraco 4.5.1 tree control/web service. - /// - /// - /// Since we're inheriting from a UserControl and all of the ClientDependency registrations are done inline, we need - /// to re-register the ClientDependencies. - /// - [ClientDependency(10, ClientDependencyType.Css, "Tree/treeIcons.css", "UmbracoClient")] - [ClientDependency(11, ClientDependencyType.Css, "Tree/menuIcons.css", "UmbracoClient")] - [ClientDependency(12, ClientDependencyType.Css, "Tree/Themes/umbraco/style.css", "UmbracoClient")] - [ClientDependency(0, ClientDependencyType.Javascript, "Application/NamespaceManager.js", "UmbracoClient")] - [ClientDependency(ClientDependencyType.Javascript, "Application/UmbracoClientManager.js", "UmbracoClient")] - [ClientDependency(ClientDependencyType.Javascript, "Application/UmbracoApplicationActions.js", "UmbracoClient")] - [ClientDependency(ClientDependencyType.Javascript, "Application/UmbracoUtils.js", "UmbracoClient")] - [ClientDependency(0, ClientDependencyType.Javascript, "ui/jquery.js", "UmbracoClient")] - [ClientDependency(10, ClientDependencyType.Javascript, "Application/JQuery/jquery.metadata.min.js", "UmbracoClient")] - [ClientDependency(11, ClientDependencyType.Javascript, "Tree/jquery.tree.js", "UmbracoClient")] - [ClientDependency(12, ClientDependencyType.Javascript, "Tree/UmbracoContext.js", "UmbracoClient")] - [ClientDependency(12, ClientDependencyType.Javascript, "Tree/jquery.tree.contextmenu.js", "UmbracoClient")] - [ClientDependency(12, ClientDependencyType.Javascript, "Tree/jquery.tree.checkbox.js", "UmbracoClient")] - [ClientDependency(12, ClientDependencyType.Javascript, "Tree/NodeDefinition.js", "UmbracoClient")] - [ClientDependency(13, ClientDependencyType.Javascript, "Tree/UmbracoTree.js", "UmbracoClient")] - public class CustomTreeControl : TreeControl - { - /// - /// Static constructor to ensure that our web service is copied locally - /// - static CustomTreeControl() - { - var servicePath = Path.Combine(SystemDirectories.Umbraco, "plugins", "MultiNodePicker"); + /// + /// A custom tree control that uses a custom web service to return the initial node, this is required + /// due to a bug that exists in Umbraco 4.5.1 tree control/web service. + /// + /// + /// Since we're inheriting from a UserControl and all of the ClientDependency registrations are done inline, we need + /// to re-register the ClientDependencies. + /// + [ClientDependency(10, ClientDependencyType.Css, "Tree/treeIcons.css", "UmbracoClient")] + [ClientDependency(11, ClientDependencyType.Css, "Tree/menuIcons.css", "UmbracoClient")] + [ClientDependency(12, ClientDependencyType.Css, "Tree/Themes/umbraco/style.css", "UmbracoClient")] + [ClientDependency(0, ClientDependencyType.Javascript, "Application/NamespaceManager.js", "UmbracoClient")] + [ClientDependency(ClientDependencyType.Javascript, "Application/UmbracoClientManager.js", "UmbracoClient")] + [ClientDependency(ClientDependencyType.Javascript, "Application/UmbracoApplicationActions.js", "UmbracoClient")] + [ClientDependency(ClientDependencyType.Javascript, "Application/UmbracoUtils.js", "UmbracoClient")] + [ClientDependency(0, ClientDependencyType.Javascript, "ui/jquery.js", "UmbracoClient")] + [ClientDependency(10, ClientDependencyType.Javascript, "Application/JQuery/jquery.metadata.min.js", "UmbracoClient")] + [ClientDependency(11, ClientDependencyType.Javascript, "Tree/jquery.tree.js", "UmbracoClient")] + [ClientDependency(12, ClientDependencyType.Javascript, "Tree/UmbracoContext.js", "UmbracoClient")] + [ClientDependency(12, ClientDependencyType.Javascript, "Tree/jquery.tree.contextmenu.js", "UmbracoClient")] + [ClientDependency(12, ClientDependencyType.Javascript, "Tree/jquery.tree.checkbox.js", "UmbracoClient")] + [ClientDependency(12, ClientDependencyType.Javascript, "Tree/NodeDefinition.js", "UmbracoClient")] + [ClientDependency(13, ClientDependencyType.Javascript, "Tree/UmbracoTree.js", "UmbracoClient")] + public class CustomTreeControl : TreeControl + { + private static readonly object m_Locker = new object(); - if (!Directory.Exists(servicePath)) - { - lock (m_Locker) - { - //double check locking - if (!Directory.Exists(servicePath)) - { - //now create our new local web service - var wServiceTxt = CustomTreeServiceResource.CustomTreeService; - var dirMultiNodePicker = new DirectoryInfo(servicePath); - if (!dirMultiNodePicker.Exists) - { - dirMultiNodePicker.Create(); - } - var wServiceFile = new FileInfo(Path.Combine(dirMultiNodePicker.FullName, "CustomTreeService.asmx")); - if (!wServiceFile.Exists) - { - using (var sw = new StreamWriter(wServiceFile.Create())) - { - sw.Write(wServiceTxt); - } - } - } - } - } - } + /// + /// Ensure child controls are created on init + /// + /// + protected override void OnInit(EventArgs e) + { + base.OnInit(e); - private static readonly object m_Locker = new object(); + this.EnsureChildControls(); + } - /// - /// Ensure child controls are created on init - /// - /// - protected override void OnInit(EventArgs e) - { - base.OnInit(e); + /// + /// Create the child controls + /// + protected override void CreateChildControls() + { + base.CreateChildControls(); - this.EnsureChildControls(); - } + TreeContainer = new HtmlGenericControl(); + TreeContainer.TagName = "div"; + TreeContainer.ID = "TreeContainer"; - /// - /// Create the child controls - /// - protected override void CreateChildControls() - { - base.CreateChildControls(); + this.Controls.Add(TreeContainer); + } - TreeContainer = new HtmlGenericControl(); - TreeContainer.TagName = "div"; - TreeContainer.ID = "TreeContainer"; + /// + /// Adds the internal markup to the TreeContainer control + /// + /// + protected override void OnPreRender(EventArgs e) + { + base.OnPreRender(e); - this.Controls.Add(TreeContainer); - } + //add the internal markup to the TreeContainer + /*
*/ + TreeContainer.Controls.Add(new LiteralControl(@"
")); + } - /// - /// Adds the internal markup to the TreeContainer control - /// - /// - protected override void OnPreRender(EventArgs e) - { - base.OnPreRender(e); + /// + /// Render out the correct markup for the tree + /// + /// + /// Since we're inheriting from a UserControl, we need to render out the markup manually + /// + /// + protected override void Render(System.Web.UI.HtmlTextWriter writer) + { + //You'll notice that we're replacing the 'serviceUrl' parameter with our own custom web service! - //add the internal markup to the TreeContainer - /*
*/ - TreeContainer.Controls.Add(new LiteralControl(@"
")); - } - - /// - /// Render out the correct markup for the tree - /// - /// - /// Since we're inheriting from a UserControl, we need to render out the markup manually - /// - /// - protected override void Render(System.Web.UI.HtmlTextWriter writer) - { - //You'll notice that we're replacing the 'serviceUrl' parameter with our own custom web service! - - writer.Write(@" + writer.Write(@" "); - //render the controls - TreeContainer.RenderControl(writer); - } - } + //render the controls + TreeContainer.RenderControl(writer); + } + } } \ No newline at end of file diff --git a/umbraco/presentation/umbraco/controls/Tree/CustomTreeService.cs b/umbraco/presentation/umbraco/controls/Tree/CustomTreeService.cs index d9a8ae4158..dd6b49f65a 100644 --- a/umbraco/presentation/umbraco/controls/Tree/CustomTreeService.cs +++ b/umbraco/presentation/umbraco/controls/Tree/CustomTreeService.cs @@ -10,114 +10,114 @@ using umbraco.controls.Tree; namespace umbraco.controls.Tree { - /// - /// Client side ajax utlities for the tree - /// - [ScriptService] - [WebService] - public class CustomTreeService : WebService - { - /// - /// Returns some info about the node such as path and id - /// - /// - /// - [WebMethod] - [ScriptMethod(ResponseFormat = ResponseFormat.Json)] - public NodeInfo GetNodeInfo(int id) - { - Authorize(); + /// + /// Client side ajax utlities for the tree + /// + [ScriptService] + [WebService] + public class CustomTreeService : WebService + { + /// + /// Returns some info about the node such as path and id + /// + /// + /// + [WebMethod] + [ScriptMethod(ResponseFormat = ResponseFormat.Json)] + public NodeInfo GetNodeInfo(int id) + { + Authorize(); - var node = new CMSNode(id); - return new NodeInfo() - { - Id = node.Id, - Path = node.Path, - PathAsNames = string.Join("->", - GetPathNames(node.Path.Split(',') - .Select(x => int.Parse(x)) - .ToArray())) - }; - } + var node = new CMSNode(id); + return new NodeInfo() + { + Id = node.Id, + Path = node.Path, + PathAsNames = string.Join("->", + GetPathNames(node.Path.Split(',') + .Select(x => int.Parse(x)) + .ToArray())) + }; + } - /// - /// returns the node names for each id passed in - /// - /// - /// - private string[] GetPathNames(int[] ids) - { - return ids - .Where(x => x != -1) - .Select(x => new CMSNode(x).Text).ToArray(); - } + /// + /// returns the node names for each id passed in + /// + /// + /// + private string[] GetPathNames(int[] ids) + { + return ids + .Where(x => x != -1) + .Select(x => new CMSNode(x).Text).ToArray(); + } - /// - /// Returns a key/value object with: json, app, js as the keys - /// - /// - [WebMethod] - [ScriptMethod(ResponseFormat = ResponseFormat.Json)] - public Dictionary GetInitAppTreeData(string app, string treeType, bool showContextMenu, bool isDialog, TreeDialogModes dialogMode, string functionToCall, string nodeKey) - { - Authorize(); + /// + /// Returns a key/value object with: json, app, js as the keys + /// + /// + [WebMethod] + [ScriptMethod(ResponseFormat = ResponseFormat.Json)] + public Dictionary GetInitAppTreeData(string app, string treeType, bool showContextMenu, bool isDialog, TreeDialogModes dialogMode, string functionToCall, string nodeKey) + { + Authorize(); - var treeCtl = new TreeControl() - { - ShowContextMenu = showContextMenu, - IsDialog = isDialog, - DialogMode = dialogMode, - App = app, - TreeType = string.IsNullOrEmpty(treeType) ? "" : treeType, //don't set the tree type unless explicitly set - NodeKey = string.IsNullOrEmpty(nodeKey) ? "" : nodeKey, - //StartNodeID = -1, //TODO: set this based on parameters! - FunctionToCall = string.IsNullOrEmpty(functionToCall) ? "" : functionToCall - }; + var treeCtl = new TreeControl() + { + ShowContextMenu = showContextMenu, + IsDialog = isDialog, + DialogMode = dialogMode, + App = app, + TreeType = string.IsNullOrEmpty(treeType) ? "" : treeType, //don't set the tree type unless explicitly set + NodeKey = string.IsNullOrEmpty(nodeKey) ? "" : nodeKey, + //StartNodeID = -1, //TODO: set this based on parameters! + FunctionToCall = string.IsNullOrEmpty(functionToCall) ? "" : functionToCall + }; - var returnVal = new Dictionary(); + var returnVal = new Dictionary(); - if (string.IsNullOrEmpty(treeType)) - { - //if there's not tree type specified, then render out the tree as per normal with the normal - //way of doing things - returnVal.Add("json", treeCtl.GetJSONInitNode()); - } - else - { - //since 4.5.1 has a bug in it, it ignores if the treeType is specified and will always only render - //the whole APP not just a specific tree. - //this is a work around for this bug until it is fixed (which should be fixed in 4.5.2 + if (string.IsNullOrEmpty(treeType)) + { + //if there's not tree type specified, then render out the tree as per normal with the normal + //way of doing things + returnVal.Add("json", treeCtl.GetJSONInitNode()); + } + else + { + //since 4.5.1 has a bug in it, it ignores if the treeType is specified and will always only render + //the whole APP not just a specific tree. + //this is a work around for this bug until it is fixed (which should be fixed in 4.5.2 - //get the tree that we need to render - var tree = TreeDefinitionCollection.Instance.FindTree(treeType).CreateInstance(); - tree.ShowContextMenu = showContextMenu; - tree.IsDialog = isDialog; - tree.DialogMode = dialogMode; - tree.NodeKey = string.IsNullOrEmpty(nodeKey) ? "" : nodeKey; - tree.FunctionToCall = string.IsNullOrEmpty(functionToCall) ? "" : functionToCall; + //get the tree that we need to render + var tree = TreeDefinitionCollection.Instance.FindTree(treeType).CreateInstance(); + tree.ShowContextMenu = showContextMenu; + tree.IsDialog = isDialog; + tree.DialogMode = dialogMode; + tree.NodeKey = string.IsNullOrEmpty(nodeKey) ? "" : nodeKey; + tree.FunctionToCall = string.IsNullOrEmpty(functionToCall) ? "" : functionToCall; - //now render it's start node - var xTree = new XmlTree(); + //now render it's start node + var xTree = new XmlTree(); - //we're going to hijack the node name here to make it say content/media - var node = tree.RootNode; - if (node.Text.Equals("[FilteredContentTree]")) node.Text = ui.GetText("content"); - else if (node.Text.Equals("[FilteredMediaTree]")) node.Text = ui.GetText("media"); - xTree.Add(node); + //we're going to hijack the node name here to make it say content/media + var node = tree.RootNode; + if (node.Text.Equals("[FilteredContentTree]")) node.Text = ui.GetText("content"); + else if (node.Text.Equals("[FilteredMediaTree]")) node.Text = ui.GetText("media"); + xTree.Add(node); - returnVal.Add("json", xTree.ToString()); - } + returnVal.Add("json", xTree.ToString()); + } - returnVal.Add("app", app); - returnVal.Add("js", treeCtl.JSCurrApp); + returnVal.Add("app", app); + returnVal.Add("js", treeCtl.JSCurrApp); - return returnVal; - } + return returnVal; + } - internal static void Authorize() - { - if (!umbraco.BasePages.BasePage.ValidateUserContextID(umbraco.BasePages.BasePage.umbracoUserContextID)) - throw new Exception("Client authorization failed. User is not logged in"); - } - } + internal static void Authorize() + { + if (!umbraco.BasePages.BasePage.ValidateUserContextID(umbraco.BasePages.BasePage.umbracoUserContextID)) + throw new Exception("Client authorization failed. User is not logged in"); + } + } } \ No newline at end of file diff --git a/umbraco/presentation/umbraco/controls/Tree/CustomTreeServiceResource.Designer.cs b/umbraco/presentation/umbraco/controls/Tree/CustomTreeServiceResource.Designer.cs deleted file mode 100644 index fe84e5292e..0000000000 --- a/umbraco/presentation/umbraco/controls/Tree/CustomTreeServiceResource.Designer.cs +++ /dev/null @@ -1,72 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Runtime Version:4.0.30319.488 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace umbraco.controls.Tree -{ - - - /// - /// A strongly-typed resource class, for looking up localized strings, etc. - /// - // This class was auto-generated by the StronglyTypedResourceBuilder - // class via a tool like ResGen or Visual Studio. - // To add or remove a member, edit your .ResX file then rerun ResGen - // with the /str option, or rebuild your VS project. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class CustomTreeServiceResource { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal CustomTreeServiceResource() { - } - - /// - /// Returns the cached ResourceManager instance used by this class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("uComponents.Core.Shared.Tree.CustomTreeServiceResource", typeof(CustomTreeServiceResource).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Overrides the current thread's CurrentUICulture property for all - /// resource lookups using this strongly typed resource class. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - - /// - /// Looks up a localized string similar to <%@ WebService language="C#" class="uComponents.Core.Shared.Tree.CustomTreeService" %>. - /// - internal static string CustomTreeService { - get { - return ResourceManager.GetString("CustomTreeService", resourceCulture); - } - } - } -} diff --git a/umbraco/presentation/umbraco/controls/Tree/CustomTreeServiceResource.resx b/umbraco/presentation/umbraco/controls/Tree/CustomTreeServiceResource.resx deleted file mode 100644 index ff813c630a..0000000000 --- a/umbraco/presentation/umbraco/controls/Tree/CustomTreeServiceResource.resx +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - - customtreeservice.asmx;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 - - \ No newline at end of file diff --git a/umbraco/presentation/umbraco/uQuery/ContentExtensions.cs b/umbraco/presentation/umbraco/uQuery/ContentExtensions.cs index d076ddb452..0913fa9c5a 100644 --- a/umbraco/presentation/umbraco/uQuery/ContentExtensions.cs +++ b/umbraco/presentation/umbraco/uQuery/ContentExtensions.cs @@ -71,9 +71,7 @@ namespace umbraco /// /// empty string, or property value as string /// - // TODO: [LK] Move to uComponents.Legacy project - [Obsolete("Use .GetProperty(propertyAlias) instead.", false)] - public static string GetPropertyAsString(this Content item, string propertyAlias) + internal static string GetPropertyAsString(this Content item, string propertyAlias) { var propertyValue = string.Empty; var property = item.getProperty(propertyAlias); @@ -94,9 +92,7 @@ namespace umbraco /// /// true if can cast value, else false for all other circumstances /// - // TODO: [LK] Move to uComponents.Legacy project - [Obsolete("Use .GetProperty(propertyAlias) instead.", false)] - public static bool GetPropertyAsBoolean(this Content item, string propertyAlias) + internal static bool GetPropertyAsBoolean(this Content item, string propertyAlias) { var propertyValue = false; var property = item.getProperty(propertyAlias); @@ -117,52 +113,6 @@ namespace umbraco return propertyValue; } - /// - /// Get a DateTime value from a content item's property. - /// - /// The content item. - /// alias of propety to get - /// - /// DateTime value or DateTime.MinValue for all other circumstances - /// - // TODO: [LK] Move to uComponents.Legacy project - [Obsolete("Use .GetProperty(propertyAlias) instead.", false)] - public static DateTime GetPropertyAsDateTime(this Content item, string propertyAlias) - { - var propertyValue = DateTime.MinValue; - var property = item.getProperty(propertyAlias); - - if (property != null && property.Value != null) - { - DateTime.TryParse(Convert.ToString(property.Value), out propertyValue); - } - - return propertyValue; - } - - /// - /// Get an int value from a content item's property. - /// - /// The content item. - /// alias of propety to get - /// - /// int value of property or int.MinValue for all other circumstances - /// - // TODO: [LK] Move to uComponents.Legacy project - [Obsolete("Use .GetProperty(propertyAlias) instead.", false)] - public static int GetPropertyAsInt(this Content item, string propertyAlias) - { - var propertyValue = int.MinValue; - var property = item.getProperty(propertyAlias); - - if (property != null && property.Value != null) - { - int.TryParse(Convert.ToString(property.Value), out propertyValue); - } - - return propertyValue; - } - /// /// Gets the random content item. /// diff --git a/umbraco/presentation/umbraco/uQuery/MediaExtensions.cs b/umbraco/presentation/umbraco/uQuery/MediaExtensions.cs index e35740f56b..7bddbf5662 100644 --- a/umbraco/presentation/umbraco/uQuery/MediaExtensions.cs +++ b/umbraco/presentation/umbraco/uQuery/MediaExtensions.cs @@ -130,7 +130,6 @@ namespace umbraco ///
/// an umbraco.cms.businesslogic.media.Media object /// an int representing the depth of the Media object in the tree - // TODO: [LK] Move to uComponents.Legacy project [Obsolete("Use .Level instead")] public static int GetDepth(this Media media) { diff --git a/umbraco/presentation/umbraco/uQuery/NodeExtensions.cs b/umbraco/presentation/umbraco/uQuery/NodeExtensions.cs index 7edfc35359..824bba21c9 100644 --- a/umbraco/presentation/umbraco/uQuery/NodeExtensions.cs +++ b/umbraco/presentation/umbraco/uQuery/NodeExtensions.cs @@ -9,638 +9,591 @@ using umbraco.NodeFactory; namespace umbraco { - /// - /// uQuery extensions for the Node object. - /// - public static class NodeExtensions - { - /// - /// Gets the ancestor by path level. - /// - /// The node. - /// The level. - /// Returns an ancestor node by path level. - public static Node GetAncestorByPathLevel(this Node node, int level) - { - var nodeId = uQuery.GetNodeIdByPathLevel(node.Path, level); - return uQuery.GetNode(nodeId); - } + /// + /// uQuery extensions for the Node object. + /// + public static class NodeExtensions + { + /// + /// Gets the ancestor by path level. + /// + /// The node. + /// The level. + /// Returns an ancestor node by path level. + public static Node GetAncestorByPathLevel(this Node node, int level) + { + var nodeId = uQuery.GetNodeIdByPathLevel(node.Path, level); + return uQuery.GetNode(nodeId); + } - /// - /// Functionally similar to the XPath axis 'ancestor' - /// Get the Ancestor Nodes from current to root, (useful for breadcrumbs) - /// - /// an umbraco.presentation.nodeFactory.Node object - /// Node as IEnumerable - public static IEnumerable GetAncestorNodes(this Node node) - { - var ancestor = node.Parent; + /// + /// Functionally similar to the XPath axis 'ancestor' + /// Get the Ancestor Nodes from current to root, (useful for breadcrumbs) + /// + /// an umbraco.presentation.nodeFactory.Node object + /// Node as IEnumerable + public static IEnumerable GetAncestorNodes(this Node node) + { + var ancestor = node.Parent; - while (ancestor != null) - { - yield return ancestor as Node; + while (ancestor != null) + { + yield return ancestor as Node; - ancestor = ancestor.Parent; - } - } + ancestor = ancestor.Parent; + } + } - /// - /// Functionally similar to the XPath axis 'ancestor-or-self' - /// - /// an umbraco.presentation.nodeFactory.Node object - /// Node as IEnumerable - public static IEnumerable GetAncestorOrSelfNodes(this Node node) - { - yield return node; + /// + /// Functionally similar to the XPath axis 'ancestor-or-self' + /// + /// an umbraco.presentation.nodeFactory.Node object + /// Node as IEnumerable + public static IEnumerable GetAncestorOrSelfNodes(this Node node) + { + yield return node; - foreach (var ancestor in node.GetAncestorNodes()) - { - yield return ancestor; - } - } + foreach (var ancestor in node.GetAncestorNodes()) + { + yield return ancestor; + } + } - /// - /// Functionally similar to the XPath axis 'preceding-sibling' - /// - /// an umbraco.presentation.nodeFactory.Node object - /// Node as IEumerable - public static IEnumerable GetPrecedingSiblingNodes(this Node node) - { - if (node.Parent != null) - { - var parentNode = node.Parent as Node; - foreach (var precedingSiblingNode in parentNode.GetChildNodes().Where(childNode => childNode.SortOrder < node.SortOrder)) - { - yield return precedingSiblingNode; - } - } - } + /// + /// Functionally similar to the XPath axis 'preceding-sibling' + /// + /// an umbraco.presentation.nodeFactory.Node object + /// Node as IEumerable + public static IEnumerable GetPrecedingSiblingNodes(this Node node) + { + if (node.Parent != null) + { + var parentNode = node.Parent as Node; + foreach (var precedingSiblingNode in parentNode.GetChildNodes().Where(childNode => childNode.SortOrder < node.SortOrder)) + { + yield return precedingSiblingNode; + } + } + } - /// - /// Functionally similar to the XPath axis 'following-sibling' - /// - /// an umbraco.presentation.nodeFactory.Node object - /// Node as IEumerable - public static IEnumerable GetFollowingSiblingNodes(this Node node) - { - if (node.Parent != null) - { - var parentNode = node.Parent as Node; - foreach (var followingSiblingNode in parentNode.GetChildNodes().Where(childNode => childNode.SortOrder > node.SortOrder)) - { - yield return followingSiblingNode; - } - } - } + /// + /// Functionally similar to the XPath axis 'following-sibling' + /// + /// an umbraco.presentation.nodeFactory.Node object + /// Node as IEumerable + public static IEnumerable GetFollowingSiblingNodes(this Node node) + { + if (node.Parent != null) + { + var parentNode = node.Parent as Node; + foreach (var followingSiblingNode in parentNode.GetChildNodes().Where(childNode => childNode.SortOrder > node.SortOrder)) + { + yield return followingSiblingNode; + } + } + } - /// - /// Gets all sibling Nodes - /// - /// an umbraco.presentation.nodeFactory.Node object - /// Node as IEumerable - public static IEnumerable GetSiblingNodes(this Node node) - { - if (node.Parent != null) - { - var parentNode = node.Parent as Node; - foreach (var siblingNode in parentNode.GetChildNodes().Where(childNode => childNode.Id != node.Id)) - { - yield return siblingNode; - } - } - } + /// + /// Gets all sibling Nodes + /// + /// an umbraco.presentation.nodeFactory.Node object + /// Node as IEumerable + public static IEnumerable GetSiblingNodes(this Node node) + { + if (node.Parent != null) + { + var parentNode = node.Parent as Node; + foreach (var siblingNode in parentNode.GetChildNodes().Where(childNode => childNode.Id != node.Id)) + { + yield return siblingNode; + } + } + } - /// - /// Functionally similar to the XPath axis 'descendant-or-self' - /// - /// an umbraco.presentation.nodeFactory.Node object - /// Node as IEnumerable - public static IEnumerable GetDescendantOrSelfNodes(this Node node) - { - yield return node; + /// + /// Functionally similar to the XPath axis 'descendant-or-self' + /// + /// an umbraco.presentation.nodeFactory.Node object + /// Node as IEnumerable + public static IEnumerable GetDescendantOrSelfNodes(this Node node) + { + yield return node; - foreach (var descendant in node.GetDescendantNodes()) - { - yield return descendant; - } - } + foreach (var descendant in node.GetDescendantNodes()) + { + yield return descendant; + } + } - /// - /// Functionally similar to the XPath axis 'descendant' - /// Make the All Descendants LINQ queryable - /// taken from: http://our.umbraco.org/wiki/how-tos/useful-helper-extension-methods-%28linq-null-safe-access%29 - /// - /// an umbraco.presentation.nodeFactory.Node object - /// Node as IEnumerable - public static IEnumerable GetDescendantNodes(this Node node) - { - foreach (Node child in node.Children) - { - yield return child; + /// + /// Functionally similar to the XPath axis 'descendant' + /// Make the All Descendants LINQ queryable + /// taken from: http://our.umbraco.org/wiki/how-tos/useful-helper-extension-methods-%28linq-null-safe-access%29 + /// + /// an umbraco.presentation.nodeFactory.Node object + /// Node as IEnumerable + public static IEnumerable GetDescendantNodes(this Node node) + { + foreach (Node child in node.Children) + { + yield return child; - foreach (var descendant in child.GetDescendantNodes()) - { - yield return descendant; - } - } - } + foreach (var descendant in child.GetDescendantNodes()) + { + yield return descendant; + } + } + } - /// - /// Drills down into the descendant nodes returning those where Func is true, when Func is false further descendants are not checked - /// taken from: http://ucomponents.codeplex.com/discussions/246406 - /// - /// The umbraco.presentation.nodeFactory.Node. - /// The func - /// Nodes as IEnumerable - public static IEnumerable GetDescendantNodes(this Node node, Func func) - { - foreach (Node child in node.Children) - { - if (func(child)) - { - yield return child; + /// + /// Drills down into the descendant nodes returning those where Func is true, when Func is false further descendants are not checked + /// taken from: http://ucomponents.codeplex.com/discussions/246406 + /// + /// The umbraco.presentation.nodeFactory.Node. + /// The func + /// Nodes as IEnumerable + public static IEnumerable GetDescendantNodes(this Node node, Func func) + { + foreach (Node child in node.Children) + { + if (func(child)) + { + yield return child; - foreach (var descendant in child.GetDescendantNodes(func)) - { - yield return descendant; - } - } - } - } + foreach (var descendant in child.GetDescendantNodes(func)) + { + yield return descendant; + } + } + } + } - /// - /// Gets the descendant nodes by document-type. - /// - /// The umbraco.presentation.nodeFactory.Node. - /// The document type alias. - /// Nodes as IEnumerable - public static IEnumerable GetDescendantNodesByType(this Node node, string documentTypeAlias) - { - return node.GetDescendantNodes(n => n.NodeTypeAlias == documentTypeAlias); - } + /// + /// Gets the descendant nodes by document-type. + /// + /// The umbraco.presentation.nodeFactory.Node. + /// The document type alias. + /// Nodes as IEnumerable + public static IEnumerable GetDescendantNodesByType(this Node node, string documentTypeAlias) + { + return node.GetDescendantNodes(n => n.NodeTypeAlias == documentTypeAlias); + } - /// - /// Functionally similar to the XPath axis 'child' - /// Make the imediate Children LINQ queryable - /// Performance optimised for just imediate children. - /// taken from: http://our.umbraco.org/wiki/how-tos/useful-helper-extension-methods-%28linq-null-safe-access%29 - /// - /// an umbraco.presentation.nodeFactory.Node object - /// Node as IEnumerable - public static IEnumerable GetChildNodes(this Node node) - { - foreach (Node child in node.Children) - { - yield return child; - } - } + /// + /// Functionally similar to the XPath axis 'child' + /// Make the imediate Children LINQ queryable + /// Performance optimised for just imediate children. + /// taken from: http://our.umbraco.org/wiki/how-tos/useful-helper-extension-methods-%28linq-null-safe-access%29 + /// + /// an umbraco.presentation.nodeFactory.Node object + /// Node as IEnumerable + public static IEnumerable GetChildNodes(this Node node) + { + foreach (Node child in node.Children) + { + yield return child; + } + } - /// - /// Gets the child nodes. - /// - /// The umbraco.presentation.nodeFactory.Node. - /// The func. - /// Nodes as IEnumerable - public static IEnumerable GetChildNodes(this Node node, Func func) - { - foreach (Node child in node.Children) - { - if (func(child)) - { - yield return child; - } - } - } + /// + /// Gets the child nodes. + /// + /// The umbraco.presentation.nodeFactory.Node. + /// The func. + /// Nodes as IEnumerable + public static IEnumerable GetChildNodes(this Node node, Func func) + { + foreach (Node child in node.Children) + { + if (func(child)) + { + yield return child; + } + } + } - /// - /// Gets the child nodes by document-type. - /// - /// The umbraco.presentation.nodeFactory.Node. - /// The document type alias. - /// Nodes as IEnumerable - public static IEnumerable GetChildNodesByType(this Node node, string documentTypeAlias) - { - return node.GetChildNodes(n => n.NodeTypeAlias == documentTypeAlias); - } + /// + /// Gets the child nodes by document-type. + /// + /// The umbraco.presentation.nodeFactory.Node. + /// The document type alias. + /// Nodes as IEnumerable + public static IEnumerable GetChildNodesByType(this Node node, string documentTypeAlias) + { + return node.GetChildNodes(n => n.NodeTypeAlias == documentTypeAlias); + } - /// - /// Extension method on Node to retun a matching child node by name - /// - /// an umbraco.presentation.nodeFactory.Node object - /// name of node to search for - /// null or Node - public static Node GetChildNodeByName(this Node parentNode, string nodeName) - { - Node node = null; + /// + /// Extension method on Node to retun a matching child node by name + /// + /// an umbraco.presentation.nodeFactory.Node object + /// name of node to search for + /// null or Node + public static Node GetChildNodeByName(this Node parentNode, string nodeName) + { + Node node = null; - foreach (Node child in parentNode.Children) - { - if (child.Name == nodeName) - { - node = child; - break; - } - } + foreach (Node child in parentNode.Children) + { + if (child.Name == nodeName) + { + node = child; + break; + } + } - return node; + return node; - //// return node.GetChildNodes(n => n.Name == nodeName); - } + //// return node.GetChildNodes(n => n.Name == nodeName); + } - /// - /// Determines whether the specified node has property. - /// - /// The node. - /// The property alias. - /// - /// true if the specified node has property; otherwise, false. - /// - public static bool HasProperty(this Node node, string propertyAlias) - { - var property = node.GetProperty(propertyAlias); - return (property != null); - } + /// + /// Determines whether the specified node has property. + /// + /// The node. + /// The property alias. + /// + /// true if the specified node has property; otherwise, false. + /// + public static bool HasProperty(this Node node, string propertyAlias) + { + var property = node.GetProperty(propertyAlias); + return (property != null); + } #pragma warning disable 0618 /// - /// Get a value of type T from a property - /// - /// type T to cast to - /// an umbraco.presentation.nodeFactory.Node object - /// alias of property to get - /// default(T) or property cast to (T) - public static T GetProperty(this Node node, string propertyAlias) + /// Get a value of type T from a property + ///
+ /// type T to cast to + /// an umbraco.presentation.nodeFactory.Node object + /// alias of property to get + /// default(T) or property cast to (T) + public static T GetProperty(this Node node, string propertyAlias) { var typeConverter = TypeDescriptor.GetConverter(typeof(T)); - if (typeConverter != null) - { - if (typeof(T) == typeof(bool)) - { + if (typeConverter != null) + { + if (typeof(T) == typeof(bool)) + { // Use the GetPropertyAsBoolean method, as this handles true also being stored as "1" return (T)typeConverter.ConvertFrom(node.GetPropertyAsBoolean(propertyAlias).ToString()); } - try - { - return (T)typeConverter.ConvertFromString(node.GetPropertyAsString(propertyAlias)); - } - catch - { - return default(T); - } - } - else - { - return default(T); + try + { + return (T)typeConverter.ConvertFromString(node.GetPropertyAsString(propertyAlias)); + } + catch + { + return default(T); + } + } + else + { + return default(T); } } #pragma warning restore 0618 /// - /// Get a string value for the supplied property alias - /// - /// an umbraco.presentation.nodeFactory.Node object - /// alias of propety to get - /// empty string, or property value as string - // TODO: [LK] Move to uComponents.Legacy project - [Obsolete("Use .GetProperty(propertyAlias) instead", false)] - public static string GetPropertyAsString(this Node node, string propertyAlias) - { - var propertyValue = string.Empty; - var property = node.GetProperty(propertyAlias); + /// Get a string value for the supplied property alias + /// + /// an umbraco.presentation.nodeFactory.Node object + /// alias of propety to get + /// empty string, or property value as string + internal static string GetPropertyAsString(this Node node, string propertyAlias) + { + var propertyValue = string.Empty; + var property = node.GetProperty(propertyAlias); - if (property != null) - { - propertyValue = property.Value; - } + if (property != null) + { + propertyValue = property.Value; + } - return propertyValue; - } + return propertyValue; + } - /// - /// Get a boolean value for the supplied property alias (works with built in Yes/No dataype) - /// - /// an umbraco.presentation.nodeFactory.Node object - /// alias of propety to get - /// true if can cast value, else false for all other circumstances - // TODO: [LK] Move to uComponents.Legacy project - [Obsolete("Use .GetProperty(propertyAlias) instead", false)] - public static bool GetPropertyAsBoolean(this Node node, string propertyAlias) - { - var propertyValue = false; - var property = node.GetProperty(propertyAlias); + /// + /// Get a boolean value for the supplied property alias (works with built in Yes/No dataype) + /// + /// an umbraco.presentation.nodeFactory.Node object + /// alias of propety to get + /// true if can cast value, else false for all other circumstances + internal static bool GetPropertyAsBoolean(this Node node, string propertyAlias) + { + var propertyValue = false; + var property = node.GetProperty(propertyAlias); - if (property != null) - { - // Umbraco yes / no datatype stores a string value of '1' or '0' - if (property.Value == "1") - { - propertyValue = true; - } - else - { - bool.TryParse(property.Value, out propertyValue); - } - } + if (property != null) + { + // Umbraco yes / no datatype stores a string value of '1' or '0' + if (property.Value == "1") + { + propertyValue = true; + } + else + { + bool.TryParse(property.Value, out propertyValue); + } + } - return propertyValue; - } + return propertyValue; + } - /// - /// Get a DateTime value for the supplied property alias - /// - /// an umbraco.presentation.nodeFactory.Node object - /// alias of propety to get - /// DateTime value or DateTime.MinValue for all other circumstances - // TODO: [LK] Move to uComponents.Legacy project - [Obsolete("Use .GetProperty(propertyAlias) instead", false)] - public static DateTime GetPropertyAsDateTime(this Node node, string propertyAlias) - { - var propertyValue = DateTime.MinValue; - var property = node.GetProperty(propertyAlias); + /// + /// Extension method on Node obj to get it's depth + /// taken from: http://our.umbraco.org/wiki/how-tos/useful-helper-extension-methods-%28linq-null-safe-access%29 + /// + /// an umbraco.presentation.nodeFactory.Node object + /// int for depth, starts at 1 + [Obsolete("Use .Level instead")] + public static int GetDepth(this Node node) + { + return node.Path.Split(',').ToList().Count; + } - if (property != null) - { - DateTime.TryParse(property.Value, out propertyValue); - } + /// + /// Tell me the level of this node (0 = root) + /// updated from Depth and changed to start at 0 + /// to align with other 'Level' methods (eg xslt) + /// + /// + /// + public static int Level(this Node node) + { + return node.Path.Split(',').Length - 1; + } - return propertyValue; - } + /// + /// Gets the XML for the Node. + /// + /// The node. + /// Returns an XmlNode for the selected Node + public static XmlNode ToXml(this Node node) + { + return ((IHasXmlNode)umbraco.library.GetXmlNodeById(node.Id.ToString()).Current).GetNode(); + } - /// - /// Get an int value for the supplied property alias - /// - /// an umbraco.presentation.nodeFactory.Node object - /// alias of propety to get - /// int value of property or int.MinValue for all other circumstances - // TODO: [LK] Move to uComponents.Legacy project - [Obsolete("Use .GetProperty(propertyAlias) instead", false)] - public static int GetPropertyAsInt(this Node node, string propertyAlias) - { - var propertyValue = int.MinValue; - var property = node.GetProperty(propertyAlias); + /// + /// Returns the url for a given crop name using the built in Image Cropper datatype + /// + /// an umbraco.presentation.nodeFactory.Node object + /// property alias + /// name of crop to get url for + /// emtpy string or url + public static string GetImageCropperUrl(this Node node, string propertyAlias, string cropName) + { + string cropUrl = string.Empty; - if (property != null) - { - int.TryParse(property.Value, out propertyValue); - } + /* + * Example xml : + * + * + * + * + * + * + */ - return propertyValue; - } + if (!string.IsNullOrEmpty(node.GetProperty(propertyAlias))) + { + var xml = node.GetProperty(propertyAlias); - /// - /// Extension method on Node obj to get it's depth - /// taken from: http://our.umbraco.org/wiki/how-tos/useful-helper-extension-methods-%28linq-null-safe-access%29 - /// - /// an umbraco.presentation.nodeFactory.Node object - /// int for depth, starts at 1 - // TODO: [LK] Move to uComponents.Legacy project - [Obsolete("Use .Level instead")] - public static int GetDepth(this Node node) - { - return node.Path.Split(',').ToList().Count; - } + // TODO: [??] Add Node extension method: GetPropertyAsXmlNode() - /// - /// Tell me the level of this node (0 = root) - /// updated from Depth and changed to start at 0 - /// to align with other 'Level' methods (eg xslt) - /// - /// - /// - public static int Level(this Node node) - { - return node.Path.Split(',').Length - 1; - } + var xmlDocument = new XmlDocument(); + xmlDocument.LoadXml(xml); - /// - /// Gets the XML for the Node. - /// - /// The node. - /// Returns an XmlNode for the selected Node - public static XmlNode ToXml(this Node node) - { - return ((IHasXmlNode)umbraco.library.GetXmlNodeById(node.Id.ToString()).Current).GetNode(); - } + var cropNode = xmlDocument.SelectSingleNode(string.Concat("descendant::crops/crop[@name='", cropName, "']")); - /// - /// Returns the url for a given crop name using the built in Image Cropper datatype - /// - /// an umbraco.presentation.nodeFactory.Node object - /// property alias - /// name of crop to get url for - /// emtpy string or url - public static string GetImageCropperUrl(this Node node, string propertyAlias, string cropName) - { - string cropUrl = string.Empty; + if (cropNode != null) + { + cropUrl = cropNode.Attributes.GetNamedItem("url").InnerText; + } + } - /* - * Example xml : - * - * - * - * - * - * - */ + return cropUrl; + } - if (!string.IsNullOrEmpty(node.GetProperty(propertyAlias))) - { - var xml = node.GetProperty(propertyAlias); + /// + /// Sets a property value on this node + /// + /// an umbraco.presentation.nodeFactory.Node object + /// alias of property to set + /// value to set + /// the same node object on which this is an extension method + public static Node SetProperty(this Node node, string propertyAlias, object value) + { + var document = new Document(node.Id); - // TODO: [??] Add Node extension method: GetPropertyAsXmlNode() + document.SetProperty(propertyAlias, value); - var xmlDocument = new XmlDocument(); - xmlDocument.LoadXml(xml); + return node; + } - var cropNode = xmlDocument.SelectSingleNode(string.Concat("descendant::crops/crop[@name='", cropName, "']")); + /// + /// Republishes this node + /// + /// an umbraco.presentation.nodeFactory.Node object + /// if true then publishes under the context of User(0), if false uses current user + /// the same node object on which this is an extension method + public static Node Publish(this Node node, bool useAdminUser) + { + var document = new Document(node.Id); - if (cropNode != null) - { - cropUrl = cropNode.Attributes.GetNamedItem("url").InnerText; - } - } + document.Publish(useAdminUser); - return cropUrl; - } + return node; + } - /// - /// Sets a property value on this node - /// - /// an umbraco.presentation.nodeFactory.Node object - /// alias of property to set - /// value to set - /// the same node object on which this is an extension method - public static Node SetProperty(this Node node, string propertyAlias, object value) - { - var document = new Document(node.Id); + /// + /// Gets a random node. + /// + /// The nodes. + /// + /// Returns a random node from a collection of nodes. + /// + public static Node GetRandom(this List nodes) + { + var random = umbraco.library.GetRandom(); + return nodes[random.Next(0, (nodes.Count - 1))]; + } - document.SetProperty(propertyAlias, value); + /// + /// Gets a collection of random nodes. + /// + /// The nodes. + /// The number of items. + /// + /// Returns the specified number of random nodes from a collection of nodes. + /// + public static IEnumerable GetRandom(this List nodes, int numberOfItems) + { + var output = new List(numberOfItems); - return node; - } + while (output.Count < numberOfItems) + { + var randomNode = nodes.GetRandom(); + if (!output.Contains(randomNode)) + { + output.Add(randomNode); + } + } - /// - /// Republishes this node - /// - /// an umbraco.presentation.nodeFactory.Node object - /// if true then publishes under the context of User(0), if false uses current user - /// the same node object on which this is an extension method - public static Node Publish(this Node node, bool useAdminUser) - { - var document = new Document(node.Id); + return output; + } - document.Publish(useAdminUser); + /// + /// Gets the full nice URL. + /// + /// The node. + /// + public static string GetFullNiceUrl(this Node node) + { + if (!string.IsNullOrEmpty(node.NiceUrl) && node.NiceUrl[0] == '/') + { + return string.Concat(library.RequestServerVariables("HTTP_HOST"), node.NiceUrl); + } - return node; - } + return node.NiceUrl; + } - /// - /// Gets a random node. - /// - /// The nodes. - /// - /// Returns a random node from a collection of nodes. - /// - public static Node GetRandom(this List nodes) - { - var random = umbraco.library.GetRandom(); - return nodes[random.Next(0, (nodes.Count - 1))]; - } + /// + /// Gets the full nice URL. + /// + /// The node. + /// The language. + /// + public static string GetFullNiceUrl(this Node node, string language) + { + return node.GetFullNiceUrl(language, false); + } - /// - /// Gets a collection of random nodes. - /// - /// The nodes. - /// The number of items. - /// - /// Returns the specified number of random nodes from a collection of nodes. - /// - public static IEnumerable GetRandom(this List nodes, int numberOfItems) - { - var output = new List(numberOfItems); + /// + /// Gets the full nice URL. + /// + /// The node. + /// The language. + /// if set to true [SSL]. + /// + public static string GetFullNiceUrl(this Node node, string language, bool ssl) + { + foreach (var domain in library.GetCurrentDomains(node.Id)) + { + if (domain.Language.Equals(language)) + { + return node.GetFullNiceUrl(domain, ssl); + } + } - while (output.Count < numberOfItems) - { - var randomNode = nodes.GetRandom(); - if (!output.Contains(randomNode)) - { - output.Add(randomNode); - } - } + return string.Empty; + } - return output; - } + /// + /// Gets the full nice URL. + /// + /// The node. + /// The domain. + /// + public static string GetFullNiceUrl(this Node node, Domain domain) + { + return node.GetFullNiceUrl(domain, false); + } - /// - /// Gets the full nice URL. - /// - /// The node. - /// - public static string GetFullNiceUrl(this Node node) - { - if (!string.IsNullOrEmpty(node.NiceUrl) && node.NiceUrl[0] == '/') - { - return string.Concat(library.RequestServerVariables("HTTP_HOST"), node.NiceUrl); - } + /// + /// Gets the full nice URL. + /// + /// The node. + /// The domain. + /// if set to true [SSL]. + /// + public static string GetFullNiceUrl(this Node node, Domain domain, bool ssl) + { + // TODO: [OA] Document on Codeplex + if (!string.IsNullOrEmpty(node.NiceUrl) && node.NiceUrl[0] == '/') + { + return (ssl ? "https://" : "http://") + domain.Name + node.NiceUrl; + } - return node.NiceUrl; - } + return node.NiceUrl.Replace(library.RequestServerVariables("HTTP_HOST"), string.Concat((ssl ? "https://" : "http://"), domain.Name)); + } - /// - /// Gets the full nice URL. - /// - /// The node. - /// The language. - /// - public static string GetFullNiceUrl(this Node node, string language) - { - return node.GetFullNiceUrl(language, false); - } - - /// - /// Gets the full nice URL. - /// - /// The node. - /// The language. - /// if set to true [SSL]. - /// - public static string GetFullNiceUrl(this Node node, string language, bool ssl) - { - foreach (var domain in library.GetCurrentDomains(node.Id)) - { - if (domain.Language.Equals(language)) - { - return node.GetFullNiceUrl(domain, ssl); - } - } - - return string.Empty; - } - - /// - /// Gets the full nice URL. - /// - /// The node. - /// The domain. - /// - public static string GetFullNiceUrl(this Node node, Domain domain) - { - return node.GetFullNiceUrl(domain, false); - } - - /// - /// Gets the full nice URL. - /// - /// The node. - /// The domain. - /// if set to true [SSL]. - /// - public static string GetFullNiceUrl(this Node node, Domain domain, bool ssl) - { - // TODO: [OA] Document on Codeplex - if (!string.IsNullOrEmpty(node.NiceUrl) && node.NiceUrl[0] == '/') - { - return (ssl ? "https://" : "http://") + domain.Name + node.NiceUrl; - } - - return node.NiceUrl.Replace(library.RequestServerVariables("HTTP_HOST"), string.Concat((ssl ? "https://" : "http://"), domain.Name)); - } - - /// - /// Determines whether [the specified node] [is hidden from navigation]. - /// - /// The node. - /// - /// true if [the specified node] [is hidden from navigation]; otherwise, false. - /// - public static bool IsHiddenFromNavigation(this Node node) - { - // TODO: [OA] Document on Codeplex. Is this one really necessary? - [HR] this one could be confusing as depends on default naming convention - return node.GetProperty("umbracoNaviHide"); - } + /// + /// Determines whether [the specified node] [is hidden from navigation]. + /// + /// The node. + /// + /// true if [the specified node] [is hidden from navigation]; otherwise, false. + /// + public static bool IsHiddenFromNavigation(this Node node) + { + // TODO: [OA] Document on Codeplex. Is this one really necessary? - [HR] this one could be confusing as depends on default naming convention + return node.GetProperty("umbracoNaviHide"); + } #pragma warning disable 0618 - /// - /// Converts legacy nodeFactory collection to INode collection - /// - /// The legacy nodeFactory nodes. - /// Returns the legacy nodeFactory nodes as INode nodes. - public static IEnumerable ToINodes(this IEnumerable nodes) - { - return nodes.Select(n => new Node(n.Id)); - } + /// + /// Converts legacy nodeFactory collection to INode collection + /// + /// The legacy nodeFactory nodes. + /// Returns the legacy nodeFactory nodes as INode nodes. + public static IEnumerable ToINodes(this IEnumerable nodes) + { + return nodes.Select(n => new Node(n.Id)); + } - /// - /// Converts INode collection to legacy nodeFactory collection - /// - /// The nodes. - /// Returns the nodes as legacy nodeFactory nodes. - public static IEnumerable ToLegacyNodes(this IEnumerable nodes) - { - return nodes.Select(n => new umbraco.presentation.nodeFactory.Node(n.Id)); - } + /// + /// Converts INode collection to legacy nodeFactory collection + /// + /// The nodes. + /// Returns the nodes as legacy nodeFactory nodes. + public static IEnumerable ToLegacyNodes(this IEnumerable nodes) + { + return nodes.Select(n => new umbraco.presentation.nodeFactory.Node(n.Id)); + } #pragma warning restore 0618 - } + } } \ No newline at end of file diff --git a/umbraco/presentation/umbraco/uQuery/PreValueExtensions.cs b/umbraco/presentation/umbraco/uQuery/PreValueExtensions.cs index e22bc71132..f5931a2846 100644 --- a/umbraco/presentation/umbraco/uQuery/PreValueExtensions.cs +++ b/umbraco/presentation/umbraco/uQuery/PreValueExtensions.cs @@ -1,6 +1,4 @@ -//using uComponents.Core.Shared; -//using uComponents.Core.Shared.Extensions; -using umbraco.cms.businesslogic.datatype; +using umbraco.cms.businesslogic.datatype; namespace umbraco { diff --git a/umbraco/presentation/umbraco/uQuery/uQuery-Nodes.cs b/umbraco/presentation/umbraco/uQuery/uQuery-Nodes.cs index b2b4004147..cba1e99acd 100644 --- a/umbraco/presentation/umbraco/uQuery/uQuery-Nodes.cs +++ b/umbraco/presentation/umbraco/uQuery/uQuery-Nodes.cs @@ -166,7 +166,6 @@ namespace umbraco /// /// url to search for /// null or node matching supplied url - /// Uses uComponents.Core.XsltExtensions.Nodes.GetNodeIdByUrl public static Node GetNodeByUrl(string url) { return uQuery.GetNode(uQuery.GetNodeIdByUrl(url));