You are here

power_menu.module in Power Menu 7

Same filename and directory in other branches
  1. 6 power_menu.module
  2. 7.2 power_menu.module

This module provides some additional menu features. The features are not actually new, but are part of other modules. it's though very cumbersome to creating a new menu item, because one has to go to all the different places to configure these settings

File

power_menu.module
View source
<?php

/**
 * @file
 * This module provides some additional menu features. The features are not actually new, but are part of other modules.
 * it's though very cumbersome to creating a new menu item, because one has to go to all the different places to configure
 * these settings
 */

/**
 * Implements hook_menu().
 */
function power_menu_menu() {
  $items['admin/config/search/power_menu'] = array(
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'power_menu_admin_form',
    ),
    'access arguments' => array(
      'administer site configuration',
    ),
    'file' => 'power_menu.admin.inc',
    'title' => 'Power Menu settings',
    'description' => 'Configure the Power Menu.',
  );
  return $items;
}

/**
 * Implements hook_form_ID_alter().
 *
 * We are going to alter the form for editing a menu item and are going to add
 * some additional fields:
 *
 * alias: allows us to automatically add an alias for a menu item.
 *
 * taxonomy_create: If we have connected the navigation with a taxonomy vocab
 *   we can create new taxonomy terms from the menu
 *
 * taxonomy_link: or just connect menu items with a taxonomy term, which is needed
 *   to ensure that the menu item can be set to active at the right place.
 *
 * nodetype: also we can choose to connect a menu item with a nodetype which is needed
 *   to ensure that the mneu item can bet set to active when a certain node type is
 *   being displayed.
 *
 * @param array $form
 * @param array $form_state
 */
function power_menu_form_menu_edit_item_alter(&$form, &$form_state) {
  module_load_include('inc', 'power_menu', 'power_menu.forms');
  _power_menu_form_alter($form, $form_state);
}

/**
 * Implements hook_form_ID_alter().
 *
 * we are going to alter the form so that a user can set default properties
 * default properties are used incase no properties are found on menu items
 * @param $form
 * @param $form_state
 */
function power_menu_form_menu_overview_form_alter(&$form, &$form_state) {
  module_load_include('inc', 'power_menu', 'power_menu.forms');
  _power_menu_form_overview_alter($form, $form_state);
}

/**
 * Callback function when menu_edit_item form is being submitted
 * @param array $form
 * @param array $form_state
 */
function power_menu_form_menu_edit_item_submit($form, &$form_state) {
  module_load_include('inc', 'power_menu', 'power_menu.forms');
  _power_menu_form_menu_edit_item_submit($form, $form_state);
}

/**
 * It's possible for the user to write a path like news/[tid]
 * [tid] is like a token, that will be replaced by the either newly created term id ($tid)
 * or the linked term id.
 *
 * @param int $tid
 * @param int $mlid
 * @param String $link_path
 */
function _power_menu_replace_tid_in_path($tid, $mlid, $link_path) {
  $ar = array(
    'mlid' => $mlid,
    'link_path' => str_replace("[tid]", $tid, $link_path),
  );
  drupal_write_record('menu_links', $ar, array(
    'mlid',
  ));
}

/**
 * Implements hook_node_view().
 */
function power_menu_node_view($node, $view_mode = 'full') {
  if ($view_mode == 'full') {
    $item = power_menu_node_location($node);
    if ($item) {
      $current_power_menu = power_menu_get_menu();
      menu_tree_set_path($current_power_menu, $item['href']);

      //menu_set_item(NULL, $item);
      $breadcrumbs = power_menu_get_breadcrumbs();
      if (variable_get('power_menu_breadcrumb_title', FALSE)) {
        $breadcrumbs[] = $node->title;
      }
      drupal_set_breadcrumb($breadcrumbs);
    }
  }
}

