Index: themes/garland/fix-ie-rtl.css =================================================================== RCS file: /cvs/drupal/drupal/themes/garland/fix-ie-rtl.css,v retrieving revision 1.1 diff -u -r1.1 fix-ie-rtl.css --- themes/garland/fix-ie-rtl.css 6 Sep 2007 21:17:07 -0000 1.1 +++ themes/garland/fix-ie-rtl.css 28 Oct 2007 05:57:49 -0000 @@ -47,7 +47,7 @@ margin-bottom: 1em; } -td.menu-disabled { +tr.menu-disabled { /* Use filter to emulate CSS3 opacity */ filter: alpha(opacity=50); } Index: themes/garland/fix-ie.css =================================================================== RCS file: /cvs/drupal/drupal/themes/garland/fix-ie.css,v retrieving revision 1.6 diff -u -r1.6 fix-ie.css --- themes/garland/fix-ie.css 6 Sep 2007 21:23:32 -0000 1.6 +++ themes/garland/fix-ie.css 28 Oct 2007 05:57:49 -0000 @@ -49,7 +49,7 @@ margin-bottom: 1em; } -td.menu-disabled { +tr.menu-disabled { /* Use filter to emulate CSS3 opacity */ filter: alpha(opacity=50); } Index: themes/garland/style.css =================================================================== RCS file: /cvs/drupal/drupal/themes/garland/style.css,v retrieving revision 1.27 diff -u -r1.27 style.css --- themes/garland/style.css 11 Oct 2007 09:51:29 -0000 1.27 +++ themes/garland/style.css 28 Oct 2007 05:57:49 -0000 @@ -779,13 +787,7 @@ /** * Menu.module */ -tr.odd td.menu-disabled { - background-color: #edf5fa; -} -tr.even td.menu-disabled { - background-color: #fff; -} -td.menu-disabled { +tr.menu-disabled { opacity: 0.5; } Index: modules/menu/menu.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/menu/menu.admin.inc,v retrieving revision 1.4 diff -u -r1.4 menu.admin.inc --- modules/menu/menu.admin.inc 21 Oct 2007 18:59:02 -0000 1.4 +++ modules/menu/menu.admin.inc 28 Oct 2007 05:57:49 -0000 @@ -21,11 +21,10 @@ } /** - * Shows for one menu the menu items accessible to the current user and relevant operations. + * Form for editing an entire menu tree at once. Shows for one menu the menu + * items accessible to the current user and relevant operations. */ -function menu_overview($menu) { - - $header = array(t('Menu item'), t('Expanded'), array('data' => t('Operations'), 'colspan' => '3')); +function menu_overview_form(&$form_state, $menu) { $sql =" 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, ml.* FROM {menu_links} ml LEFT JOIN {menu_router} m ON m.path = ml.router_path @@ -37,81 +36,133 @@ $node_links = array(); menu_tree_collect_node_links($tree, $node_links); menu_tree_check_access($tree, $node_links); - $rows = _menu_overview_tree($tree); - $output = theme('table', $header, $rows); - $output .= theme('pager', NULL, 200, 0); - return $output; + + $form = _menu_overview_tree_form($form_state, $tree); + $form['submit'] = array( + '#type' => 'submit', + '#value' => t('Submit'), + ); + return $form; } /** - * Recursive helper function for menu_overview(). + * Recursive helper function for menu_overview_form(). */ -function _menu_overview_tree($tree) { - static $rows = array(); +function _menu_overview_tree_form(&$form_state, $tree) { + static $form = array('#tree' => TRUE); foreach ($tree as $data) { $title = ''; $item = $data['link']; // Don't show callbacks; these have $item['hidden'] < 0. if ($item && $item['hidden'] >= 0) { - $title = str_repeat(' ', $item['depth'] - 1) . ($item['depth'] > 1 ? '- ' : ''); - $title .= l($item['title'], $item['href'], $item['options']); - // Populate the operations field. + $mlid = $item['mlid']; + $form[$mlid] = array( + '#attributes' => $item['hidden'] ? array('class' => 'menu-disabled') : array('class' => 'menu-enabled'), + ); + $form[$mlid]['title'] = array( + '#value' => l($item['title'], $item['href'], $item['options']) . ($item['hidden'] ? ' ('. t('disabled') .')' : ''), + ); + $form[$mlid]['hidden'] = array( + '#type' => 'checkbox', + '#default_value' => isset($form_state[$mlid]['hidden']) ? $form_state[$mlid]['hidden'] : !$item['hidden'], + ); + $form[$mlid]['expanded'] = array( + '#value' => $item['has_children'] ? (($item['expanded']) ? t('Yes') : t('No')) : '', + ); + $form[$mlid]['weight'] = array( + '#type' => 'weight', + '#default_value' => isset($form_state[$mlid]['weight']) ? $form_state[$mlid]['weight'] : $item['weight'], + ); + $form[$mlid]['depth'] = array( + '#type' => 'hidden', + '#value' => $item['depth'], + ); + $form[$mlid]['mlid'] = array( + '#type' => 'hidden', + '#value' => $item['mlid'], + ); + $form[$mlid]['plid'] = array( + '#type' => 'textfield', + '#default_value' => isset($form_state[$mlid]['plid']) ? $form_state[$mlid]['plid'] : $item['plid'], + '#size' => 6, + ); + + // Build a list of operations. $operations = array(); - // Set the edit column. - $operations[] = array('data' => l(t('edit'), 'admin/build/menu/item/'. $item['mlid'] .'/edit')); - if ($item['hidden']) { - $title .= ' ('. t('disabled') .')'; - $class = 'menu-disabled'; - $operations[] = array('data' => l(t('enable'), 'admin/build/menu/item/'. $item['mlid'] .'/enable')); - } - else { - $class = 'menu-enabled'; - $operations[] = array('data' => l(t('disable'), 'admin/build/menu/item/'. $item['mlid'] .'/disable')); - } + $operations['edit'] = l(t('edit'), 'admin/build/menu/item/'. $item['mlid'] .'/edit'); // Only items created by the menu module can be deleted. if ($item['module'] == 'menu') { - $operations[] = array('data' => l(t('delete'), 'admin/build/menu/item/'. $item['mlid'] .'/delete')); + $operations['delete'] = l(t('delete'), 'admin/build/menu/item/'. $item['mlid'] .'/delete'); } // Set the reset column. elseif ($item['module'] == 'system' && $item['customized']) { - $operations[] = array('data' => l(t('reset'), 'admin/build/menu/item/'. $item['mlid'] .'/reset')); + $operations['reset'] = l(t('reset'), 'admin/build/menu/item/'. $item['mlid'] .'/reset'); } - else { - $operations[] = array('data' => ''); - } - $row = array( - array('data' => $title, 'class' => $class), - array('data' => ($item['has_children'] ? (($item['expanded']) ? t('Yes') : t('No')) : ''), 'class' => $class), - ); - foreach ($operations as $operation) { - $operation['class'] = $class; - $row[] = $operation; + + $form[$mlid]['operations'] = array(); + foreach ($operations as $op => $value) { + $form[$mlid]['operations'][$op] = array('#value' => $value); } - $rows[] = $row; } + if ($data['below']) { - _menu_overview_tree($data['below']); + _menu_overview_tree_form($form_state, $data['below']); } } - return $rows; + return $form; } /** - * Menu callback; enable/disable a menu link. - * - * @param $hide - * TRUE to not show in the menu tree. FALSE to make the item and its children - * reappear in menu tree. - * @param $item - * The menu item. + * Theme the menu overview form into a sortable drag and drop table. */ -function menu_flip_item($hide, $item) { +function theme_menu_overview_form($form) { + // Add the draggable table javascript. + drupal_add_tabledrag('menu-overview', 'menu-plid', 'match', 'parent', 'menu-plid', 'menu-mlid'); + drupal_add_tabledrag('menu-overview', 'menu-weight', 'order', 'sibling', 'menu-weight'); + + $header = array(t('Menu item'), t('Expanded'), t('Enabled'), t('Parent'), t('Weight'), array('data' => t('Operations'), 'colspan' => '3')); + $rows = array(); + foreach (element_children($form) as $mlid) { + if (isset($form[$mlid]['mlid'])) { + $plid = $form[$mlid]['plid']['#value']; - $item['hidden'] = (bool)$hide; - $item['customized'] = 1; - menu_link_save($item); - drupal_set_message($hide ? t('The menu item has been disabled.') : t('The menu item has been enabled.')); - drupal_goto('admin/build/menu-customize/'. $item['menu_name']); + // Build a list of operations. + $operations = array(); + foreach (element_children($form[$mlid]['operations']) as $op) { + $operations[] = drupal_render($form[$mlid]['operations'][$op]); + } + while (count($operations) < 2) { + $operations[] = ''; + } + + // Add special classes to be used for tabledrag.js. + $form[$mlid]['plid']['#attributes']['class'] = 'menu-plid menu-plid-'. $plid; + $form[$mlid]['mlid']['#attributes']['class'] = 'menu-mlid menu-mlid-'. $plid; + $form[$mlid]['weight']['#attributes']['class'] = 'menu-weight menu-weight-'. $plid; + + // Make indentations. + $indentation = ''; + for ($n = 1; $n < $form[$mlid]['depth']['#value']; $n++) { + $indentation .= '