public int GetTaggedContentItemCount(int tagId) { var localizationBucket = new LocalizationBucket(_cultureManager, _workContextAccessor); if (localizationBucket.CurrentCulture == null || localizationBucket.CurrentCulture.Id == 0) { return(0); } return(_contentManager .Query <TagsPart, TagsPartRecord>(VersionOptions.Published) .Where(tpr => tpr.Tags.Any(tr => tr.TagRecord.Id == tagId)) .List() .Select(x => x.As <LocalizationPart>()) .Where(x => x.Culture == null && localizationBucket.IsCurrentCultureDefault || x.Culture != null && x.Culture.Id == localizationBucket.CurrentCulture.Id) .Count()); }
public IEnumerable <IContent> GetTaggedContentItems(int tagId, int skip, int take) { var localizationBucket = new LocalizationBucket(_cultureManager, _workContextAccessor); if (localizationBucket.CurrentCulture == null || localizationBucket.CurrentCulture.Id == 0) { return(new TagsPart[0]); } return(_contentManager .Query <TagsPart, TagsPartRecord>(VersionOptions.Published) .Where(tpr => tpr.Tags.Any(tr => tr.TagRecord.Id == tagId)) .Join <CommonPartRecord>().OrderByDescending(x => x.CreatedUtc) .List() .Select(x => x.As <LocalizationPart>()) .Where(x => x.Culture == null && localizationBucket.IsCurrentCultureDefault || x.Culture != null && x.Culture.Id == localizationBucket.CurrentCulture.Id) .Skip(skip).Take(take)); }
public IEnumerable <LocalizedTag> GetLocalizedTags() { var localizationBucket = new LocalizationBucket(_cultureManager, _workContextAccessor); if (localizationBucket.CurrentCulture == null || localizationBucket.CurrentCulture.Id == 0) { return(new List <LocalizedTag>()); } var cacheKey = "RM.Localization.TagCloud." + localizationBucket.CurrentCulture.Culture; return(_cacheManager.Get(cacheKey, ctx => { ctx.Monitor(_signals.When(_localizedTagcloudTagsChanged)); var tags = _contentManager .Query <TagsPart, TagsPartRecord>(VersionOptions.Published) .List() .Select(x => x.As <LocalizationPart>()) .Where(x => x.Culture == null && localizationBucket.IsCurrentCultureDefault || x.Culture != null && x.Culture.Id == localizationBucket.CurrentCulture.Id) .Select(x => x.As <TagsPart>()) .SelectMany(x => x.CurrentTags) .GroupBy(x => x.TagName) .Select(x => new LocalizedTag { TagName = x.Key, Count = x.Count() }).ToList(); if (tags.Any()) { var maxCount = tags.Max(tc => tc.Count); var minCount = tags.Min(tc => tc.Count); var delta = maxCount - minCount; if (delta != 0) { foreach (var tag in tags) { tag.Bucket = (tag.Count - minCount) * (Buckets - 1) / delta + 1; } } } return tags; })); }
public IEnumerable<LocalizedTag> GetLocalizedTags() { var localizationBucket = new LocalizationBucket(_cultureManager, _workContextAccessor); if (localizationBucket.CurrentCulture == null || localizationBucket.CurrentCulture.Id == 0) return new List<LocalizedTag>(); var cacheKey = "RM.Localization.TagCloud." + localizationBucket.CurrentCulture.Culture; return _cacheManager.Get(cacheKey, ctx => { ctx.Monitor(_signals.When(_localizedTagcloudTagsChanged)); var tags = _contentManager .Query<TagsPart, TagsPartRecord>(VersionOptions.Published) .List() .Select(x => x.As<LocalizationPart>()) .Where(x => x.Culture == null && localizationBucket.IsCurrentCultureDefault || x.Culture != null && x.Culture.Id == localizationBucket.CurrentCulture.Id) .Select(x => x.As<TagsPart>()) .SelectMany(x => x.CurrentTags) .GroupBy(x => x.TagName) .Select(x => new LocalizedTag { TagName = x.Key, Count = x.Count() }).ToList(); if (tags.Any()) { var maxCount = tags.Max(tc => tc.Count); var minCount = tags.Min(tc => tc.Count); var delta = maxCount - minCount; if (delta != 0) { foreach (var tag in tags) { tag.Bucket = (tag.Count - minCount) * (Buckets - 1) / delta + 1; } } } return tags; }); }
public int GetTaggedContentItemCount(int tagId) { var localizationBucket = new LocalizationBucket(_cultureManager, _workContextAccessor); if (localizationBucket.CurrentCulture == null || localizationBucket.CurrentCulture.Id == 0) return 0; return _contentManager .Query<TagsPart, TagsPartRecord>(VersionOptions.Published) .Where(tpr => tpr.Tags.Any(tr => tr.TagRecord.Id == tagId)) .List() .Select(x => x.As<LocalizationPart>()) .Where(x => x.Culture == null && localizationBucket.IsCurrentCultureDefault || x.Culture != null && x.Culture.Id == localizationBucket.CurrentCulture.Id) .Count(); }
public IEnumerable<IContent> GetTaggedContentItems(int tagId, int skip, int take) { var localizationBucket = new LocalizationBucket(_cultureManager, _workContextAccessor); if (localizationBucket.CurrentCulture == null || localizationBucket.CurrentCulture.Id == 0) return new TagsPart[0]; return _contentManager .Query<TagsPart, TagsPartRecord>(VersionOptions.Published) .Where(tpr => tpr.Tags.Any(tr => tr.TagRecord.Id == tagId)) .Join<CommonPartRecord>().OrderByDescending(x => x.CreatedUtc) .List() .Select(x=>x.As<LocalizationPart>()) .Where(x=>x.Culture == null && localizationBucket.IsCurrentCultureDefault || x.Culture != null && x.Culture.Id == localizationBucket.CurrentCulture.Id) .Skip(skip).Take(take); }