/**
 * Implements hook_ctools_render_alter().
 *
 * When we use CTools Pagemanager, hook_nodeapi (view) is not being called, because ctools alters the
 * hook_menu and redirects the page callback to it's own function in node_view.inc Well, power_menu
 * never knows that a node is actually being displayed -> so we alter the ctools_render function and
 * start the normal power_menu_nodeapi procedure
 *
 * @param array $info
 * @param boolean $page
 * @param array $args
 * @param array $contexts
 * @param array $task
 * @param unknown_type $subtask
 */
function power_menu_ctools_render_alter($info, $page, $data) {
  extract($data);
  if (!empty($task['admin path']) && $task['admin path'] == 'node/%node' && $page) {
    power_menu_nodeapi($contexts['argument_nid_1']->data, 'view', NULL, $page);
  }
}

/**
 * Implements hook_init().
 *
 * here we are going to invoke hook_power_menu_href
 * a possible implementation of it, could look as followed:
 *
 * function rapsli_power_menu_href($menu_item) {
 *   $ar_active = array('my_path' => 'my_path/*');
 *     foreach ($ar_active as $key => $pattern) {
 *       if (drupal_match_path($menu_item['href'], $pattern)) {
 *       return $key;
 *     }
 *   }
 * }
 *
 */
function power_menu_init() {
  $item = menu_get_item();
  $result = module_invoke_all('power_menu_href', $item);
  if (is_array($result)) {
    $href = array_pop($result);
    if (!empty($href)) {
      $item['href'] = $href;
      menu_set_item(NULL, $item);
      $breadcrumbs = power_menu_get_breadcrumbs();
      if (variable_get('power_menu_breadcrumb_title', FALSE)) {
        $breadcrumbs[] = $node->title;
      }
      drupal_set_breadcrumb($breadcrumbs);
    }
  }
}

/**
 * We are trying to figure out which of the blocks is currently active. We need this incase we display multiple
 * menu blocks on the page, that are linked to the same term id, but have a different path. For example:
 *
 * Menu Block 1
 *  - Item 1 -> neuigkeiten/1 (and is linked to tid 1)
 *  - Item 2 -> neuigkeiten/2 (and is linked to tid 2)
 *
 *  Menu Block 2
 *  - Ding 1 -> news/1 (and is linked to tid 1)
 *  - Ding 2 -> news/2 (and is linked to tid 2)
 *
 *  If we are now looking at node/4 (which has tid 2) we go into our power_menu table to see which path we have to
 *  set active, but there are two paths with a relation to tid 2. We don't know which to take, that's why we have
 *  to figure out, which menu-block is currently active on the page we are looking at.
 *  If both are active... well, screw you. Only one is going to be active.
 */
function _power_menu_get_active_menu_block() {
  foreach ($result as $block) {

    // Match path if necessary
    if ($block->pages) {
      if ($block->visibility < 2) {
        $path = drupal_get_path_alias($_GET['q']);

        // Compare with the internal and path alias (if any).
        $page_match = drupal_match_path($path, $block->pages);
        if ($path != $_GET['q']) {
          $page_match = $page_match || drupal_match_path($_GET['q'], $block->pages);
        }

        // When $block->visibility has a value of 0, the block is displayed on
        // all pages except those listed in $block->pages. When set to 1, it
        // is displayed only on those pages listed in $block->pages.
        $page_match = !($block->visibility xor $page_match);
      }
      else {
        if (module_exists('php')) {
          $page_match = php_eval($block->pages);
        }
      }
    }
    else {
      $page_match = TRUE;
    }
  }
}

/**
 * Return all menus that are used for power menu
 */
function power_menu_get_pm_menus() {
  return variable_get('power_menu_menu', array());
}

/**
 * @todo Please document this function.
 * @see http://drupal.org/node/1354
 */
function power_menu_get_navigation_taxonomy() {
  return variable_get('power_menu_taxonomy_navigation', '');
}

/**
 * Get the menu which is defined as the power menu
 */
