2003-11-22 20:52:06 +00:00
|
|
|
<?php
|
|
|
|
|
2004-10-29 20:58:58 +00:00
|
|
|
/** @file parentiterator.inc
|
2004-10-31 19:05:37 +00:00
|
|
|
* @ingroup SPL
|
2004-10-29 20:58:58 +00:00
|
|
|
* @brief class FilterIterator
|
|
|
|
* @author Marcus Boerger
|
|
|
|
* @date 2003 - 2004
|
|
|
|
*
|
|
|
|
* SPL - Standard PHP Library
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Iterator to filter parents
|
|
|
|
* @author Marcus Boerger
|
|
|
|
* @version 1.1
|
|
|
|
*
|
|
|
|
* This extended FilterIterator allows a recursive iteration using
|
|
|
|
* RecursiveIteratorIterator that only shows those elements which have
|
|
|
|
* children.
|
|
|
|
*/
|
2003-11-22 20:52:06 +00:00
|
|
|
class ParentIterator extends FilterIterator implements RecursiveIterator
|
|
|
|
{
|
2004-10-29 20:58:58 +00:00
|
|
|
/** @param $it the RecursiveIterator to filter
|
|
|
|
*/
|
2003-11-30 16:20:03 +00:00
|
|
|
function __construct(RecursiveIterator $it)
|
|
|
|
{
|
|
|
|
parent::__construct($it);
|
|
|
|
}
|
2004-10-29 20:58:58 +00:00
|
|
|
|
|
|
|
/** @return whetehr the current element has children
|
|
|
|
*/
|
2003-11-22 20:52:06 +00:00
|
|
|
function accept()
|
|
|
|
{
|
|
|
|
return $this->it->hasChildren();
|
|
|
|
}
|
|
|
|
|
2004-10-29 20:58:58 +00:00
|
|
|
/** @return whether the current element has children
|
|
|
|
*/
|
2003-11-22 20:52:06 +00:00
|
|
|
function hasChildren()
|
|
|
|
{
|
|
|
|
return $this->it->hasChildren();
|
|
|
|
}
|
|
|
|
|
2004-10-29 20:58:58 +00:00
|
|
|
/** @return the ParentIterator for the current elements children
|
|
|
|
*/
|
2003-11-22 20:52:06 +00:00
|
|
|
function getChildren()
|
|
|
|
{
|
|
|
|
return new ParentIterator($this->it->getChildren());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|