#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

View File

@@ -11,20 +11,29 @@ using Orchard.Themes;
using Orchard.UI.Navigation;
namespace Orchard.Core.Containers.Controllers {
using Orchard.Settings;
public class ItemController : Controller {
private readonly IContentManager _contentManager;
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;
_containersPathConstraint = containersPathConstraint;
_siteService = siteService;
Shape = shapeFactory;
}
dynamic Shape { get; set; }
[Themed]
public ActionResult Display(string path, Pager pager) {
public ActionResult Display(string path, PagerParameters pagerParameters) {
var matchedPath = _containersPathConstraint.FindPath(path);
if (string.IsNullOrEmpty(matchedPath)) {
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;
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
: container.As<ContainerPart>().Record.PageSize;
var pagerShape = Shape.Pager(pager).TotalItemCount(query.Count());