function power_menu_get_menu() {
  global $user, $language, $theme_key;
  $menus = array_filter(variable_get('power_menu_menu', array()));
  if (empty($menus)) {
    drupal_set_message(t("You have not chosen any power menu. Please visit the power menu settings"));
    return NULL;
  }
  $rids = array_keys($user->roles);
  $current_theme = variable_get('theme_default', 'none');
  $result = db_query("SELECT b.* FROM {block} AS b LEFT JOIN {block_role} AS r ON b.delta = r.delta\n    WHERE b.module IN ('menu', 'system') \n    AND b.theme = :theme AND b.delta IN (:delta)\n    AND (r.rid IN (:rids) OR r.rid IS NULL)", array(
    ':theme' => $current_theme,
    ':delta' => array_values($menus),
    ':rids' => $rids,
  ));
  foreach ($result as $block) {

    // Filter menu blocks by language
    if (module_exists('i18n_block')) {

      // Fake status and theme. Otherwise the i18n_block module would not check the
      // language definition on the menu block in i18n_block_block_list_alter().
      $block->status = 1;
      $block->theme = $theme_key;
      $lang_block = array(
        $block->bid => $block,
      );
      i18n_block_block_list_alter($lang_block);

      // Is the block removed, continue with the next power menu block
      if (count($lang_block) == 0) {
        continue;
      }
    }

    // Match path if necessary
    if ($block->pages) {
      if ($block->visibility < 2) {
        $path = drupal_get_path_alias($_GET['q']);

        // Compare with the internal and path alias (if any).
        $page_match = drupal_match_path($path, $block->pages);
        if ($path != $_GET['q']) {
          $page_match = $page_match || drupal_match_path($_GET['q'], $block->pages);
        }

        // When $block->visibility has a value of 0, the block is displayed on
        // all pages except those listed in $block->pages. When set to 1, it
        // is displayed only on those pages listed in $block->pages.
        $page_match = !($block->visibility xor $page_match);
        if ($page_match) {
          return $block->delta;
        }
      }
      else {
        if (module_exists('php')) {
          $page_match = php_eval($block->pages);
        }
      }
    }
    else {
      $page_match = TRUE;
      return $block->delta;
    }
  }
}

/**
 * Determine the menu location of a node.
 *
 * Inspired by _menu_get_active_trail().
 */
function power_menu_node_location($node) {
  $item = menu_get_item();

  // Check is path recognition enabled for this content type
  $path_ct = variable_get('power_menu_path_content_types', array());
  if (in_array($node->type, $path_ct, TRUE)) {

    // Get the path alias and remove the last path element
    $alias = drupal_lookup_path('alias', "node/" . $node->nid);
    $alias = explode('/', $alias);
    array_pop($alias);

    // Does a parent path exists
    if (count($alias) > 0) {
      $alias = implode('/', $alias);

      // Menu link lookup for given alias
      $link_path = db_query("SELECT ml.link_path FROM url_alias AS ua LEFT JOIN menu_links AS ml ON ua.source = ml.link_path WHERE ua.alias = :alias", array(
        ':alias' => $alias,
      ))
        ->fetchField();
      if ($link_path) {
        $item['href'] = $link_path;
        return $item;
      }
    }
  }
  $current_power_menu = power_menu_get_menu();

  // incase the node is directly somewhere in the navigation we don't need all the checking
  // and just use the core handling to decide which menu item to mark active
  $mlid = db_query("SELECT mlid FROM {menu_links} WHERE menu_name = :menu_name AND link_path = :link_path", array(
    ':menu_name' => $current_power_menu,
    ':link_path' => "node/{$node->nid}",
  ))
    ->fetchField();
  if ($mlid > 0) {
    $item = NULL;
  }

  // check if this nodetype is assigned to some menu path
  if (($href = db_query("SELECT path FROM {power_menu} WHERE nodetype = :nodetype AND menu_name = :menu_name", array(
    ':nodetype' => $node->type,
    ':menu_name' => $current_power_menu,
  ))
    ->fetchField()) != '') {
    $item['href'] = $href;
  }

  // we are going to check if there are certain taxonomy terms that should active a menu item
  $taxonomy_field = 'field_' . variable_get('power_menu_taxonomy_field', '');
  if (!empty($taxonomy_field) && !empty($node->{$taxonomy_field})) {
    $href = _power_menu_get_node_location_taxonomy($node, $current_power_menu);
    if ($href) {
      $item['href'] = $href;
    }
  }
  return $item;
}

