summaryrefslogtreecommitdiff
path: root/kolab.org/www/drupal-7.18/sites/all/modules/views/modules/search/views_handler_filter_search.inc
diff options
context:
space:
mode:
Diffstat (limited to 'kolab.org/www/drupal-7.18/sites/all/modules/views/modules/search/views_handler_filter_search.inc')
-rw-r--r--kolab.org/www/drupal-7.18/sites/all/modules/views/modules/search/views_handler_filter_search.inc30
1 files changed, 25 insertions, 5 deletions
diff --git a/kolab.org/www/drupal-7.18/sites/all/modules/views/modules/search/views_handler_filter_search.inc b/kolab.org/www/drupal-7.18/sites/all/modules/views/modules/search/views_handler_filter_search.inc
index 7430494..16515a7 100644
--- a/kolab.org/www/drupal-7.18/sites/all/modules/views/modules/search/views_handler_filter_search.inc
+++ b/kolab.org/www/drupal-7.18/sites/all/modules/views/modules/search/views_handler_filter_search.inc
@@ -29,11 +29,29 @@ class views_handler_filter_search extends views_handler_filter {
$options = parent::option_definition();
$options['operator']['default'] = 'optional';
+ $options['remove_score'] = array('default' => FALSE, 'bool' => TRUE);
return $options;
}
/**
+ * Overrides views_handler_filter::options_form().
+ *
+ * Add an option to remove search scores from the query.
+ */
+ function options_form(&$form, &$form_state) {
+ parent::options_form($form, $form_state);
+
+ $form['remove_score'] = array(
+ '#type' => 'checkbox',
+ '#title' => t('Remove search score'),
+ '#description' => t('Check this box to remove the search score from the query. This can help reduce help reduce duplicate search results when using this filter.'),
+ '#default_value' => $this->options['remove_score'],
+ );
+ }
+
+
+ /**
* Provide simple equality operator
*/
function operator_form(&$form, &$form_state) {
@@ -126,12 +144,14 @@ class views_handler_filter_search extends views_handler_filter {
$search_condition = db_and();
- // Create a new join to relate the 'serach_total' table to our current 'search_index' table.
- $join = new views_join;
- $join->construct('search_total', $search_index, 'word', 'word');
- $search_total = $this->query->add_relationship('search_total', $join, $search_index);
+ if (!$this->options['remove_score']) {
+ // Create a new join to relate the 'serach_total' table to our current 'search_index' table.
+ $join = new views_join;
+ $join->construct('search_total', $search_index, 'word', 'word');
+ $search_total = $this->query->add_relationship('search_total', $join, $search_index);
- $this->search_score = $this->query->add_field('', "SUM($search_index.score * $search_total.count)", 'score', array('aggregate' => TRUE));
+ $this->search_score = $this->query->add_field('', "SUM($search_index.score * $search_total.count)", 'score', array('aggregate' => TRUE));
+ }
if (empty($this->query->relationships[$this->relationship])) {
$base_table = $this->query->base_table;