Open Journal Systems  3.3.0
VirtualArrayIterator Class Reference
Inheritance diagram for VirtualArrayIterator:
ItemIterator

Public Member Functions

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

Static Public Member Functions

static factory ($wholeArray, $rangeInfo)
 

Data Fields

 $count
 
 $itemsPerPage
 
 $page
 
 $theArray
 
 $wasEmpty
 

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.

Constructor & Destructor Documentation

◆ __construct()

VirtualArrayIterator::__construct ( $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 58 of file VirtualArrayIterator.inc.php.

References $itemsPerPage, $page, $theArray, and wasEmpty().

Member Function Documentation

◆ array_slice_key()

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
Parameters
$arrayArray
$offsetint
$lenint

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

◆ atFirstPage()

VirtualArrayIterator::atFirstPage ( )

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

Returns
boolean

Reimplemented from ItemIterator.

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

◆ atLastPage()

VirtualArrayIterator::atLastPage ( )

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

Returns
boolean

Reimplemented from ItemIterator.

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

References $count.

◆ eof()

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

Reimplemented from ItemIterator.

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

◆ factory()

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 81 of file VirtualArrayIterator.inc.php.

◆ getCount()

VirtualArrayIterator::getCount ( )

Get the total number of items in the virtual array

Returns
int

Reimplemented from ItemIterator.

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

References $count.

◆ getPage()

VirtualArrayIterator::getPage ( )

Get the page number that this iterator represents

Returns
int

Reimplemented from ItemIterator.

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

References $page.

◆ getPageCount()

VirtualArrayIterator::getPageCount ( )

Get the total number of pages in the virtual array

Returns
int

Reimplemented from ItemIterator.

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

◆ next()

& VirtualArrayIterator::next ( )

Return the next item in the iterator.

Returns
object

Reimplemented from ItemIterator.

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

Referenced by nextWithKey().

◆ nextWithKey()

VirtualArrayIterator::nextWithKey ( )

Return the next item in the iterator, with key.

Returns
array (key, value)

Reimplemented from ItemIterator.

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

References next().

◆ toArray()

& VirtualArrayIterator::toArray ( )

Convert the iterator into an array

Returns
array

Reimplemented from ItemIterator.

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

References $theArray.

◆ wasEmpty()

VirtualArrayIterator::wasEmpty ( )

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

Returns
boolean

Reimplemented from ItemIterator.

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

References $wasEmpty.

Referenced by __construct().

Field Documentation

◆ $count

int VirtualArrayIterator::$count

The total number of items.

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

Referenced by atLastPage(), and getCount().

◆ $itemsPerPage

int VirtualArrayIterator::$itemsPerPage

Number of items to iterate through on this page

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

Referenced by __construct().

◆ $page

int VirtualArrayIterator::$page

The current page.

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

Referenced by __construct(), and getPage().

◆ $theArray

array VirtualArrayIterator::$theArray

The array of contents of this iterator.

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

Referenced by __construct(), and toArray().

◆ $wasEmpty

boolean VirtualArrayIterator::$wasEmpty

Whether or not the iterator was empty from the start

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

Referenced by wasEmpty().


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