aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio <silvio@devlet.com.br>2011-06-15 16:46:58 -0300
committerSilvio <silvio@devlet.com.br>2011-06-15 16:46:58 -0300
commit3c55b4bf505bcdd2e532e166751da4f7e461eeea (patch)
treeb506e0a769236e36e1264dca74fb4d013428ba22
parentbea1e00688626c1fd527209f9349449364ec9fe2 (diff)
downloadtaxonomy_node_tree-3c55b4bf505bcdd2e532e166751da4f7e461eeea.tar.gz
taxonomy_node_tree-3c55b4bf505bcdd2e532e166751da4f7e461eeea.tar.bz2
Adding $parents parameter to taxonomy_node_tree_get_empty()
-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