ProcessWire PageArray
PageArray provides an array-like means for storing PageReferences and is
utilized throughout ProcessWire.
ProcessWire 2.x Copyright (C) 2010 by Ryan Cramer Licensed under GNU/GPL v2,
see LICENSE.TXT
http://www.processwire.com http://www.ryancramer.com
Methods summary
public
boolean
|
#
isValidItem( mixed $item )
Template mehod that descendant classes may use to validate items added to
this WireArray
Template mehod that descendant classes may use to validate items added to
this WireArray
Parameters
Returns
boolean True if item is valid and may be added, false if not
|
public
boolean
|
#
isValidKey( string|integer $key )
Validate the key used to add a Page
Validate the key used to add a Page
PageArrays are keyed by an incremental number that does NOT relate to the
Page ID.
Parameters
Returns
boolean True if key is valid and may be used, false if not
|
public
mixed
|
#
makeBlankItem( )
Per WireArray interface, return a blank Page
Per WireArray interface, return a blank Page
Returns
mixed
|
public
PageArray
|
#
import( array|PageArray|Page $pages )
Import the provided pages into this PageArray.
Import the provided pages into this PageArray.
Parameters
Returns
|
public
boolean
|
#
has( Page|id $key )
Does this PageArray contain the given index or Page?
Does this PageArray contain the given index or Page?
Parameters
- $key
Page|id $page Array index or Page object.
Returns
boolean True if the index or Page exists here, false if not.
|
public
PageArray
|
#
add( Page|PageArray|integer $page )
Add a Page to this PageArray.
Add a Page to this PageArray.
Parameters
- $page
Page|PageArray|integer Page object, PageArray object, or Page ID. If Page, the Page will be added. If
PageArray, it will do the same thing as the import() function: import all the
pages. If Page ID, it will be loaded and added.
Returns
|
public
|
#
set( integer $key, Page $value )
Sets an index in the PageArray.
Sets an index in the PageArray.
Parameters
- $key
integer Key of item to set.
- $value
Page Value of item.
|
public
WireArray
|
#
prepend( Page $item )
Prepend a Page to the beginning of the PageArray.
Prepend a Page to the beginning of the PageArray.
Parameters
Returns
|
public
boolean
|
#
remove( integer|Page $key )
Remove the given Page or key from the PageArray.
Remove the given Page or key from the PageArray.
Parameters
Returns
boolean true if removed, false if not
|
public
Page|null
|
#
shift( )
Shift the first Page off of the PageArray and return it.
Shift the first Page off of the PageArray and return it.
Returns
|
public
Page|null
|
#
pop( )
Pop the last page off of the PageArray and return it.
Pop the last page off of the PageArray and return it.
Returns
|
public
PageArray
|
#
setTotal( integer $total )
Set the total number of pages, if more than are in this PageArray.
Set the total number of pages, if more than are in this PageArray.
Used for pagination.
Parameters
Returns
|
public
integer
|
#
getTotal( )
Get the total number of pages, if more than are in this PageArray.
Get the total number of pages, if more than are in this PageArray.
Used for pagination.
Returns
integer
|
public
integer
|
#
getLimit( )
Get the imposed limit on number of pages.
Get the imposed limit on number of pages.
If no limit set, then return number of pages currently in this PageArray.
Used for pagination.
Returns
integer
|
public
|
#
setStart( integer $numStart )
Set the 'start' limitor that resulted in this PageArray
Set the 'start' limitor that resulted in this PageArray
Parameters
- $numStart
integer $numStart;
|
public
integer
|
#
getStart( )
If a limit was imposed, get the index of the starting result assuming other
results preceded those present in this PageArray
If a limit was imposed, get the index of the starting result assuming other
results preceded those present in this PageArray
Used for pagination.
Returns
integer
|
public
PageArray
|
#
setLimit( integer $numLimit )
Set the imposed limit that resulted in this PageArray.
Set the imposed limit that resulted in this PageArray.
Used for pagination.
Parameters
Returns
|
public
|
#
setSelectors( Selectors $selectors )
Set the Selectors that led to this PageArray, if applicable
Set the Selectors that led to this PageArray, if applicable
Parameters
|
public
Selectors|null
|
#
getSelectors( )
Return the Selectors that led to this PageArray, or null if not
set/applicable
Return the Selectors that led to this PageArray, or null if not
set/applicable
Returns
|
protected
WireArray
|
#
filterData( string|Selectors $selectors, boolean $not = false )
Filter out Pages that don't match the selector.
Filter out Pages that don't match the selector.
This is applicable to and destructive to the WireArray.
Parameters
- $selectors
string|Selectors AttributeSelector string to use as the filter.
- $not
boolean Make this a "not" filter? (default is false)
Returns
WireArrayreference to current [filtered] instance
|
public
string
|
#
__toString( )
PageArrays always return a string of the Page IDs separated by pipe "|"
characters
PageArrays always return a string of the Page IDs separated by pipe "|"
characters
Pipe charactesr are used for compatibility with Selector OR statements
Returns
string
|
Properties summary
protected
integer
|
$numTotal
|
0 |
#
Total number of pages, including those here and others that aren't, but may
be here in pagination.
Total number of pages, including those here and others that aren't, but may
be here in pagination.
|
protected
integer
|
$numLimit
|
0 |
#
If this PageArray is a partial representation of a larger set, this will
contain the max number of pages allowed to be present/loaded in the PageArray at
once.
If this PageArray is a partial representation of a larger set, this will
contain the max number of pages allowed to be present/loaded in the PageArray at
once.
May vary from count() when on the last page of a result set. As a result,
paging routines should refer to their own itemsPerPage rather than count().
Applicable for paginated result sets. This number is not enforced for adding
items to this PageArray.
|
protected
integer
|
$numStart
|
0 |
#
If this PageArray is a partial representation of a larger set, this will
contain the starting result number if previous results preceded it.
If this PageArray is a partial representation of a larger set, this will
contain the starting result number if previous results preceded it.
|
protected
Selectors
|
$selectors
|
null |
#
Reference to the selectors that led to this PageArray, if applicable
Reference to the selectors that led to this PageArray, if applicable
|