Detailed Description

PagingInfo contains information about a paged list.

Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 18 of file PagingInfo.php.

Public Member Functions

 __construct ($pageSize, $ignoreTotalCount=false)
 
 setTotalCount ($totalCount)
 
 getTotalCount ()
 
 setPage ($page)
 
 getPage ()
 
 getPageSize ()
 
 getPageCount ()
 
 setOffset ($offset)
 
 getOffset ()
 
 isOnFirstPage ()
 
 isOnLastPage ()
 
 isIgnoringTotalCount ()
 
 getPagination ($urlPattern, $maxDisplayPages=10)
 

Public Attributes

const SIZE_INFINITE = -1
 

Constructor & Destructor Documentation

◆ __construct()

__construct (   $pageSize,
  $ignoreTotalCount = false 
)

Creates a PagingInfo object.

The ignoreTotalCount parameter may be set to true, if the count is to be ignored. This may speed up loading of objects, because an extra count query may be omitted.

Parameters
$pageSizeThe pageSize (PagingInfo::SIZE_INFINITE to set no page size)
$ignoreTotalCountBoolean whether this instance ignores the total count or not (optional, default: false)

Definition at line 36 of file PagingInfo.php.

Member Function Documentation

◆ setTotalCount()

setTotalCount (   $totalCount)

Set the number of list items.

Parameters
$totalCountThe number of list items.

Definition at line 48 of file PagingInfo.php.

◆ getTotalCount()

getTotalCount ( )

Get the number of list items.

Returns
Number

Definition at line 56 of file PagingInfo.php.

◆ setPage()

setPage (   $page)

Set the current page (1-based) (also sets the offset).

Parameters
$pageThe current page.

Definition at line 64 of file PagingInfo.php.

◆ getPage()

getPage ( )

Get the current page (1-based).

Returns
Number

Definition at line 73 of file PagingInfo.php.

◆ getPageSize()

getPageSize ( )

Get the size of a pages.

Returns
Number

Definition at line 81 of file PagingInfo.php.

◆ getPageCount()

getPageCount ( )

Get the number of pages.

Returns
Number

Definition at line 89 of file PagingInfo.php.

◆ setOffset()

setOffset (   $offset)

Set the current offset (also selects the page).

Parameters
$offsetThe current list offset.

Definition at line 97 of file PagingInfo.php.

◆ getOffset()

getOffset ( )

Get the current offset.

Returns
Number

Definition at line 106 of file PagingInfo.php.

◆ isOnFirstPage()

isOnFirstPage ( )

Determine if we are on the first page.

Returns
Boolean

Definition at line 114 of file PagingInfo.php.

◆ isOnLastPage()

isOnLastPage ( )

Determine if we are on the first page.

Returns
Boolean

Definition at line 122 of file PagingInfo.php.

◆ isIgnoringTotalCount()

isIgnoringTotalCount ( )

Check if this instance iignores the total count.

Returns
Boolean

Definition at line 130 of file PagingInfo.php.

◆ getPagination()

getPagination (   $urlPattern,
  $maxDisplayPages = 10 
)

Get the pages for a pagination navigation.

Parameters
$urlPatternUrl string to use containing literal {page}, that will be replaced
$maxDisplayPagesMaximum number of pages to display (optional, default: 10)
Returns
Array with keys 'first', 'last', 'current', 'prev', 'next', 'pages' and arrays with 'url', 'num' as values or null, if page count <= 1

Definition at line 140 of file PagingInfo.php.

Member Data Documentation

◆ SIZE_INFINITE

const SIZE_INFINITE = -1

Definition at line 20 of file PagingInfo.php.