You are here

function bigmenu_slice_form in Big Menu 6

Same name and namespace in other branches
  1. 7 bigmenu.admin.inc \bigmenu_slice_form()

Form for editing the immediate children of the given menu item id

Invoked by menu callback or by json request

Return value

FAPI form.

2 string references to 'bigmenu_slice_form'
bigmenu_menu in ./bigmenu.module
Declare admin links and AJAX callbacks
bigmenu_slice_form_js in ./bigmenu.admin.inc
Return a submenu slice form in json format Menu callback, invoked by AJAX

File

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

Code

function bigmenu_slice_form(&$form_state, $menu, $menu_link, $depth = 2) {
  $menu_slice = menu_get_menus();

  // DB lookup the children of this item
  global $menu_admin;
  $p_depth = 'p' . $menu_link['depth'];
  $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 = '%s'\n    AND %s = %d\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, $menu['menu_name'], $p_depth, $menu_link['mlid']);
  $tree = menu_tree_data($result);
  $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;

  // When doing a slice, don't show the actual parent link item, just the children
  foreach ($tree as $ix => $data) {
    unset($tree[$ix]['link']);
  }

  // (there was only one, but I didn't know its name)
  $form = _bigmenu_overview_tree_form($tree, $depth);
  $form['#theme'] = 'bigmenu_overview_form';
  $form['#menu'] = $menu;
  if (element_children($form)) {
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Save configuration'),
    );
  }
  else {
    $form['empty_menu'] = array(
      '#value' => t('There are no menu items yet.'),
    );
  }
  return $form;
}