Chyrp

Paginator

Paginates over an array.

Summary
Paginator Paginates over an array.
Functions
__construct Prepares an array for pagination.
next Returns the next pagination sequence.
prev Returns the next pagination sequence.
next_page Checks whether or not it makes sense to show the Next Page link.
prev_page Checks whether or not it makes sense to show the Previous Page link.
next_link Outputs a link to the next page.
prev_link Outputs a link to the previous page.
next_page_url Returns the URL to the next page.
prev_page_url Returns the URL to the previous page.

Functions

__construct

public function __construct( $array,   
$per_page  =  5,
$name  =  "page",
$model  =  true,
$page  =  null )

Prepares an array for pagination.

Parameters

$array The array to paginate.
$per_page Amount of items per page.
$name The name of the $_GET parameter to use for determining the current page.
$model If this is true, each item in $array that gets shown on the page will be initialized as a model of whatever is passed as the second argument to $array.  The first argument of $array is expected to be an array of IDs.

Returns

A paginated array $per_page or smaller.

next

public function next()

Returns the next pagination sequence.

prev

public function prev()

Returns the next pagination sequence.

next_page

public function next_page()

Checks whether or not it makes sense to show the Next Page link.

prev_page

public function prev_page()

Checks whether or not it makes sense to show the Previous Page link.

next_link

public function next_link( $text  =  null,
$class  =  "next_page",
$clean_urls  =  true )

Outputs a link to the next page.

Parameters

$text The text for the link.
$class The CSS class for the link.
$clean_urls Whether to link with dirty or clean URLs.

prev_link

public function prev_link( $text  =  null,
$class  =  "prev_page",
$clean_urls  =  true )

Outputs a link to the previous page.

Parameters

$text The text for the link.
$class The CSS class for the link.
$clean_urls Whether to link with dirty or clean URLs.

next_page_url

public function next_page_url( $clean_urls  =  true )

Returns the URL to the next page.

Parameters

$clean_urls Whether to link with dirty or clean URLs.

prev_page_url

public function prev_page_url( $clean_urls  =  true )

Returns the URL to the previous page.

Parameters

$clean_urls Whether to link with dirty or clean URLs.