Commit cca8e7e5 authored by Dries's avatar Dries

- Patch #744258 by sun: admin/structure/taxonomy paths have to use machine_name(), not vid.

parent cfe7f8e6
......@@ -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.'));
}
......
......@@ -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'));
......
......@@ -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]']);
......
......@@ -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'];
}
......@@ -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),
......@@ -974,6 +974,21 @@ function taxonomy_vocabulary_load($vid) {
return reset($vocabularies);
}
/**
* 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.
*
......
......@@ -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'));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment