Revision 76bdcd04
Added by Assos Assos almost 6 years ago
drupal7/sites/all/modules/webform/webform.module | ||
---|---|---|
2444 | 2444 |
1 => t('Display the confirmation page in the block on the same page (no redirect)'), |
2445 | 2445 |
), |
2446 | 2446 |
'#default_value' => $settings['confirmation_block'], |
2447 |
'#description' => t('This setting overrides the webform\'s configuration and redirection location settings when the webform is submitted via this block.'),
|
|
2447 |
'#description' => t("This setting overrides the webform's configuration and redirection location settings when the webform is submitted via this block."),
|
|
2448 | 2448 |
); |
2449 | 2449 |
return $form; |
2450 | 2450 |
} |
... | ... | |
2615 | 2615 |
// For resuming a previous draft, find the next page after the last |
2616 | 2616 |
// validated page. |
2617 | 2617 |
if (!isset($form_state['storage']['page_num']) && $submission && $submission->is_draft && $submission->highest_valid_page) { |
2618 |
// Find the |
|
2619 |
// 1) previous/next non-empty page, or
|
|
2620 |
// 2) the preview page, or
|
|
2621 |
// 3) the preview page, forcing its display if the form would
|
|
2622 |
// unexpectedly submit, or
|
|
2623 |
// 4) page 1 even if empty, if no other previous page would be shown.
|
|
2618 |
// Find the:
|
|
2619 |
// 1. previous/next non-empty page, or
|
|
2620 |
// 2. the preview page, or
|
|
2621 |
// 3. the preview page, forcing its display if the form would unexpectedly
|
|
2622 |
// submit, or |
|
2623 |
// 4. page 1 even if empty, if no other previous page would be shown.
|
|
2624 | 2624 |
$form_state['webform']['page_num'] = $submission->highest_valid_page; |
2625 | 2625 |
do { |
2626 | 2626 |
$form_state['webform']['page_num']++; |
... | ... | |
2643 | 2643 |
$page_num = $form_state['webform']['page_num']; |
2644 | 2644 |
$preview = $form_state['webform']['preview']; |
2645 | 2645 |
|
2646 |
if ($page_count > 1) { |
|
2646 |
if ($node->webform['progressbar_include_confirmation'] || $page_count > 1) {
|
|
2647 | 2647 |
$page_labels = webform_page_labels($node, $form_state); |
2648 | 2648 |
$form['progressbar'] = array( |
2649 | 2649 |
'#theme' => 'webform_progressbar', |
... | ... | |
3043 | 3043 |
$cid = $elements['#webform_component']['cid']; |
3044 | 3044 |
$page_num = $form_state['values']['details']['page_num']; |
3045 | 3045 |
// Webform-specific enhancements: |
3046 |
// 1) Only validate the field if it was used in this submission.
|
|
3046 |
// 1. Only validate the field if it was used in this submission.
|
|
3047 | 3047 |
// This both skips validation on the field and sets the value of the |
3048 | 3048 |
// field to NULL, preventing any dangerous input. Short-circuit |
3049 | 3049 |
// validation for a hidden component (hidden by rules dependent upon |
3050 | 3050 |
// component on previous pages), or a component this is dependent upon |
3051 | 3051 |
// values on the current page, but is hidden based upon their current |
3052 | 3052 |
// values. |
3053 |
// 2) Only validate if the field has not been set by conditionals.
|
|
3053 |
// 2. Only validate if the field has not been set by conditionals.
|
|
3054 | 3054 |
// The user will be unable to fix the validation without surmising the |
3055 | 3055 |
// logic and changing the trigger for the conditional. Also, it isn't |
3056 | 3056 |
// possible to set $element['#value'] without component-specific |
... | ... | |
3099 | 3099 |
if (isset($elements['#needs_validation'])) { |
3100 | 3100 |
// Make sure a value is passed when the field is required. |
3101 | 3101 |
// A simple call to empty() will not cut it here as some fields, like |
3102 |
// checkboxes, can return a valid value of '0'. Instead, check the
|
|
3103 |
// length if it's a string, and the item count if it's an array. For
|
|
3102 |
// checkboxes, can return a valid value of 0. Instead, check the
|
|
3103 |
// length if it's a string, and if it's an array whether it is empty. For
|
|
3104 | 3104 |
// radios, FALSE means that no value was submitted, so check that too. |
3105 |
if ($elements['#required'] && (!count($elements['#value']) || (is_string($elements['#value']) && strlen(trim($elements['#value'])) == 0) || $elements['#value'] === FALSE)) { |
|
3105 |
$value_is_empty_string = is_string($elements['#value']) && strlen(trim($elements['#value'])) === 0; |
|
3106 |
$value_is_empty_array = is_array($elements['#value']) && !$elements['#value']; |
|
3107 |
if ($elements['#required'] && ($value_is_empty_string || $value_is_empty_array || $elements['#value'] === FALSE || $elements['#value'] === NULL)) { |
|
3106 | 3108 |
form_error($elements, t('!name field is required.', array('!name' => $elements['#title']))); |
3107 | 3109 |
} |
3108 | 3110 |
|
... | ... | |
3297 | 3299 |
$current_page = $form_state['storage']['page_num']; |
3298 | 3300 |
|
3299 | 3301 |
if (isset($forward)) { |
3300 |
// Find the |
|
3301 |
// 1) previous/next non-empty page, or
|
|
3302 |
// 2) the preview page, or
|
|
3303 |
// 3) the preview page, forcing its display if the form would
|
|
3304 |
// unexpectedly submit, or
|
|
3305 |
// 4) page 1 even if empty, if no other previous page would be shown.
|
|
3302 |
// Find the:
|
|
3303 |
// 1. previous/next non-empty page, or
|
|
3304 |
// 2. the preview page, or
|
|
3305 |
// 3. the preview page, forcing its display if the form would unexpectedly
|
|
3306 |
// submit, or |
|
3307 |
// 4. page 1 even if empty, if no other previous page would be shown.
|
|
3306 | 3308 |
$preview_page_num = $form_state['storage']['page_count'] + (int) !$form_state['webform']['preview']; |
3307 | 3309 |
$page_num = $current_page; |
3308 | 3310 |
do { |
... | ... | |
3601 | 3603 |
|
3602 | 3604 |
// Progress bar. |
3603 | 3605 |
$vars['progressbar'] = ''; |
3604 |
$page_labels = webform_page_labels($node);
|
|
3605 |
$page_count = count($page_labels);
|
|
3606 |
if ($node->webform['progressbar_include_confirmation'] && $page_count > 2) {
|
|
3606 |
if ($node->webform['progressbar_include_confirmation']) {
|
|
3607 |
$page_labels = webform_page_labels($node);
|
|
3608 |
$page_count = count($page_labels);
|
|
3607 | 3609 |
$vars['progressbar'] = theme('webform_progressbar', array( |
3608 | 3610 |
'node' => $node, |
3609 | 3611 |
'page_num' => $page_count, |
... | ... | |
3756 | 3758 |
case 'inline': |
3757 | 3759 |
$output .= $description[$above]; |
3758 | 3760 |
$description[$above] = ''; |
3759 |
// FALL THRU. |
|
3760 | 3761 |
case 'before': |
3761 | 3762 |
case 'invisible': |
3762 |
$output .= ' ' . theme('form_element_label', $variables); |
|
3763 |
$output .= ' ' . $description[$above] . $prefix . $element['#children'] . $suffix . "\n"; |
|
3763 |
case 'after': |
|
3764 |
$title = ' ' . theme('form_element_label', $variables); |
|
3765 |
break; |
|
3766 |
} |
|
3767 |
|
|
3768 |
$children = ' ' . $description[$above] . $prefix . $element['#children'] . $suffix; |
|
3769 |
switch ($element['#title_display']) { |
|
3770 |
case 'inline': |
|
3771 |
case 'before': |
|
3772 |
case 'invisible': |
|
3773 |
$output .= $title; |
|
3774 |
$output .= $children; |
|
3764 | 3775 |
break; |
3765 | 3776 |
|
3766 | 3777 |
case 'after': |
3767 |
$output .= ' ' . $description[$above] . $prefix . $element['#children'] . $suffix;
|
|
3768 |
$output .= ' ' . theme('form_element_label', $variables) . "\n";
|
|
3778 |
$output .= $children;
|
|
3779 |
$output .= $title;
|
|
3769 | 3780 |
break; |
3770 | 3781 |
|
3771 | 3782 |
case 'none': |
3772 | 3783 |
case 'attribute': |
3773 | 3784 |
// Output no label and no required marker, only the children. |
3774 |
$output .= ' ' . $description[$above] . $prefix . $element['#children'] . $suffix . "\n";
|
|
3785 |
$output .= $children;
|
|
3775 | 3786 |
break; |
3776 | 3787 |
} |
3788 |
$output .= "\n"; |
|
3777 | 3789 |
|
3778 | 3790 |
$output .= $description[!$above]; |
3779 | 3791 |
$output .= "</div>\n"; |
... | ... | |
5172 | 5184 |
@$timezone = new DateTimeZone($timezone_name); |
5173 | 5185 |
if (isset($reference_timestamp)) { |
5174 | 5186 |
// A reference for relative dates has been provided. |
5175 |
// 1) Convert the reference timestamp (in UTC) to a DateTime.
|
|
5176 |
// 2) Set to time zone to the user or system timezone, recreating
|
|
5177 |
// the reference time in the appropriate time zone.
|
|
5178 |
// 3) Set the time to midnight because when a non-referenced relative
|
|
5187 |
// 1. Convert the reference timestamp (in UTC) to a DateTime.
|
|
5188 |
// 2. Set to time zone to the user or system timezone, recreating the
|
|
5189 |
// reference time in the appropriate time zone. |
|
5190 |
// 3. Set the time to midnight because when a non-referenced relative
|
|
5179 | 5191 |
// date is created without a time, it is created at midnight (0:00). |
5180 |
// 4) Adjust to the specified relative (or absolute) time.
|
|
5192 |
// 4. Adjust to the specified relative (or absolute) time.
|
|
5181 | 5193 |
@$datetime = new DateTime('@' . $reference_timestamp); |
5182 | 5194 |
@$datetime->setTimezone($timezone) |
5183 | 5195 |
->setTime(0, 0, 0) |
Also available in: Unified diff
Weekly update of contrib modules