From 3c55b4bf505bcdd2e532e166751da4f7e461eeea Mon Sep 17 00:00:00 2001 From: Silvio Date: Wed, 15 Jun 2011 16:46:58 -0300 Subject: Adding $parents parameter to taxonomy_node_tree_get_empty() --- taxonomy_node_tree.module | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/taxonomy_node_tree.module b/taxonomy_node_tree.module index 18184c6..34c1693 100644 --- a/taxonomy_node_tree.module +++ b/taxonomy_node_tree.module @@ -177,19 +177,20 @@ function taxonomy_node_tree_count($term, &$count = 0) { * @param $clean * Set to true to cleanup term before adding to list. * + * @param $parents + * Set to FALSE to exclude parent items even if they + * don't have descendant nodes. + * * @param $list * Array to store term list. * * @return * Array with terms without descendant nodes. - * - * @todo - * Skip parents should be controlled by a parameter. */ -function taxonomy_node_tree_get_empty($term, $clean = FALSE, &$list = array()) { +function taxonomy_node_tree_get_empty($term, $clean = FALSE, $parents = TRUE, &$list = array()) { if (taxonomy_node_tree_count($term) == 0) { // Skip parents. - if ($term->parents[0] != 0) { + if ($term->parents[0] != 0 || ($term->parents[0] == 0 && $parents)) { $save = drupal_clone($term); if ($clean == TRUE) { @@ -203,7 +204,7 @@ function taxonomy_node_tree_get_empty($term, $clean = FALSE, &$list = array()) { } else if (isset($term->below)) { foreach ($term->below as $below) { - taxonomy_node_tree_get_empty($below, $clean, $list); + taxonomy_node_tree_get_empty($below, $clean, $parents, $list); } } @@ -211,7 +212,7 @@ function taxonomy_node_tree_get_empty($term, $clean = FALSE, &$list = array()) { } /** - * Build a list of no-nempty terms. + * Build a list of non-nempty terms. * * @param $term * Term object. @@ -220,7 +221,7 @@ function taxonomy_node_tree_get_empty($term, $clean = FALSE, &$list = array()) { * Set to true to cleanup term before adding to list. * * @param $parents - * Set to TRUE to keep parent nodes even if they don't have + * Set to TRUE to keep parent items even if they don't have * descendant nodes. * * @param $list @@ -268,7 +269,7 @@ function taxonomy_node_tree_get_non_empty($term, $clean = FALSE, $parents = FALS * Set to TRUE to remove branches without descendant nodes. * * @param $parents - * Set to TRUE to keep parent nodes even if they don't have + * Set to TRUE to keep parent items even if they don't have * descendant nodes. Used just when $clean is also set to TRUE. * * @return -- cgit v1.2.3