2003-11-18 22:18:38 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class CachingRecursiveIterator extends CachingIterator implements RecursiveIterator
|
|
|
|
{
|
|
|
|
protected $hasChildren;
|
|
|
|
protected $getChildren;
|
2003-11-22 20:51:15 +00:00
|
|
|
protected $catch_get_child;
|
2003-11-18 22:18:38 +00:00
|
|
|
|
2003-12-08 08:31:08 +00:00
|
|
|
function __construct(RecursiveIterator $it, $flags = CIT_CALL_TOSTRING)
|
2003-11-22 20:51:15 +00:00
|
|
|
{
|
2003-12-07 15:03:11 +00:00
|
|
|
parent::__construct($it, $flags);
|
2003-11-18 22:18:38 +00:00
|
|
|
}
|
|
|
|
|
2003-11-22 20:51:15 +00:00
|
|
|
function next()
|
|
|
|
{
|
2003-11-18 22:18:38 +00:00
|
|
|
if ($this->hasChildren = $this->it->hasChildren()) {
|
2003-11-19 00:18:30 +00:00
|
|
|
try {
|
2003-12-07 15:03:11 +00:00
|
|
|
//$this->getChildren = new CachingRecursiveIterator($this->it->getChildren(), $this->flags);
|
2003-11-19 00:18:30 +00:00
|
|
|
// workaround memleaks...
|
|
|
|
$child = $this->it->getChildren();
|
2003-12-07 15:03:11 +00:00
|
|
|
$this->getChildren = new CachingRecursiveIterator($child, $this->flags);
|
2003-11-19 00:18:30 +00:00
|
|
|
}
|
|
|
|
catch(Exception $e) {
|
2003-12-07 15:03:11 +00:00
|
|
|
if (!$this->flags & CIT_CATCH_GET_CHILD) {
|
2003-11-19 00:18:30 +00:00
|
|
|
throw $e;
|
|
|
|
}
|
|
|
|
$this->hasChildren = false;
|
|
|
|
$this->getChildren = NULL;
|
|
|
|
}
|
2003-11-18 22:18:38 +00:00
|
|
|
} else {
|
|
|
|
$this->getChildren = NULL;
|
|
|
|
}
|
|
|
|
parent::next();
|
|
|
|
}
|
|
|
|
|
2003-11-22 20:51:15 +00:00
|
|
|
function hasChildren()
|
|
|
|
{
|
2003-11-18 22:18:38 +00:00
|
|
|
return $this->hasChildren;
|
|
|
|
}
|
|
|
|
|
2003-11-22 20:51:15 +00:00
|
|
|
function getChildren()
|
|
|
|
{
|
2003-11-18 22:18:38 +00:00
|
|
|
return $this->getChildren;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|