Пример #1
0
        protected virtual string GetFieldGutterHtml()
        {
            if (string.IsNullOrEmpty(this.Value) || !Sitecore.Data.ID.IsID(this.Value))
            {
                return(string.Format("<div id=\"{1}_fieldGutterDiv\" class=\"droplinkFieldGutterDiv\">{0}</div>", string.Empty, this.ID));
            }

            Item selectedItem = Sitecore.Context.ContentDatabase.GetItem(this.Value);

            if (selectedItem.IsNull())
            {
                return(string.Format("<div id=\"{1}_fieldGutterDiv\" class=\"droplinkFieldGutterDiv\">{0}</div>", string.Empty, this.ID));
            }

            IFieldGutterProcessor fieldGutterProcessor = FieldGutterProcessorFactory.GetProcessor();

            if (fieldGutterProcessor == null)
            {
                return(string.Format("<div id=\"{1}_fieldGutterDiv\" class=\"droplinkFieldGutterDiv\">{0}</div>", string.Empty, this.ID));
            }

            string fieldGutterHtml = fieldGutterProcessor.Process(new FieldGutterArgs(selectedItem, this.ID));

            if (string.IsNullOrEmpty(fieldGutterHtml))
            {
                return(string.Format("<div id=\"{1}_fieldGutterDiv\" class=\"droplinkFieldGutterDiv\">{0}</div>", string.Empty, this.ID));
            }

            return(string.Format("<div id=\"{1}_fieldGutterDiv\" class=\"droplinkFieldGutterDiv\">{0}</div>", fieldGutterHtml, this.ID));
        }
        /// <summary>
        /// Renders the item not found list item as Html
        /// </summary>
        /// <param name="itemId"></param>
        /// <param name="fieldId"></param>
        /// <returns></returns>
        public virtual string RenderItemNotFound(string itemId, string fieldId)
        {
            string displayText = string.Format("The item could not be retrieved from Sitecore. Id: {0}", itemId);

            string fieldGutterHtml = string.Empty;
            IFieldGutterProcessor fieldGutterProcessor = FieldGutterProcessorFactory.GetProcessor();

            if (fieldGutterProcessor != null)
            {
                string html = fieldGutterProcessor.Process(null);
                if (!string.IsNullOrEmpty(html))
                {
                    fieldGutterHtml = html;
                }
            }

            return(string.Format(HtmlTemplate,
                                 itemId,
                                 fieldGutterHtml,
                                 fieldId,
                                 AddRemoveHtml(string.Format("FieldSuite.Fields.RemoveItem('{0}', '{1}');", fieldId, itemId), Images.GetSpacer(16, 16)),
                                 displayText,
                                 Images.GetImage("/sitecore modules/shell/field suite/images/bullet_ball_red.png", 0x10, 0x10, "absmiddle", "0px 4px 0px 0px", displayText),
                                 displayText,
                                 displayText,
                                 ItemClick,
                                 SelectedClass));
        }
