/** * Return the term object matching a term ID. */ function taxonomy_get_term($tid) { // simple cache using a static var? 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()) { $tree = taxonomy_get_tree($vocabulary_id); $options = array(); drupal_set_message("post -> " . var_export($_POST, true)); if ($blank) { $options[0] = $blank; } if ($tree) { foreach ($tree as $term) { if (!in_array($term->tid, $exclude)) { $options[$term->tid] = _taxonomy_depth($term->depth, '-') . $term->name; } } if (!$blank && !$value) { // required but without a predefined value, so set first as predefined $value = $tree[0]->tid; } } // appear as checkboxes for multiple select hack (jordan willms 2005) //drupal_set_message(var_export($options,true)); if ($multiple) { $rev = array_reverse($options,true); array_pop($rev); $options = array_reverse($rev, true); drupal_set_message(var_export($value, true)); return form_checkboxes($title, $name . ($multiple ? '' : ']['), $value, $options, $description, NULL, TRUE); } else { return form_select($title, $name . ($multiple ? '' : ']['), $value, $options, $description, $multiple ? 'size="'. min(12, count($options)) .'"' : 0, $multiple); } }