public static List <ViewCategory> createBreadcrumbData(int categoryItemID, Lang lang)
        {
            ViewCategory        category       = getCategoryRecursively(categoryItemID, lang);
            List <ViewCategory> breadcrumbData = new List <ViewCategory>();

            breadcrumbData = convertCategoryRecursiveToList(breadcrumbData, category);


            for (var k = breadcrumbData.Count - 1; k >= 0; k--)
            {
                var cate        = breadcrumbData[k];
                var _cat        = cate.categoryItemID;
                var hasArticles = WebApplication2.Context.ArticlePublishedDbContext.getInstance().hasArticlesPublishedByCategoryID(_cat, lang.lang);
                if (!hasArticles && breadcrumbData.Count - 1 > k)
                {
                    cate.link = breadcrumbData[k + 1].link;
                }
            }


            if (breadcrumbData.Count > 0)
            {
                var cat = WebApplication2.Context.InfrastructureCategoryDbContext.getInstance().findCategoryByURL("home");
                if (cat != null)
                {
                    ViewCategory home = new ViewCategory();
                    home.link  = new Link(lang.locale, null, null, null);
                    home.title = cat.GetName(lang.lang);
                    breadcrumbData.Insert(0, home);
                }
            }
            return(breadcrumbData);
        }
        public static ViewCategory getCategoryRecursively(int categoryItemID, Lang lang)
        {
            ViewCategory category = null;
            var          cat      = WebApplication2.Context.InfrastructureCategoryDbContext.getInstance().findCategoryByIDNoTracking(categoryItemID);

            if (cat != null)
            {
                category = new ViewCategory(cat, lang);
                category.categoryParent = getCategoryRecursively(category.categoryParentItemID, lang);
            }
            return(category);
        }
 public static List <ViewCategory> convertCategoryRecursiveToList(List <ViewCategory> categories, ViewCategory category)
 {
     if (category != null)
     {
         if (category.categoryParent != null)
         {
             categories = convertCategoryRecursiveToList(categories, category.categoryParent);
         }
         categories.Add(category);
     }
     return(categories);
 }
Beispiel #4
0
 public Current(BaseControllerSession session, Account me, ViewCategory page)
 {
     this.session = session;
     this.me      = me;
     this.page    = page;
 }