Ejemplo n.º 1
0
        public string BuildUrl(SafeDictionary <string> attributes = null)
        {
            if (attributes == null)
            {
                attributes = new SafeDictionary <string>();
            }

            Func <string, Func <string>, string> getValue = (key, func) =>
            {
                var value = attributes[key] ?? func();
                attributes.Remove(key);
                return(value);
            };

            var url = Url;

            if (Type == LinkType.Anchor)
            {
                url = string.Empty;
            }

            UrlBuilder builder = new UrlBuilder(url);

            var query  = getValue("query", () => Query);
            var anchor = getValue("anchor", () => Anchor);

            if (query.IsNotNullOrEmpty())
            {
                builder.AddQueryString(query);
            }

            return(UrlFormat.Formatted(builder.ToString(), anchor.IsNullOrEmpty() ? "" : "#" + anchor));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Render HTML for a link
        /// </summary>
        /// <param name="link">The link to render</param>
        /// <param name="attributes">Addtiional attributes to add. Do not include href or title</param>
        /// <param name="contents">Content to go in the link instead of the standard text</param>
        /// <returns>An "a" HTML element</returns>
        public static RenderingResult BeginRenderLink(Fields.Link link, NameValueCollection attributes, string contents, TextWriter writer)
        {
            if (link == null)
            {
                return(new RenderingResult(writer, string.Empty, string.Empty));
            }
            if (attributes == null)
            {
                attributes = new NameValueCollection();
            }


            string format = "<a href='{0}{1}' {2}>{3}";

            contents = contents == null ? link.Text ?? link.Title : contents;


            Func <string, Func <string>, string> getValue = (key, func) =>
            {
                var value = attributes.AllKeys.Any(x => x == key) ? attributes[key] : func();
                attributes.Remove(key);
                return(value);
            };

            UrlBuilder builder = new UrlBuilder(link.Url);

            var query  = getValue("query", () => link.Query);
            var anchor = getValue("anchor", () => link.Anchor);



            if (query.IsNotNullOrEmpty())
            {
                builder.AddQueryString(query);
            }

            AttributeCheck(attributes, "class", link.Class);
            AttributeCheck(attributes, "target", link.Target);
            AttributeCheck(attributes, "title", link.Title);

            string firstPart = format.Formatted(builder.ToString(), anchor.IsNullOrEmpty() ? "" : "#" + anchor, Utilities.ConvertAttributes(attributes), contents);
            string lastPart  = "</a>";

            return(new RenderingResult(writer, firstPart, lastPart));
        }
Ejemplo n.º 3
0
        public string BuildUrl(NameValueCollection attributes = null)
        {
            Func <string, Func <string>, string> getValue = (key, func) =>
            {
                var value = attributes.AllKeys.Any(x => x == key) ? attributes[key] : func();
                attributes.Remove(key);
                return(value);
            };

            UrlBuilder builder = new UrlBuilder(Url);

            var query  = getValue("query", () => Query);
            var anchor = getValue("anchor", () => Anchor);

            if (query.IsNotNullOrEmpty())
            {
                builder.AddQueryString(query);
            }

            return(UrlFormat.Formatted(builder.ToString(), anchor.IsNullOrEmpty() ? "" : "#" + anchor));
        }
Ejemplo n.º 4
0
        public string BuildUrl(NameValueCollection attributes = null)
        {

            Func<string, Func<string>, string> getValue = (key, func) =>
            {
                var value = attributes.AllKeys.Any(x => x == key) ? attributes[key] : func();
                attributes.Remove(key);
                return value;
            };

            UrlBuilder builder = new UrlBuilder(Url);

            var query = getValue("query", () => Query);
            var anchor = getValue("anchor", () => Anchor);
            
            if (query.IsNotNullOrEmpty())
                builder.AddQueryString(query);

            return UrlFormat.Formatted(builder.ToString(), anchor.IsNullOrEmpty() ? "" : "#" + anchor);
        }
Ejemplo n.º 5
0
        private void RenderFolderCreator(HtmlTextWriter writer)
        {
            var controlMode = SPContext.Current.FormContext.FormMode;

            writer.AddAttribute(HtmlTextWriterAttribute.Id, "part1");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-formtable");
            writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
            writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
            writer.AddStyleAttribute(HtmlTextWriterStyle.MarginTop, "8px");
            writer.RenderBeginTag(HtmlTextWriterTag.Table);

            writer.RenderBeginTag(HtmlTextWriterTag.Tr);

            // Td
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-formlabel");
            writer.AddAttribute(HtmlTextWriterAttribute.Width, "190px");
            writer.AddAttribute(HtmlTextWriterAttribute.Valign, "top");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-standardheader");
            writer.RenderBeginTag(HtmlTextWriterTag.H3);

            writer.Write("Name");

            if (controlMode != SPControlMode.Display)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Title, "This is a required field.");
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-formvalidation");
                writer.RenderBeginTag(HtmlTextWriterTag.Span);
                writer.Write(" *");
                writer.RenderEndTag(); // span
            }

            writer.RenderEndTag(); // h3
            writer.RenderEndTag(); // td

            // Td
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-formbody");
            writer.AddAttribute(HtmlTextWriterAttribute.Valign, "top");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            SPListItem folder = null;

            if (controlMode != SPControlMode.New)
            {
                folder = SPContext.Current.List.GetItemById(Convert.ToInt32(Page.Request.QueryString["ID"]));
            }

            if (controlMode == SPControlMode.Display)
            {
                var viewUrl = Page.Request.QueryString["Source"];
                if (string.IsNullOrEmpty(viewUrl))
                {
                    viewUrl = SPContext.Current.List.DefaultViewUrl;
                }

                var urlBuilder = new UrlBuilder(viewUrl);
                urlBuilder.ClearQueryString();
                // ReSharper disable PossibleNullReferenceException
                urlBuilder.AddQueryString("RootFolder", folder.Folder.ServerRelativeUrl);
                // ReSharper restore PossibleNullReferenceException

                writer.AddAttribute(HtmlTextWriterAttribute.Rel, "sp_DialogLinkNavigate");
                writer.AddAttribute(HtmlTextWriterAttribute.Href, urlBuilder.ToString());
                writer.RenderBeginTag(HtmlTextWriterTag.A);
                writer.Write(SPEncode.HtmlEncode(folder.Name));
                writer.RenderEndTag(); // a
            }
            else
            {
                writer.RenderBeginTag(HtmlTextWriterTag.Span);

                if (!Page.IsPostBack && SPContext.Current.FormContext.FormMode == SPControlMode.Edit)
                {
                    // ReSharper disable PossibleNullReferenceException
                    writer.AddAttribute(HtmlTextWriterAttribute.Value, folder.Name);
                    // ReSharper restore PossibleNullReferenceException
                }
                else
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Value, folderName);
                }

                writer.AddAttribute(HtmlTextWriterAttribute.Title, "Name");
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-long");
                writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID + "$onetidIOFile");
                writer.RenderBeginTag(HtmlTextWriterTag.Input);

                if (!IsValid)
                {
                    writer.Write("<br/>");
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-formvalidation");
                    writer.RenderBeginTag(HtmlTextWriterTag.Span);

                    writer.AddAttribute("role", "alert");
                    writer.RenderBeginTag(HtmlTextWriterTag.Span);
                    writer.Write(ErrorMessage);
                    writer.RenderEndTag(); // span
                    writer.RenderEndTag(); // span
                }

                writer.RenderEndTag(); // input

                writer.RenderEndTag(); // span
            }

            writer.RenderEndTag(); // td

            writer.RenderEndTag(); // tr

            writer.RenderEndTag(); // table

            // Table
            writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
            writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
            writer.RenderBeginTag(HtmlTextWriterTag.Table);
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);

            writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-formline");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            writer.Write("<img width=\"1\" height=\"1\" alt=\"\" src=\"/_layouts/15/images/blank.gif\" complete=\"complete\"/>");
            writer.RenderEndTag(); // td

            writer.RenderEndTag(); // tr
            writer.RenderEndTag(); // table

            // Table
            writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
            writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
            writer.AddStyleAttribute(HtmlTextWriterStyle.PaddingTop, "7px");
            writer.RenderBeginTag(HtmlTextWriterTag.Table);
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);

            writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            // Table
            writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-formtoolbar");
            writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "2");
            writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
            writer.RenderBeginTag(HtmlTextWriterTag.Table);
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);

            // Td
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            if (controlMode == SPControlMode.New)
            {
                writer.Write("&nbsp;");
            }
            else
            {
                createdModifiedInfo.ControlMode = controlMode;
                createdModifiedInfo.RenderControl(writer);
            }
            writer.RenderEndTag(); // td

            // Td
            writer.AddAttribute(HtmlTextWriterAttribute.Width, "99%");
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-toolbar");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            writer.Write("<img width=\"1\" height=\"18\" alt=\"\" src=\"/_layouts/15/images/blank.gif\" complete=\"complete\"/>");
            writer.RenderEndTag(); // td

            if (controlMode == SPControlMode.Display)
            {
                // Td
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-toolbar");
                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                RenderButton(writer, "Close", "C", "SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.cancel, null);");
                writer.RenderEndTag(); // td
            }
            else
            {
                // Td
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-toolbar");
                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                RenderButton(writer, "Save", "O", Page.ClientScript.GetPostBackEventReference(this, "ADD_OR_EDIT_FOLDER"));
                writer.RenderEndTag(); // td

                // Td
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-separator");
                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                writer.Write("&nbsp;");
                writer.RenderEndTag(); // td

                // Td
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-toolbar");
                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                RenderButton(writer, "Cancel", "C", "SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.cancel, null);");
                writer.RenderEndTag(); // td
            }

            writer.RenderEndTag(); // tr
            writer.RenderEndTag(); // table

            writer.RenderEndTag(); // td

            writer.RenderEndTag(); // tr
            writer.RenderEndTag(); // table

            writer.RenderEndTag(); // div

            writer.AddAttribute(HtmlTextWriterAttribute.Type, "text/javascript");
            writer.RenderBeginTag(HtmlTextWriterTag.Script);
            writer.Write("SetUploadPageTitle();");
            writer.RenderEndTag(); // script
        }
