예제 #1
0
 private static void RecalculateCount(ITaxonomyService taxonomyService, TermsPart part)
 {
     foreach (var term in part.Terms)
     {
         var termPart = taxonomyService.GetTerm(term.TermRecord.Id);
         term.TermRecord.Count = (int)taxonomyService.GetContentItemsCount(termPart);
     }
 }
예제 #2
0
        private static void RecalculateCount(IContentManager contentManager, ITaxonomyService taxonomyService, TermsPart part) {
            // submits any change to the db so that GetContentItemsCount is accurate
            contentManager.Flush();

            foreach (var term in part.Terms) {
                var termPart = taxonomyService.GetTerm(term.TermRecord.Id);
                term.TermRecord.Count = (int)taxonomyService.GetContentItemsCount(termPart);
            }
        }
예제 #3
0
        private static void RecalculateCount(IContentManager contentManager, ITaxonomyService taxonomyService, TermsPart part)
        {
            // submits any change to the db so that GetContentItemsCount is accurate
            contentManager.Flush();

            foreach (var term in part.Terms)
            {
                var termPart = taxonomyService.GetTerm(term.TermRecord.Id);
                term.TermRecord.Count = (int)taxonomyService.GetContentItemsCount(termPart);
            }
        }
예제 #4
0
        protected override DriverResult Display(TermPart part, string displayType, dynamic shapeHelper)
        {
            return(Combined(
                       ContentShape("Parts_TermPart_Feed", () => {
                // generates a link to the RSS feed for this term
                _feedManager.Register(part.Name, "rss", new RouteValueDictionary {
                    { "term", part.Id }
                });
                return null;
            }),
                       ContentShape("Parts_TermPart", () => {
                var pagerParameters = new PagerParameters();
                var httpContext = _httpContextAccessor.Current();
                if (httpContext != null)
                {
                    pagerParameters.Page = Convert.ToInt32(httpContext.Request.QueryString["page"]);
                }

                var pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
                var taxonomy = _taxonomyService.GetTaxonomy(part.TaxonomyId);
                var totalItemCount = _taxonomyService.GetContentItemsCount(part);

                var partSettings = part.Settings.GetModel <TermPartSettings>();
                if (partSettings != null && partSettings.OverrideDefaultPagination)
                {
                    pager.PageSize = partSettings.PageSize;
                }

                var childDisplayType = partSettings != null &&
                                       !String.IsNullOrWhiteSpace(partSettings.ChildDisplayType)
                        ? partSettings.ChildDisplayType
                        : "Summary";
                // asign Taxonomy and Term to the content item shape (Content) in order to provide
                // alternates when those content items are displayed when they are listed on a term
                var termContentItems = _taxonomyService.GetContentItems(part, pager.GetStartIndex(), pager.PageSize)
                                       .Select(c => _contentManager.BuildDisplay(c, childDisplayType).Taxonomy(taxonomy).Term(part));

                var list = shapeHelper.List();

                list.AddRange(termContentItems);

                var pagerShape = pager.PageSize == 0
                        ? null
                        : shapeHelper.Pager(pager)
                                 .TotalItemCount(totalItemCount)
                                 .Taxonomy(taxonomy)
                                 .Term(part);

                return shapeHelper.Parts_TermPart(ContentItems: list, Taxonomy: taxonomy, Pager: pagerShape);
            })));
        }
예제 #5
0
        // Retrieve the number of associated content items, for the whole hierarchy
        private static void RecalculateCount(ITaxonomyService taxonomyService, TermsPart part) {
            foreach (var term in part.Terms) {
                var termPart = taxonomyService.GetTerm(term.TermRecord.Id);
                while (termPart != null) {
                    termPart.Count = (int)taxonomyService.GetContentItemsCount(termPart);

                    // compute count for the hierarchy too
                    if (termPart.Container != null) {
                        var parentTerm = termPart.Container.As<TermPart>();
                        termPart = parentTerm;
                    }
                }
            }
        }
        private void ProcessTerm(TermPart termPart, ICollection <int> processedTermPartRecordIds)
        {
            termPart.Count = (int)_taxonomyService.GetContentItemsCount(termPart);
            processedTermPartRecordIds.Add(termPart.Id);

            // Look for a parent term that has not yet been processed
            if (termPart.Container != null)
            {
                var parentTerm = termPart.Container.As <TermPart>();
                if (parentTerm != null && !processedTermPartRecordIds.Contains(parentTerm.Id))
                {
                    ProcessTerm(parentTerm, processedTermPartRecordIds);
                }
            }
        }
예제 #7
0
        public ActionResult Item(string termPath, PagerParameters pagerParameters)
        {
            var pager         = new Pager(_siteService.GetSiteSettings(), pagerParameters);
            var correctedPath = _termPathConstraint.FindPath(termPath);

            if (correctedPath == null)
            {
                return(HttpNotFound());
            }

            var termPart = _taxonomyService.GetTermByPath(correctedPath);

            if (termPart == null)
            {
                return(HttpNotFound());
            }

            var taxonomy       = _taxonomyService.GetTaxonomy(termPart.TaxonomyId);
            var totalItemCount = _taxonomyService.GetContentItemsCount(termPart);

            var termContentItems = _taxonomyService.GetContentItems(termPart, pager.GetStartIndex(), pager.PageSize)
                                   .Select(c => _contentManager.BuildDisplay(c, "Summary").Taxonomy(taxonomy).Term(termPart));

            dynamic term = _contentManager.BuildDisplay(termPart);

            var list = Shape.List();

            list.AddRange(termContentItems);

            term.Content.Add(
                Shape.Taxonomies_TermContentItems_List(ContentItems: list)
                .Taxonomy(taxonomy)
                .Term(termPart), "5");

            term.Content.Add(
                Shape.Pager(pager)
                .TotalItemCount(totalItemCount)
                .Taxonomy(taxonomy)
                .Term(termPart), "Content:after");

            // generates a link to the RSS feed for this term
            _feedManager.Register(termPart.Name, "rss", new RouteValueDictionary {
                { "term", termPart.Id }
            });

            return(new ShapeResult(this, term));
        }
예제 #8
0
        // Retrieve the number of associated content items, for the whole hierarchy
        private static void RecalculateCount(ITaxonomyService taxonomyService, TermsPart part)
        {
            foreach (var term in part.Terms)
            {
                var termPart = taxonomyService.GetTerm(term.TermRecord.Id);
                while (termPart != null)
                {
                    termPart.Count = (int)taxonomyService.GetContentItemsCount(termPart);

                    // compute count for the hierarchy too
                    if (termPart.Container != null)
                    {
                        var parentTerm = termPart.Container.As <TermPart>();
                        termPart = parentTerm;
                    }
                }
            }
        }
예제 #9
0
        public void Process(params int[] termPartRecordIds)
        {
            foreach (var id in termPartRecordIds)
            {
                var termPart = _taxonomyService.GetTerm(id);
                while (termPart != null)
                {
                    termPart.Count = (int)_taxonomyService.GetContentItemsCount(termPart);

                    // compute count for the hierarchy too
                    if (termPart.Container != null)
                    {
                        var parentTerm = termPart.Container.As <TermPart>();
                        termPart = parentTerm;
                    }
                }
            }
        }
 private static void RecalculateCount(ITaxonomyService taxonomyService, TermsPart part) {
     foreach (var term in part.Terms) {
         var termPart = taxonomyService.GetTerm(term.TermRecord.Id);
         term.TermRecord.Count = (int)taxonomyService.GetContentItemsCount(termPart);
     }
 }