protected virtual StringBuilder LoadChildren(StringBuilder output, Guid rootContentID, string sItemCSS, int iParent, int iLevel)
        {
            List <SiteNav> lstNav = GetChildren(rootContentID);

            string sThis2CSS = sItemCSS;

            if (lstNav != null && lstNav.Any())
            {
                output.AppendLine();
                output.AppendLine("<ul id=\"listitem" + iParent.ToString() + "-childlist\" class=\"childlist childlevel" + iLevel + " " + this.CssULClassLower + "\">");

                foreach (SiteNav c2 in lstNav)
                {
                    List <SiteNav> cc = GetChildren(c2.Root_ContentID);

                    if (this.MultiLevel)
                    {
                        string sChild = " ";
                        if (cc != null && cc.Any())
                        {
                            sChild = " level" + iLevel + "-haschildren " + this.CssHasChildren + " ";
                        }
                        sThis2CSS = " level" + iLevel + " " + sItemCSS + sChild;
                    }
                    else
                    {
                        sThis2CSS = sItemCSS;
                    }

                    if (SiteData.IsFilenameCurrentPage(c2.FileName) ||
                        ControlUtilities.AreFilenamesSame(c2.FileName, this.ParentFileName))
                    {
                        sThis2CSS = sThis2CSS + " " + this.CssSelected;
                    }
                    sThis2CSS = (sThis2CSS + " child-nav").Replace("   ", " ").Replace("  ", " ").Trim();

                    iItemNumber++;
                    output.AppendLine("<li id=\"listitem" + iItemNumber.ToString() + "\" class=\"" + sThis2CSS + "\"><a href=\"" + c2.FileName + "\">" + c2.NavMenuText + "</a>");

                    if (cc != null && cc.Any())
                    {
                        LoadChildren(output, c2.Root_ContentID, sItemCSS, iItemNumber, iLevel + 1);
                    }

                    output.Append("</li>");

                    output.AppendLine();
                }

                output.AppendLine("</ul> ");
            }

            return(output);
        }
Beispiel #2
0
        public override string ToHtmlString()
        {
            LoadData();
            TweakData();

            string sItemCss = String.Empty;

            StringBuilder output = new StringBuilder();

            if (!String.IsNullOrEmpty(this.CssClass))
            {
                output.AppendLine("<ul id=\"" + this.ElementId + "\" class=\"" + this.CssClass + "\">");
            }
            else
            {
                output.AppendLine("<ul id=\"" + this.ElementId + "\" >");
            }

            if (this.NavigationData != null && this.NavigationData.Any())
            {
                foreach (var n in this.NavigationData)
                {
                    if (SiteData.IsFilenameCurrentPage(n.FileName) ||
                        (n.NavOrder == 0 && SiteData.IsCurrentLikelyHomePage) ||
                        ControlUtilities.AreFilenamesSame(n.FileName, this.CmsPage.ThePage.FileName))
                    {
                        sItemCss = String.Format(" {0} {1} ", this.CssItem, this.CssSelected).Trim();
                    }
                    else
                    {
                        sItemCss = String.Format(" {0} ", this.CssItem).Trim();
                    }

                    if (!String.IsNullOrEmpty(sItemCss))
                    {
                        output.Append("<li class=\"" + sItemCss + "\">");
                    }
                    else
                    {
                        output.Append("<li>");
                    }

                    output.Append(" <a href=\"" + n.FileName + "\">" + n.NavMenuText + "</a> </li>" + Environment.NewLine);
                }
            }

            output.AppendLine("</ul>");

            return(output.ToString());
        }
