function views_handler_filter_term_node_tid::validate_term_strings in Views (for Drupal 7) 6.2
Same name and namespace in other branches
- 6.3 modules/taxonomy/views_handler_filter_term_node_tid.inc \views_handler_filter_term_node_tid::validate_term_strings()
- 7.3 modules/taxonomy/views_handler_filter_term_node_tid.inc \views_handler_filter_term_node_tid::validate_term_strings()
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.
2 calls to views_handler_filter_term_node_tid::validate_term_strings()
- views_handler_filter_term_node_tid::exposed_validate in modules/
taxonomy/ views_handler_filter_term_node_tid.inc - Validate the exposed filter form
- views_handler_filter_term_node_tid::value_validate in modules/
taxonomy/ views_handler_filter_term_node_tid.inc - Validate the options form.
File
- modules/
taxonomy/ views_handler_filter_term_node_tid.inc, line 243
Class
- views_handler_filter_term_node_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;
$args[] = $value;
$placeholders[] = "'%s'";
}
if (!$args) {
return;
}
// add the taxonomy vid to the argument list.
$args[] = $this->options['vid'];
$result = db_query(db_rewrite_sql("SELECT t.* FROM {term_data} t WHERE t.name IN (" . implode(', ', $placeholders) . ") AND t.vid = %d", 't', 'tid', $args), $args);
while ($term = db_fetch_object($result)) {
unset($missing[strtolower($term->name)]);
$tids[] = $term->tid;
}
if ($missing) {
form_error($form, format_plural(count($missing), 'Unable to find term: @terms', 'Unable to find terms: @terms', array(
'@terms' => implode(', ', array_keys($missing)),
)));
}
return $tids;
}