PagerRenderer
in package
Class PagerRenderer
This class is passed to the view that describes the pagination, and is used to get the link information and provide utility methods needed to work with pagination.
Tags
Table of Contents
Properties
- $current : int
- Current page number.
- $first : int
- First page number in the set of links to be displayed.
- $last : int
- Last page number in the set of links to be displayed.
- $pageCount : int
- Total number of pages.
- $pageSelector : string
- Name of $_GET parameter
- $segment : int
- Segment number used for pagination.
- $total : int
- Total number of items.
- $uri : URI
- URI base for pagination links
Methods
- __construct() : mixed
- Constructor.
- getCurrent() : string
- Returns the URI of the current page.
- getCurrentPageNumber() : int
- Returns the page number of the current page.
- getFirst() : string
- Returns the URI of the first page.
- getFirstPageNumber() : int
- Returns the page number of the first page in the set of links to be displayed.
- getLast() : string
- Returns the URI of the last page.
- getLastPageNumber() : int
- Returns the page number of the last page in the set of links to be displayed.
- getNext() : string|null
- Returns a URL to the "next" page. The next page is NOT, the page after the current page, but is the page that follows the "last" page.
- getNextPage() : string|null
- Returns a URL to the "next" page.
- getNextPageNumber() : int|null
- Returns the next page number.
- getPageCount() : int
- Returns total number of pages.
- getPrevious() : string|null
- Returns a URL to the "previous" page. The previous page is NOT the page before the current page, but is the page just before the "first" page.
- getPreviousPage() : string|null
- Returns a URL to the "previous" page.
- getPreviousPageNumber() : int|null
- Returns the previous page number.
- hasNext() : bool
- Checks to see if there is a "next" page after our "last" page.
- hasNextPage() : bool
- Checks to see if there is a "next" page after our "last" page.
- hasPrevious() : bool
- Checks to see if there is a "previous" page before our "first" page.
- hasPreviousPage() : bool
- Checks to see if there is a "previous" page before our "first" page.
- links() : array<int, array{uri: string, title: int, active: bool}>
- Returns an array of links that should be displayed. Each link is represented by another array containing of the URI the link should go to, the title (number) of the link, and a boolean value representing whether this link is active or not.
- setSurroundCount() : PagerRenderer
- Sets the total number of links that should appear on either side of the current page. Adjusts the first and last counts to reflect it.
- updatePages() : void
- Updates the first and last pages based on $surroundCount, which is the number of links surrounding the active page to show.
Properties
$current
Current page number.
protected
int
$current
$first
First page number in the set of links to be displayed.
protected
int
$first
$last
Last page number in the set of links to be displayed.
protected
int
$last
$pageCount
Total number of pages.
protected
int
$pageCount
$pageSelector
Name of $_GET parameter
protected
string
$pageSelector
$segment
Segment number used for pagination.
protected
int
$segment
$total
Total number of items.
protected
int
$total
$uri
URI base for pagination links
protected
URI
$uri
Methods
__construct()
Constructor.
public
__construct(array<string|int, mixed> $details) : mixed
Parameters
- $details : array<string|int, mixed>
getCurrent()
Returns the URI of the current page.
public
getCurrent() : string
Return values
stringgetCurrentPageNumber()
Returns the page number of the current page.
public
getCurrentPageNumber() : int
Return values
intgetFirst()
Returns the URI of the first page.
public
getFirst() : string
Return values
stringgetFirstPageNumber()
Returns the page number of the first page in the set of links to be displayed.
public
getFirstPageNumber() : int
Return values
intgetLast()
Returns the URI of the last page.
public
getLast() : string
Return values
stringgetLastPageNumber()
Returns the page number of the last page in the set of links to be displayed.
public
getLastPageNumber() : int
Return values
intgetNext()
Returns a URL to the "next" page. The next page is NOT, the page after the current page, but is the page that follows the "last" page.
public
getNext() : string|null
Return values
string|nullgetNextPage()
Returns a URL to the "next" page.
public
getNextPage() : string|null
You MUST call hasNextPage() first, or this value may be invalid.
Return values
string|nullgetNextPageNumber()
Returns the next page number.
public
getNextPageNumber() : int|null
Return values
int|nullgetPageCount()
Returns total number of pages.
public
getPageCount() : int
Return values
intgetPrevious()
Returns a URL to the "previous" page. The previous page is NOT the page before the current page, but is the page just before the "first" page.
public
getPrevious() : string|null
Return values
string|nullgetPreviousPage()
Returns a URL to the "previous" page.
public
getPreviousPage() : string|null
You MUST call hasPreviousPage() first, or this value may be invalid.
Return values
string|nullgetPreviousPageNumber()
Returns the previous page number.
public
getPreviousPageNumber() : int|null
Return values
int|nullhasNext()
Checks to see if there is a "next" page after our "last" page.
public
hasNext() : bool
Return values
boolhasNextPage()
Checks to see if there is a "next" page after our "last" page.
public
hasNextPage() : bool
Return values
boolhasPrevious()
Checks to see if there is a "previous" page before our "first" page.
public
hasPrevious() : bool
Return values
boolhasPreviousPage()
Checks to see if there is a "previous" page before our "first" page.
public
hasPreviousPage() : bool
Return values
boollinks()
Returns an array of links that should be displayed. Each link is represented by another array containing of the URI the link should go to, the title (number) of the link, and a boolean value representing whether this link is active or not.
public
links() : array<int, array{uri: string, title: int, active: bool}>
Return values
array<int, array{uri: string, title: int, active: bool}>setSurroundCount()
Sets the total number of links that should appear on either side of the current page. Adjusts the first and last counts to reflect it.
public
setSurroundCount([int|null $count = null ]) : PagerRenderer
Parameters
- $count : int|null = null
Return values
PagerRendererupdatePages()
Updates the first and last pages based on $surroundCount, which is the number of links surrounding the active page to show.
protected
updatePages([int|null $count = null ]) : void
Parameters
- $count : int|null = null
-
The new "surroundCount"