Beispiel #3
0
        protected void InitList()
        {
            output   = new StringBuilder();
            sItemCss = String.Empty;

            if (!String.IsNullOrEmpty(this.CssClass))
            {
                output.AppendLine("<ul id=\"" + this.ElementId + "\" class=\"" + this.CssClass + "\">");
            }
            else
            {
                output.AppendLine("<ul id=\"" + this.ElementId + "\" >");
            }

            if (this.NavigationData != null && this.NavigationData.Any())
            {
                foreach (var n in this.NavigationData.OrderBy(x => x.NavOrder).Where(x => x.Parent_ContentID == null))
                {
                    if (SiteData.IsFilenameCurrentPage(n.FileName) ||
                        (n.NavOrder == 0 && SiteData.IsCurrentLikelyHomePage) ||
                        ControlUtilities.AreFilenamesSame(n.FileName, this.CmsPage.ThePage.FileName))
                    {
                        sItemCss = String.Format(" {0} {1} ", this.CssItem, this.CssSelected).Trim();
                    }
                    else
                    {
                        sItemCss = String.Format(" {0} ", this.CssItem).Trim();
                    }

                    if (!String.IsNullOrEmpty(sItemCss))
                    {
                        output.Append("<li class=\"" + sItemCss + "\">");
                    }
                    else
                    {
                        output.Append("<li>");
                    }

                    output.Append(" <a href=\"" + n.FileName + "\">" + n.NavMenuText + "</a> ");
                    LoadChildLevels(n.Root_ContentID);
                    output.Append(" </li>" + Environment.NewLine);
                }
            }

            output.AppendLine("</ul>");
        }
        public static MvcHtmlString RssLink(SiteData.RSSFeedInclude mode,
                                            string imagePath       = "",
                                            string imageAltText    = "RSS",
                                            object imageAttributes = null,
                                            object linkAttributes  = null)
        {
            var url = new UrlHelper(Html.ViewContext.RequestContext);

            var anchorBuilder = new TagBuilder("a");

            anchorBuilder.MergeAttribute("href", String.Format("{0}?type={1}", CarrotCakeHtml.RssUri, mode));

            var lnkAttribs = (IDictionary <string, object>)HtmlHelper.AnonymousObjectToHtmlAttributes(linkAttributes);

            anchorBuilder.MergeAttributes(lnkAttribs);

            if (String.IsNullOrEmpty(imagePath))
            {
                imagePath = ControlUtilities.GetWebResourceUrl("Carrotware.CMS.UI.Components.feed.png");
            }

            var imgBuilder = new TagBuilder("img");

            imgBuilder.MergeAttribute("src", url.Content(imagePath));
            imgBuilder.MergeAttribute("alt", imageAltText);
            imgBuilder.MergeAttribute("title", imageAltText);

            var imgAttribs = (IDictionary <string, object>)HtmlHelper.AnonymousObjectToHtmlAttributes(imageAttributes);

            imgBuilder.MergeAttributes(imgAttribs);

            string imgHtml = imgBuilder.ToString(TagRenderMode.SelfClosing);

            anchorBuilder.InnerHtml = imgHtml;

            return(MvcHtmlString.Create(anchorBuilder.ToString()));
        }
