Пример #1
0
        /// <summary>
        /// Returns Field Placeholder Value
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public string Execute(FieldPlaceholderArgs args)
        {
            if (args == null || string.IsNullOrEmpty(args.ClickEvent) || string.IsNullOrEmpty(Key) || string.IsNullOrEmpty(args.ItemId))
            {
                return string.Empty;
            }

            string clickEvent = args.ClickEvent;
            clickEvent = clickEvent.Replace(Key, args.ItemId);

            return clickEvent;
        }
Пример #2
0
        /// <summary>
        /// Returns Field Placeholder Value
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        public string Execute(FieldPlaceholderArgs args)
        {
            if (args == null || string.IsNullOrEmpty(args.ClickEvent) || string.IsNullOrEmpty(Key) || string.IsNullOrEmpty(args.Source))
            {
                return(string.Empty);
            }

            string clickEvent = args.ClickEvent;

            clickEvent = clickEvent.Replace(Key, args.Source);

            return(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("&#183;");
                    }
                    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());
        }