admin_menu_tree

Versions
6
admin_menu_tree()
7
admin_menu_tree($menu_name)

Build the full administration menu tree from static and expanded dynamic items.

Parameters

$menu_name The menu name to use as base for the tree.

Code

contributions/admin_menu/admin_menu.inc, line 14

<?php
function admin_menu_tree($menu_name) {
  // Get placeholder expansion arguments from hook_admin_menu_map()
  // implementations.
  module_load_include('inc', 'admin_menu', 'admin_menu.map');
  $expand_map = module_invoke_all('admin_menu_map');
  // Allow modules to alter the expansion map.
  drupal_alter('admin_menu_map', $expand_map);

  $new_map = array();
  $hidden = array();
  foreach ($expand_map as $path => $data) {
    // Convert named placeholders to anonymous placeholders, since the menu
    // system stores paths using anonymous placeholders.
    // @todo Why specify named placeholders in the first place then?
    $replacements = array_fill_keys(array_keys($data['arguments'][0]), '%');
    $data['parent'] = strtr($data['parent'], $replacements);
    $new_map[strtr($path, $replacements)] = $data;

    // Collect paths to hide.
    if (isset($data['hide'])) {
      $hidden[strtr($data['hide'], $replacements)] = 1;
    }
  }
  $expand_map = $new_map;
  unset($new_map);

  // Retrieve dynamic menu link tree for the expansion mappings.
  $tree_dynamic = admin_menu_tree_dynamic($expand_map);

  // Merge local tasks with static menu tree.
  $tree = menu_tree_all_data($menu_name);
  admin_menu_merge_tree($tree, $tree_dynamic, array(), $hidden);

  return $tree;
}
?>

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • Web page addresses and e-mail addresses turn into links automatically.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.