Issue #1479454 by Hugo Wetterberg, galooph, dawehner, andypost, marcingy, heyrocker...
[project/drupal.git] / core / modules / views / lib / Drupal / views / Plugin / views / filter / FilterPluginBase.php
1 <?php
2
3 /**
4 * @file
5 * Definition of Drupal\views\Plugin\views\filter\FilterPluginBase.
6 */
7
8 namespace Drupal\views\Plugin\views\filter;
9
10 use Drupal\views\Plugin\views\HandlerBase;
11 use Drupal\views\Plugin\views\display\DisplayPluginBase;
12 use Drupal\Core\Annotation\Plugin;
13 use Drupal\views\ViewExecutable;
14
15 /**
16 * @defgroup views_filter_handlers Views filter handlers
17 * @{
18 * Handlers to tell Views how to filter queries.
19 *
20 * Definition items:
21 * - allow empty: If true, the 'IS NULL' and 'IS NOT NULL' operators become
22 * available as standard operators.
23 *
24 * Object flags:
25 * You can set some specific behavior by setting up the following flags on
26 * your custom class.
27 *
28 * - always_multiple:
29 * Disable the possibility to force a single value.
30 * - no_operator:
31 * Disable the possibility to use operators.
32 * - always_required:
33 * Disable the possibility to allow a exposed input to be optional.
34 */
35
36 /**
37 * Base class for filters.
38 *
39 * @ingroup views_filter_handlers
40 */
41 abstract class FilterPluginBase extends HandlerBase {
42
43 /**
44 * Contains the actual value of the field,either configured in the views ui
45 * or entered in the exposed filters.
46 */
47 var $value = NULL;
48
49 /**
50 * Contains the operator which is used on the query.
51 */
52 var $operator = '=';
53
54 /**
55 * Contains the information of the selected item in a gruped filter.
56 */
57 var $group_info = NULL;
58
59 /**
60 * @var bool
61 * Disable the possibility to force a single value.
62 */
63 var $always_multiple = FALSE;
64
65 /**
66 * @var bool
67 * Disable the possibility to use operators.
68 */
69 var $no_operator = FALSE;
70
71 /**
72 * @var bool
73 * Disable the possibility to allow a exposed input to be optional.
74 */
75 var $always_required = FALSE;
76
77 /**
78 * Overrides \Drupal\views\Plugin\views\HandlerBase::init().
79 *
80 * Provide some extra help to get the operator/value easier to use.
81 *
82 * This likely has to be overridden by filters which are more complex
83 * than simple operator/value.
84 */
85 public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
86 parent::init($view, $display, $options);
87
88 $this->operator = $this->options['operator'];
89 $this->value = $this->options['value'];
90 $this->group_info = $this->options['group_info']['default_group'];
91
92 // Set the default value of the operator ID.
93 if (!empty($options['exposed']) && !empty($options['expose']['operator']) && !isset($options['expose']['operator_id'])) {
94 $this->options['expose']['operator_id'] = $options['expose']['operator'];
95 }
96
97 if ($this->multipleExposedInput()) {
98 $this->group_info = array_filter($options['group_info']['default_group_multiple']);
99 $this->options['expose']['multiple'] = TRUE;
100 }
101
102
103 // If there are relationships in the view, allow empty should be true
104 // so that we can do IS NULL checks on items. Not all filters respect
105 // allow empty, but string and numeric do and that covers enough.
106 if ($this->view->display_handler->getOption('relationships')) {
107 $this->definition['allow empty'] = TRUE;
108 }
109 }
110
111 protected function defineOptions() {
112 $options = parent::defineOptions();
113
114 $options['operator'] = array('default' => '=');
115 $options['value'] = array('default' => '');
116 $options['group'] = array('default' => '1');
117 $options['exposed'] = array('default' => FALSE, 'bool' => TRUE);
118 $options['expose'] = array(
119 'contains' => array(
120 'operator_id' => array('default' => FALSE),
121 'label' => array('default' => '', 'translatable' => TRUE),
122 'description' => array('default' => '', 'translatable' => TRUE),
123 'use_operator' => array('default' => FALSE, 'bool' => TRUE),
124 'operator' => array('default' => ''),
125 'identifier' => array('default' => ''),
126 'required' => array('default' => FALSE, 'bool' => TRUE),
127 'remember' => array('default' => FALSE, 'bool' => TRUE),
128 'multiple' => array('default' => FALSE, 'bool' => TRUE),
129 'remember_roles' => array('default' => array(
130 DRUPAL_AUTHENTICATED_RID => DRUPAL_AUTHENTICATED_RID,
131 )),
132 ),
133 );
134
135 // A group is a combination of a filter, an operator and a value
136 // operating like a single filter.
137 // Users can choose from a select box which group they want to apply.
138 // Views will filter the view according to the defined values.
139 // Because it acts as a standard filter, we have to define
140 // an identifier and other settings like the widget and the label.
141 // This settings are saved in another array to allow users to switch
142 // between a normal filter and a group of filters with a single click.
143 $options['is_grouped'] = array('default' => FALSE, 'bool' => TRUE);
144 $options['group_info'] = array(
145 'contains' => array(
146 'label' => array('default' => '', 'translatable' => TRUE),
147 'description' => array('default' => '', 'translatable' => TRUE),
148 'identifier' => array('default' => ''),
149 'optional' => array('default' => TRUE, 'bool' => TRUE),
150 'widget' => array('default' => 'select'),
151 'multiple' => array('default' => FALSE, 'bool' => TRUE),
152 'remember' => array('default' => 0),
153 'default_group' => array('default' => 'All'),
154 'default_group_multiple' => array('default' => array()),
155 'group_items' => array('default' => array()),
156 ),
157 );
158
159 return $options;
160 }
161
162 /**
163 * Display the filter on the administrative summary
164 */
165 public function adminSummary() {
166 return check_plain((string) $this->operator) . ' ' . check_plain((string) $this->value);
167 }
168
169 /**
170 * Determine if a filter can be exposed.
171 */
172 public function canExpose() { return TRUE; }
173
174 /**
175 * Determine if a filter can be converted into a group.
176 * Only exposed filters with operators available can be converted into groups.
177 */
178 function can_build_group() {
179 return $this->isExposed() && (count($this->operator_options()) > 0);
180 }
181
182 /**
183 * Returns TRUE if the exposed filter works like a grouped filter.
184 */
185 public function isAGroup() {
186 return $this->isExposed() && !empty($this->options['is_grouped']);
187 }
188
189 /**
190 * Provide the basic form which calls through to subforms.
191 * If overridden, it is best to call through to the parent,
192 * or to at least make sure all of the functions in this form
193 * are called.
194 */
195 public function buildOptionsForm(&$form, &$form_state) {
196 parent::buildOptionsForm($form, $form_state);
197 if ($this->canExpose()) {
198 $this->showExposeButton($form, $form_state);
199 }
200 if ($this->can_build_group()) {
201 $this->show_build_group_button($form, $form_state);
202 }
203 $form['clear_markup_start'] = array(
204 '#markup' => '<div class="clearfix">',
205 );
206 if ($this->isAGroup()) {
207 if ($this->can_build_group()) {
208 $form['clear_markup_start'] = array(
209 '#markup' => '<div class="clearfix">',
210 );
211 // Render the build group form.
212 $this->show_build_group_form($form, $form_state);
213 $form['clear_markup_end'] = array(
214 '#markup' => '</div>',
215 );
216 }
217 }
218 else {
219 // Add the subform from operator_form().
220 $this->show_operator_form($form, $form_state);
221 // Add the subform from value_form().
222 $this->show_value_form($form, $form_state);
223 $form['clear_markup_end'] = array(
224 '#markup' => '</div>',
225 );
226 if ($this->canExpose()) {
227 // Add the subform from buildExposeForm().
228 $this->showExposeForm($form, $form_state);
229 }
230 }
231 }
232
233 /**
234 * Simple validate handler
235 */
236 public function validateOptionsForm(&$form, &$form_state) {
237 $this->operator_validate($form, $form_state);
238 $this->value_validate($form, $form_state);
239 if (!empty($this->options['exposed']) && !$this->isAGroup()) {
240 $this->validateExposeForm($form, $form_state);
241 }
242 if ($this->isAGroup()) {
243 $this->build_group_validate($form, $form_state);
244 }
245 }
246
247 /**
248 * Simple submit handler
249 */
250 public function submitOptionsForm(&$form, &$form_state) {
251 unset($form_state['values']['expose_button']); // don't store this.
252 unset($form_state['values']['group_button']); // don't store this.
253 if (!$this->isAGroup()) {
254 $this->operator_submit($form, $form_state);
255 $this->value_submit($form, $form_state);
256 }
257 if (!empty($this->options['exposed'])) {
258 $this->submitExposeForm($form, $form_state);
259 }
260 if ($this->isAGroup()) {
261 $this->build_group_submit($form, $form_state);
262 }
263 }
264
265 /**
266 * Shortcut to display the operator form.
267 */
268 function show_operator_form(&$form, &$form_state) {
269 $this->operator_form($form, $form_state);
270 $form['operator']['#prefix'] = '<div class="views-group-box views-left-30">';
271 $form['operator']['#suffix'] = '</div>';
272 }
273
274 /**
275 * Options form subform for setting the operator.
276 *
277 * This may be overridden by child classes, and it must
278 * define $form['operator'];
279 *
280 * @see buildOptionsForm()
281 */
282 function operator_form(&$form, &$form_state) {
283 $options = $this->operator_options();
284 if (!empty($options)) {
285 $form['operator'] = array(
286 '#type' => count($options) < 10 ? 'radios' : 'select',
287 '#title' => t('Operator'),
288 '#default_value' => $this->operator,
289 '#options' => $options,
290 );
291 }
292 }
293
294 /**
295 * Provide a list of options for the default operator form.
296 * Should be overridden by classes that don't override operator_form
297 */
298 function operator_options() { return array(); }
299
300 /**
301 * Validate the operator form.
302 */
303 function operator_validate($form, &$form_state) { }
304
305 /**
306 * Perform any necessary changes to the form values prior to storage.
307 * There is no need for this function to actually store the data.
308 */
309 function operator_submit($form, &$form_state) { }
310
311 /**
312 * Shortcut to display the value form.
313 */
314 function show_value_form(&$form, &$form_state) {
315 $this->value_form($form, $form_state);
316 if (empty($this->no_operator)) {
317 $form['value']['#prefix'] = '<div class="views-group-box views-right-70">' . (isset($form['value']['#prefix']) ? $form['value']['#prefix'] : '');
318 $form['value']['#suffix'] = (isset($form['value']['#suffix']) ? $form['value']['#suffix'] : '') . '</div>';
319 }
320 }
321
322 /**
323 * Options form subform for setting options.
324 *
325 * This should be overridden by all child classes and it must
326 * define $form['value']
327 *
328 * @see buildOptionsForm()
329 */
330 function value_form(&$form, &$form_state) { $form['value'] = array(); }
331
332 /**
333 * Validate the options form.
334 */
335 function value_validate($form, &$form_state) { }
336
337 /**
338 * Perform any necessary changes to the form values prior to storage.
339 * There is no need for this function to actually store the data.
340 */
341 function value_submit($form, &$form_state) { }
342
343 /**
344 * Shortcut to display the exposed options form.
345 */
346 function show_build_group_form(&$form, &$form_state) {
347 if (empty($this->options['is_grouped'])) {
348 return;
349 }
350
351 $this->build_group_form($form, $form_state);
352
353 // When we click the expose button, we add new gadgets to the form but they
354 // have no data in $_POST so their defaults get wiped out. This prevents
355 // these defaults from getting wiped out. This setting will only be TRUE
356 // during a 2nd pass rerender.
357 if (!empty($form_state['force_build_group_options'])) {
358 foreach (element_children($form['group_info']) as $id) {
359 if (isset($form['group_info'][$id]['#default_value']) && !isset($form['group_info'][$id]['#value'])) {
360 $form['group_info'][$id]['#value'] = $form['group_info'][$id]['#default_value'];
361 }
362 }
363 }
364 }
365
366 /**
367 * Shortcut to display the build_group/hide button.
368 */
369 function show_build_group_button(&$form, &$form_state) {
370
371 $form['group_button'] = array(
372 '#prefix' => '<div class="views-grouped clearfix">',
373 '#suffix' => '</div>',
374 // Should always come after the description and the relationship.
375 '#weight' => -190,
376 );
377
378 $grouped_description = t('Grouped filters allow a choice between predefined operator|value pairs.');
379 $form['group_button']['radios'] = array(
380 '#theme_wrappers' => array('container'),
381 '#attributes' => array('class' => array('js-only')),
382 );
383 $form['group_button']['radios']['radios'] = array(
384 '#title' => t('Filter type to expose'),
385 '#description' => $grouped_description,
386 '#type' => 'radios',
387 '#options' => array(
388 t('Single filter'),
389 t('Grouped filters'),
390 ),
391 );
392
393 if (empty($this->options['is_grouped'])) {
394 $form['group_button']['markup'] = array(
395 '#markup' => '<div class="description grouped-description">' . $grouped_description . '</div>',
396 );
397 $form['group_button']['button'] = array(
398 '#limit_validation_errors' => array(),
399 '#type' => 'submit',
400 '#value' => t('Grouped filters'),
401 '#submit' => array('views_ui_config_item_form_build_group'),
402 );
403 $form['group_button']['radios']['radios']['#default_value'] = 0;
404 }
405 else {
406 $form['group_button']['button'] = array(
407 '#limit_validation_errors' => array(),
408 '#type' => 'submit',
409 '#value' => t('Single filter'),
410 '#submit' => array('views_ui_config_item_form_build_group'),
411 );
412 $form['group_button']['radios']['radios']['#default_value'] = 1;
413 }
414 }
415 /**
416 * Shortcut to display the expose/hide button.
417 */
418 public function showExposeButton(&$form, &$form_state) {
419 $form['expose_button'] = array(
420 '#prefix' => '<div class="views-expose clearfix">',
421 '#suffix' => '</div>',
422 // Should always come after the description and the relationship.
423 '#weight' => -200,
424 );
425
426 // Add a checkbox for JS users, which will have behavior attached to it
427 // so it can replace the button.
428 $form['expose_button']['checkbox'] = array(
429 '#theme_wrappers' => array('container'),
430 '#attributes' => array('class' => array('js-only')),
431 );
432 $form['expose_button']['checkbox']['checkbox'] = array(
433 '#title' => t('Expose this filter to visitors, to allow them to change it'),
434 '#type' => 'checkbox',
435 );
436
437 // Then add the button itself.
438 if (empty($this->options['exposed'])) {
439 $form['expose_button']['markup'] = array(
440 '#markup' => '<div class="description exposed-description">' . t('This filter is not exposed. Expose it to allow the users to change it.') . '</div>',
441 );
442 $form['expose_button']['button'] = array(
443 '#limit_validation_errors' => array(),
444 '#type' => 'submit',
445 '#value' => t('Expose filter'),
446 '#submit' => array('views_ui_config_item_form_expose'),
447 );
448 $form['expose_button']['checkbox']['checkbox']['#default_value'] = 0;
449 }
450 else {
451 $form['expose_button']['markup'] = array(
452 '#markup' => '<div class="description exposed-description">' . t('This filter is exposed. If you hide it, users will not be able to change it.') . '</div>',
453 );
454 $form['expose_button']['button'] = array(
455 '#limit_validation_errors' => array(),
456 '#type' => 'submit',
457 '#value' => t('Hide filter'),
458 '#submit' => array('views_ui_config_item_form_expose'),
459 );
460 $form['expose_button']['checkbox']['checkbox']['#default_value'] = 1;
461 }
462 }
463
464 /**
465 * Options form subform for exposed filter options.
466 *
467 * @see buildOptionsForm()
468 */
469 public function buildExposeForm(&$form, &$form_state) {
470 $form['#theme'] = 'views_ui_expose_filter_form';
471 // #flatten will move everything from $form['expose'][$key] to $form[$key]
472 // prior to rendering. That's why the pre_render for it needs to run first,
473 // so that when the next pre_render (the one for fieldsets) runs, it gets
474 // the flattened data.
475 array_unshift($form['#pre_render'], 'views_ui_pre_render_flatten_data');
476 $form['expose']['#flatten'] = TRUE;
477
478 if (empty($this->always_required)) {
479 $form['expose']['required'] = array(
480 '#type' => 'checkbox',
481 '#title' => t('Required'),
482 '#default_value' => $this->options['expose']['required'],
483 );
484 }
485 else {
486 $form['expose']['required'] = array(
487 '#type' => 'value',
488 '#value' => TRUE,
489 );
490 }
491 $form['expose']['label'] = array(
492 '#type' => 'textfield',
493 '#default_value' => $this->options['expose']['label'],
494 '#title' => t('Label'),
495 '#size' => 40,
496 );
497
498 $form['expose']['description'] = array(
499 '#type' => 'textfield',
500 '#default_value' => $this->options['expose']['description'],
501 '#title' => t('Description'),
502 '#size' => 60,
503 );
504
505 if (!empty($form['operator']['#type'])) {
506 // Increase the width of the left (operator) column.
507 $form['operator']['#prefix'] = '<div class="views-group-box views-left-40">';
508 $form['operator']['#suffix'] = '</div>';
509 $form['value']['#prefix'] = '<div class="views-group-box views-right-60">';
510 $form['value']['#suffix'] = '</div>';
511
512 $form['expose']['use_operator'] = array(
513 '#type' => 'checkbox',
514 '#title' => t('Expose operator'),
515 '#description' => t('Allow the user to choose the operator.'),
516 '#default_value' => !empty($this->options['expose']['use_operator']),
517 );
518 $form['expose']['operator_id'] = array(
519 '#type' => 'textfield',
520 '#default_value' => $this->options['expose']['operator_id'],
521 '#title' => t('Operator identifier'),
522 '#size' => 40,
523 '#description' => t('This will appear in the URL after the ? to identify this operator.'),
524 '#states' => array(
525 'visible' => array(
526 ':input[name="options[expose][use_operator]"]' => array('checked' => TRUE),
527 ),
528 ),
529 '#fieldset' => 'more',
530 );
531 }
532 else {
533 $form['expose']['operator_id'] = array(
534 '#type' => 'value',
535 '#value' => '',
536 );
537 }
538
539 if (empty($this->always_multiple)) {
540 $form['expose']['multiple'] = array(
541 '#type' => 'checkbox',
542 '#title' => t('Allow multiple selections'),
543 '#description' => t('Enable to allow users to select multiple items.'),
544 '#default_value' => $this->options['expose']['multiple'],
545 );
546 }
547 $form['expose']['remember'] = array(
548 '#type' => 'checkbox',
549 '#title' => t('Remember the last selection'),
550 '#description' => t('Enable to remember the last selection made by the user.'),
551 '#default_value' => $this->options['expose']['remember'],
552 );
553
554 $role_options = array_map('check_plain', user_role_names());
555 $form['expose']['remember_roles'] = array(
556 '#type' => 'checkboxes',
557 '#title' => t('User roles'),
558 '#description' => t('Remember exposed selection only for the selected user role(s). If you select no roles, the exposed data will never be stored.'),
559 '#default_value' => $this->options['expose']['remember_roles'],
560 '#options' => $role_options,
561 '#states' => array(
562 'invisible' => array(
563 ':input[name="options[expose][remember]"]' => array('checked' => FALSE),
564 ),
565 ),
566 );
567
568 $form['expose']['identifier'] = array(
569 '#type' => 'textfield',
570 '#default_value' => $this->options['expose']['identifier'],
571 '#title' => t('Filter identifier'),
572 '#size' => 40,
573 '#description' => t('This will appear in the URL after the ? to identify this filter. Cannot be blank.'),
574 '#fieldset' => 'more',
575 );
576 }
577
578 /**
579 * Validate the options form.
580 */
581 public function validateExposeForm($form, &$form_state) {
582 if (empty($form_state['values']['options']['expose']['identifier'])) {
583 form_error($form['expose']['identifier'], t('The identifier is required if the filter is exposed.'));
584 }
585
586 if (!empty($form_state['values']['options']['expose']['identifier']) && $form_state['values']['options']['expose']['identifier'] == 'value') {
587 form_error($form['expose']['identifier'], t('This identifier is not allowed.'));
588 }
589
590 if (!$this->view->display_handler->isIdentifierUnique($form_state['id'], $form_state['values']['options']['expose']['identifier'])) {
591 form_error($form['expose']['identifier'], t('This identifier is used by another handler.'));
592 }
593 }
594
595 /**
596 * Validate the build group options form.
597 */
598 function build_group_validate($form, &$form_state) {
599 if (!empty($form_state['values']['options']['group_info'])) {
600 if (empty($form_state['values']['options']['group_info']['identifier'])) {
601 form_error($form['group_info']['identifier'], t('The identifier is required if the filter is exposed.'));
602 }
603
604 if (!empty($form_state['values']['options']['group_info']['identifier']) && $form_state['values']['options']['group_info']['identifier'] == 'value') {
605 form_error($form['group_info']['identifier'], t('This identifier is not allowed.'));
606 }
607
608 if (!$this->view->display_handler->isIdentifierUnique($form_state['id'], $form_state['values']['options']['group_info']['identifier'])) {
609 form_error($form['group_info']['identifier'], t('This identifier is used by another handler.'));
610 }
611 }
612
613 if (!empty($form_state['values']['options']['group_info']['group_items'])) {
614 foreach ($form_state['values']['options']['group_info']['group_items'] as $id => $group) {
615 if (empty($group['remove'])) {
616
617 // Check if the title is defined but value wasn't defined.
618 if (!empty($group['title'])) {
619 if ((!is_array($group['value']) && trim($group['value']) == "") ||
620 (is_array($group['value']) && count(array_filter($group['value'], '_views_array_filter_zero')) == 0)) {
621 form_error($form['group_info']['group_items'][$id]['value'],
622 t('The value is required if title for this item is defined.'));
623 }
624 }
625
626 // Check if the value is defined but title wasn't defined.
627 if ((!is_array($group['value']) && trim($group['value']) != "") ||
628 (is_array($group['value']) && count(array_filter($group['value'], '_views_array_filter_zero')) > 0)) {
629 if (empty($group['title'])) {
630 form_error($form['group_info']['group_items'][$id]['title'],
631 t('The title is required if value for this item is defined.'));
632 }
633 }
634 }
635 }
636 }
637 }
638
639 /**
640 * Save new group items, re-enumerates and remove groups marked to delete.
641 */
642 function build_group_submit($form, &$form_state) {
643 $groups = array();
644 uasort($form_state['values']['options']['group_info']['group_items'], 'drupal_sort_weight');
645 // Filter out removed items.
646
647 // Start from 1 to avoid problems with #default_value in the widget.
648 $new_id = 1;
649 $new_default = 'All';
650 foreach ($form_state['values']['options']['group_info']['group_items'] as $id => $group) {
651 if (empty($group['remove'])) {
652 // Don't store this.
653 unset($group['remove']);
654 unset($group['weight']);
655 $groups[$new_id] = $group;
656
657 if ($form_state['values']['options']['group_info']['default_group'] === $id) {
658 $new_default = $new_id;
659 }
660 }
661 $new_id++;
662 }
663 if ($new_default != 'All') {
664 $form_state['values']['options']['group_info']['default_group'] = $new_default;
665 }
666 $filter_default_multiple = array_filter($form_state['values']['options']['group_info']['default_group_multiple']);
667 $form_state['values']['options']['group_info']['default_group_multiple'] = $filter_default_multiple;
668
669 $form_state['values']['options']['group_info']['group_items'] = $groups;
670 }
671
672 /**
673 * Provide default options for exposed filters.
674 */
675 public function defaultExposeOptions() {
676 $this->options['expose'] = array(
677 'use_operator' => FALSE,
678 'operator' => $this->options['id'] . '_op',
679 'identifier' => $this->options['id'],
680 'label' => $this->definition['title'],
681 'description' => NULL,
682 'remember' => FALSE,
683 'multiple' => FALSE,
684 'required' => FALSE,
685 );
686 }
687
688 /**
689 * Provide default options for exposed filters.
690 */
691 function build_group_options() {
692 $this->options['group_info'] = array(
693 'label' => $this->definition['title'],
694 'description' => NULL,
695 'identifier' => $this->options['id'],
696 'optional' => TRUE,
697 'widget' => 'select',
698 'multiple' => FALSE,
699 'remember' => FALSE,
700 'default_group' => 'All',
701 'default_group_multiple' => array(),
702 'group_items' => array(),
703 );
704 }
705
706 /**
707 * Build a form containing a group of operator | values to apply as a
708 * single filter.
709 */
710 function group_form(&$form, &$form_state) {
711 if (!empty($this->options['group_info']['optional']) && !$this->multipleExposedInput()) {
712
713 $old_any = $this->options['group_info']['widget'] == 'select' ? '<Any>' : '&lt;Any&gt;';
714 $any_label = config('views.settings')->get('ui.exposed_filter_any_label') == 'old_any' ? $old_any : t('- Any -');
715 $groups = array('All' => $any_label);
716 }
717 foreach ($this->options['group_info']['group_items'] as $id => $group) {
718 if (!empty($group['title'])) {
719 $groups[$id] = $id != 'All' ? t($group['title']) : $group['title'];
720 }
721 }
722
723 if (count($groups)) {
724 $value = $this->options['group_info']['identifier'];
725
726 $form[$value] = array(
727 '#type' => $this->options['group_info']['widget'],
728 '#default_value' => $this->group_info,
729 '#options' => $groups,
730 );
731 if (!empty($this->options['group_info']['multiple'])) {
732 if (count($groups) < 5) {
733 $form[$value]['#type'] = 'checkboxes';
734 }
735 else {
736 $form[$value]['#type'] = 'select';
737 $form[$value]['#size'] = 5;
738 $form[$value]['#multiple'] = TRUE;
739 }
740 unset($form[$value]['#default_value']);
741 if (empty($form_state['input'])) {
742 $form_state['input'][$value] = $this->group_info;
743 }
744 }
745
746 $this->options['expose']['label'] = '';
747 }
748 }
749
750
751 /**
752 * Render our chunk of the exposed filter form when selecting
753 *
754 * You can override this if it doesn't do what you expect.
755 */
756 public function buildExposedForm(&$form, &$form_state) {
757 if (empty($this->options['exposed'])) {
758 return;
759 }
760
761 // Build the exposed form, when its based on an operator.
762 if (!empty($this->options['expose']['use_operator']) && !empty($this->options['expose']['operator_id'])) {
763 $operator = $this->options['expose']['operator_id'];
764 $this->operator_form($form, $form_state);
765 $form[$operator] = $form['operator'];
766
767 if (isset($form[$operator]['#title'])) {
768 unset($form[$operator]['#title']);
769 }
770
771 $this->exposed_translate($form[$operator], 'operator');
772
773 unset($form['operator']);
774 }
775
776 // Build the form and set the value based on the identifier.
777 if (!empty($this->options['expose']['identifier'])) {
778 $value = $this->options['expose']['identifier'];
779 $this->value_form($form, $form_state);
780 $form[$value] = $form['value'];
781
782 if (isset($form[$value]['#title']) && !empty($form[$value]['#type']) && $form[$value]['#type'] != 'checkbox') {
783 unset($form[$value]['#title']);
784 }
785
786 $this->exposed_translate($form[$value], 'value');
787
788 if (!empty($form['#type']) && ($form['#type'] == 'checkboxes' || ($form['#type'] == 'select' && !empty($form['#multiple'])))) {
789 unset($form[$value]['#default_value']);
790 }
791
792 if (!empty($form['#type']) && $form['#type'] == 'select' && empty($form['#multiple'])) {
793 $form[$value]['#default_value'] = 'All';
794 }
795
796 if ($value != 'value') {
797 unset($form['value']);
798 }
799 }
800 }
801
802 /**
803 * Build the form to let users create the group of exposed filters.
804 * This form is displayed when users click on button 'Build group'
805 */
806 function build_group_form(&$form, &$form_state) {
807 if (empty($this->options['exposed']) || empty($this->options['is_grouped'])) {
808 return;
809 }
810 $form['#theme'] = 'views_ui_build_group_filter_form';
811
812 // #flatten will move everything from $form['group_info'][$key] to $form[$key]
813 // prior to rendering. That's why the pre_render for it needs to run first,
814 // so that when the next pre_render (the one for fieldsets) runs, it gets
815 // the flattened data.
816 array_unshift($form['#pre_render'], 'views_ui_pre_render_flatten_data');
817 $form['group_info']['#flatten'] = TRUE;
818
819 if (!empty($this->options['group_info']['identifier'])) {
820 $identifier = $this->options['group_info']['identifier'];
821 }
822 else {
823 $identifier = 'group_' . $this->options['expose']['identifier'];
824 }
825 $form['group_info']['identifier'] = array(
826 '#type' => 'textfield',
827 '#default_value' => $identifier,
828 '#title' => t('Filter identifier'),
829 '#size' => 40,
830 '#description' => t('This will appear in the URL after the ? to identify this filter. Cannot be blank.'),
831 '#fieldset' => 'more',
832 );
833 $form['group_info']['label'] = array(
834 '#type' => 'textfield',
835 '#default_value' => $this->options['group_info']['label'],
836 '#title' => t('Label'),
837 '#size' => 40,
838 );
839 $form['group_info']['description'] = array(
840 '#type' => 'textfield',
841 '#default_value' => $this->options['group_info']['description'],
842 '#title' => t('Description'),
843 '#size' => 60,
844 );
845 $form['group_info']['optional'] = array(
846 '#type' => 'checkbox',
847 '#title' => t('Optional'),
848 '#description' => t('This exposed filter is optional and will have added options to allow it not to be set.'),
849 '#default_value' => $this->options['group_info']['optional'],
850 );
851 $form['group_info']['multiple'] = array(
852 '#type' => 'checkbox',
853 '#title' => t('Allow multiple selections'),
854 '#description' => t('Enable to allow users to select multiple items.'),
855 '#default_value' => $this->options['group_info']['multiple'],
856 );
857 $form['group_info']['widget'] = array(
858 '#type' => 'radios',
859 '#default_value' => $this->options['group_info']['widget'],
860 '#title' => t('Widget type'),
861 '#options' => array(
862 'radios' => t('Radios'),
863 'select' => t('Select'),
864 ),
865 '#description' => t('Select which kind of widget will be used to render the group of filters'),
866 );
867 $form['group_info']['remember'] = array(
868 '#type' => 'checkbox',
869 '#title' => t('Remember'),
870 '#description' => t('Remember the last setting the user gave this filter.'),
871 '#default_value' => $this->options['group_info']['remember'],
872 );
873
874 if (!empty($this->options['group_info']['identifier'])) {
875 $identifier = $this->options['group_info']['identifier'];
876 }
877 else {
878 $identifier = 'group_' . $this->options['expose']['identifier'];
879 }
880 $form['group_info']['identifier'] = array(
881 '#type' => 'textfield',
882 '#default_value' => $identifier,
883 '#title' => t('Filter identifier'),
884 '#size' => 40,
885 '#description' => t('This will appear in the URL after the ? to identify this filter. Cannot be blank.'),
886 '#fieldset' => 'more',
887 );
888 $form['group_info']['label'] = array(
889 '#type' => 'textfield',
890 '#default_value' => $this->options['group_info']['label'],
891 '#title' => t('Label'),
892 '#size' => 40,
893 );
894 $form['group_info']['optional'] = array(
895 '#type' => 'checkbox',
896 '#title' => t('Optional'),
897 '#description' => t('This exposed filter is optional and will have added options to allow it not to be set.'),
898 '#default_value' => $this->options['group_info']['optional'],
899 );
900 $form['group_info']['widget'] = array(
901 '#type' => 'radios',
902 '#default_value' => $this->options['group_info']['widget'],
903 '#title' => t('Widget type'),
904 '#options' => array(
905 'radios' => t('Radios'),
906 'select' => t('Select'),
907 ),
908 '#description' => t('Select which kind of widget will be used to render the group of filters'),
909 );
910 $form['group_info']['remember'] = array(
911 '#type' => 'checkbox',
912 '#title' => t('Remember'),
913 '#description' => t('Remember the last setting the user gave this filter.'),
914 '#default_value' => $this->options['group_info']['remember'],
915 );
916
917 $groups = array('All' => '- Any -'); // The string '- Any -' will not be rendered see @theme_views_ui_build_group_filter_form
918
919 // Provide 3 options to start when we are in a new group.
920 if (count($this->options['group_info']['group_items']) == 0) {
921 $this->options['group_info']['group_items'] = array_fill(1, 3, array());
922 }
923
924 // After the general settings, comes a table with all the existent groups.
925 $default_weight = 0;
926 foreach ($this->options['group_info']['group_items'] as $item_id => $item) {
927 if (!empty($form_state['values']['options']['group_info']['group_items'][$item_id]['remove'])) {
928 continue;
929 }
930 // Each rows contains three widgets:
931 // a) The title, where users define how they identify a pair of operator | value
932 // b) The operator
933 // c) The value (or values) to use in the filter with the selected operator
934
935 // In each row, we have to display the operator form and the value from
936 // $row acts as a fake form to render each widget in a row.
937 $row = array();
938 $groups[$item_id] = '';
939 $this->operator_form($row, $form_state);
940 // Force the operator form to be a select box. Some handlers uses
941 // radios and they occupy a lot of space in a table row.
942 $row['operator']['#type'] = 'select';
943 $row['operator']['#title'] = '';
944 $this->value_form($row, $form_state);
945
946 // Fix the dependencies to update value forms when operators
947 // changes. This is needed because forms are inside a new form and
948 // their ids changes. Dependencies are used when operator changes
949 // from to 'Between', 'Not Between', etc, and two or more widgets
950 // are displayed.
951 $without_children = TRUE;
952 foreach (element_children($row['value']) as $children) {
953 $has_state = FALSE;
954 $states = array();
955 foreach ($row['value'][$children]['#states']['visible'] as $key => $state) {
956 if (isset($state[':input[name="options[operator]"]'])) {
957 $has_state = TRUE;
958 $states[$key] = $state[':input[name="options[operator]"]']['value'];
959 }
960 }
961 if ($has_state) {
962 foreach ($states as $key => $state) {
963 $row['value'][$children]['#states']['visible'][] = array(
964 ':input[name="options[group_info][group_items][' . $item_id . '][operator]"]' => array('value' => $state),
965 );
966 unset($row['value'][$children]['#states']['visible'][$key]);
967 }
968
969 $row['value'][$children]['#title'] = '';
970
971 if (!empty($this->options['group_info']['group_items'][$item_id]['value'][$children])) {
972 $row['value'][$children]['#default_value'] = $this->options['group_info']['group_items'][$item_id]['value'][$children];
973 }
974 }
975 $without_children = FALSE;
976 }
977
978 if ($without_children) {
979 if (!empty($this->options['group_info']['group_items'][$item_id]['value'])) {
980 $row['value']['#default_value'] = $this->options['group_info']['group_items'][$item_id]['value'];
981 }
982 }
983
984 if (!empty($this->options['group_info']['group_items'][$item_id]['operator'])) {
985 $row['operator']['#default_value'] = $this->options['group_info']['group_items'][$item_id]['operator'];
986 }
987
988 $default_title = '';
989 if (!empty($this->options['group_info']['group_items'][$item_id]['title'])) {
990 $default_title = $this->options['group_info']['group_items'][$item_id]['title'];
991 }
992
993 // Per item group, we have a title that identifies it.
994 $form['group_info']['group_items'][$item_id] = array(
995 'title' => array(
996 '#type' => 'textfield',
997 '#size' => 20,
998 '#default_value' => $default_title,
999 ),
1000 'operator' => $row['operator'],
1001 'value' => $row['value'],
1002 'remove' => array(
1003 '#type' => 'checkbox',
1004 '#id' => 'views-removed-' . $item_id,
1005 '#attributes' => array('class' => array('views-remove-checkbox')),
1006 '#default_value' => 0,
1007 ),
1008 'weight' => array(
1009 '#type' => 'weight',
1010 '#delta' => 10,
1011 '#default_value' => $default_weight++,
1012 '#attributes' => array('class' => array('weight')),
1013 ),
1014 );
1015 }
1016 // From all groups, let chose which is the default.
1017 $form['group_info']['default_group'] = array(
1018 '#type' => 'radios',
1019 '#options' => $groups,
1020 '#default_value' => $this->options['group_info']['default_group'],
1021 '#required' => TRUE,
1022 '#attributes' => array(
1023 'class' => array('default-radios'),
1024 )
1025 );
1026 // From all groups, let chose which is the default.
1027 $form['group_info']['default_group_multiple'] = array(
1028 '#type' => 'checkboxes',
1029 '#options' => $groups,
1030 '#default_value' => $this->options['group_info']['default_group_multiple'],
1031 '#attributes' => array(
1032 'class' => array('default-checkboxes'),
1033 )
1034 );
1035
1036 $form['group_info']['add_group'] = array(
1037 '#prefix' => '<div class="views-build-group clear-block">',
1038 '#suffix' => '</div>',
1039 '#type' => 'submit',
1040 '#value' => t('Add another item'),
1041 '#submit' => array('views_ui_config_item_form_add_group'),
1042 );
1043
1044 $js = array();
1045 $js['tableDrag']['views-filter-groups']['weight'][0] = array(
1046 'target' => 'weight',
1047 'source' => NULL,
1048 'relationship' => 'sibling',
1049 'action' => 'order',
1050 'hidden' => TRUE,
1051 'limit' => 0,
1052 );
1053 if (!empty($form_state['js settings']) && is_array($js)) {
1054 $form_state['js settings'] = array_merge($form_state['js settings'], $js);
1055 }
1056 else {
1057 $form_state['js settings'] = $js;
1058 }
1059 }
1060
1061
1062 /**
1063 * Make some translations to a form item to make it more suitable to
1064 * exposing.
1065 */
1066 function exposed_translate(&$form, $type) {
1067 if (!isset($form['#type'])) {
1068 return;
1069 }
1070
1071 if ($form['#type'] == 'radios') {
1072 $form['#type'] = 'select';
1073 }
1074 // Checkboxes don't work so well in exposed forms due to GET conversions.
1075 if ($form['#type'] == 'checkboxes') {
1076 if (empty($form['#no_convert']) || empty($this->options['expose']['multiple'])) {
1077 $form['#type'] = 'select';
1078 }
1079 if (!empty($this->options['expose']['multiple'])) {
1080 $form['#multiple'] = TRUE;
1081 }
1082 }
1083 if (empty($this->options['expose']['multiple']) && isset($form['#multiple'])) {
1084 unset($form['#multiple']);
1085 $form['#size'] = NULL;
1086 }
1087
1088 // Cleanup in case the translated element's (radios or checkboxes) display value contains html.
1089 if ($form['#type'] == 'select') {
1090 $this->prepare_filter_select_options($form['#options']);
1091 }
1092
1093 if ($type == 'value' && empty($this->always_required) && empty($this->options['expose']['required']) && $form['#type'] == 'select' && empty($form['#multiple'])) {
1094 $any_label = config('views.settings')->get('ui.exposed_filter_any_label') == 'old_any' ? t('<Any>') : t('- Any -');
1095 $form['#options'] = array('All' => $any_label) + $form['#options'];
1096 $form['#default_value'] = 'All';
1097 }
1098
1099 if (!empty($this->options['expose']['required'])) {
1100 $form['#required'] = TRUE;
1101 }
1102 }
1103
1104
1105
1106 /**
1107 * Sanitizes the HTML select element's options.
1108 *
1109 * The function is recursive to support optgroups.
1110 */
1111 function prepare_filter_select_options(&$options) {
1112 foreach ($options as $value => $label) {
1113 // Recurse for optgroups.
1114 if (is_array($label)) {
1115 $this->prepare_filter_select_options($options[$value]);
1116 }
1117 // FAPI has some special value to allow hierarchy.
1118 // @see _form_options_flatten
1119 elseif (is_object($label)) {
1120 $this->prepare_filter_select_options($options[$value]->option);
1121 }
1122 else {
1123 $options[$value] = strip_tags(decode_entities($label));
1124 }
1125 }
1126 }
1127
1128 /**
1129 * Tell the renderer about our exposed form. This only needs to be
1130 * overridden for particularly complex forms. And maybe not even then.
1131 *
1132 * @return array|null
1133 * For standard exposed filters. An array with the following keys:
1134 * - operator: The $form key of the operator. Set to NULL if no operator.
1135 * - value: The $form key of the value. Set to NULL if no value.
1136 * - label: The label to use for this piece.
1137 * For grouped exposed filters. An array with the following keys:
1138 * - value: The $form key of the value. Set to NULL if no value.
1139 * - label: The label to use for this piece.
1140 */
1141 public function exposedInfo() {
1142 if (empty($this->options['exposed'])) {
1143 return;
1144 }
1145
1146 if ($this->isAGroup()) {
1147 return array(
1148 'value' => $this->options['group_info']['identifier'],
1149 'label' => $this->options['group_info']['label'],
1150 'description' => $this->options['group_info']['description'],
1151 );
1152 }
1153
1154 return array(
1155 'operator' => $this->options['expose']['operator_id'],
1156 'value' => $this->options['expose']['identifier'],
1157 'label' => $this->options['expose']['label'],
1158 'description' => $this->options['expose']['description'],
1159 );
1160 }
1161
1162 /*
1163 * Transform the input from a grouped filter into a standard filter.
1164 *
1165 * When a filter is a group, find the set of operator and values
1166 * that the choosed item represents, and inform views that a normal
1167 * filter was submitted by telling the operator and the value selected.
1168 *
1169 * The param $selected_group_id is only passed when the filter uses the
1170 * checkboxes widget, and this function will be called for each item
1171 * choosed in the checkboxes.
1172 */
1173 function convert_exposed_input(&$input, $selected_group_id = NULL) {
1174 if ($this->isAGroup()) {
1175 // If it is already defined the selected group, use it. Only valid
1176 // when the filter uses checkboxes for widget.
1177 if (!empty($selected_group_id)) {
1178 $selected_group = $selected_group_id;
1179 }
1180 else {
1181 $selected_group = $input[$this->options['group_info']['identifier']];
1182 }
1183 if ($selected_group == 'All' && !empty($this->options['group_info']['optional'])) {
1184 return NULL;
1185 }
1186 if ($selected_group != 'All' && empty($this->options['group_info']['group_items'][$selected_group])) {
1187 return FALSE;
1188 }
1189 if (isset($selected_group) && isset($this->options['group_info']['group_items'][$selected_group])) {
1190 $input[$this->options['expose']['operator']] = $this->options['group_info']['group_items'][$selected_group]['operator'];
1191
1192 // Value can be optional, For example for 'empty' and 'not empty' filters.
1193 if (!empty($this->options['group_info']['group_items'][$selected_group]['value'])) {
1194 $input[$this->options['expose']['identifier']] = $this->options['group_info']['group_items'][$selected_group]['value'];
1195 }
1196 $this->options['expose']['use_operator'] = TRUE;
1197
1198 $this->group_info = $input[$this->options['group_info']['identifier']];
1199 return TRUE;
1200 }
1201 else {
1202 return FALSE;
1203 }
1204 }
1205 }
1206
1207 /**
1208 * Returns the options available for a grouped filter that users checkboxes
1209 * as widget, and therefore has to be applied several times, one per
1210 * item selected.
1211 */
1212 function group_multiple_exposed_input(&$input) {
1213 if (!empty($input[$this->options['group_info']['identifier']])) {
1214 return array_filter($input[$this->options['group_info']['identifier']]);
1215 }
1216 return array();
1217 }
1218
1219 /**
1220 * Returns TRUE if users can select multiple groups items of a
1221 * grouped exposed filter.
1222 */
1223 public function multipleExposedInput() {
1224 return $this->isAGroup() && !empty($this->options['group_info']['multiple']);
1225 }
1226
1227 /**
1228 * If set to remember exposed input in the session, store it there.
1229 * This function is similar to storeExposedInput but modified to
1230 * work properly when the filter is a group.
1231 */
1232 function store_group_input($input, $status) {
1233 if (!$this->isAGroup() || empty($this->options['group_info']['identifier'])) {
1234 return TRUE;
1235 }
1236
1237 if (empty($this->options['group_info']['remember'])) {
1238 return;
1239 }
1240
1241 // Figure out which display id is responsible for the filters, so we
1242 // know where to look for session stored values.
1243 $display_id = ($this->view->display_handler->isDefaulted('filters')) ? 'default' : $this->view->current_display;
1244
1245 // false means that we got a setting that means to recuse ourselves,
1246 // so we should erase whatever happened to be there.
1247 if ($status === FALSE && isset($_SESSION['views'][$this->view->storage->id()][$display_id])) {
1248 $session = &$_SESSION['views'][$this->view->storage->id()][$display_id];
1249
1250 if (isset($session[$this->options['group_info']['identifier']])) {
1251 unset($session[$this->options['group_info']['identifier']]);
1252 }
1253 }
1254
1255 if ($status !== FALSE) {
1256 if (!isset($_SESSION['views'][$this->view->storage->id()][$display_id])) {
1257 $_SESSION['views'][$this->view->storage->id()][$display_id] = array();
1258 }
1259
1260 $session = &$_SESSION['views'][$this->view->storage->id()][$display_id];
1261
1262 $session[$this->options['group_info']['identifier']] = $input[$this->options['group_info']['identifier']];
1263 }
1264 }
1265
1266 /**
1267 * Check to see if input from the exposed filters should change
1268 * the behavior of this filter.
1269 */
1270 public function acceptExposedInput($input) {
1271 if (empty($this->options['exposed'])) {
1272 return TRUE;
1273 }
1274
1275
1276 if (!empty($this->options['expose']['use_operator']) && !empty($this->options['expose']['operator_id']) && isset($input[$this->options['expose']['operator_id']])) {
1277 $this->operator = $input[$this->options['expose']['operator_id']];
1278 }
1279
1280 if (!empty($this->options['expose']['identifier'])) {
1281 $value = $input[$this->options['expose']['identifier']];
1282
1283 // Various ways to check for the absence of non-required input.
1284 if (empty($this->options['expose']['required'])) {
1285 if (($this->operator == 'empty' || $this->operator == 'not empty') && $value === '') {
1286 $value = ' ';
1287 }
1288
1289 if ($this->operator != 'empty' && $this->operator != 'not empty') {
1290 if ($value == 'All' || $value === array()) {
1291 return FALSE;
1292 }
1293 }
1294
1295 if (!empty($this->always_multiple) && $value === '') {
1296 return FALSE;
1297 }
1298 }
1299
1300
1301 if (isset($value)) {
1302 $this->value = $value;
1303 if (empty($this->always_multiple) && empty($this->options['expose']['multiple'])) {
1304 $this->value = array($value);
1305 }
1306 }
1307 else {
1308 return FALSE;
1309 }
1310 }
1311
1312 return TRUE;
1313 }
1314
1315 public function storeExposedInput($input, $status) {
1316 if (empty($this->options['exposed']) || empty($this->options['expose']['identifier'])) {
1317 return TRUE;
1318 }
1319
1320 if (empty($this->options['expose']['remember'])) {
1321 return;
1322 }
1323
1324 // Check if we store exposed value for current user.
1325 global $user;
1326 $allowed_rids = empty($this->options['expose']['remember_roles']) ? array() : array_filter($this->options['expose']['remember_roles']);
1327 $intersect_rids = array_intersect_key($allowed_rids, $user->roles);
1328 if (empty($intersect_rids)) {
1329 return;
1330 }
1331
1332 // Figure out which display id is responsible for the filters, so we
1333 // know where to look for session stored values.
1334 $display_id = ($this->view->display_handler->isDefaulted('filters')) ? 'default' : $this->view->current_display;
1335
1336 // shortcut test.
1337 $operator = !empty($this->options['expose']['use_operator']) && !empty($this->options['expose']['operator_id']);
1338
1339 // false means that we got a setting that means to recuse ourselves,
1340 // so we should erase whatever happened to be there.
1341 if (!$status && isset($_SESSION['views'][$this->view->storage->id()][$display_id])) {
1342 $session = &$_SESSION['views'][$this->view->storage->id()][$display_id];
1343 if ($operator && isset($session[$this->options['expose']['operator_id']])) {
1344 unset($session[$this->options['expose']['operator_id']]);
1345 }
1346
1347 if (isset($session[$this->options['expose']['identifier']])) {
1348 unset($session[$this->options['expose']['identifier']]);
1349 }
1350 }
1351
1352 if ($status) {
1353 if (!isset($_SESSION['views'][$this->view->storage->id()][$display_id])) {
1354 $_SESSION['views'][$this->view->storage->id()][$display_id] = array();
1355 }
1356
1357 $session = &$_SESSION['views'][$this->view->storage->id()][$display_id];
1358
1359 if ($operator && isset($input[$this->options['expose']['operator_id']])) {
1360 $session[$this->options['expose']['operator_id']] = $input[$this->options['expose']['operator_id']];
1361 }
1362
1363 $session[$this->options['expose']['identifier']] = $input[$this->options['expose']['identifier']];
1364 }
1365 }
1366
1367 /**
1368 * Add this filter to the query.
1369 *
1370 * Due to the nature of fapi, the value and the operator have an unintended
1371 * level of indirection. You will find them in $this->operator
1372 * and $this->value respectively.
1373 */
1374 public function query() {
1375 $this->ensureMyTable();
1376 $this->query->add_where($this->options['group'], "$this->tableAlias.$this->realField", $this->value, $this->operator);
1377 }
1378
1379 /**
1380 * Can this filter be used in OR groups?
1381 *
1382 * Some filters have complicated where clauses that cannot be easily used
1383 * with OR groups. Some filters must also use HAVING which also makes
1384 * them not groupable. These filters will end up in a special group
1385 * if OR grouping is in use.
1386 *
1387 * @return bool
1388 */
1389 function can_group() {
1390 return TRUE;
1391 }
1392
1393 }
1394
1395 /**
1396 * @}
1397 */