Пример #3
0
        /// <summary>
        /// Renders that this item is not configured for the Velir Images Field
        /// </summary>
        /// <param name="itemId"></param>
        /// <param name="fieldId"></param>
        /// <returns></returns>
        public string RenderItemConfigured(string itemId, string fieldId)
        {
            const string displayText = "This item's template is not configured for this field.";

            //setup description
            string title = displayText;

            if (title.Length > 21)
            {
                title = title.Substring(0, 21) + "...";
            }

            string fieldGutterHtml = string.Empty;
            IFieldGutterProcessor fieldGutterProcessor = FieldGutterProcessorFactory.GetProcessor();

            if (fieldGutterProcessor != null)
            {
                string html = fieldGutterProcessor.Process(null);
                if (!string.IsNullOrEmpty(html))
                {
                    fieldGutterHtml = html;
                }
            }

            return(string.Format(HtmlTemplate,
                                 itemId,
                                 fieldGutterHtml,
                                 "<img border=\"0\" src=\"/sitecore modules/shell/field suite/images/unknown.png?w=125&amp;h=125&amp;thn=true&amp;db=master\">",
                                 displayText,
                                 Images.GetImage("/sitecore modules/shell/field suite/images/bullet_ball_red.png", 0x10, 0x10, "absmiddle", "0px 4px 0px 0px", displayText),
                                 title,
                                 displayText,
                                 string.Format("FieldSuite.Fields.ImagesField.ToggleItem(this, '{0}');", fieldId),
                                 SelectedClass));
        }
        /// <summary>
        /// Renders the list item as Html
        /// </summary>
        /// <param name="item"></param>
        /// <param name="itemId"></param>
        /// <param name="fieldId"></param>
        /// <param name="useFieldGutter"></param>
        /// <returns></returns>
        public virtual string Render(Item item, string itemId, string fieldId, bool useFieldGutter)
        {
            if (item.IsNull())
            {
                return(RenderItemNotFound(itemId, fieldId));
            }

            //disable items if the form is read only)
            if (ReadOnly)
            {
                ItemClick   = string.Empty;
                ButtonClick = string.Empty;
            }

            string templateName = string.Empty;

            //defaults
            string icon = "/sitecore modules/shell/field suite/document_error.png";

            //set to items properties
            if (item.IsNotNull())
            {
                icon = item.Appearance.Icon;

                TemplateItem template = item.Template;
                if (!string.IsNullOrEmpty(template.Name))
                {
                    templateName = template.Name;
                }
            }

            string fieldGutterHtml = string.Empty;

            if (useFieldGutter)
            {
                IFieldGutterProcessor fieldGutterProcessor = FieldGutterProcessorFactory.GetProcessor();
                if (fieldGutterProcessor != null)
                {
                    string html = fieldGutterProcessor.Process(new FieldGutterArgs(item, fieldId));
                    if (!string.IsNullOrEmpty(html))
                    {
                        fieldGutterHtml = html;
                    }
                }
            }

            return(string.Format(HtmlTemplate,
                                 item.ID,
                                 fieldGutterHtml,
                                 fieldId,
                                 AddRemoveHtml(ButtonClick, Images.GetSpacer(16, 16)),
                                 templateName,
                                 Images.GetImage(icon, 0x10, 0x10, "absmiddle", "0px 4px 0px 0px", templateName),
                                 Text,
                                 HoverText,
                                 ItemClick,
                                 SelectedClass));
        }
Пример #5
0
        /// <summary>
        /// Renders an item
        /// </summary>
        /// <param name="itemId"></param>
        /// <param name="selectedItem"></param>
        /// <returns></returns>
        public override string RenderItem(string itemId, bool selectedItem)
        {
            if (string.IsNullOrEmpty(itemId))
            {
                return(string.Empty);
            }

            FieldSuiteListItem listItem = new FieldSuiteListItem();

            listItem.ShowAddRemoveButton = true;

            Item item = RenderingDatabase.GetItem(itemId);

            if (item.IsNull())
            {
                return(listItem.RenderItemNotFound(itemId, this.ID));
            }

            listItem.ButtonClick   = string.Format("FieldSuite.Fields.Treelist.RemoveItem('{0}', this);", this.ID);
            listItem.ItemClick     = "FieldSuite.Fields.SelectItem(this);";
            listItem.SelectedClass = "velirFieldSelected";
            listItem.ReadOnly      = this.ReadOnly;
            listItem.Text          = item.DisplayName;
            listItem.HoverText     = item.Paths.FullPath;

            Int32 renderCount = RenderItemCount;

            if (selectedItem)
            {
                renderCount = RenderSelectedItemCount;
            }

            //for performance reason limit field gutter
            bool useFieldGutter = false;
            IFieldGutterProcessor fieldGutterProcessor = FieldGutterProcessorFactory.GetProcessor();

            if (fieldGutterProcessor != null)
            {
                Int32 maxCount = fieldGutterProcessor.MaxCount;
                if (maxCount != 0 && renderCount <= maxCount)
                {
                    useFieldGutter = true;
                }
            }

            //return list item as html
            if (selectedItem)
            {
                RenderSelectedItemCount++;
            }
            else
            {
                RenderItemCount++;
            }

            //return list item as html
            return(listItem.Render(item, item.ID.ToString(), this.ID, useFieldGutter));
        }
