private IEnumerable <PageData> FindPages(PageListBlock currentBlock)
        {
            IEnumerable <PageData> pages;
            var listRoot = currentBlock.Root;

            if (currentBlock.Recursive)
            {
                if (currentBlock.PageTypeFilter != null)
                {
                    pages = contentLocator.FindPagesByPageType(listRoot, true, currentBlock.PageTypeFilter.ID);
                }
                else
                {
                    pages = contentLocator.GetAll <PageData>(listRoot);
                }
            }
            else
            {
                if (currentBlock.PageTypeFilter != null)
                {
                    pages = contentLoader.GetChildren <PageData>(listRoot)
                            .Where(p => p.PageTypeID == currentBlock.PageTypeFilter.ID);
                }
                else
                {
                    pages = contentLoader.GetChildren <PageData>(listRoot);
                }
            }

            if (currentBlock.CategoryFilter != null && currentBlock.CategoryFilter.Any())
            {
                pages = pages.Where(x => x.Category.Intersect(currentBlock.CategoryFilter).Any());
            }
            return(pages);
        }
Exemplo n.º 2
0
        private IEnumerable <PageData> FindPages(PageListBlock currentBlock)
        {
            IEnumerable <PageData> pages = new List <PageData>();
            var current  = currentBlock;
            var rootList = currentBlock.Roots?.FilteredItems ?? Enumerable.Empty <ContentAreaItem>();

            if (currentBlock.Recursive)
            {
                if (currentBlock.PageTypeFilter != null)
                {
                    foreach (var root in rootList)
                    {
                        var page = _contentLocator.FindPagesByPageType(root.ContentLink as PageReference, true, currentBlock.PageTypeFilter.ID);
                        pages = pages.Union(page);
                    }
                }
                else
                {
                    foreach (var root in rootList)
                    {
                        var page = _contentLocator.GetAll <PageData>(root.ContentLink as PageReference);
                        pages = pages.Union(page);
                    }
                }
            }
            else
            {
                if (currentBlock.PageTypeFilter != null)
                {
                    foreach (var root in rootList)
                    {
                        var page = _contentLoader.GetChildren <PageData>(root.ContentLink as PageReference)
                                   .Where(p => p.ContentTypeID == currentBlock.PageTypeFilter.ID);
                        pages = pages.Union(page);
                    }
                }
                else
                {
                    foreach (var root in rootList)
                    {
                        var page = _contentLoader.GetChildren <PageData>(root.ContentLink as PageReference);
                        pages = pages.Union(page);
                    }
                }
            }
            if (currentBlock.CategoryListFilter != null && currentBlock.CategoryListFilter.Any())
            {
                pages = pages.Where(x =>
                {
                    var categories = (x as ICategorizableContent)?.Categories;
                    return(categories != null &&
                           categories.Intersect(currentBlock.CategoryListFilter).Any());
                });
            }
            pages = pages.Where(x => x.VisibleInMenu);

            return(pages);
        }
Exemplo n.º 3
0
        private IEnumerable <PageData> FindPages(BlogListBlock currentBlock, Category category)
        {
            var      pageRouteHelper = ServiceLocator.Current.GetInstance <IPageRouteHelper>();
            PageData currentPage     = pageRouteHelper.Page ?? contentLoader.Get <PageData>(ContentReference.StartPage);

            var listRoot = currentBlock.Root ?? currentPage.ContentLink.ToPageReference();

            IEnumerable <PageData> pages;

            if (currentBlock.Recursive)
            {
                if (currentBlock.PageTypeFilter != null)
                {
                    pages = contentLocator.FindPagesByPageType(listRoot, true, currentBlock.PageTypeFilter.ID);
                }
                else
                {
                    pages = contentLocator.GetAll <PageData>(listRoot);
                }
            }
            else
            {
                if (currentBlock.PageTypeFilter != null)
                {
                    pages = contentLoader.GetChildren <PageData>(listRoot)
                            .Where(p => p.ContentTypeID == currentBlock.PageTypeFilter.ID);
                }
                else
                {
                    pages = contentLoader.GetChildren <PageData>(listRoot);
                }
            }

            if (currentBlock.CategoryFilter != null && currentBlock.CategoryFilter.Any())
            {
                pages = pages.Where(x => x.Category.Intersect(currentBlock.CategoryFilter).Any());
            }
            else if (category != null)
            {
                var catlist = new CategoryList
                {
                    category.ID
                };

                pages = pages.Where(x => x.Category.Intersect(catlist).Any());
            }
            pages = pages.Where(p => p.PageTypeName == typeof(BlogItemPage).GetPageType().Name).ToList();
            return(pages);
        }
