~spreadubuntu/spreadubuntu/devel-drupal6

« back to all changes in this revision

Viewing changes to sites/all/modules/views/handlers/views_handler_filter_many_to_one.inc

  • Committer: ruben
  • Date: 2009-06-08 09:38:49 UTC
  • Revision ID: ruben@captive-20090608093849-s1qtsyctv2vwp1x1
SpreadUbuntu moving to Drupal6. Based on ubuntu-drupal theme and adding our modules

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
// $Id: views_handler_filter_many_to_one.inc,v 1.1 2008/09/03 19:21:28 merlinofchaos Exp $
 
3
 
 
4
/**
 
5
 * Complex filter to handle filtering for many to one relationships,
 
6
 * such as terms (many terms per node) or roles (many roles per user).
 
7
 *
 
8
 * The construct method needs to be overridden to provide a list of options;
 
9
 * alternately, the value_form and admin_summary methods need to be overriden
 
10
 * to provide something that isn't just a select list.
 
11
 */
 
12
class views_handler_filter_many_to_one extends views_handler_filter_in_operator {
 
13
  function init(&$view, &$options) {
 
14
    parent::init($view, $options);
 
15
    $this->helper = new views_many_to_one_helper($this);
 
16
  }
 
17
 
 
18
  function option_definition() {
 
19
    $options = parent::option_definition();
 
20
 
 
21
    $options['operator']['default'] = 'or';
 
22
    $options['value']['default'] = array();
 
23
 
 
24
    return $options;
 
25
  }
 
26
 
 
27
  /**
 
28
   * Provide inclusive/exclusive matching
 
29
   */
 
30
  function operator_options() {
 
31
    return array(
 
32
      'or' => t('Is one of'),
 
33
      'and' => t('Is all of'),
 
34
      'not' => t('Is none of'),
 
35
    );
 
36
  }
 
37
 
 
38
  var $value_form_type = 'select';
 
39
  function value_form(&$form, &$form_state) {
 
40
    parent::value_form($form, $form_state);
 
41
 
 
42
    if (empty($form_state['exposed'])) {
 
43
      $this->helper->options_form($form, $form_state);
 
44
    }
 
45
  }
 
46
 
 
47
  /**
 
48
   * Override ensure_my_table so we can control how this joins in.
 
49
   * The operator actually has influence over joining.
 
50
   */
 
51
  function ensure_my_table() {
 
52
    $this->helper->ensure_my_table();
 
53
  }
 
54
 
 
55
  function query() {
 
56
    if (empty($this->value)) {
 
57
      return;
 
58
    }
 
59
    $this->helper->add_filter();
 
60
  }
 
61
}