You are here

function _taxonomy_manager_check_duplicates in Taxonomy Manager 7

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

returns TRUE if term with same name exists more often

3 calls to _taxonomy_manager_check_duplicates()
taxonomy_manager_form_move_validate in ./taxonomy_manager.admin.inc
Validation handler for moving terms
taxonomy_manager_form_term_merge_validate in ./taxonomy_manager.admin.inc
Validation handler for validating terms
taxonomy_manager_term_data_form_validate_parents_add in ./taxonomy_manager.admin.inc

File

./taxonomy_manager.admin.inc, line 1692

Code

function _taxonomy_manager_check_duplicates($vid, $autocomplete_value, &$msg) {
  $regexp = '%(?:^|,\\ *)("(?>[^"]*)(?>""[^"]* )*"|(?: [^",]*))%x';
  preg_match_all($regexp, $autocomplete_value, $matches);
  foreach ($matches[1] as $match) {
    $terms = array();
    $terms = taxonomy_manager_autocomplete_tags_get_tids($match, $vid, FALSE);
    if (count($terms) > 1) {
      $tids = array();
      foreach ($terms as $t) {
        $term = taxonomy_term_load($t['tid']);
        $tids[] = $term->tid . (!empty($term->language) ? '-' . check_plain($term->language) : '');
      }
      $msg .= check_plain($match) . ": " . implode(", ", $tids);
      return TRUE;
    }
  }
  return FALSE;
}