Esempio n. 1
0
        internal override string show()
        {
            selectedCatId = this.ParentCategoryId;
            StringBuilder sb = new StringBuilder();

            Int32.TryParse(Provider.Request["item"], out selectedCatId);
            if (selectedCatId == 0)
            {
                selectedCatId = 1;
            }

            Entities.Content selectedCat = (Entities.Content)Provider.Database.Read(typeof(Entities.Content), selectedCatId);

            if (this.showHomeLink)
            {
                addLink(sb, Provider.Configuration.MainPage, "nav", selectedCatId == 1, 1, "", Provider.GetModuleResource("Home Page"));
            }

            IDatabaseEntity[] cats = Provider.Database.ReadList(typeof(Entities.Content), "select Id, " + (useSpotTitle ? "SpotTitle as Title" : "Title") + ", ClassName, Hierarchy, ShowInPage from Content where CategoryId=" + (this.Dynamic ? selectedCatId : this.ParentCategoryId) + " and Visible=1 order by OrderNo").SafeCastToArray <IDatabaseEntity>();
            if (cats.Length == 0 && this.Dynamic)
            {
                cats = Provider.Database.ReadList(typeof(Entities.Content), "select Id, " + (useSpotTitle ? "SpotTitle as Title" : "Title") + ", ClassName, Hierarchy, ShowInPage from Content where CategoryId=" + selectedCat.CategoryId + " and Visible=1 order by OrderNo").SafeCastToArray <IDatabaseEntity>();
            }
            Provider.Translate(cats);

            foreach (Entities.Content dr in cats)
            {
                //string template = Provider.GetTemplate(dr, useTemplate);
                string template = this.forceToUseTemplate ? this.useTemplate : Provider.GetTemplate(dr, useTemplate);

                bool selected = selectedCat.IsUnder(dr.Id) || dr.Id == selectedCatId;

                addLink(sb, template, "nav", selected, dr.Id, dr.Category.Title, dr.Title);
                if (this.showChildCategories && (selectedCat.Id == dr.Id || selectedCat.Hierarchy.IndexOf(dr.Id.ToString().PadLeft(5, '0')) > -1))
                {
                    IDatabaseEntity[] subCats = Provider.Database.ReadList(typeof(Entities.Content), "select Id, " + (useSpotTitle ? "SpotTitle as Title" : "Title") + ", ClassName, Hierarchy, ShowInPage from Content where CategoryId=" + dr.Id + " and Visible=1 order by OrderNo").SafeCastToArray <IDatabaseEntity>();
                    Provider.Translate(subCats);

                    foreach (Entities.Content drSub in subCats)
                    {
                        //template = Provider.GetTemplate(drSub, useTemplate);
                        template = this.forceToUseTemplate ? this.useTemplate : Provider.GetTemplate(drSub, useTemplate);
                        selected = selectedCat.IsUnder(drSub.Id) || drSub.Id == selectedCatId;
                        addLink(sb, template, "subNav", selected, drSub.Id, drSub.Category.Title, drSub.Title);
                    }
                }
            }
            if (popupDepth > 0)
            {
                ArrayList alCats = new ArrayList();
                foreach (Entities.Content cat in cats)
                {
                    alCats.Add(cat.Id.ToString());
                }
                IDatabaseEntity[] childItems = Provider.Database.ReadList(typeof(Entities.Content), "select Id, " + (useSpotTitle ? "SpotTitle as Title" : "Title") + ", ClassName, Hierarchy, ShowInPage, CategoryId from Content where CategoryId in (" + string.Join(",", (string[])alCats.ToArray(typeof(string))) + ") and Visible=1 order by OrderNo").SafeCastToArray <IDatabaseEntity>();
                sb.Append("<div  style=\"display:none;position:absolute\" class=\"popupMenuItems hideOnOut\">\n");
                foreach (Entities.Content childContent in childItems)
                {
                    string template = this.forceToUseTemplate ? this.useTemplate : Provider.GetTemplate(childContent, useTemplate);
                    addPopupLink(sb, template, "popupMenuItem", childContent.Id, childContent.Title, childContent.CategoryId, childContent.Category.Title);
                }
                sb.Append("</div>\n");
                sb.AppendFormat("<script type=\"text/javascript\">navigationPopupInit('Navigation_{0}',{1});</script>\n", this.Id, this.Horizontal?"true":"false");
            }

            sb.Append("<div style=\"clear:both\"></div>\n");

            return(sb.ToString());
        }