/**
 *
 * @param $node
 * @param $current_menu
 */
function _power_menu_get_node_location_taxonomy($node, $current_power_menu) {
  $taxonomy_field = 'field_' . variable_get('power_menu_taxonomy_field', '');
  if (!empty($taxonomy_field) && !empty($node->{$taxonomy_field})) {
    $terms = field_get_items('node', $node, $taxonomy_field);
    if ($terms) {
      return db_query("SELECT path FROM {power_menu} WHERE tid = :tid AND menu_name = :menu_name", array(
        ':tid' => $terms[0]['tid'],
        ':menu_name' => $current_power_menu,
      ))
        ->fetchField();
    }
  }
  return NULL;
}

/**
 * Set Breadcrumbs based on active menu trail.
 * I borrowed this function from the menutrails module
 */
function power_menu_get_breadcrumbs() {
  $item = menu_get_item();

  // Give first priority to the selected menu.
  $menu = power_menu_get_menu();
  if (!$menu) {
    $menu = db_query("SELECT menu_name FROM {menu_links} WHERE link_path = :link_path AND module = :module", array(
      ':link_path' => $item['href'],
      ':module' => 'menu',
    ))
      ->fetchField();
  }
  $tree = menu_tree_page_data($menu);
  $crumbs = array(
    l(t('Home'), '<front>'),
  );
  _power_menu_recurse_crumbs($tree, $item, $crumbs);
  return $crumbs;
}

/**
 * I borowed this function from the menutrails menu. Thanks a lot
 * @param array $tree
 * @param array $item
 * @param array $crumbs
 * @param array $above
 */
function _power_menu_recurse_crumbs($tree, $item, &$crumbs, $above = array()) {
  foreach ($tree as $menu_item) {
    if (!$menu_item['link']['in_active_trail']) {
      continue;
    }
    if ($menu_item['link']['link_path'] == $item['href']) {
      foreach ($above as $trail_item) {
        $crumbs[] = l($trail_item['link']['link_title'], $trail_item['link']['link_path']);
      }
      $crumbs[] = l($menu_item['link']['link_title'], $menu_item['link']['link_path']);
      break;
    }
    if (is_array($menu_item['below'])) {
      _power_menu_recurse_crumbs($menu_item['below'], $item, $crumbs, array_merge($above, array(
        $menu_item,
      )));
    }
  }
}

/**
 * Return a themed set of links.
 *
 * The important difference is that we use the in_active_trail bit here to set
 * an "active" CSS class, which is what most themes (e.g. garland) use to
 * denote an active/open menu item. You should alter/override this as your
 * design needs dictate.
 *
 * @param $links
 *   A keyed array of links to be themed.
 * @param $attributes
 *   A keyed array of attributes
 * @return
 *   A string containing an unordered list of links.
 */
