Projet

Général

Profil

Révision 8c72e82a

Ajouté par Assos Assos il y a environ 7 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/webform/components/date.inc
70 70
    '#type' => 'radios',
71 71
    '#title' => t('Default value timezone'),
72 72
    '#default_value' => empty($component['extra']['timezone']) ? 'user' : $component['extra']['timezone'],
73
    '#description' => t('If using relative dates for a default value (e.g. "today") base the current day on this timezone.'),
73
    '#description' => t('If using relative dates for a default value (for example, "today") base the current day on this timezone.'),
74 74
    '#options' => array('user' => t('User timezone'), 'site' => t('Website timezone')),
75 75
    '#weight' => 2,
76 76
    '#access' => variable_get('configurable_timezones', 1),
......
131 131
}
132 132

  
133 133
/**
134
 * Implements hook_form_id_validate.
134
 * Implements hook_form_id_validate().
135 135
 *
136 136
 * Warns user about hiding all the date fields and not using the date picker.
137 137
 */
......
140 140
  form_set_value($form['extra']['exclude'], array_filter(array_values($form_state['values']['extra']['exclude'])), $form_state);
141 141

  
142 142
  // Note that Drupal 7 doesn't support setting errors no checkboxes due to
143
  // browser issues. @see https://www.drupal.org/node/222380
143
  // browser issues. See: https://www.drupal.org/node/222380
144 144
  if (count($form_state['values']['extra']['exclude']) == 3) {
145 145
    form_set_error('extra][exclude', 'The day, month and year can\'t all be hidden.');
146 146
  }
......
155 155
  foreach (array('start_date', 'end_date') as $field) {
156 156
    if (trim($form_state['values']['extra'][$field]) && !($date[$field] = webform_strtodate('c', $form_state['values']['extra'][$field]))) {
157 157
      form_set_error("extra][$field", t('The @field could not be interpreted in <a href="http://www.gnu.org/software/tar/manual/html_chapter/Date-input-formats.html">GNU Date Input Format</a>.',
158
                                                 array('@field' => $form['validation'][$field]['#title'])));
158
      array('@field' => $form['validation'][$field]['#title'])));
159 159
    }
160 160
  }
161 161
  if (!empty($date['start_date']) && !empty($date['end_date']) && $date['end_date'] < $date['start_date']) {
......
213 213
 */
214 214
function webform_expand_date($element) {
215 215
  $timezone = $element['#timezone'] != 'user' ? NULL : 'user';
216
  
216

  
217 217
  // Accept a string or array value for #default_value.
218 218
  if (!empty($element['#default_value']) && is_string($element['#default_value'])) {
219 219
    $timestring = webform_strtodate('c', $element['#default_value'], $timezone);
......
281 281
      }
282 282
      else {
283 283
        $month_options = array_intersect_key($month_options, array_flip(range($range['start']['month'], 12))) +
284
                         array_intersect_key($month_options, array_flip(range(1, $range['end']['month'])));
284
          array_intersect_key($month_options, array_flip(range(1, $range['end']['month'])));
285 285
      }
286 286
      unset($month_options); // Drop PHP reference.
287 287
      if ($delta_months <= 1) {
......
297 297
          // Range spans two months and at least one day would be omitted.
298 298
          $days_in_month = date('t', mktime(0, 0, 0, $range['start']['month'], 1, $range['start']['year']));
299 299
          $day_options = array_intersect_key($day_options, array_flip(range($range['start']['day'], $days_in_month))) +
300
                         array_intersect_key($day_options, array_flip(range(1, $range['end']['day'])));
300
            array_intersect_key($day_options, array_flip(range(1, $range['end']['day'])));
301 301
        }
302 302
        unset($day_options); // Drop PHP reference.
303 303
      }
......
423 423
      return;
424 424
    }
425 425

  
426
    // Ensure date is made up of integers.
427
    foreach (array('year', 'month', 'day') as $date_part) {
428
      $element[$date_part]['#value'] = (int) $element[$date_part]['#value'];
429
    }
430

  
426 431
    // Check for a valid date.
427 432
    if (!checkdate($element['month']['#value'], $element['day']['#value'], $element['year']['#value'])) {
428 433
      form_error($element, t('Entered !name is not a valid date.', array('!name' => $element['#title'])));

Formats disponibles : Unified diff