aboutsummaryrefslogtreecommitdiff
path: root/finder_menu.module
diff options
context:
space:
mode:
Diffstat (limited to 'finder_menu.module')
-rw-r--r--finder_menu.module55
1 files changed, 55 insertions, 0 deletions
diff --git a/finder_menu.module b/finder_menu.module
new file mode 100644
index 0000000..9eb17b6
--- /dev/null
+++ b/finder_menu.module
@@ -0,0 +1,55 @@
+<?php
+// $Id$
+
+/**
+ * Implementation of hook_block();
+ */
+function finder_taxonomy_block($op = 'list', $delta = 0, $edit = array()) {
+ switch ($op) {
+ case 'list':
+ $blocks[0]['info'] = t('Finder Menu');
+ $blocks[0]['cache'] = BLOCK_NO_CACHE;
+ return $blocks;
+
+ case 'configure':
+ $form['finder_taxonomy_vid'] = array(
+ '#type' => 'radios',
+ '#title' => t('Select the vocabulary to list'),
+ '#default_value' => variable_get('finder_taxonomy_vid', 1),
+ '#options' => finder_taxonomy_get_vocabularies(),
+ );
+ return $form;
+
+ case 'save':
+ variable_set('finder_taxonomy_vid', (int) $edit['finder_taxonomy_vid']);
+ break;
+
+ case 'view':
+ $vid = variable_get('finder_taxonomy_vid', 1);
+ $tree = finder_taxonomy_get_terms($vid);
+ $block['content'] = theme('item_list', $tree);
+ return $block;
+ }
+}
+
+/**
+ * Get all vocabularies;
+ */
+function finder_taxonomy_get_vocabularies() {
+ $result = db_query('SELECT vid, name from {vocabulary}');
+ while ($item = db_fetch_object($result)) {
+ $items[$item->vid] = $item->name;
+ }
+ return $items;
+}
+
+function finder_taxonomy_get_terms($vid = null) {
+ if ($vid != null) {
+ $tree = taxonomy_get_tree($vid);
+ foreach ($tree as $term) {
+ $items[$term->tid] = $term->name;
+ }
+ return $items;
+ }
+ return null;
+}