rapila
Public Member Functions | Protected Attributes | List of all members
SimplePager Class Reference
Inheritance diagram for SimplePager:

Public Member Functions

 __construct ($oQuery, $iPage=1, $iMaxRowsPerPage=25)
 
 requiresPagination ()
 
 setPageLinkBase ($sPageLinkBaseBase)
 
 getResult ()
 
 getQuery ()
 
 getFirstPage ()
 
 atFirstPage ()
 
 getLastPage ()
 
 atLastPage ()
 
 getPreviousLinks ($iRange=5)
 
 getNextLinks ($iRange=5)
 
 isLastPageComplete ()
 
 getPrevious ()
 
 getNext ()
 
 getPageLink ($iPage)
 
 getPreviousLink ()
 
 getNextLink ()
 
 setPage ($iPage)
 
 getPage ()
 
 setRowsPerPage ($iMaxRowsPerPage)
 
 getRowsPerPage ()
 
 getTotalRecordCount ()
 
 setStart ($iValue)
 
 getTotalPageCount ()
 
 setMaxRowPerPage ($iValue)
 
 getRowsOnPage ($iPage)
 
 count ()
 
 current ()
 
 key ()
 
 next ()
 
 rewind ()
 
 valid ()
 

Protected Attributes

 $iStart = 0
 
 $iMaxRowsPerPage = 0
 

Detailed Description

This file is part of the Rapila package. For the full copyright and license information, please view the LICENSE file that was distributed with this source code.

MIT License SimplePager • inspired by the PropelPager • handling only query objects

Example Usage:

$oQuery = ExampleQuery::create()->whateverQuery();

$oPager = new SimplePager($oQuery, 1, 50); [query, page, max_rows per_page]

$oPager->requiresPagination() $oPager->setPageLinkBase(url_without_page)

$oPager->getPreviousLink() $oPager->getNextLink()

foreach($oPager->getPreviousLinks() as $iPage) { echo $oPager->getPageLink($iPage); } // returns PropelCollection $oPager->getResult()[->getData()]

Iterate since PropelObjects extends ArrayObject $oIterator = $oPager->getResult()->getIterator(); while ($oIterator->valid()) { echo $oIterator->current(); $oIterator->next(); }

// Queries executed with defined select $oPager->getQuery()->select('fieldName1', 'fieldName2')->find() // etc

Author
Jürg Messmer jm@mo.nosp@m.saic.nosp@m.s.ch
Version
0.8 20120908.1121

Constructor & Destructor Documentation

SimplePager::__construct (   $oQuery,
  $iPage = 1,
  $iMaxRowsPerPage = 25 
)

Create a new Simple Pager.

Parameters
Criteria$oQuery
int$iPageThe current iPage (1-based).
int$iMaxRowsPerPageThe number of rows that should be displayed per iPage.

Member Function Documentation

SimplePager::atFirstPage ( )

Convenience method to indicate whether current iPage is the first iPage.

Returns
boolean
SimplePager::atLastPage ( )

Convenience method to indicate whether current iPage is the last page.

Returns
boolean
SimplePager::count ( )

Returns the count of the current page's records

Returns
int
SimplePager::getFirstPage ( )

Get the first iPage

For now I can only think of returning 1 always. It should probably return 0 if there are no iTotalPageCount

Returns
int 1
SimplePager::getLastPage ( )

Get last iPage

Returns
int $lastPage
SimplePager::getNext ( )

Get next id

Returns
mixed $next
SimplePager::getNextLink ( )

get relative or absolute page link

Returns
mixed string/null
SimplePager::getNextLinks (   $iRange = 5)

Get an array of next id's

Parameters
int$iRange
Returns
array $links
SimplePager::getPage ( )

Get current iPage.

Returns
int
SimplePager::getPageLink (   $iPage)
Parameters
int$iPage
Returns
string
SimplePager::getPrevious ( )

Get previous id

Returns
mixed $prev
SimplePager::getPreviousLink ( )

get relative or absolute page link

Returns
mixed string/null
SimplePager::getPreviousLinks (   $iRange = 5)

Get an array of previous id's

Parameters
int$iRange
Returns
array $links
SimplePager::getQuery ( )
Returns
query object
SimplePager::getResult ( )

Get the iPaged resultset

Returns
PropelCollection
SimplePager::getRowsPerPage ( )

Get number of rows per iPage.

Returns
int
SimplePager::getTotalPageCount ( )

get total iTotalPageCount

Returns
int Total page count
SimplePager::getTotalRecordCount ( )

Gets the total number of (un-LIMITed) records.

Returns
int Total number of records - disregarding iPage, iMaxRowsPerPage, etc.
SimplePager::isLastPageComplete ( )

Returns whether last page is complete

Returns
bool Last page complete or not
SimplePager::requiresPagination ( )
Returns
boolean
SimplePager::setMaxRowPerPage (   $iValue)

Sets max rows (limit).

Parameters
int$iValue
Returns
void
SimplePager::setPage (   $iPage)

Set the current iPage number (First iPage is 1).

Parameters
int$iPage
Returns
void
SimplePager::setPageLinkBase (   $sPageLinkBaseBase)

Set the asic pager url without page number

Parameters
stringbase url description: the base url without the page id
Returns
void
SimplePager::setRowsPerPage (   $iMaxRowsPerPage)

Set the number of rows per iPage.

Parameters
int$iMaxRowsPerPage
SimplePager::setStart (   $iValue)

Sets the start row or offset.

Parameters
int

The documentation for this class was generated from the following file: