menu_edit_item

Versions
4.6
menu_edit_item($mid = 0)
6
menu_edit_item(&$form_state, $type, $item, $menu)
7
menu_edit_item($form, &$form_state, $type, $item, $menu)

Menu callback; dispatch to the appropriate menu item edit function.

Code

modules/menu.module, line 239

<?php
function menu_edit_item($mid = 0) {
  $op = $_POST['op'];
  $edit = $_POST['edit'];

  $output = '';

  switch ($op) {
    case t('Submit'):
      menu_edit_item_validate($edit);
      if (!form_get_errors()) {
        menu_edit_item_save($edit);
        drupal_goto('admin/menu');
      }
      $output .= menu_edit_item_form($edit);
      break;
    default:
      if ($mid > 0) {
        $item = db_fetch_object(db_query('SELECT * FROM {menu} WHERE mid = %d', $mid));

        $edit['mid'] = $item->mid;
        $edit['pid'] = $item->pid;
        $edit['path'] = $item->path;
        $edit['title'] = $item->title;
        $edit['description'] = $item->description;
        $edit['weight'] = $item->weight;
        $edit['type'] = $item->type;
      }
      else {
        $edit['mid'] = 0; // In case a negative ID was passed in.
        $edit['pid'] = 1; // default to "Navigation" menu.
        $edit['type'] = MENU_CUSTOM_ITEM;
      }
      $output .= menu_edit_item_form($edit);
  }

  print theme('page', $output);
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.