function taxonomy_manager_form_submit in Taxonomy Manager 7
Same name and namespace in other branches
- 5 taxonomy_manager.module \taxonomy_manager_form_submit()
- 6.2 taxonomy_manager.admin.inc \taxonomy_manager_form_submit()
- 6 taxonomy_manager.admin.inc \taxonomy_manager_form_submit()
submits the taxonomy manager form (only search button)
1 call to taxonomy_manager_form_submit()
- taxonomy_manager_double_tree_form_submit in ./
taxonomy_manager.admin.inc - submits the taxonomy manager double tree
File
- ./
taxonomy_manager.admin.inc, line 1239
Code
function taxonomy_manager_form_submit($form, &$form_state) {
if ($form_state['values']['delete'] === TRUE) {
return taxonomy_manager_term_confirm_delete_submit($form, $form_state);
}
$voc = $form_state['values']['voc'];
if (isset($form_state['values']['voc2'])) {
$voc2 = $form_state['values']['voc2'];
$url_prefix = 'admin/structure/taxonomy_manager/double-tree/' . $voc->machine_name . '/' . $voc2->machine_name;
}
else {
$url_prefix = 'admin/structure/taxonomy_manager/voc/' . $voc->machine_name;
}
$search_string = $form_state['values']['search']['field'];
$terms = array();
$include_synonyms = FALSE;
$selected_tids = array();
$language = "";
// @todo
/*if ($form_state['values']['search']['options']['synonyms']) {
$include_synonyms = TRUE;
}*/
if ($form_state['values']['search']['options']['subtrees']) {
$selected_tids = $form_state['values']['taxonomy']['manager']['tree']['selected_terms'];
}
if (isset($form_state['values']['search']['options']['language'])) {
$language = $form_state['values']['taxonomy']['manager']['top']['language'];
}
$terms = taxonomy_manager_autocomplete_search_terms($search_string, $voc->vid, $include_synonyms, $selected_tids, $language);
if (count($terms) == 1) {
$tid = $terms[0];
drupal_set_message(t("Your search string matches exactly one term"));
drupal_goto($url_prefix . '/' . $tid);
}
elseif (count($terms) > 1) {
$matched_text_list = array();
foreach ($terms as $matched_tid) {
$matched_term = taxonomy_term_load($matched_tid);
$parents = array();
foreach (taxonomy_get_parents($matched_tid) as $parent) {
$parents[] = check_plain($parent->name);
}
$parent_text = count($parents) ? implode(' | ', $parents) . " › " : "";
$matched_text_list[] = $parent_text . l($matched_term->name, $url_prefix . '/' . $matched_term->tid, array(
'attributes' => array(
'title' => taxonomy_manager_tree_term_extra_info($matched_term),
),
)) . " (" . $matched_term->tid . (!empty($matched_term->language) ? '-' . check_plain($matched_term->language) : '') . ")";
}
form_set_value($form, array(
'searched_terms' => $terms,
), $form_state);
drupal_set_message(t("Your search string matches !count terms:", array(
'!count' => count($terms),
)) . theme('item_list', array(
'items' => $matched_text_list,
)));
$form_state['rebuild'] = TRUE;
}
else {
drupal_set_message(t("No match found. Filtering root level terms starting with @search_string.", array(
'@search_string' => $search_string,
)));
drupal_set_message(l(t("Show unfiltered tree"), $url_prefix));
drupal_goto($url_prefix . '/0/' . $search_string);
}
}