From f20712209d2a7de5bec875bcf11c2c4c2333d6b1 Mon Sep 17 00:00:00 2001 From: leekelleher Date: Sun, 29 Apr 2012 19:05:59 -0100 Subject: [PATCH] Relocated the uComponents data-type base classes to from 'cms' to 'editorControls' - better to keep them self-contained, (at this time). --- .../AbstractJsonPrevalueEditor.cs | 107 ++++++++++++++++++ .../editorControls}/AbstractOptions.cs | 2 +- .../editorControls/AbstractPrevalueEditor.cs | 79 +++++++++++++ .../editorControls}/CsvToXmlData.cs | 12 +- components/editorControls/PrevalueEditor.css | 83 ++++++++++++++ .../PrevalueEditorExtensions.cs | 105 +++++++++++++++++ .../editorControls/ResourceExtensions.cs | 73 ++++++++++++ .../editorControls}/XmlData.cs | 6 +- .../umbraco.editorControls.csproj | 8 ++ .../datatype/AbstractJsonPrevalueEditor.cs | 107 ------------------ .../datatype/AbstractPrevalueEditor.cs | 77 ------------- .../datatype/PrevalueEditorExtensions.cs | 105 ----------------- umbraco/cms/umbraco.cms.csproj | 7 -- 13 files changed, 465 insertions(+), 306 deletions(-) create mode 100644 components/editorControls/AbstractJsonPrevalueEditor.cs rename {umbraco/cms/businesslogic/datatype => components/editorControls}/AbstractOptions.cs (92%) create mode 100644 components/editorControls/AbstractPrevalueEditor.cs rename {umbraco/cms/businesslogic/datatype => components/editorControls}/CsvToXmlData.cs (82%) create mode 100644 components/editorControls/PrevalueEditor.css create mode 100644 components/editorControls/PrevalueEditorExtensions.cs create mode 100644 components/editorControls/ResourceExtensions.cs rename {umbraco/cms/businesslogic/datatype => components/editorControls}/XmlData.cs (85%) delete mode 100644 umbraco/cms/businesslogic/datatype/AbstractJsonPrevalueEditor.cs delete mode 100644 umbraco/cms/businesslogic/datatype/AbstractPrevalueEditor.cs delete mode 100644 umbraco/cms/businesslogic/datatype/PrevalueEditorExtensions.cs diff --git a/components/editorControls/AbstractJsonPrevalueEditor.cs b/components/editorControls/AbstractJsonPrevalueEditor.cs new file mode 100644 index 0000000000..fe093caf80 --- /dev/null +++ b/components/editorControls/AbstractJsonPrevalueEditor.cs @@ -0,0 +1,107 @@ +using System; +using System.Web.Script.Serialization; +using umbraco.BusinessLogic; +using umbraco.cms.businesslogic.datatype; + +namespace umbraco.editorControls +{ + /// + /// Abstract class for the PreValue Editor. + /// Specifically designed to serialize/deserialize the options as JSON. + /// + public abstract class AbstractJsonPrevalueEditor : AbstractPrevalueEditor + { + /// + /// The underlying base data-type. + /// + protected readonly umbraco.cms.businesslogic.datatype.BaseDataType m_DataType; + + /// + /// An object to temporarily lock writing to the database. + /// + private static readonly object m_Locker = new object(); + + /// + /// Initializes a new instance of the class. + /// + /// Type of the data. + public AbstractJsonPrevalueEditor(umbraco.cms.businesslogic.datatype.BaseDataType dataType) + { + this.m_DataType = dataType; + } + + /// + /// Initializes a new instance of the class. + /// + /// Type of the data. + /// Type of the database field. + public AbstractJsonPrevalueEditor(umbraco.cms.businesslogic.datatype.BaseDataType dataType, umbraco.cms.businesslogic.datatype.DBTypes dbType) + : base() + { + this.m_DataType = dataType; + this.m_DataType.DBType = dbType; + } + + /// + /// Gets the PreValue options for the data-type. + /// + /// The type of the resulting object. + /// + /// Returns the options for the PreValue Editor + /// + public T GetPreValueOptions() + { + var prevalues = PreValues.GetPreValues(this.m_DataType.DataTypeDefinitionId); + if (prevalues.Count > 0) + { + var prevalue = (PreValue)prevalues[0]; + if (!string.IsNullOrEmpty(prevalue.Value)) + { + try + { + // deserialize the options + var serializer = new JavaScriptSerializer(); + + // return the options + return serializer.Deserialize(prevalue.Value); + } + catch (Exception ex) + { + Log.Add(LogTypes.Error, this.m_DataType.DataTypeDefinitionId, string.Concat("umbraco.editorControls: Execption thrown: ", ex)); + } + } + } + + // if all else fails, return default options + return default(T); + } + + /// + /// Saves the data-type PreValue options. + /// + public void SaveAsJson(object options) + { + // serialize the options into JSON + var serializer = new JavaScriptSerializer(); + var json = serializer.Serialize(options); + + lock (m_Locker) + { + var prevalues = PreValues.GetPreValues(this.m_DataType.DataTypeDefinitionId); + if (prevalues.Count > 0) + { + var prevalue = (PreValue)prevalues[0]; + + // update + prevalue.Value = json; + prevalue.Save(); + } + else + { + // insert + PreValue.MakeNew(this.m_DataType.DataTypeDefinitionId, json); + } + } + } + } +} \ No newline at end of file diff --git a/umbraco/cms/businesslogic/datatype/AbstractOptions.cs b/components/editorControls/AbstractOptions.cs similarity index 92% rename from umbraco/cms/businesslogic/datatype/AbstractOptions.cs rename to components/editorControls/AbstractOptions.cs index 13443dda96..f166343210 100644 --- a/umbraco/cms/businesslogic/datatype/AbstractOptions.cs +++ b/components/editorControls/AbstractOptions.cs @@ -1,6 +1,6 @@ using System.ComponentModel; -namespace umbraco.cms.businesslogic.datatype +namespace umbraco.editorControls { /// /// Abstract class for the Prevalue Editor options. diff --git a/components/editorControls/AbstractPrevalueEditor.cs b/components/editorControls/AbstractPrevalueEditor.cs new file mode 100644 index 0000000000..d66d0f4592 --- /dev/null +++ b/components/editorControls/AbstractPrevalueEditor.cs @@ -0,0 +1,79 @@ +using System; +using System.Web.UI; +using System.Web.UI.WebControls; +using umbraco.interfaces; +using umbraco.cms.businesslogic.datatype; + +[assembly: WebResource("umbraco.editorControls.PrevalueEditor.css", "text/css")] + +namespace umbraco.editorControls +{ + /// + /// Abstract class for the PreValue Editor. + /// + public abstract class AbstractPrevalueEditor : WebControl, IDataPrevalue + { + /// + /// Initializes a new instance of the class. + /// + public AbstractPrevalueEditor() + : base() + { + } + + /// + /// Gets the editor. + /// + /// The editor. + public virtual Control Editor + { + get + { + return this; + } + } + + /// + /// Saves this instance. + /// + public virtual void Save() + { + } + + /// + /// Raises the event. + /// + /// An object that contains the event data. + protected override void OnInit(EventArgs e) + { + base.OnInit(e); + this.EnsureChildControls(); + + // Adds the client dependencies. + this.RegisterEmbeddedClientResource("umbraco.editorControls.PrevalueEditor.css", ClientDependencyType.Css); + } + + /// + /// Renders the HTML opening tag 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. + public override void RenderBeginTag(HtmlTextWriter writer) + { + writer.AddAttribute(HtmlTextWriterAttribute.Class, "PrevalueEditor"); + writer.RenderBeginTag(HtmlTextWriterTag.Div); + + base.RenderBeginTag(writer); + } + + /// + /// Renders the HTML closing tag of the control into the specified writer. This method is used primarily by control developers. + /// + /// A that represents the output stream to render HTML content on the client. + public override void RenderEndTag(HtmlTextWriter writer) + { + base.RenderEndTag(writer); + + writer.RenderEndTag(); + } + } +} \ No newline at end of file diff --git a/umbraco/cms/businesslogic/datatype/CsvToXmlData.cs b/components/editorControls/CsvToXmlData.cs similarity index 82% rename from umbraco/cms/businesslogic/datatype/CsvToXmlData.cs rename to components/editorControls/CsvToXmlData.cs index 28545aa912..626839c35e 100644 --- a/umbraco/cms/businesslogic/datatype/CsvToXmlData.cs +++ b/components/editorControls/CsvToXmlData.cs @@ -2,12 +2,12 @@ using umbraco; using umbraco.cms.businesslogic.datatype; -namespace umbraco.cms.businesslogic.datatype +namespace umbraco.editorControls { /// /// Overrides the object to return the value as XML. /// - public class CsvToXmlData : DefaultData + public class CsvToXmlData : umbraco.cms.businesslogic.datatype.DefaultData { /// /// The separators to split the delimited string. @@ -28,7 +28,7 @@ namespace umbraco.cms.businesslogic.datatype /// Initializes a new instance of the class. /// /// Type of the data. - public CsvToXmlData(BaseDataType dataType) + public CsvToXmlData(umbraco.cms.businesslogic.datatype.BaseDataType dataType) : this(dataType, "values") { } @@ -38,7 +38,7 @@ namespace umbraco.cms.businesslogic.datatype /// /// Type of the data. /// Name of the root. - public CsvToXmlData(BaseDataType dataType, string rootName) + public CsvToXmlData(umbraco.cms.businesslogic.datatype.BaseDataType dataType, string rootName) : this(dataType, rootName, "value") { } @@ -50,7 +50,7 @@ namespace umbraco.cms.businesslogic.datatype /// Type of the data. /// Name of the root. /// Name of the element. - public CsvToXmlData(BaseDataType dataType, string rootName, string elementName) + public CsvToXmlData(umbraco.cms.businesslogic.datatype.BaseDataType dataType, string rootName, string elementName) : this(dataType, rootName, elementName, new[] { "," }) { } @@ -62,7 +62,7 @@ namespace umbraco.cms.businesslogic.datatype /// Name of the root. /// Name of the element. /// The separator. - public CsvToXmlData(BaseDataType dataType, string rootName, string elementName, string[] separator) + public CsvToXmlData(umbraco.cms.businesslogic.datatype.BaseDataType dataType, string rootName, string elementName, string[] separator) : base(dataType) { this.rootName = rootName; diff --git a/components/editorControls/PrevalueEditor.css b/components/editorControls/PrevalueEditor.css new file mode 100644 index 0000000000..9461eac967 --- /dev/null +++ b/components/editorControls/PrevalueEditor.css @@ -0,0 +1,83 @@ +/* Standard clearfix */ +.clearfix:after +{ + content: "."; + display: block; + clear: both; + visibility: hidden; + line-height: 0; + height: 0; +} + +.clearfix +{ + display: inline-block; +} + +html[xmlns] .clearfix +{ + display: block; +} + +* html .clearfix +{ + height: 1%; +} + +.PrevalueEditor +{ + background: transparent url('<%= WebResource("uComponents.Core.Shared.Resources.Images.ucomponents-logo-small.png")%>') no-repeat right 8px; + padding-top: 40px; +} +.PrevalueEditor div.row +{ + margin-top: 5px; + margin-bottom: 5px; +} +.PrevalueEditor div.label +{ + float: left; + width: 120px; + margin-right: 10px; +} +.PrevalueEditor div.field +{ + float: left; +} + +.PrevalueEditor div.description +{ + clear: left; + color: #666; + float: left; + font-style: italic; + margin: 3px 0 10px 130px; +} + +/* validation */ +.PrevalueEditor .validator +{ + color: red; + display: block; + font-size: 11px; + margin-bottom: 3px; + margin-top: 3px; + visibility: visible; +} + +/* headers */ +.PrevalueEditor h3 +{ + clear: left; + color: #666; + float: left; + font-style: italic; + font-weight: bold; + margin: 3px 10px 10px 0; +} + +/* Tables */ +.PrevalueEditor td +{ + font-weight: bold; +} diff --git a/components/editorControls/PrevalueEditorExtensions.cs b/components/editorControls/PrevalueEditorExtensions.cs new file mode 100644 index 0000000000..12a4d66067 --- /dev/null +++ b/components/editorControls/PrevalueEditorExtensions.cs @@ -0,0 +1,105 @@ +using System.Web.UI; +using System.Web.UI.HtmlControls; +using System.Web.UI.WebControls; + +namespace umbraco.editorControls +{ + /// + /// Extension methods for the Prevalue Editor + /// + public static class PrevalueEditorExtensions + { + /// + /// Adds the prevalue controls. + /// + /// The collection. + /// The controls. + public static void AddPrevalueControls(this ControlCollection collection, params Control[] controls) + { + foreach (var control in controls) + { + collection.Add(control); + } + } + + /// + /// Adds the prevalue row heading. + /// + /// The writer. + /// The heading. + public static void AddPrevalueHeading(this HtmlTextWriter writer, string heading) + { + writer.AddAttribute(HtmlTextWriterAttribute.Class, "row clearfix"); + writer.RenderBeginTag(HtmlTextWriterTag.Div); // start 'row' + + writer.RenderBeginTag(HtmlTextWriterTag.H3); // start 'h3' + + writer.Write(heading); + + writer.RenderEndTag(); // end 'h3' + + writer.RenderEndTag(); // end 'row' + } + + /// + /// Adds a new row to the Prevalue Editor. + /// + /// The HtmlTextWriter. + /// The label for the field. + /// The controls for the field. + public static void AddPrevalueRow(this HtmlTextWriter writer, string label, params Control[] controls) + { + writer.AddPrevalueRow(label, string.Empty, controls); + } + + /// + /// Adds a new row to the Prevalue Editor, (with an optional description). + /// + /// The HtmlTextWriter. + /// The label for the field. + /// The description for the field. + /// The controls for the field. + public static void AddPrevalueRow(this HtmlTextWriter writer, string label, string description, params Control[] controls) + { + writer.AddAttribute(HtmlTextWriterAttribute.Class, "row clearfix"); + writer.RenderBeginTag(HtmlTextWriterTag.Div); // start 'row' + + writer.AddAttribute(HtmlTextWriterAttribute.Class, "label"); + writer.RenderBeginTag(HtmlTextWriterTag.Div); // start 'label' + + var lbl = new HtmlGenericControl("label") { InnerText = label }; + + if (controls.Length > 0 && !string.IsNullOrEmpty(controls[0].ClientID)) + { + lbl.Attributes.Add("for", controls[0].ClientID); + } + + lbl.RenderControl(writer); + + writer.RenderEndTag(); // end 'label' + + writer.AddAttribute(HtmlTextWriterAttribute.Class, "field"); + writer.RenderBeginTag(HtmlTextWriterTag.Div); // start 'field' + + foreach (var control in controls) + { + control.RenderControl(writer); + } + + writer.RenderEndTag(); // end 'field' + + if (!string.IsNullOrEmpty(description)) + { + writer.AddAttribute(HtmlTextWriterAttribute.Class, "description"); + writer.RenderBeginTag(HtmlTextWriterTag.Div); // start 'description' + + Label desc = new Label() { Text = description }; + desc.RenderControl(writer); + + writer.RenderEndTag(); // end 'description' + } + + writer.RenderEndTag(); // end 'row' + } + } +} \ No newline at end of file diff --git a/components/editorControls/ResourceExtensions.cs b/components/editorControls/ResourceExtensions.cs new file mode 100644 index 0000000000..18593679f4 --- /dev/null +++ b/components/editorControls/ResourceExtensions.cs @@ -0,0 +1,73 @@ +using System; +using System.Web.UI; +using umbraco; +using umbraco.cms.businesslogic.datatype; +using System.Web.UI.HtmlControls; + +namespace umbraco.editorControls +{ + /// + /// Extension methods for embedded resources + /// + public static class ResourceExtensions + { + /// + /// Registers the embedded client resource. + /// + /// The control. + /// Name of the resource. + /// The type. + public static void RegisterEmbeddedClientResource(this Control ctl, string resourceName, ClientDependencyType type) + { + ctl.RegisterEmbeddedClientResource(ctl.GetType(), resourceName, type); + } + + /// + /// Registers the embedded client resource. + /// + /// The control. + /// The resource container. + /// Name of the resource. + /// The type. + public static void RegisterEmbeddedClientResource(this Control ctl, Type resourceContainer, string resourceName, ClientDependencyType type) + { + ctl.Page.RegisterEmbeddedClientResource(resourceContainer, resourceName, type); + } + + /// + /// Registers the embedded client resource. + /// + /// The page. + /// The type containing the embedded resource + /// Name of the resource. + /// The type. + public static void RegisterEmbeddedClientResource(this Page page, Type resourceContainer, string resourceName, ClientDependencyType type) + { + var target = page.Header; + + // if there's no don't throw an exception. + if (target != null) + { + switch (type) + { + case ClientDependencyType.Css: + // get the urls for the embedded resources + var resourceUrl = page.ClientScript.GetWebResourceUrl(resourceContainer, resourceName); + var link = new HtmlLink(); + link.Attributes.Add("href", resourceUrl); + link.Attributes.Add("type", "text/css"); + link.Attributes.Add("rel", "stylesheet"); + target.Controls.Add(link); + break; + + case ClientDependencyType.Javascript: + page.ClientScript.RegisterClientScriptResource(resourceContainer, resourceName); + break; + + default: + break; + } + } + } + } +} \ No newline at end of file diff --git a/umbraco/cms/businesslogic/datatype/XmlData.cs b/components/editorControls/XmlData.cs similarity index 85% rename from umbraco/cms/businesslogic/datatype/XmlData.cs rename to components/editorControls/XmlData.cs index 406dabcb99..147080e4d2 100644 --- a/umbraco/cms/businesslogic/datatype/XmlData.cs +++ b/components/editorControls/XmlData.cs @@ -1,18 +1,18 @@ using System.Xml; using umbraco.cms.businesslogic.datatype; -namespace umbraco.cms.businesslogic.datatype +namespace umbraco.editorControls { /// /// Overrides the object to return the value as XML. /// - public class XmlData : DefaultData + public class XmlData : umbraco.cms.businesslogic.datatype.DefaultData { /// /// Initializes a new instance of the class. /// /// Type of the data. - public XmlData(BaseDataType dataType) + public XmlData(umbraco.cms.businesslogic.datatype.BaseDataType dataType) : base(dataType) { } diff --git a/components/editorControls/umbraco.editorControls.csproj b/components/editorControls/umbraco.editorControls.csproj index 77a315e39a..bb1e7587fb 100644 --- a/components/editorControls/umbraco.editorControls.csproj +++ b/components/editorControls/umbraco.editorControls.csproj @@ -167,6 +167,9 @@ SolutionInfo.cs + + + Code @@ -186,6 +189,7 @@ Code + Code @@ -311,6 +315,7 @@ Code + Code @@ -322,6 +327,7 @@ + @@ -398,6 +404,7 @@ + @@ -459,6 +466,7 @@ + diff --git a/umbraco/cms/businesslogic/datatype/AbstractJsonPrevalueEditor.cs b/umbraco/cms/businesslogic/datatype/AbstractJsonPrevalueEditor.cs deleted file mode 100644 index 72b91dcb5d..0000000000 --- a/umbraco/cms/businesslogic/datatype/AbstractJsonPrevalueEditor.cs +++ /dev/null @@ -1,107 +0,0 @@ -using System; -using System.Web.Script.Serialization; -using umbraco.BusinessLogic; -using umbraco.cms.businesslogic.datatype; - -namespace umbraco.cms.businesslogic.datatype -{ - /// - /// Abstract class for the PreValue Editor. - /// Specifically designed to serialize/deserialize the options as JSON. - /// - public abstract class AbstractJsonPrevalueEditor : AbstractPrevalueEditor - { - /// - /// The underlying base data-type. - /// - protected readonly BaseDataType m_DataType; - - /// - /// An object to temporarily lock writing to the database. - /// - private static readonly object m_Locker = new object(); - - /// - /// Initializes a new instance of the class. - /// - /// Type of the data. - public AbstractJsonPrevalueEditor(BaseDataType dataType) - { - this.m_DataType = dataType; - } - - /// - /// Initializes a new instance of the class. - /// - /// Type of the data. - /// Type of the database field. - public AbstractJsonPrevalueEditor(BaseDataType dataType, DBTypes dbType) - : base() - { - this.m_DataType = dataType; - this.m_DataType.DBType = dbType; - } - - /// - /// Gets the PreValue options for the data-type. - /// - /// The type of the resulting object. - /// - /// Returns the options for the PreValue Editor - /// - public T GetPreValueOptions() - { - var prevalues = PreValues.GetPreValues(this.m_DataType.DataTypeDefinitionId); - if (prevalues.Count > 0) - { - var prevalue = (PreValue)prevalues[0]; - if (!string.IsNullOrEmpty(prevalue.Value)) - { - try - { - // deserialize the options - var serializer = new JavaScriptSerializer(); - - // return the options - return serializer.Deserialize(prevalue.Value); - } - catch (Exception ex) - { - Log.Add(LogTypes.Error, this.m_DataType.DataTypeDefinitionId, string.Concat("uComponents: Execption thrown: ", ex.Message)); - } - } - } - - // if all else fails, return default options - return default(T); - } - - /// - /// Saves the data-type PreValue options. - /// - public void SaveAsJson(object options) - { - // serialize the options into JSON - var serializer = new JavaScriptSerializer(); - var json = serializer.Serialize(options); - - lock (m_Locker) - { - var prevalues = PreValues.GetPreValues(this.m_DataType.DataTypeDefinitionId); - if (prevalues.Count > 0) - { - PreValue prevalue = (PreValue)prevalues[0]; - - // update - prevalue.Value = json; - prevalue.Save(); - } - else - { - // insert - PreValue.MakeNew(this.m_DataType.DataTypeDefinitionId, json); - } - } - } - } -} \ No newline at end of file diff --git a/umbraco/cms/businesslogic/datatype/AbstractPrevalueEditor.cs b/umbraco/cms/businesslogic/datatype/AbstractPrevalueEditor.cs deleted file mode 100644 index cfe71cd5f1..0000000000 --- a/umbraco/cms/businesslogic/datatype/AbstractPrevalueEditor.cs +++ /dev/null @@ -1,77 +0,0 @@ -using System; -using System.Web.UI; -using System.Web.UI.WebControls; -using ClientDependency.Core; -using umbraco.interfaces; - -namespace umbraco.cms.businesslogic.datatype -{ - /// - /// Abstract class for the PreValue Editor. - /// - public abstract class AbstractPrevalueEditor : WebControl, IDataPrevalue - { - /// - /// Initializes a new instance of the class. - /// - public AbstractPrevalueEditor() - : base() - { - } - - /// - /// Gets the editor. - /// - /// The editor. - public virtual Control Editor - { - get - { - return this; - } - } - - /// - /// Saves this instance. - /// - public virtual void Save() - { - } - - /// - /// Raises the event. - /// - /// An object that contains the event data. - protected override void OnInit(EventArgs e) - { - base.OnInit(e); - this.EnsureChildControls(); - - // Adds the client dependencies. - this.AddResourceToClientDependency("uComponents.DataTypes.Shared.Resources.Styles.PrevalueEditor.css", ClientDependencyType.Css); - } - - /// - /// Renders the HTML opening tag 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. - public override void RenderBeginTag(HtmlTextWriter writer) - { - writer.AddAttribute(HtmlTextWriterAttribute.Class, "uComponents"); - writer.RenderBeginTag(HtmlTextWriterTag.Div); - - base.RenderBeginTag(writer); - } - - /// - /// Renders the HTML closing tag of the control into the specified writer. This method is used primarily by control developers. - /// - /// A that represents the output stream to render HTML content on the client. - public override void RenderEndTag(HtmlTextWriter writer) - { - base.RenderEndTag(writer); - - writer.RenderEndTag(); - } - } -} \ No newline at end of file diff --git a/umbraco/cms/businesslogic/datatype/PrevalueEditorExtensions.cs b/umbraco/cms/businesslogic/datatype/PrevalueEditorExtensions.cs deleted file mode 100644 index a704c3b5f6..0000000000 --- a/umbraco/cms/businesslogic/datatype/PrevalueEditorExtensions.cs +++ /dev/null @@ -1,105 +0,0 @@ -using System.Web.UI; -using System.Web.UI.HtmlControls; -using System.Web.UI.WebControls; - -namespace umbraco.cms.businesslogic.datatype -{ - /// - /// Extension methods for the Prevalue Editor - /// - public static class PrevalueEditorExtensions - { - /// - /// Adds the prevalue controls. - /// - /// The collection. - /// The controls. - public static void AddPrevalueControls(this ControlCollection collection, params Control[] controls) - { - foreach (var control in controls) - { - collection.Add(control); - } - } - - /// - /// Adds the prevalue row heading. - /// - /// The writer. - /// The heading. - public static void AddPrevalueHeading(this HtmlTextWriter writer, string heading) - { - writer.AddAttribute(HtmlTextWriterAttribute.Class, "row clearfix"); - writer.RenderBeginTag(HtmlTextWriterTag.Div); // start 'row' - - writer.RenderBeginTag(HtmlTextWriterTag.H3); // start 'h3' - - writer.Write(heading); - - writer.RenderEndTag(); // end 'h3' - - writer.RenderEndTag(); // end 'row' - } - - /// - /// Adds a new row to the Prevalue Editor. - /// - /// The HtmlTextWriter. - /// The label for the field. - /// The controls for the field. - public static void AddPrevalueRow(this HtmlTextWriter writer, string label, params Control[] controls) - { - writer.AddPrevalueRow(label, string.Empty, controls); - } - - /// - /// Adds a new row to the Prevalue Editor, (with an optional description). - /// - /// The HtmlTextWriter. - /// The label for the field. - /// The description for the field. - /// The controls for the field. - public static void AddPrevalueRow(this HtmlTextWriter writer, string label, string description, params Control[] controls) - { - writer.AddAttribute(HtmlTextWriterAttribute.Class, "row clearfix"); - writer.RenderBeginTag(HtmlTextWriterTag.Div); // start 'row' - - writer.AddAttribute(HtmlTextWriterAttribute.Class, "label"); - writer.RenderBeginTag(HtmlTextWriterTag.Div); // start 'label' - - var lbl = new HtmlGenericControl("label") { InnerText = label }; - - if (controls.Length > 0 && !string.IsNullOrEmpty(controls[0].ClientID)) - { - lbl.Attributes.Add("for", controls[0].ClientID); - } - - lbl.RenderControl(writer); - - writer.RenderEndTag(); // end 'label' - - writer.AddAttribute(HtmlTextWriterAttribute.Class, "field"); - writer.RenderBeginTag(HtmlTextWriterTag.Div); // start 'field' - - foreach (var control in controls) - { - control.RenderControl(writer); - } - - writer.RenderEndTag(); // end 'field' - - if (!string.IsNullOrEmpty(description)) - { - writer.AddAttribute(HtmlTextWriterAttribute.Class, "description"); - writer.RenderBeginTag(HtmlTextWriterTag.Div); // start 'description' - - Label desc = new Label() { Text = description }; - desc.RenderControl(writer); - - writer.RenderEndTag(); // end 'description' - } - - writer.RenderEndTag(); // end 'row' - } - } -} \ No newline at end of file diff --git a/umbraco/cms/umbraco.cms.csproj b/umbraco/cms/umbraco.cms.csproj index aa08616d8d..8582d789cd 100644 --- a/umbraco/cms/umbraco.cms.csproj +++ b/umbraco/cms/umbraco.cms.csproj @@ -200,11 +200,7 @@ - - - - @@ -212,9 +208,6 @@ - - -