32
components/editorControls/SettingControls/CheckBox.cs
Normal file
32
components/editorControls/SettingControls/CheckBox.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using umbraco.cms.businesslogic.datatype;
|
||||
|
||||
namespace umbraco.editorControls.SettingControls
|
||||
{
|
||||
public class CheckBox: DataEditorSettingType
|
||||
{
|
||||
private System.Web.UI.WebControls.CheckBox cb = new System.Web.UI.WebControls.CheckBox();
|
||||
|
||||
public override string Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return cb.Checked.ToString();
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == true.ToString())
|
||||
cb.Checked = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override System.Web.UI.Control RenderControl(DataEditorSetting sender)
|
||||
{
|
||||
cb.ID = sender.GetName();
|
||||
return cb;
|
||||
}
|
||||
}
|
||||
}
|
||||
59
components/editorControls/SettingControls/CheckBoxList.cs
Normal file
59
components/editorControls/SettingControls/CheckBoxList.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using umbraco.cms.businesslogic.datatype;
|
||||
|
||||
namespace umbraco.editorControls.SettingControls
|
||||
{
|
||||
public class CheckBoxList : DataEditorSettingType
|
||||
{
|
||||
private System.Web.UI.WebControls.CheckBoxList cbl = new System.Web.UI.WebControls.CheckBoxList();
|
||||
|
||||
private string _val = string.Empty;
|
||||
public override string Value
|
||||
{
|
||||
get
|
||||
{
|
||||
string retVal = string.Empty;
|
||||
|
||||
foreach (System.Web.UI.WebControls.ListItem item in cbl.Items)
|
||||
{
|
||||
if (item.Selected)
|
||||
retVal += item.Value + ";";
|
||||
}
|
||||
return retVal;
|
||||
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
_val = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override System.Web.UI.Control RenderControl(DataEditorSetting sender)
|
||||
{
|
||||
cbl.ID = sender.GetName();
|
||||
|
||||
cbl.Items.Clear();
|
||||
|
||||
foreach (string s in Prevalues)
|
||||
{
|
||||
System.Web.UI.WebControls.ListItem item = new System.Web.UI.WebControls.ListItem(s);
|
||||
|
||||
if(_val.Contains(s + ";"))
|
||||
item.Selected = true;
|
||||
|
||||
cbl.Items.Add(item);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return cbl;
|
||||
}
|
||||
}
|
||||
}
|
||||
43
components/editorControls/SettingControls/DropDownList.cs
Normal file
43
components/editorControls/SettingControls/DropDownList.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using umbraco.cms.businesslogic.datatype;
|
||||
|
||||
namespace umbraco.editorControls.SettingControls
|
||||
{
|
||||
public class DropDownList: 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();
|
||||
|
||||
foreach (string s in Prevalues)
|
||||
{
|
||||
ddl.Items.Add(s);
|
||||
}
|
||||
|
||||
ddl.SelectedValue = _val;
|
||||
|
||||
return ddl;
|
||||
}
|
||||
}
|
||||
}
|
||||
45
components/editorControls/SettingControls/ListBox.cs
Normal file
45
components/editorControls/SettingControls/ListBox.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using umbraco.cms.businesslogic.datatype;
|
||||
|
||||
namespace umbraco.editorControls.SettingControls
|
||||
{
|
||||
public class ListBox : DataEditorSettingType
|
||||
{
|
||||
private System.Web.UI.WebControls.ListBox lb = new System.Web.UI.WebControls.ListBox();
|
||||
|
||||
private string _val = string.Empty;
|
||||
public override string Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return lb.SelectedValue;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
_val = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override System.Web.UI.Control RenderControl(DataEditorSetting sender)
|
||||
{
|
||||
lb.ID = sender.GetName();
|
||||
|
||||
lb.CssClass = "guiInputStandardSize";
|
||||
|
||||
lb.Items.Clear();
|
||||
|
||||
foreach (string s in Prevalues)
|
||||
{
|
||||
lb.Items.Add(s);
|
||||
}
|
||||
|
||||
lb.SelectedValue = _val;
|
||||
|
||||
return lb;
|
||||
}
|
||||
}
|
||||
}
|
||||
60
components/editorControls/SettingControls/ListBoxMultiple.cs
Normal file
60
components/editorControls/SettingControls/ListBoxMultiple.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using umbraco.cms.businesslogic.datatype;
|
||||
|
||||
namespace umbraco.editorControls.SettingControls
|
||||
{
|
||||
public class ListBoxMultiple : DataEditorSettingType
|
||||
{
|
||||
private System.Web.UI.WebControls.ListBox lb = new System.Web.UI.WebControls.ListBox();
|
||||
|
||||
private string _val = string.Empty;
|
||||
public override string Value
|
||||
{
|
||||
get
|
||||
{
|
||||
string retVal = string.Empty;
|
||||
|
||||
foreach (System.Web.UI.WebControls.ListItem item in lb.Items)
|
||||
{
|
||||
if (item.Selected)
|
||||
retVal += item.Value + ";";
|
||||
}
|
||||
return retVal;
|
||||
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
_val = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override System.Web.UI.Control RenderControl(DataEditorSetting sender)
|
||||
{
|
||||
lb.ID = sender.GetName();
|
||||
lb.SelectionMode = System.Web.UI.WebControls.ListSelectionMode.Multiple;
|
||||
lb.CssClass = "guiInputStandardSize";
|
||||
lb.Items.Clear();
|
||||
|
||||
foreach (string s in Prevalues)
|
||||
{
|
||||
System.Web.UI.WebControls.ListItem item = new System.Web.UI.WebControls.ListItem(s);
|
||||
|
||||
if (_val.Contains(s + ";"))
|
||||
item.Selected = true;
|
||||
|
||||
lb.Items.Add(item);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
return lb;
|
||||
}
|
||||
}
|
||||
}
|
||||
37
components/editorControls/SettingControls/Password.cs
Normal file
37
components/editorControls/SettingControls/Password.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI.WebControls;
|
||||
using umbraco.cms.businesslogic.datatype;
|
||||
|
||||
namespace umbraco.editorControls.SettingControls
|
||||
{
|
||||
public class Password : DataEditorSettingType
|
||||
{
|
||||
private TextBox tb = new TextBox();
|
||||
|
||||
public override string Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return tb.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
tb.Text = value;
|
||||
tb.Attributes["value"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public override System.Web.UI.Control RenderControl(DataEditorSetting sender)
|
||||
{
|
||||
tb.ID = sender.GetName();
|
||||
|
||||
tb.TextMode = TextBoxMode.Password;
|
||||
tb.CssClass = "guiInputText guiInputStandardSize";
|
||||
return tb;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
43
components/editorControls/SettingControls/RadioButtonList.cs
Normal file
43
components/editorControls/SettingControls/RadioButtonList.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using umbraco.cms.businesslogic.datatype;
|
||||
|
||||
namespace umbraco.editorControls.SettingControls
|
||||
{
|
||||
public class RadioButtonList: DataEditorSettingType
|
||||
{
|
||||
private System.Web.UI.WebControls.RadioButtonList rbl = new System.Web.UI.WebControls.RadioButtonList();
|
||||
|
||||
private string _val = string.Empty;
|
||||
public override string Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return rbl.SelectedValue;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
_val = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override System.Web.UI.Control RenderControl(DataEditorSetting sender)
|
||||
{
|
||||
rbl.ID = sender.GetName();
|
||||
|
||||
rbl.Items.Clear();
|
||||
|
||||
foreach (string s in Prevalues)
|
||||
{
|
||||
rbl.Items.Add(s);
|
||||
}
|
||||
|
||||
rbl.SelectedValue = _val;
|
||||
|
||||
return rbl;
|
||||
}
|
||||
}
|
||||
}
|
||||
39
components/editorControls/SettingControls/TextArea.cs
Normal file
39
components/editorControls/SettingControls/TextArea.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI.WebControls;
|
||||
using umbraco.cms.businesslogic.datatype;
|
||||
|
||||
namespace umbraco.editorControls.SettingControls
|
||||
{
|
||||
public class TextArea : DataEditorSettingType
|
||||
{
|
||||
private TextBox tb = new TextBox();
|
||||
|
||||
public override string Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return tb.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
tb.Text = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override System.Web.UI.Control RenderControl(DataEditorSetting sender)
|
||||
{
|
||||
tb.ID = sender.GetName();
|
||||
tb.TextMode = TextBoxMode.MultiLine;
|
||||
tb.CssClass = "guiInputText guiInputStandardSize";
|
||||
tb.Rows = 7;
|
||||
|
||||
if (string.IsNullOrEmpty(tb.Text) && this.Prevalues.Count > 0)
|
||||
tb.Text = this.Prevalues[0];
|
||||
|
||||
return tb;
|
||||
}
|
||||
}
|
||||
}
|
||||
39
components/editorControls/SettingControls/TextField.cs
Normal file
39
components/editorControls/SettingControls/TextField.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
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
|
||||
{
|
||||
public class TextField : DataEditorSettingType
|
||||
{
|
||||
private TextBox tb = new TextBox();
|
||||
|
||||
public override string Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return tb.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
tb.Text = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override System.Web.UI.Control RenderControl(DataEditorSetting sender)
|
||||
{
|
||||
tb.ID = sender.GetName();
|
||||
tb.TextMode = TextBoxMode.SingleLine;
|
||||
tb.CssClass = "guiInputText guiInputStandardSize";
|
||||
|
||||
|
||||
if (string.IsNullOrEmpty(tb.Text) && Prevalues.Count > 0)
|
||||
tb.Text = Prevalues[0];
|
||||
|
||||
return tb;
|
||||
}
|
||||
}
|
||||
}
|
||||
73
components/editorControls/SettingControls/Values.cs
Normal file
73
components/editorControls/SettingControls/Values.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.Web.UI.HtmlControls;
|
||||
using umbraco.cms.businesslogic.datatype;
|
||||
|
||||
[assembly: System.Web.UI.WebResource("umbraco.editorControls.SettingControls.js.Values.js", "text/js")]
|
||||
[assembly: System.Web.UI.WebResource("umbraco.editorControls.SettingControls.css.Values.css", "text/css")]
|
||||
namespace umbraco.editorControls.SettingControls
|
||||
{
|
||||
|
||||
public class Values : DataEditorSettingType
|
||||
{
|
||||
|
||||
private Panel p = new Panel();
|
||||
private TextBox tb = new TextBox();
|
||||
|
||||
|
||||
public override string Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return tb.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
tb.Text = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override System.Web.UI.Control RenderControl(DataEditorSetting sender)
|
||||
{
|
||||
tb.ID = sender.GetName();
|
||||
tb.CssClass = "valuesInput";
|
||||
tb.Attributes.Add("style", "display:none;");
|
||||
|
||||
|
||||
string html = "<div class='values'>";
|
||||
|
||||
html += "</div>";
|
||||
|
||||
html += "<input type='text' class='valueInput' />";
|
||||
html += " <a onclick=\"valuesDataEditorSettingTypeAddValue(this); return false;\" href='#' class='Add'>Add Value</a>";
|
||||
|
||||
|
||||
p.Controls.Add(new System.Web.UI.LiteralControl("<div class='valuesDataEditorSettingType'>"));
|
||||
p.Controls.Add(new System.Web.UI.LiteralControl(html));
|
||||
p.Controls.Add(tb);
|
||||
p.Controls.Add(new System.Web.UI.LiteralControl("</div>"));
|
||||
|
||||
|
||||
System.Web.UI.Page page = (System.Web.UI.Page)HttpContext.Current.Handler;
|
||||
|
||||
|
||||
page.ClientScript.RegisterClientScriptInclude(
|
||||
"umbraco.editorControls.SettingControls.js.Values.js",
|
||||
page.ClientScript.GetWebResourceUrl(typeof(Values), "umbraco.editorControls.SettingControls.js.Values.js"));
|
||||
|
||||
|
||||
HtmlHead head = (HtmlHead)page.Header;
|
||||
HtmlLink link = new HtmlLink();
|
||||
link.Attributes.Add("href", page.ClientScript.GetWebResourceUrl(typeof(Values), "umbraco.editorControls.SettingControls.css.Values.css"));
|
||||
link.Attributes.Add("type", "text/css");
|
||||
link.Attributes.Add("rel", "stylesheet");
|
||||
head.Controls.Add(link);
|
||||
|
||||
|
||||
return p;
|
||||
}
|
||||
}
|
||||
}
|
||||
15
components/editorControls/SettingControls/css/Values.css
Normal file
15
components/editorControls/SettingControls/css/Values.css
Normal file
@@ -0,0 +1,15 @@
|
||||
.valuesDataEditorSettingType .value
|
||||
{
|
||||
padding-bottom:5px;
|
||||
}
|
||||
|
||||
.valuesDataEditorSettingType .value .del
|
||||
{
|
||||
color:Red;
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
.valuesDataEditorSettingType .value .handle
|
||||
{
|
||||
cursor:move;
|
||||
}
|
||||
183
components/editorControls/SettingControls/js/Values.js
Normal file
183
components/editorControls/SettingControls/js/Values.js
Normal file
@@ -0,0 +1,183 @@
|
||||
jQuery(document).ready(function () {
|
||||
|
||||
|
||||
|
||||
jQuery(".valuesDataEditorSettingType").each(function () {
|
||||
|
||||
var vals = jQuery(".valuesInput", this).val();
|
||||
|
||||
var values = jQuery(".values", this);
|
||||
|
||||
var vals_array = vals.split(";");
|
||||
var part_num = 0;
|
||||
while (part_num < vals_array.length) {
|
||||
|
||||
if (vals_array[part_num] != "") {
|
||||
var existingValue = "<div class='value'><span>" + vals_array[part_num] + "</span> <a class='del'>Delete</a> <a class='handle'>Drag</a></div>";
|
||||
|
||||
values.append(existingValue);
|
||||
}
|
||||
part_num++;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
jQuery(".valuesDataEditorSettingType .value .del").click(function () {
|
||||
jQuery(this).parent().remove();
|
||||
valuesDataEditorSettingTypeResetValues();
|
||||
});
|
||||
|
||||
|
||||
jQuery(".valuesDataEditorSettingType .value span").valuesInlineEdit();
|
||||
|
||||
|
||||
jQuery(".valuesDataEditorSettingType .values").sortable({
|
||||
handle : '.handle',
|
||||
update : function () {
|
||||
|
||||
valuesDataEditorSettingTypeResetValues();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function valuesDataEditorSettingTypeAddValue(sender) {
|
||||
|
||||
|
||||
var valuesDataEditorSettingType = jQuery(sender).parent();
|
||||
|
||||
var value = jQuery(".valueInput", valuesDataEditorSettingType).val();
|
||||
|
||||
if (value != "") {
|
||||
|
||||
var values = jQuery(".values", valuesDataEditorSettingType);
|
||||
|
||||
var newValue = "<div class='value'><span>" + value + "</span> <a class='del'>Delete</a> <a class='handle'>Drag</a></div>";
|
||||
|
||||
values.append(newValue);
|
||||
|
||||
jQuery(".valuesDataEditorSettingType .value span").valuesInlineEdit();
|
||||
|
||||
jQuery(".valueInput", valuesDataEditorSettingType).val("");
|
||||
|
||||
|
||||
valuesDataEditorSettingTypeSetValues(values, jQuery(".valuesInput", valuesDataEditorSettingType));
|
||||
}
|
||||
|
||||
|
||||
jQuery(".valuesDataEditorSettingType .value .del").click(function () {
|
||||
jQuery(this).parent().remove();
|
||||
valuesDataEditorSettingTypeResetValues();
|
||||
});
|
||||
|
||||
jQuery(".valuesDataEditorSettingType .values").sortable({
|
||||
handle : '.handle',
|
||||
update : function () {
|
||||
|
||||
valuesDataEditorSettingTypeResetValues();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function valuesDataEditorSettingTypeSetValues(valuesContainer,valuesInput) {
|
||||
|
||||
var vals = "";
|
||||
jQuery(".value", valuesContainer).each(function () {
|
||||
|
||||
vals += jQuery("span",this).html() + ";";
|
||||
});
|
||||
|
||||
valuesInput.val(vals);
|
||||
}
|
||||
|
||||
function valuesDataEditorSettingTypeResetValues() {
|
||||
jQuery(".valuesDataEditorSettingType").each(function () {
|
||||
|
||||
valuesDataEditorSettingTypeSetValues(jQuery(".values", this), jQuery(".valuesInput", this));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
(function ($) {
|
||||
|
||||
$.fn.valuesInlineEdit = function (options) {
|
||||
|
||||
options = $.extend({
|
||||
hover: 'hover',
|
||||
value: '',
|
||||
save: '',
|
||||
placeholder: 'Click to edit'
|
||||
}, options);
|
||||
|
||||
return $.each(this, function () {
|
||||
$.valuesInlineEdit(this, options);
|
||||
});
|
||||
}
|
||||
|
||||
$.valuesInlineEdit = function (obj, options) {
|
||||
|
||||
var self = $(obj),
|
||||
placeholderHtml = '<span class="inlineEdit-placeholder">' + options.placeholder + '</span>';
|
||||
|
||||
self.value = function (newValue) {
|
||||
if (arguments.length) {
|
||||
self.data('value', $(newValue).hasClass('inlineEdit-placeholder') ? '' : newValue);
|
||||
}
|
||||
return self.data('value');
|
||||
}
|
||||
|
||||
self.value($.trim(self.text()) || options.value);
|
||||
|
||||
self.bind('click', function (event) {
|
||||
var $this = $(event.target);
|
||||
|
||||
if ($this.is(self[0].tagName) || $this.hasClass('inlineEdit-placeholder')) {
|
||||
self
|
||||
.html('<input type="text" value="' + self.value() + '">')
|
||||
.find('input')
|
||||
.bind('blur', function () {
|
||||
if ($this.children('input').val().length > 0) {
|
||||
|
||||
try {
|
||||
self.value($this.children('input').val());
|
||||
|
||||
|
||||
|
||||
} catch (err) { }
|
||||
|
||||
|
||||
}
|
||||
else {
|
||||
self.value('Click to edit');
|
||||
}
|
||||
if (self.timer) {
|
||||
window.clearTimeout(self.timer);
|
||||
}
|
||||
self.timer = window.setTimeout(function () {
|
||||
self.html(self.value() || placeholderHtml);
|
||||
self.removeClass(options.hover);
|
||||
valuesDataEditorSettingTypeResetValues();
|
||||
}, 200);
|
||||
})
|
||||
.focus();
|
||||
}
|
||||
})
|
||||
.hover(
|
||||
function () {
|
||||
$(this).addClass(options.hover);
|
||||
},
|
||||
function () {
|
||||
$(this).removeClass(options.hover);
|
||||
}
|
||||
);
|
||||
|
||||
if (!self.value()) {
|
||||
self.html($(placeholderHtml));
|
||||
}
|
||||
}
|
||||
|
||||
})(jQuery);
|
||||
@@ -299,6 +299,27 @@
|
||||
<Compile Include="relatedlinks\RelatedLinksDataEditor.cs" />
|
||||
<Compile Include="relatedlinks\RelatedLinksDataType.cs" />
|
||||
<Compile Include="relatedlinks\RelatedLinksPrevalueEditor.cs" />
|
||||
<Compile Include="SettingControls\CheckBox.cs" />
|
||||
<Compile Include="SettingControls\CheckBoxList.cs" />
|
||||
<Compile Include="SettingControls\DropDownList.cs" />
|
||||
<Compile Include="SettingControls\ListBox.cs" />
|
||||
<Compile Include="SettingControls\ListBoxMultiple.cs" />
|
||||
<Compile Include="SettingControls\Password.cs" />
|
||||
<Compile Include="SettingControls\Pickers\BasePicker.cs" />
|
||||
<Compile Include="SettingControls\Pickers\Content.cs" />
|
||||
<Compile Include="SettingControls\Pickers\Date.cs" />
|
||||
<Compile Include="SettingControls\Pickers\DateWithTime.cs" />
|
||||
<Compile Include="SettingControls\Pickers\DocumentType.cs" />
|
||||
<Compile Include="SettingControls\Pickers\Field.cs" />
|
||||
<Compile Include="SettingControls\Pickers\Media.cs" />
|
||||
<Compile Include="SettingControls\Pickers\MediaType.cs" />
|
||||
<Compile Include="SettingControls\Pickers\MemberGroup.cs" />
|
||||
<Compile Include="SettingControls\Pickers\MemberType.cs" />
|
||||
<Compile Include="SettingControls\Pickers\Path.cs" />
|
||||
<Compile Include="SettingControls\RadioButtonList.cs" />
|
||||
<Compile Include="SettingControls\TextArea.cs" />
|
||||
<Compile Include="SettingControls\TextField.cs" />
|
||||
<Compile Include="SettingControls\Values.cs" />
|
||||
<Compile Include="simpleEditor\simpleEditor.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
@@ -396,7 +417,10 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="mediapicker\MediaPicker.js" />
|
||||
<EmbeddedResource Include="SettingControls\css\Values.css" />
|
||||
<EmbeddedResource Include="SettingControls\js\Values.js" />
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<PropertyGroup>
|
||||
<PreBuildEvent>
|
||||
|
||||
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace umbraco.cms.businesslogic.skinning
|
||||
namespace umbraco.cms.businesslogic
|
||||
{
|
||||
public abstract class ProviderBase
|
||||
{
|
||||
@@ -3,6 +3,7 @@ using System.Data;
|
||||
|
||||
using umbraco.DataLayer;
|
||||
using umbraco.BusinessLogic;
|
||||
using System.Collections.Generic;
|
||||
|
||||
|
||||
namespace umbraco.cms.businesslogic.datatype
|
||||
@@ -113,5 +114,52 @@ namespace umbraco.cms.businesslogic.datatype
|
||||
return "dataNvarchar";
|
||||
}
|
||||
}
|
||||
|
||||
internal bool HasSettings()
|
||||
{
|
||||
bool hasSettings = false;
|
||||
foreach (System.Reflection.PropertyInfo p in this.GetType().GetProperties())
|
||||
{
|
||||
object[] o = p.GetCustomAttributes(typeof(DataEditorSetting), true);
|
||||
|
||||
if (o.Length > 0)
|
||||
{
|
||||
hasSettings = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return hasSettings;
|
||||
}
|
||||
|
||||
internal Dictionary<string, DataEditorSetting> Settings()
|
||||
{
|
||||
Dictionary<string, DataEditorSetting> s = new Dictionary<string, DataEditorSetting>();
|
||||
|
||||
foreach (System.Reflection.PropertyInfo p in this.GetType().GetProperties())
|
||||
{
|
||||
|
||||
object[] o = p.GetCustomAttributes(typeof(DataEditorSetting), true);
|
||||
|
||||
if (o.Length > 0)
|
||||
s.Add(p.Name, (DataEditorSetting)o[0]);
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
internal void LoadSettings(List<Setting<string, string>> settings)
|
||||
{
|
||||
foreach (Setting<string, string> setting in settings)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.GetType().InvokeMember(setting.Key, System.Reflection.BindingFlags.SetProperty, null, this, new object[] { setting.Value });
|
||||
|
||||
}
|
||||
catch (MissingMethodException ex) { }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
51
umbraco/cms/businesslogic/datatype/DataEditorSetting.cs
Normal file
51
umbraco/cms/businesslogic/datatype/DataEditorSetting.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Reflection;
|
||||
|
||||
namespace umbraco.cms.businesslogic.datatype
|
||||
{
|
||||
[System.AttributeUsage(System.AttributeTargets.Property, AllowMultiple = false)]
|
||||
public class DataEditorSetting: System.Attribute
|
||||
{
|
||||
string name;
|
||||
public string description;
|
||||
public string control;
|
||||
public string assembly;
|
||||
public string prevalues;
|
||||
|
||||
public DataEditorSetting(string name)
|
||||
{
|
||||
this.name = name;
|
||||
description = "";
|
||||
control = "umbraco.editorControls.SettingControls.TextField";
|
||||
assembly = "umbraco.editorControls";
|
||||
prevalues = "";
|
||||
}
|
||||
|
||||
public string GetName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public List<string> GetPrevalues()
|
||||
{
|
||||
List<string> list = new List<string>();
|
||||
list.AddRange(prevalues.Split(','));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public DataEditorSettingType GetDataEditorSettingType()
|
||||
{
|
||||
Assembly a = string.IsNullOrEmpty(assembly) ? Assembly.GetExecutingAssembly() : Assembly.Load(assembly);
|
||||
DataEditorSettingType dst = (DataEditorSettingType)a.CreateInstance(control);
|
||||
|
||||
if (dst != null)
|
||||
dst.Prevalues = GetPrevalues();
|
||||
|
||||
return dst;
|
||||
}
|
||||
}
|
||||
}
|
||||
20
umbraco/cms/businesslogic/datatype/DataEditorSettingType.cs
Normal file
20
umbraco/cms/businesslogic/datatype/DataEditorSettingType.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace umbraco.cms.businesslogic.datatype
|
||||
{
|
||||
public abstract class DataEditorSettingType : ProviderBase, IDataEditorSettingType
|
||||
{
|
||||
public virtual string Value { get; set; }
|
||||
public abstract System.Web.UI.Control RenderControl(DataEditorSetting setting);
|
||||
|
||||
private List<string> m_prevalues = new List<string>();
|
||||
public List<string> Prevalues
|
||||
{
|
||||
get { return m_prevalues; }
|
||||
set { m_prevalues = value; }
|
||||
}
|
||||
}
|
||||
}
|
||||
103
umbraco/cms/businesslogic/datatype/DataEditorSettingsStorage.cs
Normal file
103
umbraco/cms/businesslogic/datatype/DataEditorSettingsStorage.cs
Normal file
@@ -0,0 +1,103 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using umbraco.DataLayer;
|
||||
|
||||
namespace umbraco.cms.businesslogic.datatype
|
||||
{
|
||||
public class DataEditorSettingsStorage
|
||||
{
|
||||
private ISqlHelper sqlHelper;
|
||||
|
||||
public DataEditorSettingsStorage()
|
||||
{
|
||||
init( DataLayerHelper.CreateSqlHelper(umbraco.GlobalSettings.DbDSN));
|
||||
}
|
||||
|
||||
private void init(ISqlHelper connection) {
|
||||
sqlHelper = connection;
|
||||
}
|
||||
|
||||
public List<Setting<string, string>> GetSettings(int dataTypeNodeID)
|
||||
{
|
||||
|
||||
string sql = "select * from cmsDataTypePreValues where datatypenodeid = @datatypenodeid";
|
||||
IRecordsReader settingsReader = sqlHelper.ExecuteReader(sql, sqlHelper.CreateParameter("@datatypenodeid", dataTypeNodeID));
|
||||
|
||||
List<Setting<string, string>> settings = new List<Setting<string, string>>();
|
||||
|
||||
while (settingsReader.Read())
|
||||
{
|
||||
Setting<string, string> setting = new Setting<string, string>();
|
||||
setting.Key = settingsReader.GetString("alias");
|
||||
setting.Value = settingsReader.GetString("value");
|
||||
settings.Add(setting);
|
||||
}
|
||||
|
||||
settingsReader.Dispose();
|
||||
|
||||
return settings;
|
||||
}
|
||||
|
||||
|
||||
public void ClearSettings(int dataTypeNodeID)
|
||||
{
|
||||
string sql = "delete from cmsDataTypePreValues where datatypenodeid = @datatypenodeid";
|
||||
sqlHelper.ExecuteNonQuery(sql, sqlHelper.CreateParameter("@datatypenodeid", dataTypeNodeID));
|
||||
}
|
||||
|
||||
|
||||
public void InsertSettings(int dataTypeNodeID, List<Setting<string, string>> settings)
|
||||
{
|
||||
int i = 0;
|
||||
foreach (Setting<string, string> s in settings)
|
||||
{
|
||||
string sql = "insert into cmsDataTypePreValues (datatypenodeid,[value],sortorder,alias) values (@datatypenodeid,@value,@sortorder,@alias)";
|
||||
sqlHelper.ExecuteNonQuery(sql,
|
||||
sqlHelper.CreateParameter("@datatypenodeid", dataTypeNodeID),
|
||||
sqlHelper.CreateParameter("@alias", s.Key),
|
||||
sqlHelper.CreateParameter("@value", s.Value),
|
||||
sqlHelper.CreateParameter("@sortorder", i));
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void InsertSetting(int dataTypeNodeID, string key, string value, int sortOrder)
|
||||
{
|
||||
|
||||
string sql = "insert into cmsDataTypePreValues (datatypenodeid,[value],sortorder,alias) values (@datatypenodeid,@value,@sortorder,@alias)";
|
||||
sqlHelper.ExecuteNonQuery(sql,
|
||||
sqlHelper.CreateParameter("@datatypenodeid", dataTypeNodeID),
|
||||
sqlHelper.CreateParameter("@alias", key),
|
||||
sqlHelper.CreateParameter("@value", value),
|
||||
sqlHelper.CreateParameter("@sortorder", sortOrder));
|
||||
|
||||
}
|
||||
|
||||
public void UpdateSettings(int dataTypeNodeID, List<Setting<string, string>> settings)
|
||||
{
|
||||
ClearSettings(dataTypeNodeID);
|
||||
InsertSettings(dataTypeNodeID, settings);
|
||||
}
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
sqlHelper.Dispose();
|
||||
sqlHelper = null;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public struct Setting<K, V>
|
||||
{
|
||||
public K Key { get; set; }
|
||||
public V Value { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using System.Web.UI.WebControls;
|
||||
using umbraco.interfaces;
|
||||
using umbraco.BusinessLogic;
|
||||
using umbraco.DataLayer;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace umbraco.cms.businesslogic.datatype
|
||||
{
|
||||
@@ -24,6 +25,10 @@ namespace umbraco.cms.businesslogic.datatype
|
||||
private string _prevalue;
|
||||
private bool _displayTextBox;
|
||||
|
||||
|
||||
private Dictionary<string, DataEditorSettingType> dtSettings = new Dictionary<string, DataEditorSettingType>();
|
||||
|
||||
|
||||
public static ISqlHelper SqlHelper
|
||||
{
|
||||
get { return Application.SqlHelper; }
|
||||
@@ -39,32 +44,49 @@ namespace umbraco.cms.businesslogic.datatype
|
||||
// state it knows its datatypedefinitionid
|
||||
_displayTextBox = DisplayTextBox;
|
||||
_datatype = DataType;
|
||||
setupChildControls();
|
||||
//setupChildControls();
|
||||
}
|
||||
|
||||
|
||||
private void setupChildControls()
|
||||
{
|
||||
_dropdownlist = new DropDownList();
|
||||
_dropdownlist.ID = "dbtype";
|
||||
//private void setupChildControls()
|
||||
//{
|
||||
// DataEditorPropertyPanel pnlType = new DataEditorPropertyPanel();
|
||||
// pnlType.Text = ui.Text("dataBaseDatatype");
|
||||
|
||||
_textbox = new TextBox();
|
||||
_textbox.ID = "prevalues";
|
||||
_textbox.Visible = _displayTextBox;
|
||||
// _dropdownlist = new DropDownList();
|
||||
// _dropdownlist.ID = "dbtype";
|
||||
|
||||
// put the childcontrols in context - ensuring that
|
||||
// the viewstate is persisted etc.
|
||||
Controls.Add(_textbox);
|
||||
Controls.Add(_dropdownlist);
|
||||
// _dropdownlist.Items.Add(DBTypes.Date.ToString());
|
||||
// _dropdownlist.Items.Add(DBTypes.Integer.ToString());
|
||||
// _dropdownlist.Items.Add(DBTypes.Ntext.ToString());
|
||||
// _dropdownlist.Items.Add(DBTypes.Nvarchar.ToString());
|
||||
|
||||
_dropdownlist.Items.Add(DBTypes.Date.ToString());
|
||||
_dropdownlist.Items.Add(DBTypes.Integer.ToString());
|
||||
_dropdownlist.Items.Add(DBTypes.Ntext.ToString());
|
||||
_dropdownlist.Items.Add(DBTypes.Nvarchar.ToString());
|
||||
}
|
||||
// DataEditorPropertyPanel pnlPrevalue = new DataEditorPropertyPanel();
|
||||
// pnlPrevalue.Text = ui.Text("prevalue");
|
||||
|
||||
// _textbox = new TextBox();
|
||||
// _textbox.ID = "prevalues";
|
||||
// _textbox.Visible = _displayTextBox;
|
||||
|
||||
// // put the childcontrols in context - ensuring that
|
||||
// // the viewstate is persisted etc.
|
||||
|
||||
// pnlType.Controls.Add(_dropdownlist);
|
||||
// Controls.Add(pnlType);
|
||||
|
||||
// if (_displayTextBox)
|
||||
// {
|
||||
// pnlPrevalue.Controls.Add(_textbox);
|
||||
// Controls.Add(pnlPrevalue);
|
||||
// }
|
||||
|
||||
|
||||
//}
|
||||
|
||||
protected override void OnLoad(EventArgs e)
|
||||
{
|
||||
LoadSettings();
|
||||
|
||||
base.OnLoad(e);
|
||||
if (!Page.IsPostBack)
|
||||
{
|
||||
@@ -161,41 +183,177 @@ namespace umbraco.cms.businesslogic.datatype
|
||||
// If the prevalue editor has an prevalue textbox - save the textbox value as the prevalue
|
||||
Prevalue = _textbox.Text;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Render(HtmlTextWriter writer)
|
||||
{
|
||||
writer.Write("<div class='propertyItem'><div class='propertyItemheader'>" + ui.Text("dataBaseDatatype") + "</div>");
|
||||
_dropdownlist.RenderControl(writer);
|
||||
writer.Write("<br style='clear: both'/></div>");
|
||||
DataEditorSettingsStorage ss = new DataEditorSettingsStorage();
|
||||
|
||||
ss.ClearSettings(_datatype.DataTypeDefinitionId);
|
||||
|
||||
if (_displayTextBox)
|
||||
int i = 0;
|
||||
foreach (KeyValuePair<string, DataEditorSettingType> k in dtSettings)
|
||||
{
|
||||
writer.Write("<div class='propertyItem'><div class='propertyItemheader'>" + ui.Text("prevalue") + "</div>");
|
||||
_textbox.RenderControl(writer);
|
||||
writer.Write("<br style='clear: both'/></div>");
|
||||
ss.InsertSetting(_datatype.DataTypeDefinitionId, k.Key, k.Value.Value, i);
|
||||
i++;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
writer.WriteLine("<div class='propertyItem'>");
|
||||
writer.WriteLine("<tr><td>Database datatype</td><td>");
|
||||
_dropdownlist.RenderControl(writer);
|
||||
writer.Write("</td></tr>");
|
||||
if (_displayTextBox)
|
||||
writer.WriteLine("<tr><td>Prevalue: </td><td>");
|
||||
_textbox.RenderControl(writer);
|
||||
writer.WriteLine("</td></tr>");
|
||||
writer.Write("</div>");
|
||||
*/
|
||||
|
||||
ss.Dispose();
|
||||
}
|
||||
|
||||
//protected override void Render(HtmlTextWriter writer)
|
||||
//{
|
||||
// writer.Write("<div class='propertyItem'><div class='propertyItemheader'>" + ui.Text("dataBaseDatatype") + "</div>");
|
||||
// _dropdownlist.RenderControl(writer);
|
||||
// writer.Write("<br style='clear: both'/></div>");
|
||||
|
||||
|
||||
// if (_displayTextBox)
|
||||
// {
|
||||
// writer.Write("<div class='propertyItem'><div class='propertyItemheader'>" + ui.Text("prevalue") + "</div>");
|
||||
// _textbox.RenderControl(writer);
|
||||
// writer.Write("<br style='clear: both'/></div>");
|
||||
// }
|
||||
|
||||
// /*
|
||||
// writer.WriteLine("<div class='propertyItem'>");
|
||||
// writer.WriteLine("<tr><td>Database datatype</td><td>");
|
||||
// _dropdownlist.RenderControl(writer);
|
||||
// writer.Write("</td></tr>");
|
||||
// if (_displayTextBox)
|
||||
// writer.WriteLine("<tr><td>Prevalue: </td><td>");
|
||||
// _textbox.RenderControl(writer);
|
||||
// writer.WriteLine("</td></tr>");
|
||||
// writer.Write("</div>");
|
||||
// */
|
||||
|
||||
//}
|
||||
|
||||
[Obsolete("Use the PreValues class for data access instead")]
|
||||
public static string GetPrevalueFromId(int Id)
|
||||
{
|
||||
return SqlHelper.ExecuteScalar<string>("Select [value] from cmsDataTypePreValues where id = @id",
|
||||
SqlHelper.CreateParameter("@id", Id));
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void LoadSettings()
|
||||
{
|
||||
DataEditorPropertyPanel pnlType = new DataEditorPropertyPanel();
|
||||
pnlType.Text = ui.Text("dataBaseDatatype");
|
||||
|
||||
_dropdownlist = new DropDownList();
|
||||
_dropdownlist.ID = "dbtype";
|
||||
|
||||
_dropdownlist.Items.Add(DBTypes.Date.ToString());
|
||||
_dropdownlist.Items.Add(DBTypes.Integer.ToString());
|
||||
_dropdownlist.Items.Add(DBTypes.Ntext.ToString());
|
||||
_dropdownlist.Items.Add(DBTypes.Nvarchar.ToString());
|
||||
|
||||
DataEditorPropertyPanel pnlPrevalue = new DataEditorPropertyPanel();
|
||||
pnlPrevalue.Text = ui.Text("prevalue");
|
||||
|
||||
_textbox = new TextBox();
|
||||
_textbox.ID = "prevalues";
|
||||
_textbox.Visible = _displayTextBox;
|
||||
|
||||
// put the childcontrols in context - ensuring that
|
||||
// the viewstate is persisted etc.
|
||||
|
||||
pnlType.Controls.Add(_dropdownlist);
|
||||
Controls.Add(pnlType);
|
||||
|
||||
if (_displayTextBox)
|
||||
{
|
||||
pnlPrevalue.Controls.Add(_textbox);
|
||||
Controls.Add(pnlPrevalue);
|
||||
}
|
||||
|
||||
|
||||
foreach (KeyValuePair<string, DataEditorSetting> kv in _datatype.Settings())
|
||||
{
|
||||
DataEditorSettingType dst = kv.Value.GetDataEditorSettingType();
|
||||
dtSettings.Add(kv.Key, dst);
|
||||
|
||||
DataEditorPropertyPanel panel = new DataEditorPropertyPanel();
|
||||
panel.Text = kv.Value.GetName();
|
||||
panel.Text += "<br/><small>" + kv.Value.description + "</small>";
|
||||
|
||||
|
||||
if (_datatype.HasSettings())
|
||||
{
|
||||
DataEditorSettingsStorage ss = new DataEditorSettingsStorage();
|
||||
|
||||
List<Setting<string, string>> s = ss.GetSettings(_datatype.DataTypeDefinitionId);
|
||||
ss.Dispose();
|
||||
|
||||
if (s.Find(set => set.Key == kv.Key).Value != null)
|
||||
dst.Value = s.Find(set => set.Key == kv.Key).Value;
|
||||
|
||||
}
|
||||
|
||||
panel.Controls.Add(dst.RenderControl(kv.Value));
|
||||
|
||||
this.Controls.Add(panel);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class DataEditorPropertyPanel : System.Web.UI.WebControls.Panel
|
||||
{
|
||||
public DataEditorPropertyPanel()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private string m_Text = string.Empty;
|
||||
public string Text
|
||||
{
|
||||
get { return m_Text; }
|
||||
set { m_Text = value; }
|
||||
}
|
||||
|
||||
|
||||
protected override void OnLoad(System.EventArgs EventArguments)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void Render(System.Web.UI.HtmlTextWriter writer)
|
||||
{
|
||||
|
||||
this.CreateChildControls();
|
||||
string styleString = "";
|
||||
|
||||
foreach (string key in this.Style.Keys)
|
||||
{
|
||||
styleString += key + ":" + this.Style[key] + ";";
|
||||
}
|
||||
|
||||
writer.WriteLine("<div class=\"propertyItem\" style='" + styleString + "'>");
|
||||
if (m_Text != string.Empty)
|
||||
{
|
||||
writer.WriteLine("<div class=\"propertyItemheader\">" + m_Text + "</div>");
|
||||
writer.WriteLine("<div class=\"propertyItemContent\">");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
this.RenderChildren(writer);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
writer.WriteLine("Error creating control <br />");
|
||||
writer.WriteLine(ex.ToString());
|
||||
}
|
||||
|
||||
if (m_Text != string.Empty)
|
||||
writer.WriteLine("</div>");
|
||||
|
||||
writer.WriteLine("</div>");
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
13
umbraco/cms/businesslogic/datatype/IDataEditorSettingType.cs
Normal file
13
umbraco/cms/businesslogic/datatype/IDataEditorSettingType.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace umbraco.cms.businesslogic.datatype
|
||||
{
|
||||
public interface IDataEditorSettingType
|
||||
{
|
||||
string Value { get; set; }
|
||||
System.Web.UI.Control RenderControl(DataEditorSetting setting);
|
||||
}
|
||||
}
|
||||
@@ -196,7 +196,11 @@
|
||||
<Compile Include="Actions\IActionHandler.cs" />
|
||||
<Compile Include="businesslogic\CMSPreviewNode.cs" />
|
||||
<Compile Include="businesslogic\datatype\ClientDependencyAttribute.cs" />
|
||||
<Compile Include="businesslogic\datatype\DataEditorSetting.cs" />
|
||||
<Compile Include="businesslogic\datatype\DataEditorSettingsStorage.cs" />
|
||||
<Compile Include="businesslogic\datatype\DataEditorSettingType.cs" />
|
||||
<Compile Include="businesslogic\datatype\DBTypes.cs" />
|
||||
<Compile Include="businesslogic\datatype\IDataEditorSettingType.cs" />
|
||||
<Compile Include="businesslogic\datatype\PreValue.cs" />
|
||||
<Compile Include="businesslogic\installer\IInstallerStep.cs" />
|
||||
<Compile Include="businesslogic\installer\InstallerStep.cs" />
|
||||
@@ -221,7 +225,7 @@
|
||||
<Compile Include="businesslogic\skinning\Dependency.cs" />
|
||||
<Compile Include="businesslogic\skinning\DependencyType.cs" />
|
||||
<Compile Include="businesslogic\skinning\Palette.cs" />
|
||||
<Compile Include="businesslogic\skinning\ProviderBase.cs" />
|
||||
<Compile Include="businesslogic\ProviderBase.cs" />
|
||||
<Compile Include="businesslogic\skinning\Skin.cs" />
|
||||
<Compile Include="businesslogic\skinning\Task.cs" />
|
||||
<Compile Include="businesslogic\skinning\tasks\AddStyleSheetToTemplate.cs" />
|
||||
|
||||
Reference in New Issue
Block a user