You are here

function admin_menu_admin_menu_output_build in Administration menu 6.3

Same name and namespace in other branches
  1. 8.3 admin_menu.module \admin_menu_admin_menu_output_build()
  2. 7.3 admin_menu.module \admin_menu_admin_menu_output_build()

Implements hook_admin_menu_output_build().

File

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

Code

function admin_menu_admin_menu_output_build(&$content) {

  // Retrieve the "Add content" link tree.
  $link = db_fetch_array(db_query("SELECT * FROM {menu_links} WHERE router_path = 'node/add' AND module = 'system'"));
  $conditions = array();
  for ($i = 1; $i < MENU_MAX_DEPTH; $i++) {
    if (!empty($link["p{$i}"])) {
      $conditions["p{$i}"] = $link["p{$i}"];
    }
  }

  // Forked from menu.inc.
  // @see menu_tree_all_data()
  $where = '';
  $args = array();
  foreach ($conditions as $column => $value) {
    $where .= " AND {$column} = %d";
    $args[] = $value;
  }
  $parents = $args;
  array_unshift($args, $link['menu_name']);
  $data['tree'] = menu_tree_data(db_query("\n    SELECT m.load_functions, m.to_arg_functions, m.access_callback, m.access_arguments, m.page_callback, m.page_arguments, m.title, m.title_callback, m.title_arguments, m.type, m.description, ml.*\n    FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path\n    WHERE ml.menu_name = '%s'" . $where . "\n    ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC, p9 ASC", $args), $parents);
  $data['node_links'] = array();
  menu_tree_collect_node_links($data['tree'], $data['node_links']);
  menu_tree_check_access($data['tree'], $data['node_links']);
  $tree = $data['tree'];
  $links = admin_menu_links_menu($tree);
  if (!empty($links)) {

    // If the user has access to the top-level "Content" category, insert the
    // "Add content" link tree there.
    if (isset($content['menu']['admin/content'])) {
      $content['menu']['admin/content'] += $links;
    }
    else {
      $key = key($links);
      $links[$key]['#weight'] = -100;
      $content['menu'] += $links;
    }
  }
}