#16797: Adding setting for global paging. Fixing issue with query string specified pagesize being the same as default size.

--HG--
branch : dev
This commit is contained in:
Andre Rodrigues
2010-12-09 16:39:06 -08:00
parent c88c13c2e1
commit 2c16581106
19 changed files with 171 additions and 34 deletions
@@ -60,6 +60,11 @@ namespace Orchard.Tests.Stubs {
get { throw new NotImplementedException(); } get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); } set { throw new NotImplementedException(); }
} }
public int PageSize {
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
} }
public class StubUser : IUser { public class StubUser : IUser {
@@ -11,20 +11,29 @@ using Orchard.Themes;
using Orchard.UI.Navigation; using Orchard.UI.Navigation;
namespace Orchard.Core.Containers.Controllers { namespace Orchard.Core.Containers.Controllers {
using Orchard.Settings;
public class ItemController : Controller { public class ItemController : Controller {
private readonly IContentManager _contentManager; private readonly IContentManager _contentManager;
private readonly IContainersPathConstraint _containersPathConstraint; private readonly IContainersPathConstraint _containersPathConstraint;
private readonly ISiteService _siteService;
public ItemController(
IContentManager contentManager,
IContainersPathConstraint containersPathConstraint,
IShapeFactory shapeFactory,
ISiteService siteService) {
public ItemController(IContentManager contentManager, IContainersPathConstraint containersPathConstraint, IShapeFactory shapeFactory) {
_contentManager = contentManager; _contentManager = contentManager;
_containersPathConstraint = containersPathConstraint; _containersPathConstraint = containersPathConstraint;
_siteService = siteService;
Shape = shapeFactory; Shape = shapeFactory;
} }
dynamic Shape { get; set; } dynamic Shape { get; set; }
[Themed] [Themed]
public ActionResult Display(string path, Pager pager) { public ActionResult Display(string path, PagerParameters pagerParameters) {
var matchedPath = _containersPathConstraint.FindPath(path); var matchedPath = _containersPathConstraint.FindPath(path);
if (string.IsNullOrEmpty(matchedPath)) { if (string.IsNullOrEmpty(matchedPath)) {
throw new ApplicationException("404 - should not have passed path constraint"); throw new ApplicationException("404 - should not have passed path constraint");
@@ -51,7 +60,8 @@ namespace Orchard.Core.Containers.Controllers {
var descendingOrder = container.As<ContainerPart>().Record.OrderByDirection == (int) OrderByDirection.Descending; var descendingOrder = container.As<ContainerPart>().Record.OrderByDirection == (int) OrderByDirection.Descending;
query = query.OrderBy(container.As<ContainerPart>().Record.OrderByProperty, descendingOrder); query = query.OrderBy(container.As<ContainerPart>().Record.OrderByProperty, descendingOrder);
pager.PageSize = pager.PageSize != Pager.PageSizeDefault && container.As<ContainerPart>().Record.Paginated Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
pager.PageSize = pagerParameters.PageSize != null && container.As<ContainerPart>().Record.Paginated
? pager.PageSize ? pager.PageSize
: container.As<ContainerPart>().Record.PageSize; : container.As<ContainerPart>().Record.PageSize;
var pagerShape = Shape.Pager(pager).TotalItemCount(query.Count()); var pagerShape = Shape.Pager(pager).TotalItemCount(query.Count());
@@ -17,6 +17,7 @@ using Orchard.Localization;
using Orchard.Logging; using Orchard.Logging;
using Orchard.UI.Navigation; using Orchard.UI.Navigation;
using Orchard.UI.Notify; using Orchard.UI.Notify;
using Orchard.Settings;
namespace Orchard.Core.Contents.Controllers { namespace Orchard.Core.Contents.Controllers {
[ValidateInput(false)] [ValidateInput(false)]
@@ -24,17 +25,20 @@ namespace Orchard.Core.Contents.Controllers {
private readonly IContentManager _contentManager; private readonly IContentManager _contentManager;
private readonly IContentDefinitionManager _contentDefinitionManager; private readonly IContentDefinitionManager _contentDefinitionManager;
private readonly ITransactionManager _transactionManager; private readonly ITransactionManager _transactionManager;
private readonly ISiteService _siteService;
public AdminController( public AdminController(
IOrchardServices orchardServices, IOrchardServices orchardServices,
IContentManager contentManager, IContentManager contentManager,
IContentDefinitionManager contentDefinitionManager, IContentDefinitionManager contentDefinitionManager,
ITransactionManager transactionManager, ITransactionManager transactionManager,
ISiteService siteService,
IShapeFactory shapeFactory) { IShapeFactory shapeFactory) {
Services = orchardServices; Services = orchardServices;
_contentManager = contentManager; _contentManager = contentManager;
_contentDefinitionManager = contentDefinitionManager; _contentDefinitionManager = contentDefinitionManager;
_transactionManager = transactionManager; _transactionManager = transactionManager;
_siteService = siteService;
T = NullLocalizer.Instance; T = NullLocalizer.Instance;
Logger = NullLogger.Instance; Logger = NullLogger.Instance;
Shape = shapeFactory; Shape = shapeFactory;
@@ -45,7 +49,8 @@ namespace Orchard.Core.Contents.Controllers {
public Localizer T { get; set; } public Localizer T { get; set; }
public ILogger Logger { get; set; } public ILogger Logger { get; set; }
public ActionResult List(ListContentsViewModel model, Pager pager) { public ActionResult List(ListContentsViewModel model, PagerParameters pagerParameters) {
Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
if (model.ContainerId != null && _contentManager.GetLatest((int)model.ContainerId) == null) if (model.ContainerId != null && _contentManager.GetLatest((int)model.ContainerId) == null)
return HttpNotFound(); return HttpNotFound();
@@ -90,6 +90,7 @@ namespace Orchard.Core.Settings {
.Column<string>("HomePage") .Column<string>("HomePage")
.Column<string>("SiteCulture") .Column<string>("SiteCulture")
.Column<string>("ResourceDebugMode", c => c.WithDefault("FromAppSetting")) .Column<string>("ResourceDebugMode", c => c.WithDefault("FromAppSetting"))
.Column<int>("PageSize")
); );
return 1; return 1;
@@ -8,28 +8,39 @@ namespace Orchard.Core.Settings.Models {
get { return Record.PageTitleSeparator; } get { return Record.PageTitleSeparator; }
set { Record.PageTitleSeparator = value; } set { Record.PageTitleSeparator = value; }
} }
public string SiteName { public string SiteName {
get { return Record.SiteName; } get { return Record.SiteName; }
set { Record.SiteName = value; } set { Record.SiteName = value; }
} }
public string SiteSalt { public string SiteSalt {
get { return Record.SiteSalt; } get { return Record.SiteSalt; }
} }
public string SuperUser { public string SuperUser {
get { return Record.SuperUser; } get { return Record.SuperUser; }
set { Record.SuperUser = value; } set { Record.SuperUser = value; }
} }
public string HomePage { public string HomePage {
get { return Record.HomePage; } get { return Record.HomePage; }
set { Record.HomePage = value; } set { Record.HomePage = value; }
} }
public string SiteCulture { public string SiteCulture {
get { return Record.SiteCulture; } get { return Record.SiteCulture; }
set { Record.SiteCulture = value; } set { Record.SiteCulture = value; }
} }
public ResourceDebugMode ResourceDebugMode { public ResourceDebugMode ResourceDebugMode {
get { return Record.ResourceDebugMode; } get { return Record.ResourceDebugMode; }
set { Record.ResourceDebugMode = value; } set { Record.ResourceDebugMode = value; }
} }
public int PageSize {
get { return Record.PageSize; }
set { Record.PageSize = value; }
}
} }
} }
@@ -3,12 +3,26 @@ using Orchard.Settings;
namespace Orchard.Core.Settings.Models { namespace Orchard.Core.Settings.Models {
public class SiteSettingsPartRecord : ContentPartRecord { public class SiteSettingsPartRecord : ContentPartRecord {
public const int DefaultPageSize = 10;
public SiteSettingsPartRecord() {
PageSize = DefaultPageSize;
}
public virtual string SiteSalt { get; set; } public virtual string SiteSalt { get; set; }
public virtual string SiteName { get; set; } public virtual string SiteName { get; set; }
public virtual string SuperUser { get; set; } public virtual string SuperUser { get; set; }
public virtual string PageTitleSeparator { get; set; } public virtual string PageTitleSeparator { get; set; }
public virtual string HomePage { get; set; } public virtual string HomePage { get; set; }
public virtual string SiteCulture { get; set; } public virtual string SiteCulture { get; set; }
public virtual ResourceDebugMode ResourceDebugMode { get; set; } public virtual ResourceDebugMode ResourceDebugMode { get; set; }
public virtual int PageSize { get; set; }
} }
} }
@@ -15,8 +15,7 @@ namespace Orchard.Core.Settings.ViewModels {
get { return Site.ContentItem.Id; } get { return Site.ContentItem.Id; }
} }
public string PageTitleSeparator public string PageTitleSeparator {
{
get { return Site.Record.PageTitleSeparator; } get { return Site.Record.PageTitleSeparator; }
set { Site.Record.PageTitleSeparator = value; } set { Site.Record.PageTitleSeparator = value; }
} }
@@ -40,5 +39,10 @@ namespace Orchard.Core.Settings.ViewModels {
get { return Site.As<SiteSettingsPart>().ResourceDebugMode; } get { return Site.As<SiteSettingsPart>().ResourceDebugMode; }
set { Site.As<SiteSettingsPart>().ResourceDebugMode = value; } set { Site.As<SiteSettingsPart>().ResourceDebugMode = value; }
} }
public int PageSize {
get { return Site.As<SiteSettingsPart>().PageSize; }
set { Site.As<SiteSettingsPart>().PageSize = value; }
}
} }
} }
@@ -36,4 +36,9 @@
@Html.DropDownList("ResourceDebugMode", resourceDebugMode) @Html.DropDownList("ResourceDebugMode", resourceDebugMode)
<span class="hint">@T("Determines whether scripts and stylesheets load in their debuggable or minified form.")</span> <span class="hint">@T("Determines whether scripts and stylesheets load in their debuggable or minified form.")</span>
</div> </div>
<div>
<label for="DefaultPageSize">@T("Default number of items per page")</label>
@Html.TextBoxFor(m => m.PageSize, new { @class = "textMedium" })
<span class="hint">@T("Determines the default number of items that are shown per page.")</span>
</div>
</fieldset> </fieldset>
@@ -15,6 +15,8 @@ using Orchard.UI.Navigation;
using Orchard.UI.Notify; using Orchard.UI.Notify;
namespace Orchard.Blogs.Controllers { namespace Orchard.Blogs.Controllers {
using Orchard.Settings;
[ValidateInput(false), Admin] [ValidateInput(false), Admin]
public class BlogAdminController : Controller, IUpdateModel { public class BlogAdminController : Controller, IUpdateModel {
private readonly IBlogService _blogService; private readonly IBlogService _blogService;
@@ -22,6 +24,7 @@ namespace Orchard.Blogs.Controllers {
private readonly IContentManager _contentManager; private readonly IContentManager _contentManager;
private readonly ITransactionManager _transactionManager; private readonly ITransactionManager _transactionManager;
private readonly IBlogSlugConstraint _blogSlugConstraint; private readonly IBlogSlugConstraint _blogSlugConstraint;
private readonly ISiteService _siteService;
public BlogAdminController( public BlogAdminController(
IOrchardServices services, IOrchardServices services,
@@ -30,6 +33,7 @@ namespace Orchard.Blogs.Controllers {
IContentManager contentManager, IContentManager contentManager,
ITransactionManager transactionManager, ITransactionManager transactionManager,
IBlogSlugConstraint blogSlugConstraint, IBlogSlugConstraint blogSlugConstraint,
ISiteService siteService,
IShapeFactory shapeFactory) { IShapeFactory shapeFactory) {
Services = services; Services = services;
_blogService = blogService; _blogService = blogService;
@@ -37,6 +41,7 @@ namespace Orchard.Blogs.Controllers {
_contentManager = contentManager; _contentManager = contentManager;
_transactionManager = transactionManager; _transactionManager = transactionManager;
_blogSlugConstraint = blogSlugConstraint; _blogSlugConstraint = blogSlugConstraint;
_siteService = siteService;
T = NullLocalizer.Instance; T = NullLocalizer.Instance;
Shape = shapeFactory; Shape = shapeFactory;
} }
@@ -147,7 +152,8 @@ namespace Orchard.Blogs.Controllers {
return View((object)viewModel); return View((object)viewModel);
} }
public ActionResult Item(int blogId, Pager pager) { public ActionResult Item(int blogId, PagerParameters pagerParameters) {
Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
BlogPart blogPart = _blogService.Get(blogId, VersionOptions.Latest).As<BlogPart>(); BlogPart blogPart = _blogService.Get(blogId, VersionOptions.Latest).As<BlogPart>();
if (blogPart == null) if (blogPart == null)
@@ -13,6 +13,8 @@ using Orchard.Themes;
using Orchard.UI.Navigation; using Orchard.UI.Navigation;
namespace Orchard.Blogs.Controllers { namespace Orchard.Blogs.Controllers {
using Orchard.Settings;
[Themed] [Themed]
public class BlogController : Controller { public class BlogController : Controller {
private readonly IOrchardServices _services; private readonly IOrchardServices _services;
@@ -22,6 +24,7 @@ namespace Orchard.Blogs.Controllers {
private readonly IFeedManager _feedManager; private readonly IFeedManager _feedManager;
private readonly IWorkContextAccessor _workContextAccessor; private readonly IWorkContextAccessor _workContextAccessor;
private readonly IHomePageProvider _routableHomePageProvider; private readonly IHomePageProvider _routableHomePageProvider;
private readonly ISiteService _siteService;
public BlogController( public BlogController(
IOrchardServices services, IOrchardServices services,
@@ -31,13 +34,15 @@ namespace Orchard.Blogs.Controllers {
IFeedManager feedManager, IFeedManager feedManager,
IShapeFactory shapeFactory, IShapeFactory shapeFactory,
IWorkContextAccessor workContextAccessor, IWorkContextAccessor workContextAccessor,
IEnumerable<IHomePageProvider> homePageProviders) { IEnumerable<IHomePageProvider> homePageProviders,
ISiteService siteService) {
_services = services; _services = services;
_blogService = blogService; _blogService = blogService;
_blogPostService = blogPostService; _blogPostService = blogPostService;
_blogSlugConstraint = blogSlugConstraint; _blogSlugConstraint = blogSlugConstraint;
_feedManager = feedManager; _feedManager = feedManager;
_workContextAccessor = workContextAccessor; _workContextAccessor = workContextAccessor;
_siteService = siteService;
_routableHomePageProvider = homePageProviders.SingleOrDefault(p => p.GetProviderName() == RoutableHomePageProvider.Name); _routableHomePageProvider = homePageProviders.SingleOrDefault(p => p.GetProviderName() == RoutableHomePageProvider.Name);
Logger = NullLogger.Instance; Logger = NullLogger.Instance;
Shape = shapeFactory; Shape = shapeFactory;
@@ -59,7 +64,8 @@ namespace Orchard.Blogs.Controllers {
return View((object)viewModel); return View((object)viewModel);
} }
public ActionResult Item(string blogSlug, Pager pager) { public ActionResult Item(string blogSlug, PagerParameters pagerParameters) {
Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
var correctedSlug = _blogSlugConstraint.FindSlug(blogSlug); var correctedSlug = _blogSlugConstraint.FindSlug(blogSlug);
if (correctedSlug == null) if (correctedSlug == null)
return HttpNotFound(); return HttpNotFound();
@@ -14,12 +14,20 @@ using Orchard.Comments.ViewModels;
using Orchard.Comments.Services; using Orchard.Comments.Services;
namespace Orchard.Comments.Controllers { namespace Orchard.Comments.Controllers {
using Orchard.Settings;
[ValidateInput(false)] [ValidateInput(false)]
public class AdminController : Controller { public class AdminController : Controller {
private readonly ICommentService _commentService; private readonly ICommentService _commentService;
private readonly ISiteService _siteService;
public AdminController(IOrchardServices services, ICommentService commentService, IShapeFactory shapeFactory) { public AdminController(
IOrchardServices services,
ICommentService commentService,
ISiteService siteService,
IShapeFactory shapeFactory) {
_commentService = commentService; _commentService = commentService;
_siteService = siteService;
Services = services; Services = services;
Logger = NullLogger.Instance; Logger = NullLogger.Instance;
T = NullLocalizer.Instance; T = NullLocalizer.Instance;
@@ -31,7 +39,9 @@ namespace Orchard.Comments.Controllers {
public Localizer T { get; set; } public Localizer T { get; set; }
dynamic Shape { get; set; } dynamic Shape { get; set; }
public ActionResult Index(CommentIndexOptions options, Pager pager) { public ActionResult Index(CommentIndexOptions options, PagerParameters pagerParameters) {
Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
// Default options // Default options
if (options == null) if (options == null)
options = new CommentIndexOptions(); options = new CommentIndexOptions();
@@ -15,19 +15,24 @@ using Orchard.Collections;
using Orchard.Themes; using Orchard.Themes;
namespace Orchard.Search.Controllers { namespace Orchard.Search.Controllers {
using Orchard.Settings;
[ValidateInput(false), Themed] [ValidateInput(false), Themed]
public class SearchController : Controller { public class SearchController : Controller {
private readonly ISearchService _searchService; private readonly ISearchService _searchService;
private readonly IContentManager _contentManager; private readonly IContentManager _contentManager;
private readonly ISiteService _siteService;
public SearchController( public SearchController(
IOrchardServices services, IOrchardServices services,
ISearchService searchService, ISearchService searchService,
IContentManager contentManager, IContentManager contentManager,
ISiteService siteService,
IShapeFactory shapeFactory) { IShapeFactory shapeFactory) {
Services = services; Services = services;
_searchService = searchService; _searchService = searchService;
_contentManager = contentManager; _contentManager = contentManager;
_siteService = siteService;
T = NullLocalizer.Instance; T = NullLocalizer.Instance;
Logger = NullLogger.Instance; Logger = NullLogger.Instance;
@@ -39,7 +44,8 @@ namespace Orchard.Search.Controllers {
public ILogger Logger { get; set; } public ILogger Logger { get; set; }
dynamic Shape { get; set; } dynamic Shape { get; set; }
public ActionResult Index(Pager pager, string q = "") { public ActionResult Index(PagerParameters pagerParameters, string q = "") {
Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
var searchFields = Services.WorkContext.CurrentSite.As<SearchSettingsPart>().SearchedFields; var searchFields = Services.WorkContext.CurrentSite.As<SearchSettingsPart>().SearchedFields;
IPageOfItems<ISearchHit> searchHits = new PageOfItems<ISearchHit>(new ISearchHit[] { }); IPageOfItems<ISearchHit> searchHits = new PageOfItems<ISearchHit>(new ISearchHit[] { });
@@ -8,6 +8,7 @@ using Orchard.Commands.Builtin;
using Orchard.ContentManagement; using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers; using Orchard.ContentManagement.Handlers;
using Orchard.ContentManagement.MetaData.Builders; using Orchard.ContentManagement.MetaData.Builders;
using Orchard.Core.Settings.Models;
using Orchard.Data.Migration.Interpreters; using Orchard.Data.Migration.Interpreters;
using Orchard.Data.Providers; using Orchard.Data.Providers;
using Orchard.Data.Migration; using Orchard.Data.Migration;
@@ -172,6 +173,11 @@ namespace Orchard.Setup {
get { return ResourceDebugMode.FromAppSetting; } get { return ResourceDebugMode.FromAppSetting; }
set { throw new NotImplementedException(); } set { throw new NotImplementedException(); }
} }
public int PageSize {
get { return SiteSettingsPartRecord.DefaultPageSize; }
set { throw new NotImplementedException(); }
}
} }
} }
} }
@@ -4,6 +4,7 @@ using Orchard.ContentManagement;
using Orchard.DisplayManagement; using Orchard.DisplayManagement;
using Orchard.Localization; using Orchard.Localization;
using Orchard.Logging; using Orchard.Logging;
using Orchard.Settings;
using Orchard.Tags.Services; using Orchard.Tags.Services;
using Orchard.Tags.ViewModels; using Orchard.Tags.ViewModels;
using Orchard.Themes; using Orchard.Themes;
@@ -14,14 +15,17 @@ namespace Orchard.Tags.Controllers {
public class HomeController : Controller { public class HomeController : Controller {
private readonly ITagService _tagService; private readonly ITagService _tagService;
private readonly IContentManager _contentManager; private readonly IContentManager _contentManager;
private readonly ISiteService _siteService;
private readonly dynamic _shapeFactory; private readonly dynamic _shapeFactory;
public HomeController( public HomeController(
ITagService tagService, ITagService tagService,
IContentManager contentManager, IContentManager contentManager,
ISiteService siteService,
IShapeFactory shapeFactory) { IShapeFactory shapeFactory) {
_tagService = tagService; _tagService = tagService;
_contentManager = contentManager; _contentManager = contentManager;
_siteService = siteService;
_shapeFactory = shapeFactory; _shapeFactory = shapeFactory;
T = NullLocalizer.Instance; T = NullLocalizer.Instance;
} }
@@ -35,7 +39,9 @@ namespace Orchard.Tags.Controllers {
return View(model); return View(model);
} }
public ActionResult Search(string tagName, Pager pager) { public ActionResult Search(string tagName, PagerParameters pagerParameters) {
Pager pager = new Pager(_siteService.GetSiteSettings(), pagerParameters);
var tag = _tagService.GetTagByName(tagName); var tag = _tagService.GetTagByName(tagName);
if (tag == null) { if (tag == null) {
+1
View File
@@ -188,6 +188,7 @@
<Compile Include="Themes\ThemeManager.cs" /> <Compile Include="Themes\ThemeManager.cs" />
<Compile Include="UI\FlatPositionComparer.cs" /> <Compile Include="UI\FlatPositionComparer.cs" />
<Compile Include="UI\Navigation\Pager.cs" /> <Compile Include="UI\Navigation\Pager.cs" />
<Compile Include="UI\Navigation\PagerParameters.cs" />
<Compile Include="UI\Resources\IResourceManifestProvider.cs" /> <Compile Include="UI\Resources\IResourceManifestProvider.cs" />
<Compile Include="UI\Resources\ResourceManifestBuilder.cs" /> <Compile Include="UI\Resources\ResourceManifestBuilder.cs" />
<Compile Include="UI\Zones\LayoutWorkContext.cs" /> <Compile Include="UI\Zones\LayoutWorkContext.cs" />
+1
View File
@@ -12,5 +12,6 @@ namespace Orchard.Settings {
string HomePage { get; set; } string HomePage { get; set; }
string SiteCulture { get; set; } string SiteCulture { get; set; }
ResourceDebugMode ResourceDebugMode { get; set; } ResourceDebugMode ResourceDebugMode { get; set; }
int PageSize { get; set; }
} }
} }
+39 -12
View File
@@ -1,22 +1,49 @@
namespace Orchard.UI.Navigation { using Orchard.Settings;
namespace Orchard.UI.Navigation {
public class Pager { public class Pager {
private const int PageDefault = 1; /// <summary>
public const int PageSizeDefault = 10; /// The default page number.
private int _pageSize; /// </summary>
private int _size; public const int PageDefault = 1;
public int Page { /// <summary>
get { return _pageSize > 0 ? _pageSize : PageDefault; } /// Constructs a new pager.
set { _pageSize = value; } /// </summary>
/// <param name="site">The site settings.</param>
/// <param name="pagerParameters">The pager parameters.</param>
public Pager(ISite site, PagerParameters pagerParameters)
: this(site, pagerParameters.Page, pagerParameters.PageSize) {
} }
public int PageSize { /// <summary>
get { return _size > 0 ? _size : PageSizeDefault; } /// Constructs a new pager.
set { _size = value; } /// </summary>
/// <param name="site">The site settings.</param>
/// <param name="page">The page parameter.</param>
/// <param name="pageSize">The page size parameter.</param>
public Pager(ISite site, int? page, int? pageSize) {
Page = (int) (page != null ? (page > 0 ? page : PageDefault) : PageDefault);
PageSize = pageSize ?? site.PageSize;
} }
/// <summary>
/// Gets or sets the current page number or the default page number if none is specified.
/// </summary>
public int Page { get; set; }
/// <summary>
/// Gets or sets the current page size or the site default size if none is specified.
/// </summary>
public int PageSize { get; set; }
/// <summary>
/// Gets the current page start index.
/// </summary>
/// <param name="page">The current page number.</param>
/// <returns>The index in which the page starts.</returns>
public int GetStartIndex(int? page = null) { public int GetStartIndex(int? page = null) {
return ((page ?? Page) - 1)*PageSize; return ((page ?? Page) - PageDefault) * PageSize;
} }
} }
} }
@@ -0,0 +1,13 @@
namespace Orchard.UI.Navigation {
public class PagerParameters {
/// <summary>
/// Gets or sets the current page number or null if none specified.
/// </summary>
public int? Page { get; set; }
/// <summary>
/// Gets or sets the current page size or null if none specified.
/// </summary>
public int? PageSize { get; set; }
}
}