Beispiel #5
0
        public override string GetHtml()
        {
            List <SiteNav> lstNav  = new List <SiteNav>();
            StringBuilder  sb      = new StringBuilder();
            SiteNav        pageNav = this.ContentPage.GetSiteNav();
            string         sParent = pageNav.FileName.ToLower();

            using (ISiteNavHelper navHelper = SiteNavFactory.GetSiteNavHelper()) {
                if (SiteData.CurretSiteExists && SiteData.CurrentSite.Blog_Root_ContentID.HasValue &&
                    pageNav.ContentType == ContentPageType.PageType.BlogEntry)
                {
                    lstNav = navHelper.GetPageCrumbNavigation(SiteData.CurrentSiteID, SiteData.CurrentSite.Blog_Root_ContentID.Value, !SecurityData.IsAuthEditor);

                    if (lstNav != null && lstNav.Any())
                    {
                        pageNav.NavOrder = lstNav.Max(x => x.NavOrder) + 100;
                        lstNav.Add(pageNav);
                    }
                }
                else
                {
                    lstNav = navHelper.GetPageCrumbNavigation(SiteData.CurrentSiteID, pageNav.Root_ContentID, !SecurityData.IsAuthEditor);
                }
                lstNav.RemoveAll(x => x.ShowInSiteNav == false && x.ContentType == ContentPageType.PageType.ContentEntry);
            }

            lstNav.ForEach(q => ControlUtilities.IdentifyLinkAsInactive(q));

            string sCSS = String.Empty;

            if (!String.IsNullOrEmpty(this.CssClass))
            {
                sCSS = " class=\"" + this.CssClass + "\" ";
            }

            string sSelCSS = String.Format("{0} {1}", this.CssSelected, this.CssWrapper).Trim();

            string sWrapCSS = String.Empty;

            if (!String.IsNullOrEmpty(this.CssWrapper))
            {
                sWrapCSS = " class=\"" + this.CssWrapper + "\" ";
            }

            if (this.DisplayAsList)
            {
                sb.AppendLine("<ul" + sCSS + " id=\"" + this.ElementId + "\">");
                foreach (SiteNav c in lstNav)
                {
                    if (SiteData.IsFilenameCurrentPage(c.FileName) || ControlUtilities.AreFilenamesSame(c.FileName, sParent))
                    {
                        sb.AppendLine("<li class=\"" + sSelCSS + "\">" + c.NavMenuText + "</li> ");
                    }
                    else
                    {
                        sb.AppendLine("<li" + sWrapCSS + "><a href=\"" + c.FileName + "\">" + c.NavMenuText + "</a></li> ");
                    }
                }
                sb.AppendLine("</ul>");
            }
            else
            {
                string sDivider = String.Format(" {0} ", this.TextDivider);
                int    iCtr     = 1;
                int    iMax     = lstNav.Count;
                sb.AppendLine("<div" + sCSS + " id=\"" + this.ElementId + "\">");
                foreach (SiteNav c in lstNav)
                {
                    if (SiteData.IsFilenameCurrentPage(c.FileName) || ControlUtilities.AreFilenamesSame(c.FileName, sParent))
                    {
                        sb.AppendLine("<span class=\"" + sSelCSS + "\">" + c.NavMenuText + " " + sDivider + "</span> ");
                    }
                    else
                    {
                        sb.AppendLine("<span" + sWrapCSS + "><a href=\"" + c.FileName + "\">" + c.NavMenuText + "</a> " + sDivider + "</span> ");
                    }
                    iCtr++;

                    if (iCtr == iMax)
                    {
                        sDivider = String.Empty;
                    }
                }
                sb.AppendLine("</div>");
            }

            return(sb.ToString());
        }
        public static HtmlString RenderWidget(string placeHolderName)
        {
            StringBuilder sb                  = new StringBuilder();
            string        sWidgetZone         = String.Empty;
            string        masterWidgetWrapper = String.Empty;
            string        widgetMenuTemplate  = String.Empty;
            string        sStatusTemplate     = String.Empty;

            if (SecurityData.AdvancedEditMode)
            {
                widgetMenuTemplate  = "<li id=\"liMenu\"><a href=\"javascript:[[JS_CALL]]\" id=\"cmsMenuEditLink\" class=\"cmsWidgetBarLink cmsWidgetBarIconPencil\" alt=\"[[CAP]]\" title=\"[[CAP]]\"> [[CAP]]</a></li>";
                sWidgetZone         = ControlUtilities.GetManifestResourceStream("Carrotware.CMS.UI.Components._WidgetZone.cshtml");
                masterWidgetWrapper = ControlUtilities.GetManifestResourceStream("Carrotware.CMS.UI.Components._WidgetWrapper.cshtml");

                sWidgetZone         = sWidgetZone.Replace("[[PLACEHOLDER]]", placeHolderName);
                masterWidgetWrapper = masterWidgetWrapper.Replace("[[PLACEHOLDER]]", placeHolderName);
            }

            int iWidgetCount = 0;

            var widgetList = (from w in CmsPage.TheWidgets
                              where w.PlaceholderName.ToLowerInvariant() == placeHolderName.ToLowerInvariant()
                              orderby w.WidgetOrder, w.EditDate
                              select w).ToList();

            foreach (Widget widget in widgetList)
            {
                bool IsWidgetClass = false;

                string widgetKey = String.Format("WidgetId_{0}_{1}", placeHolderName, iWidgetCount);
                if (Html.ViewContext.Controller is IContentController)
                {
                    IContentController cc = (Html.ViewContext.Controller as IContentController);

                    widgetKey = String.Format("WidgetId_{0}", cc.WidgetCount);
                }

                iWidgetCount++;

                string widgetText    = String.Empty;
                string widgetWrapper = String.Empty;
                Dictionary <string, string> lstMenus = new Dictionary <string, string>();

                if (widget.ControlPath.Contains(":"))
                {
                    string[] path         = widget.ControlPath.Split(':');
                    string   objectPrefix = path[0];
                    string   objectClass  = path[1];
                    string   altView      = path.Length >= 3 ? path[2] : String.Empty;

                    Object obj      = null;
                    Object settings = null;

                    try {
                        Type objType = ReflectionUtilities.GetTypeFromString(objectClass);

                        obj = Activator.CreateInstance(objType);

                        if (objectPrefix.ToUpperInvariant() != "CLASS")
                        {
                            IsWidgetClass = false;
                            // assumed to be a controller action/method
                            Object attrib = ReflectionUtilities.GetAttribute <WidgetActionSettingModelAttribute>(objType, objectPrefix);

                            if (attrib != null && attrib is WidgetActionSettingModelAttribute)
                            {
                                string attrClass = (attrib as WidgetActionSettingModelAttribute).ClassName;
                                Type   s         = ReflectionUtilities.GetTypeFromString(attrClass);
                                settings = Activator.CreateInstance(s);
                            }
                        }
                        else
                        {
                            IsWidgetClass = true;
                            // a class widget is its own setting object
                            settings = obj;
                        }

                        if (settings != null)
                        {
                            if (settings is IWidget)
                            {
                                IWidget w = settings as IWidget;
                                w.SiteID            = CmsPage.TheSite.SiteID;
                                w.RootContentID     = widget.Root_ContentID;
                                w.PageWidgetID      = widget.Root_WidgetID;
                                w.IsDynamicInserted = true;
                                w.IsBeingEdited     = SecurityData.AdvancedEditMode;
                                w.WidgetClientID    = widgetKey;

                                List <WidgetProps> lstProp = widget.ParseDefaultControlProperties();
                                w.PublicParmValues = lstProp.ToDictionary(t => t.KeyName, t => t.KeyValue);

                                lstMenus = w.JSEditFunctions;

                                if (!lstMenus.Any() && w.EnableEdit)
                                {
                                    lstMenus.Add("Edit", "cmsGenericEdit('" + widget.Root_ContentID.ToString() + "','" + widget.Root_WidgetID.ToString() + "')");
                                }
                            }

                            if (settings is IWidgetView)
                            {
                                if (!String.IsNullOrEmpty(altView))
                                {
                                    (settings as IWidgetView).AlternateViewFile = altView;
                                }
                            }

                            if (settings is IWidgetRawData)
                            {
                                (settings as IWidgetRawData).RawWidgetData = widget.ControlProperties;
                            }
                        }

                        if (obj != null && settings != null && obj is IWidgetDataObject)
                        {
                            (obj as IWidgetDataObject).WidgetPayload = settings;
                        }

                        if (IsWidgetClass && obj is IHtmlString)
                        {
                            widgetText = (obj as IHtmlString).ToHtmlString();
                        }
                        else
                        {
                            widgetText = GetResultViewStringFromController(objectPrefix, objType, obj);
                        }
                    } catch (Exception ex) {
                        LiteralMessage msg = new LiteralMessage(ex, widgetKey, widget.ControlPath);
                        obj        = msg;
                        widgetText = msg.ToHtmlString();
                    }
                }

                widgetText = widgetText ?? String.Empty;

                if (!widget.ControlPath.Contains(":") && String.IsNullOrEmpty(widgetText))
                {
                    string[] path       = widget.ControlPath.Split('|');
                    string   viewPath   = path[0];
                    string   modelClass = String.Empty;
                    if (path.Length > 1)
                    {
                        modelClass = path[1];
                    }

                    try {
                        if (viewPath.EndsWith(".cshtml") || viewPath.EndsWith(".vbhtml"))
                        {
                            if (String.IsNullOrEmpty(modelClass))
                            {
                                widgetText = RenderPartialToString(viewPath);
                            }
                            else
                            {
                                Type objType = ReflectionUtilities.GetTypeFromString(modelClass);

                                Object model = Activator.CreateInstance(objType);

                                if (model is IWidgetRawData)
                                {
                                    (model as IWidgetRawData).RawWidgetData = widget.ControlProperties;
                                }

                                if (model is IWidget)
                                {
                                    IWidget w = model as IWidget;
                                    w.SiteID            = CmsPage.TheSite.SiteID;
                                    w.RootContentID     = widget.Root_ContentID;
                                    w.PageWidgetID      = widget.Root_WidgetID;
                                    w.IsDynamicInserted = true;
                                    w.IsBeingEdited     = SecurityData.AdvancedEditMode;
                                    w.WidgetClientID    = widgetKey;

                                    List <WidgetProps> lstProp = widget.ParseDefaultControlProperties();
                                    w.PublicParmValues = lstProp.ToDictionary(t => t.KeyName, t => t.KeyValue);

                                    lstMenus = w.JSEditFunctions;

                                    if (!lstMenus.Any() && w.EnableEdit)
                                    {
                                        lstMenus.Add("Edit", "cmsGenericEdit('" + widget.Root_ContentID.ToString() + "','" + widget.Root_WidgetID.ToString() + "')");
                                    }
                                }

                                widgetText = RenderPartialToString(viewPath, model);
                            }
                        }
                    } catch (Exception ex) {
                        LiteralMessage msg = new LiteralMessage(ex, widgetKey, widget.ControlPath);
                        widgetText = msg.ToHtmlString();
                    }
                }

                if (widgetText == null || widget.ControlPath.ToLowerInvariant().EndsWith(".ascx"))
                {
                    LiteralMessage msg = new LiteralMessage("The widget is not supported.", widgetKey, widget.ControlPath);
                    widgetText = msg.ToHtmlString();
                }

                widgetText = widgetText ?? String.Empty;

                if (SecurityData.AdvancedEditMode)
                {
                    if (widget.IsWidgetActive)
                    {
                        sStatusTemplate = "<a href=\"javascript:cmsRemoveWidgetLink('[[ITEM_ID]]');\" id=\"cmsContentRemoveLink\" class=\"cmsWidgetBarLink cmsWidgetBarIconCross\" alt=\"Remove\" title=\"Remove\">  Disable</a>";
                    }
                    else
                    {
                        sStatusTemplate = "<a href=\"javascript:cmsActivateWidgetLink('[[ITEM_ID]]');\" id=\"cmsActivateWidgetLink\" class=\"cmsWidgetBarLink cmsWidgetBarIconActive\" alt=\"Activate\" title=\"Activate\">  Enable</a>";
                    }

                    widgetWrapper = masterWidgetWrapper;
                    widgetWrapper = widgetWrapper.Replace("[[STATUS_LINK]]", sStatusTemplate);
                    widgetWrapper = widgetWrapper.Replace("[[WIDGET_PATH]]", widget.ControlPath);
                    widgetWrapper = widgetWrapper.Replace("[[sequence]]", widget.WidgetOrder.ToString());
                    widgetWrapper = widgetWrapper.Replace("[[ITEM_ID]]", widget.Root_WidgetID.ToString());

                    CMSPlugin plug = (from p in CmsPage.Plugins
                                      where p.FilePath.ToLowerInvariant() == widget.ControlPath.ToLowerInvariant()
                                      select p).FirstOrDefault();

                    string captionPrefix = String.Empty;

                    if (!widget.IsWidgetActive)
                    {
                        captionPrefix = String.Format("{0} {1}", CMSConfigHelper.InactivePagePrefix, captionPrefix);
                    }
                    if (widget.IsRetired)
                    {
                        captionPrefix = String.Format("{0} {1}", CMSConfigHelper.RetiredPagePrefix, captionPrefix);
                    }
                    if (widget.IsUnReleased)
                    {
                        captionPrefix = String.Format("{0} {1}", CMSConfigHelper.UnreleasedPagePrefix, captionPrefix);
                    }
                    if (widget.IsWidgetPendingDelete)
                    {
                        captionPrefix = String.Format("{0} {1}", CMSConfigHelper.PendingDeletePrefix, captionPrefix);
                    }

                    if (plug != null)
                    {
                        string sysControl = (plug.SystemPlugin ? "[CMS]" : String.Empty);
                        widgetWrapper = widgetWrapper.Replace("[[WIDGET_CAPTION]]", String.Format("{0}  {1}  {2}", captionPrefix, plug.Caption, sysControl).Trim());
                    }
                    else
                    {
                        widgetWrapper = widgetWrapper.Replace("[[WIDGET_CAPTION]]", String.Format("{0}  UNTITLED", captionPrefix).Trim());
                    }

                    StringBuilder sbMenu = new StringBuilder();
                    sbMenu.AppendLine();
                    if (lstMenus != null)
                    {
                        foreach (var d in lstMenus)
                        {
                            sbMenu.AppendLine(widgetMenuTemplate.Replace("[[JS_CALL]]", d.Value).Replace("[[CAP]]", d.Key));
                        }
                    }

                    widgetWrapper = widgetWrapper.Replace("[[MENU_ITEMS]]", sbMenu.ToString().Trim());
                    widgetWrapper = widgetWrapper.Replace("[[WIDGET_CAPTION]]", widget.ControlPath + captionPrefix);

                    widgetWrapper = widgetWrapper.Replace("[[CONTENT]]", widgetText);
                }
                else
                {
                    widgetWrapper = widgetText;
                }

                if (!String.IsNullOrEmpty(widgetWrapper))
                {
                    sb.AppendLine(widgetWrapper);
                }
            }

            string bodyText = String.Empty;

            if (SecurityData.AdvancedEditMode)
            {
                bodyText = sWidgetZone.Replace("[[CONTENT]]", sb.ToString());
            }
            else
            {
                bodyText = sb.ToString();
            }

            return(new HtmlString(bodyText));
        }
        protected virtual StringBuilder WriteTopLevel(StringBuilder output)
        {
            List <SiteNav> lstNav        = GetTopNav();
            SiteNav        parentPageNav = ControlUtilities.GetParentPage();
            List <SiteNav> lstNavTree    = ControlUtilities.GetPageNavTree().OrderByDescending(x => x.NavOrder).ToList();

            this.ParentFileName = parentPageNav.FileName.ToLower();

            if (lstNav != null && lstNav.Any())
            {
                output.AppendLine();
                WriteListPrefix(output);

                string sItemCSS = String.Empty;
                if (!String.IsNullOrEmpty(this.CssItem))
                {
                    sItemCSS = String.Format(" {0} ", this.CssItem);
                }

                string sThis1CSS = sItemCSS;

                foreach (SiteNav c1 in lstNav)
                {
                    List <SiteNav> cc = GetChildren(c1.Root_ContentID);

                    string sChild = " ";
                    if (this.MultiLevel)
                    {
                        if (cc != null && cc.Any())
                        {
                            sChild = " level1-haschildren " + this.CssHasChildren + " ";
                        }
                        sThis1CSS = " level1 " + sItemCSS + sChild;
                    }
                    else
                    {
                        sThis1CSS = sItemCSS;
                    }
                    if (SiteData.IsFilenameCurrentPage(c1.FileName) ||
                        (c1.NavOrder == 0 && SiteData.IsCurrentLikelyHomePage) ||
                        (IsContained(lstNavTree, c1.Root_ContentID) != null) ||
                        ControlUtilities.AreFilenamesSame(c1.FileName, this.ParentFileName))
                    {
                        sThis1CSS = sThis1CSS + " " + this.CssSelected;
                    }
                    if (lstNav.Where(x => x.NavOrder < 0).Count() > 0)
                    {
                        if (c1.NavOrder < 0)
                        {
                            sThis1CSS = sThis1CSS + " parent-nav";
                        }
                        else
                        {
                            sThis1CSS = sThis1CSS + " child-nav";
                        }
                    }
                    sThis1CSS = sThis1CSS.Replace("   ", " ").Replace("  ", " ").Trim();

                    iItemNumber++;
                    output.AppendLine("<li id=\"listitem" + iItemNumber.ToString() + "\" class=\"" + sThis1CSS + "\"><a href=\"" + c1.FileName + "\">" + c1.NavMenuText + "</a>");

                    if (this.MultiLevel && cc != null && cc.Any())
                    {
                        LoadChildren(output, c1.Root_ContentID, sItemCSS, iItemNumber, 2);
                    }

                    output.AppendLine("</li>");
                    output.AppendLine();
                }
                WriteListSuffix(output);
            }
            else
            {
                output.AppendLine("<span style=\"display: none;\" id=\"" + this.ElementId + "\"></span>");
            }

            return(output);
        }