Пример #6
0
        private void RenderItems(HtmlTextWriter output)
        {
            Assert.ArgumentNotNull(output, "output");
            foreach (string itemId in this.Value.Split(new char[] { '|' }))
            {
                if (string.IsNullOrEmpty(itemId))
                {
                    continue;
                }

                FieldSuiteListItem listItem = new FieldSuiteListItem();
                listItem.ShowAddRemoveButton = false;

                Item item = this.Database.GetItem(itemId);
                if (item == null)
                {
                    output.Write(listItem.RenderItemNotFound(itemId, this.ID));
                }
                else
                {
                    //for performance reason limit field gutter
                    bool useFieldGutter = false;
                    IFieldGutterProcessor fieldGutterProcessor = FieldGutterProcessorFactory.GetProcessor();
                    if (fieldGutterProcessor != null)
                    {
                        Int32 maxCount = fieldGutterProcessor.MaxCount;
                        if (maxCount != 0 && RenderSelectedItemCount <= maxCount)
                        {
                            useFieldGutter = true;
                        }
                    }

                    RenderSelectedItemCount++;

                    listItem.ButtonClick   = string.Format("FieldSuite.Fields.ToggleItem('{0}', this);", this.ID);
                    listItem.ItemClick     = "FieldSuite.Fields.SelectItem(this);";
                    listItem.SelectedClass = "velirFieldSelected";
                    listItem.ReadOnly      = false;
                    listItem.Text          = item.DisplayName;
                    listItem.HoverText     = item.Paths.FullPath;

                    //return list item as html
                    output.Write(listItem.Render(item, itemId, ID, useFieldGutter));
                }
            }
        }
Пример #7
0
        protected string RenderItem(GeneralLinkItem linkItem)
        {
            GeneralLinksListItem listItem = new GeneralLinksListItem();
            bool useFieldGutter           = false;

            listItem.ShowAddRemoveButton = true;
            listItem.ButtonClick         = string.Format("FieldSuite.Fields.GeneralLinks.RemoveItem(this, '{0}');", this.ID);
            listItem.ItemClick           = "FieldSuite.Fields.SelectItem(this);";
            listItem.SelectedClass       = "velirFieldSelected";
            listItem.ReadOnly            = this.ReadOnly;
            listItem.Text = linkItem.LinkText;

            listItem.HoverText = linkItem.Url;
            if (!string.IsNullOrEmpty(linkItem.Id) && Sitecore.Data.ID.IsID(linkItem.Id))
            {
                Database db = Sitecore.Data.Database.GetDatabase("master");
                if (db != null)
                {
                    Item item = db.GetItem(linkItem.Id);
                    if (item.IsNotNull())
                    {
                        listItem.HoverText = item.Paths.FullPath;
                        useFieldGutter     = true;

                        //for performance reason limit field gutter
                        IFieldGutterProcessor fieldGutterProcessor = FieldGutterProcessorFactory.GetProcessor();
                        if (fieldGutterProcessor != null)
                        {
                            Int32 maxCount = fieldGutterProcessor.MaxCount;
                            if (maxCount != 0 && RenderItemCount <= maxCount)
                            {
                                RenderItemCount++;
                            }
                        }
                    }
                }
            }

            return(listItem.RenderGeneralLink(linkItem, this.ID, useFieldGutter));
        }
Пример #8
0
        protected virtual string GetFieldGutterHtml(FieldGutterArgs args)
        {
            if (args == null || args.InnerItem.IsNull())
            {
                return(string.Empty);
            }

            IFieldGutterProcessor fieldGutterProcessor = FieldGutterProcessorFactory.GetProcessor();

            if (fieldGutterProcessor == null)
            {
                return(string.Empty);
            }

            string fieldGutterHtml = fieldGutterProcessor.Process(args);

            if (string.IsNullOrEmpty(fieldGutterHtml))
            {
                return(string.Empty);
            }

            return(fieldGutterHtml);
        }
