You are here

function dhtml_menu_theme_menu_item_link in DHTML Menu 6.4

Same name and namespace in other branches
  1. 8 dhtml_menu.theme.inc \dhtml_menu_theme_menu_item_link()
  2. 6.3 dhtml_menu.module \dhtml_menu_theme_menu_item_link()

Preprocessor for menu_item_link. Adds an ID attribute to menu links and helps the module follow the recursion of menu_tree_output().

2 string references to 'dhtml_menu_theme_menu_item_link'
dhtml_menu_theme_registry_alter in ./dhtml_menu.module
Implementation of hook_theme_registry_alter(). Replaces the theme functions for the menu_item functions, and stores the original functions in order to call them when this module is done with preprocessing.
dhtml_menu_update_7101 in ./dhtml_menu.install
#7101: 7.x-1.x-dev upgrade (duplicated in 6.x-3.x). Remove two obsolete variables and rebuild all themes.

File

./dhtml_menu.theme.inc, line 14
dhtml_menu.theme.inc All functions related to generating the menu markup.

Code

function dhtml_menu_theme_menu_item_link($link) {
  global $theme;
  static $function;
  $settings = variable_get('dhtml_menu_settings', array());
  if (!isset($function)) {
    $registry = variable_get('dhtml_menu_theme', array());
    if (isset($registry[$theme]) && function_exists($registry[$theme]['menu_item_link'])) {
      $function = $registry[$theme]['menu_item_link'];
    }
    else {
      $function = 'theme_menu_item_link';
    }
  }

  // Do not stack items that have no menu or mlid.
  if (empty($link['menu_name']) || empty($link['mlid'])) {
    return $function($link);
  }
  $extended_link = $link;

  // If the menu is blacklisted or not whitelisted, mark the link as disabled for DHTML.
  $extended_link['dhtml_disabled'] = ($settings['filter']['type'] == 'blacklist') == !empty($settings['filter']['list'][$link['menu_name']]);

  // Add the ID attribute.
  $extended_link = array_merge_recursive($extended_link, array(
    'localized_options' => array(
      'attributes' => array(),
    ),
  ));
  $extended_link['localized_options']['attributes']['id'] = 'dhtml_menu-' . _dhtml_menu_unique_id($link['mlid']);

  // Each link in series is another level of recursion. Add it to the stack, even if it is disabled.
  _dhtml_menu_stack($extended_link);

  // Pass the altered variables to the normal menu themer, but only if DHTML should be used.
  return $function(!$extended_link['dhtml_disabled'] ? $extended_link : $link);
}