Commit 0f79c1e9 authored by Steven Wittens's avatar Steven Wittens
Browse files

- Improve recursion in taxonomy_get_tree() (Morbus)

parent 18e852e4
......@@ -624,15 +624,15 @@ function taxonomy_get_tree($vid, $parent = 0, $depth = -1, $max_depth = NULL) {
}
$max_depth = (is_null($max_depth)) ? count($children[$vid]) : $max_depth;
if ($children[$vid][$parent]) {
foreach ($children[$vid][$parent] as $child) {
if ($max_depth > $depth) {
$terms[$vid][$child]->depth = $depth;
// The "parent" attribute is not useful, as it would show one parent only.
unset($terms[$vid][$child]->parent);
$terms[$vid][$child]->parents = $parents[$vid][$child];
$tree[] = $terms[$vid][$child];
foreach ($children[$vid][$parent] as $child) {
if ($max_depth > $depth) {
$terms[$vid][$child]->depth = $depth;
// The "parent" attribute is not useful, as it would show one parent only.
unset($terms[$vid][$child]->parent);
$terms[$vid][$child]->parents = $parents[$vid][$child];
$tree[] = $terms[$vid][$child];
if ($children[$vid][$child]) {
$tree = array_merge($tree, taxonomy_get_tree($vid, $child, $depth, $max_depth));
}
}
......
......@@ -624,15 +624,15 @@ function taxonomy_get_tree($vid, $parent = 0, $depth = -1, $max_depth = NULL) {
}
$max_depth = (is_null($max_depth)) ? count($children[$vid]) : $max_depth;
if ($children[$vid][$parent]) {
foreach ($children[$vid][$parent] as $child) {
if ($max_depth > $depth) {
$terms[$vid][$child]->depth = $depth;
// The "parent" attribute is not useful, as it would show one parent only.
unset($terms[$vid][$child]->parent);
$terms[$vid][$child]->parents = $parents[$vid][$child];
$tree[] = $terms[$vid][$child];
foreach ($children[$vid][$parent] as $child) {
if ($max_depth > $depth) {
$terms[$vid][$child]->depth = $depth;
// The "parent" attribute is not useful, as it would show one parent only.
unset($terms[$vid][$child]->parent);
$terms[$vid][$child]->parents = $parents[$vid][$child];
$tree[] = $terms[$vid][$child];
if ($children[$vid][$child]) {
$tree = array_merge($tree, taxonomy_get_tree($vid, $child, $depth, $max_depth));
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment