From 0f79c1e9462f16de3bd0bc3f199b48906cb092af Mon Sep 17 00:00:00 2001 From: Steven Wittens Date: Wed, 6 Apr 2005 04:48:39 +0000 Subject: - Improve recursion in taxonomy_get_tree() (Morbus) --- modules/taxonomy/taxonomy.module | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'modules/taxonomy/taxonomy.module') diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index 8fb5163d6..150796ff3 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -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)); } } -- cgit v1.2.3