/// <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)); }
/// <summary> /// This method runs the source field builder as a modal /// </summary> /// <param name="args"></param> public void RunAddForm(ClientPipelineArgs args) { if (!args.IsPostBack) { //get url for field type selector modal UrlString ustr = new UrlString(UIUtil.GetUri("control:FieldSuiteAddForm")); ustr.Parameters.Add(args.Parameters); //open field type selector Context.ClientPage.ClientResponse.ShowModalDialog(ustr.ToString(), "500", "300", "", true); //wait for response args.WaitForPostBack(); } else { //verify result if (!args.HasResult || string.IsNullOrEmpty(args.Result)) { return; } string linkedItemId = args.Result; if (!ID.IsID(linkedItemId)) { return; } IFieldSuiteListItem listItem = GetListItem(linkedItemId, args.Parameters["fieldid"]); if (listItem == null) { listItem = new FieldSuiteImageListItem(); SheerResponse.Eval("FieldSuite.Fields.ImagesField.AddItemToContent(\"" + args.Parameters["fieldid"] + "\",\"" + HttpUtility.HtmlEncode(listItem.RenderItemNotFound(linkedItemId, args.Parameters["fieldid"])) + "\",\"" + linkedItemId + "\")"); return; } SheerResponse.Eval("FieldSuite.Fields.ImagesField.AddItemToContent(\"" + args.Parameters["fieldid"] + "\",\"" + HttpUtility.HtmlEncode(listItem.Render(linkedItemId, args.Parameters["fieldid"], true)) + "\",\"" + linkedItemId + "\")"); } }