mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 11:44:58 +08:00
Removing the Pager HtmlHelper extension method.
work item: 16784 --HG-- branch : dev
This commit is contained in:
@@ -67,74 +67,6 @@ namespace Orchard.Mvc.Html {
|
||||
return MvcHtmlString.Create(builder.ToString(TagRenderMode.Normal));
|
||||
}
|
||||
|
||||
#region Pager
|
||||
|
||||
public static IHtmlString Pager<T>(this HtmlHelper html, IPageOfItems<T> pageOfItems, int currentPage, int defaultPageSize, object values = null, string previousText = "<", string nextText = ">", bool alwaysShowPreviousAndNext = false) {
|
||||
if (pageOfItems.TotalPageCount < 2)
|
||||
return new HtmlString(string.Empty);
|
||||
|
||||
var sb = new StringBuilder(75);
|
||||
var rvd = new RouteValueDictionary {{"q", ""},{"page", 0}};
|
||||
var viewContext = html.ViewContext;
|
||||
var urlHelper = new UrlHelper(viewContext.RequestContext);
|
||||
|
||||
if (pageOfItems.PageSize != defaultPageSize)
|
||||
rvd.Add("pagesize", pageOfItems.PageSize);
|
||||
|
||||
foreach (var item in viewContext.RouteData.Values) {
|
||||
rvd.Add(item.Key, item.Value);
|
||||
}
|
||||
|
||||
|
||||
if (values != null) {
|
||||
var rvd2 = new RouteValueDictionary(values);
|
||||
|
||||
foreach (var item in rvd2) {
|
||||
rvd[item.Key] = item.Value;
|
||||
}
|
||||
}
|
||||
|
||||
sb.Append("<p class=\"pager\">");
|
||||
|
||||
if (currentPage > 1 || alwaysShowPreviousAndNext) {
|
||||
if (currentPage == 2)
|
||||
rvd.Remove("page");
|
||||
else
|
||||
rvd["page"] = currentPage - 1;
|
||||
|
||||
sb.AppendFormat(" <a href=\"{1}\" class=\"previous\">{0}</a>", previousText,
|
||||
urlHelper.RouteUrl(rvd));
|
||||
}
|
||||
|
||||
//todo: when there are many pages (> 15?) maybe do something like 1 2 3...6 7 8...13 14 15
|
||||
for (var p = 1; p <= pageOfItems.TotalPageCount; p++) {
|
||||
if (p == currentPage) {
|
||||
sb.AppendFormat(" <span>{0}</span>", p);
|
||||
}
|
||||
else {
|
||||
if (p == 1)
|
||||
rvd.Remove("page");
|
||||
else
|
||||
rvd["page"] = p;
|
||||
|
||||
sb.AppendFormat(" <a href=\"{1}\">{0}</a>", p,
|
||||
urlHelper.RouteUrl(rvd));
|
||||
}
|
||||
}
|
||||
|
||||
if (currentPage < pageOfItems.TotalPageCount || alwaysShowPreviousAndNext) {
|
||||
rvd["page"] = currentPage + 1;
|
||||
sb.AppendFormat("<a href=\"{1}\" class=\"next\">{0}</a>", nextText,
|
||||
urlHelper.RouteUrl(rvd));
|
||||
}
|
||||
|
||||
sb.Append("</p>");
|
||||
|
||||
return new HtmlString(sb.ToString());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region UnorderedList
|
||||
|
||||
public static IHtmlString UnorderedList<T>(this HtmlHelper htmlHelper, IEnumerable<T> items, Func<T, int, MvcHtmlString> generateContent, string cssClass) {
|
||||
|
Reference in New Issue
Block a user