recode for PHP 7.3
This commit is contained in:
parent
991872aeb8
commit
0a56d9c337
1 changed files with 62 additions and 99 deletions
|
@ -1,123 +1,86 @@
|
|||
<?php
|
||||
/**
|
||||
* Project:
|
||||
* Contenido Content Management System
|
||||
*
|
||||
* Description:
|
||||
* Iterator class
|
||||
*
|
||||
* Requirements:
|
||||
* @con_php_req 5.0
|
||||
*
|
||||
*
|
||||
* @package Contenido Backend classes
|
||||
* @version 1.0.2
|
||||
* @author unknown
|
||||
* @copyright four for business AG <www.4fb.de>
|
||||
* @license http://www.contenido.org/license/LIZENZ.txt
|
||||
* @link http://www.4fb.de
|
||||
* @link http://www.contenido.org
|
||||
* @since file available since contenido release <= 4.6
|
||||
*
|
||||
* {@internal
|
||||
* created unknown
|
||||
* modified 2008-06-30, Dominik Ziegler, add security fix
|
||||
*
|
||||
* $Id: class.iterator.php 2 2011-07-20 12:00:48Z oldperl $:
|
||||
* }}
|
||||
*
|
||||
*/
|
||||
|
||||
if(!defined('CON_FRAMEWORK')) {
|
||||
die('Illegal call');
|
||||
}
|
||||
|
||||
/**
|
||||
* cIterator: A class which represents the C/C++/JAVA Iterator support.
|
||||
*
|
||||
* Iterating items is a mechanism to "step" trough a list of defined items.
|
||||
* Basically, the iterator is similar to an array, but provides easy functions
|
||||
* to step trough the list.
|
||||
*
|
||||
* An instance of an iterator is usually created by a class returning multiple
|
||||
* items and automatically filled using the $aItems parameter of the constructor,
|
||||
* and then returned to the caller.
|
||||
* @package Core
|
||||
* @subpackage Util
|
||||
* @version $Rev$
|
||||
* @since 2.1
|
||||
* @author Ortwin Pinke <o.pinke@conlite.org>
|
||||
* @copyright (c) 2019, conlite.org
|
||||
* @license http://www.gnu.de/documents/gpl.en.html GPL v3 (english version)
|
||||
* @license http://www.gnu.de/documents/gpl.de.html GPL v3 (deutsche Version)
|
||||
* @link http://www.conlite.org ConLite.org
|
||||
*
|
||||
* The caller receives the iterator object and can step trough all items using
|
||||
* the "next" method.
|
||||
*
|
||||
* @todo Add more stepping methods, as well as retrieving items
|
||||
*
|
||||
* $Id:$
|
||||
*/
|
||||
class cIterator
|
||||
{
|
||||
// security check
|
||||
defined('CON_FRAMEWORK') or die('Illegal call');
|
||||
|
||||
class cIterator {
|
||||
|
||||
/**
|
||||
* Holds the items which should be iterated
|
||||
* @var array
|
||||
*/
|
||||
var $_aIteratorItems;
|
||||
|
||||
/**
|
||||
* Iterator constructor
|
||||
*
|
||||
* This function initializes the constructor, adds the passed items
|
||||
* and moves the iterator to the first element.
|
||||
*
|
||||
* @param $aItems array Items to add
|
||||
* @return none
|
||||
*/
|
||||
function __construct ($aItems)
|
||||
{
|
||||
if (is_array($aItems))
|
||||
{
|
||||
$this->_aIteratorItems = $aItems;
|
||||
} else {
|
||||
$this->_aIteratorItems = array();
|
||||
}
|
||||
|
||||
$this->reset();
|
||||
}
|
||||
*/
|
||||
var $_aIteratorItems;
|
||||
|
||||
/**
|
||||
/**
|
||||
* Holds the keys of the array which should be iterated
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_aKeys;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $aItems items to add
|
||||
*/
|
||||
public function __construct($aItems) {
|
||||
if (is_array($aItems)) {
|
||||
$this->_aIteratorItems = $aItems;
|
||||
} else {
|
||||
$this->_aIteratorItems = array();
|
||||
}
|
||||
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* reset: Resets the iterator to the first element
|
||||
*
|
||||
* This function moves the iterator to the first element
|
||||
*
|
||||
*
|
||||
* @return none
|
||||
*/
|
||||
function reset ()
|
||||
{
|
||||
reset($this->_aIteratorItems);
|
||||
}
|
||||
*/
|
||||
function reset() {
|
||||
$this->_aKeys = array_keys($this->_aIteratorItems);
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* next: Returns the next item in the iterator
|
||||
*
|
||||
* This function returns the item, or false if no
|
||||
* items are left.
|
||||
*
|
||||
*
|
||||
* @return mixed item or false if nothing was found
|
||||
*/
|
||||
function next ()
|
||||
{
|
||||
$item = each($this->_aIteratorItems);
|
||||
*/
|
||||
function next() {
|
||||
$key = array_shift($this->_aKeys);
|
||||
return isset($this->_aIteratorItems[$key]) ? $this->_aIteratorItems[$key] : false;
|
||||
}
|
||||
|
||||
if ($item === false)
|
||||
{
|
||||
return false;
|
||||
} else {
|
||||
return $item["value"];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* count: Returns the number of items in the iterator
|
||||
*
|
||||
*
|
||||
* @return int Number of items
|
||||
*/
|
||||
function count ()
|
||||
{
|
||||
return count($this->_aIteratorItems);
|
||||
}
|
||||
*/
|
||||
function count() {
|
||||
if(is_countable($this->_aIteratorItems)) {
|
||||
return count($this->_aIteratorItems);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in a new issue