Projet

Général

Profil

Révision 5d12d676

Ajouté par Assos Assos il y a environ 6 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/views/handlers/views_handler_filter.inc
2 2

  
3 3
/**
4 4
 * @file
5
 * @todo.
5
 * Definitions of views_handler_filter and views_handler_filter_broken.
6 6
 */
7 7

  
8 8
/**
......
32 32
 * @ingroup views_filter_handlers
33 33
 */
34 34
class views_handler_filter extends views_handler {
35

  
35 36
  /**
36 37
   * Contains the actual value of the field,either configured in the views ui
37 38
   * or entered in the exposed filters.
39
   *
40
   * @var mixed
38 41
   */
39
  var $value = NULL;
42
  public $value = NULL;
40 43

  
41 44
  /**
42 45
   * Contains the operator which is used on the query.
46
   *
47
   * @var string
43 48
   */
44
  var $operator = '=';
49
  public $operator = '=';
45 50

  
46 51
  /**
47 52
   * Contains the information of the selected item in a gruped filter.
53
   *
54
   * @var array|null
48 55
   */
49
  var $group_info = NULL;
56
  public $group_info = NULL;
50 57

  
51 58
  /**
52
   * @var bool
53 59
   * Disable the possibility to force a single value.
60
   *
61
   * @var bool
54 62
   */
55
  var $always_multiple = FALSE;
63
  public $always_multiple = FALSE;
56 64

  
57 65
  /**
58
   * @var bool
59 66
   * Disable the possibility to use operators.
67
   *
68
   * @var bool
60 69
   */
61
  var $no_operator = FALSE;
70
  public $no_operator = FALSE;
62 71

  
63 72
  /**
64
   * @var bool
65 73
   * Disable the possibility to allow a exposed input to be optional.
74
   *
75
   * @var bool
66 76
   */
67
  var $always_required = FALSE;
77
  public $always_required = FALSE;
68 78

  
69 79
  /**
70 80
   * Provide some extra help to get the operator/value easier to use.
......
72 82
   * This likely has to be overridden by filters which are more complex
73 83
   * than simple operator/value.
74 84
   */
75
  function init(&$view, &$options) {
85
  public function init(&$view, &$options) {
76 86
    parent::init($view, $options);
77 87

  
78 88
    $this->operator = $this->options['operator'];
......
107 117
    }
108 118
  }
109 119

  
110
  function option_definition() {
120
  /**
121
   * {@inheritdoc}
122
   */
123
  public function option_definition() {
111 124
    $options = parent::option_definition();
112 125

  
113 126
    $options['operator'] = array('default' => '=');
......
160 173
  }
161 174

  
162 175
  /**
163
   * Display the filter on the administrative summary
176
   * Display the filter on the administrative summary.
164 177
   */
165
  function admin_summary() {
178
  public function admin_summary() {
166 179
    return check_plain((string) $this->operator) . ' ' . check_plain((string) $this->value);
167 180
  }
168 181

  
169 182
  /**
170 183
   * Determine if a filter can be exposed.
171 184
   */
172
  function can_expose() { return TRUE; }
185
  public function can_expose() {
186
    return TRUE;
187
  }
173 188

  
174 189
  /**
175 190
   * Determine if a filter can be converted into a group.
191
   *
176 192
   * Only exposed filters with operators available can be converted into groups.
177 193
   */
178
  function can_build_group() {
194
  public function can_build_group() {
179 195
    return $this->is_exposed() && (count($this->operator_options()) > 0);
180 196
  }
181 197

  
182 198
  /**
183 199
   * Returns TRUE if the exposed filter works like a grouped filter.
184 200
   */
185
  function is_a_group() {
201
  public function is_a_group() {
186 202
    return $this->is_exposed() && !empty($this->options['is_grouped']);
187 203
  }
188 204

  
189 205
  /**
190 206
   * Provide the basic form which calls through to subforms.
207
   *
191 208
   * If overridden, it is best to call through to the parent,
192 209
   * or to at least make sure all of the functions in this form
193 210
   * are called.
194 211
   */
195
  function options_form(&$form, &$form_state) {
212
  public function options_form(&$form, &$form_state) {
196 213
    parent::options_form($form, $form_state);
197 214
    if ($this->can_expose()) {
198 215
      $this->show_expose_button($form, $form_state);
......
233 250
  /**
234 251
   * Simple validate handler
235 252
   */
236
  function options_validate(&$form, &$form_state) {
253
  public function options_validate(&$form, &$form_state) {
237 254
    $this->operator_validate($form, $form_state);
238 255
    $this->value_validate($form, $form_state);
239 256
    if (!empty($this->options['exposed']) && !$this->is_a_group()) {
......
245 262
  }
246 263

  
247 264
  /**
248
   * Simple submit handler
265
   * Simple submit handler.
249 266
   */
250
  function options_submit(&$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.
267
  public function options_submit(&$form, &$form_state) {
268
    // Don't store these.
269
    unset($form_state['values']['expose_button']);
270
    unset($form_state['values']['group_button']);
271

  
253 272
    if (!$this->is_a_group()) {
254 273
      $this->operator_submit($form, $form_state);
255 274
      $this->value_submit($form, $form_state);
......
265 284
  /**
266 285
   * Shortcut to display the operator form.
267 286
   */
268
  function show_operator_form(&$form, &$form_state) {
287
  public function show_operator_form(&$form, &$form_state) {
269 288
    $this->operator_form($form, $form_state);
270 289
    $form['operator']['#prefix'] = '<div class="views-group-box views-left-30">';
271 290
    $form['operator']['#suffix'] = '</div>';
......
279 298
   *
280 299
   * @see options_form()
281 300
   */
282
  function operator_form(&$form, &$form_state) {
301
  public function operator_form(&$form, &$form_state) {
283 302
    $options = $this->operator_options();
284 303
    if (!empty($options)) {
285 304
      $form['operator'] = array(
......
293 312

  
294 313
  /**
295 314
   * Provide a list of options for the default operator form.
315
   *
296 316
   * Should be overridden by classes that don't override operator_form
297 317
   */
298
  function operator_options() { return array(); }
318
  public function operator_options() {
319
    return array();
320
  }
299 321

  
300 322
  /**
301 323
   * Validate the operator form.
302 324
   */
303
  function operator_validate($form, &$form_state) { }
325
  public function operator_validate($form, &$form_state) {
326
  }
304 327

  
305 328
  /**
306 329
   * Perform any necessary changes to the form values prior to storage.
330
   *
307 331
   * There is no need for this function to actually store the data.
308 332
   */
309
  function operator_submit($form, &$form_state) { }
333
  public function operator_submit($form, &$form_state) {
334
  }
310 335

  
311 336
  /**
312 337
   * Shortcut to display the value form.
313 338
   */
314
  function show_value_form(&$form, &$form_state) {
339
  public function show_value_form(&$form, &$form_state) {
315 340
    $this->value_form($form, $form_state);
316 341
    if (empty($this->no_operator)) {
317 342
      $form['value']['#prefix'] = '<div class="views-group-box views-right-70">' . (isset($form['value']['#prefix']) ? $form['value']['#prefix'] : '');
......
322 347
  /**
323 348
   * Options form subform for setting options.
324 349
   *
325
   * This should be overridden by all child classes and it must
326
   * define $form['value']
350
   * This should be overridden by all child classes and it must define
351
   * $form['value'].
327 352
   *
328 353
   * @see options_form()
329 354
   */
330
  function value_form(&$form, &$form_state) { $form['value'] = array(); }
355
  public function value_form(&$form, &$form_state) {
356
    $form['value'] = array();
357
  }
331 358

  
332 359
  /**
333 360
   * Validate the options form.
334 361
   */
335
  function value_validate($form, &$form_state) { }
362
  public function value_validate($form, &$form_state) {
363
  }
336 364

  
337 365
  /**
338 366
   * Perform any necessary changes to the form values prior to storage.
367
   *
339 368
   * There is no need for this function to actually store the data.
340 369
   */
341
  function value_submit($form, &$form_state) { }
370
  public function value_submit($form, &$form_state) {
371
  }
342 372

  
343 373
  /**
344 374
   * Shortcut to display the exposed options form.
345 375
   */
346
  function show_build_group_form(&$form, &$form_state) {
376
  public function show_build_group_form(&$form, &$form_state) {
347 377
    if (empty($this->options['is_grouped'])) {
348 378
      return;
349 379
    }
......
366 396
  /**
367 397
   * Shortcut to display the build_group/hide button.
368 398
   */
369
  function show_build_group_button(&$form, &$form_state) {
370

  
399
  public function show_build_group_button(&$form, &$form_state) {
371 400
    $form['group_button'] = array(
372 401
      '#prefix' => '<div class="views-grouped clearfix">',
373 402
      '#suffix' => '</div>',
......
412 441
      $form['group_button']['radios']['radios']['#default_value'] = 1;
413 442
    }
414 443
  }
444

  
415 445
  /**
416 446
   * Shortcut to display the expose/hide button.
417 447
   */
418
  function show_expose_button(&$form, &$form_state) {
448
  public function show_expose_button(&$form, &$form_state) {
419 449
    $form['expose_button'] = array(
420 450
      '#prefix' => '<div class="views-expose clearfix">',
421 451
      '#suffix' => '</div>',
......
423 453
      '#weight' => -200,
424 454
    );
425 455

  
426
    // Add a checkbox for JS users, which will have behavior attached to it
427
    // so it can replace the button.
456
    // Add a checkbox for JS users, which will have behavior attached to it so
457
    // it can replace the button.
428 458
    $form['expose_button']['checkbox'] = array(
429 459
      '#theme_wrappers' => array('container'),
430 460
      '#attributes' => array('class' => array('js-only')),
......
466 496
   *
467 497
   * @see options_form()
468 498
   */
469
  function expose_form(&$form, &$form_state) {
499
  public function expose_form(&$form, &$form_state) {
470 500
    $form['#theme'] = 'views_ui_expose_filter_form';
471 501
    // #flatten will move everything from $form['expose'][$key] to $form[$key]
472 502
    // prior to rendering. That's why the pre_render for it needs to run first,
......
566 596
      '#description' => t('Remember exposed selection only for the selected user role(s). If you select no roles, the exposed data will never be stored.'),
567 597
      '#default_value' => $this->options['expose']['remember_roles'],
568 598
      '#options' => $role_options,
569
      '#dependency' =>  array(
599
      '#dependency' => array(
570 600
        'edit-options-expose-remember' => array(1),
571 601
      ),
572 602
    );
......
584 614
  /**
585 615
   * Validate the options form.
586 616
   */
587
  function expose_validate($form, &$form_state) {
617
  public function expose_validate($form, &$form_state) {
588 618
    if (empty($form_state['values']['options']['expose']['identifier'])) {
589 619
      form_error($form['expose']['identifier'], t('The identifier is required if the filter is exposed.'));
590 620
    }
......
601 631
    }
602 632
  }
603 633

  
604
   /**
634
  /**
605 635
   * Validate the build group options form.
606 636
   */
607
  function build_group_validate($form, &$form_state) {
637
  public function build_group_validate($form, &$form_state) {
608 638
    if (!empty($form_state['values']['options']['group_info'])) {
609 639
      if (empty($form_state['values']['options']['group_info']['identifier'])) {
610 640
        form_error($form['group_info']['identifier'], t('The identifier is required if the filter is exposed.'));
......
625 655
    if (!empty($form_state['values']['options']['group_info']['group_items'])) {
626 656
      foreach ($form_state['values']['options']['group_info']['group_items'] as $id => $group) {
627 657
        if (empty($group['remove'])) {
628

  
629 658
          // Check if the title is defined but value wasn't defined.
630 659
          if (!empty($group['title'])) {
631 660
            if ((!is_array($group['value']) && trim($group['value']) == "") ||
632 661
                (is_array($group['value']) && count(array_filter($group['value'], '_views_array_filter_zero')) == 0)) {
633 662
              form_error($form['group_info']['group_items'][$id]['value'],
634
                         t('The value is required if title for this item is defined.'));
663
                t('The value is required if title for this item is defined.'));
635 664
            }
636 665
          }
637 666

  
......
640 669
              (is_array($group['value']) && count(array_filter($group['value'], '_views_array_filter_zero')) > 0)) {
641 670
            if (empty($group['title'])) {
642 671
              form_error($form['group_info']['group_items'][$id]['title'],
643
                         t('The title is required if value for this item is defined.'));
672
                t('The title is required if value for this item is defined.'));
644 673
            }
645 674
          }
646 675
        }
......
651 680
  /**
652 681
   * Save new group items, re-enumerates and remove groups marked to delete.
653 682
   */
654
  function build_group_submit($form, &$form_state) {
683
  public function build_group_submit($form, &$form_state) {
655 684
    $groups = array();
656 685
    uasort($form_state['values']['options']['group_info']['group_items'], 'drupal_sort_weight');
657
    // Filter out removed items.
658 686

  
687
    // Filter out removed items.
659 688
    // Start from 1 to avoid problems with #default_value in the widget.
660 689
    $new_id = 1;
661 690
    $new_default = 'All';
......
684 713
  /**
685 714
   * Provide default options for exposed filters.
686 715
   */
687
  function expose_options() {
716
  public function expose_options() {
688 717
    $this->options['expose'] = array(
689 718
      'use_operator' => FALSE,
690 719
      'operator' => $this->options['id'] . '_op',
......
697 726
    );
698 727
  }
699 728

  
700
   /**
729
  /**
701 730
   * Provide default options for exposed filters.
702 731
   */
703
  function build_group_options() {
732
  public function build_group_options() {
704 733
    $this->options['group_info'] = array(
705 734
      'label' => $this->definition['title'],
706 735
      'description' => NULL,
......
716 745
  }
717 746

  
718 747
  /**
719
   * Build a form containing a group of operator | values to apply as a
720
   * single filter.
748
   * Build a form with a group of operator | values to apply as a single filter.
721 749
   */
722
  function group_form(&$form, &$form_state) {
750
  public function group_form(&$form, &$form_state) {
723 751
    if (!empty($this->options['group_info']['optional']) && !$this->multiple_exposed_input()) {
724

  
725 752
      $old_any = $this->options['group_info']['widget'] == 'select' ? '<Any>' : '&lt;Any&gt;';
726 753
      $any_label = variable_get('views_exposed_filter_any_label', 'new_any') == 'old_any' ? $old_any : t('- Any -');
727 754
      $groups = array('All' => $any_label);
......
750 777
          $form[$value]['#multiple'] = TRUE;
751 778
        }
752 779
        unset($form[$value]['#default_value']);
753
        if (empty($form_state['input'])) {
780
        if (empty($form_state['input'][$value])) {
754 781
          $form_state['input'][$value] = $this->group_info;
755 782
        }
756 783
      }
......
765 792
   *
766 793
   * You can override this if it doesn't do what you expect.
767 794
   */
768
  function exposed_form(&$form, &$form_state) {
795
  public function exposed_form(&$form, &$form_state) {
769 796
    if (empty($this->options['exposed'])) {
770 797
      return;
771 798
    }
......
811 838

  
812 839
  /**
813 840
   * Build the form to let users create the group of exposed filters.
841
   *
814 842
   * This form is displayed when users click on button 'Build group'
815 843
   */
816
  function build_group_form(&$form, &$form_state) {
844
  public function build_group_form(&$form, &$form_state) {
817 845
    if (empty($this->options['exposed']) || empty($this->options['is_grouped'])) {
818 846
      return;
819 847
    }
820 848
    $form['#theme'] = 'views_ui_build_group_filter_form';
821 849

  
822
    // #flatten will move everything from $form['group_info'][$key] to $form[$key]
823
    // prior to rendering. That's why the pre_render for it needs to run first,
824
    // so that when the next pre_render (the one for fieldsets) runs, it gets
825
    // the flattened data.
850
    // #flatten will move everything from $form['group_info'][$key] to
851
    // $form[$key] prior to rendering. That's why the pre_render for it needs
852
    // to run first, so that when the next pre_render (the one for fieldsets)
853
    // runs, it gets the flattened data.
826 854
    array_unshift($form['#pre_render'], 'views_ui_pre_render_flatten_data');
827 855
    $form['group_info']['#flatten'] = TRUE;
828 856

  
......
925 953
      '#default_value' => $this->options['group_info']['remember'],
926 954
    );
927 955

  
928
    $groups = array('All' => '- Any -'); // The string '- Any -' will not be rendered see @theme_views_ui_build_group_filter_form
956
    // The string '- Any -' will not be rendered.
957
    // @see theme_views_ui_build_group_filter_form()
958
    $groups = array('All' => '- Any -'); 
929 959

  
930 960
    // Provide 3 options to start when we are in a new group.
931 961
    if (count($this->options['group_info']['group_items']) == 0) {
......
939 969
        continue;
940 970
      }
941 971
      // Each rows contains three widgets:
942
      // a) The title, where users define how they identify a pair of operator | value
943
      // b) The operator
944
      // c) The value (or values) to use in the filter with the selected operator
945

  
972
      // a) The title, where users define how they identify a pair of operator
973
      //    | value.
974
      // b) The operator.
975
      // c) The value (or values) to use in the filter with the selected
976
      //    operator.
946 977
      // In each row, we have to display the operator form and the value from
947 978
      // $row acts as a fake form to render each widget in a row.
948 979
      $row = array();
......
954 985
      $row['operator']['#title'] = '';
955 986
      $this->value_form($row, $form_state);
956 987

  
957
      // Fix the dependencies to update value forms when operators
958
      // changes. This is needed because forms are inside a new form and
959
      // their ids changes. Dependencies are used when operator changes
960
      // from to 'Between', 'Not Between', etc, and two or more widgets
961
      // are displayed.
988
      // Fix the dependencies to update value forms when operators changes.
989
      // This is needed because forms are inside a new form and their ids
990
      // changes. Dependencies are used when operator changes from to
991
      // 'Between', 'Not Between', etc, and two or more widgets are displayed.
962 992
      $without_children = TRUE;
963 993
      foreach (element_children($row['value']) as $children) {
964 994
        if (isset($row['value'][$children]['#dependency']['edit-options-operator'])) {
......
1005 1035
        ),
1006 1036
        'weight' => array(
1007 1037
          '#type' => 'weight',
1008
          '#delta' => 10,
1038
          '#delta' => count($this->options['group_info']['group_items']),
1009 1039
          '#default_value' => $default_weight++,
1010 1040
          '#attributes' => array('class' => array('weight')),
1011 1041
        ),
......
1058 1088

  
1059 1089

  
1060 1090
  /**
1061
   * Make some translations to a form item to make it more suitable to
1062
   * exposing.
1091
   * Make some translations to a form item to make it more suitable to exposing.
1063 1092
   */
1064
  function exposed_translate(&$form, $type) {
1093
  public function exposed_translate(&$form, $type) {
1065 1094
    if (!isset($form['#type'])) {
1066 1095
      return;
1067 1096
    }
......
1083 1112
      $form['#size'] = NULL;
1084 1113
    }
1085 1114

  
1086
    // Cleanup in case the translated element's (radios or checkboxes) display value contains html.
1115
    // Cleanup in case the translated element's (radios or checkboxes) display
1116
    // value contains html.
1087 1117
    if ($form['#type'] == 'select') {
1088 1118
      $this->prepare_filter_select_options($form['#options']);
1089 1119
    }
......
1099 1129
    }
1100 1130
  }
1101 1131

  
1102

  
1103

  
1104 1132
  /**
1105 1133
   * Sanitizes the HTML select element's options.
1106 1134
   *
1107 1135
   * The function is recursive to support optgroups.
1108 1136
   */
1109
  function prepare_filter_select_options(&$options) {
1137
  public function prepare_filter_select_options(&$options) {
1110 1138
    foreach ($options as $value => $label) {
1111 1139
      // Recurse for optgroups.
1112 1140
      if (is_array($label)) {
1113 1141
        $this->prepare_filter_select_options($options[$value]);
1114 1142
      }
1115 1143
      // FAPI has some special value to allow hierarchy.
1116
      // @see _form_options_flatten
1144
      // @see _form_options_flatten()
1117 1145
      elseif (is_object($label)) {
1118 1146
        $this->prepare_filter_select_options($options[$value]->option);
1119 1147
      }
......
1124 1152
  }
1125 1153

  
1126 1154
  /**
1127
   * Tell the renderer about our exposed form. This only needs to be
1128
   * overridden for particularly complex forms. And maybe not even then.
1155
   * Tell the renderer about our exposed form.
1156
   *
1157
   * This only needs to be overridden for particularly complex forms. And maybe
1158
   * not even then.
1129 1159
   *
1130 1160
   * @return array|null
1131 1161
   *   For standard exposed filters. An array with the following keys:
......
1136 1166
   *   - value: The $form key of the value. Set to NULL if no value.
1137 1167
   *   - label: The label to use for this piece.
1138 1168
   */
1139
  function exposed_info() {
1169
  public function exposed_info() {
1140 1170
    if (empty($this->options['exposed'])) {
1141 1171
      return;
1142 1172
    }
......
1157 1187
    );
1158 1188
  }
1159 1189

  
1160
  /*
1190
  /**
1161 1191
   * Transform the input from a grouped filter into a standard filter.
1162 1192
   *
1163 1193
   * When a filter is a group, find the set of operator and values
......
1168 1198
   * checkboxes widget, and this function will be called for each item
1169 1199
   * choosed in the checkboxes.
1170 1200
   */
1171
  function convert_exposed_input(&$input, $selected_group_id = NULL) {
1201
  public function convert_exposed_input(&$input, $selected_group_id = NULL) {
1172 1202
    if ($this->is_a_group()) {
1173
      // If it is already defined the selected group, use it. Only valid
1174
      // when the filter uses checkboxes for widget.
1203
      // If it is already defined the selected group, use it. Only valid when
1204
      // the filter uses checkboxes for widget.
1175 1205
      if (!empty($selected_group_id)) {
1176 1206
        $selected_group = $selected_group_id;
1177 1207
      }
......
1187 1217
      if (isset($selected_group) && isset($this->options['group_info']['group_items'][$selected_group])) {
1188 1218
        $input[$this->options['expose']['operator']] = $this->options['group_info']['group_items'][$selected_group]['operator'];
1189 1219

  
1190
        // Value can be optional, For example for 'empty' and 'not empty' filters.
1220
        // Value can be optional, For example for 'empty' and 'not empty'
1221
        // filters.
1191 1222
        if (!empty($this->options['group_info']['group_items'][$selected_group]['value'])) {
1192 1223
          $input[$this->options['expose']['identifier']] = $this->options['group_info']['group_items'][$selected_group]['value'];
1193 1224
        }
......
1207 1238
   * as widget, and therefore has to be applied several times, one per
1208 1239
   * item selected.
1209 1240
   */
1210
  function group_multiple_exposed_input(&$input) {
1241
  public function group_multiple_exposed_input(&$input) {
1211 1242
    if (!empty($input[$this->options['group_info']['identifier']])) {
1212 1243
      return array_filter($input[$this->options['group_info']['identifier']]);
1213 1244
    }
......
1215 1246
  }
1216 1247

  
1217 1248
  /**
1218
   * Returns TRUE if users can select multiple groups items of a
1219
   * grouped exposed filter.
1249
   *
1250
   *
1251
   * @return bool
1252
   *   TRUE if users can select multiple groups items of a grouped exposed
1253
   *   filter.
1220 1254
   */
1221
  function multiple_exposed_input() {
1255
  public function multiple_exposed_input() {
1222 1256
    return $this->is_a_group() && !empty($this->options['group_info']['multiple']);
1223 1257
  }
1224 1258

  
......
1227 1261
   * This function is similar to store_exposed_input but modified to
1228 1262
   * work properly when the filter is a group.
1229 1263
   */
1230
  function store_group_input($input, $status) {
1264
  public function store_group_input($input, $status) {
1231 1265
    if (!$this->is_a_group() || empty($this->options['group_info']['identifier'])) {
1232 1266
      return TRUE;
1233 1267
    }
......
1236 1270
      return;
1237 1271
    }
1238 1272

  
1239
    // Figure out which display id is responsible for the filters, so we
1240
    // know where to look for session stored values.
1273
    // Figure out which display id is responsible for the filters, so we know
1274
    // where to look for session stored values.
1241 1275
    $display_id = ($this->view->display_handler->is_defaulted('filters')) ? 'default' : $this->view->current_display;
1242 1276

  
1243
    // false means that we got a setting that means to recuse ourselves,
1244
    // so we should erase whatever happened to be there.
1277
    // False means that we got a setting that means to recuse ourselves, so we
1278
    // should erase whatever happened to be there.
1245 1279
    if ($status === FALSE && isset($_SESSION['views'][$this->view->name][$display_id])) {
1246 1280
      $session = &$_SESSION['views'][$this->view->name][$display_id];
1247 1281

  
......
1262 1296
  }
1263 1297

  
1264 1298
  /**
1265
   * Check to see if input from the exposed filters should change
1266
   * the behavior of this filter.
1299
   * Check to see if input from the exposed filters should change the behavior.
1267 1300
   */
1268
  function accept_exposed_input($input) {
1301
  public function accept_exposed_input($input) {
1269 1302
    if (empty($this->options['exposed'])) {
1270 1303
      return TRUE;
1271 1304
    }
1272 1305

  
1273

  
1274 1306
    if (!empty($this->options['expose']['use_operator']) && !empty($this->options['expose']['operator_id']) && isset($input[$this->options['expose']['operator_id']])) {
1275 1307
      $this->operator = $input[$this->options['expose']['operator_id']];
1276 1308
    }
......
1295 1327
        }
1296 1328
      }
1297 1329

  
1298

  
1299 1330
      if (isset($value)) {
1300 1331
        $this->value = $value;
1301 1332
        if (empty($this->always_multiple) && empty($this->options['expose']['multiple'])) {
......
1310 1341
    return TRUE;
1311 1342
  }
1312 1343

  
1313
  function store_exposed_input($input, $status) {
1344
  /**
1345
   *
1346
   */
1347
  public function store_exposed_input($input, $status) {
1314 1348
    if (empty($this->options['exposed']) || empty($this->options['expose']['identifier'])) {
1315 1349
      return TRUE;
1316 1350
    }
......
1327 1361
      return;
1328 1362
    }
1329 1363

  
1330
    // Figure out which display id is responsible for the filters, so we
1331
    // know where to look for session stored values.
1364
    // Figure out which display id is responsible for the filters, so we know
1365
    // where to look for session stored values.
1332 1366
    $display_id = ($this->view->display_handler->is_defaulted('filters')) ? 'default' : $this->view->current_display;
1333 1367

  
1334
    // shortcut test.
1368
    // Shortcut test.
1335 1369
    $operator = !empty($this->options['expose']['use_operator']) && !empty($this->options['expose']['operator_id']);
1336 1370

  
1337
    // false means that we got a setting that means to recuse ourselves,
1338
    // so we should erase whatever happened to be there.
1371
    // False means that we got a setting that means to recuse ourselves, so we
1372
    // should erase whatever happened to be there.
1339 1373
    if (!$status && isset($_SESSION['views'][$this->view->name][$display_id])) {
1340 1374
      $session = &$_SESSION['views'][$this->view->name][$display_id];
1341 1375
      if ($operator && isset($session[$this->options['expose']['operator_id']])) {
......
1366 1400
   * Add this filter to the query.
1367 1401
   *
1368 1402
   * Due to the nature of fapi, the value and the operator have an unintended
1369
   * level of indirection. You will find them in $this->operator
1370
   * and $this->value respectively.
1403
   * level of indirection. You will find them in $this->operator and
1404
   * $this->value respectively.
1371 1405
   */
1372
  function query() {
1406
  public function query() {
1373 1407
    $this->ensure_my_table();
1374 1408
    $this->query->add_where($this->options['group'], "$this->table_alias.$this->real_field", $this->value, $this->operator);
1375 1409
  }
......
1377 1411
  /**
1378 1412
   * Can this filter be used in OR groups?
1379 1413
   *
1380
   * Some filters have complicated where clauses that cannot be easily used
1381
   * with OR groups. Some filters must also use HAVING which also makes
1382
   * them not groupable. These filters will end up in a special group
1383
   * if OR grouping is in use.
1414
   * Some filters have complicated where clauses that cannot be easily used with
1415
   * OR groups. Some filters must also use HAVING which also makes them not
1416
   * groupable. These filters will end up in a special group if OR grouping is
1417
   * in use.
1384 1418
   *
1385 1419
   * @return bool
1420
   *   Whether the filter can be used in OR groups.
1386 1421
   */
1387
   function can_group() {
1422
   public function can_group() {
1388 1423
     return TRUE;
1389 1424
   }
1425

  
1390 1426
}
1391 1427

  
1392 1428

  
......
1396 1432
 * @ingroup views_filter_handlers
1397 1433
 */
1398 1434
class views_handler_filter_broken extends views_handler_filter {
1399
  function ui_name($short = FALSE) {
1435

  
1436
  /**
1437
   * {@inheritdoc}
1438
   */
1439
  public function ui_name($short = FALSE) {
1400 1440
    return t('Broken/missing handler');
1401 1441
  }
1402 1442

  
1403
  function ensure_my_table() { /* No table to ensure! */ }
1404
  function query($group_by = FALSE) { /* No query to run */ }
1405
  function options_form(&$form, &$form_state) {
1443
  /**
1444
   * {@inheritdoc}
1445
   */
1446
  public function ensure_my_table() {
1447
    // No table to ensure!
1448
  }
1449

  
1450
  /**
1451
   * {@inheritdoc}
1452
   */
1453
  public function query($group_by = FALSE) {
1454
    // No query to run.
1455
  }
1456

  
1457
  /**
1458
   * {@inheritdoc}
1459
   */
1460
  public function options_form(&$form, &$form_state) {
1406 1461
    $form['markup'] = array(
1407 1462
      '#markup' => '<div class="form-item description">' . t('The handler for this item is broken or missing and cannot be used. If a module provided the handler and was disabled, re-enabling the module may restore it. Otherwise, you should probably delete this item.') . '</div>',
1408 1463
    );
1409 1464
  }
1410 1465

  
1411 1466
  /**
1412
   * Determine if the handler is considered 'broken'
1467
   * {@inheritdoc}
1413 1468
   */
1414
  function broken() { return TRUE; }
1469
  public function broken() {
1470
    return TRUE;
1471
  }
1472

  
1415 1473
}
1416 1474

  
1417 1475
/**
1418 1476
 * Filter by no empty values, though allow to use "0".
1419
 * @param $var
1477
 *
1478
 * @param string $var
1479
 *
1420 1480
 * @return bool
1421 1481
 */
1422 1482
function _views_array_filter_zero($var) {

Formats disponibles : Unified diff