You are here

function taxonomy_manager_form_merge_validate in Taxonomy Manager 6

Same name and namespace in other branches
  1. 6.2 taxonomy_manager.admin.inc \taxonomy_manager_form_merge_validate()

Validation handler for validating terms

1 string reference to 'taxonomy_manager_form_merge_validate'
taxonomy_manager_merge_form in ./taxonomy_manager.admin.inc
form for merging terms

File

./taxonomy_manager.admin.inc, line 924

Code

function taxonomy_manager_form_merge_validate($form, &$form_state) {
  $selected_tids = array();
  $selected_tids = $form_state['values']['taxonomy']['manager']['tree']['selected_terms'];
  $main_terms = array();
  $regexp = '%(?:^|,\\ *)("(?>[^"]*)(?>""[^"]* )*"|(?: [^",]*))%x';
  preg_match_all($regexp, $form_state['values']['merge']['main_term'], $matches);
  $main_terms = $matches[1];
  if (!is_array($main_terms) || count($main_terms) == 0 || empty($main_terms[0])) {
    form_set_error('merge][main_term', t("Please enter a name into %title", array(
      '%title' => "'" . t('Main term') . "'",
    )));
    $form_state['rebuild'] = TRUE;
  }
  else {
    if (count($main_terms) > 1) {
      form_set_error('merge][main_term', t("Please only enter single names into %title", array(
        '%title' => "'" . t('Main term') . "'",
      )));
      $form_state['rebuild'] = TRUE;
    }
  }
  if (count($selected_tids) < 1) {
    form_set_error('merge', t("Please selected terms you want to merge"));
    $form_state['rebuild'] = TRUE;
  }
  else {
    if (count($selected_tids) > 50) {
      form_set_error('merge', t("Please select less than 50 terms to merge. Merging to many terms in one step can cause timeouts and inconsistent database states"));
      $form_state['rebuild'] = TRUE;
    }
  }
}