summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.18/sites/all/modules/views/handlers/views_handler_filter_combine.inc
diff options
context:
space:
mode:
Diffstat (limited to 'kolab.org/www/drupal-7.18/sites/all/modules/views/handlers/views_handler_filter_combine.inc')
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/views/handlers/views_handler_filter_combine.inc51
1 files changed, 42 insertions, 9 deletions
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/views/handlers/views_handler_filter_combine.inc b/kolab.org/www/drupal-7.18/sites/all/modules/views/handlers/views_handler_filter_combine.inc
index c9def53..915924b 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/views/handlers/views_handler_filter_combine.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/views/handlers/views_handler_filter_combine.inc
@@ -14,7 +14,7 @@ class views_handler_filter_combine extends views_handler_filter_string {
/**
* @var views_plugin_query_default
*/
- var $query;
+ public $query;
function option_definition() {
$options = parent::option_definition();
@@ -27,7 +27,7 @@ class views_handler_filter_combine extends views_handler_filter_string {
parent::options_form($form, $form_state);
$this->view->init_style();
- // Allow to choose all fields as possible
+ // Allow to choose all fields as possible.
if ($this->view->style_plugin->uses_fields()) {
$options = array();
foreach ($this->view->display_handler->get_handlers('field') as $name => $field) {
@@ -55,7 +55,8 @@ class views_handler_filter_combine extends views_handler_filter_string {
// Only add the fields if they have a proper field and table alias.
foreach ($this->options['fields'] as $id) {
$field = $this->view->field[$id];
- // Always add the table of the selected fields to be sure a table alias exists.
+ // Always add the table of the selected fields to be sure a table alias
+ // exists.
$field->ensure_my_table();
if (!empty($field->field_alias) && !empty($field->field_alias)) {
$fields[] = "$field->table_alias.$field->real_field";
@@ -63,14 +64,14 @@ class views_handler_filter_combine extends views_handler_filter_string {
}
if ($fields) {
$count = count($fields);
- $seperated_fields = array();
+ $separated_fields = array();
foreach ($fields as $key => $field) {
- $seperated_fields[] = $field;
- if ($key < $count-1) {
- $seperated_fields[] = "' '";
+ $separated_fields[] = $field;
+ if ($key < $count - 1) {
+ $separated_fields[] = "' '";
}
}
- $expression = implode(', ', $seperated_fields);
+ $expression = implode(', ', $separated_fields);
$expression = "CONCAT_WS(' ', $expression)";
$info = $this->operators();
@@ -82,7 +83,6 @@ class views_handler_filter_combine extends views_handler_filter_string {
// By default things like op_equal uses add_where, that doesn't support
// complex expressions, so override all operators.
-
function op_equal($field) {
$placeholder = $this->placeholder();
$operator = $this->operator();
@@ -94,6 +94,39 @@ class views_handler_filter_combine extends views_handler_filter_string {
$this->query->add_where_expression($this->options['group'], "$field LIKE $placeholder", array($placeholder => '%' . db_like($this->value) . '%'));
}
+ function op_word($field) {
+ $where = $this->operator == 'word' ? db_or() : db_and();
+
+ // Don't filter on empty strings.
+ if (empty($this->value)) {
+ return;
+ }
+
+ preg_match_all('/ (-?)("[^"]+"|[^" ]+)/i', ' ' . $this->value, $matches, PREG_SET_ORDER);
+ foreach ($matches as $match) {
+ $phrase = FALSE;
+ // Strip off phrase quotes.
+ if ($match[2]{0} == '"') {
+ $match[2] = substr($match[2], 1, -1);
+ $phrase = TRUE;
+ }
+ $words = trim($match[2], ',?!();:-');
+ $words = $phrase ? array($words) : preg_split('/ /', $words, -1, PREG_SPLIT_NO_EMPTY);
+ $placeholder = $this->placeholder();
+ foreach ($words as $word) {
+ $where->where($field . " LIKE $placeholder", array($placeholder => '%' . db_like(trim($word, " ,!?")) . '%'));
+ }
+ }
+
+ if (!$where) {
+ return;
+ }
+
+ // Previously this was a call_user_func_array() but that's unnecessary
+ // as views will unpack an array that is a single arg.
+ $this->query->add_where($this->options['group'], $where);
+ }
+
function op_starts($field) {
$placeholder = $this->placeholder();
$this->query->add_where_expression($this->options['group'], "$field LIKE $placeholder", array($placeholder => db_like($this->value) . '%'));