--- modules/taxonomy.module.orig Wed Nov 08 20:20:24 2006 +++ modules/taxonomy.module Wed Nov 08 20:20:45 2006 @@ -364,15 +364,15 @@ $exclude[] = $edit['tid']; if ($vocabulary->hierarchy == 1) { - $form['parent'] = _taxonomy_term_select(t('Parent'), 'parent', $parent, $vocabulary_id, l(t('Parent term'), 'admin/help/taxonomy', NULL, NULL, 'parent') .'.', 0, '<'. t('root') .'>', $exclude); + $form['parent'] = theme('taxonomy_term_select', t('Parent'), 'parent', $parent, $vocabulary_id, l(t('Parent term'), 'admin/help/taxonomy', NULL, NULL, 'parent') .'.', 0, '<'. t('root') .'>', $exclude); } elseif ($vocabulary->hierarchy == 2) { - $form['parent'] = _taxonomy_term_select(t('Parents'), 'parent', $parent, $vocabulary_id, l(t('Parent terms'), 'admin/help/taxonomy', NULL, NULL, 'parent') .'.', 1, '<'. t('root') .'>', $exclude); + $form['parent'] = theme('taxonomy_term_select', t('Parents'), 'parent', $parent, $vocabulary_id, l(t('Parent terms'), 'admin/help/taxonomy', NULL, NULL, 'parent') .'.', 1, '<'. t('root') .'>', $exclude); } } if ($vocabulary->relations) { - $form['relations'] = _taxonomy_term_select(t('Related terms'), 'relations', array_keys(taxonomy_get_related($edit['tid'])), $vocabulary_id, NULL, 1, '<'. t('none') .'>', array($edit['tid'])); + $form['relations'] = theme('taxonomy_term_select', t('Related terms'), 'relations', array_keys(taxonomy_get_related($edit['tid'])), $vocabulary_id, NULL, 1, '<'. t('none') .'>', array($edit['tid'])); } $form['synonyms'] = array('#type' => 'textarea', '#title' => t('Synonyms'), '#default_value' => implode("\n", taxonomy_get_synonyms($edit['tid'])), '#description' => t('Synonyms of this term, one synonym per line.', array('%help-url' => url('admin/help/taxonomy', NULL, NULL, 'synonyms')))); @@ -533,9 +533,21 @@ } /** - * Generate a form element for selecting terms from a vocabulary. + * + * @param $vid + * Vocabulary id. + * @param $value + * The currently selected value. + * @param $help + * The description of what this vocabulary represents. If NULL, the value is + * taken from the vocabulary itself ($vocabulary->help). + * @param $name + * The name parameter of the form item being built. Set this if you want to use + * the vocabulary list to set fields other than taxonomy. + * @param $title + * The label on the form item. If left NULL, it will default to the vocabulary name. */ -function taxonomy_form($vid, $value = 0, $help = NULL, $name = 'taxonomy') { +function taxonomy_form($vid, $value = 0, $help = NULL, $name = 'taxonomy', $title = NULL) { $vocabulary = taxonomy_get_vocabulary($vid); $help = ($help) ? $help : $vocabulary->help; if ($vocabulary->required) { @@ -544,8 +556,10 @@ else { $blank = '<'. t('none') .'>'; } - - return _taxonomy_term_select(check_plain($vocabulary->name), $name, $value, $vid, $help, intval($vocabulary->multiple), $blank); + if (is_null($title)) { + $title = $vocabulary->name; + } + return theme('taxonomy_term_select', check_plain($title), $name, $value, $vid, $help, intval($vocabulary->multiple), $blank); } /** @@ -1031,7 +1045,30 @@ return db_fetch_object(db_query('SELECT * FROM {term_data} WHERE tid = %d', $tid)); } -function _taxonomy_term_select($title, $name, $value, $vocabulary_id, $description, $multiple, $blank, $exclude = array()) { +/** + * Theme a form element for selecting terms from a vocabulary. + * + * @param $title + * The label on the form item. If left NULL, it will default to the vocabulary name. + * @param $name + * The name parameter of the form item being built. Set this if you want to use + * the vocabulary list to set fields other than taxonomy. + * @param $value + * The currently selected value. + * @param $vid + * Vocabulary id. + * @param $description + * The description of what this vocabulary represents. If NULL, the value is + * taken from the vocabulary itself ($vocabulary->help). + * @param $multiple + * Can multiple terms be selected? + * @param $blank + * If this form element is not required, the $blank element will be the first + * in the list. + * @param $exclude + * an array of term ids that shouldn't appear in the list. + */ +function theme_taxonomy_term_select($title, $name, $value, $vocabulary_id, $description, $multiple, $blank, $exclude = array()) { $tree = taxonomy_get_tree($vocabulary_id); $options = array();