You are here

function theme_admin_drilldown_menu_tree_output in Admin 7.2

Same name and namespace in other branches
  1. 6.2 theme/theme.inc \theme_admin_drilldown_menu_tree_output()

Alternative to menu_tree_output() which uses admin implementations of the core menu theme functions.

File

theme/theme.inc, line 74

Code

function theme_admin_drilldown_menu_tree_output($variables) {
  $tree = $variables['menu'];
  $output = '';
  $items = array();

  // Pull out just the menu items we are going to render so that we
  // get an accurate count for the first/last classes.
  foreach ($tree as $data) {
    if (!$data['link']['hidden']) {
      $items[] = $data;
    }
  }
  $num_items = count($items);
  foreach ($items as $i => $data) {
    $extra_class = NULL;
    if ($i == 0) {
      $extra_class = 'first';
    }
    if ($i == $num_items - 1) {
      $extra_class = 'last';
    }
    $link = theme('admin_drilldown_menu_item_link', array(
      'item' => $data['link'],
    ));
    $in_active_trail = isset($data['link']['in_active_trail']) ? $data['link']['in_active_trail'] : FALSE;
    if ($data['below']) {
      $output .= theme('admin_drilldown_menu_item', array(
        'link' => $link,
        'has_children' => $data['link']['has_children'],
        'menu' => theme('admin_drilldown_menu_tree_output', array(
          'menu' => $data['below'],
        )),
        'in_active_trail' => $in_active_trail,
        'extra_class' => $extra_class,
      ));
    }
    else {
      $output .= theme('admin_drilldown_menu_item', array(
        'link' => $link,
        'has_children' => $data['link']['has_children'],
        'menu' => '',
        'in_active_trail' => $in_active_trail,
        'extra_class' => $extra_class,
      ));
    }
  }
  return $output ? theme('admin_drilldown_menu_tree', array(
    'menu' => $output,
  )) : '';
}