Beispiel #1
0
        /// <summary>
        /// Sends server control content to a provided <see cref="T:System.Web.UI.HtmlTextWriter" /> object, which writes the content to be rendered on the client.
        /// </summary>
        /// <param name="writer">The <see cref="T:System.Web.UI.HtmlTextWriter" /> object that receives the server control content.</param>
        protected override void Render([NotNull] HtmlTextWriter writer)
        {
            if (this.UserCanUpload)
            {
                // add popmenu Attachments to this mix...
                this.popMenuAttachments = new AttachmentsPopMenu();
                this.Controls.Add(this.popMenuAttachments);
            }

            writer.Write("<div class=\"btn-toolbar\" role=\"toolbar\">");
            writer.Write("<div class=\"btn-group\" role =\"group\">");

            RenderButton(writer, "setStyle('bold','')", this.GetText("COMMON", "TT_BOLD"), "bold");
            RenderButton(writer, "setStyle('italic','')", this.GetText("COMMON", "TT_ITALIC"), "italic");

            RenderButton(writer, "setStyle('underline','')", this.GetText("COMMON", "TT_UNDERLINE"), "underline");

            writer.Write("</div>");
            writer.Write("<div class=\"btn-group\" role =\"group\">");

            RenderButton(
                writer,
                "setStyle('highlight','')",
                this.GetText("COMMON", "TT_HIGHLIGHT"),
                "pencil-square-o");

            RenderButton(writer, "setStyle('quote','')", this.GetText("COMMON", "TT_QUOTE"), "quote-left");

            // add drop down for optional "extra" codes...
            writer.WriteLine(@"<div class=""btn-group"" role=""group""><button type=""button"" class=""btn btn-secondary btn-sm dropdown-toggle"" title=""{0}""
                       data-toggle=""dropdown"" aria-haspopup=""true"" aria-expanded=""false"">
                  <i class=""fa fa-code fa-fw""></i></button>".FormatWith(this.GetText("COMMON", "TT_CODE")));

            var highLightList = new List <HighLightList>
            {
                new HighLightList
                {
                    BrushAlias = "markup",
                    BrushName  = "Plain Text"
                },
                new HighLightList
                {
                    BrushAlias = "bash",
                    BrushName  = "Bash(shell)"
                },
                new HighLightList {
                    BrushAlias = "c", BrushName = "C"
                },
                new HighLightList {
                    BrushAlias = "cpp", BrushName = "C++"
                },
                new HighLightList
                {
                    BrushAlias = "csharp",
                    BrushName  = "C#"
                },
                new HighLightList {
                    BrushAlias = "css", BrushName = "CSS"
                },
                new HighLightList {
                    BrushAlias = "git", BrushName = "Git"
                },
                new HighLightList
                {
                    BrushAlias = "markup",
                    BrushName  = "HTML"
                },
                new HighLightList
                {
                    BrushAlias = "java",
                    BrushName  = "Java"
                },
                new HighLightList
                {
                    BrushAlias = "javascript",
                    BrushName  = "JavaScript"
                },
                new HighLightList
                {
                    BrushAlias = "python",
                    BrushName  = "Python"
                },
                new HighLightList {
                    BrushAlias = "sql", BrushName = "SQL"
                },
                new HighLightList
                {
                    BrushAlias = "markup",
                    BrushName  = "XML"
                },
                new HighLightList
                {
                    BrushAlias = "vb",
                    BrushName  = "Visual Basic"
                }
            };

            writer.Write("<div class=\"dropdown-menu\">");

            foreach (var item in highLightList)
            {
                writer.WriteLine(
                    @"<a class=""dropdown-item"" href=""#"" onclick=""setStyle('codelang','{0}')"">{1}</a>",
                    item.BrushAlias,
                    item.BrushName);
            }

            writer.Write("</div>");
            writer.Write("</div>");

            RenderButton(writer, "setStyle('img','')", this.GetText("COMMON", "TT_IMAGE"), "image");

            if (this.Get <YafBoardSettings>().EnableAlbum &&
                (this.PageContext.UsrAlbums > 0 && this.PageContext.NumAlbums > 0) && !this.PageContext.CurrentForumPage.IsAdminPage)
            {
                var albumImageList = LegacyDb.album_images_by_user(this.PageContext.PageUserID);

                // add drop down for optional "extra" codes...
                writer.WriteLine(@"<div class=""btn-group"" role=""group""><button type=""button"" class=""btn btn-secondary btn-sm dropdown-toggle"" title=""{0}""
                       data-toggle=""dropdown"" aria-haspopup=""true"" aria-expanded=""false"">
                  <i class=""fa fa-image fa-fw""></i></button>".FormatWith(this.GetText("COMMON", "ALBUMIMG_CODE")));

                writer.Write("<div class=\"dropdown-menu\">");

                foreach (DataRow row in albumImageList.Rows)
                {
                    this.popMenuAlbums.AddClientScriptItem(
                        row["Caption"].ToString().IsSet() ? row["Caption"].ToString() : row["FileName"].ToString(),
                        "setStyle('AlbumImgId','{0}')".FormatWith(row["ImageID"]),
                        "{0}resource.ashx?image={1}".FormatWith(YafForumInfo.ForumClientFileRoot, row["ImageID"]));
                }

                this.popMenuAlbums.RenderControl(writer);

                writer.Write("</div>");
                writer.Write("</div>");
            }

            if (this.UserCanUpload)
            {
                // add drop down for optional "extra" codes...
                writer.WriteLine(@"<div class=""btn-group"" role=""group""><button type=""button"" class=""btn btn-secondary btn-sm dropdown-toggle attachments-toggle"" title=""{0}""
                       data-toggle=""dropdown"" aria-haspopup=""true"" aria-expanded=""false"">
                  <i class=""fa fa-paperclip fa-fw""></i></button>".FormatWith(this.GetText("COMMON", "ATTACH_BBCODE")));

                writer.Write("<div class=\"dropdown-menu\">");

                this.popMenuAttachments.RenderControl(writer);

                writer.Write("</div>");
                writer.Write("</div>");
            }

            RenderButton(writer, "setStyle('createlink','')", this.GetText("COMMON", "TT_CREATELINK"), "link");

            writer.Write("</div>");
            writer.Write("<div class=\"btn-group\" role =\"group\">");

            RenderButton(
                writer,
                "setStyle('unorderedlist','')",
                this.GetText("COMMON", "TT_LISTUNORDERED"),
                "list-ul");

            RenderButton(writer, "setStyle('orderedlist','')", this.GetText("COMMON", "TT_LISTORDERED"), "list-ol");

            writer.Write("</div>");
            writer.Write("<div class=\"btn-group\" role =\"group\">");

            RenderButton(writer, "setStyle('justifyleft','')", this.GetText("COMMON", "TT_ALIGNLEFT"), "align-left");

            RenderButton(
                writer,
                "setStyle('justifycenter','')",
                this.GetText("COMMON", "TT_ALIGNCENTER"),
                "align-center");

            RenderButton(
                writer,
                "setStyle('justifyright','')",
                this.GetText("COMMON", "TT_ALIGNRIGHT"),
                "align-right");

            writer.Write("</div>");
            writer.Write("<div class=\"btn-group\" role =\"group\">");

            RenderButton(writer, "setStyle('outdent','')", this.GetText("COMMON", "OUTDENT"), "outdent");

            RenderButton(writer, "setStyle('indent','')", this.GetText("COMMON", "INDENT"), "indent");

            var customBbCode = this.Get <YafDbBroker>().GetCustomBBCode().ToList();

            if (customBbCode.Any())
            {
                writer.Write("</div>");
                writer.Write("<div class=\"btn-group\" role =\"group\">");

                // add drop down for optional "extra" codes...
                writer.WriteLine(@"<div class=""btn-group"" role=""group""><button type=""button"" class=""btn btn-secondary btn-sm dropdown-toggle"" title=""{0}""
                       data-toggle=""dropdown"" aria-haspopup=""true"" aria-expanded=""false"">
                  <i class=""fa fa-plug fa-fw""></i></button>".FormatWith(this.GetText("COMMON", "CUSTOM_BBCODE")));

                writer.Write("<div class=\"dropdown-menu fill-width\">");

                foreach (var row in customBbCode)
                {
                    var name = row.Name;

                    if (row.Description.IsSet())
                    {
                        // use the description as the option "name"
                        name = this.Get <IBBCode>().LocalizeCustomBBCodeElement(row.Description.Trim());
                    }

                    var onclickJs = row.OnClickJS.IsSet()
                                        ? row.OnClickJS
                                        : "setStyle('{0}','')".FormatWith(row.Name.Trim());

                    writer.WriteLine(@"<a class=""dropdown-item"" href=""#"" onclick=""{0}"">{1}</a>", onclickJs, name);
                }

                writer.Write("</div>");
                writer.Write("</div>");
            }

            writer.Write("</div>");
            writer.Write("<div class=\"btn-group\" role =\"group\">");

            // add drop down for optional "extra" codes...
            writer.WriteLine(@"<div class=""btn-group"" role=""group""><button type=""button"" class=""btn btn-secondary btn-sm dropdown-toggle"" title=""{0}""
                       data-toggle=""dropdown"" aria-haspopup=""true"" aria-expanded=""false"">
                  {0}</button>".FormatWith(this.GetText("COMMON", "FONT_COLOR")));

            writer.Write("<div class=\"dropdown-menu\">");

            string[] colors =
            {
                "Dark Red",  "Red",    "Orange", "Brown", "Yellow", "Green", "Olive", "Cyan", "Blue",
                "Dark Blue", "Indigo", "Violet", "White", "Black"
            };

            foreach (var color in colors)
            {
                writer.WriteLine(
                    @"<a class=""dropdown-item"" href=""#"" onclick=""setStyle('color', '{0}');"" style=""color:{0}"">{1}</a>",
                    color.Replace(" ", string.Empty).ToLower(),
                    color);
            }

            writer.Write("</div>");
            writer.Write("</div>");

            // add drop down for optional "extra" codes...
            writer.WriteLine(@"<div class=""btn-group"" role=""group""><button type=""button"" class=""btn btn-secondary btn-sm dropdown-toggle"" title=""{0}""
                       data-toggle=""dropdown"" aria-haspopup=""true"" aria-expanded=""false"">
                  {0}</button>".FormatWith(this.GetText("COMMON", "FONT_SIZE")));

            writer.Write("<div class=\"dropdown-menu\">");

            for (var index = 1; index < 9; index++)
            {
                writer.WriteLine(
                    @"<a class=""dropdown-item"" href=""#"" onclick=""setStyle('fontsize', {0});"">{1}</a>",
                    index,
                    index.Equals(5) ? "Default" : index.ToString());
            }

            writer.Write("</div>");
            writer.Write("</div>");

            writer.Write("</div></div>");

            this._textCtl.RenderControl(writer);
        }
Beispiel #2
0
        /// <summary>
        /// Sends server control content to a provided <see cref="T:System.Web.UI.HtmlTextWriter" /> object, which writes the content to be rendered on the client.
        /// </summary>
        /// <param name="writer">The <see cref="T:System.Web.UI.HtmlTextWriter" /> object that receives the server control content.</param>
        protected override void Render([NotNull] HtmlTextWriter writer)
        {
            if (this.UserCanUpload)
            {
                // add PopMenu Attachments to this mix...
                this.popMenuAttachments = new AttachmentsPopMenu();
                this.Controls.Add(this.popMenuAttachments);
            }

            writer.Write("<div class=\"btn-toolbar\" role=\"toolbar\">");
            writer.Write("<div class=\"btn-group mr-1 mt-1\" role =\"group\">");

            RenderButton(writer, "setStyle('bold','')", this.GetText("COMMON", "TT_BOLD"), "bold");
            RenderButton(writer, "setStyle('italic','')", this.GetText("COMMON", "TT_ITALIC"), "italic");

            RenderButton(writer, "setStyle('underline','')", this.GetText("COMMON", "TT_UNDERLINE"), "underline");

            writer.Write("</div>");
            writer.Write("<div class=\"btn-group mr-1 mt-1\" role =\"group\">");

            RenderButton(writer, "setStyle('highlight','')", this.GetText("COMMON", "TT_HIGHLIGHT"), "pen-square");

            writer.Write("</div>");

            writer.Write("<div class=\"btn-group mt-1\" role =\"group\">");

            if (!this.Get <HttpRequestBase>().Browser.IsMobileDevice)
            {
                writer.WriteLine(
                    @"<button type=""button"" class=""btn btn-secondary btn-sm dropdown-toggle"" title=""{0}""
                       data-toggle=""dropdown"" aria-haspopup=""true"" aria-expanded=""false"" id=""emoji"">
                  <i class=""fa fa-smile fa-fw""></i></button>",
                    this.GetText("COMMON", "CUSTOM_BBCODE"));

                writer.Write(
                    @"<div class=""dropdown-menu"">
                      <a class=""dropdown-item"" href=""#"" id=""emoji-area""></a>
                    </div>");
            }

            writer.Write("</div>");

            writer.Write("<div class=\"btn-group mt-1\" role =\"group\">");

            RenderButton(writer, "setStyle('createlink','')", this.GetText("COMMON", "TT_CREATELINK"), "link");

            RenderButton(writer, "setStyle('quote','')", this.GetText("COMMON", "TT_QUOTE"), "quote-left");

            // add drop down for optional "extra" codes...
            writer.WriteLine(
                @"<button type=""button"" class=""btn btn-secondary btn-sm dropdown-toggle"" title=""{0}""
                       data-toggle=""dropdown"" aria-haspopup=""true"" aria-expanded=""false"">
                  <i class=""fa fa-code fa-fw""></i></button>",
                this.GetText("COMMON", "TT_CODE"));

            var highLightList = new List <HighLightList>
            {
                new HighLightList {
                    BrushAlias = "markup", BrushName = "Plain Text"
                },
                new HighLightList {
                    BrushAlias = "bash", BrushName = "Bash(shell)"
                },
                new HighLightList {
                    BrushAlias = "c", BrushName = "C"
                },
                new HighLightList {
                    BrushAlias = "cpp", BrushName = "C++"
                },
                new HighLightList {
                    BrushAlias = "csharp", BrushName = "C#"
                },
                new HighLightList {
                    BrushAlias = "css", BrushName = "CSS"
                },
                new HighLightList {
                    BrushAlias = "git", BrushName = "Git"
                },
                new HighLightList {
                    BrushAlias = "markup", BrushName = "HTML"
                },
                new HighLightList {
                    BrushAlias = "java", BrushName = "Java"
                },
                new HighLightList {
                    BrushAlias = "javascript", BrushName = "JavaScript"
                },
                new HighLightList {
                    BrushAlias = "python", BrushName = "Python"
                },
                new HighLightList {
                    BrushAlias = "sql", BrushName = "SQL"
                },
                new HighLightList {
                    BrushAlias = "markup", BrushName = "XML"
                },
                new HighLightList {
                    BrushAlias = "vb", BrushName = "Visual Basic"
                }
            };

            writer.Write("<div class=\"dropdown-menu\">");

            highLightList.ForEach(
                item => writer.WriteLine(
                    @"<a class=""dropdown-item"" href=""#"" onclick=""setStyle('codelang','{0}')"">{1}</a>",
                    item.BrushAlias,
                    item.BrushName));

            writer.Write("</div>");

            writer.Write("</div>");

            writer.Write("<div class=\"btn-group mt-1\" role =\"group\">");

            RenderButton(writer, "setStyle('img','')", this.GetText("COMMON", "TT_IMAGE"), "image");

            if (this.Get <BoardSettings>().EnableAlbum&& this.PageContext.UsrAlbums > 0 &&
                this.PageContext.NumAlbums > 0 &&
                !this.PageContext.CurrentForumPage.IsAdminPage)
            {
                // add drop down for optional "extra" codes...
                writer.WriteLine(
                    @"<button type=""button"" class=""btn btn-secondary btn-sm dropdown-toggle albums-toggle"" title=""{0}""
                       data-toggle=""dropdown"" aria-haspopup=""true"" aria-expanded=""false"">
                  <i class=""fa fa-image fa-fw""></i></button>",
                    this.GetText("COMMON", "ALBUMIMG_CODE"));

                writer.Write("<div class=\"dropdown-menu\">");

                this.popMenuAlbums.RenderControl(writer);

                writer.Write("</div>");

                writer.Write("</div>");
            }

            if (this.UserCanUpload)
            {
                writer.Write("</div>");
                writer.Write("<div class=\"btn-group mt-1\" role =\"group\">");

                // add drop down for optional "extra" codes...
                writer.WriteLine(
                    @"<button type=""button"" class=""btn btn-secondary btn-sm dropdown-toggle attachments-toggle"" title=""{0}""
                       data-toggle=""dropdown"" aria-haspopup=""true"" aria-expanded=""false"">
                  <i class=""fa fa-paperclip fa-fw""></i></button>",
                    this.GetText("COMMON", "ATTACH_BBCODE"));

                writer.Write("<div class=\"dropdown-menu\">");

                this.popMenuAttachments.RenderControl(writer);

                writer.Write("</div>");
                writer.Write("</div>");
            }

            writer.Write("</div>");

            writer.Write("<div class=\"btn-group mr-1 mt-1\" role =\"group\">");

            RenderButton(writer, "setStyle('unorderedlist','')", this.GetText("COMMON", "TT_LISTUNORDERED"), "list-ul");

            RenderButton(writer, "setStyle('orderedlist','')", this.GetText("COMMON", "TT_LISTORDERED"), "list-ol");

            writer.Write("</div>");
            writer.Write("<div class=\"btn-group mr-1 mt-1\" role =\"group\">");

            RenderButton(writer, "setStyle('justifyleft','')", this.GetText("COMMON", "TT_ALIGNLEFT"), "align-left");

            RenderButton(
                writer,
                "setStyle('justifycenter','')",
                this.GetText("COMMON", "TT_ALIGNCENTER"),
                "align-center");

            RenderButton(writer, "setStyle('justifyright','')", this.GetText("COMMON", "TT_ALIGNRIGHT"), "align-right");

            writer.Write("</div>");
            writer.Write("<div class=\"btn-group mr-1 mt-1\" role =\"group\">");

            RenderButton(writer, "setStyle('outdent','')", this.GetText("COMMON", "OUTDENT"), "outdent");

            RenderButton(writer, "setStyle('indent','')", this.GetText("COMMON", "INDENT"), "indent");

            var customBbCode = this.Get <YafDbBroker>().GetCustomBBCode().ToList();

            var customBbCodesWithToolbar   = customBbCode.Where(code => code.UseToolbar == true).ToList();
            var customBbCodesWithNoToolbar =
                customBbCode.Where(code => code.UseToolbar == false || code.UseToolbar.HasValue == false);

            if (customBbCode.Any())
            {
                writer.Write("</div>");
                writer.Write("<div class=\"btn-group mt-1\" role =\"group\">");

                if (customBbCodesWithToolbar.Any())
                {
                    customBbCodesWithToolbar.ForEach(
                        row =>
                    {
                        var name = row.Name;

                        var onclickJs = row.OnClickJS.IsSet()
                                                    ? row.OnClickJS
                                                    : $"setStyle('{row.Name.Trim()}','')";

                        writer.WriteLine(
                            @"<button type=""button"" class=""btn btn-secondary btn-sm"" onclick=""{2}"" title=""{1}""{3}>
                  <i class=""fab fa-{0} fa-fw""></i></button>",
                            row.Name.ToLower(),
                            this.Get <IBBCode>().LocalizeCustomBBCodeElement(row.Description.Trim()),
                            onclickJs,
                            name);
                    });
                }

                // add drop down for optional "extra" codes...
                writer.WriteLine(
                    @"<div class=""btn-group"" role=""group""><button type=""button"" class=""btn btn-secondary btn-sm dropdown-toggle"" title=""{0}""
                       data-toggle=""dropdown"" aria-haspopup=""true"" aria-expanded=""false"">
                  <i class=""fa fa-plug fa-fw""></i></button>",
                    this.GetText("COMMON", "CUSTOM_BBCODE"));

                writer.Write("<div class=\"dropdown-menu fill-width\">");

                customBbCodesWithNoToolbar.ForEach(
                    row =>
                {
                    var name = row.Name;

                    if (row.Description.IsSet())
                    {
                        // use the description as the option "name"
                        name = this.Get <IBBCode>().LocalizeCustomBBCodeElement(row.Description.Trim());
                    }

                    var onclickJs = row.OnClickJS.IsSet() ? row.OnClickJS : $"setStyle('{row.Name.Trim()}','')";

                    writer.WriteLine(
                        @"<a class=""dropdown-item"" href=""#"" onclick=""{0}"">{1}</a>",
                        onclickJs,
                        name);
                });

                writer.Write("</div>");
                writer.Write("</div>");
            }

            writer.Write("</div>");
            writer.Write("<div class=\"btn-group mt-1\" role =\"group\">");

            // add drop down for optional "extra" codes...
            writer.WriteLine(
                @"<button type=""button"" class=""btn btn-secondary btn-sm dropdown-toggle"" title=""{0}""
                       data-toggle=""dropdown"" aria-haspopup=""true"" aria-expanded=""false"">
                  <i class=""fa fa-font fa-fw""></i> {0}</button>",
                this.GetText("COMMON", "FONT_COLOR"));

            writer.Write("<div class=\"dropdown-menu editorColorMenu\">");

            string[] colors =
            {
                "Dark Red", "Red",    "Orange", "Brown", "Yellow", "Green", "Olive", "Cyan", "Blue", "Dark Blue",
                "Indigo",   "Violet", "White",  "Black"
            };

            colors.ForEach(
                color => writer.WriteLine(
                    @"<a class=""dropdown-item"" href=""#"" onclick=""setStyle('color', '{0}');"" style=""color:{0}"">{1}</a>",
                    color.Replace(" ", string.Empty).ToLower(),
                    color));

            writer.Write("</div>");

            writer.Write("</div>");
            writer.Write("<div class=\"btn-group mt-1\" role =\"group\">");

            // add drop down for optional "extra" codes...
            writer.WriteLine(
                @"<button type=""button"" class=""btn btn-secondary btn-sm dropdown-toggle"" title=""{0}""
                       data-toggle=""dropdown"" aria-haspopup=""true"" aria-expanded=""false"">
                  <i class=""fa fa-font fa-fw""></i> {0}</button>",
                this.GetText("COMMON", "FONT_SIZE"));

            writer.Write("<div class=\"dropdown-menu\">");

            for (var index = 1; index < 9; index++)
            {
                writer.WriteLine(
                    @"<a class=""dropdown-item"" href=""#"" onclick=""setStyle('fontsize', {0});"">{1}</a>",
                    index,
                    index.Equals(5) ? "Default" : index.ToString());
            }

            writer.Write("</div></div>");

            writer.Write("<div class=\"btn-group mt-1\" role =\"group\">");

            RenderButton(writer, "SaveMessage()", this.GetText("COMMON", "TT_SAVE"), "save");

            writer.Write("</div>");

            writer.Write("</div>");

            this.TextAreaControl.RenderControl(writer);
        }
        /// <summary>
        /// Sends server control content to a provided <see cref="T:System.Web.UI.HtmlTextWriter" /> object, which writes the content to be rendered on the client.
        /// </summary>
        /// <param name="writer">The <see cref="T:System.Web.UI.HtmlTextWriter" /> object that receives the server control content.</param>
        protected override void Render([NotNull] HtmlTextWriter writer)
        {
            if (this.UserCanUpload)
            {
                // add popmenu Attachments to this mix...
                this._popMenuAttachments = new AttachmentsPopMenu();
                this.Controls.Add(this._popMenuAttachments);
            }

            writer.WriteLine(@"<table border=""0"" id=""bbcodeFeatures"">");
            writer.WriteLine("<tr><td>");

            this.RenderButton(
                writer,
                "bold",
                "FormatText('bold','')",
                this.GetText("COMMON", "TT_BOLD"),
                "yafEditor/bold.gif");
            this.RenderButton(
                writer,
                "italic",
                "FormatText('italic','')",
                this.GetText("COMMON", "TT_ITALIC"),
                "yafEditor/italic.gif");

            this.RenderButton(
                writer,
                "underline",
                "FormatText('underline','')",
                this.GetText("COMMON", "TT_UNDERLINE"),
                "yafEditor/underline.gif");

            writer.WriteLine("&nbsp;");

            this.RenderButton(
                writer,
                "highlight",
                "FormatText('highlight','')",
                this.GetText("COMMON", "TT_HIGHLIGHT"),
                "yafEditor/highlight.gif");

            this.RenderButton(
                writer,
                "quote",
                "FormatText('quote','')",
                this.GetText("COMMON", "TT_QUOTE"),
                "yafEditor/quote.gif");

            // add drop down for optional "extra" codes...
            writer.WriteLine(
                @"<img src=""{5}"" id=""{3}"" alt=""{4}"" title=""{4}"" onclick=""{0}"" onload=""Button_Load(this)"" onmouseover=""{1}"" />"
                .FormatWith(
                    this._popMenuBBCode.ControlOnClick,
                    this._popMenuBBCode.ControlOnMouseOver,
                    this.GetText("COMMON", "TT_CODE"),
                    "{0}_bbcode_popMenu".FormatWith(this.ClientID),
                    this.GetText("COMMON", "TT_CODELANG"),
                    this.ResolveUrl("yafEditor/code.gif")));

            var highLightList = new List <HighLightList>
            {
                new HighLightList
                {
                    BrushAlias = "markup",
                    BrushName  = "Plain Text"
                },
                new HighLightList
                {
                    BrushAlias = "markup",
                    BrushName  = "HTML"
                },
                new HighLightList {
                    BrushAlias = "css", BrushName = "CSS"
                },
                new HighLightList
                {
                    BrushAlias = "javascript",
                    BrushName  = "JavaScript"
                },
                new HighLightList {
                    BrushAlias = "c", BrushName = "C"
                },
                new HighLightList {
                    BrushAlias = "cpp", BrushName = "C++"
                },
                new HighLightList {
                    BrushAlias = "csharp", BrushName = "C#"
                },
                new HighLightList {
                    BrushAlias = "git", BrushName = "Git"
                },
                new HighLightList {
                    BrushAlias = "sql", BrushName = "SQL"
                },
                new HighLightList
                {
                    BrushAlias = "markup",
                    BrushName  = "XML"
                },
            };

            foreach (HighLightList item in highLightList)
            {
                this._popMenuBBCode.AddClientScriptItem(
                    item.BrushName,
                    "setStyle('codelang','{0}')".FormatWith(item.BrushAlias));
            }

            this.RenderButton(
                writer,
                "img",
                "FormatText('img','')",
                this.GetText("COMMON", "TT_IMAGE"),
                "yafEditor/image.gif");

            if (this.Get <YafBoardSettings>().EnableAlbum &&
                (this.PageContext.UsrAlbums > 0 && this.PageContext.NumAlbums > 0))
            {
                var albumImageList = LegacyDb.album_images_by_user(this.PageContext.PageUserID);

                writer.WriteLine(
                    @"<img src=""{5}"" id=""{3}"" alt=""{4}"" title=""{4}"" onclick=""{0}"" onload=""Button_Load(this)"" onmouseover=""{1}"" />"
                    .FormatWith(
                        this._popMenuAlbums.ControlOnClick,
                        this._popMenuAlbums.ControlOnMouseOver,
                        this.GetText("COMMON", "ALBUMIMG_BBCODE"),
                        "{0}_albums_popMenu".FormatWith(this.ClientID),
                        this.GetText("COMMON", "ALBUMIMG_BBCODE"),
                        this.ResolveUrl("yafEditor/albums.gif")));

                foreach (DataRow row in albumImageList.Rows)
                {
                    this._popMenuAlbums.AddClientScriptItem(
                        row["Caption"].ToString().IsSet()
                            ? row["Caption"].ToString()
                            : row["FileName"].ToString(),
                        "setStyle('AlbumImgId','{0}')".FormatWith(row["ImageID"]),
                        "{0}resource.ashx?image={1}".FormatWith(YafForumInfo.ForumClientFileRoot, row["ImageID"]));
                }
            }

            if (this.UserCanUpload)
            {
                var attachments = this.GetRepository <Attachment>()
                                  .ListTyped(userID: this.PageContext.PageUserID, pageIndex: 0, pageSize: 10000);

                writer.WriteLine(
                    @"<img src=""{5}"" id=""{3}"" alt=""{4}"" title=""{4}"" onclick=""{0}"" onload=""Button_Load(this)"" onmouseover=""{1}"" />"
                    .FormatWith(
                        this._popMenuAttachments.ControlOnClick,
                        this._popMenuAttachments.ControlOnMouseOver,
                        this.GetText("COMMON", "ATTACH_BBCODE"),
                        "{0}_attachments_popMenu".FormatWith(this.ClientID),
                        this.GetText("COMMON", "ATTACH_BBCODE"),
                        this.ResolveUrl("yafEditor/attach.png")));

                foreach (var attachment in attachments)
                {
                    var url = attachment.FileName.IsImageName()
                                  ? "{0}resource.ashx?i={1}&editor=true".FormatWith(
                        YafForumInfo.ForumClientFileRoot,
                        attachment.ID)
                                  : "{0}Images/document.png".FormatWith(YafForumInfo.ForumClientFileRoot);

                    this._popMenuAttachments.AddClientScriptItem(
                        attachment.FileName.Truncate(40),
                        "insertAttachment('{0}', '{1}')".FormatWith(attachment.ID, url),
                        attachment.FileName.IsImageName()
                            ? "{0}resource.ashx?i={1}&editor=true".FormatWith(YafForumInfo.ForumClientFileRoot, attachment.ID)
                            : "{0}Images/document.png".FormatWith(YafForumInfo.ForumClientFileRoot));
                }
            }

            this.RenderButton(
                writer,
                "createlink",
                "FormatText('createlink','')",
                this.GetText("COMMON", "TT_CREATELINK"),
                "yafEditor/link.gif");

            writer.WriteLine("&nbsp;");

            this.RenderButton(
                writer,
                "unorderedlist",
                "FormatText('unorderedlist','')",
                this.GetText("COMMON", "TT_LISTUNORDERED"),
                "yafEditor/unorderedlist.gif");
            this.RenderButton(
                writer,
                "orderedlist",
                "FormatText('orderedlist','')",
                this.GetText("COMMON", "TT_LISTORDERED"),
                "yafEditor/orderedlist.gif");

            writer.WriteLine("&nbsp;");

            this.RenderButton(
                writer,
                "justifyleft",
                "FormatText('justifyleft','')",
                this.GetText("COMMON", "TT_ALIGNLEFT"),
                "yafEditor/justifyleft.gif");
            this.RenderButton(
                writer,
                "justifycenter",
                "FormatText('justifycenter','')",
                this.GetText("COMMON", "TT_ALIGNCENTER"),
                "yafEditor/justifycenter.gif");
            this.RenderButton(
                writer,
                "justifyright",
                "FormatText('justifyright','')",
                this.GetText("COMMON", "TT_ALIGNRIGHT"),
                "yafEditor/justifyright.gif");

            writer.WriteLine("&nbsp;");

            this.RenderButton(
                writer,
                "outdent",
                "FormatText('outdent','')",
                this.GetText("COMMON", "OUTDENT"),
                "yafEditor/outdent.gif");

            this.RenderButton(
                writer,
                "indent",
                "FormatText('indent','')",
                this.GetText("COMMON", "INDENT"),
                "yafEditor/indent.gif");

            var customBbCode = this.Get <YafDbBroker>().GetCustomBBCode().ToList();

            if (customBbCode.Any())
            {
                writer.WriteLine("&nbsp;");

                // add drop down for optional "extra" codes...
                writer.WriteLine(
                    @"<img src=""{5}"" id=""{3}"" alt=""{4}"" title=""{4}"" onclick=""{0}"" onload=""Button_Load(this)"" onmouseover=""{1}"" />"
                    .FormatWith(
                        this._popMenuBBCustom.ControlOnClick,
                        this._popMenuBBCustom.ControlOnMouseOver,
                        this.GetText("COMMON", "CUSTOM_BBCODE"),
                        this.ClientID + "_bbcustom_popMenu",
                        this.GetText("COMMON", "TT_CUSTOMBBCODE"),
                        this.ResolveUrl("yafEditor/bbcode.gif")));

                foreach (var row in customBbCode)
                {
                    var name = row.Name;

                    if (row.Description.IsSet())
                    {
                        // use the description as the option "name"
                        name = this.Get <IBBCode>().LocalizeCustomBBCodeElement(row.Description.Trim());
                    }

                    var onclickJs = row.OnClickJS.IsSet()
                                           ? row.OnClickJS
                                           : "setStyle('{0}','')".FormatWith(row.Name.Trim());

                    this._popMenuBBCustom.AddClientScriptItem(name, onclickJs);
                }
            }

            writer.WriteLine("	</td></tr>");
            writer.WriteLine("	<tr><td>");

            // TODO: Convert to a control...
            writer.WriteLine(this.GetText("COMMON", "FONT_COLOR"));
            writer.WriteLine(
                "<select onchange=\"if(this.value!='') setStyle('color',this.value); this.value=''\">");
            writer.WriteLine("<option value=\"\">Default</option>");

            string[] colors =
            {
                "Dark Red",  "Red",    "Orange", "Brown", "Yellow", "Green", "Olive", "Cyan", "Blue",
                "Dark Blue", "Indigo", "Violet", "White", "Black"
            };

            foreach (var color in colors)
            {
                var tValue = color.Replace(" ", string.Empty).ToLower();
                writer.WriteLine("<option style=\"color:{0}\" value=\"{0}\">{1}</option>".FormatWith(tValue, color));
            }

            writer.WriteLine("</select>");

            // TODO: Just convert to a drop down control...
            writer.WriteLine(this.GetText("COMMON", "FONT_SIZE"));
            writer.WriteLine(
                "<select onchange=\"if(this.value!='') setStyle('fontsize',this.value); this.value=''\">");
            writer.WriteLine("<option value=\"1\">1</option>");
            writer.WriteLine("<option value=\"2\">2</option>");
            writer.WriteLine("<option value=\"3\">3</option>");
            writer.WriteLine("<option value=\"4\">4</option>");
            writer.WriteLine("<option selected=\"selected\" value=\"5\">Default</option>");
            writer.WriteLine("<option value=\"6\">6</option>");
            writer.WriteLine("<option value=\"7\">7</option>");
            writer.WriteLine("<option value=\"8\">8</option>");
            writer.WriteLine("<option value=\"9\">9</option>");
            writer.WriteLine("</select>");

            writer.WriteLine("</td></tr>");
            writer.WriteLine("</table>");

            this._textCtl.RenderControl(writer);

            this._popMenuBBCustom.RenderControl(writer);
            this._popMenuBBCode.RenderControl(writer);
            this._popMenuAlbums.RenderControl(writer);

            if (this.UserCanUpload)
            {
                this._popMenuAttachments.RenderControl(writer);
            }
        }