summaryrefslogtreecommitdiff
path: root/modules/taxonomy/taxonomy.module
diff options
context:
space:
mode:
authorNeil Drumm <drumm@3064.no-reply.drupal.org>2006-08-24 05:43:38 +0000
committerNeil Drumm <drumm@3064.no-reply.drupal.org>2006-08-24 05:43:38 +0000
commit153fbc7839f70ff5d8deb4d3379ae007f494e973 (patch)
tree249100e25e595e86a8fd2bb7b9e30c1bdb01c1a4 /modules/taxonomy/taxonomy.module
parent849a10fbbab9abb2858bd5c2e080f926adb063db (diff)
downloadbrdo-153fbc7839f70ff5d8deb4d3379ae007f494e973.tar.gz
brdo-153fbc7839f70ff5d8deb4d3379ae007f494e973.tar.bz2
#79732 by drewish, fix the taxonomy forms and some code cleanup.
Diffstat (limited to 'modules/taxonomy/taxonomy.module')
-rw-r--r--modules/taxonomy/taxonomy.module47
1 files changed, 26 insertions, 21 deletions
diff --git a/modules/taxonomy/taxonomy.module b/modules/taxonomy/taxonomy.module
index c0e4bc48c..467290908 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();
}
/**