aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--taxonomy_node_tree.module57
1 files changed, 56 insertions, 1 deletions
diff --git a/taxonomy_node_tree.module b/taxonomy_node_tree.module
index 22ed479..acbc1d0 100644
--- a/taxonomy_node_tree.module
+++ b/taxonomy_node_tree.module
@@ -19,7 +19,7 @@
* Taxonomy id.
*
* @return
- * Array with parent terms of the vocabulary
+ * Array with parent terms of the vocabulary.
*/
function taxonomy_node_tree_parents($vid) {
// Get all terms from a given vocabulary
@@ -213,3 +213,58 @@ function taxonomy_node_tree_taxonomy_get_tree($vid, $parent = 0, $depth = -1, $m
return $tree;
}
+
+
+/**
+ * Recursively build the menu.
+ *
+ * @ingroup themeable
+ */
+function taxonomy_node_tree_list($menu, $id, $class, &$level = NULL) {
+
+ if ($level == NULL) {
+ $output = '<ul id="' . $id .'" class="'. $class .'">';
+ $output .= implode((array) module_invoke_all('taxonomy_node_tree_list'));
+ $level = 0;
+ }
+ else {
+ $output = '<ul id="'. $id .'[ul]['. $level .']" class="'. $class .'">';
+ }
+
+ foreach ($menu as $menu_item) {
+ if ($menu_item['link']['hidden'] == 0) {
+ $output .= '<li>';
+ if ($menu_item['below'] !== FALSE && taxonomy_node_tree_has_unhidden_submenu($menu_item['below'])) {
+ $level++;
+ $output .= $menu_item['link']['title'];
+ $output .= taxonomy_node_tree_list($menu_item['below'], $id, $class, $level);
+ }
+ else {
+ $output .= theme('menu_item_link', $menu_item['link']);
+ }
+ $output .= '</li>';
+ }
+ }
+
+ $output .= '</ul>';
+ return $output;
+
+}
+
+/**
+ * Check whether a menu has at least one unhidden submenu.
+ */
+function taxonomy_node_tree_has_unhidden_submenu($menu = FALSE) {
+
+ if ($menu == FALSE) {
+ return FALSE;
+ }
+
+ foreach ($menu as $menu_item) {
+ if ($menu_item['link']['hidden'] == 0) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}