/// <summary> /// Process Field Placeholders /// </summary> /// <param name = "args"></param> /// <returns></returns> public string Process(FieldPlaceholderArgs args) { if (args == null) { return string.Empty; } //list check List<IFieldPlaceholder> fieldPlaceholders = FieldPlaceholderItems; if (fieldPlaceholders == null || fieldPlaceholders.Count == 0) { return string.Empty; } foreach (IFieldPlaceholder fieldPlaceholder in fieldPlaceholders) { if (fieldPlaceholder == null) { continue; } //validate item string processedClickEvent = fieldPlaceholder.Execute(args); if (string.IsNullOrEmpty(processedClickEvent)) { continue; } //add output of validation to the master validation list args.ClickEvent = processedClickEvent; } //return all output validation return args.ClickEvent; }
/// <summary> /// Process Field Placeholders /// </summary> /// <param name = "args"></param> /// <returns></returns> public string Process(FieldPlaceholderArgs args) { if (args == null) { return(string.Empty); } //list check List <IFieldPlaceholder> fieldPlaceholders = FieldPlaceholderItems; if (fieldPlaceholders == null || fieldPlaceholders.Count == 0) { return(string.Empty); } foreach (IFieldPlaceholder fieldPlaceholder in fieldPlaceholders) { if (fieldPlaceholder == null) { continue; } //validate item string processedClickEvent = fieldPlaceholder.Execute(args); if (string.IsNullOrEmpty(processedClickEvent)) { continue; } //add output of validation to the master validation list args.ClickEvent = processedClickEvent; } //return all output validation return(args.ClickEvent); }
private string RenderMenuButtons(Sitecore.Shell.Applications.ContentManager.Editor.Field field, Item menu, bool readOnly) { Assert.ArgumentNotNull(field, "field"); Assert.ArgumentNotNull(menu, "menu"); HtmlTextWriter writer = new HtmlTextWriter(new StringWriter()); writer.Write("<div class=\"scContentButtons\">"); bool flag = true; foreach (Item item in menu.Children) { if (!this.IsFieldEditor || MainUtil.GetBool(item["Show In Field Editor"], false)) { if (!flag) { writer.Write("·"); } flag = false; string clickEvent = string.Empty; if (!string.IsNullOrEmpty(item["Message"])) { clickEvent = item["Message"]; } FieldPlaceholderArgs fieldPlaceholderArgs = new FieldPlaceholderArgs(); fieldPlaceholderArgs.FieldId = field.ControlID; if (this.CurrentItem != null) { fieldPlaceholderArgs.ItemId = this.CurrentItem.ID.ToString(); fieldPlaceholderArgs.InnerItem = CurrentItem; fieldPlaceholderArgs.TemplateItem = CurrentItem.Template; } fieldPlaceholderArgs.Source = GetFieldSource(field); fieldPlaceholderArgs.ClickEvent = item["Message"]; fieldPlaceholderArgs.FieldItem = menu; IFieldPlaceholderProcessor fieldPlaceholderProcessor = FieldPlaceholderProcessorFactory.GetProcessor(); if (fieldPlaceholderProcessor != null) { clickEvent = fieldPlaceholderProcessor.Process(fieldPlaceholderArgs); if (string.IsNullOrEmpty(clickEvent)) { clickEvent = string.Empty; } } //to send a message to the messaging system (handleMessage) if (item["Client Event"] == null || string.IsNullOrEmpty(item["Client Event"]) || item["Client Event"] == "0") { clickEvent = Sitecore.Context.ClientPage.GetClientEvent(clickEvent); } if (readOnly) { writer.Write("<span class=\"scContentButtonDisabled\">"); writer.Write(item["Display Name"]); writer.Write("</span>"); } else { string cssClass = "scContentButton"; if (!string.IsNullOrEmpty(item["CssClass"])) { cssClass = item["CssClass"]; } string innerHtml = item["Inner Html"]; if (string.IsNullOrEmpty(innerHtml)) { innerHtml = item["Display Name"]; } writer.Write("<a href=\"#\" class=\"" + cssClass + "\" onclick=\"" + clickEvent + "\">"); writer.Write(innerHtml); writer.Write("</a>"); } } } writer.Write("</div>"); return writer.InnerWriter.ToString(); }