/// <summary> /// Returns a dictionary where the key is the taxon and value is /// the number is the count of the times that the taxon is used(marked) /// </summary> /// <returns></returns> protected override Dictionary <ITaxon, uint> GetTaxaItemsCountForTaxonomy() { if (ShowItemCount) { var taxonomyIds = BlogsManager.GetManager(Provider) .GetBlogPosts() .Where(b => b.Status == ContentLifecycleStatus.Live && b.Parent.Title == BlogName && b.Visible) .SelectMany(b => b.GetValue <TrackedList <Guid> >(FieldName)) .GroupBy(id => id); return(taxonomyIds.ToDictionary( group => CurrentTaxonomyManager.GetTaxon(group.Key), group => (uint)group.Count())); } else { var taxonomyIds = BlogsManager.GetManager(Provider) .GetBlogPosts() .Where(b => b.Status == ContentLifecycleStatus.Live && b.Parent.Title == BlogName && b.Visible) .SelectMany(b => b.GetValue <TrackedList <Guid> >(FieldName)) .Distinct(); return(taxonomyIds.ToDictionary( id => CurrentTaxonomyManager.GetTaxon(id), id => (uint)1)); // ShowItemCount is false so this doesn't matter. } }
/// <summary> /// Gets view models of all available taxa in a flat list. /// </summary> /// <returns></returns> protected virtual IList <TaxonViewModel> GetAllTaxa <T>() where T : Taxon { var statistics = this.GetTaxonomyStatistics(); var taxa = this.Sort(CurrentTaxonomyManager.GetTaxa <T>() .Where(t => t.Taxonomy.Id == this.ResolvedTaxonomyId)); return(this.GetFlatTaxaViewModelsWithStatistics(taxa, statistics)); }
/// <summary> /// Gets the taxa view models for each taxon by using the provided ids of taxons that we want explicitly to be shown by the widget. /// </summary> /// <returns></returns> protected virtual IList <TaxonViewModel> GetSpecificTaxa <T>() where T : Taxon { var selectedTaxaGuids = this.selectedTaxaIds.Select(id => new Guid(id)); var taxa = (IEnumerable <Taxon>) this.Sort( CurrentTaxonomyManager.GetTaxa <T>() .Where(t => selectedTaxaGuids.Contains(t.Id))); if (this.SortExpression == "AsSetManually") { taxa = taxa.OrderBy(t => this.selectedTaxaIds.IndexOf(t.Id.ToString())); } var statistics = this.GetTaxonomyStatistics(); return(this.GetFlatTaxaViewModelsWithStatistics(taxa, statistics)); }
/// <summary> /// Creates list of view models each representing a taxon that is used by the content type that the widget is set to work with. /// </summary> /// <returns></returns> protected virtual IList <TaxonViewModel> GetTaxaByContentType() { var statistics = this.GetTaxonomyStatistics(); var contentProviderName = this.GetContentProviderName(); if (this.ContentType != null) { statistics = statistics.Where(s => s.DataItemType == this.ContentType.FullName); } if (!string.IsNullOrWhiteSpace(contentProviderName)) { statistics = statistics.Where(s => s.ItemProviderName == contentProviderName); } var taxa = this.Sort(CurrentTaxonomyManager.GetTaxa <FlatTaxon>() .Where(t => t.Taxonomy.Id == this.ResolvedTaxonomyId)); return(this.GetFlatTaxaViewModelsWithStatistics(taxa, statistics)); }