* @author Bruno Massa * It Generates menu links for all taxonomy terms */ // Some "magic numbers" mastered define('TAXONOMY_MENU_NONE', 0); define('TAXONOMY_MENU_NORMAL', 1); define('TAXONOMY_MENU_VIEW', 2); define('TAXONOMY_MENU_DEFAULT_TAX', 3); /** * Admin area. Configure the module, setting which * vocabularies will be converted into menus items * * @return * Array. The form fields. */ function __taxonomy_menu_admin() { require_once(drupal_get_path('module', 'taxonomy_menu') .'/taxonomy_menu.inc'); return _taxonomy_menu_admin(); } /** * Admin area. Configure the module, setting which * vocabularies will be converted into menus items */ function __taxonomy_menu_admin_submit(&$form_id, &$form) { // Save these options variable_set('taxonomy_menu_display_page', $form['taxonomy_menu_display_page']); variable_set('taxonomy_menu_hide_module_page', $form['taxonomy_menu_hide_module_page']); variable_set('taxonomy_menu_display_num', $form['taxonomy_menu_display_num']); variable_set('taxonomy_menu_hide_empty', $form['taxonomy_menu_hide_empty']); variable_set('taxonomy_menu_display_descendants', $form['taxonomy_menu_display_descendants']); variable_set('taxonomy_menu_display_context', $form['taxonomy_menu_display_context']); // Save which category should be displayed on menu foreach (taxonomy_get_vocabularies() as $vocab) { variable_set('taxonomy_menu_show_'. $vocab->vid, $form['taxonomy_menu_show_'. $vocab->vid]); if (module_exists('views')) { variable_set('taxonomy_menu_show_views_'. $vocab->vid, $form['taxonomy_menu_show_view_'. $vocab->vid]); } } // Rebuild the menu to include these features variable_set('menu_rebuild_needed', TRUE); } /** * Implementation of hook_help(). */ function taxonomy_menu_help($section) { switch ($section) { case 'admin/help#taxonomy_menu': $output = '

'. t('Taxonomy terms allow classification of content into categories and subcategories. The taxonomy menu module adds links to the navigation menu for taxonomy terms. This is useful when the community is focused on creating content that is organized in a taxonomy.') .'

'. '

'. t('The taxonomy menu administration interface allows taxonomy terms to be enabled to show in the navigation menu. You can also select whether a term\'s descendents subterms are displayed.') .'

'. t('

You can

', array('@admin-taxonomy' => url('admin/content/taxonomy'), '@admin-taxonomy-add-vocabulary' => url('admin/content/taxonomy/add/vocabulary'))). '

'. t('For more information please read the configuration and customization handbook Taxonomy menu page.', array('@taxonomy_menu' => 'http://www.drupal.org/handbook/modules/taxonomy_menu/')) .'

'; return $output; } } /** * Implementation of hook_menu(). * * Most of the heavy lifting of the module is done here. */ function taxonomy_menu_menu($may_cache) { if (!empty($may_cache)) { require_once(drupal_get_path('module', 'taxonomy_menu') .'/taxonomy_menu.inc'); return _taxonomy_menu_menu(); } } /** * Implementation of hook_nodeapi(). * * This hook enables the menu to be displayed in context during node views. */ function taxonomy_menu_nodeapi(&$node, $op, $a3, $a4) { static $vocabs = array(); // skip checking for vocabs if display node context is disabled if (!variable_get('taxonomy_menu_display_context', TRUE)) { $vocabs = NULL; } // First check if the node has a relevant category.s if (empty($vocabs) and is_array($vocabs)) { // The node should have taxonomy terms if (!$terms = taxonomy_node_get_terms($node->nid)) { return; } // Check if at least one vocabulary is revelevant // for us, being a menu foreach ($terms as $term) { if (variable_get('taxonomy_menu_show_'. $term->vid, TAXONOMY_MENU_NONE)) { $vocabs[$term->vid][] = $term->tid; } } // If none of the terms are tracked by this module, // forget it if (empty($vocabs)) { $vocabs = FALSE; return; } } if ($op == 'view' and $a4 == TRUE and !empty($vocabs)) { require_once(drupal_get_path('module', 'taxonomy_menu') .'/taxonomy_menu.inc'); _taxonomy_menu_node_view($node, $vocabs); } elseif ($op == 'update' or $op == 'insert') { variable_set('menu_rebuild_needed', TRUE); } } /** * Page callback that renders a node listing for the selected term. */ function __taxonomy_menu_page() { require_once(drupal_get_path('module', 'taxonomy_menu') .'/taxonomy_menu.inc'); return _taxonomy_menu_page(); } /** * Implementation of hook_taxonomy(). * * Invalidates the menu cache on taxonomy changes. */ function taxonomy_menu_taxonomy() { variable_set('menu_rebuild_needed', TRUE); } function taxonomy_menu_term_path(&$term) { return 'asdf'; } /** * Include pathauto & token functions for taxonomy_pathauto */ require_once(drupal_get_path('module', 'taxonomy_menu') .'/taxonomy_menu_pathauto.inc');