Projet

Général

Profil

Révision 1f623f01

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

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/webform_validation/webform_validation.validators.inc
601 601
        $entry[$count]['key'] = key($items);
602 602
        $value = array_shift($items);
603 603
        if ($components[$entry[$count]['key']]['type'] === 'date') {
604
          if (checkdate((int) $value['month'], (int) $value['day'], (int) $value['year'])) {
604
          if (!empty($value) && checkdate((int) $value['month'], (int) $value['day'], (int) $value['year'])) {
605 605
            $entry[$count]['value'] = date('Y-m-d', mktime(0, 0, 0, (int) $value['month'], (int) $value['day'], (int) $value['year']));
606 606
          }
607 607
          else {
......
927 927
 * Count the number of words in a value.
928 928
 *
929 929
 * Strip HTML first.
930
 *
931
 * @param string|array $val
932
 *   A string or array of strings in which to count words.
933
 *
934
 * @return int
935
 *   The number of words in the input.
930 936
 */
931 937
function _webform_validation_count_words($val) {
932 938
  $val = _webform_validation_flatten_array($val);
933 939

  
940
  // Strip any HTML tags so they're not counted in the word count.
934 941
  $val = strip_tags($val);
935
  // Replace entities representing spaces with actual spaces.
936
  $val = str_replace(' ', ' ', $val);
937
  $val = str_replace(' ', ' ', $val);
942
  // Convert character entities back to characters. Without this, entities for
943
  // whitespace characters would not be counted as word boundaries.
944
  $val = html_entity_decode($val);
938 945

  
939
  return str_word_count($val);
946
  return count(preg_split('/[[:space:]\xC2\xA0]+/', $val));
940 947
}
941 948

  
942 949
/**

Formats disponibles : Unified diff