Пример #9
0
        protected virtual string GetFieldGutterHtml(Item item, string fieldId)
        {
            if (item.IsNull())
            {
                return(string.Format("<div id=\"{1}_fieldGutterDiv\" class=\"droplinkFieldGutterDiv\">{0}</div>", string.Empty, fieldId));
            }

            IFieldGutterProcessor fieldGutterProcessor = FieldGutterProcessorFactory.GetProcessor();

            if (fieldGutterProcessor == null)
            {
                return(string.Format("<div id=\"{1}_fieldGutterDiv\" class=\"droplinkFieldGutterDiv\">{0}</div>", string.Empty, fieldId));
            }

            string fieldGutterHtml = fieldGutterProcessor.Process(new FieldGutterArgs(item, fieldId));

            if (string.IsNullOrEmpty(fieldGutterHtml))
            {
                return(string.Format("<div id=\"{1}_fieldGutterDiv\" class=\"droplinkFieldGutterDiv\">{0}</div>", string.Empty, fieldId));
            }

            return(string.Format("<div id=\"{1}_fieldGutterDiv\" class=\"droplinkFieldGutterDiv\">{0}</div>", fieldGutterHtml, fieldId));
        }
Пример #10
0
        /// <summary>
        /// Renders an item
        /// </summary>
        /// <param name="itemId"></param>
        /// <returns></returns>
        public override string RenderItem(string itemId, bool selectedItem)
        {
            if (string.IsNullOrEmpty(itemId))
            {
                return(string.Empty);
            }

            FieldSuiteImageListItem listItem = new FieldSuiteImageListItem();
            Item item = Sitecore.Context.ContentDatabase.GetItem(itemId);

            if (item.IsNull())
            {
                return(listItem.RenderItemNotFound(itemId, this.ID));
            }

            //get interface item
            IFieldSuiteImage fieldSuiteImage = FieldSuiteImageFactory.GetFieldSuiteImage(item);

            if (fieldSuiteImage == null)
            {
                return(listItem.RenderItemConfigured(itemId, this.ID));
            }

            //set default
            string imageSrc = "/sitecore modules/shell/field suite/images/unknown.png";

            //set to image of the item
            if (!string.IsNullOrEmpty(fieldSuiteImage.ImageUrl))
            {
                //setup image and sitecore click event
                imageSrc = fieldSuiteImage.ImageUrl.ToLower();
            }

            //add thumbnail parameter
            string parameters = "w=125&h=125&thn=true&db=" + MasterDatabase.Name.ToLower();

            if (imageSrc.Contains("?"))
            {
                imageSrc += "&" + parameters;
            }
            else
            {
                imageSrc += "?" + parameters;
            }

            string titleText = string.Format("{0}: {1}", item.Name, item.Paths.FullPath);

            //if the form is readonly
            string onclick = "";

            if (!this.ReadOnly)
            {
                onclick = string.Format("javascript:FieldSuite.Fields.ImagesField.ToggleItem(this, '{0}');", this.ID);
            }

            //setup description
            string description = string.Empty;

            if (!string.IsNullOrEmpty(fieldSuiteImage.Title))
            {
                description = fieldSuiteImage.Title;
                if (description.Length > 13)
                {
                    description = description.Substring(0, 13) + "...";
                }
            }

            listItem.Text       = description;
            listItem.HoverText  = titleText;
            listItem.ReadOnly   = this.ReadOnly;
            listItem.ItemClick  = onclick;
            listItem.Parameters = new List <object>();
            listItem.Parameters.Add(string.Format("<img border=\"0\" src=\"{0}\">", imageSrc));

            //for performance reason limit field gutter
            Int32 renderCount = RenderItemCount;

            if (selectedItem)
            {
                renderCount = RenderSelectedItemCount;
            }

            //for performance reason limit field gutter
            bool useFieldGutter = false;
            IFieldGutterProcessor fieldGutterProcessor = FieldGutterProcessorFactory.GetProcessor();

            if (fieldGutterProcessor != null)
            {
                Int32 maxCount = fieldGutterProcessor.MaxCount;
                if (maxCount != 0 && renderCount <= maxCount)
                {
                    useFieldGutter = true;
                }
            }

            //return list item as html
            if (selectedItem)
            {
                RenderSelectedItemCount++;
            }
            else
            {
                RenderItemCount++;
            }

            return(listItem.Render(item, item.ID.ToString(), this.ID, useFieldGutter));
        }