Beispiel #8
0
        public static string GetParentPageName()
        {
            SiteNav nav = ControlUtilities.GetParentPage();

            return(nav.FileName.ToLowerInvariant());
        }
        public override string GetHead()
        {
            FlipColor();

            string sCSSText = String.Empty;

            if (!this.AutoStylingDisabled)
            {
                sCSSText = ControlUtilities.GetManifestResourceStream("Carrotware.CMS.UI.Components.TopMenu.txt");

                if (!String.IsNullOrEmpty(sCSSText))
                {
                    sCSSText = sCSSText.Replace("{FORE_HEX}", ColorTranslator.ToHtml(this.ForeColor).ToLowerInvariant());
                    sCSSText = sCSSText.Replace("{BG_HEX}", ColorTranslator.ToHtml(this.BGColor).ToLowerInvariant());

                    sCSSText = sCSSText.Replace("{HOVER_FORE_HEX}", ColorTranslator.ToHtml(this.HoverFGColor).ToLowerInvariant());
                    sCSSText = sCSSText.Replace("{HOVER_BG_HEX}", ColorTranslator.ToHtml(this.HoverBGColor).ToLowerInvariant());

                    sCSSText = sCSSText.Replace("{SEL_FORE_HEX}", ColorTranslator.ToHtml(this.SelFGColor).ToLowerInvariant());
                    sCSSText = sCSSText.Replace("{SEL_BG_HEX}", ColorTranslator.ToHtml(this.SelBGColor).ToLowerInvariant());

                    sCSSText = sCSSText.Replace("{UNSEL_FORE_HEX}", ColorTranslator.ToHtml(this.UnSelFGColor).ToLowerInvariant());
                    sCSSText = sCSSText.Replace("{UNSEL_BG_HEX}", ColorTranslator.ToHtml(this.UnSelBGColor).ToLowerInvariant());

                    sCSSText = sCSSText.Replace("{SUB_FORE_HEX}", ColorTranslator.ToHtml(this.SubFGColor).ToLowerInvariant());
                    sCSSText = sCSSText.Replace("{SUB_BG_HEX}", ColorTranslator.ToHtml(this.SubBGColor).ToLowerInvariant());

                    if (this.FontSize.Value.HasValue)
                    {
                        sCSSText = sCSSText.Replace("{FONT_SIZE}", this.FontSize.ToString());
                        if (this.FontSize.Type == SizeType.Pixel)
                        {
                            sCSSText = sCSSText.Replace("{MENU_HEIGHT}", String.Format("{0}px", Math.Floor(4 + (this.FontSize.Value.Value * 3))));
                        }
                    }
                    else
                    {
                        sCSSText = sCSSText.Replace("{FONT_SIZE}", "inherit");
                    }
                    sCSSText = sCSSText.Replace("{MENU_HEIGHT}", "3em");

                    if (this.MenuFontSize.Value.HasValue)
                    {
                        sCSSText = sCSSText.Replace("{MAIN_FONT_SIZE}", this.MenuFontSize.ToString());
                    }
                    else
                    {
                        sCSSText = sCSSText.Replace("{MAIN_FONT_SIZE}", "inherit");
                    }

                    sCSSText = sCSSText.Replace("{MOBILE_WIDTH}", "100%");

                    sCSSText = sCSSText.Replace("{DESK_WIDTH}", "100%");

                    sCSSText = sCSSText.Replace("{MENU_SELECT_CLASS}", this.CssSelected);
                    sCSSText = sCSSText.Replace("{MENU_HASCHILD_CLASS}", this.CssHasChildren);

                    if (!String.IsNullOrEmpty(this.CssTopBackground))
                    {
                        this.CssTopBackground = this.CssTopBackground.Replace(";", "");
                        sCSSText = sCSSText.Replace("{TOP_BACKGROUND_STYLE}", "background: " + this.CssTopBackground + ";");
                    }
                    else
                    {
                        sCSSText = sCSSText.Replace("{TOP_BACKGROUND_STYLE}", "");
                    }

                    sCSSText = sCSSText.Replace("{MENU_ID}", "#" + this.ElementId + "");
                    sCSSText = sCSSText.Replace("{MENU_WRAPPER_ID}", "#" + this.ElementId + "-wrapper");
                    sCSSText = "\r\n\t<style type=\"text/css\">\r\n" + sCSSText + "\r\n\t</style>\r\n";
                }
            }

            return(sCSSText);
        }