aboutsummaryrefslogtreecommitdiff
path: root/taxonomy_node_tree.module
diff options
context:
space:
mode:
Diffstat (limited to 'taxonomy_node_tree.module')
-rw-r--r--taxonomy_node_tree.module19
1 files 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