Exemplo n.º 4
0
        public IEnumerable <PageData> FindPages(PageListBlock currentBlock)
        {
            IEnumerable <PageData> pages;
            var listRoot = currentBlock.Root;

            if (currentBlock.Recursive)
            {
                if (currentBlock.PageTypeFilter != null)
                {
                    pages = contentLocator.FindPagesByPageType(listRoot, true, currentBlock.PageTypeFilter.ID);
                }
                else
                {
                    pages = contentLocator.GetAll <PageData>(listRoot);
                }
            }
            else
            {
                if (currentBlock.PageTypeFilter != null)
                {
                    pages = contentLoader.GetChildren <PageData>(listRoot)
                            .Where(p => p.ContentTypeID == currentBlock.PageTypeFilter.ID);
                }
                else
                {
                    pages = contentLoader.GetChildren <PageData>(listRoot);
                }
            }

            if (currentBlock.CategoryFilter != null && currentBlock.CategoryFilter.Any())
            {
                pages = pages.Where(x => x.Category.Intersect(currentBlock.CategoryFilter).Any());
            }

            var asCollection = new PageDataCollection(pages);
            var sortFilter   = new FilterSort(currentBlock.SortOrder);

            sortFilter.Sort(asCollection);
            pages = asCollection;

            if (currentBlock.Count > 0)
            {
                pages = pages.Take(currentBlock.Count);
            }

            return(pages);
        }
Exemplo n.º 5
0
        private IEnumerable <PageData> FindPages(PageListBlock currentBlock)
        {
            IEnumerable <PageData> pages;
            var listRoot = currentBlock.Root;

            if (currentBlock.Recursive)
            {
                if (currentBlock.PageTypeFilter != null)
                {
                    pages = _contentLocator.FindPagesByPageType(listRoot, true, currentBlock.PageTypeFilter.ID);
                }
                else
                {
                    pages = _contentLocator.GetAll <PageData>(listRoot);
                }
            }
            else
            {
                if (currentBlock.PageTypeFilter != null)
                {
                    pages = _contentLoader.GetChildren <PageData>(listRoot)
                            .Where(p => p.ContentTypeID == currentBlock.PageTypeFilter.ID);
                }
                else
                {
                    pages = _contentLoader.GetChildren <PageData>(listRoot);
                }
            }

            if (currentBlock.CategoryListFilter != null && currentBlock.CategoryListFilter.Any())
            {
                pages = pages.Where(x =>
                {
                    var categories = (x as ICategorizableContent)?.Categories;
                    return(categories != null &&
                           categories.Intersect(currentBlock.CategoryListFilter).Any());
                });
            }

            pages = pages.Where(x => x.VisibleInMenu);
            return(pages);
        }
Exemplo n.º 6
0
        private IEnumerable <PageData> FindPages(PageListBlock currentBlock)
        {
            IEnumerable <PageData> pages;
            var listRoot = currentBlock.Root;

            if (currentBlock.Recursive)
            {
                _renderingContextResolver.Current.DependentOnAllContent = true;
                if (currentBlock.PageTypeFilter != null)
                {
                    pages = contentLocator.FindPagesByPageType(listRoot, true, currentBlock.PageTypeFilter.ID);
                }
                else
                {
                    pages = contentLocator.GetAll <PageData>(listRoot);
                }
            }
            else
            {
                //Add an additional dependecy to the list root,
                _renderingContextResolver.Current.AddChildrenListingDependency(currentBlock.Root);

                if (currentBlock.PageTypeFilter != null)
                {
                    pages = contentLoader.GetChildren <PageData>(listRoot)
                            .Where(p => p.ContentTypeID == currentBlock.PageTypeFilter.ID);
                }
                else
                {
                    pages = contentLoader.GetChildren <PageData>(listRoot);
                }
            }

            if (currentBlock.CategoryFilter != null && currentBlock.CategoryFilter.Any())
            {
                pages = pages.Where(x => x.Category.Intersect(currentBlock.CategoryFilter).Any());
            }
            return(pages);
        }