Projet

Général

Profil

Révision 32700c57

Ajouté par Assos Assos il y a environ 5 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/ldap/ldap_views/handlers/ldap_views_handler_filter.inc
6 6
 * including equality, contains, not contains, etc.
7 7
 */
8 8

  
9
/**
10
 *
11
 */
9 12
class ldap_views_handler_filter extends views_handler_filter {
10
  // exposed filter options
11
  var $always_multiple = TRUE;
13
  /**
14
   * Exposed filter options.
15
   */
16
  public $always_multiple = TRUE;
12 17

  
13
  function option_definition() {
18
  /**
19
   *
20
   */
21
  public function option_definition() {
14 22
    $options = parent::option_definition();
15
    $options['expose']['contains']['required'] = array('default' => FALSE);
23
    $options['expose']['contains']['required'] = ['default' => FALSE];
16 24
    return $options;
17 25
  }
18 26

  
......
21 29
   * to add or remove functionality by overriding this function and
22 30
   * adding/removing items from this array.
23 31
   */
24
  function operators() {
25
    $operators = array(
26
      '=' => array(
32
  public function operators() {
33
    $operators = [
34
      '=' => [
27 35
        'title' => t('Is equal to'),
28 36
        'short' => t('='),
29 37
        'method' => 'op_equal',
30 38
        'values' => 1,
31
      ),
32
      '!=' => array(
39
      ],
40
      '!=' => [
33 41
        'title' => t('Is not equal to'),
34 42
        'short' => t('!='),
35 43
        'method' => 'op_equal',
36 44
        'values' => 1,
37
      ),
38
      'contains' => array(
45
      ],
46
      'contains' => [
39 47
        'title' => t('Contains'),
40 48
        'short' => t('contains'),
41 49
        'method' => 'op_contains',
42 50
        'values' => 1,
43
      ),
44
      'starts' => array(
51
      ],
52
      'starts' => [
45 53
        'title' => t('Starts with'),
46 54
        'short' => t('begins'),
47 55
        'method' => 'op_starts',
48 56
        'values' => 1,
49
      ),
50
      'not_starts' => array(
57
      ],
58
      'not_starts' => [
51 59
        'title' => t('Does not start with'),
52 60
        'short' => t('not_begins'),
53 61
        'method' => 'op_not_starts',
54 62
        'values' => 1,
55
      ),
56
      'ends' => array(
63
      ],
64
      'ends' => [
57 65
        'title' => t('Ends with'),
58 66
        'short' => t('ends'),
59 67
        'method' => 'op_ends',
60 68
        'values' => 1,
61
      ),
62
      'not_ends' => array(
69
      ],
70
      'not_ends' => [
63 71
        'title' => t('Does not end with'),
64 72
        'short' => t('not_ends'),
65 73
        'method' => 'op_not_ends',
66 74
        'values' => 1,
67
      ),
68
      'not' => array(
75
      ],
76
      'not' => [
69 77
        'title' => t('Does not contain'),
70 78
        'short' => t('!has'),
71 79
        'method' => 'op_not',
72 80
        'values' => 1,
73
      ),
74
      'greater' => array(
81
      ],
82
      'greater' => [
75 83
        'title' => t('Greater than or equal to'),
76 84
        'short' => t('greater_eq'),
77 85
        'method' => 'op_greater_eq',
78 86
        'values' => 1,
79
      ),
80
      'less' => array(
87
      ],
88
      'less' => [
81 89
        'title' => t('Less than or equal to'),
82 90
        'short' => t('less_eq'),
83 91
        'method' => 'op_less_eq',
84 92
        'values' => 1,
85
      ),
86
    );
93
      ],
94
    ];
87 95

  
88 96
    return $operators;
89 97
  }
90 98

  
91 99
  /**
92
   * Build strings from the operators() for 'select' options
100
   * Build strings from the operators() for 'select' options.
93 101
   */
94
  function operator_options($which = 'title') {
95
    $options = array();
102
  public function operator_options($which = 'title') {
103
    $options = [];
96 104
    foreach ($this->operators() as $id => $info) {
97 105
      $options[$id] = $info[$which];
98 106
    }
......
100 108
    return $options;
101 109
  }
102 110

  
103
  function admin_summary() {
111
  /**
112
   *
113
   */
114
  public function admin_summary() {
104 115
    if (!empty($this->options['exposed'])) {
105 116
      return t('exposed');
106 117
    }
......
116 127
    return $output;
117 128
  }
118 129

  
119
  function operator_values($values = 1) {
120
    $options = array();
130
  /**
131
   *
132
   */
133
  public function operator_values($values = 1) {
134
    $options = [];
121 135
    foreach ($this->operators() as $id => $info) {
122 136
      if (isset($info['values']) && $info['values'] == $values) {
123 137
        $options[] = $id;
......
128 142
  }
129 143

  
130 144
  /**
131
   * Provide a simple textfield for equality
145
   * Provide a simple textfield for equality.
132 146
   */
133
  function value_form(&$form, &$form_state) {
147
  public function value_form(&$form, &$form_state) {
134 148
    // We have to make some choices when creating this as an exposed
135 149
    // filter form. For example, if the operator is locked and thus
136 150
    // not rendered, we can't render dependencies; instead we only
......
143 157
      $identifier = $this->options['expose']['identifier'];
144 158

  
145 159
      if (empty($this->options['expose']['use_operator']) || empty($this->options['expose']['operator_id'])) {
146
        // exposed and locked.
160
        // Exposed and locked.
147 161
        $which = in_array($this->operator, $this->operator_values(1)) ? 'value' : 'none';
148 162
      }
149 163
      else {
......
152 166
    }
153 167

  
154 168
    if ($which == 'all' || $which == 'value') {
155
      $form['value'] = array(
169
      $form['value'] = [
156 170
        '#type' => 'textfield',
157 171
        '#title' => t('Value'),
158 172
        '#size' => 30,
159 173
        '#default_value' => $this->value,
160
      );
174
      ];
161 175
      if (!empty($form_state['exposed']) && !isset($form_state['input'][$identifier])) {
162 176
        $form_state['input'][$identifier] = $this->value;
163 177
      }
164 178

  
165 179
      if ($which == 'all') {
166
        $form['value'] += array(
167
          '#dependency' => array($source => $this->operator_values(1)),
168
        );
180
        $form['value'] += [
181
          '#dependency' => [$source => $this->operator_values(1)],
182
        ];
169 183
      }
170 184
    }
171 185

  
172 186
    if (!isset($form['value'])) {
173 187
      // Ensure there is something in the 'value'.
174
      $form['value'] = array(
188
      $form['value'] = [
175 189
        '#type' => 'value',
176
        '#value' => NULL
177
      );
190
        '#value' => NULL,
191
      ];
178 192
    }
179 193
  }
180 194

  
......
185 199
   * level of indirection. You will find them in $this->operator
186 200
   * and $this->value respectively.
187 201
   */
188
  function query() {
202
  public function query() {
189 203
    $this->ensure_my_table();
190 204
    $field = $this->real_field;
191 205

  
......
195 209
    }
196 210
  }
197 211

  
198
  function op_equal($field) {
212
  /**
213
   *
214
   */
215
  public function op_equal($field) {
199 216
    $this->query->add_where($this->options['group'], $field, $this->value, $this->operator);
200 217
  }
201 218

  
202
  function op_contains($field) {
219
  /**
220
   *
221
   */
222
  public function op_contains($field) {
203 223
    $this->query->add_where($this->options['group'], $field, "*$this->value*", '=');
204 224
  }
205 225

  
206
  function op_starts($field) {
226
  /**
227
   *
228
   */
229
  public function op_starts($field) {
207 230
    $this->query->add_where($this->options['group'], $field, "$this->value*", '=');
208 231
  }
209 232

  
210
  function op_not_starts($field) {
233
  /**
234
   *
235
   */
236
  public function op_not_starts($field) {
211 237
    $this->query->add_where($this->options['group'], $field, "$this->value*", '!=');
212 238
  }
213 239

  
214
  function op_ends($field) {
240
  /**
241
   *
242
   */
243
  public function op_ends($field) {
215 244
    $this->query->add_where($this->options['group'], $field, "*$this->value", '=');
216 245
  }
217 246

  
218
  function op_not_ends($field) {
247
  /**
248
   *
249
   */
250
  public function op_not_ends($field) {
219 251
    $this->query->add_where($this->options['group'], $field, "*$this->value", '!=');
220 252
  }
221 253

  
222
  function op_not($field) {
254
  /**
255
   *
256
   */
257
  public function op_not($field) {
223 258
    $this->query->add_where($this->options['group'], $field, "*$this->value*", '!=');
224 259
  }
225 260

  
226
  function op_greater_eq($field) {
261
  /**
262
   *
263
   */
264
  public function op_greater_eq($field) {
227 265
    $this->query->add_where($this->options['group'], $field, $this->value, '>=');
228 266
  }
229 267

  
230
  function op_less_eq($field) {
268
  /**
269
   *
270
   */
271
  public function op_less_eq($field) {
231 272
    $this->query->add_where($this->options['group'], $field, $this->value, '<=');
232 273
  }
233 274

  
234
  function op_exists($field) {
275
  /**
276
   *
277
   */
278
  public function op_exists($field) {
235 279
    $this->query->add_where($this->options['group'], $field, '*', $this->operator == 'exists' ? '=' : '!=');
236 280
  }
237 281

  

Formats disponibles : Unified diff