protected virtual IEnumerable <EntryItem> GetEntries() { IEnumerable <EntryItem> entries; string tag = QueryString["tag"]; string sort = QueryString["sort"]; if (!string.IsNullOrEmpty(tag)) { entries = ManagerFactory.EntryManagerInstance.GetBlogEntries(CurrentBlog, int.MaxValue, tag, null, null, null); } else if (Context.Item.TemplateIsOrBasedOn(Settings.CategoryTemplateIds)) { entries = ManagerFactory.EntryManagerInstance.GetBlogEntries(CurrentBlog, int.MaxValue, null, Context.Item.Name); } else if (!string.IsNullOrEmpty(sort)) { var algorithm = InterestingEntriesCore.GetAlgororithmFromString(sort, InterestingEntriesAlgorithm.Custom); if (algorithm != InterestingEntriesAlgorithm.Custom) { var core = new InterestingEntriesCore(ManagerFactory.EntryManagerInstance, algorithm); entries = core.GetEntries(CurrentBlog, int.MaxValue); } else { entries = new EntryItem[0]; } } else { entries = ManagerFactory.EntryManagerInstance.GetBlogEntries(CurrentBlog); } return(entries); }
public InterestingEntries(IInterstingEntriesAlgorithm interestingEntriesCore) { InterestingEntriesCore = interestingEntriesCore; Algororithm = WeBlog.Components.InterestingEntriesCore.GetAlgororithmFromString(Mode); if (Algororithm != InterestingEntriesAlgorithm.Custom || InterestingEntriesCore == null) { InterestingEntriesCore = new InterestingEntriesCore(ManagerFactory.EntryManagerInstance, Algororithm); } }
protected override void OnInit(EventArgs e) { base.OnInit(e); var algororithm = WeBlog.Components.InterestingEntriesCore.GetAlgororithmFromString(Mode); if (algororithm != InterestingEntriesAlgorithm.Custom || InterestingEntriesCore == null) { InterestingEntriesCore = new InterestingEntriesCore(ManagerFactory.EntryManagerInstance, algororithm); } }
protected virtual IList <EntryItem> GetEntries() { SearchResults <Entry> results = null; string tag = QueryString["tag"]; string sort = QueryString["sort"]; var author = QueryString["author"]; var criteria = new EntryCriteria { PageSize = TotalToShow, PageNumber = (StartIndex / TotalToShow) + 1 }; if (!string.IsNullOrEmpty(tag)) { criteria.Tag = tag; results = EntryManager.GetBlogEntries(CurrentBlog, criteria, ListOrder.Descending); } else if (author != null) { // todo: need to implement entry criteria for author results = EntryManager.GetBlogEntries(CurrentBlog, EntryCriteria.AllEntries, ListOrder.Descending); var authorEntries = results.Results.GroupBy(item => AuthorsCore.GetUserFullName(item.Author)) .FirstOrDefault(items => AuthorsCore.GetAuthorIdentity(items.Key) == author).ToList(); results = new SearchResults <Entry>(authorEntries, false); } else if (TemplateManager.TemplateIsOrBasedOn(Context.Item, Settings.CategoryTemplateIds)) { criteria.Category = Context.Item.Name; results = EntryManager.GetBlogEntries(CurrentBlog, criteria, ListOrder.Descending); } else if (!string.IsNullOrEmpty(sort)) { var algorithm = InterestingEntriesCore.GetAlgororithmFromString(sort, InterestingEntriesAlgorithm.Custom); if (algorithm != InterestingEntriesAlgorithm.Custom) { var core = new InterestingEntriesCore(EntryManager, algorithm); var maxCount = TotalToShow + (TotalToShow * StartIndex) + 1; return(core.GetEntries(CurrentBlog, maxCount)); } else { results = SearchResults <Entry> .Empty; } } else { results = EntryManager.GetBlogEntries(CurrentBlog, criteria, ListOrder.Descending); } var entryItems = new List <EntryItem>(); foreach (var entry in results.Results) { var item = Database.GetItem(entry.Uri); if (item != null) { entryItems.Add(new EntryItem(item)); } } ShowViewMoreLink = results.HasMoreResults; return(entryItems); }