Index: modules/taxonomy.module =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy.module,v retrieving revision 1.180 diff -u -F^f -r1.180 taxonomy.module --- modules/taxonomy.module 3 Mar 2005 19:18:19 -0000 1.180 +++ modules/taxonomy.module 3 Mar 2005 19:46:51 -0000 @@ -175,9 +175,10 @@ function _taxonomy_confirm_del_vocabular $form .= form_hidden('confirm', 1); $form .= form_hidden('type', 'vocabulary'); $form .= form_hidden('vid', $vid); + $form .= '
'. t('Are you sure you want to delete the vocabulary %vocab and all its terms?', array('%vocab' => ''. $vocabulary->name .'')) .'
'; $form .= form_submit(t('Delete')); - return form(form_item(t('Delete vocabulary "%name"', array('%name' => $vocabulary->name)), $form, t('Are you sure you want to delete the vocabulary and all its terms?'))); + return form($form); } function taxonomy_form_term($edit = array()) { @@ -255,16 +256,20 @@ function taxonomy_save_term($edit) { db_query('DELETE FROM {term_hierarchy} WHERE tid = %d', $edit['tid']); if (!isset($edit['parent'])) { - $edit['parent'] = 0; + $edit['parent'] = array(0); } if (is_array($edit['parent'])) { foreach ($edit['parent'] as $parent) { - db_query('INSERT INTO {term_hierarchy} (tid, parent) VALUES (%d, %d)', $edit['tid'], $parent); + if (is_array($parent)) { + foreach ($parent as $tid) { + db_query('INSERT INTO {term_hierarchy} (tid, parent) VALUES (%d, %d)', $edit['tid'], $tid); + } + } + else { + db_query('INSERT INTO {term_hierarchy} (tid, parent) VALUES (%d, %d)', $edit['tid'], $parent); + } } } - else { - db_query('INSERT INTO {term_hierarchy} (tid, parent) VALUES (%d, %d)', $edit['tid'], $edit['parent'][0]); - } db_query('DELETE FROM {term_synonym} WHERE tid = %d', $edit['tid']); if ($edit['synonyms']) { @@ -306,7 +311,7 @@ function taxonomy_del_term($tid) { db_query('DELETE FROM {term_node} WHERE tid = %d', $tid); module_invoke_all('taxonomy', 'delete', 'term', $term); - drupal_set_message(t('Deleted term "%name".', array('%name' => $term->name))); + drupal_set_message(t('Deleted term %name.', array('%name' => ''. $term->name .''))); } $tids = $orphans; @@ -318,14 +323,13 @@ function taxonomy_del_term($tid) { function _taxonomy_confirm_del_term($tid) { $term = taxonomy_get_term($tid); + $form = ''. t('Are you sure you want to delete the term %term and all its children (if any)?', array('%term' => ''. $term->name .'')) .'
'; $form .= form_hidden('confirm', 1); $form .= form_hidden('type', 'term'); $form .= form_hidden('tid', $tid); $form .= form_submit(t('Delete')); - $output = form(form_item(t('Delete term "%name" and all its children', array('%name' => $term->name)), $form, t('Are you sure you want to delete the term and all its children (if any)?'))); - - return $output; + return form($form); } /** @@ -482,8 +486,15 @@ function taxonomy_node_get_terms($nid, $ function taxonomy_node_save($nid, $terms) { taxonomy_node_delete($nid); - if ($terms) { + if (is_array($terms)) { foreach ($terms as $term) { + if (is_array($term)) { + foreach ($term as $tid) { + if ($tid) { + db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $nid, $tid); + } + } + } if ($term) { db_query('INSERT INTO {term_node} (nid, tid) VALUES (%d, %d)', $nid, $term); } @@ -732,13 +743,15 @@ function taxonomy_get_term($tid) { function _taxonomy_term_select($title, $name, $value, $vocabulary_id, $description, $multiple, $blank, $exclude = array()) { $tree = taxonomy_get_tree($vocabulary_id); + $options = array(); + if ($blank) { - $options[] = array('tid' => 0, 'name' => $blank); + $options[0] = $blank; } if ($tree) { foreach ($tree as $term) { if (!in_array($term->tid, $exclude)) { - $options[] = array('tid' => $term->tid, 'name' => _taxonomy_depth($term->depth, '-').$term->name); + $options[$term->tid] = _taxonomy_depth($term->depth, '-') . $term->name; } } if (!$blank && !$value) { @@ -747,15 +760,7 @@ function _taxonomy_term_select($title, $ } } - if (count($options) > 0) { - foreach ($options as $option) { - $select .= ''; - } - - $size = min(12, count($options)); - - return form_item($title, "", $description, NULL, false, _form_get_error($name)); - } + return form_select($title, $name .'][', $value, $options, $description, $multiple ? 'size="'. min(12, count($options)) .'"' : 0, $multiple); } function _taxonomy_depth($depth, $graphic = '--') {