aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio <s1lv10@uol.com.br>2009-10-19 11:01:40 -0200
committerSilvio <s1lv10@uol.com.br>2009-10-19 11:01:40 -0200
commit3c86ad79c908e0cac0281f4a431eb7ba3a13ea81 (patch)
tree1b31cf965867146c48414465b2fea3763401b034
parente8edc3e2c8facdce7b3d8c9f99871b07e36bc226 (diff)
downloadtaxonomy_node_tree-3c86ad79c908e0cac0281f4a431eb7ba3a13ea81.tar.gz
taxonomy_node_tree-3c86ad79c908e0cac0281f4a431eb7ba3a13ea81.tar.bz2
Adding taxonomy render functions
New functions taxonomy_node_tree_list() and taxonomy_node_tree_has_unhidden_submenu()
-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;
+}