public static array
treerecurse
(mixed $id, mixed $indent, mixed $list, mixed &$children, mixed $maxlevel = 9999, mixed $level = 0, mixed $type = 1)
/**
* Build the list representing the menu tree
*
* @param integer $id Id of the menu item
* @param string $indent The indentation string
* @param array $list The list to process
* @param array $children The children of the current item
* @param integer $maxlevel The maximum number of levels in the tree
* @param integer $level The starting level
* @param int $type Set the type of spacer to use. Use 1 for |_ or 0 for -
*
* @return array
*
* @since 1.5
*/
public static function treerecurse($id, $indent, $list, &$children, $maxlevel = 9999, $level = 0, $type = 1)
{
if ($level <= $maxlevel && isset($children[$id]) && is_array($children[$id])) {
if ($type) {
$pre = '<sup>|_</sup> ';
$spacer = '. ';
} else {
$pre = '- ';
$spacer = ' ';
}
foreach ($children[$id] as $v) {
$id = $v->id;
if ($v->parent_id == 0) {
$txt = $v->title;
} else {
$txt = $pre . $v->title;
}
$list[$id] = $v;
$list[$id]->treename = $indent . $txt;
if (isset($children[$id]) && is_array($children[$id])) {
$list[$id]->children = count($children[$id]);
$list = static::treerecurse($id, $indent . $spacer, $list, $children, $maxlevel, $level + 1, $type);
} else {
$list[$id]->children = 0;
}
}
}
return $list;
}