Open Journal Systems  2.4.4
 All Classes Namespaces Functions Variables Groups Pages
VirtualArrayIterator Class Reference
Inheritance diagram for VirtualArrayIterator:
ItemIterator

Public Member Functions

 array_slice_key ($array, $offset, $len=-1)
 
 atFirstPage ()
 
 atLastPage ()
 
 eof ()
 
 getCount ()
 
 getPage ()
 
 getPageCount ()
 
next ()
 
nextWithKey ()
 
toArray ()
 
 VirtualArrayIterator (&$theArray, $totalItems, $page=-1, $itemsPerPage=-1)
 
 wasEmpty ()
 
- Public Member Functions inherited from ItemIterator
 atFirstPage ()
 
 atLastPage ()
 
 eof ()
 
 getCount ()
 
 getPage ()
 
 getPageCount ()
 
next ()
 
nextWithKey ()
 
toArray ()
 
 wasEmpty ()
 

Static Public Member Functions

static factory ($wholeArray, $rangeInfo)
 

Detailed Description

Provides paging and iteration for "virtual" arrays – arrays for which only the current "page" is available, but are much bigger in entirety.

Definition at line 20 of file VirtualArrayIterator.inc.php.

Member Function Documentation

VirtualArrayIterator::array_slice_key (   $array,
  $offset,
  $len = -1 
)

A version of array_slice that takes keys into account. Thanks to pies at sputnik dot pl. This is made redundant by PHP 5.0.2's updated array_slice, but we can't assume everyone has that. FIXME: Reconcile this against the dupe in ArrayItemIterator.

See Also
http://ca3.php.net/manual/en/function.array-slice.php

Definition at line 170 of file VirtualArrayIterator.inc.php.

VirtualArrayIterator::atFirstPage ( )

Check whether or not this iterator is for the first page of a sequence

Returns
boolean

Definition at line 100 of file VirtualArrayIterator.inc.php.

VirtualArrayIterator::atLastPage ( )

Check whether or not this iterator is for the last page of a sequence

Returns
boolean

Definition at line 108 of file VirtualArrayIterator.inc.php.

VirtualArrayIterator::eof ( )

Return a boolean indicating whether or not we've reached the end of results Note: This implementation requires that next() be called before every eof() will function properly (except the first call).

Returns
boolean

Definition at line 142 of file VirtualArrayIterator.inc.php.

static VirtualArrayIterator::factory (   $wholeArray,
  $rangeInfo 
)
static

Factory Method. Extracts the appropriate page items from the whole array and calls the constructor.

Parameters
$wholeArrayarray The whole array of items
$rangeInfoint The number of items per page
Returns
object VirtualArrayIterator

Definition at line 65 of file VirtualArrayIterator.inc.php.

References VirtualArrayIterator().

VirtualArrayIterator::getCount ( )

Get the total number of items in the virtual array

Returns
int

Definition at line 124 of file VirtualArrayIterator.inc.php.

VirtualArrayIterator::getPage ( )

Get the page number that this iterator represents

Returns
int

Definition at line 116 of file VirtualArrayIterator.inc.php.

VirtualArrayIterator::getPageCount ( )

Get the total number of pages in the virtual array

Returns
int

Definition at line 132 of file VirtualArrayIterator.inc.php.

& VirtualArrayIterator::next ( )

Return the next item in the iterator.

Returns
object

Definition at line 74 of file VirtualArrayIterator.inc.php.

Referenced by nextWithKey().

& VirtualArrayIterator::nextWithKey ( )

Return the next item in the iterator, with key.

Returns
array (key, value)

Definition at line 90 of file VirtualArrayIterator.inc.php.

References next().

& VirtualArrayIterator::toArray ( )

Convert the iterator into an array

Returns
array

Definition at line 158 of file VirtualArrayIterator.inc.php.

VirtualArrayIterator::VirtualArrayIterator ( $theArray,
  $totalItems,
  $page = -1,
  $itemsPerPage = -1 
)

Constructor.

Parameters
$theArrayarray The array of items to iterate through
$totalItemsint The total number of items in the virtual "larger" array
$pageint the current page number
$itemsPerPageint Number of items to display per page

Definition at line 43 of file VirtualArrayIterator.inc.php.

References wasEmpty().

Referenced by factory().

VirtualArrayIterator::wasEmpty ( )

Return a boolean indicating whether or not this iterator was empty from the beginning

Returns
boolean

Definition at line 150 of file VirtualArrayIterator.inc.php.

Referenced by VirtualArrayIterator().


The documentation for this class was generated from the following file: