bug fixes
* Makefile: my deploy config * NpgsqlMembershipProvider.cs: Fixes a Bug introduced by Npgsql driver upgrade * ResultPages.cs: . * style.css: other colors * BlogsController.cs: code cleaning * GoogleController.cs: refactoring * ErrorHtmlFormatter.cs: MarkdownDeep calls now come from yavscModel * YavscHelpers.cs: xmldoc * Index.aspx: code formatting * UserPosts.aspx: nothing to note * Web.csproj: MarkdownHelper has gone to the yavscModel project * MarkdownHelper.cs: * BlogEntryCollection.cs: refactoring + extract an intro from Markdown for PostInfo* * YavscModel.csproj: MarkdownHelper integration
This commit is contained in:
parent
bdae927f67
commit
ce1689df7b
19 changed files with 193 additions and 129 deletions
|
|
@ -1,3 +1,7 @@
|
|||
2015-10-04 Paul Schneider <paul@pschneider.fr>
|
||||
|
||||
* ResultPages.cs: .
|
||||
|
||||
2015-09-23 Paul Schneider <paul@pschneider.fr>
|
||||
|
||||
* InputUserName.cs: formatting
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using System.Security.Permissions;
|
|||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using System.ComponentModel;
|
||||
using System.Collections;
|
||||
|
||||
namespace Yavsc.WebControls
|
||||
{
|
||||
|
|
@ -29,19 +30,16 @@ namespace Yavsc.WebControls
|
|||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the results per page.
|
||||
/// </summary>
|
||||
/// <value>The results per page.</value>
|
||||
[Bindable (true)]
|
||||
[DefaultValue(10)]
|
||||
public int ResultsPerPage {
|
||||
public int PageSize {
|
||||
get {
|
||||
return (int)( ViewState["ResultsPerPage"]==null?10:ViewState["ResultsPerPage"]);
|
||||
return (int)( ViewState["PageSize"]==null?10:ViewState["PageSize"]);
|
||||
}
|
||||
set {
|
||||
ViewState["ResultsPerPage"]=value;
|
||||
ViewState["PageSize"]=value;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -50,11 +48,8 @@ namespace Yavsc.WebControls
|
|||
/// Gets or sets the result count.
|
||||
/// </summary>
|
||||
/// <value>The result count.</value>
|
||||
[Bindable (true)]
|
||||
[DefaultValue(0)]
|
||||
public int ResultCount {
|
||||
get {
|
||||
|
||||
return (int)( ViewState["ResultCount"]==null?0:ViewState["ResultCount"]);
|
||||
}
|
||||
set {
|
||||
|
|
@ -66,7 +61,6 @@ namespace Yavsc.WebControls
|
|||
/// Gets or sets the text.
|
||||
/// </summary>
|
||||
/// <value>The text.</value>
|
||||
[Bindable (true)]
|
||||
[DefaultValue("Pages:")]
|
||||
[Localizable(true)]
|
||||
public string Text {
|
||||
|
|
@ -85,25 +79,27 @@ namespace Yavsc.WebControls
|
|||
/// </summary>
|
||||
/// <value>The action.</value>
|
||||
[Bindable (true)]
|
||||
[DefaultValue("")]
|
||||
[DefaultValue("?pageIndex=")]
|
||||
public string Action {
|
||||
get {
|
||||
|
||||
string s = (string)ViewState["Action"];
|
||||
return (s == null) ? String.Empty : s;
|
||||
return (s == null) ? "?pageIndex=" : s;
|
||||
}
|
||||
set {
|
||||
ViewState["Action"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the none.
|
||||
/// </summary>
|
||||
/// <value>The none.</value>
|
||||
[Bindable (true)]
|
||||
[DefaultValue("none")]
|
||||
public string None {
|
||||
get {
|
||||
|
||||
string s = (string) ViewState["None"];
|
||||
return (s == null) ? String.Empty : s;
|
||||
return (string) ViewState["None"];
|
||||
}
|
||||
set {
|
||||
ViewState["None"] = value;
|
||||
|
|
@ -116,41 +112,42 @@ namespace Yavsc.WebControls
|
|||
/// <value>The current page.</value>
|
||||
[Bindable (true)]
|
||||
[DefaultValue(0)]
|
||||
public int CurrentPage {
|
||||
public int PageIndex {
|
||||
get {
|
||||
int i = (int)(ViewState["CurrentPage"]==null?0:ViewState["CurrentPage"]);
|
||||
int i = (int)(ViewState["PageIndex"]==null?0:ViewState["PageIndex"]);
|
||||
return i;
|
||||
}
|
||||
set {
|
||||
ViewState["CurrentPage"] = value;
|
||||
ViewState["PageIndex"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders the contents as the list of links to pages of results.
|
||||
/// </summary>
|
||||
/// <param name="writer">Writer.</param>
|
||||
protected override void RenderContents (HtmlTextWriter writer)
|
||||
{
|
||||
if (ResultCount > 0 && ResultCount > ResultsPerPage ) {
|
||||
if (ResultCount > 0 && ResultCount > PageSize ) {
|
||||
writer.WriteEncodedText (Text);
|
||||
int pageCount = ((ResultCount-1) / ResultsPerPage) + 1;
|
||||
for (int pi = (CurrentPage < 5) ? 0 : CurrentPage - 5; pi < pageCount && pi < CurrentPage + 5; pi++) {
|
||||
if (CurrentPage == pi)
|
||||
writer.RenderBeginTag ("b");
|
||||
else {
|
||||
writer.AddAttribute (HtmlTextWriterAttribute.Href,
|
||||
string.Format (Action, pi));
|
||||
writer.RenderBeginTag ("a");
|
||||
int pageCount = ((ResultCount-1) / PageSize) + 1;
|
||||
if ( pageCount > 1 ) {
|
||||
for (int pi = (PageIndex < 5) ? 0 : PageIndex - 5; pi < pageCount && pi < PageIndex + 5; pi++) {
|
||||
if (PageIndex == pi)
|
||||
writer.RenderBeginTag ("b");
|
||||
else {
|
||||
writer.AddAttribute (HtmlTextWriterAttribute.Href,
|
||||
string.Format (Action, pi));
|
||||
writer.RenderBeginTag ("a");
|
||||
}
|
||||
writer.Write (pi + 1);
|
||||
writer.RenderEndTag ();
|
||||
writer.Write (" ");
|
||||
}
|
||||
writer.Write (pi+1);
|
||||
writer.RenderEndTag ();
|
||||
writer.Write (" ");
|
||||
}
|
||||
}
|
||||
if (ResultCount == 0) {
|
||||
writer.Write ("(");
|
||||
writer.Write (None);
|
||||
writer.Write (")");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue