@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using umbraco.cms.businesslogic.datatype;
|
||||
|
||||
namespace umbraco.editorControls.SettingControls.Pickers
|
||||
{
|
||||
public class BasePicker: DataEditorSettingType
|
||||
{
|
||||
public Guid ObjectGuid { get; set; }
|
||||
|
||||
private System.Web.UI.WebControls.DropDownList ddl = new System.Web.UI.WebControls.DropDownList();
|
||||
|
||||
private string _val = string.Empty;
|
||||
|
||||
public override string Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return ddl.SelectedValue;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
_val = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override System.Web.UI.Control RenderControl(DataEditorSetting sender)
|
||||
{
|
||||
|
||||
ddl.ID = sender.GetName();
|
||||
|
||||
ddl.Items.Clear();
|
||||
List<KeyValuePair<String, String>> items = new List<KeyValuePair<String, String>>();
|
||||
|
||||
if (ObjectGuid != Guid.Empty)
|
||||
{
|
||||
Guid[] guids = umbraco.cms.businesslogic.CMSNode.getAllUniquesFromObjectType(ObjectGuid);
|
||||
foreach (Guid g in guids)
|
||||
{
|
||||
umbraco.cms.businesslogic.CMSNode node = new umbraco.cms.businesslogic.CMSNode(g);
|
||||
items.Add(new KeyValuePair<string, string>(node.Id.ToString(), node.Text));
|
||||
}
|
||||
}
|
||||
|
||||
items.Sort(delegate(KeyValuePair<String, String> x, KeyValuePair<String, String> y) { return x.Value.CompareTo(y.Value); });
|
||||
|
||||
foreach (KeyValuePair<String, String> kv in items)
|
||||
{
|
||||
ddl.Items.Add(new System.Web.UI.WebControls.ListItem(kv.Value, kv.Key));
|
||||
}
|
||||
|
||||
System.Web.UI.WebControls.ListItem li = new System.Web.UI.WebControls.ListItem("Choose...", "");
|
||||
li.Selected = true;
|
||||
ddl.Items.Insert(0, li);
|
||||
|
||||
|
||||
|
||||
ddl.SelectedValue = _val;
|
||||
|
||||
return ddl;
|
||||
}
|
||||
}
|
||||
}
|
||||
180
components/editorControls/SettingControls/Pickers/Content.cs
Normal file
180
components/editorControls/SettingControls/Pickers/Content.cs
Normal file
@@ -0,0 +1,180 @@
|
||||
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("<div class=\"picker\"{0}>", tb.Text != string.Empty ? " style=\"display:none\"" : ""));
|
||||
cc.RenderControl(writer);
|
||||
|
||||
if (_showXPath)
|
||||
{
|
||||
writer.Write(string.Format(
|
||||
" <a href=\"javascript:showXpathTextbox('{0}');\">Or enter Xpath</a>",
|
||||
this.ClientID));
|
||||
|
||||
writer.Write("</div>");
|
||||
|
||||
writer.Write(string.Format("<div class=\"xpath\"{0}>", !(tb.Text != string.Empty) ? " style=\"display:none\"" : ""));
|
||||
tb.RenderControl(writer);
|
||||
|
||||
writer.Write(string.Format(
|
||||
" <a href=\"javascript:showContentPicker('{0}');\">Or pick node</a>",
|
||||
this.ClientID));
|
||||
}
|
||||
|
||||
writer.Write("</div>");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private string _val = string.Empty;
|
||||
public string Value
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
if (_showXPath && tb.Text != string.Empty)
|
||||
return tb.Text;
|
||||
else
|
||||
return cc.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
_val = value;
|
||||
|
||||
int nodeId;
|
||||
|
||||
if (int.TryParse(_val, out nodeId))
|
||||
cc.Text = _val;
|
||||
else if (ShowXPath)
|
||||
tb.Text = _val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
42
components/editorControls/SettingControls/Pickers/Date.cs
Normal file
42
components/editorControls/SettingControls/Pickers/Date.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using umbraco.uicontrols.DatePicker;
|
||||
using umbraco.cms.businesslogic.datatype;
|
||||
|
||||
namespace umbraco.editorControls.SettingControls.Pickers
|
||||
{
|
||||
public class Date: DataEditorSettingType
|
||||
{
|
||||
private DateTimePicker dp = new DateTimePicker();
|
||||
|
||||
private string _val = string.Empty;
|
||||
public override string Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return dp.DateTime.ToString();
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
_val = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override System.Web.UI.Control RenderControl(DataEditorSetting sender)
|
||||
{
|
||||
|
||||
dp.ShowTime = false;
|
||||
|
||||
dp.ID = sender.GetName().Replace(" ", "_");
|
||||
|
||||
if(!string.IsNullOrEmpty(_val))
|
||||
dp.DateTime = Convert.ToDateTime(_val);
|
||||
|
||||
return dp;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using umbraco.uicontrols.DatePicker;
|
||||
using umbraco.cms.businesslogic.datatype;
|
||||
|
||||
namespace umbraco.editorControls.SettingControls.Pickers
|
||||
{
|
||||
public class DateWithTime : DataEditorSettingType
|
||||
{
|
||||
private DateTimePicker dp = new DateTimePicker();
|
||||
|
||||
private string _val = string.Empty;
|
||||
public override string Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return dp.DateTime.ToString();
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
_val = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override System.Web.UI.Control RenderControl(DataEditorSetting sender)
|
||||
{
|
||||
|
||||
dp.ShowTime = true;
|
||||
|
||||
dp.ID = sender.GetName().Replace(" ", "_");
|
||||
|
||||
if (!string.IsNullOrEmpty(_val))
|
||||
dp.DateTime = Convert.ToDateTime(_val);
|
||||
|
||||
return dp;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace umbraco.editorControls.SettingControls.Pickers
|
||||
{
|
||||
|
||||
public class DocumentType: BasePicker {
|
||||
public DocumentType() {
|
||||
ObjectGuid = new Guid("a2cb7800-f571-4787-9638-bc48539a0efb");
|
||||
}
|
||||
}
|
||||
}
|
||||
63
components/editorControls/SettingControls/Pickers/Field.cs
Normal file
63
components/editorControls/SettingControls/Pickers/Field.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using umbraco.DataLayer;
|
||||
using umbraco.cms.businesslogic.datatype;
|
||||
|
||||
namespace umbraco.editorControls.SettingControls.Pickers
|
||||
{
|
||||
public class Field : DataEditorSettingType
|
||||
{
|
||||
private System.Web.UI.WebControls.DropDownList ddl = new System.Web.UI.WebControls.DropDownList();
|
||||
|
||||
private string _val = string.Empty;
|
||||
|
||||
public override string Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return ddl.SelectedValue;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
_val = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override System.Web.UI.Control RenderControl(DataEditorSetting sender)
|
||||
{
|
||||
|
||||
ddl.ID = sender.GetName();
|
||||
|
||||
ddl.Items.Clear();
|
||||
List<KeyValuePair<String, String>> items = new List<KeyValuePair<String, String>>();
|
||||
|
||||
|
||||
string[] preValuesSource = { "@createDate", "@creatorName", "@level", "@nodeType", "@nodeTypeAlias", "@pageID", "@pageName", "@parentID", "@path", "@template", "@updateDate", "@writerID", "@writerName" };
|
||||
|
||||
string fieldSql = "select distinct alias from cmsPropertyType order by alias";
|
||||
|
||||
IRecordsReader dataTypes = umbraco.BusinessLogic.Application.SqlHelper.ExecuteReader(fieldSql);
|
||||
ddl.DataTextField = "alias";
|
||||
ddl.DataValueField = "alias";
|
||||
ddl.DataSource = dataTypes;
|
||||
ddl.DataBind();
|
||||
|
||||
foreach (string s in preValuesSource)
|
||||
{
|
||||
ddl.Items.Add(new System.Web.UI.WebControls.ListItem(s, s.Replace("@", "")));
|
||||
}
|
||||
|
||||
|
||||
System.Web.UI.WebControls.ListItem li = new System.Web.UI.WebControls.ListItem("Choose...", "");
|
||||
li.Selected = true;
|
||||
ddl.Items.Insert(0, li);
|
||||
|
||||
ddl.SelectedValue = _val;
|
||||
|
||||
return ddl;
|
||||
}
|
||||
}
|
||||
}
|
||||
49
components/editorControls/SettingControls/Pickers/Media.cs
Normal file
49
components/editorControls/SettingControls/Pickers/Media.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using umbraco.cms.businesslogic.datatype;
|
||||
|
||||
namespace umbraco.editorControls.SettingControls.Pickers
|
||||
{
|
||||
public class Media : DataEditorSettingType
|
||||
{
|
||||
|
||||
private umbraco.controls.ContentPicker mp = new umbraco.controls.ContentPicker();
|
||||
|
||||
private string _val = string.Empty;
|
||||
public override string Value
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
return mp.Value;
|
||||
}
|
||||
set
|
||||
{
|
||||
int output;
|
||||
if (!string.IsNullOrEmpty(value) && int.TryParse(value, out output))
|
||||
_val = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override System.Web.UI.Control RenderControl(DataEditorSetting sender)
|
||||
{
|
||||
|
||||
mp.ID = sender.GetName().Replace(" ", "_");
|
||||
|
||||
mp.AppAlias = "media";
|
||||
mp.TreeAlias = "media";
|
||||
|
||||
int output;
|
||||
if (!string.IsNullOrEmpty(_val) && int.TryParse(_val, out output))
|
||||
{
|
||||
mp.Value = _val;
|
||||
|
||||
}
|
||||
return mp;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace umbraco.editorControls.SettingControls.Pickers
|
||||
{
|
||||
public class MediaType : BasePicker
|
||||
{
|
||||
public MediaType()
|
||||
{
|
||||
ObjectGuid = new Guid("4ea4382b-2f5a-4c2b-9587-ae9b3cf3602e");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace umbraco.editorControls.SettingControls.Pickers
|
||||
{
|
||||
public class MemberGroup : BasePicker
|
||||
{
|
||||
public MemberGroup()
|
||||
{
|
||||
ObjectGuid = new Guid("366e63b9-880f-4e13-a61c-98069b029728");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
|
||||
namespace umbraco.editorControls.SettingControls.Pickers
|
||||
{
|
||||
public class MemberType : BasePicker
|
||||
{
|
||||
public MemberType()
|
||||
{
|
||||
ObjectGuid = new Guid("9b5416fb-e72f-45a9-a07b-5a9a2709ce43");
|
||||
}
|
||||
}
|
||||
}
|
||||
88
components/editorControls/SettingControls/Pickers/Path.cs
Normal file
88
components/editorControls/SettingControls/Pickers/Path.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using umbraco.cms.businesslogic.datatype;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
|
||||
namespace umbraco.editorControls.SettingControls.Pickers
|
||||
{
|
||||
public class Path : DataEditorSettingType
|
||||
{
|
||||
private PathPicker pp = new PathPicker();
|
||||
|
||||
private string _val = string.Empty;
|
||||
public override string Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return pp.Value;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
_val = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override System.Web.UI.Control RenderControl(DataEditorSetting sender)
|
||||
{
|
||||
|
||||
|
||||
pp.ID = sender.GetName().Replace(" ", "_");
|
||||
|
||||
pp.Value = _val;
|
||||
return pp;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class PathPicker : WebControl
|
||||
{
|
||||
private TextBox tb;
|
||||
|
||||
public PathPicker()
|
||||
{
|
||||
EnsureChildControls();
|
||||
}
|
||||
|
||||
protected override void CreateChildControls()
|
||||
{
|
||||
|
||||
tb = new TextBox();
|
||||
tb.CssClass = "guiInputText guiInputStandardSize";
|
||||
tb.ID = this.ID + "input";
|
||||
this.Controls.Add(tb);
|
||||
|
||||
}
|
||||
|
||||
protected override void Render(System.Web.UI.HtmlTextWriter writer)
|
||||
{
|
||||
tb.RenderControl(writer);
|
||||
|
||||
writer.WriteLine(string.Format(" <a onclick=\"{0}\"href=\"javascript:void(0);\">Select</a>",
|
||||
string.Format("javascript:UmbClientMgr.openModalWindow('developer/packages/directoryBrowser.aspx?target={0}', 'Choose a file or a folder', true, 400, 500, 0, 0); return false;", tb.ClientID)));
|
||||
|
||||
}
|
||||
|
||||
private string _val = string.Empty;
|
||||
public string Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return tb.Text;
|
||||
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
{
|
||||
_val = value;
|
||||
tb.Text = _val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user