Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 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);
 }
Exemplo n.º 4
0
 public Current(BaseControllerSession session, Account me, ViewCategory page)
 {
     this.session = session;
     this.me      = me;
     this.page    = page;
 }