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_date.inc
11 11
 * @ingroup views_filter_handlers
12 12
 */
13 13
class views_handler_filter_date extends views_handler_filter_numeric {
14
  function option_definition() {
14

  
15
  /**
16
   * {@inheritdoc}
17
   */
18
  public function option_definition() {
15 19
    $options = parent::option_definition();
16 20

  
17
    // value is already set up properly, we're just adding our new field to it.
21
    // Value is already set up properly, we're just adding our new field to it.
18 22
    $options['value']['contains']['type']['default'] = 'date';
19 23

  
20 24
    return $options;
21 25
  }
22 26

  
23 27
  /**
24
   * Add a type selector to the value form
28
   * Add a type selector to the value form.
25 29
   */
26
  function value_form(&$form, &$form_state) {
30
  public function value_form(&$form, &$form_state) {
27 31
    if (empty($form_state['exposed'])) {
28 32
      $form['value']['type'] = array(
29 33
        '#type' => 'radios',
......
38 42
    parent::value_form($form, $form_state);
39 43
  }
40 44

  
41
  function options_validate(&$form, &$form_state) {
45
  /**
46
   * {@inheritdoc}
47
   */
48
  public function options_validate(&$form, &$form_state) {
42 49
    parent::options_validate($form, $form_state);
43 50

  
44 51
    if (!empty($this->options['exposed']) && empty($form_state['values']['options']['expose']['required'])) {
......
49 56
    $this->validate_valid_time($form['value'], $form_state['values']['options']['operator'], $form_state['values']['options']['value']);
50 57
  }
51 58

  
52
  function exposed_validate(&$form, &$form_state) {
59
  /**
60
   * {@inheritdoc}
61
   */
62
  public function exposed_validate(&$form, &$form_state) {
53 63
    if (empty($this->options['exposed'])) {
54 64
      return;
55 65
    }
......
74 84
  /**
75 85
   * Validate that the time values convert to something usable.
76 86
   */
77
  function validate_valid_time(&$form, $operator, $value) {
87
  public function validate_valid_time(&$form, $operator, $value) {
78 88
    $operators = $this->operators();
79 89

  
80 90
    if ($operators[$operator]['values'] == 1) {
......
98 108
  /**
99 109
   * Validate the build group options form.
100 110
   */
101
  function build_group_validate($form, &$form_state) {
111
  public function build_group_validate($form, &$form_state) {
102 112
    // Special case to validate grouped date filters, this is because the
103 113
    // $group['value'] array contains the type of filter (date or offset)
104 114
    // and therefore the number of items the comparission has to be done
......
122 132
    }
123 133
  }
124 134

  
125

  
126
  function accept_exposed_input($input) {
135
  /**
136
   * {@inheritdoc}
137
   */
138
  public function accept_exposed_input($input) {
127 139
    if (empty($this->options['exposed'])) {
128 140
      return TRUE;
129 141
    }
......
152 164
      }
153 165
    }
154 166

  
155
    // restore what got overwritten by the parent.
167
    // Restore what got overwritten by the parent.
156 168
    $this->value['type'] = $type;
157 169
    return $rc;
158 170
  }
159 171

  
160
  function op_between($field) {
172
  /**
173
   *
174
   */
175
  public function op_between($field) {
161 176
    // Use the substitutions to ensure a consistent timestamp.
162 177
    $query_substitutions = views_views_query_substitutions($this->view);
163 178
    $a = intval(strtotime($this->value['min'], $query_substitutions['***CURRENT_TIME***']));
164 179
    $b = intval(strtotime($this->value['max'], $query_substitutions['***CURRENT_TIME***']));
165 180

  
166
    // This is safe because we are manually scrubbing the values.
167
    // It is necessary to do it this way because $a and $b are formulas when using an offset.
181
    // This is safe because we are manually scrubbing the values. It is
182
    // necessary to do it this way because $a and $b are formulas when using an
183
    // offset.
168 184
    $operator = strtoupper($this->operator);
169 185
    $this->query->add_where_expression($this->options['group'], "$field $operator $a AND $b");
170 186
  }
171 187

  
172
  function op_simple($field) {
188
  /**
189
   *
190
   */
191
  public function op_simple($field) {
173 192
    // Use the substitutions to ensure a consistent timestamp.
174 193
    $query_substitutions = views_views_query_substitutions($this->view);
175 194
    $value = intval(strtotime($this->value['value'], $query_substitutions['***CURRENT_TIME***']));
176 195

  
177
    // This is safe because we are manually scrubbing the value.
178
    // It is necessary to do it this way because $value is a formula when using an offset.
196
    // This is safe because we are manually scrubbing the value. It is
197
    // necessary to do it this way because $value is a formula when using an
198
    // offset.
179 199
    $this->query->add_where_expression($this->options['group'], "$field $this->operator $value");
180 200
  }
201

  
181 202
}

Formats disponibles : Unified diff