function date_repeat_merge in Date 6.2
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 date_repeat/date_repeat_form.inc \date_repeat_merge()
- 7.3 date_repeat/date_repeat_form.inc \date_repeat_merge()
- 7 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/
date_repeat.inc - Validation for date repeat form element.
File
- date_repeat/
date_repeat_form.inc, line 304 - 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_value';
$until_element = $element;
$until_element['#value'] = $form_values['UNTIL']['datetime'];
$until_element['#date_format'] = date_limit_format($element['#date_format'], array(
'year',
'month',
'day',
));
$form_values['UNTIL']['datetime'] = $function($until_element, 0, 10);
$form_values['UNTIL']['datetime'] = substr($form_values['UNTIL']['datetime'], 0, 10);
$form_values['UNTIL']['granularity'] = serialize(drupal_map_assoc(array(
'year',
'month',
'day',
'hour',
)));
$form_values['UNTIL']['all_day'] = TRUE;
}
if (array_key_exists('EXDATE', $form_values) && is_array($form_values['EXDATE'])) {
$function = $element['#date_repeat_widget'] . '_input_value';
$exdate_element = $element;
foreach ($form_values['EXDATE'] as $delta => $value) {
if (is_array($value['datetime'])) {
$exdate_element['#value'] = $form_values['EXDATE'][$delta]['datetime'];
$exdate_element['#date_format'] = date_limit_format($element['#date_format'], array(
'year',
'month',
'day',
));
$form_values['EXDATE'][$delta]['datetime'] = $function($exdate_element);
}
}
}
if (array_key_exists('RDATE', $form_values) && is_array($form_values['RDATE'])) {
$function = $element['#date_repeat_widget'] . '_input_value';
$rdate_element = $element;
foreach ($form_values['RDATE'] as $delta => $value) {
if (is_array($value['datetime'])) {
$rdate_element['#value'] = $form_values['RDATE'][$delta]['datetime'];
$rdate_element['#date_format'] = date_limit_format($element['#date_format'], array(
'year',
'month',
'day',
));
$form_values['RDATE'][$delta]['datetime'] = $function($rdate_element);
}
}
}
return $form_values;
}