Projet

Général

Profil

Révision 65389548

Ajouté par Assos Assos il y a plus de 4 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/webform_validation/webform_validation.validators.inc
36 36
        'textfield',
37 37
      ),
38 38
      'custom_data' => array(
39
        'label' => t('Specify numeric validation range'),
40
        'description' => t('Optionally specify the minimum-maximum range to validate the user-entered numeric value against. Usage:') . theme('item_list', array('items' => array(t('empty: no value validation'), t('"100": greater than or equal to 100'), t('"|100": less than or equal to 100 (including negative numbers)'), t('"0|100": greater than or equal to 0 & less than or equal to 100'), t('"10|100": greater than or equal to 10 & less than or equal to 100'), t('"-100|-10": greater than or equal to -100 & less than or equal to -10')))),
39
        'label' => t('Numeric validation range'),
40
        'description' => t('Optionally specify the minimum-maximum range to validate the user-entered numeric value against. Usage:') . theme('table', array(
41
          'header' => array(t('Value'), t('Meaning')),
42
          'rows' => array(
43
            array(t('(empty)'), t('No value validation')),
44
            array('100', t('Greater than or equal to 100')),
45
            array('|100', t('Less than or equal to 100 (including negative numbers)')),
46
            array('0|100', t('Greater than or equal to 0 & less than or equal to 100')),
47
            array('10|100', t('Greater than or equal to 10 & less than or equal to 100')),
48
            array('-100|-10', t('Greater than or equal to -100 & less than or equal to -10')),
49
          ),
50
        )),
51
        'validate_regex' => '/^((-?[\d.]+)?\|)?(-?[\d.]+)$/',
41 52
        'required' => FALSE,
42 53
      ),
43 54
      'description' => t('Verifies that user-entered values are numeric, with the option to specify min and / or max values.'),
......
54 65
      'custom_data' => array(
55 66
        'label' => t('Minimum number of characters'),
56 67
        'description' => t('Specify the minimum number of characters that have to be entered to pass validation.'),
68
        'validate_regex' => '/^\d+$/',
57 69
      ),
58 70
      'description' => t('Verifies that a user-entered value contains at least the specified number of characters.'),
59 71
    ),
......
69 81
      'custom_data' => array(
70 82
        'label' => t('Maximum number of characters'),
71 83
        'description' => t('Specify the maximum number of characters that can be entered to pass validation.'),
84
        'validate_regex' => '/^\d+$/',
72 85
      ),
73 86
      'description' => t('Verifies that a user-entered value contains at most the specified number of characters.'),
74 87
    ),
......
83 96
      'custom_data' => array(
84 97
        'label' => t('Minimum number of words'),
85 98
        'description' => t('Specify the minimum number of words that have to be entered to pass validation. Words are defined as strings of letters separated by spaces.'),
99
        'validate_regex' => '/^\d+$/',
86 100
      ),
87 101
      'description' => t('Verifies that a user-entered value contains at least the specified number of words.'),
88 102
    ),
......
97 111
      'custom_data' => array(
98 112
        'label' => t('Maximum number of words'),
99 113
        'description' => t('Specify the maximum number of words that have to be entered to pass validation. Words are defined as strings of letters separated by spaces.'),
114
        'validate_regex' => '/^\d+$/',
100 115
      ),
101 116
      'description' => t('Verifies that a user-entered value contains at most the specified number of words.'),
102 117
    ),
......
117 132
            t('Enter "<=20" if the components must add up to less than or equal to 20.'),
118 133
          ),
119 134
        )),
135
        'validate_regex' => '/^(=|>|>=|<|<=)(-?[\d.]+)$/',
120 136
      ),
121 137
      'description' => t('Require the values of the selected fields to add up to exactly, greater than or equal to, or less than or equal to a specified number.'),
122 138
    ),
......
152 168
      'custom_data' => array(
153 169
        'label' => t('Comparison operator'),
154 170
        'description' => t('Specify the comparison operator you want to use. Must be one of: >, >=, <, <=. The validator will compare the first component with the second using this operator. If the components are of type email, they will get case-insensitive comparison.'),
171
        'validate_regex' => '/^(>|>=|<|<=)$/',
155 172
      ),
156 173
      'min_components' => 2,
157 174
      'max_components' => 2,
......
229 246
            t('Enter "<=2" if the user must complete <b>at most</b> 2 of the selected components.'),
230 247
          ),
231 248
        )),
249
        'validate_regex' => '/^[><]?=\d+$/',
232 250
      ),
233 251
      'min_components' => 2,
234 252
      'description' => t('Requires the user to complete some number of components out of a group of components. For example, complete at least 2 out of 3, complete at most 4 out of 6, or complete exactly 3 our of 4.'),
......
241 259
      'custom_data' => array(
242 260
        'label' => t('Minimum number of selections'),
243 261
        'description' => t('Specify the minimum number of options a user should select.'),
262
        'validate_regex' => '/^\d+$/',
244 263
      ),
245 264
      'description' => t('Forces the user to select at least a defined number of options from the specified webform components.'),
246 265
    ),
......
252 271
      'custom_data' => array(
253 272
        'label' => t('Maximum number of selections'),
254 273
        'description' => t('Specify the maximum number of options a user can select.'),
274
        'validate_regex' => '/^\d+$/',
255 275
      ),
256 276
      'description' => t('Forces the user to select at most a defined number of options from the specified webform components.'),
257 277
    ),
......
264 284
      'custom_data' => array(
265 285
        'label' => t('Number of selections'),
266 286
        'description' => t('Specify how many options a user can select.'),
287
        'validate_regex' => '/^\d+$/',
267 288
      ),
268 289
      'description' => t('Forces the user to select exactly the defined number of options from the specified webform components.'),
269 290
    ),
......
431 452
    return NULL;
432 453
  }
433 454

  
455
  // Allow translation for all components item names if available.
456
  if (module_exists('webform_localization')) {
457
    foreach ($components as &$component) {
458
      $dummy_element = array(
459
        '#title' => '',
460
      );
461
      _webform_localization_translate_component($dummy_element, $component);
462
      if (isset($dummy_element['#title']) && (string) $dummy_element['#title']) {
463
        $component['name'] = $dummy_element['#title'];
464
      }
465
    }
466
  }
467

  
434 468
  // For certain validators, if all components to be compared are email
435 469
  // components, make the values lower-case to avoid case-sensitive comparison.
436 470
  if (in_array($validator_name, array('equal', 'comparison', 'unique'))) {
......
624 658
          }
625 659
        }
626 660
        elseif ($components[$entry[$count]['key']]['type'] === 'time') {
627
          $time = $value['hour'] . ':' . $value['minute'];
628
          if (!empty($value['ampm'])) {
629
            $time .= ' ' . $value['ampm'];
661
          if (isset($value['hour']) && isset($value['minute'])) {
662
            $time = $value['hour'] . ':' . str_pad($value['minute'], 2, '0', STR_PAD_LEFT);
663
            if (!empty($value['ampm'])) {
664
              $time .= ' ' . $value['ampm'];
665
            }
666
            $time = strtotime($time);
667
          }
668
          else {
669
            $time = NULL;
630 670
          }
631
          $time = strtotime($time);
632 671
          if ($time) {
633 672
            $entry[$count]['value'] = date('H:i', $time);
634 673
          }

Formats disponibles : Unified diff