Exemplo n.º 1
0
        public BlogHelper(PageBlogList currPage)
        {
            _currPage = currPage;
            LoadSettings();

            _postItems = _currPage.Descendants <PageArticleItem>().ToList();

            if (GlobalTagsActive)
            {
                _tagItemCount = new Dictionary <string, int>();
                IPublishedContent homePage = currPage.AncestorOrSelf(1);
                var allTags = ContentHelper.GetHelper().TagQuery.GetAllContentTags("blogtags")
                              .Where(x => x.NodeCount > 0)
                              .Where(x => ContentHelper.GetHelper().TagQuery.GetContentByTag(x.Text, "blogtags").Where(y => y.IsInPath(homePage)).Any());

                foreach (var t in allTags)
                {
                    _tagItemCount.Add(t.Text, _postItems.Where(x => x.Tags != null && x.Tags.ToString().Split(',').Contains(t.Text)).Count());
                }
            }
            //Load categories and blog posts.
            if (GlobalCategoriesActive)
            {
                _categoryItems = _currPage.Descendant <FolderGenericCategories>().Children <DGenericCategoryItem>().ToList();
            }



            //If categories enabled, count blog posts for each category
            if (GlobalCategoriesActive)
            {
                _categoryItemCount = new Dictionary <int, int>();

                //Get only the non-empty categories (GetCategories() gets only categories with items) and count items in each
                foreach (DGenericCategoryItem categoryItem in GetCategories())
                {
                    _categoryItemCount.Add(
                        categoryItem.Id,
                        _postItems.Where(x => !string.IsNullOrEmpty(x.Categories) && categoryItem.Id.ToString().IsContainedInCsv(x.Categories)).Count()
                        );
                }
            }
        }
Exemplo n.º 2
0
 public static BlogHelper GetCachedBlogHelper(ApplicationContext cx, PageBlogList blogRoot)
 {
     return((BlogHelper)cx.ApplicationCache.RuntimeCache.GetCacheItem(string.Format("blogHelper{0}", blogRoot.Id.ToString()), () => new BlogHelper(blogRoot)));
 }
Exemplo n.º 3
0
 public PageBlogListViewModel(PageBlogList currPage) : base(currPage)
 {
 }