You are here

function theme_admin_menu_item in Administration menu 5.3

Same name and namespace in other branches
  1. 5 admin_menu.inc \theme_admin_menu_item()
  2. 5.2 admin_menu.module \theme_admin_menu_item()
  3. 6 admin_menu.module \theme_admin_menu_item()

High-performance implementation of theme_menu_item().

This saves us a theme() call and does only the absolute minimum to get the admin menu links rendered.

Parameters

$mid: The menu id of the item.

$children: A string containing any rendered child items of this menu.

$leaf: A boolean indicating whether this menu item is a leaf.

1 call to theme_admin_menu_item()
theme_admin_menu_tree in ./admin_menu.module
Return a rendered menu tree.

File

./admin_menu.module, line 436
Render an administrative menu as a dropdown menu at the top of the window.

Code

function theme_admin_menu_item($mid, $children = '', $leaf = TRUE) {
  static $display_option, $destination;
  $_admin_menu = admin_menu_get_menu();
  $item = $_admin_menu[$mid];
  if (!isset($display_option)) {
    $display_option = variable_get('admin_menu_display', 0);
    $destination = drupal_get_destination();
  }

  // Display extra information about menu items if enabled (devel).
  if ($display_option) {
    if ($display_option == 'mid') {
      $item['title'] = $item['title'] . ' (' . $mid . ')';
    }
    else {
      if (isset($item[$display_option])) {
        $item['title'] = $item['title'] . ' (' . $item[$display_option] . ')';
      }
    }
  }
  $class = array();
  if (!$leaf) {
    $class[] = 'expandable';
  }
  if (isset($item['class'])) {
    $class[] = $item['class'];
  }

  // Strip destination query string from href attribute and apply a CSS class
  // for our JavaScript behavior instead.
  $path = preg_replace('/[\\?|&]' . preg_quote($destination, '/') . '/', '', $item['path']);
  if ($path != $item['path']) {
    if (!empty($item['attributes']['class'])) {
      $item['attributes']['class'] .= ' admin-menu-destination';
    }
    else {
      $item['attributes']['class'] = 'admin-menu-destination';
    }
  }
  $output = '<li' . (!empty($class) ? ' class="' . implode(' ', $class) . '"' : '') . '>';
  $output .= '<a href="' . check_url($path) . '"' . drupal_attributes($item['attributes']) . '>' . filter_xss_admin($item['title']) . '</a>' . $children . '</li>';
  return $output;
}