Ejemplo n.º 6
0
        protected override string GetDisplayItemLink(DataRow item, out bool showItemIndialog)
        {
            var web = SPContext.Current.Web;
            var rawUrl = SPEncode.UrlEncode(Page.Request.RawUrl);

            switch (List.BaseTemplate)
            {
                case SPListTemplateType.DiscussionBoard:
                    var discussionList = web.Lists[new Guid(item["ListId"].ToString())];
                    var discussionItem = discussionList.GetItemById(Convert.ToInt32(item["ID"]));
                    var rootFolder = SPEncode.UrlEncode(web.ServerRelativeUrl.TrimEnd('/') + "/" + discussionItem.Url);
                    showItemIndialog = false;
                    return string.Format("{0}/{1}/Flat.aspx?RootFolder={2}", web.Url, discussionList.RootFolder.Url, rootFolder);
                default:
                    var type = item["Item Type"].ToString();
                    if (type == "1;#")
                    {
                        showItemIndialog = false;
                        var urlBuilder = new UrlBuilder(Page.Request.Url);
                        urlBuilder.ClearQueryString();
                        urlBuilder.AddQueryString("RootFolder", item["ServerUrl"].ToString());
                        return urlBuilder.ToString();
                    }

                    showItemIndialog = true;
                    return string.Format("{0}/_layouts/listform.aspx?PageType=4&ListId={1}&ID={2}&Source={3}",
                                         web.Url, item["ListId"], item["ID"], rawUrl);
            }
        }
