You are here

public static function apachesolr_views_query::escape_term in Apache Solr Views 6

Escapes a term for passing it to the query.

4 calls to apachesolr_views_query::escape_term()
apachesolr_views_handler_argument::query in handlers/apachesolr_views_handler_argument.inc
Add argument to query.
apachesolr_views_handler_argument_optionwidget::query in handlers/apachesolr_views_handler_argument_optionwidget.inc
Override query() and do some fancy manipulation of the argument so that it is boiled down to the actual field value instead of the nice title
apachesolr_views_handler_filter_author::query in handlers/apachesolr_views_handler_filter_author.inc
apachesolr_views_handler_filter_type::query in handlers/apachesolr_views_handler_filter_type.inc

File

./apachesolr_views_query.inc, line 819

Class

apachesolr_views_query
Class for handling a view that gets its data not from the database, but from a Solr server.

Code

public static function escape_term($term) {
  $term = trim($term);
  if (empty($term)) {
    return '';
  }
  if ($term[0] == '"' && $term[strlen($term) - 1] == '"' || $term[0] == '(' && $term[strlen($term) - 1] == ')') {
    return $term;
  }
  if (strpos($term, ' TO ') !== FALSE) {
    return $term;
  }
  if (strpos($term, ' ') !== FALSE) {
    return Drupal_Apache_Solr_Service::phrase($term);
  }
  return Drupal_Apache_Solr_Service::escape($term);
}