/// <summary>
        /// Renders an item
        /// </summary>
        /// <param name="itemId"></param>
        /// <param name="selectedItem"></param>
        /// <returns></returns>
        public virtual string RenderItem(string itemId, bool selectedItem)
        {
            if (string.IsNullOrEmpty(itemId))
            {
                return string.Empty;
            }

            Item item = Sitecore.Context.ContentDatabase.GetItem(itemId);
            if (item.IsNull())
            {
                //return not found list item template
                FieldSuiteListItem listItem = new FieldSuiteListItem();
                listItem.ShowAddRemoveButton = true;
                return listItem.RenderItemNotFound(itemId, this.ID);
            }

            return RenderItem(item, selectedItem);
        }
Example #2
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));
                }
            }
        }
        /// <summary>
        /// Renders an item
        /// </summary>
        /// <param name="item"></param>
        /// <param name="selectedItem"></param>
        /// <returns></returns>
        public virtual string RenderItem(Item item, bool selectedItem)
        {
            FieldSuiteListItem listItem = new FieldSuiteListItem();
            if (item.IsNull())
            {
                //return not found list item template
                listItem.ShowAddRemoveButton = true;
                return listItem.RenderItemNotFound(item.ID.ToString(), this.ID);
            }

            listItem.ShowAddRemoveButton = true;
            listItem.ButtonClick = string.Format("FieldSuite.Fields.ToggleItem('{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 listItem.Render(item, item.ID.ToString(), this.ID, useFieldGutter);
        }