Class Helper_Page {
/** Total Information count */
Var $ infoCount;
/** Total page number */
Var $ pageCount;
/** Number of entries displayed per page */
Var $ items;
/** Current page number */
Var $ pageNo;
/** Start position of the query */
Var $ startPos;
/** Next page */
Var $ nextPageNo;
/** Previous page */
Var $ prevPageNo;
Function Helper_Page ($ infoCount, $ items, $ pageNo)
{
$ This-> infoCount = $ infoCount;
$ This-> items = $ items;
$ This-> pageNo = $ pageNo;
$ This-> pageCount = $ this-> GetPageCount ();
$ This-> AdjustPageNo ();
$ This-> startPos = $ this-> GetStartPos ();
}
Function AdjustPageNo ()
{
If ($ this-> pageNo = ''| $ this-> pageNo <1)
$ This-> pageNo = 1;
If ($ this-> pageNo> $ this-> pageCount)
$ This-> pageNo = $ this-> pageCount;
}
/**
* Next Page
*/
Function GoToNextPage ()
{
$ NextPageNo = $ this-> pageNo + 1;
If ($ nextPageNo> $ this-> pageCount)
{
$ This-> nextPageNo = $ this-> pageCount;
Return false;
}
$ This-> nextPageNo = $ nextPageNo;
Return true;
}
/**
* Previous Page
*/
Function GotoPrevPage ()
{
$ PrevPageNo = $ this-> pageNo-1;
If ($ prevPageNo <1)
{
$ This-> prevPageNo = 1;
Return false;
}
$ This-> prevPageNo = $ prevPageNo;
Return true;
}
Function GetPageCount ()
{
Return ceil ($ this-> infoCount/$ this-> items );
}
Function GetStartPos ()
{
Return ($ this-> pageNo-1) * $ this-> items;
}
}