19 require_once(BASE.
"wcmf/lib/persistence/class.PersistenceFacade.php");
20 require_once(BASE.
"wcmf/lib/util/class.SessionData.php");
47 $this->_oidList = array();
48 $this->_allList = array();
49 $this->_currentOID = $oid;
50 $this->_currentDepth = 0;
60 $uid = md5(uniqid(
""));
61 $state = array(
'end' => $this->_end,
'oidList' => $this->_oidList,
'allList' => $this->_allList,
'currentOID' => $this->_currentOID,
62 'currentDepth' => $this->_currentDepth);
63 $session->set(
'PersistentIterator.'.$uid, $state);
76 $state = $session->get(
'PersistentIterator.'.$uid);
82 $instance->_end = $state[
'end'];
83 $instance->_oidList = $state[
'oidList'];
84 $instance->_allList = $state[
'allList'];
85 $instance->_currentDepth = $state[
'currentDepth'];
97 $childOIDs = $node->getProperty(
'childoids');
100 if (sizeOf($this->_oidList) != 0) {
101 list($this->_currentOID, $this->_currentDepth) = array_pop($this->_oidList);
139 $this->_oidList= array();
140 $this->_allList = array();
141 $this->_currentOID = $oid;
142 $this->_currentDepth = 0;
152 for ($i=sizeOf($oidList)-1;$i>=0;$i--)
154 if (!in_array($oidList[$i], $this->_allList)) {
155 array_push($this->_oidList, array($oidList[$i], $depth));
156 array_push($this->_allList, $oidList[$i]);
165 for ($i=0; $i<sizeOf($this->_oidList); $i++)
167 $str .= $this->_oidList[$i][0].
",";
addToSeenList($oidList, $depth)
PersistentIterator is used to iterate over a tree/list build of oids using a Depth-First-Algorithm. To persist its state use the PersistentIterator::save() method, to restore its state use the static PersistentIterator::load() method, which returns the loaded instance. States are identified by an unique id, which is provided after saving. PersistentIterator implements the 'Iterator Pattern'.