Révision 5d12d676
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/views/handlers/views_handler_filter_fields_compare.inc | ||
---|---|---|
10 | 10 |
* |
11 | 11 |
* @ingroup views_filter_handlers |
12 | 12 |
*/ |
13 |
|
|
14 | 13 |
class views_handler_filter_fields_compare extends views_handler_filter { |
15 | 14 |
|
16 |
function can_expose() { |
|
15 |
/** |
|
16 |
* {@inheritdoc} |
|
17 |
*/ |
|
18 |
public function can_expose() { |
|
17 | 19 |
return FALSE; |
18 | 20 |
} |
19 | 21 |
|
20 | 22 |
/** |
21 |
* Overrides views_handler_filter#option_definition().
|
|
23 |
* {@inheritdoc}
|
|
22 | 24 |
*/ |
23 |
function option_definition() { |
|
25 |
public function option_definition() {
|
|
24 | 26 |
$options = parent::option_definition(); |
25 | 27 |
|
26 | 28 |
$options['left_field'] = $options['right_field'] = array('default' => ''); |
... | ... | |
31 | 33 |
/** |
32 | 34 |
* Provide a list of all operators. |
33 | 35 |
*/ |
34 |
function fields_operator_options() { |
|
36 |
public function fields_operator_options() {
|
|
35 | 37 |
return array( |
36 | 38 |
'<' => t('Is less than'), |
37 | 39 |
'<=' => t('Is less than or equal to'), |
38 | 40 |
'=' => t('Is equal to'), |
39 |
'<>' => t('Is not equal to'),
|
|
41 |
'<>' => t('Is not equal to'), |
|
40 | 42 |
'>=' => t('Is greater than or equal to'), |
41 |
'>' => t('Is greater than') |
|
43 |
'>' => t('Is greater than'),
|
|
42 | 44 |
); |
43 | 45 |
} |
44 | 46 |
|
45 | 47 |
/** |
46 | 48 |
* Provide a list of available fields. |
47 | 49 |
*/ |
48 |
function field_options() { |
|
50 |
public function field_options() {
|
|
49 | 51 |
$options = array(); |
50 | 52 |
|
51 | 53 |
$field_handlers = $this->view->display_handler->get_handlers('field'); |
... | ... | |
59 | 61 |
} |
60 | 62 |
|
61 | 63 |
/** |
62 |
* Overrides views_handler_filter#options_form().
|
|
64 |
* {@inheritdoc}
|
|
63 | 65 |
*/ |
64 |
function options_form(&$form, &$form_state) { |
|
66 |
public function options_form(&$form, &$form_state) {
|
|
65 | 67 |
parent::options_form($form, $form_state); |
66 | 68 |
|
67 | 69 |
$field_options = $this->field_options(); |
... | ... | |
93 | 95 |
} |
94 | 96 |
|
95 | 97 |
/** |
96 |
* Overrides views_handler_filter#query(). |
|
97 |
* |
|
98 |
* Build extra condition from existing fields (from existing joins). |
|
98 |
* {@inheritdoc} |
|
99 | 99 |
*/ |
100 |
function query() { |
|
100 |
public function query() { |
|
101 |
// Build extra condition from existing fields (from existing joins). |
|
101 | 102 |
$left = $this->options['left_field']; |
102 | 103 |
$right = $this->options['right_field']; |
103 | 104 |
|
... | ... | |
120 | 121 |
$right_table_alias = $this->query->ensure_table($right_handler->table, $right_handler->relationship); |
121 | 122 |
|
122 | 123 |
// Build piece of SQL. |
123 |
$snippet = |
|
124 |
$left_table_alias . '.' . $left_handler->real_field . |
|
125 |
' ' . $this->options['operator'] . ' ' . |
|
126 |
$right_table_alias . '.' . $right_handler->real_field; |
|
124 |
$snippet = $left_table_alias . '.' . $left_handler->real_field |
|
125 |
. ' ' . $this->options['operator'] . ' ' |
|
126 |
. $right_table_alias . '.' . $right_handler->real_field; |
|
127 | 127 |
|
128 | 128 |
$this->query->add_where_expression($this->options['group'], $snippet); |
129 | 129 |
} |
130 | 130 |
|
131 | 131 |
/** |
132 |
* Overrides views_handler_filter#admin_summary().
|
|
132 |
* {@inheritdoc}
|
|
133 | 133 |
*/ |
134 |
function admin_summary() { |
|
134 |
public function admin_summary() {
|
|
135 | 135 |
return check_plain( |
136 |
$this->options['left_field'] . ' ' .
|
|
137 |
$this->options['operator'] . ' ' .
|
|
138 |
$this->options['right_field'] |
|
136 |
$this->options['left_field'] . ' ' |
|
137 |
. $this->options['operator'] . ' '
|
|
138 |
. $this->options['right_field']
|
|
139 | 139 |
); |
140 | 140 |
} |
141 | 141 |
|
Formats disponibles : Unified diff
Weekly update of contrib modules