Révision 5d12d676
Ajouté par Assos Assos il y a environ 6 ans
drupal7/sites/all/modules/views/handlers/views_handler_filter_combine.inc | ||
---|---|---|
11 | 11 |
* @ingroup views_field_handlers |
12 | 12 |
*/ |
13 | 13 |
class views_handler_filter_combine extends views_handler_filter_string { |
14 |
|
|
14 | 15 |
/** |
15 | 16 |
* @var views_plugin_query_default |
16 | 17 |
*/ |
17 | 18 |
public $query; |
18 | 19 |
|
19 |
function option_definition() { |
|
20 |
/** |
|
21 |
* {@inheritdoc} |
|
22 |
*/ |
|
23 |
public function option_definition() { |
|
20 | 24 |
$options = parent::option_definition(); |
21 | 25 |
$options['fields'] = array('default' => array()); |
22 | 26 |
|
23 | 27 |
return $options; |
24 | 28 |
} |
25 | 29 |
|
26 |
function options_form(&$form, &$form_state) { |
|
30 |
/** |
|
31 |
* {@inheritdoc} |
|
32 |
*/ |
|
33 |
public function options_form(&$form, &$form_state) { |
|
27 | 34 |
parent::options_form($form, $form_state); |
28 | 35 |
$this->view->init_style(); |
29 | 36 |
|
... | ... | |
49 | 56 |
} |
50 | 57 |
} |
51 | 58 |
|
52 |
function query() { |
|
59 |
/** |
|
60 |
* {@inheritdoc} |
|
61 |
*/ |
|
62 |
public function query() { |
|
53 | 63 |
$this->view->_build('field'); |
54 | 64 |
$fields = array(); |
55 | 65 |
// Only add the fields if they have a proper field and table alias. |
... | ... | |
86 | 96 |
} |
87 | 97 |
} |
88 | 98 |
|
89 |
// By default things like op_equal uses add_where, that doesn't support |
|
90 |
// complex expressions, so override all operators. |
|
91 |
function op_equal($field) { |
|
99 |
/** |
|
100 |
* By default things like op_equal uses add_where, that doesn't support |
|
101 |
* complex expressions, so override all operators. |
|
102 |
*/ |
|
103 |
public function op_equal($field) { |
|
92 | 104 |
$placeholder = $this->placeholder(); |
93 | 105 |
$operator = $this->operator(); |
94 | 106 |
$this->query->add_where_expression($this->options['group'], "$field $operator $placeholder", array($placeholder => $this->value)); |
95 | 107 |
} |
96 | 108 |
|
97 |
function op_contains($field) { |
|
109 |
/** |
|
110 |
* |
|
111 |
*/ |
|
112 |
public function op_contains($field) { |
|
98 | 113 |
$placeholder = $this->placeholder(); |
99 | 114 |
$this->query->add_where_expression($this->options['group'], "$field LIKE $placeholder", array($placeholder => '%' . db_like($this->value) . '%')); |
100 | 115 |
} |
101 | 116 |
|
102 |
function op_word($field) { |
|
117 |
/** |
|
118 |
* |
|
119 |
*/ |
|
120 |
public function op_word($field) { |
|
103 | 121 |
$where = $this->operator == 'word' ? db_or() : db_and(); |
104 | 122 |
|
105 | 123 |
// Don't filter on empty strings. |
... | ... | |
132 | 150 |
$this->query->add_where($this->options['group'], $where); |
133 | 151 |
} |
134 | 152 |
|
135 |
function op_starts($field) { |
|
153 |
/** |
|
154 |
* |
|
155 |
*/ |
|
156 |
public function op_starts($field) { |
|
136 | 157 |
$placeholder = $this->placeholder(); |
137 | 158 |
$this->query->add_where_expression($this->options['group'], "$field LIKE $placeholder", array($placeholder => db_like($this->value) . '%')); |
138 | 159 |
} |
139 | 160 |
|
140 |
function op_not_starts($field) { |
|
161 |
/** |
|
162 |
* |
|
163 |
*/ |
|
164 |
public function op_not_starts($field) { |
|
141 | 165 |
$placeholder = $this->placeholder(); |
142 | 166 |
$this->query->add_where_expression($this->options['group'], "$field NOT LIKE $placeholder", array($placeholder => db_like($this->value) . '%')); |
143 | 167 |
} |
144 | 168 |
|
145 |
function op_ends($field) { |
|
169 |
/** |
|
170 |
* |
|
171 |
*/ |
|
172 |
public function op_ends($field) { |
|
146 | 173 |
$placeholder = $this->placeholder(); |
147 | 174 |
$this->query->add_where_expression($this->options['group'], "$field LIKE $placeholder", array($placeholder => '%' . db_like($this->value))); |
148 | 175 |
} |
149 | 176 |
|
150 |
function op_not_ends($field) { |
|
177 |
/** |
|
178 |
* |
|
179 |
*/ |
|
180 |
public function op_not_ends($field) { |
|
151 | 181 |
$placeholder = $this->placeholder(); |
152 | 182 |
$this->query->add_where_expression($this->options['group'], "$field NOT LIKE $placeholder", array($placeholder => '%' . db_like($this->value))); |
153 | 183 |
} |
154 | 184 |
|
155 |
function op_not($field) { |
|
185 |
/** |
|
186 |
* |
|
187 |
*/ |
|
188 |
public function op_not($field) { |
|
156 | 189 |
$placeholder = $this->placeholder(); |
157 | 190 |
$this->query->add_where_expression($this->options['group'], "$field NOT LIKE $placeholder", array($placeholder => '%' . db_like($this->value) . '%')); |
158 | 191 |
} |
159 | 192 |
|
160 |
function op_regex($field) { |
|
193 |
/** |
|
194 |
* |
|
195 |
*/ |
|
196 |
public function op_regex($field) { |
|
161 | 197 |
$placeholder = $this->placeholder(); |
162 | 198 |
$this->query->add_where_expression($this->options['group'], "$field RLIKE $placeholder", array($placeholder => $this->value)); |
163 | 199 |
} |
164 | 200 |
|
165 |
function op_empty($field) { |
|
201 |
/** |
|
202 |
* |
|
203 |
*/ |
|
204 |
public function op_empty($field) { |
|
166 | 205 |
if ($this->operator == 'empty') { |
167 | 206 |
$operator = "IS NULL"; |
168 | 207 |
} |
... | ... | |
172 | 211 |
|
173 | 212 |
$this->query->add_where_expression($this->options['group'], "$field $operator"); |
174 | 213 |
} |
214 |
|
|
175 | 215 |
} |
Formats disponibles : Unified diff
Weekly update of contrib modules