/** * Utility Function: * Get the ancestors of each category node * * @access private * @return array */ private static function _getCatAncestors($id, $indent, $list, &$children, $title, $maxlevel = 9999, $level = 0, $type = 1, $ancestors = null) { $ROOT_CATEGORY_ID = 1; if (!$ancestors) { $ancestors = array(); } if (@$children[$id] && $level <= $maxlevel) { foreach ($children[$id] as $v) { $id = $v->id; if (!in_array($v->parent_id, $ancestors) && $v->parent_id != $ROOT_CATEGORY_ID) { $ancestors[] = $v->parent_id; } if ($v->parent_id == 1) { // Top level category ( a child of ROOT) $pre = ''; $spacer = ' . '; } else { if ($type) { $pre = '<sup>|_</sup> '; $spacer = ' . '; } else { $pre = '- '; $spacer = ' . '; } } if ($title) { if ($v->parent_id == 0) { $txt = '' . $v->title; } else { $txt = $pre . $v->title; } } else { if ($v->parent_id == 0) { $txt = ''; } else { $txt = $pre; } } $pt = $v->parent_id; $list[$id] = $v; $list[$id]->treename = "{$indent}{$txt}"; $list[$id]->title = $v->title; $list[$id]->slug = $v->slug; $list[$id]->access = $v->access; $list[$id]->ancestors = $ancestors; $list[$id]->childrenarray = @$children[$id]; $list[$id]->children = count(@$children[$id]); $list[$id]->level = $level + 1; $list = plgSystemFlexisystem::_getCatAncestors($id, $indent . $spacer, $list, $children, $title, $maxlevel, $level + 1, $type, $ancestors); } } return $list; }