diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php index 99ab62e..5bb1dad 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermTest.php @@ -407,9 +407,8 @@ function testTermReorder() { $this->assertEqual($terms[1]->parents, array($term2->id()), 'Term 3 was made a child of term 2.'); $this->assertEqual($terms[2]->tid, $term1->id(), 'Term 1 was moved below term 2.'); - $this->drupalPost('admin/structure/taxonomy/manage/' . $this->vocabulary->id(), array(), t('Reset to alphabetical')); // Submit confirmation form. - $this->drupalPost(NULL, array(), t('Reset to alphabetical')); + $this->drupalPost('admin/structure/taxonomy/reset/' . $this->vocabulary->id(), array(), t('Reset to alphabetical')); drupal_static_reset('taxonomy_get_tree'); drupal_static_reset('taxonomy_get_treeparent'); diff --git a/core/modules/taxonomy/taxonomy.admin.inc b/core/modules/taxonomy/taxonomy.admin.inc old mode 100644 new mode 100755 index 4e7c5c2..93d5332 --- a/core/modules/taxonomy/taxonomy.admin.inc +++ b/core/modules/taxonomy/taxonomy.admin.inc @@ -279,8 +279,7 @@ function taxonomy_overview_terms($form, &$form_state, Vocabulary $vocabulary) { '#button_type' => 'primary', ); $form['actions']['reset_alphabetical'] = array( - '#type' => 'submit', - '#value' => t('Reset to alphabetical') + '#markup' => l(t('Reset to alphabetical'), 'admin/structure/taxonomy/reset/' . $vocabulary->id()), ); $form_state['redirect'] = array(current_path(), (isset($_GET['page']) ? array('query' => array('page' => $_GET['page'])) : array())); } @@ -304,12 +303,6 @@ function taxonomy_overview_terms($form, &$form_state, Vocabulary $vocabulary) { * @see taxonomy_overview_terms() */ function taxonomy_overview_terms_submit($form, &$form_state) { - if ($form_state['triggering_element']['#value'] == t('Reset to alphabetical')) { - // Redirect to confirmation form for the reset action. - $form_state['redirect'] = 'admin/structure/taxonomy/manage/' . $form_state['taxonomy']['vocabulary']->id() . '/reset'; - return; - } - // Sort term order based on weight. uasort($form_state['values']['terms'], 'drupal_sort_weight'); @@ -388,3 +381,38 @@ function taxonomy_overview_terms_submit($form, &$form_state) { } drupal_set_message(t('The configuration options have been saved.')); } + +/** + * Form builder to confirm resetting a vocabulary to alphabetical order. + * + * @ingroup forms + * @see taxonomy_vocabulary_confirm_reset_alphabetical_submit() + */ +function taxonomy_reset_terms($form, &$form_state, Drupal\taxonomy\Entity\Vocabulary $vocabulary) { + $form['type'] = array('#type' => 'value', '#value' => 'vocabulary'); + $form['vid'] = array('#type' => 'value', '#value' => $vocabulary->id()); + $form['name'] = array('#type' => 'value', '#value' => $vocabulary->label()); + $form['reset_alphabetical'] = array('#type' => 'value', '#value' => TRUE); + return confirm_form($form, + t('Are you sure you want to reset the vocabulary %title to alphabetical order?', + array('%title' => $vocabulary->label())), + 'admin/structure/taxonomy/manage/' . $vocabulary->id(), + t('Resetting a vocabulary will discard all custom ordering and sort items alphabetically.'), + t('Reset to alphabetical'), + t('Cancel')); +} + +/** + * Submit handler to reset a vocabulary to alphabetical order after confirmation. + * + * @see taxonomy_vocabulary_confirm_reset_alphabetical() + */ +function taxonomy_reset_terms_submit($form, &$form_state) { + db_update('taxonomy_term_data') + ->fields(array('weight' => 0)) + ->condition('vid', $form_state['values']['vid']) + ->execute(); + drupal_set_message(t('Reset vocabulary %name to alphabetical order.', array('%name' => $form_state['values']['name']))); + watchdog('taxonomy', 'Reset vocabulary %name to alphabetical order.', array('%name' => $form_state['values']['name']), WATCHDOG_NOTICE); + $form_state['redirect'] = 'admin/structure/taxonomy/manage/' . $form_state['values']['vid']; +} diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index 0bfa84d..17a1e6d 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -310,10 +310,22 @@ function taxonomy_menu() { 'access arguments' => array(4, 'view'), 'file' => 'taxonomy.admin.inc', ); + + $items['admin/structure/taxonomy/reset/%taxonomy_vocabulary'] = array( + 'title callback' => 'entity_page_label', + 'title arguments' => array(4), + 'page callback' => 'drupal_get_form', + 'page arguments' => array('taxonomy_reset_terms', 4), + 'access callback' => 'entity_page_access', + 'access arguments' => array(4, 'edit'), + 'file' => 'taxonomy.admin.inc', + ); + $items['admin/structure/taxonomy/manage/%taxonomy_vocabulary/list'] = array( 'title' => 'List', 'type' => MENU_DEFAULT_LOCAL_TASK, ); + $items['admin/structure/taxonomy/manage/%taxonomy_vocabulary/edit'] = array( 'title' => 'Edit', 'page callback' => 'entity_get_form', @@ -323,6 +335,7 @@ function taxonomy_menu() { 'type' => MENU_LOCAL_TASK, 'file' => 'taxonomy.admin.inc', ); + $items['admin/structure/taxonomy/%taxonomy_vocabulary/delete'] = array( 'title' => 'Delete', 'type' => MENU_LOCAL_TASK, diff --git a/core/themes/seven/style.css b/core/themes/seven/style.css old mode 100644 new mode 100755 index b0da782..18e650d --- a/core/themes/seven/style.css +++ b/core/themes/seven/style.css @@ -854,6 +854,17 @@ select.form-select:focus { } /** + * Improve spacing of reset to alphabetical link. + */ +#reset-to-alphabetical { + margin-left: 10px; /* LTR */ +} +[dir="rtl"] #reset-to-alphabetical { + margin-left: 0; + margin-right: 10px; +} + +/** * Improve form element usability on narrow devices. */ @media screen and (max-width: 600px) {