function date_repeat_merge in Date 7
Same name and namespace in other branches
- 8 date_repeat/date_repeat_form.inc \date_repeat_merge()
- 5.2 date_repeat/date_repeat_form.inc \date_repeat_merge()
- 6.2 date_repeat/date_repeat_form.inc \date_repeat_merge()
- 6 date_repeat/date_repeat_form.inc \date_repeat_merge()
- 7.3 date_repeat/date_repeat_form.inc \date_repeat_merge()
- 7.2 date_repeat/date_repeat_form.inc \date_repeat_merge()
Regroup values back into a consistant array, no matter what state it is in.
3 calls to date_repeat_merge()
- date_repeat_rrule_validate in date_repeat/
date_repeat_form.inc - Build a RRULE out of the form values.
- _date_repeat_rrule_process in date_repeat/
date_repeat_form.inc - Generate the repeat setting form.
- _date_repeat_widget_validate in ./
date_repeat.inc - Validation for date repeat form element.
File
- date_repeat/
date_repeat_form.inc, line 276 - Code to add a date repeat selection form to a date field and create an iCal RRULE from the chosen selections.
Code
function date_repeat_merge($form_values, $element) {
if (empty($form_values) || !is_array($form_values)) {
return $form_values;
}
if (array_key_exists('advanced', $form_values) || array_key_exists('exceptions', $form_values) || array_key_exists('additions', $form_values)) {
if (!array_key_exists('advanced', $form_values)) {
$form_values['advanced'] = array();
}
if (!array_key_exists('exceptions', $form_values)) {
$form_values['exceptions'] = array();
}
if (!array_key_exists('additions', $form_values)) {
$form_values['additions'] = array();
}
$form_values = array_merge($form_values, (array) $form_values['advanced'], (array) $form_values['exceptions'], (array) $form_values['additions']);
unset($form_values['advanced']);
unset($form_values['exceptions']);
unset($form_values['additions']);
}
if (array_key_exists('BYDAY', $form_values)) {
unset($form_values['BYDAY']['']);
}
if (array_key_exists('BYMONTH', $form_values)) {
unset($form_values['BYMONTH']['']);
}
if (array_key_exists('BYMONTHDAY', $form_values)) {
unset($form_values['BYMONTHDAY']['']);
}
if (array_key_exists('UNTIL', $form_values) && is_array($form_values['UNTIL']['datetime'])) {
$function = $element['#date_repeat_widget'] . '_input_date';
$until_element = $element;
$until_element['#date_format'] = date_limit_format($element['#date_format'], array(
'year',
'month',
'day',
));
$date = $function($until_element, $form_values['UNTIL']['datetime']);
$form_values['UNTIL']['datetime'] = is_object($date) ? $date
->format(DATE_FORMAT_DATETIME) : '';
}
if (array_key_exists('EXDATE', $form_values) && is_array($form_values['EXDATE'])) {
$function = $element['#date_repeat_widget'] . '_input_date';
$exdate_element = $element;
foreach ($form_values['EXDATE'] as $delta => $value) {
if (is_array($value['datetime'])) {
$exdate_element['#date_format'] = date_limit_format($element['#date_format'], array(
'year',
'month',
'day',
));
$date = $function($exdate_element, $form_values['EXDATE'][$delta]['datetime']);
$form_values['EXDATE'][$delta]['datetime'] = is_object($date) ? $date
->format(DATE_FORMAT_DATETIME) : '';
}
}
}
if (array_key_exists('RDATE', $form_values) && is_array($form_values['RDATE'])) {
$function = $element['#date_repeat_widget'] . '_input_date';
$rdate_element = $element;
foreach ($form_values['RDATE'] as $delta => $value) {
if (is_array($value['datetime'])) {
$rdate_element['#date_format'] = date_limit_format($element['#date_format'], array(
'year',
'month',
'day',
));
$form_values['RDATE'][$delta]['datetime'] = $function($rdate_element, $form_values['RDATE'][$delta]['datetime']);
}
}
}
return $form_values;
}