diff options
-rw-r--r-- | modules/field_ui/field_ui.test | 3 | ||||
-rw-r--r-- | modules/forum/forum.test | 2 | ||||
-rw-r--r-- | modules/path/path.test | 3 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.admin.inc | 17 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.module | 29 | ||||
-rw-r--r-- | modules/taxonomy/taxonomy.test | 12 |
6 files changed, 42 insertions, 24 deletions
diff --git a/modules/field_ui/field_ui.test b/modules/field_ui/field_ui.test index 67a602a34..510a09356 100644 --- a/modules/field_ui/field_ui.test +++ b/modules/field_ui/field_ui.test @@ -92,7 +92,8 @@ class FieldUITestCase extends DrupalWebTestCase { // Assert the field appears in the "add existing field" section for // different entity types; e.g. if a field was added in a node entity, it // should also appear in the 'taxonomy term' entity. - $this->drupalGet('admin/structure/taxonomy/1/fields'); + $vocabulary = taxonomy_vocabulary_load(1); + $this->drupalGet('admin/structure/taxonomy/' . $vocabulary->machine_name . '/fields'); $this->assertTrue($this->xpath('//select[@id="edit--add-existing-field-field-name"]//option[@value="' . $this->field_name . '"]'), t('Existing field was found in account settings.')); } diff --git a/modules/forum/forum.test b/modules/forum/forum.test index 377ac76f9..80fe69d2f 100644 --- a/modules/forum/forum.test +++ b/modules/forum/forum.test @@ -157,7 +157,7 @@ class ForumTestCase extends DrupalWebTestCase { ); // Edit the vocabulary. - $this->drupalPost('admin/structure/taxonomy/' . $vid . '/edit', $edit, t('Save')); + $this->drupalPost('admin/structure/taxonomy/' . $original_settings->machine_name . '/edit', $edit, t('Save')); $this->assertResponse(200); $this->assertRaw(t('Updated vocabulary %name.', array('%name' => $title)), t('Vocabulary was edited')); diff --git a/modules/path/path.test b/modules/path/path.test index e6a60232b..c8d9f1015 100644 --- a/modules/path/path.test +++ b/modules/path/path.test @@ -190,12 +190,13 @@ class PathTaxonomyTermTestCase extends DrupalWebTestCase { */ function testTermAlias() { // Create a term in the default 'Tags' vocabulary with URL alias. + $vocabulary = taxonomy_vocabulary_load(1); $description = $this->randomName();; $edit = array(); $edit['name'] = $this->randomName(); $edit['description[value]'] = $description; $edit['path[alias]'] = $this->randomName(); - $this->drupalPost('admin/structure/taxonomy/1/add', $edit, t('Save')); + $this->drupalPost('admin/structure/taxonomy/' . $vocabulary->machine_name . '/add', $edit, t('Save')); // Confirm that the alias works. $this->drupalGet($edit['path[alias]']); diff --git a/modules/taxonomy/taxonomy.admin.inc b/modules/taxonomy/taxonomy.admin.inc index 31856e2db..55ef4d6c9 100644 --- a/modules/taxonomy/taxonomy.admin.inc +++ b/modules/taxonomy/taxonomy.admin.inc @@ -20,9 +20,9 @@ function taxonomy_overview_vocabularies($form) { $form[$vocabulary->vid]['#vocabulary'] = $vocabulary; $form[$vocabulary->vid]['name'] = array('#markup' => check_plain($vocabulary->name)); $form[$vocabulary->vid]['weight'] = array('#type' => 'weight', '#delta' => 10, '#default_value' => $vocabulary->weight); - $form[$vocabulary->vid]['edit'] = array('#type' => 'link', '#title' => t('edit vocabulary'), '#href' => "admin/structure/taxonomy/$vocabulary->vid/edit"); - $form[$vocabulary->vid]['list'] = array('#type' => 'link', '#title' => t('list terms'), '#href' => "admin/structure/taxonomy/$vocabulary->vid"); - $form[$vocabulary->vid]['add'] = array('#type' => 'link', '#title' => t('add terms'), '#href' => "admin/structure/taxonomy/$vocabulary->vid/add"); + $form[$vocabulary->vid]['edit'] = array('#type' => 'link', '#title' => t('edit vocabulary'), '#href' => "admin/structure/taxonomy/$vocabulary->machine_name/edit"); + $form[$vocabulary->vid]['list'] = array('#type' => 'link', '#title' => t('list terms'), '#href' => "admin/structure/taxonomy/$vocabulary->machine_name"); + $form[$vocabulary->vid]['add'] = array('#type' => 'link', '#title' => t('add terms'), '#href' => "admin/structure/taxonomy/$vocabulary->machine_name/add"); } // Only make this form include a submit button and weight if more than one @@ -209,12 +209,12 @@ function taxonomy_form_vocabulary_submit($form, &$form_state) { switch (taxonomy_vocabulary_save($vocabulary)) { case SAVED_NEW: drupal_set_message(t('Created new vocabulary %name.', array('%name' => $vocabulary->name))); - watchdog('taxonomy', 'Created new vocabulary %name.', array('%name' => $vocabulary->name), WATCHDOG_NOTICE, l(t('edit'), 'admin/structure/taxonomy/' . $vocabulary->vid . '/edit')); + watchdog('taxonomy', 'Created new vocabulary %name.', array('%name' => $vocabulary->name), WATCHDOG_NOTICE, l(t('edit'), 'admin/structure/taxonomy/' . $vocabulary->machine_name . '/edit')); break; case SAVED_UPDATED: drupal_set_message(t('Updated vocabulary %name.', array('%name' => $vocabulary->name))); - watchdog('taxonomy', 'Updated vocabulary %name.', array('%name' => $vocabulary->name), WATCHDOG_NOTICE, l(t('edit'), 'admin/structure/taxonomy/' . $vocabulary->vid . '/edit')); + watchdog('taxonomy', 'Updated vocabulary %name.', array('%name' => $vocabulary->name), WATCHDOG_NOTICE, l(t('edit'), 'admin/structure/taxonomy/' . $vocabulary->machine_name . '/edit')); break; } @@ -378,7 +378,7 @@ function taxonomy_overview_terms($form, &$form_state, $vocabulary) { $form['#page_entries'] = $page_entries; $form['#back_step'] = $back_step; $form['#forward_step'] = $forward_step; - $form['#empty_text'] = t('No terms available. <a href="@link">Add term</a>.', array('@link' => url('admin/structure/taxonomy/' . $vocabulary->vid . '/add'))); + $form['#empty_text'] = t('No terms available. <a href="@link">Add term</a>.', array('@link' => url('admin/structure/taxonomy/' . $vocabulary->machine_name . '/add'))); if ($vocabulary->hierarchy < 2 && count($tree) > 1) { $form['submit'] = array( @@ -941,12 +941,13 @@ function taxonomy_vocabulary_confirm_reset_alphabetical($form, &$form_state, $vi $form['type'] = array('#type' => 'value', '#value' => 'vocabulary'); $form['vid'] = array('#type' => 'value', '#value' => $vid); + $form['machine_name'] = array('#type' => 'value', '#value' => $vocabulary->machine_name); $form['name'] = array('#type' => 'value', '#value' => $vocabulary->name); $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->name)), - 'admin/structure/taxonomy/' . $vid, + 'admin/structure/taxonomy/' . $vocabulary->machine_name, t('Resetting a vocabulary will discard all custom ordering and sort items alphabetically.'), t('Reset to alphabetical'), t('Cancel')); @@ -964,5 +965,5 @@ function taxonomy_vocabulary_confirm_reset_alphabetical_submit($form, &$form_sta ->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/' . $form_state['values']['vid']; + $form_state['redirect'] = 'admin/structure/taxonomy/' . $form_state['values']['machine_name']; } diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index 944efe348..df5ce1bb5 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -42,7 +42,7 @@ function taxonomy_help($path, $arg) { $output = '<p>' . t('Taxonomy is for categorizing content. Terms are grouped into vocabularies. For example, a vocabulary called "Fruit" would contain the terms "Apple" and "Banana".') . '</p>'; return $output; case 'admin/structure/taxonomy/%': - $vocabulary = taxonomy_vocabulary_load($arg[3]); + $vocabulary = taxonomy_vocabulary_machine_name_load($arg[3]); switch ($vocabulary->hierarchy) { case 0: return '<p>' . t('You can reorganize the terms in %capital_name using their drag-and-drop handles, and group terms under a parent term by sliding them under and to the right of the parent.', array('%capital_name' => drupal_ucfirst($vocabulary->name), '%name' => $vocabulary->name)) . '</p>'; @@ -109,8 +109,8 @@ function taxonomy_entity_info() { $return['taxonomy_term']['bundles'][$machine_name] = array( 'label' => $vocabulary->name, 'admin' => array( - 'path' => 'admin/structure/taxonomy/%taxonomy_vocabulary', - 'real path' => 'admin/structure/taxonomy/' . $vocabulary->vid, + 'path' => 'admin/structure/taxonomy/%taxonomy_vocabulary_machine_name', + 'real path' => 'admin/structure/taxonomy/' . $machine_name, 'bundle argument' => 3, 'access arguments' => array('administer taxonomy'), ), @@ -302,7 +302,7 @@ function taxonomy_menu() { 'file' => 'taxonomy.pages.inc', ); - $items['admin/structure/taxonomy/%taxonomy_vocabulary'] = array( + $items['admin/structure/taxonomy/%taxonomy_vocabulary_machine_name'] = array( 'title callback' => 'taxonomy_admin_vocabulary_title_callback', 'title arguments' => array(3), 'page callback' => 'drupal_get_form', @@ -310,12 +310,12 @@ function taxonomy_menu() { 'access arguments' => array('administer taxonomy'), 'file' => 'taxonomy.admin.inc', ); - $items['admin/structure/taxonomy/%taxonomy_vocabulary/list'] = array( + $items['admin/structure/taxonomy/%taxonomy_vocabulary_machine_name/list'] = array( 'title' => 'List', 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -20, ); - $items['admin/structure/taxonomy/%taxonomy_vocabulary/edit'] = array( + $items['admin/structure/taxonomy/%taxonomy_vocabulary_machine_name/edit'] = array( 'title' => 'Edit', 'page callback' => 'drupal_get_form', 'page arguments' => array('taxonomy_form_vocabulary', 3), @@ -325,7 +325,7 @@ function taxonomy_menu() { 'file' => 'taxonomy.admin.inc', ); - $items['admin/structure/taxonomy/%taxonomy_vocabulary/add'] = array( + $items['admin/structure/taxonomy/%taxonomy_vocabulary_machine_name/add'] = array( 'title' => 'Add term', 'page callback' => 'drupal_get_form', 'page arguments' => array('taxonomy_form_term', array(), 3), @@ -975,6 +975,21 @@ function taxonomy_vocabulary_load($vid) { } /** + * Return the vocabulary object matching a vocabulary machine name. + * + * @param $name + * The vocabulary's machine name. + * + * @return + * The vocabulary object with all of its metadata, if exists, FALSE otherwise. + * Results are statically cached. + */ +function taxonomy_vocabulary_machine_name_load($name) { + $vocabularies = taxonomy_vocabulary_load_multiple(NULL, array('machine_name' => $name)); + return reset($vocabularies); +} + +/** * Return the term object matching a term ID. * * @param $tid diff --git a/modules/taxonomy/taxonomy.test b/modules/taxonomy/taxonomy.test index 5d809d16c..b27509b1f 100644 --- a/modules/taxonomy/taxonomy.test +++ b/modules/taxonomy/taxonomy.test @@ -163,7 +163,7 @@ class TaxonomyVocabularyFunctionalTest extends TaxonomyWebTestCase { // Delete the vocabulary. $edit = array(); - $this->drupalPost('admin/structure/taxonomy/' . $vid . '/edit', $edit, t('Delete')); + $this->drupalPost('admin/structure/taxonomy/' . $vocabulary->machine_name . '/edit', $edit, t('Delete')); $this->assertRaw(t('Are you sure you want to delete the vocabulary %name?', array('%name' => $vocabulary->name)), t('[confirm deletion] Asks for confirmation.')); $this->assertText(t('Deleting a vocabulary will delete all the terms in it. This action cannot be undone.'), t('[confirm deletion] Inform that all terms will be deleted.')); @@ -455,14 +455,14 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase { $edit['parent[]'] = array(0); // Create the term to edit. - $this->drupalPost('admin/structure/taxonomy/' . $this->vocabulary->vid . '/add', $edit, t('Save')); + $this->drupalPost('admin/structure/taxonomy/' . $this->vocabulary->machine_name . '/add', $edit, t('Save')); $terms = taxonomy_get_term_by_name($edit['name']); $term = reset($terms); $this->assertNotNull($term, t('Term found in database')); // Submitting a term takes us to the add page; we need the List page. - $this->drupalGet('admin/structure/taxonomy/' . $this->vocabulary->vid); + $this->drupalGet('admin/structure/taxonomy/' . $this->vocabulary->machine_name); // Test edit link as accessed from Taxonomy administration pages. // Because Simpletest creates its own database when running tests, we know @@ -516,7 +516,7 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase { // tabledrag.js by changing the page HTML source. Each term has three hidden // fields, "tid:1:0[tid]", "tid:1:0[parent]", and "tid:1:0[depth]". The // order of the input fields in the page is used when the form is processed. - $this->drupalGet('admin/structure/taxonomy/' . $this->vocabulary->vid); + $this->drupalGet('admin/structure/taxonomy/' . $this->vocabulary->machine_name); $reorder = array( 'tid:' . $term1->tid . ':0' => 'tid:' . $term2->tid . ':0', 'tid:' . $term2->tid . ':0' => 'tid:' . $term3->tid . ':0', @@ -546,7 +546,7 @@ class TaxonomyTermTestCase extends TaxonomyWebTestCase { $this->assertEqual($terms[1]->parents, array($term2->tid), t('Term 3 was made a child of term 2.')); $this->assertEqual($terms[2]->tid, $term1->tid, t('Term 1 was moved below term 2.')); - $this->drupalPost('admin/structure/taxonomy/' . $this->vocabulary->vid, array(), t('Reset to alphabetical')); + $this->drupalPost('admin/structure/taxonomy/' . $this->vocabulary->machine_name, array(), t('Reset to alphabetical')); // Submit confirmation form. $this->drupalPost(NULL, array(), t('Reset to alphabetical')); @@ -688,7 +688,7 @@ class TaxonomyHooksTestCase extends TaxonomyWebTestCase { 'name' => $this->randomName(), 'antonym' => 'Long', ); - $this->drupalPost('admin/structure/taxonomy/' . $vocabulary->vid . '/add', $edit, t('Save')); + $this->drupalPost('admin/structure/taxonomy/' . $vocabulary->machine_name . '/add', $edit, t('Save')); $terms = taxonomy_get_term_by_name($edit['name']); $term = reset($terms); $this->assertEqual($term->antonym, $edit['antonym'], t('Antonym was loaded into the term object')); |