Exemplo n.º 1
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));
                }
            }
        }
Exemplo n.º 2
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);
        }
        /// <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);
        }