private void FillTextBox(Sitecore.Shell.Applications.ContentEditor.Text text, Sitecore.Web.UI.HtmlControls.Checklist list) { foreach (ChecklistItem i in list.Items) { if (i.Checked) { if (text.Value.Length > 0) { text.Value += Separator; } text.Value += i.Name; } } }
protected override void OnPreRender(EventArgs e) { Sitecore.Shell.Applications.ContentEditor.Checklist list = FindControl(GetID("list")) as Sitecore.Shell.Applications.ContentEditor.Checklist; Sitecore.Shell.Applications.ContentEditor.Text text = FindControl(GetID("text")) as Sitecore.Shell.Applications.ContentEditor.Text; FillTextBox(text, list); if (!isEvent) { if (list != null) { for (int i = 0; i < list.Items.Length; i++) { list.Items[i].ServerProperties["Click"] = string.Format("{0}.ListItemClick", this.ID); } } } base.OnPreRender(e); }
//protected override void OK_Click() { // ReadValuesIntoResponse(); // SheerResponse.SetDialogValue(this.ScheduleValue.XmlValue.ToString()); // base.OK_Click(); //} //if (!Sitecore.Web.UI.XamlSharp.Xaml.XamlControl.AjaxScriptManager.IsEvent) { // Sitecore.Shell.Applications.ContentEditor.Checklist list = FindControl(GetID("list")) as Sitecore.Shell.Applications.ContentEditor.Checklist; // Sitecore.Shell.Applications.ContentEditor.Text text = FindControl(GetID("text")) as Sitecore.Shell.Applications.ContentEditor.Text; // list.CheckAll(); //} public override void HandleMessage(Sitecore.Web.UI.Sheer.Message message) { if (message["id"] == this.ID) { Sitecore.Shell.Applications.ContentEditor.Checklist list = FindControl(GetID("list")) as Sitecore.Shell.Applications.ContentEditor.Checklist; Sitecore.Shell.Applications.ContentEditor.Text text = FindControl(GetID("text")) as Sitecore.Shell.Applications.ContentEditor.Text; if (list != null) { string messageText; if ((messageText = message.Name) == null) { return; } if (messageText != "checklist:checkall") { if (messageText == "checklist:uncheckall") { list.UncheckAll(); } else if (messageText == "checklist:invert") { list.Invert(); } } else if (messageText != "checklist:selectplayer") { list.CheckAll(); } else if (messageText != "checklist:clear") { } else { list.CheckAll(); } } } base.HandleMessage(message); }
public Control GetEditor(Item fieldType) { Assert.ArgumentNotNull(fieldType, "fieldType"); if (!this.Arguments.ShowInputBoxes) { switch (fieldType.Name.ToLowerInvariant()) { case "html": case "memo": case "rich text": case "security": case "multi-line text": return(new Memo()); } if (fieldType.Name == "password") { return(new Password()); } return(new Sitecore.Shell.Applications.ContentEditor.Text()); } System.Web.UI.Control webControl = Resource.GetWebControl(fieldType["Control"]); if (webControl == null) { string str2 = fieldType["Assembly"]; string str3 = fieldType["Class"]; if (!string.IsNullOrEmpty(str2) && !string.IsNullOrEmpty(str3)) { webControl = Sitecore.Reflection.ReflectionUtil.CreateObject(str2, str3, new object[0]) as Control; } } if (webControl == null) { webControl = new Sitecore.Shell.Applications.ContentEditor.Text(); } return(webControl); }
protected override void OnLoad(EventArgs e) { Assert.ArgumentNotNull(e, "e"); if (!Sitecore.Context.ClientPage.IsEvent) { isEvent = false; Sitecore.Shell.Applications.ContentEditor.Checklist list = new Sitecore.Shell.Applications.ContentEditor.Checklist(); this.Controls.Add(list); list.ID = GetID("list"); list.Source = this.Source; list.ItemID = ItemID; list.FieldName = FieldName; list.TrackModified = TrackModified; list.Disabled = this.Disabled; list.Value = this.Value; Sitecore.Shell.Applications.ContentEditor.Text text = new Sitecore.Shell.Applications.ContentEditor.Text(); this.Controls.AddAt(0, text); text.ID = GetID("text"); text.ReadOnly = true; text.Disabled = this.Disabled; Button b = new Button(); this.Controls.Add(b); b.ID = GetID("button"); b.Disabled = this.Disabled; b.Click = "checklist:selectplayer"; b.Header = "click me"; this.Controls.Add(new LiteralControl(Sitecore.Resources.Images.GetSpacer(0x18, 16))); } else { Sitecore.Shell.Applications.ContentEditor.Checklist list = FindControl(GetID("list")) as Sitecore.Shell.Applications.ContentEditor.Checklist; if (list != null) { ListString valueList = new ListString(); foreach (DataChecklistItem item in list.Items) { if (item.Checked) { valueList.Add(item.ItemID); } } if (this.Value != valueList.ToString()) { this.TrackModified = list.TrackModified; //this.SetModified(); } this.Value = valueList.ToString(); } } base.OnLoad(e); if (!Sitecore.Web.UI.XamlSharp.Xaml.XamlControl.AjaxScriptManager.IsEvent) { SheerResponse.Alert("hey2", true); } }
protected override void OnLoad(EventArgs e) { Assert.ArgumentNotNull(e, "e"); if (!Sitecore.Context.ClientPage.IsEvent) { isEvent = false; Sitecore.Shell.Applications.ContentEditor.Checklist list = new Sitecore.Shell.Applications.ContentEditor.Checklist(); this.Controls.Add(list); list.ID = GetID("list"); list.Source = this.Source; list.ItemID = ItemID; list.FieldName = FieldName; list.TrackModified = TrackModified; list.Disabled = this.Disabled; list.Value = this.Value; Sitecore.Shell.Applications.ContentEditor.Text text = new Sitecore.Shell.Applications.ContentEditor.Text(); this.Controls.AddAt(0, text); text.ID = GetID("text"); text.ReadOnly = true; text.Disabled = this.Disabled; Button b = new Button(); this.Controls.Add(b); b.ID = GetID("button"); b.Disabled = this.Disabled; b.Click = "checklist:selectplayer"; b.Header = "click me"; this.Controls.Add(new LiteralControl(Sitecore.Resources.Images.GetSpacer(0x18, 16))); } else { Sitecore.Shell.Applications.ContentEditor.Checklist list = FindControl(GetID("list")) as Sitecore.Shell.Applications.ContentEditor.Checklist; if (list != null) { ListString valueList = new ListString(); foreach (DataChecklistItem item in list.Items) { if (item.Checked) { valueList.Add(item.ItemID); } } if (this.Value != valueList.ToString()) { this.TrackModified = list.TrackModified; //this.SetModified(); } this.Value = valueList.ToString(); } } base.OnLoad(e); if (!Sitecore.Web.UI.XamlSharp.Xaml.XamlControl.AjaxScriptManager.IsEvent) { SheerResponse.Alert("hey2", true); } }
public Control GetEditor(Item fieldType) { Assert.ArgumentNotNull(fieldType, "fieldType"); if (!this.Arguments.ShowInputBoxes) { switch (fieldType.Name.ToLowerInvariant()) { case "html": case "memo": case "rich text": case "security": case "multi-line text": return new Memo(); } if (fieldType.Name == "password") { return new Password(); } return new Sitecore.Shell.Applications.ContentEditor.Text(); } System.Web.UI.Control webControl = Resource.GetWebControl(fieldType["Control"]); if (webControl == null) { string str2 = fieldType["Assembly"]; string str3 = fieldType["Class"]; if (!string.IsNullOrEmpty(str2) && !string.IsNullOrEmpty(str3)) { webControl = Sitecore.Reflection.ReflectionUtil.CreateObject(str2, str3, new object[0]) as Control; } } if (webControl == null) { webControl = new Sitecore.Shell.Applications.ContentEditor.Text(); } return webControl; }
/// <summary> /// Sends server control content to a provided <see cref="T:System.Web.UI.HtmlTextWriter"></see> object, which writes the content to be rendered on the client. /// </summary> /// <param name="output">The <see cref="T:System.Web.UI.HtmlTextWriter"></see> object that receives the server control content.</param> protected override void DoRender(HtmlTextWriter output) { IDictionary dictionary; ArrayList list; Item current = Sitecore.Context.ContentDatabase.GetItem(this.ItemID); Item[] items = this.GetItems(current); this.GetSelectedItems(items, out list, out dictionary); #region Rendering filter box var sb = new StringBuilder(); foreach (DictionaryEntry entry in dictionary) { var item = entry.Value as Item; if (item != null) { sb.Append(item.DisplayName + ","); sb.Append(GetItemValue(item) + ","); } } output.Write("<input type=\"hidden\" width=\"100%\" id=\"multilistValues" + ClientID + "\" value=\"" + sb.ToString() + "\" style=\"width: 200px;margin-left:3px;\">"); #endregion ServerProperties["ID"] = ID; var str = string.Empty; if (ReadOnly) { str = " disabled=\"disabled\""; } output.Write("<input id=\"" + ID + "_Value\" type=\"hidden\" value=\"" + StringUtil.EscapeQuote(Value) + "\" />"); output.Write("<table" + this.GetControlAttributes() + ">"); output.Write("<tr>"); output.Write("<td class=\"scContentControlMultilistCaption\" width=\"50%\">" + Translate.Text("All") + "</td>"); output.Write("<td width=\"20\">" + Images.GetSpacer(20, 1) + "</td>"); output.Write("<td class=\"scContentControlMultilistCaption\" width=\"50%\">" + Translate.Text("Selected") + "</td>"); output.Write("<td width=\"20\">" + Images.GetSpacer(20, 1) + "</td>"); output.Write("</tr>"); output.Write("<tr>"); output.Write("<td valign=\"top\" height=\"100%\">"); var textFirstName = new Sitecore.Shell.Applications.ContentEditor.Text(); textFirstName.ID = GetID("textFirstName"); var textLastName = new Sitecore.Shell.Applications.ContentEditor.Text(); textLastName.ID = GetID("textLastName"); // var TreeViewThing = new Sitecore.Shell.Applications.ContentEditor.TreeList(); TreeViewThing.ID = "DropTreeForBucket"; TreeViewThing.RenderControl(output); output.Write("<input type=\"text\" width=\"100%\" class=\"scIgnoreModified\" style=\"color:gray\" value=\"Type here to search\" id=\"filterBox" + ClientID + "\" style=\"width:100%\">"); output.Write("<select id=\"" + ID + "_unselected\" class=\"scContentControlMultilistBox\" multiple=\"multiple\" size=\"10\"" + str + " >"); foreach (DictionaryEntry entry in dictionary) { Item item = entry.Value as Item; if (item != null) { output.Write("<option value=\"" + this.GetItemValue(item) + "\">" + item.DisplayName + "</option>"); } } output.Write("</select>"); output.Write("</td>"); output.Write("<td valign=\"top\">"); output.Write("<img class=\"\" height=\"16\" width=\"16\" border=\"0\" alt=\"\" style=\"margin: 2px;\" src=\"/sitecore/shell/themes/standard/Images/blank.png\"/>"); output.Write("<br />"); this.RenderButton(output, "Core/16x16/arrow_blue_right.png", ""); output.Write("<br />"); this.RenderButton(output, "Core/16x16/arrow_blue_left.png", ""); output.Write("</td>"); output.Write("<td valign=\"top\" height=\"100%\">"); output.Write("<select style=\"margin-top:22px\" id=\"" + this.ID + "_selected\" class=\"scContentControlMultilistBox\" multiple=\"multiple\" size=\"10\"" + str + ">"); for (int i = 0; i < list.Count; i++) { Item item3 = list[i] as Item; if (item3 != null) { output.Write("<option value=\"" + this.GetItemValue(item3) + "\">" + item3.DisplayName + "</option>"); } else { string path = list[i] as string; if (path != null) { string str3; Item item4 = Sitecore.Context.ContentDatabase.GetItem(path); if (item4 != null) { str3 = item4.DisplayName + ' ' + Translate.Text("[Not in the selection List]"); } else { str3 = path + ' ' + Translate.Text("[Item not found]"); } output.Write("<option value=\"" + path + "\">" + str3 + "</option>"); } } } output.Write("</select>"); output.Write("</td>"); output.Write("<td valign=\"top\">"); output.Write("<img class=\"\" height=\"16\" width=\"16\" border=\"0\" alt=\"\" style=\"margin: 2px;\" src=\"/sitecore/shell/themes/standard/Images/blank.png\"/>"); output.Write("<br />"); RenderButton(output, "Core/16x16/arrow_blue_up.png", "javascript:scContent.multilistMoveUp('" + ID + "')"); output.Write("<br />"); RenderButton(output, "Core/16x16/arrow_blue_down.png", "javascript:scContent.multilistMoveDown('" + ID + "')"); output.Write("</td>"); output.Write("</tr>"); output.Write("<div style=\"border:1px solid #999999;font:8pt tahoma;display:none;padding:2px;margin:4px 0px 4px 0px;height:14px\" id=\"" + ID + "_all_help\"></div>"); output.Write("<div style=\"border:1px solid #999999;font:8pt tahoma;display:none;padding:2px;margin:4px 0px 4px 0px;height:14px\" id=\"" + ID + "_selected_help\"></div>"); output.Write("</table>"); RenderScript(output); }