You are here

function bigmenu_overview_form in Big Menu 7

Same name and namespace in other branches
  1. 6 bigmenu.admin.inc \bigmenu_overview_form()

Overview form for bigmenu.

2 string references to 'bigmenu_overview_form'
bigmenu_menu_alter in ./bigmenu.module
Take over core menu admin page.
bigmenu_slice_form in ./bigmenu.admin.inc
Form for editing the immediate children of the given menu item id.

File

./bigmenu.admin.inc, line 22
Administrative page callbacks for bigmenu module.

Code

function bigmenu_overview_form($form, &$form_state, $menu, $depth = 1) {
  global $menu_admin;
  $p_depth = 'p' . (string) ((int) $depth + 3);
  $sql = "\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 = :menu_name\n    AND {$p_depth} = 0\n    ORDER BY p1 ASC, p2 ASC, p3 ASC, p4 ASC, p5 ASC, p6 ASC, p7 ASC, p8 ASC, p9 ASC";
  $result = db_query($sql, array(
    ':menu_name' => $menu['menu_name'],
  ), array(
    'fetch' => PDO::FETCH_ASSOC,
  ));
  $links = array();
  foreach ($result as $item) {
    $links[] = $item;
  }
  $tree = menu_tree_data($links);
  $node_links = array();
  menu_tree_collect_node_links($tree, $node_links);

  // We indicate that a menu administrator is running the menu access check.
  $menu_admin = TRUE;
  menu_tree_check_access($tree, $node_links);
  $menu_admin = FALSE;

  // If the user doesn't have the permission to use big menu, use core's form.
  $new_form = user_access('use bigmenu') ? _bigmenu_overview_tree_form($tree) : _menu_overview_tree_form($tree);
  $cached_mlids = bigmenu_get_cached_mlids($form_state);
  $new_form = array_merge($new_form, $cached_mlids);
  $new_form['#menu'] = $menu;
  if (element_children($new_form)) {
    $new_form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Save configuration'),
    );
  }
  else {
    $new_form['#empty_text'] = array(
      '#markup' => t('There are no menu items yet.'),
    );
  }
  return $new_form;
}