Ejemplo n.º 7
0
        private void RegisterListTab()
        {
            var lcid = Thread.CurrentThread.CurrentUICulture.LCID;

            var listTab = new RibbonTab("VP.Sharepoint.CQ.Core.Ribbon.Tabs.List")
                              {
                                  Title = LocalizationHelper.GetStringFromCoreResource("cui_TabList"),
                                  Sequence = 500
                              };

            var viewFormatGroup =
                new RibbonGroup("VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Groups.ViewFormat")
                    {
                        Sequence = 10,
                        Title = LocalizationHelper.GetStringFromCoreResource("cui_GrpViewFormat"),
                        Image32By32Popup = string.Format("/_layouts/{0}/images/formatmap32x32.png", lcid),
                        Image32By32PopupLeft = -256,
                        Image32By32PopupTop = -256,
                        GroupTemplate = RibbonGroupTemplate.Flexible2
                    };
            viewFormatGroup.MaxSizes.Add(new RibbonMaxSize("Ribbon.List.Scaling.ViewFormat.MaxSize")
                                             {Sequence = 10, Group = viewFormatGroup, Size = RibbonSize.LargeLarge});
            viewFormatGroup.Scales.Add(new RibbonScale("Ribbon.List.Scaling.ViewFormat.Popup")
                                           {Sequence = 240, Group = viewFormatGroup, Size = RibbonSize.Popup});
            listTab.Groups.Add(viewFormatGroup);
            RegisterRibbonControls(viewFormatGroup);

            var btnStandard =
                new RibbonButton(
                    "VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Groups.ViewFormat.Controls.Standard")
                    {
                        Sequence = 10,
                        LabelText = LocalizationHelper.GetStringFromCoreResource("cui_ButStandardView"),
                        Image16By16 = string.Format("/_layouts/{0}/images/formatmap16x16.png", lcid),
                        Image16By16Top = -32,
                        Image16By16Left = -144,
                        Image32By32 = string.Format("/_layouts/{0}/images/formatmap32x32.png", lcid),
                        Image32By32Top = -256,
                        Image32By32Left = -256,
                        ToolTipTitle = LocalizationHelper.GetStringFromCoreResource("cui_ButStandardView"),
                        ToolTipDescription = LocalizationHelper.GetStringFromCoreResource("cui_STT_ButStandardView"),
                        TemplateAlias = "c1",
                    };
            viewFormatGroup.Controls.Add(btnStandard);

            var btnDatasheet =
                new RibbonButton(
                    "VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Groups.ViewFormat.Controls.Datasheet")
                    {
                        Sequence = 10,
                        LabelText = LocalizationHelper.GetStringFromCoreResource("cui_ButDataSheetView"),
                        Image16By16 = string.Format("/_layouts/{0}/images/formatmap16x16.png", lcid),
                        Image16By16Top = -48,
                        Image16By16Left = -144,
                        Image32By32 = string.Format("/_layouts/{0}/images/formatmap32x32.png", lcid),
                        Image32By32Top = 0,
                        Image32By32Left = -288,
                        ToolTipTitle = LocalizationHelper.GetStringFromCoreResource("cui_ButDataSheetView"),
                        ToolTipDescription = LocalizationHelper.GetStringFromCoreResource("cui_STT_ButDatasheetView"),
                        TemplateAlias = "c1",
                    };
            viewFormatGroup.Controls.Add(btnDatasheet);

            var datasheetGroup =
                new RibbonGroup("VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Groups.Datasheet")
                    {
                        Sequence = 20,
                        Title = LocalizationHelper.GetStringFromCoreResource("cui_GrpDatasheet"),
                        Image32By32Popup = string.Format("/_layouts/{0}/images/formatmap32x32.png", lcid),
                        Image32By32PopupLeft = -448,
                        Image32By32PopupTop = -256,
                        GroupTemplate = RibbonGroupTemplate.Flexible2
                    };
            viewFormatGroup.MaxSizes.Add(new RibbonMaxSize("Ribbon.List.Scaling.Datasheet.MaxSize")
                                             {Sequence = 20, Group = datasheetGroup, Size = RibbonSize.LargeMedium});
            viewFormatGroup.Scales.Add(new RibbonScale("Ribbon.List.Scaling.Datasheet.LargeSmall")
                                           {Sequence = 90, Group = datasheetGroup, Size = RibbonSize.LargeSmall});
            viewFormatGroup.Scales.Add(new RibbonScale("Ribbon.List.Scaling.Datasheet.Popup")
                                           {Sequence = 170, Group = datasheetGroup, Size = RibbonSize.Popup});
            listTab.Groups.Add(datasheetGroup);
            RegisterRibbonControls(datasheetGroup);

            var btnNewRow =
                new RibbonButton(
                    "VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Groups.Datasheet.Controls.NewRow")
                    {
                        Sequence = 10,
                        LabelText = LocalizationHelper.GetStringFromCoreResource("cui_ButNewRow"),
                        Image16By16 = string.Format("/_layouts/{0}/images/formatmap16x16.png", lcid),
                        Image16By16Top = -80,
                        Image16By16Left = -192,
                        Image32By32 = string.Format("/_layouts/{0}/images/formatmap32x32.png", lcid),
                        Image32By32Top = -160,
                        Image32By32Left = -384,
                        ToolTipTitle = LocalizationHelper.GetStringFromCoreResource("cui_ButNewRow"),
                        ToolTipDescription = LocalizationHelper.GetStringFromCoreResource("cui_STT_ButNewRow"),
                        TemplateAlias = "c1",
                    };
            datasheetGroup.Controls.Add(btnNewRow);

            var btnShowTaskPane =
                new RibbonButton(
                    "VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Groups.Datasheet.Controls.ShowTaskPane")
                    {
                        Sequence = 20,
                        LabelText = "",
                        Image16By16 = string.Format("/_layouts/{0}/images/formatmap16x16.png", lcid),
                        Image16By16Top = -16,
                        Image16By16Left = -152,
                        Image32By32 = string.Format("/_layouts/{0}/images/formatmap32x32.png", lcid),
                        Image32By32Top = -256,
                        Image32By32Left = -224,
                        ToolTipTitle = LocalizationHelper.GetStringFromCoreResource("cui_ButShowTaskPane"),
                        ToolTipDescription = LocalizationHelper.GetStringFromCoreResource("cui_STT_ButShowTaskPane"),
                        TemplateAlias = "c2",
                    };
            datasheetGroup.Controls.Add(btnShowTaskPane);

            var btnShowTotals =
                new RibbonButton(
                    "VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Groups.Datasheet.Controls.ShowTotals")
                    {
                        Sequence = 30,
                        LabelText = "",
                        Image16By16 = string.Format("/_layouts/{0}/images/formatmap16x16.png", lcid),
                        Image16By16Top = -240,
                        Image16By16Left = -224,
                        Image32By32 = string.Format("/_layouts/{0}/images/formatmap32x32.png", lcid),
                        Image32By32Top = -448,
                        Image32By32Left = -256,
                        ToolTipTitle = LocalizationHelper.GetStringFromCoreResource("cui_ButShowTotals"),
                        ToolTipDescription = LocalizationHelper.GetStringFromCoreResource("cui_STT_ButShowTotals"),
                        TemplateAlias = "c2",
                    };
            datasheetGroup.Controls.Add(btnShowTotals);

            var btnRefreshData =
                new RibbonButton(
                    "VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Groups.Datasheet.Controls.RefreshData")
                    {
                        Sequence = 40,
                        LabelText = "",
                        Image16By16 = string.Format("/_layouts/{0}/images/formatmap16x16.png", lcid),
                        Image16By16Top = -240,
                        Image16By16Left = -208,
                        Image32By32 = string.Format("/_layouts/{0}/images/formatmap32x32.png", lcid),
                        Image32By32Top = -448,
                        Image32By32Left = -224,
                        ToolTipTitle = LocalizationHelper.GetStringFromCoreResource("cui_ButRefreshData"),
                        ToolTipDescription = LocalizationHelper.GetStringFromCoreResource("cui_STT_ButRefreshData"),
                        TemplateAlias = "c2",
                    };
            datasheetGroup.Controls.Add(btnRefreshData);

            var customViewsGroup =
                new RibbonGroup("VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Groups.CustomViews")
                    {
                        Sequence = 40,
                        Title = LocalizationHelper.GetStringFromCoreResource("cui_GrpManageViews"),
                        Image32By32Popup = string.Format("/_layouts/{0}/images/formatmap32x32.png", lcid),
                        Image32By32PopupLeft = -352,
                        Image32By32PopupTop = -320,
                        GroupTemplate = RibbonGroupTemplate.ManageViewsGroup
                    };
            customViewsGroup.MaxSizes.Add(new RibbonMaxSize("Ribbon.List.Scaling.CustomViews.MaxSize")
                                              {Sequence = 40, Group = customViewsGroup, Size = RibbonSize.LargeMedium});
            customViewsGroup.Scales.Add(new RibbonScale("Ribbon.List.Scaling.CustomViews.LargeSmall")
                                            {Sequence = 160, Group = customViewsGroup, Size = RibbonSize.LargeSmall});
            customViewsGroup.Scales.Add(new RibbonScale("Ribbon.List.Scaling.CustomViews.Popup")
                                            {Sequence = 220, Group = customViewsGroup, Size = RibbonSize.Popup});
            listTab.Groups.Add(customViewsGroup);
            RegisterRibbonControls(customViewsGroup);

            var btnCreateView =
                new RibbonButton(
                    "VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Groups.CustomViews.Controls.CreateView")
                    {
                        Sequence = 10,
                        LabelText = LocalizationHelper.GetStringFromCoreResource("cui_ButCreateView"),
                        Image16By16 = string.Format("/_layouts/{0}/images/formatmap16x16.png", lcid),
                        Image16By16Top = -48,
                        Image16By16Left = -192,
                        Image32By32 = string.Format("/_layouts/{0}/images/formatmap32x32.png", lcid),
                        Image32By32Top = -352,
                        Image32By32Left = -352,
                        ToolTipTitle = LocalizationHelper.GetStringFromCoreResource("cui_ButCreateView"),
                        ToolTipDescription = LocalizationHelper.GetStringFromCoreResource("cui_STT_ButCreateView"),
                        TemplateAlias = "c1",
                    };
            customViewsGroup.Controls.Add(btnCreateView);

            var btnModifyView =
                new RibbonButton(
                    "VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Groups.CustomViews.Controls.ModifyView")
                    {
                        Sequence = 20,
                        LabelText = LocalizationHelper.GetStringFromCoreResource("cui_ButModifyThisView"),
                        Image16By16 = string.Format("/_layouts/{0}/images/formatmap16x16.png", lcid),
                        Image16By16Top = -32,
                        Image16By16Left = -192,
                        Image32By32 = string.Format("/_layouts/{0}/images/formatmap32x32.png", lcid),
                        Image32By32Top = -352,
                        Image32By32Left = -320,
                        ToolTipTitle = LocalizationHelper.GetStringFromCoreResource("cui_ButModifyThisView"),
                        ToolTipDescription = LocalizationHelper.GetStringFromCoreResource("cui_STT_ButModifyThisView"),
                        TemplateAlias = "c2",
                    };
            customViewsGroup.Controls.Add(btnModifyView);

            var btnCreateColumn =
                new RibbonButton(
                    "VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Groups.CustomViews.Controls.CreateColumn")
                    {
                        Sequence = 30,
                        LabelText = LocalizationHelper.GetStringFromCoreResource("cui_ButCreateColumn"),
                        Image16By16 = string.Format("/_layouts/{0}/images/formatmap16x16.png", lcid),
                        Image16By16Top = -144,
                        Image16By16Left = -176,
                        Image32By32 = string.Format("/_layouts/{0}/images/formatmap32x32.png", lcid),
                        Image32By32Top = -96,
                        Image32By32Left = -352,
                        ToolTipTitle = LocalizationHelper.GetStringFromCoreResource("cui_ButCreateColumn"),
                        ToolTipDescription = LocalizationHelper.GetStringFromCoreResource("cui_STT_ButCreateColumn"),
                        TemplateAlias = "c2",
                    };
            customViewsGroup.Controls.Add(btnCreateColumn);

            var btnNavigateUp =
                new RibbonButton(
                    "VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Groups.CustomViews.Controls.NavigateUp")
                    {
                        Sequence = 30,
                        LabelText = LocalizationHelper.GetStringFromCoreResource("cui_ButNavigateUp"),
                        Image16By16 = string.Format("/_layouts/{0}/images/formatmap16x16.png", lcid),
                        Image16By16Top = 0,
                        Image16By16Left = -56,
                        Image32By32 = string.Format("/_layouts/{0}/images/formatmap32x32.png", lcid),
                        Image32By32Top = -64,
                        Image32By32Left = 0,
                        ToolTipTitle = LocalizationHelper.GetStringFromCoreResource("cui_ButNavigateUp"),
                        ToolTipDescription = LocalizationHelper.GetStringFromCoreResource("cui_STT_ButNavigateUp"),
                        TemplateAlias = "c2",
                    };

            var rootFolder = Page.Request.QueryString["RootFolder"];
            if (!string.IsNullOrEmpty(rootFolder))
            {
                var folder = SPContext.Current.Web.GetFolder(rootFolder);
                if (folder.ParentFolder != null && folder.UniqueId != List.RootFolder.UniqueId)
                {
                    var urlBuilder = new UrlBuilder(Page.Request.RawUrl);
                    urlBuilder.AddQueryString("RootFolder", folder.ParentFolder.ServerRelativeUrl);
                    urlBuilder.RemoveAllFilterQueryString();
                    urlBuilder.RemoveQueryString("Source");

                    btnNavigateUp.Command =
                        new SPRibbonCommand("VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Commands.NavigateUp",
                            string.Format("window.location = '{0}';", urlBuilder));
                }
            }

            customViewsGroup.Controls.Add(btnNavigateUp);

            var shareGroup = new RibbonGroup("VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Groups.Share")
                                 {
                                     Sequence = 50,
                                     Title = LocalizationHelper.GetStringFromCoreResource("cui_GrpShare"),
                                     Image32By32Popup = string.Format("/_layouts/{0}/images/formatmap32x32.png", lcid),
                                     Image32By32PopupLeft = -448,
                                     Image32By32PopupTop = -256,
                                     GroupTemplate = RibbonGroupTemplate.Flexible2
                                 };
            shareGroup.MaxSizes.Add(new RibbonMaxSize("Ribbon.List.Scaling.Share.MaxSize")
                                        {Sequence = 40, Group = shareGroup, Size = RibbonSize.LargeLarge});
            shareGroup.Scales.Add(new RibbonScale("Ribbon.List.Scaling.Share.MediumMedium")
                                      {Sequence = 90, Group = shareGroup, Size = RibbonSize.MediumMedium});
            shareGroup.Scales.Add(new RibbonScale("Ribbon.List.Scaling.Share.Popup")
                                      {Sequence = 170, Group = shareGroup, Size = RibbonSize.Popup});
            listTab.Groups.Add(shareGroup);
            RegisterRibbonControls(shareGroup);

            var handlerStatement = new StringBuilder();
            handlerStatement.AppendFormat("window.location = 'mailto:?body={0}';", DataViewUtils.Escape(Page.Request.Url.OriginalString));

            var btnEmailLibraryLink =
                new RibbonButton(
                    "VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Groups.Share.Controls.EmailLibraryLink")
                    {
                        Sequence = 10,
                        LabelText = LocalizationHelper.GetStringFromCoreResource("cui_ButEmailLink"),
                        Image16By16 = string.Format("/_layouts/{0}/images/formatmap16x16.png", lcid),
                        Image16By16Top = -16,
                        Image16By16Left = -88,
                        Image32By32 = string.Format("/_layouts/{0}/images/formatmap32x32.png", lcid),
                        Image32By32Top = -128,
                        Image32By32Left = -448,
                        ToolTipTitle = LocalizationHelper.GetStringFromCoreResource("cui_ButEmailLink"),
                        ToolTipDescription = LocalizationHelper.GetStringFromCoreResource("cui_STT_ButEmailLinkList"),
                        Command =
                            new SPRibbonCommand(
                            "VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Commands.EmailLibraryLink",
                            handlerStatement.ToString()),
                        TemplateAlias = "c1",
                    };
            shareGroup.Controls.Add(btnEmailLibraryLink);

            handlerStatement = new StringBuilder();
            handlerStatement.AppendFormat("window.location = '{0}/_layouts/listfeed.aspx?List={1}';",
                                          Utilities.GetWebUrl(SPContext.Current.Web.Url), List.ID);

            var btnViewRssFeed =
                new RibbonButton(
                    "VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Groups.Share.Controls.ViewRSSFeed")
                    {
                        Sequence = 30,
                        LabelText = LocalizationHelper.GetStringFromCoreResource("cui_ButViewRSSFeed"),
                        Image16By16 = string.Format("/_layouts/{0}/images/formatmap16x16.png", lcid),
                        Image16By16Top = -128,
                        Image16By16Left = -112,
                        Image32By32 = string.Format("/_layouts/{0}/images/formatmap32x32.png", lcid),
                        Image32By32Top = -224,
                        Image32By32Left = -128,
                        ToolTipTitle = LocalizationHelper.GetStringFromCoreResource("cui_ButViewRSSFeed"),
                        ToolTipDescription = LocalizationHelper.GetStringFromCoreResource("cui_STT_ButViewRSSFeedList"),
                        Command =
                            new SPRibbonCommand(
                            "VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Commands.ViewRSSFeed",
                            handlerStatement.ToString()),
                        TemplateAlias = "c1",
                    };
            shareGroup.Controls.Add(btnViewRssFeed);

            var actionsGroup =
                new RibbonGroup("VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Groups.Actions")
                {
                    Sequence = 60,
                    Title = LocalizationHelper.GetStringFromCoreResource("cui_GrpConnect"),
                    Image32By32Popup = string.Format("/_layouts/{0}/images/formatmap32x32.png", lcid),
                    Image32By32PopupLeft = -224,
                    Image32By32PopupTop = -288,
                    GroupTemplate = RibbonGroupTemplate.Flexible2
                };
            actionsGroup.MaxSizes.Add(new RibbonMaxSize("Ribbon.List.Scaling.Actions.MaxSize") { Sequence = 50, Group = actionsGroup, Size = RibbonSize.LargeMedium });
            actionsGroup.Scales.Add(new RibbonScale("Ribbon.List.Scaling.Actions.MediumMedium") { Sequence = 120, Group = actionsGroup, Size = RibbonSize.MediumMedium });
            actionsGroup.Scales.Add(new RibbonScale("Ribbon.List.Scaling.Actions.MediumSmall") { Sequence = 140, Group = actionsGroup, Size = RibbonSize.MediumSmall });
            listTab.Groups.Add(actionsGroup);

            var btnTakeOfflineToClient =
                new RibbonButton(
                    "VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Groups.Actions.Controls.TakeOfflineToClient")
                {
                    Sequence = 20,
                    LabelText = LocalizationHelper.GetStringFromCoreResource("cui_ButSyncToComputer"),
                    Image16By16 = string.Format("/_layouts/{0}/images/formatmap16x16.png", lcid),
                    Image16By16Top = -160,
                    Image16By16Left = -176,
                    Image32By32 = string.Format("/_layouts/{0}/images/formatmap32x32.png", lcid),
                    Image32By32Top = -288,
                    Image32By32Left = -224,
                    ToolTipTitle = LocalizationHelper.GetStringFromCoreResource("cui_ButSyncToComputer"),
                    ToolTipDescription = LocalizationHelper.GetStringFromCoreResource("cui_STT_ButSyncListToComputer"),
                    TemplateAlias = "c1",
                };
            actionsGroup.Controls.Add(btnTakeOfflineToClient);

            var btnConnectToClient =
                new RibbonButton(
                    "VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Groups.Actions.Controls.ConnectToClient")
                {
                    Sequence = 30,
                    LabelText = LocalizationHelper.GetStringFromCoreResource("cui_ButConnectToClient"),
                    Image16By16 = string.Format("/_layouts/{0}/images/formatmap16x16.png", lcid),
                    Image16By16Top = 0,
                    Image16By16Left = -168,
                    Image32By32 = string.Format("/_layouts/{0}/images/formatmap32x32.png", lcid),
                    Image32By32Top = -128,
                    Image32By32Left = -352,
                    ToolTipTitle = LocalizationHelper.GetStringFromCoreResource("cui_ButConnectToClient"),
                    ToolTipDescription = LocalizationHelper.GetStringFromCoreResource("cui_STT_ButConnectToClient"),
                    TemplateAlias = "c1",
                };
            actionsGroup.Controls.Add(btnConnectToClient);

            var exportToSpreadsheetCommand = string.Format("window.location='{0}/_vti_bin/owssvr.dll?CS=65001&Using=_layouts/query.iqy&List={1}&View={2}&RootFolder={3}&CacheControl=1';", Utilities.GetWebUrl(SPContext.Current.Web.Url), List.ID, SPContext.Current.ViewContext.ViewId, List.RootFolder.Url);

            var btnExportToSpreadsheet =
                new RibbonButton(
                    "VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Groups.Actions.Controls.ExportToSpreadsheet")
                {
                    Sequence = 30,
                    LabelText = LocalizationHelper.GetStringFromCoreResource("cui_ButExportToSpreadsheet"),
                    Image16By16 = string.Format("/_layouts/{0}/images/formatmap16x16.png", lcid),
                    Image16By16Top = -152,
                    Image16By16Left = -32,
                    Image32By32 = string.Format("/_layouts/{0}/images/formatmap32x32.png", lcid),
                    Image32By32Top = -352,
                    Image32By32Left = 0,
                    ToolTipTitle = LocalizationHelper.GetStringFromCoreResource("cui_ButExportToSpreadsheet"),
                    ToolTipDescription = LocalizationHelper.GetStringFromCoreResource("cui_STT_ButExportListToSpreadsheet"),
                    TemplateAlias = "c1",
                    Command = new SPRibbonCommand("VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Commands.ExportToSpreadsheet", exportToSpreadsheetCommand, "true")
                };
            actionsGroup.Controls.Add(btnExportToSpreadsheet);

            var settingsGroup =
                new RibbonGroup("VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Groups.Settings")
                    {
                        Sequence = 80,
                        Title = LocalizationHelper.GetStringFromCoreResource("cui_GrpSettings"),
                        Image32By32Popup = string.Format("/_layouts/{0}/images/formatmap32x32.png", lcid),
                        Image32By32PopupLeft = 0,
                        Image32By32PopupTop = -384,
                        GroupTemplate = RibbonGroupTemplate.Flexible2
                    };
            settingsGroup.MaxSizes.Add(new RibbonMaxSize("Ribbon.List.Scaling.Settings.MaxSize")
                                           {Sequence = 70, Group = settingsGroup, Size = RibbonSize.LargeLarge});
            settingsGroup.Scales.Add(new RibbonScale("Ribbon.List.Scaling.Settings.LargeMedium")
                                         {Sequence = 100, Group = settingsGroup, Size = RibbonSize.LargeMedium});
            settingsGroup.Scales.Add(new RibbonScale("Ribbon.List.Scaling.Settings.LargeSmall")
                                         {Sequence = 130, Group = settingsGroup, Size = RibbonSize.LargeSmall});
            settingsGroup.Scales.Add(new RibbonScale("Ribbon.List.Scaling.Settings.Popup")
                                         {Sequence = 190, Group = settingsGroup, Size = RibbonSize.Popup});
            listTab.Groups.Add(settingsGroup);
            RegisterRibbonControls(settingsGroup);

            handlerStatement = new StringBuilder();
            handlerStatement.AppendFormat("window.location = '{0}/_layouts/listedit.aspx?List={1}';",
                                          Utilities.GetWebUrl(SPContext.Current.Web.Url), List.ID);

            var btnListSettings =
                new RibbonButton(
                    "VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Groups.Settings.Controls.ListSettings")
                    {
                        Sequence = 10,
                        LabelText = LocalizationHelper.GetStringFromCoreResource("cui_ButListSettings"),
                        Image16By16 = string.Format("/_layouts/{0}/images/formatmap16x16.png", lcid),
                        Image16By16Top = -64,
                        Image16By16Left = -192,
                        Image32By32 = string.Format("/_layouts/{0}/images/formatmap32x32.png", lcid),
                        Image32By32Top = 0,
                        Image32By32Left = -384,
                        ToolTipTitle = LocalizationHelper.GetStringFromCoreResource("cui_ButListSettings"),
                        ToolTipDescription = LocalizationHelper.GetStringFromCoreResource("cui_STT_ButListSettings"),
                        Command =
                            new SPRibbonCommand(
                            "VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Commands.ListSettings",
                            handlerStatement.ToString()),
                        TemplateAlias = "c1",
                    };
            settingsGroup.Controls.Add(btnListSettings);

            var btnListPermissions =
                new RibbonButton(
                    "VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Groups.Settings.Controls.ListPermissions")
                    {
                        Sequence = 20,
                        LabelText = LocalizationHelper.GetStringFromCoreResource("cui_ButListPermissions"),
                        Image16By16 = string.Format("/_layouts/{0}/images/formatmap16x16.png", lcid),
                        Image16By16Top = -128,
                        Image16By16Left = 0,
                        Image32By32 = string.Format("/_layouts/{0}/images/formatmap32x32.png", lcid),
                        Image32By32Top = 0,
                        Image32By32Left = -416,
                        ToolTipTitle = LocalizationHelper.GetStringFromCoreResource("cui_ButListPermissions"),
                        ToolTipDescription = LocalizationHelper.GetStringFromCoreResource("cui_STT_ButListPermissions"),
                        TemplateAlias = "c2",
                    };
            settingsGroup.Controls.Add(btnListPermissions);

            var btnManageWorkflows =
                new RibbonButton(
                    "VP.Sharepoint.CQ.Core.Ribbon.Tabs.List.Groups.Settings.Controls.ManageWorkflows")
                    {
                        Sequence = 30,
                        LabelText = LocalizationHelper.GetStringFromCoreResource("cui_ButManageWorkflow"),
                        Image16By16 = string.Format("/_layouts/{0}/images/formatmap16x16.png", lcid),
                        Image16By16Top = -112,
                        Image16By16Left = -112,
                        Image32By32 = string.Format("/_layouts/{0}/images/formatmap32x32.png", lcid),
                        Image32By32Top = -160,
                        Image32By32Left = -416,
                        ToolTipTitle = LocalizationHelper.GetStringFromCoreResource("cui_ButManageWorkflow"),
                        ToolTipDescription = LocalizationHelper.GetStringFromCoreResource("cui_STT_ButListManageWorkflow"),
                        TemplateAlias = "c2",
                    };
            settingsGroup.Controls.Add(btnManageWorkflows);

            // Register custom ribbon groups
            RegisterRibbonGroups(listTab);

            // Manual register group template
            ((BaseUserControl) NamingContainer).RegisterRibbonGroupTemplate(RibbonGroupTemplate.ManageViewsGroup);
            ((BaseUserControl) NamingContainer).RegisterRibbonTab(listTab, false);
            ((BaseUserControl) NamingContainer).LoadRibbonTab(listTab);
        }
