index 96bc7a822800db0fa9ae20a2f4be2c5df1aedc14..d4bdfc764504a331cc2505da985ac5f296f6370c 100644 (file)
return $this->nodes_[$node_id];
}
- function getLastNode($parent_id)
- {
- $childs = $this->getChilds($parent_id);
-
- for ($i=count($childs); $i>0; --$i)
- {
- $node = $this->getNode($childs[$i-1]);
- if ($node['text'] == '{')
- {
- // return command owning the block
- return $this->getNode($parent_id);
- }
- if ($node['class'] != 'comment')
- {
- return $node;
- }
- }
-
- return $this->getNode($parent_id);
- }
-
function setDumpFunc($callback)
{
- if ($callback == NULL || is_callable($callback))
+ if ($callback === NULL || is_callable($callback))
{
$this->dumpFn_ = $callback;
}
if ($last)
{
$infix = '`--- ';
- $c_prefix = $prefix . ' ';
+ $child_prefix = $prefix . ' ';
}
else
{
$infix = '|--- ';
- $c_prefix = $prefix . '| ';
+ $child_prefix = $prefix . '| ';
}
$node = $this->nodes_[$node_id];
- if ($this->dumpFn_ != NULL)
+ if ($this->dumpFn_ !== NULL)
{
$this->dump_ .= $prefix . $infix . call_user_func($this->dumpFn_, $node) . "\n";
}
$this->dump_ .= "$prefix$infix$node\n";
}
- $childs = $this->childs_[$node_id];
- for ($i=0; $i<count($childs); ++$i)
+ if (isset($this->childs_[$node_id]))
{
- $c_last = false;
- if ($i+1 == count($childs))
+ $childs = $this->childs_[$node_id];
+ $last_child = count($childs);
+
+ for ($i=1; $i <= $last_child; ++$i)
{
- $c_last = true;
+ $this->doDump_($childs[$i-1], $child_prefix, ($i == $last_child ? true : false));
}
-
- $this->doDump_($childs[$i], $c_prefix, $c_last);
}
}
}
-?>
\ No newline at end of file
+?>