public static IHtmlString Contents(string[] kinds = null, Func <ContentHead, HelperResult> itemTemplate = null, string order = "Date", Periods period = Periods.AnyTime, DateTime?createdFrom = null, DateTime?createdTo = null, bool parseContent = false, int top = 0, string navigationId = null, string location = null, string filter = null, IHtmlString noItemMessage = null, System.Linq.Expressions.Expression <Func <ContentHead, bool> > queryFilter = null) { if (itemTemplate == null) { itemTemplate = (head) => { return(new HelperResult(w => w.Write("<li>" + ContentLink(head) + "</li>"))); } } ; string str = ""; int skip = 0; if (navigationId != null) { top = BoxLib.GetListPageSize(navigationId); skip = BoxLib.GetPageSkipForList(navigationId) * top; } SiteService site = new SiteService(); DateTime?startDate = createdFrom; if (period != Periods.AnyTime) { DateTime?lastPublished = DateTime.Now; lastPublished = site.GetLastPublishDate(location, kinds); startDate = period.StartDate(lastPublished); } var contents = BoxLib.GetContents(location, order, kinds, startDate, createdTo, parseContent, skip, top, filter, queryFilter); int i = 0; foreach (ContentHead head in contents) { head.OrderIndex = i; str = str + itemTemplate(head).ToString(); i++; } if (navigationId != null) { BoxLib.SetListIsOver(navigationId, contents.Count() < top); BoxLib.SetListCount(navigationId, contents.Count()); } if (contents.Count() == 0) { if (noItemMessage != null) { return(noItemMessage); } else { return(new HtmlString("<li>No items.</li>")); } } return(new HtmlString(str)); }
public static IHtmlString ContentsRelatedWithHotestThread(Func <ContentHead, HelperResult> itemTemplate = null, string location = null, string[] kinds = null, ContentRanks rankBy = ContentRanks.PageViews, Periods period = Periods.LastDay, int top = 5, string navigationId = null) { SiteService site = new SiteService(); DateTime?lastPublished = DateTime.Now; if (period != Periods.AnyTime) { lastPublished = site.GetLastPublishDate(location, kinds); } ContentHead hotContent = site.GetHotestContent(kinds, location, rankBy, period.StartDate(lastPublished), null); if (hotContent == null) { return(new HtmlString("")); } return(ContentsRelated(hotContent.TagsToArray(), itemTemplate, null, null, null, false, top, navigationId)); }
public static IHtmlString ContentsRelatedWithHotestThread(Func<ContentHead, HelperResult> itemTemplate = null, string location = null, string[] kinds = null, ContentRanks rankBy = ContentRanks.PageViews, Periods period = Periods.LastDay, int top = 5, string navigationId = null) { SiteService site = new SiteService(); DateTime? lastPublished = DateTime.Now; if (period != Periods.AnyTime) lastPublished = site.GetLastPublishDate(location, kinds); ContentHead hotContent = site.GetHotestContent(kinds, location, rankBy, period.StartDate(lastPublished), null); if (hotContent == null) return new HtmlString(""); return ContentsRelated(hotContent.TagsToArray(), itemTemplate, null, null, null, false, top, navigationId); }
public static IHtmlString Contents(string[] kinds = null, Func<ContentHead, HelperResult> itemTemplate = null, string order = "Date", Periods period = Periods.AnyTime, DateTime? createdFrom = null, DateTime? createdTo = null, bool parseContent = false, int top = 0, string navigationId = null, string location = null, string filter = null, IHtmlString noItemMessage = null, System.Linq.Expressions.Expression<Func<ContentHead, bool>> queryFilter = null) { if (itemTemplate == null) itemTemplate = (head) => { return new HelperResult(w => w.Write("<li>" + ContentLink(head) + "</li>")); }; string str = ""; int skip = 0; if (navigationId != null) { top = BoxLib.GetListPageSize(navigationId); skip = BoxLib.GetPageSkipForList(navigationId) * top; } SiteService site = new SiteService(); DateTime? startDate = createdFrom; if (period != Periods.AnyTime) { DateTime? lastPublished = DateTime.Now; lastPublished = site.GetLastPublishDate(location, kinds); startDate = period.StartDate(lastPublished); } var contents = BoxLib.GetContents(location, order, kinds, startDate, createdTo, parseContent, skip, top + 1, filter, queryFilter); int i = 0; foreach (ContentHead head in contents) { if (i < top) { head.OrderIndex = i; str = str + itemTemplate(head).ToString(); i++; } } if (navigationId != null) { bool hasMorePage = contents.Count() == top + 1; int realCount = contents.Count(); if (realCount > top) realCount = top; BoxLib.SetListIsOver(navigationId, !hasMorePage); BoxLib.SetListCount(navigationId, realCount); } if (contents.Count() == 0) { if (noItemMessage != null) return noItemMessage; else return new HtmlString("<li>No items.</li>"); } return new HtmlString(str); }
public static IHtmlContent Contents(string[] kinds = null, Func<ContentHead, HelperResult> itemTemplate = null, Orders order = Orders.Date, Periods period = Periods.AnyTime, DateTime? createdFrom = null, DateTime? createdTo = null, bool parseContent = false, int top = 0, string navigationId = null, string location = null, string filter = null, IHtmlContent noItemMessage = null, System.Linq.Expressions.Expression<Func<ContentHead, bool>> queryFilter = null, int manualSkip = 0) { if (itemTemplate == null) { itemTemplate = (head) => { return new HelperResult(w => { return w.WriteAsync("<li>" + ContentLink(head) + "</li>"); }); }; } string str = ""; int skip = manualSkip; if (navigationId != null) { top = BoxLib.GetListPageSize(navigationId); skip = BoxLib.GetPageSkipForList(navigationId) * top; } DateTime? startDate = createdFrom; if (period != Periods.AnyTime) { DateTime? lastPublished = DateTime.Now; lastPublished = BoxLib.GetLastPublishDate(location, kinds); startDate = period.StartDate(lastPublished); } var contents = BoxLib.GetContents(location, order, kinds, startDate, createdTo, parseContent, skip, top + 1, filter, queryFilter); var sb = new StringBuilder(); using (TextWriter tw = new StringWriter(sb)) { int i = 0; foreach (ContentHead head in contents) { if (i < top) { head.OrderIndex = i; itemTemplate(head).WriteTo(tw, System.Text.Encodings.Web.HtmlEncoder.Default); i++; } } str = sb.ToString(); } if (navigationId != null) { bool hasMorePage = contents.Count() == top + 1; int realCount = contents.Count(); if (realCount > top) realCount = top; BoxLib.SetListIsOver(navigationId, !hasMorePage); BoxLib.SetListCount(navigationId, realCount); } if (contents.Count() == 0) { if (noItemMessage != null) return noItemMessage; else return new HtmlString("<li>No items.</li>"); } return new HtmlString(str); }