function i18nviews_handler_filter_taxonomy_index_tid::validate_term_strings in Internationalization Views 7.3
Validate the user string. Since this can come from either the form or the exposed filter, this is abstracted out a bit so it can handle the multiple input sources.
Overrides views_handler_filter_term_node_tid::validate_term_strings
File
- includes/
i18nviews_handler_filter_taxonomy_index_tid.inc, line 127
Class
- i18nviews_handler_filter_taxonomy_index_tid
- Filter by term id.
Code
function validate_term_strings(&$form, $values) {
if (empty($values)) {
return array();
}
$tids = array();
$placeholders = array();
$args = array();
$results = array();
foreach ($values as $value) {
$missing[strtolower($value)] = TRUE;
$names[] = $value;
}
if (!$names) {
return;
}
$query = db_select('taxonomy_term_data', 'td');
$query
->innerJoin('taxonomy_vocabulary', 'tv', 'td.vid = tv.vid');
$query
->fields('td');
$query
->condition('td.name', $names);
$query
->condition('tv.machine_name', $this->options['vocabulary']);
$query
->addTag('term_access');
$result = $query
->execute();
foreach ($result as $term) {
unset($missing[strtolower(i18n_taxonomy_term_name($term->name))]);
$tids[] = $term->tid;
}
if ($missing && !empty($this->options['error_message'])) {
form_error($form, format_plural(count($missing), 'Unable to find term: @terms', 'Unable to find terms: @terms', array(
'@terms' => implode(', ', array_keys($missing)),
)));
}
elseif ($missing && empty($this->options['error_message'])) {
$tids = array(
0,
);
}
return $tids;
}