diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module index c0e4bc48cf6..467290908cc 100644 --- a/modules/taxonomy/taxonomy.module +++ b/modules/taxonomy/taxonomy.module @@ -75,7 +75,8 @@ function taxonomy_menu($may_cache) { $items[] = array('path' => 'admin/content/taxonomy/add/vocabulary', 'title' => t('add vocabulary'), - 'callback' => 'taxonomy_admin_vocabulary_edit', + 'callback' => 'drupal_get_form', + 'callback arguments' => array('taxonomy_form_vocabulary'), 'access' => user_access('administer taxonomy'), 'type' => MENU_LOCAL_TASK); @@ -105,22 +106,23 @@ function taxonomy_menu($may_cache) { } else { if (is_numeric(arg(3))) { - $items[] = array('path' => 'admin/content/taxonomy/' . arg(3), + $vid = arg(3); + $items[] = array('path' => 'admin/content/taxonomy/'. $vid, 'title' => t('list terms'), 'callback' => 'taxonomy_overview_terms', - 'callback arguments' => array(arg(3)), + 'callback arguments' => array($vid), 'access' => user_access('administer taxonomy'), 'type' => MENU_CALLBACK); - $items[] = array('path' => 'admin/content/taxonomy/' . arg(3) . '/list', + $items[] = array('path' => 'admin/content/taxonomy/'. $vid .'/list', 'title' => t('list'), 'type' => MENU_DEFAULT_LOCAL_TASK, 'weight' => -10); - $items[] = array('path' => 'admin/content/taxonomy/' . arg(3) . '/add/term', + $items[] = array('path' => 'admin/content/taxonomy/'. $vid .'/add/term', 'title' => t('add term'), - 'callback' => 'taxonomy_form_term', - 'callback arguments' => array(array('vid' => arg(3))), + 'callback' => 'drupal_get_form', + 'callback arguments' => array('taxonomy_form_term', $vid), 'access' => user_access('administer taxonomy'), 'type' => MENU_LOCAL_TASK); } @@ -165,6 +167,9 @@ function taxonomy_overview_terms($vid) { $header = array(t('Name'), t('Operations')); $vocabulary = taxonomy_get_vocabulary($vid); + if (!$vocabulary) { + return drupal_not_found(); + } drupal_set_title(check_plain($vocabulary->name)); $start_from = $_GET['page'] ? $_GET['page'] : 0; @@ -336,7 +341,8 @@ function taxonomy_vocabulary_confirm_delete($vid) { return confirm_form($form, t('Are you sure you want to delete the vocabulary %title?', array('%title' => $vocabulary->name)), - 'admin/content/taxonomy', t('Deleting a vocabulary will delete all the terms in it. This action cannot be undone.'), + 'admin/content/taxonomy', + t('Deleting a vocabulary will delete all the terms in it. This action cannot be undone.'), t('Delete'), t('Cancel')); } @@ -347,8 +353,7 @@ function taxonomy_vocabulary_confirm_delete_submit($form_id, $form_values) { return 'admin/content/taxonomy'; } -function taxonomy_form_term($edit = array()) { - $vocabulary_id = isset($edit['vid']) ? $edit['vid'] : arg(4); +function taxonomy_form_term($vocabulary_id, $edit = array()) { $vocabulary = taxonomy_get_vocabulary($vocabulary_id); $form['name'] = array('#type' => 'textfield', '#title' => t('Term name'), '#default_value' => $edit['name'], '#maxlength' => 64, '#description' => t('The name for this term. Example: "Linux".'), '#required' => TRUE); @@ -1276,29 +1281,29 @@ function taxonomy_term_page($str_tids = '', $depth = 0, $op = 'page') { } /** - * Page to add or edit a vocabulary + * Page to edit a vocabulary */ function taxonomy_admin_vocabulary_edit($vid = NULL) { if ($_POST['op'] == t('Delete') || $_POST['edit']['confirm']) { - return taxonomy_vocabulary_confirm_delete($vid); + return drupal_get_form('taxonomy_vocabulary_confirm_delete', $vid); } - elseif ($vid) { - $vocabulary = (array)taxonomy_get_vocabulary($vid); + if ($vocabulary = (array)taxonomy_get_vocabulary($vid)) { + return drupal_get_form('taxonomy_form_vocabulary', $vocabulary); } - return drupal_get_form('taxonomy_form_vocabulary', $vocabulary); + return drupal_not_found(); } /** - * Page to list terms for a vocabulary + * Page to edit a vocabulary term */ -function taxonomy_admin_term_edit($tid = NULL) { +function taxonomy_admin_term_edit($tid) { if ($_POST['op'] == t('Delete') || $_POST['edit']['confirm']) { - return taxonomy_term_confirm_delete($tid); + return drupal_get_form('taxonomy_term_confirm_delete', $tid); } - elseif ($tid) { - $term = (array)taxonomy_get_term($tid); + if ($term = (array)taxonomy_get_term($tid)) { + return drupal_get_form('taxonomy_form_term', $term->vid, $term); } - return taxonomy_form_term($term); + return drupal_not_found(); } /**