function phptemplate_links($links, $attributes = array(
  'class' => 'links',
)) {
  global $language;
  $output = '';
  if (count($links) > 0) {
    $output = '<ul' . drupal_attributes($attributes) . '>';

    //dsm($links);
    $num_links = count($links);
    $i = 1;
    foreach ($links as $key => $link) {
      $class = $key;

      // Add first, last and active classes to the list of links to help out themers.
      if ($i == 1) {
        $class .= ' first';
      }
      if ($i == $num_links) {
        $class .= ' last';
      }
      if (isset($link['href']) && ($link['href'] == $_GET['q'] || $link['href'] == '<front>' && drupal_is_front_page()) && (empty($link['language']) || $link['language']->language == $language->language)) {
        $class .= ' active';
      }
      $a = '';
      if (isset($link['href'])) {

        // Add active class for containing <li> and <a> if 'active-trail' is set
        // on the link itself.
        if (isset($link['attributes']['class']) && strpos($link['attributes']['class'], 'active-trail') !== FALSE && strpos($class, 'active') === FALSE) {
          $class .= ' active';
          $link['attributes']['class'] .= ' active';
        }

        // Pass in $link as $options, they share the same keys.
        $a = l($link['title'], $link['href'], $link);
      }
      elseif (!empty($link['title'])) {

        // Some links are actually not links, but we wrap these in <span> for adding title and class attributes
        if (empty($link['html'])) {
          $link['title'] = check_plain($link['title']);
        }
        $span_attributes = '';
        if (isset($link['attributes'])) {
          $span_attributes = drupal_attributes($link['attributes']);
        }
        $a = '<span' . $span_attributes . '>' . $link['title'] . '</span>';
      }
      $i++;
      $output .= '<li' . drupal_attributes(array(
        'class' => $class,
      )) . '>';
      $output .= $a;
      $output .= "</li>\n";
    }
    $output .= '</ul>';
  }
  return $output;
}

/**
* Implements hook_form_ID_alter().
 ().
*
* When deleting an menu item we have to clean up the power_menu stuff
* @param array $form
* @param array $form_state
*/
function power_menu_form_menu_item_delete_form_alter(&$form, $form_state) {
  $form['#submit'][] = 'power_menu_delete_menu_item_callback';
}

/**
 * When deleting a menu item we have to make sure we also clean out our table
 * @param array $form
 * @param array $form_state
 */
function power_menu_delete_menu_item_callback($form, $form_state) {
  db_delete('power_menu')
    ->condition('mlid', $form['#item']['mlid'])
    ->execute();
}

/**
 * Implements hook_taxonomy().
 *
 * @param string $op
 * @param string $type
 * @param array $array
 */
function power_menu_taxonomy($op, $type, $array = NULL) {
  if ($op == 'delete' && $type == 'term') {
    db_delete('power_menu')
      ->condition('tid', $array['tid'])
      ->execute();
  }
}

/**
 * get a term id from a given mlid
 * this can be used to find out if a menu item is connected to a taxonomy term
 * @param array $mlid
 */
function power_menu_get_tids($mlid) {
  $ar = array();
  $result = db_query("SELECT amt.tid,td.vid,td.name, amt.nodetype FROM {power_menu} amt LEFT JOIN {taxonomy_term_data} td ON amt.tid = td.tid\n    WHERE mlid = :mlid", array(
    ':mlid' => $mlid,
  ));
  foreach ($result as $row) {
    $ar[] = $row;
  }
  return $ar;
}

/**
 * This is a rewrite of taxonomy_get_term_by_name but it also uses the vocab id (vid)
 * @param string $name
 * @param int $vid
 */
function power_menu_get_term_by_name_vocab($name, $vid) {
  $taxonomies = taxonomy_term_load_multiple(array(), array(
    'vid' => $vid,
    'name' => trim($name),
  ));
  $result = array();
  foreach ($taxonomies as $term) {
    $result[] = (array) $term;
  }
  return $result;
}

/**
 * @todo Please document this function.
 * @see http://drupal.org/node/1354
 */
function power_menu_get_menu_tree() {
  $result = db_query("SELECT * FROM {menu_links} WHERE menu_name = :menu_name", array(
    ':menu_name' => power_menu_get_menu(),
  ));
  $tree = array();
  foreach ($result as $row) {
    $tree[] = $row;
  }
  return $tree;
}

/**
 * @todo Please document this function.
 * @see http://drupal.org/node/1354
 */
function power_menu_get_mlid($href, $pms = '') {
  if ($pms == '') {
    $pms = power_menu_get_menu();
  }
  return db_query("SELECT * FROM {menu_links} WHERE link_path = :link_path AND menu_name = :menu_name", array(
    ':link_path' => $href,
    ':menu_name' => $pms,
  ))
    ->fetch();
}

/**
 * Implements hook_tokens().
 *
 * @param $type
 * @param $object
 * @param $options
 */
function power_menu_tokens($type, $tokens, $data, $options) {
  if ($type == 'node' && !empty($data['node'])) {
    $node = $data['node'];
    $pms = power_menu_get_pm_menus();
    $taxonomy_field = 'field_' . variable_get('power_menu_taxonomy_field', '');
    foreach (array_filter($pms) as $pm) {
      $mlid = db_query("SELECT mlid FROM {menu_links} WHERE menu_name = :menu_name AND link_path = :link_path", array(
        ':menu_name' => $pm,
        ':link_path' => "node/{$node->nid}",
      ))
        ->fetchField();
      if ($mlid > 0) {

        //we have a node that is in the menu
        $href = db_query("select ml2.link_path FROM {menu_links} ml INNER JOIN {menu_links} ml2 ON ml.plid = ml2.mlid WHERE ml.mlid = :mlid", array(
          ':mlid' => $mlid,
        ))
          ->fetchField();
      }
      else {
        if (($href = db_query("SELECT path FROM {power_menu} WHERE nodetype = :nodetype AND menu_name = :menu_name", array(
          ':nodetype' => $node->type,
          ':menu_name' => $pm,
        ))
          ->fetchField()) != '') {

          // a node type that belongs to a defined menu entry
        }
        else {
          if (!empty($taxonomy_field) && !empty($node->{$taxonomy_field})) {

            // a node that belongs to the taxonomy
            $href = _power_menu_get_node_location_taxonomy($node, $pm);
          }
        }
      }
      $replacement["[node:power_menu_path_{$pm}-path]"] = $href ? drupal_get_path_alias($href, $node->language) : 'content-default';
    }
    return $replacement;
  }
}

/**
 * Implements hook_token_info().
 *
 * @param $type
 */
function power_menu_token_info() {
  $pms = power_menu_get_pm_menus();
  $info = array();
  foreach (array_filter($pms) as $pm) {
    $info['tokens']['node']["power_menu_path_{$pm}-path"] = array(
      'name' => t("Power Menu: %power_menu", array(
        '%power_menu' => $pm,
      )),
      'description' => t("Path based on the Power Menu: %power_menu", array(
        '%power_menu' => $pm,
      )),
    );
  }
  return $info;
}

/**
 * Implements hook_preproces_page().
 *
 * loading properties for the page scope
 * @param $vars
 */
function power_menu_preprocess_page(&$vars) {
  $mlid = power_menu_get_mlid(check_plain($_GET['q']));
  if (isset($vars['node']) && is_object($vars['node'])) {
    $item = power_menu_node_location($vars['node']);
    $mlid = power_menu_get_mlid($item['href']);
  }
  foreach (power_menu_get_all_property_definitions() as $item) {
    if ($item['scope'] == 'page') {
      include_once DRUPAL_ROOT . '/' . $item['path'] . '/' . $item['file'];
      $ml = is_object($mlid) ? $mlid->mlid : $mlid;
      $vars[$item['property_name']] = $item['property_load']($ml);
    }
  }
}

/**
 * Implements hook_block_info().
 */
function power_menu_block_info() {
  $properties = power_menu_get_all_property_definitions();
  $blocks = array();
  foreach ($properties as $item) {
    if ($item['scope'] == 'block') {
      $blocks[$item['property_name']] = array(
        'info' => 'Power Menu Block: ' . $item['property_name'],
        'cache' => DRUPAL_CACHE_PER_PAGE,
      );
    }
  }
  return $blocks;
}

