Adding MaxPageSize to ISite

This commit is contained in:
Sebastien Ros
2014-03-13 14:13:57 -07:00
parent 6e17c7c6f5
commit 734fa047bf
9 changed files with 48 additions and 9 deletions

View File

@@ -76,7 +76,12 @@ namespace Orchard.Tests.Stubs {
set { throw new NotImplementedException(); }
}
public int PageSize{
public int PageSize {
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
public int MaxPageSize {
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}

View File

@@ -71,6 +71,7 @@ namespace Orchard.Core.Settings.Drivers {
var previousBaseUrl = model.Site.BaseUrl;
var previousSuperUser = model.Site.SuperUser;
var previousMaxPageSize = model.Site.MaxPageSize;
updater.TryUpdateModel(model, Prefix, null, null);
@@ -90,6 +91,7 @@ namespace Orchard.Core.Settings.Drivers {
}
else {
model.Site.SuperUser = previousSuperUser;
model.Site.MaxPageSize = previousMaxPageSize;
}
// ensure the base url is absolute if provided

View File

@@ -50,6 +50,11 @@ namespace Orchard.Core.Settings.Models {
set { this.Store(x => x.PageSize, value); }
}
public int MaxPageSize {
get { return this.Retrieve(x => x.MaxPageSize); }
set { this.Store(x => x.MaxPageSize, value); }
}
public string SiteTimeZone {
get { return this.Retrieve(x => x.SiteTimeZone); }
set { this.Store(x => x.SiteTimeZone, value); }

View File

@@ -51,6 +51,11 @@ namespace Orchard.Core.Settings.ViewModels {
set { Site.PageSize = value; }
}
public int MaxPageSize {
get { return Site.MaxPageSize; }
set { Site.MaxPageSize = value; }
}
public string BaseUrl {
get { return Site.BaseUrl; }
set { Site.BaseUrl = value; }

View File

@@ -45,14 +45,14 @@
@Html.EditorFor(x => x.PageTitleSeparator)
@Html.ValidationMessage("PageTitleSeparator", "*")
</div>
@if (AuthorizedFor(Orchard.Security.StandardPermissions.SiteOwner)) {
<div>
<label for="SuperUser">@T("Super user")</label>
@Html.EditorFor(x => x.SuperUser)
@Html.ValidationMessage("SuperUser", "*")
<span class="hint">@T("Enter an existing account name, or nothing if you don't want a Super user account")</span>
</div>
}
@if (AuthorizedFor(Orchard.Security.StandardPermissions.SiteOwner)) {
<div>
<label for="SuperUser">@T("Super user")</label>
@Html.EditorFor(x => x.SuperUser)
@Html.ValidationMessage("SuperUser", "*")
<span class="hint">@T("Enter an existing account name, or nothing if you don't want a Super user account")</span>
</div>
}
<div>
<label for="SiteDebugMode">@T("Resource Debug Mode")</label>
@Html.DropDownList("ResourceDebugMode", resourceDebugMode)
@@ -63,4 +63,11 @@
@Html.TextBoxFor(m => m.PageSize, new { @class = "text small" })
<span class="hint">@T("Determines the default number of items that are shown per page.")</span>
</div>
@if (AuthorizedFor(Orchard.Security.StandardPermissions.SiteOwner)) {
<div>
<label for="MaxPageSize">@T("Maximum number of items per page")</label>
@Html.TextBoxFor(m => m.MaxPageSize, new {@class = "text small"})
<span class="hint">@T("Determines the maximum number of items that are shown per page. Leave 0 for unlimited.")</span>
</div>
}
</fieldset>

View File

@@ -191,6 +191,11 @@ namespace Orchard.Setup {
set { throw new NotImplementedException(); }
}
public int MaxPageSize {
get { return SiteSettingsPart.DefaultPageSize; }
set { throw new NotImplementedException(); }
}
public string BaseUrl {
get { return ""; }
}

View File

@@ -85,6 +85,11 @@ namespace Orchard.Tokens.Tests {
set { throw new NotImplementedException(); }
}
public int MaxPageSize {
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
public string BaseUrl { get; set; }
public string SiteTimeZone {

View File

@@ -14,6 +14,7 @@ namespace Orchard.Settings {
string SiteCalendar { get; set; }
ResourceDebugMode ResourceDebugMode { get; set; }
int PageSize { get; set; }
int MaxPageSize { get; set; }
string BaseUrl { get; }
string SiteTimeZone { get; }
}

View File

@@ -25,6 +25,10 @@ namespace Orchard.UI.Navigation {
public Pager(ISite site, int? page, int? pageSize) {
Page = (int) (page != null ? (page > 0 ? page : PageDefault) : PageDefault);
PageSize = pageSize ?? site.PageSize;
if (site.MaxPageSize > 0 && PageSize > site.MaxPageSize) {
PageSize = site.MaxPageSize;
}
}
/// <summary>