From 0e116ff9cfc117c3ab5d1354cab99175061db134 Mon Sep 17 00:00:00 2001 From: Angie Byron <webchick@24967.no-reply.drupal.org> Date: Fri, 21 Aug 2009 02:54:46 +0000 Subject: [PATCH] #555142 by yched: Clean up unneeded menu-rebuild code in Field UI. --- modules/field_ui/field_ui.admin.inc | 26 +--------------- modules/field_ui/field_ui.module | 46 +++++++++++------------------ 2 files changed, 19 insertions(+), 53 deletions(-) diff --git a/modules/field_ui/field_ui.admin.inc b/modules/field_ui/field_ui.admin.inc index caaa2d062b9c..02ce61b07735 100644 --- a/modules/field_ui/field_ui.admin.inc +++ b/modules/field_ui/field_ui.admin.inc @@ -496,7 +496,6 @@ function field_ui_field_overview_form_submit($form, &$form_state) { field_create_field($field); field_create_instance($instance); - $destinations[] = $admin_path . '/fields/refresh'; $destinations[] = $admin_path . '/fields/' . $field['field_name'] . '/field-settings'; $destinations[] = $admin_path . '/fields/' . $field['field_name'] . '/edit'; @@ -528,7 +527,6 @@ function field_ui_field_overview_form_submit($form, &$form_state) { try { field_create_instance($instance); - $destinations[] = $admin_path . '/fields/refresh'; $destinations[] = $admin_path . '/fields/' . $instance['field_name'] . '/edit'; // Store new field information for any additional submit handlers. $form_state['fields_added']['_add_existing_field'] = $instance['field_name']; @@ -999,11 +997,7 @@ function field_ui_field_delete_form_submit($form, &$form_state) { } $admin_path = _field_ui_bundle_admin_path($bundle); - $destinations = array( - $admin_path . '/fields/refresh', - $admin_path . '/fields', - ); - $form_state['redirect'] = field_ui_get_destinations($destinations); + $form_state['redirect'] = field_ui_get_destinations(array($admin_path . '/fields')); } /** @@ -1331,24 +1325,6 @@ function field_ui_next_destination($bundle) { return $admin_path . '/fields'; } -/** - * Menu callback; rebuild the menu after adding new fields. - * - * Dummy function to force a page refresh so menu_rebuild() will work right - * when creating a new field that creates a new menu item. - */ -function field_ui_field_menu_refresh($obj_type, $bundle) { - $bundle = field_attach_extract_bundle($obj_type, $bundle); - - menu_rebuild(); - $destinations = field_ui_next_destination($bundle); - if (is_array($destinations)) { - $path = array_shift($destinations); - drupal_goto($path, $destinations); - } - drupal_goto($destinations); -} - /** * Helper function to order fields when theming overview forms. */ diff --git a/modules/field_ui/field_ui.module b/modules/field_ui/field_ui.module index ce856dd97a10..00db4681c397 100644 --- a/modules/field_ui/field_ui.module +++ b/modules/field_ui/field_ui.module @@ -61,34 +61,6 @@ function field_ui_menu() { 'type' => MENU_LOCAL_TASK, 'weight' => 1, ) + $access; - // A dummy function to trigger a page refresh so that field menus get - // rebuilt correctly when new fields are added. - $items["$path/fields/refresh"] = array( - 'title' => 'Refresh menu', - 'page callback' => 'field_ui_field_menu_refresh', - 'page arguments' => array($obj_type, $bundle_arg), - 'type' => MENU_CALLBACK, - 'weight' => 1, - ) + $access; - $items["$path/display"] = array( - 'title' => 'Display fields', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('field_ui_display_overview_form', $obj_type, $bundle_arg), - 'type' => MENU_LOCAL_TASK, - 'weight' => 2, - ) + $access; - - // 'Display fields' tab and context secondary tabs. - $tabs = field_ui_build_modes_tabs($obj_type); - foreach ($tabs as $key => $tab) { - $items["$path/display/$key"] = array( - 'title' => $tab['title'], - 'page arguments' => array('field_ui_display_overview_form', $obj_type, $bundle_arg, $key), - 'type' => $key == 'basic' ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK, - 'weight' => $key == 'basic' ? 0 : 1, - ) + $access; - } - $instance_position = count(explode('/', $path)) + 1; $items["$path/fields/%field_ui_menu"] = array( 'title callback' => 'field_ui_menu_label', @@ -126,6 +98,24 @@ function field_ui_menu() { 'page arguments' => array('field_ui_field_delete_form', $obj_type, $bundle_arg, $instance_position), 'type' => MENU_LOCAL_TASK, ) + $access; + + // 'Display fields' tab and context secondary tabs. + $items["$path/display"] = array( + 'title' => 'Display fields', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('field_ui_display_overview_form', $obj_type, $bundle_arg), + 'type' => MENU_LOCAL_TASK, + 'weight' => 2, + ) + $access; + $tabs = field_ui_build_modes_tabs($obj_type); + foreach ($tabs as $key => $tab) { + $items["$path/display/$key"] = array( + 'title' => $tab['title'], + 'page arguments' => array('field_ui_display_overview_form', $obj_type, $bundle_arg, $key), + 'type' => $key == 'basic' ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK, + 'weight' => $key == 'basic' ? 0 : 1, + ) + $access; + } } } } -- GitLab