function views_break_phrase

3.x handlers.inc views_break_phrase($str, &$handler = NULL)
2.x handlers.inc views_break_phrase($str, &$filter)
7 calls to views_break_phrase()
views_handler_argument_many_to_one::query in handlers/views_handler_argument_many_to_one.inc
Set up the query for this argument.
views_handler_argument_many_to_one::title in handlers/views_handler_argument_many_to_one.inc
Get the title this argument will assign the view, given the argument.
views_handler_argument_numeric::query in handlers/views_handler_argument_numeric.inc
Set up the query for this argument.
views_handler_argument_numeric::title in handlers/views_handler_argument_numeric.inc
Get the title this argument will assign the view, given the argument.
views_handler_argument_term_node_tid_depth::query in modules/taxonomy/views_handler_argument_term_node_tid_depth.inc
Set up the query for this argument.

... See full list

File

includes/handlers.inc, line 787
handlers.inc Defines the various handler objects to help build and display views.

Code

function views_break_phrase($str, &$filter) {
  if (!$filter) {
    $filter = new stdClass();
  }

  // Set up defaults:
  if (!isset($filter->value)) {
    $filter->value = array();
  }

  if (!isset($filter->operator)) {
    $filter->operator = 'or';
  }

  if ($str == '') {
    return $filter;
  }

  if (preg_match('/^([0-9]+[+ ])+[0-9]+$/', $str)) {
    // The '+' character in a query string may be parsed as ' '.
    $filter->operator = 'or';
    $filter->value = preg_split('/[+ ]/', $str);
  }
  else if (preg_match('/^([0-9]+,)*[0-9]+$/', $str)) {
    $filter->operator = 'and';
    $filter->value = explode(',', $str);
  }

  // Keep an 'error' value if invalid strings were given.
  if (!empty($str) && (empty($filter->value) || !is_array($filter->value))) {
    $filter->value = array(-1);
    return $filter;
  }

  // Doubly ensure that all values are numeric only.
  foreach ($filter->value as $id => $value) {
    $filter->value[$id] = intval($value);
  }

  return $filter;
}