diff -ru taxonomy_browser/taxonomy_browser.module joy1/modules/taxonomy_browser/taxonomy_browser.module --- taxonomy_browser/taxonomy_browser.module 2008-08-14 07:27:30.000000000 -0700 +++ joy1/modules/taxonomy_browser/taxonomy_browser.module 2009-07-06 15:30:05.000000000 -0700 @@ -365,23 +365,27 @@ $node_type_list = implode(', ', $voc_node_types); } - $tree = taxonomy_get_tree($v); - $term_opts = array(); - - if ($tree) { - foreach ($tree as $term) { - $opt_string = NULL; - if ($count_nodes) { - $count = taxonomy_term_count_nodes($term->tid); - if ($count > 0 || $show_unused) { - $opt_string = decode_entities(check_plain($term->name)) .' ('. $count .')'; + // tagging vocabularies are displayed as autocomplete boxes, so no need + // to figure out the tree. + if (!$voc->tags) { + $tree = taxonomy_get_tree($v); + $term_opts = array(); + + if ($tree) { + foreach ($tree as $term) { + $opt_string = NULL; + if ($count_nodes) { + $count = taxonomy_term_count_nodes($term->tid); + if ($count > 0 || $show_unused) { + $opt_string = decode_entities(check_plain($term->name)) .' ('. $count .')'; + } + } + else { + $opt_string = decode_entities(check_plain($term->name)); + } + if ($opt_string) { + $term_opts[$term->tid] = str_repeat('-', $term->depth) . $opt_string; } - } - else { - $opt_string = decode_entities(check_plain($term->name)); - } - if ($opt_string) { - $term_opts[$term->tid] = str_repeat('-', $term->depth) . $opt_string; } } } @@ -391,8 +395,18 @@ if (variable_get('taxonomy_browser_show_types', FALSE)) { $description .= t('"!name" is used for: !types.', array('!name' => ''. $vocname .'', '!types' => (empty($node_type_list) ? ''. t('nothing') .'' : $node_type_list))); } - - if (!empty($term_opts)) { + + if ($voc->tags) { + # this code inspired by taxonomy_form_alter() + $form['taxonomy']['tags'][$voc->vid] = array('#type' => 'textfield', + '#title' => $voc->name, + '#description' => $description, + '#default_value' => '', + '#autocomplete_path' => 'taxonomy/autocomplete/'. $voc->vid, + '#weight' => $voc->weight, + '#maxlength' => 1024, + ); + } elseif (!empty($term_opts)) { $voc_element = array( '#type' => $select_type, '#title' => $vocname, @@ -588,7 +602,29 @@ if (isset($tids) && is_array($tids)) { $tid_list = array(); foreach ($tids as $key => $tid) { - if (!empty($tid)) { + if ($key == 'tags') { + // $tid is a vid -> termstring array + // this code inspired by taxonomy_node_save() + foreach ($tid as $vid => $typed_string) { + $typed_terms = drupal_explode_tags($typed_string); + foreach ($typed_terms as $typed_term) { + // if the term exists in this vocab, save the tid. otherwise, post an error. + $possibilities = taxonomy_get_term_by_name($typed_term); + $typed_term_tid = NULL; + foreach ($possibilities as $possibility) { + if ($possibility->vid == $vid) { + $typed_term_tid = $possibility->tid; + } + } + + if ($typed_term_tid) { + $tid_list[$typed_term_tid] = $typed_term_tid; + } else { + drupal_set_message(t('The term %term was not found.', array('%term' => $typed_term)), 'warning'); + } + } + } + } elseif (!empty($tid)) { if (is_array($tid)) { foreach ($tid as $key2 => $tid2) { if (!empty($tid2)) {