Пример #11
0
        /// <summary>
        /// Renders the list item as Html
        /// </summary>
        /// <param name="linkItem"></param>
        /// <param name="fieldId"></param>
        /// <param name="useFieldGutter"></param>
        /// <returns></returns>
        public virtual string RenderGeneralLink(GeneralLinkItem linkItem, string fieldId, bool useFieldGutter)
        {
            //disable items if the form is read only)
            if (ReadOnly)
            {
                ItemClick   = string.Empty;
                ButtonClick = string.Empty;
            }

            string templateName = string.Empty;
            string icon         = string.Empty;
            Item   item         = null;

            if (!string.IsNullOrEmpty(linkItem.Id) && ID.IsID(linkItem.Id))
            {
                Database db = Database.GetDatabase("master");
                if (db != null)
                {
                    item = db.GetItem(linkItem.Id);
                    if (item.IsNotNull())
                    {
                        icon = item.Appearance.Icon;

                        TemplateItem template = item.Template;
                        if (!string.IsNullOrEmpty(template.Name))
                        {
                            templateName = template.Name;
                        }
                    }
                }
            }

            //external link
            if (linkItem.LinkType == GeneralLinkItem.ExternalLinkType)
            {
                templateName = GeneralLinkItem.ExternalLinkType;
                icon         = GeneralLinkItem.ExternalLinkIcon;
            }

            //javascript link
            if (linkItem.LinkType == GeneralLinkItem.JavascriptLinkType)
            {
                templateName = GeneralLinkItem.JavascriptLinkType;
                icon         = GeneralLinkItem.JavascriptLinkIcon;
            }

            //mail link
            if (linkItem.LinkType == GeneralLinkItem.MailLinkType)
            {
                templateName = GeneralLinkItem.MailLinkType;
                icon         = GeneralLinkItem.MailLinkIcon;
            }

            //anchor link
            if (linkItem.LinkType == GeneralLinkItem.AnchorLinkType)
            {
                templateName = GeneralLinkItem.AnchorLinkType;
                icon         = GeneralLinkItem.AnchorLinkIcon;
            }

            string sitecoreId = string.Empty;

            if (linkItem.LinkType == GeneralLinkItem.InternalLinkType || linkItem.LinkType == GeneralLinkItem.MediaLinkType)
            {
                sitecoreId = linkItem.Id;
            }

            string fieldGutterHtml = string.Format("<div class=\"fieldGutter\">{0}</div>", Images.GetSpacer(16, 16));

            if (useFieldGutter)
            {
                if (item.IsNotNull())
                {
                    IFieldGutterProcessor fieldGutterProcessor = FieldGutterProcessorFactory.GetProcessor();
                    if (fieldGutterProcessor != null)
                    {
                        string html = fieldGutterProcessor.Process(new FieldGutterArgs(item, fieldId));
                        if (!string.IsNullOrEmpty(html))
                        {
                            fieldGutterHtml = html;
                        }
                    }
                }
            }

            return(string.Format(HtmlTemplate,
                                 linkItem.LinkId,
                                 fieldGutterHtml,
                                 fieldId,
                                 AddRemoveHtml(ButtonClick, Images.GetSpacer(16, 16)),
                                 templateName,
                                 Images.GetImage(icon, 0x10, 0x10, "absmiddle", "0px 4px 0px 0px", templateName),
                                 Text,
                                 HoverText,
                                 ItemClick,
                                 SelectedClass,
                                 sitecoreId));
        }