- Patch #239945 by JeremyFrench: moved depth check out of loop.

merge-requests/26/head
Dries Buytaert 2009-04-17 19:59:51 +00:00
parent 9179976227
commit 669d112af5
1 changed files with 9 additions and 12 deletions

View File

@ -983,19 +983,16 @@ function taxonomy_get_tree($vid, $parent = 0, $max_depth = NULL, $depth = -1) {
$max_depth = (is_null($max_depth)) ? count($children[$vid]) : $max_depth; $max_depth = (is_null($max_depth)) ? count($children[$vid]) : $max_depth;
$tree = array(); $tree = array();
if (!empty($children[$vid][$parent])) { if ($max_depth > $depth && !empty($children[$vid][$parent])) {
foreach ($children[$vid][$parent] as $child) { foreach ($children[$vid][$parent] as $child) {
if ($max_depth > $depth) { $term = clone $terms[$vid][$child];
$term = clone $terms[$vid][$child]; $term->depth = $depth;
$term->depth = $depth; // The "parent" attribute is not useful, as it would show one parent only.
// The "parent" attribute is not useful, as it would show one parent only. unset($term->parent);
unset($term->parent); $term->parents = $parents[$vid][$child];
$term->parents = $parents[$vid][$child]; $tree[] = $term;
$tree[] = $term; if (!empty($children[$vid][$child])) {
$tree = array_merge($tree, taxonomy_get_tree($vid, $child, $max_depth, $depth));
if (!empty($children[$vid][$child])) {
$tree = array_merge($tree, taxonomy_get_tree($vid, $child, $max_depth, $depth));
}
} }
} }
} }