/**
 * Implements hook_block_view().
 */
function power_menu_block_view($delta) {
  $properties = power_menu_get_all_property_definitions();
  if (!empty($properties)) {
    include_once DRUPAL_ROOT . '/' . $properties[$delta]['path'] . '/' . $properties[$delta]['file'];
    $block = array(
      'content' => $properties[$delta]['property_load']($mlid),
      'subject' => $properties[$delta]['title'],
    );
    return $block;
  }
}

/*
 * We don't want to be calling the hooks all the time, so we just get the from the cache
 * cache is being flushed everytime a menu item is being saved
 * @return $properties
 */

/**
 * @todo Please document this function.
 * @see http://drupal.org/node/1354
 */
function power_menu_get_all_property_definitions() {
  if ($cache = cache_get('power_menu_properties', 'cache')) {
    $properties = $cache->data;
  }
  else {
    $dir = dir(drupal_get_path('module', 'power_menu') . '/properties');
    $properties = array();
    while ($filename = $dir
      ->read()) {
      $file = $dir->path . '/' . $filename;
      if (filetype($file) == 'file') {
        include_once DRUPAL_ROOT . '/' . $file;
        $properties = array_merge($properties, module_invoke(str_replace(".inc", '', $filename), 'power_menu_properties'));
      }
    }
    $dir
      ->close();
    $properties = array_merge($properties, module_invoke_all('power_menu_properties'));
    cache_set('power_menu_properties', $properties, 'cache');
  }
  return $properties;
}

Functions

Namesort descending Description
phptemplate_links Return a themed set of links.
power_menu_block_info Implements hook_block_info().
power_menu_block_view Implements hook_block_view().
power_menu_ctools_render_alter Implements hook_ctools_render_alter().
power_menu_delete_menu_item_callback When deleting a menu item we have to make sure we also clean out our table
power_menu_form_menu_edit_item_alter Implements hook_form_ID_alter().
power_menu_form_menu_edit_item_submit Callback function when menu_edit_item form is being submitted
power_menu_form_menu_item_delete_form_alter Implements hook_form_ID_alter(). ().
power_menu_form_menu_overview_form_alter Implements hook_form_ID_alter().
power_menu_get_all_property_definitions @todo Please document this function.
power_menu_get_breadcrumbs Set Breadcrumbs based on active menu trail. I borrowed this function from the menutrails module
power_menu_get_menu Get the menu which is defined as the power menu
power_menu_get_menu_tree @todo Please document this function.
power_menu_get_mlid @todo Please document this function.
power_menu_get_navigation_taxonomy @todo Please document this function.
power_menu_get_pm_menus Return all menus that are used for power menu
power_menu_get_term_by_name_vocab This is a rewrite of taxonomy_get_term_by_name but it also uses the vocab id (vid)
power_menu_get_tids get a term id from a given mlid this can be used to find out if a menu item is connected to a taxonomy term
power_menu_init Implements hook_init().
power_menu_menu Implements hook_menu().
power_menu_node_location Determine the menu location of a node.
power_menu_node_view Implements hook_node_view().
power_menu_preprocess_page Implements hook_preproces_page().
power_menu_taxonomy Implements hook_taxonomy().
power_menu_tokens Implements hook_tokens().
power_menu_token_info Implements hook_token_info().
_power_menu_get_active_menu_block We are trying to figure out which of the blocks is currently active. We need this incase we display multiple menu blocks on the page, that are linked to the same term id, but have a different path. For example:
_power_menu_get_node_location_taxonomy
_power_menu_recurse_crumbs I borowed this function from the menutrails menu. Thanks a lot
_power_menu_replace_tid_in_path It's possible for the user to write a path like news/[tid] [tid] is like a token, that will be replaced by the either newly created term id ($tid) or the linked term id.