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

Public Member Functions

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

Data Fields

 $count
 
 $itemsPerPage
 
 $page
 
 $theArray
 
 $wasEmpty
 

Detailed Description

Provides paging and iteration for arrays.

Definition at line 19 of file ArrayItemIterator.inc.php.

Constructor & Destructor Documentation

◆ __construct()

ArrayItemIterator::__construct ( $theArray,
  $page = -1,
  $itemsPerPage = -1 
)

Constructor.

Parameters
$theArrayarray The array of items to iterate through
$pageint the current page number
$itemsPerPageint Number of items to display per page

Definition at line 53 of file ArrayItemIterator.inc.php.

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

Member Function Documentation

◆ array_slice_key()

ArrayItemIterator::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 VirtualArrayIterator.

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

Definition at line 188 of file ArrayItemIterator.inc.php.

Referenced by __construct().

◆ atFirstPage()

ArrayItemIterator::atFirstPage ( )

Determine whether or not this iterator represents the first page

Returns
boolean

Reimplemented from ItemIterator.

Definition at line 113 of file ArrayItemIterator.inc.php.

◆ atLastPage()

ArrayItemIterator::atLastPage ( )

Determine whether or not this iterator represents the last page

Returns
boolean

Reimplemented from ItemIterator.

Definition at line 121 of file ArrayItemIterator.inc.php.

References $count.

◆ eof()

ArrayItemIterator::eof ( )

Return a boolean indicating whether or not we've reached the end of results

Returns
boolean

Reimplemented from ItemIterator.

Definition at line 153 of file ArrayItemIterator.inc.php.

◆ fromRangeInfo()

& ArrayItemIterator::fromRangeInfo ( $theArray,
$theRange 
)

Static method: Generate an iterator from an array and rangeInfo object.

Parameters
$theArrayarray
$theRangeobject

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

References $theArray.

◆ getCount()

ArrayItemIterator::getCount ( )

Get the total count of items

Returns
int

Reimplemented from ItemIterator.

Definition at line 137 of file ArrayItemIterator.inc.php.

References $count.

◆ getPage()

ArrayItemIterator::getPage ( )

Get the current page number

Returns
int

Reimplemented from ItemIterator.

Definition at line 129 of file ArrayItemIterator.inc.php.

References $page.

◆ getPageCount()

ArrayItemIterator::getPageCount ( )

Get the number of pages

Returns
int

Reimplemented from ItemIterator.

Definition at line 145 of file ArrayItemIterator.inc.php.

◆ next()

& ArrayItemIterator::next ( )

Return the next item in the iterator.

Returns
object

Reimplemented from ItemIterator.

Definition at line 87 of file ArrayItemIterator.inc.php.

Referenced by nextWithKey().

◆ nextWithKey()

ArrayItemIterator::nextWithKey ( )

Return the next item in the iterator, with key.

Returns
array (key, value)

Reimplemented from ItemIterator.

Definition at line 103 of file ArrayItemIterator.inc.php.

References next().

◆ toArray()

& ArrayItemIterator::toArray ( )

Convert this iterator to an array

Returns
array

Reimplemented from ItemIterator.

Definition at line 169 of file ArrayItemIterator.inc.php.

References $theArray.

◆ toAssociativeArray()

& ArrayItemIterator::toAssociativeArray ( )

Return this iterator as an associative array.

Definition at line 176 of file ArrayItemIterator.inc.php.

References $theArray.

◆ wasEmpty()

ArrayItemIterator::wasEmpty ( )

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

Returns
boolean

Reimplemented from ItemIterator.

Definition at line 161 of file ArrayItemIterator.inc.php.

References $wasEmpty.

Referenced by __construct().

Field Documentation

◆ $count

int ArrayItemIterator::$count

The total number of items.

Definition at line 42 of file ArrayItemIterator.inc.php.

Referenced by atLastPage(), and getCount().

◆ $itemsPerPage

int ArrayItemIterator::$itemsPerPage

Number of items to iterate through on this page

Definition at line 30 of file ArrayItemIterator.inc.php.

Referenced by __construct().

◆ $page

int ArrayItemIterator::$page

The current page.

Definition at line 36 of file ArrayItemIterator.inc.php.

Referenced by __construct(), and getPage().

◆ $theArray

array ArrayItemIterator::$theArray

The array of contents of this iterator.

Definition at line 24 of file ArrayItemIterator.inc.php.

Referenced by __construct(), fromRangeInfo(), toArray(), and toAssociativeArray().

◆ $wasEmpty

ArrayItemIterator::$wasEmpty

Whether or not the iterator was empty from the start

Definition at line 45 of file ArrayItemIterator.inc.php.

Referenced by wasEmpty().


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