PHP Class Pop\Paginator\Paginator

Author: Nick Sagona, III ([email protected])
Show file Open project: nicksagona/PopPHP Class Usage Examples

Protected Properties

Property Type Description
$bookendKey integer Page bookend key
$bookends array Page bookends
$classOff string Class 'off' name for page link tags
$classOn string Class 'on' name for page link tags
$dateFormat string Date format for handle date strings
$end integer Current page end index property
$footer string Footer template
$header string Header template
$items array Content items
$links array Page links property
$numPages integer Number of pages property
$output string Page ouput
$perPage integer Items per page property
$range integer Page range property
$rem integer Remainder property
$rowTemplate string Row template
$separator string Bookend separator
$start integer Current page start index property
$total integer Total item count property

Public Methods

Method Description
__construct ( array $items, integer $perPage = 10, integer $range = 10, integer $total = null ) : Paginator Constructor
__toString ( ) : string Output the rendered page
factory ( array $items, integer $perPage = 10, integer $range = 10, integer $total = null ) : Paginator Static method to instantiate the paginator object and return itself to facilitate chaining methods together.
getClassOff ( ) : string Method to get the class 'off' name.
getClassOn ( ) : string Method to get the class 'on' name.
getDateFormat ( ) : string Method to get the date format.
getFooter ( ) : string Method to get the footer template.
getHeader ( ) : string Method to get the header template.
getItemCount ( ) : integer Method to get the number of content items.
getItems ( ) : array Method to get the content items.
getLinks ( integer $pg = null ) : string Method to get the page links.
getPerPage ( ) : integer Method to get the page range.
getRange ( ) : integer Method to get the page range.
getRowTemplate ( ) : string Method to get the row template.
getSeparator ( ) : string Method to get the bookend separator.
getTotal ( ) : integer Method to get the content items total
render ( integer | string $pg, boolean $ret = false ) : mixed Method to render the current page.
setBookend ( integer $key = Paginator::SINGLE_ARROWS ) : Paginator Method to set the bookend key.
setClassOff ( string $cls ) : Paginator Method to set the class 'off' name.
setClassOn ( string $cls ) : Paginator Method to set the class 'on' name.
setDateFormat ( string $date = null ) : Paginator Method to set the date format.
setFooter ( string $ftr ) : Paginator Method to set the footer template.
setHeader ( string $hdr ) : Paginator Method to set the header template.
setItems ( array $items ) : Paginator Method to set the content items.
setPerPage ( integer $perPage = 10 ) : Paginator Method to set the page range.
setRange ( integer $range = 10 ) : Paginator Method to set the page range.
setRowTemplate ( string $tmpl ) : Paginator Method to set the row template.
setSeparator ( string $sep = ' | ' ) : Paginator Method to set the bookend separator.
setTotal ( integer $total = null ) : Paginator Method to set the content items total

Protected Methods

Method Description
calcItems ( integer | string $p ) : void Method to calculate the page items.
calcRange ( integer | string $pg ) : array Method to calculate the page range.
createLinks ( integer $pg = null ) : void Method to create links.

Method Details

__construct() public method

Instantiate the paginator object.
public __construct ( array $items, integer $perPage = 10, integer $range = 10, integer $total = null ) : Paginator
$items array
$perPage integer
$range integer
$total integer
return Paginator

__toString() public method

Output the rendered page
public __toString ( ) : string
return string

calcItems() protected method

Method to calculate the page items.
protected calcItems ( integer | string $p ) : void
$p integer | string
return void

calcRange() protected method

Method to calculate the page range.
protected calcRange ( integer | string $pg ) : array
$pg integer | string
return array

factory() public static method

Static method to instantiate the paginator object and return itself to facilitate chaining methods together.
public static factory ( array $items, integer $perPage = 10, integer $range = 10, integer $total = null ) : Paginator
$items array
$perPage integer
$range integer
$total integer
return Paginator

getClassOff() public method

Method to get the class 'off' name.
public getClassOff ( ) : string
return string

getClassOn() public method

Method to get the class 'on' name.
public getClassOn ( ) : string
return string

getDateFormat() public method

Method to get the date format.
public getDateFormat ( ) : string
return string

getFooter() public method

Method to get the footer template.
public getFooter ( ) : string
return string

getHeader() public method

Method to get the header template.
public getHeader ( ) : string
return string

getItemCount() public method

Method to get the number of content items.
public getItemCount ( ) : integer
return integer

getItems() public method

Method to get the content items.
public getItems ( ) : array
return array

getPerPage() public method

Method to get the page range.
public getPerPage ( ) : integer
return integer

getRange() public method

Method to get the page range.
public getRange ( ) : integer
return integer

getRowTemplate() public method

Method to get the row template.
public getRowTemplate ( ) : string
return string

getSeparator() public method

Method to get the bookend separator.
public getSeparator ( ) : string
return string

getTotal() public method

Method to get the content items total
public getTotal ( ) : integer
return integer

render() public method

Method to render the current page.
public render ( integer | string $pg, boolean $ret = false ) : mixed
$pg integer | string
$ret boolean
return mixed

setBookend() public method

Method to set the bookend key.
public setBookend ( integer $key = Paginator::SINGLE_ARROWS ) : Paginator
$key integer
return Paginator

setClassOff() public method

Method to set the class 'off' name.
public setClassOff ( string $cls ) : Paginator
$cls string
return Paginator

setClassOn() public method

Method to set the class 'on' name.
public setClassOn ( string $cls ) : Paginator
$cls string
return Paginator

setDateFormat() public method

Method to set the date format.
public setDateFormat ( string $date = null ) : Paginator
$date string
return Paginator

setFooter() public method

Method to set the footer template.
public setFooter ( string $ftr ) : Paginator
$ftr string
return Paginator

setHeader() public method

Method to set the header template.
public setHeader ( string $hdr ) : Paginator
$hdr string
return Paginator

setItems() public method

Method to set the content items.
public setItems ( array $items ) : Paginator
$items array
return Paginator

setPerPage() public method

Method to set the page range.
public setPerPage ( integer $perPage = 10 ) : Paginator
$perPage integer
return Paginator

setRange() public method

Method to set the page range.
public setRange ( integer $range = 10 ) : Paginator
$range integer
return Paginator

setRowTemplate() public method

Method to set the row template.
public setRowTemplate ( string $tmpl ) : Paginator
$tmpl string
return Paginator

setSeparator() public method

Method to set the bookend separator.
public setSeparator ( string $sep = ' | ' ) : Paginator
$sep string
return Paginator

setTotal() public method

Method to set the content items total
public setTotal ( integer $total = null ) : Paginator
$total integer
return Paginator

Property Details

$bookendKey protected property

Page bookend key
protected int $bookendKey
return integer

$bookends protected property

Page bookends
protected array $bookends
return array

$classOff protected property

Class 'off' name for page link tags
protected string $classOff
return string
Date format for handle date strings
protected string $dateFormat
return string

$end protected property

Current page end index property
protected int $end
return integer

$header protected property

Header template
protected string $header
return string

$items protected property

Content items
protected array $items
return array

$numPages protected property

Number of pages property
protected int $numPages
return integer

$output protected property

Page ouput
protected string $output
return string

$perPage protected property

Items per page property
protected int $perPage
return integer

$range protected property

Page range property
protected int $range
return integer

$rem protected property

Remainder property
protected int $rem
return integer

$rowTemplate protected property

Row template
protected string $rowTemplate
return string

$separator protected property

Bookend separator
protected string $separator
return string

$start protected property

Current page start index property
protected int $start
return integer

$total protected property

Total item count property
protected int $total
return integer