function views_break_phrase_string in Views (for Drupal 7) 6.3
Same name and namespace in other branches
- 7.3 includes/handlers.inc \views_break_phrase_string()
2 calls to views_break_phrase_string()
- views_handler_argument_string::query in handlers/views_handler_argument_string.inc
- Build the query based upon the formula
- views_handler_argument_string::title in handlers/views_handler_argument_string.inc
- Get the title this argument will assign the view, given the argument.
File
- includes/handlers.inc, line 1035
- handlers.inc
Defines the various handler objects to help build and display views.
Code
function views_break_phrase_string($str, &$handler) {
if (!$handler) {
$handler = new stdClass();
}
if (!isset($handler->value)) {
$handler->value = array();
}
if (!isset($handler->operator)) {
$handler->operator = 'or';
}
if ($str == '') {
return $handler;
}
if (preg_match('/^(\\w+[+ ])+\\w+$/', $str)) {
$handler->operator = 'or';
$handler->value = preg_split('/[+ ]/', $str);
}
else {
if (preg_match('/^((\\w|\\s)+,)*(\\w|\\s)+$/', $str)) {
$handler->operator = 'and';
$handler->value = explode(',', $str);
}
}
if (!empty($str) && (empty($handler->value) || !is_array($handler->value))) {
$handler->value = array(
-1,
);
return $handler;
}
foreach ($handler->value as $id => $value) {
$handler->value[$id] = (string) $value;
}
return $handler;
}