Ejemplo n.º 8
0
        private void RenderFolderCreator(HtmlTextWriter writer)
        {
            var controlMode = SPContext.Current.FormContext.FormMode;

            writer.AddAttribute(HtmlTextWriterAttribute.Id, "part1");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-formtable");
            writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
            writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
            writer.AddStyleAttribute(HtmlTextWriterStyle.MarginTop, "8px");
            writer.RenderBeginTag(HtmlTextWriterTag.Table);

            writer.RenderBeginTag(HtmlTextWriterTag.Tr);

            // Td
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-formlabel");
            writer.AddAttribute(HtmlTextWriterAttribute.Width, "190px");
            writer.AddAttribute(HtmlTextWriterAttribute.Valign, "top");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-standardheader");
            writer.RenderBeginTag(HtmlTextWriterTag.H3);    

            writer.Write("Name");

            if (controlMode != SPControlMode.Display)
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Title, "This is a required field.");
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-formvalidation");
                writer.RenderBeginTag(HtmlTextWriterTag.Span);
                writer.Write(" *");
                writer.RenderEndTag(); // span    
            }

            writer.RenderEndTag(); // h3
            writer.RenderEndTag(); // td

            // Td
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-formbody");
            writer.AddAttribute(HtmlTextWriterAttribute.Valign, "top");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            SPListItem folder = null;
            if (controlMode != SPControlMode.New)
            {
                folder = SPContext.Current.List.GetItemById(Convert.ToInt32(Page.Request.QueryString["ID"], CultureInfo.InvariantCulture));    
            }

            if (controlMode == SPControlMode.Display)
            {
                var viewUrl = Page.Request.QueryString["Source"];
                if (string.IsNullOrEmpty(viewUrl))
                {
                    viewUrl = SPContext.Current.List.DefaultViewUrl;
                }

                var urlBuilder = new UrlBuilder(viewUrl);
                urlBuilder.ClearQueryString();
                urlBuilder.AddQueryString("RootFolder", folder.Folder.ServerRelativeUrl);
                
                writer.AddAttribute(HtmlTextWriterAttribute.Rel, "sp_DialogLinkNavigate");
                writer.AddAttribute(HtmlTextWriterAttribute.Href, urlBuilder.ToString());
                writer.RenderBeginTag(HtmlTextWriterTag.A);
                writer.Write(SPEncode.HtmlEncode(folder.Name));
                writer.RenderEndTag(); // a
            }
            else
            {
                writer.RenderBeginTag(HtmlTextWriterTag.Span);

                if (!Page.IsPostBack && SPContext.Current.FormContext.FormMode == SPControlMode.Edit)
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Value, folder.Name);
                }
                else
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Value, folderName);
                }

                writer.AddAttribute(HtmlTextWriterAttribute.Title, "Name");
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-long");
                writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID + "$onetidIOFile");
                writer.RenderBeginTag(HtmlTextWriterTag.Input);

                if (!IsValid)
                {
                    writer.Write("<br/>");
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-formvalidation");
                    writer.RenderBeginTag(HtmlTextWriterTag.Span);

                    writer.AddAttribute("role", "alert");
                    writer.RenderBeginTag(HtmlTextWriterTag.Span);
                    writer.Write(ErrorMessage);
                    writer.RenderEndTag(); // span
                    writer.RenderEndTag(); // span
                }

                writer.RenderEndTag(); // input

                writer.RenderEndTag(); // span
            }
            
            writer.RenderEndTag(); // td

            writer.RenderEndTag(); // tr

            writer.RenderEndTag(); // table

            // Table
            writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
            writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
            writer.RenderBeginTag(HtmlTextWriterTag.Table);
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);

            writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-formline");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            writer.Write("<img width=\"1\" height=\"1\" alt=\"\" src=\"/_layouts/images/blank.gif\" complete=\"complete\"/>");
            writer.RenderEndTag(); // td

            writer.RenderEndTag(); // tr
            writer.RenderEndTag(); // table

            // Table
            writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
            writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
            writer.AddStyleAttribute(HtmlTextWriterStyle.PaddingTop, "7px");
            writer.RenderBeginTag(HtmlTextWriterTag.Table);
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);

            writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);

            // Table
            writer.AddAttribute(HtmlTextWriterAttribute.Width, "100%");
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-formtoolbar");
            writer.AddAttribute(HtmlTextWriterAttribute.Cellpadding, "2");
            writer.AddAttribute(HtmlTextWriterAttribute.Cellspacing, "0");
            writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
            writer.RenderBeginTag(HtmlTextWriterTag.Table);
            writer.RenderBeginTag(HtmlTextWriterTag.Tr);

            // Td
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            if (controlMode == SPControlMode.New)
            {
                writer.Write("&nbsp;");
            }
            else
            {
                createdModifiedInfo.ControlMode = controlMode;
                createdModifiedInfo.RenderControl(writer);
            }
            writer.RenderEndTag(); // td

            // Td
            writer.AddAttribute(HtmlTextWriterAttribute.Width, "99%");
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-toolbar");
            writer.RenderBeginTag(HtmlTextWriterTag.Td);
            writer.Write("<img width=\"1\" height=\"18\" alt=\"\" src=\"/_layouts/images/blank.gif\" complete=\"complete\"/>");
            writer.RenderEndTag(); // td

            if (controlMode == SPControlMode.Display)
            {
                // Td
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-toolbar");
                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                RenderButton(writer, "Close", "C", "SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.cancel, null);");
                writer.RenderEndTag(); // td
            }
            else
            {
                // Td
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-toolbar");
                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                RenderButton(writer, "Save", "O", Page.ClientScript.GetPostBackEventReference(this, "ADD_OR_EDIT_FOLDER"));
                writer.RenderEndTag(); // td

                // Td
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-separator");
                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                writer.Write("&nbsp;");
                writer.RenderEndTag(); // td

                // Td
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "ms-toolbar");
                writer.RenderBeginTag(HtmlTextWriterTag.Td);
                RenderButton(writer, "Cancel", "C", "SP.UI.ModalDialog.commonModalDialogClose(SP.UI.DialogResult.cancel, null);");
                writer.RenderEndTag(); // td
            }

            writer.RenderEndTag(); // tr
            writer.RenderEndTag(); // table

            writer.RenderEndTag(); // td

            writer.RenderEndTag(); // tr
            writer.RenderEndTag(); // table

            writer.RenderEndTag(); // div

            writer.AddAttribute(HtmlTextWriterAttribute.Type, "text/javascript");
            writer.RenderBeginTag(HtmlTextWriterTag.Script);
            writer.Write("SetUploadPageTitle();");
            writer.RenderEndTag(); // script
        }