using System; using System.Collections.Generic; using System.Linq; using System.Text; using umbraco.cms.businesslogic.datatype; using System.Web.UI.WebControls; namespace umbraco.editorControls.SettingControls.Pickers { public class Content : DataEditorSettingType { private ContentPickerWithXpathOption cc = new ContentPickerWithXpathOption(); private string _val = string.Empty; public override string Value { get { return cc.Value; } set { if (!string.IsNullOrEmpty(value)) _val = value; } } public override System.Web.UI.Control RenderControl(DataEditorSetting sender) { cc.ShowXPath = false; cc.ID = sender.GetName().Replace(" ", "_"); cc.Value = _val; return cc; } } public class ContentWithXpath : DataEditorSettingType { private ContentPickerWithXpathOption cc = new ContentPickerWithXpathOption(); private string _val = string.Empty; public override string Value { get { return cc.Value; } set { if (!string.IsNullOrEmpty(value)) _val = value; } } public override System.Web.UI.Control RenderControl(DataEditorSetting sender) { cc.ShowXPath = true; cc.ID = sender.GetName().Replace(" ", "_"); cc.Value = _val; return cc; } } public class ContentPickerWithXpathOption : WebControl { private bool _showXPath = true; public bool ShowXPath { get { return _showXPath; } set { _showXPath = value; } } private umbraco.controls.ContentPicker cc; private TextBox tb; public ContentPickerWithXpathOption() { EnsureChildControls(); } protected override void OnInit(EventArgs e) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "contentpickerxpath", @" function showXpathTextbox(control) { $('.picker',$('#' + control)).hide(); $('.xpath',$('#' + control)).show(); } function showContentPicker(control) { $('.xpath',$('#' + control)).hide(); $('.xpath input',$('#' + control)).val(''); $('.picker',$('#' + control)).show(); } ", true); base.OnInit(e); } protected override void CreateChildControls() { cc = new umbraco.controls.ContentPicker(); this.Controls.Add(cc); if (_showXPath) { tb = new TextBox(); tb.CssClass = "guiInputText guiInputStandardSize"; this.Controls.Add(tb); } } protected override void RenderChildren(System.Web.UI.HtmlTextWriter writer) { writer.Write(string.Format("