updated date pathauto addressfield honeypot features modules
This commit is contained in:
@@ -7,9 +7,9 @@ php = 5.2
|
||||
files[] = tests/date_repeat.test
|
||||
files[] = tests/date_repeat_form.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2014-07-29
|
||||
version = "7.x-2.8"
|
||||
; Information added by Drupal.org packaging script on 2015-09-08
|
||||
version = "7.x-2.9"
|
||||
core = "7.x"
|
||||
project = "date"
|
||||
datestamp = "1406653438"
|
||||
datestamp = "1441727353"
|
||||
|
||||
|
@@ -12,21 +12,3 @@ function date_repeat_install() {
|
||||
// Make sure this module loads after date_api.
|
||||
db_query("UPDATE {system} SET weight = 1 WHERE name = 'date_repeat'");
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_uninstall().
|
||||
*/
|
||||
function date_repeat_uninstall() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_enable().
|
||||
*/
|
||||
function date_repeat_enable() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_disable().
|
||||
*/
|
||||
function date_repeat_disable() {
|
||||
}
|
||||
|
@@ -1,7 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
*
|
||||
* This module creates a form element that allows users to select
|
||||
* repeat rules for a date, and reworks the result into an iCal
|
||||
* RRULE string that can be stored in the database.
|
||||
@@ -11,8 +10,8 @@
|
||||
*
|
||||
* Other modules can use this API to add self-validating form elements
|
||||
* to their dates, and identify dates that meet the RRULE criteria.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_element_info().
|
||||
*/
|
||||
@@ -35,6 +34,9 @@ function date_repeat_element_info() {
|
||||
return $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_theme().
|
||||
*/
|
||||
function date_repeat_theme() {
|
||||
return array(
|
||||
'date_repeat_current_exceptions' => array('render element' => 'element'),
|
||||
@@ -55,6 +57,9 @@ function date_repeat_freq_options() {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for interval options.
|
||||
*/
|
||||
function date_repeat_interval_options() {
|
||||
$options = range(0, 366);
|
||||
unset($options[0]);
|
||||
@@ -92,9 +97,11 @@ function date_repeat_dow_day_options_abbr($translated = TRUE, $length = 3) {
|
||||
case 1:
|
||||
$context = 'day_abbr1';
|
||||
break;
|
||||
|
||||
case 2:
|
||||
$context = 'day_abbr2';
|
||||
break;
|
||||
|
||||
default:
|
||||
$context = '';
|
||||
break;
|
||||
@@ -105,16 +112,28 @@ function date_repeat_dow_day_options_abbr($translated = TRUE, $length = 3) {
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for weekdays translated.
|
||||
*/
|
||||
function date_repeat_dow_day_untranslated() {
|
||||
static $date_repeat_weekdays;
|
||||
if (empty($date_repeat_weekdays)) {
|
||||
$date_repeat_weekdays = array('SU' => 'Sunday', 'MO' => 'Monday', 'TU' => 'Tuesday',
|
||||
'WE' => 'Wednesday', 'TH' => 'Thursday', 'FR' => 'Friday',
|
||||
'SA' => 'Saturday');
|
||||
$date_repeat_weekdays = array(
|
||||
'SU' => 'Sunday',
|
||||
'MO' => 'Monday',
|
||||
'TU' => 'Tuesday',
|
||||
'WE' => 'Wednesday',
|
||||
'TH' => 'Thursday',
|
||||
'FR' => 'Friday',
|
||||
'SA' => 'Saturday'
|
||||
);
|
||||
}
|
||||
return $date_repeat_weekdays;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for weekdays order.
|
||||
*/
|
||||
function date_repeat_dow_day_options_ordered($weekdays) {
|
||||
$day_keys = array_keys($weekdays);
|
||||
$day_values = array_values($weekdays);
|
||||
@@ -164,8 +183,7 @@ function date_repeat_dow2day($dow) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Shift the array of iCal day names into the right order
|
||||
* for a specific week start day.
|
||||
* Shift the array of iCal day names into the right order for a specific week start day.
|
||||
*/
|
||||
function date_repeat_days_ordered($week_start_day) {
|
||||
$days = array_flip(array_keys(date_repeat_dow_day_options(FALSE)));
|
||||
@@ -212,18 +230,21 @@ function date_repeat_rrule_description($rrule, $format = 'D M d Y') {
|
||||
'!except' => '',
|
||||
'!additional' => '',
|
||||
'!week_starts_on' => '',
|
||||
);
|
||||
);
|
||||
$interval = date_repeat_interval_options();
|
||||
switch ($rrule['FREQ']) {
|
||||
case 'WEEKLY':
|
||||
$description['!interval'] = format_plural($rrule['INTERVAL'], 'every week', 'every @count weeks') . ' ';
|
||||
break;
|
||||
|
||||
case 'MONTHLY':
|
||||
$description['!interval'] = format_plural($rrule['INTERVAL'], 'every month', 'every @count months') . ' ';
|
||||
break;
|
||||
|
||||
case 'YEARLY':
|
||||
$description['!interval'] = format_plural($rrule['INTERVAL'], 'every year', 'every @count years') . ' ';
|
||||
break;
|
||||
|
||||
default:
|
||||
$description['!interval'] = format_plural($rrule['INTERVAL'], 'every day', 'every @count days') . ' ';
|
||||
break;
|
||||
@@ -240,26 +261,41 @@ function date_repeat_rrule_description($rrule, $format = 'D M d Y') {
|
||||
if (!empty($count)) {
|
||||
// See if there is a 'pretty' option for this count, i.e. +1 => First.
|
||||
$order = array_key_exists($count, $counts) ? strtolower($counts[$count]) : $count;
|
||||
$results[] = trim(t('!repeats_every_interval on the !date_order !day_of_week', array('!repeats_every_interval ' => '', '!date_order' => $order, '!day_of_week' => $days[$day])));
|
||||
$results[] = trim(t('!repeats_every_interval on the !date_order !day_of_week',
|
||||
array(
|
||||
'!repeats_every_interval ' => '',
|
||||
'!date_order' => $order,
|
||||
'!day_of_week' => $days[$day]
|
||||
)));
|
||||
}
|
||||
else {
|
||||
$results[] = trim(t('!repeats_every_interval every !day_of_week', array('!repeats_every_interval ' => '', '!day_of_week' => $days[$day])));
|
||||
$results[] = trim(t('!repeats_every_interval every !day_of_week',
|
||||
array('!repeats_every_interval ' => '', '!day_of_week' => $days[$day])));
|
||||
}
|
||||
}
|
||||
$description['!byday'] = implode(' ' . t('and') . ' ', $results);
|
||||
}
|
||||
if (!empty($rrule['BYMONTH'])) {
|
||||
if (sizeof($rrule['BYMONTH']) < 12) {
|
||||
if (count($rrule['BYMONTH']) < 12) {
|
||||
$results = array();
|
||||
$months = date_month_names();
|
||||
foreach ($rrule['BYMONTH'] as $month) {
|
||||
$results[] = $months[$month];
|
||||
}
|
||||
if (!empty($rrule['BYMONTHDAY'])) {
|
||||
$description['!bymonth'] = trim(t('!repeats_every_interval on the !month_days of !month_names', array('!repeats_every_interval ' => '', '!month_days' => implode(', ', $rrule['BYMONTHDAY']), '!month_names' => implode(', ', $results))));
|
||||
$description['!bymonth'] = trim(t('!repeats_every_interval on the !month_days of !month_names',
|
||||
array(
|
||||
'!repeats_every_interval ' => '',
|
||||
'!month_days' => implode(', ', $rrule['BYMONTHDAY']),
|
||||
'!month_names' => implode(', ', $results)
|
||||
)));
|
||||
}
|
||||
else {
|
||||
$description['!bymonth'] = trim(t('!repeats_every_interval on !month_names', array('!repeats_every_interval ' => '', '!month_names' => implode(', ', $results))));
|
||||
$description['!bymonth'] = trim(t('!repeats_every_interval on !month_names',
|
||||
array(
|
||||
'!repeats_every_interval ' => '',
|
||||
'!month_names' => implode(', ', $results)
|
||||
)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -267,12 +303,17 @@ function date_repeat_rrule_description($rrule, $format = 'D M d Y') {
|
||||
$rrule['INTERVAL'] = 1;
|
||||
}
|
||||
if (!empty($rrule['COUNT'])) {
|
||||
$description['!count'] = trim(t('!repeats_every_interval !count times', array('!repeats_every_interval ' => '', '!count' => $rrule['COUNT'])));
|
||||
$description['!count'] = trim(t('!repeats_every_interval !count times',
|
||||
array('!repeats_every_interval ' => '', '!count' => $rrule['COUNT'])));
|
||||
}
|
||||
if (!empty($rrule['UNTIL'])) {
|
||||
$until = date_ical_date($rrule['UNTIL'], 'UTC');
|
||||
date_timezone_set($until, date_default_timezone_object());
|
||||
$description['!until'] = trim(t('!repeats_every_interval until !until_date', array('!repeats_every_interval ' => '', '!until_date' => date_format_date($until, 'custom', $format))));
|
||||
$description['!until'] = trim(t('!repeats_every_interval until !until_date',
|
||||
array(
|
||||
'!repeats_every_interval ' => '',
|
||||
'!until_date' => date_format_date($until, 'custom', $format)
|
||||
)));
|
||||
}
|
||||
if ($exceptions) {
|
||||
$values = array();
|
||||
@@ -281,11 +322,16 @@ function date_repeat_rrule_description($rrule, $format = 'D M d Y') {
|
||||
date_timezone_set($except, date_default_timezone_object());
|
||||
$values[] = date_format_date($except, 'custom', $format);
|
||||
}
|
||||
$description['!except'] = trim(t('!repeats_every_interval except !except_dates', array('!repeats_every_interval ' => '', '!except_dates' => implode(', ', $values))));
|
||||
$description['!except'] = trim(t('!repeats_every_interval except !except_dates',
|
||||
array(
|
||||
'!repeats_every_interval ' => '',
|
||||
'!except_dates' => implode(', ', $values)
|
||||
)));
|
||||
}
|
||||
if (!empty($rrule['WKST'])) {
|
||||
$day_names = date_repeat_dow_day_options();
|
||||
$description['!week_starts_on'] = trim(t('!repeats_every_interval where the week start on !day_of_week', array('!repeats_every_interval ' => '', '!day_of_week' => $day_names[trim($rrule['WKST'])])));
|
||||
$description['!week_starts_on'] = trim(t('!repeats_every_interval where the week start on !day_of_week',
|
||||
array('!repeats_every_interval ' => '', '!day_of_week' => $day_names[trim($rrule['WKST'])])));
|
||||
}
|
||||
if ($additions) {
|
||||
$values = array();
|
||||
@@ -294,9 +340,15 @@ function date_repeat_rrule_description($rrule, $format = 'D M d Y') {
|
||||
date_timezone_set($add, date_default_timezone_object());
|
||||
$values[] = date_format_date($add, 'custom', $format);
|
||||
}
|
||||
$description['!additional'] = trim(t('Also includes !additional_dates.', array('!additional_dates' => implode(', ', $values))));
|
||||
$description['!additional'] = trim(t('Also includes !additional_dates.',
|
||||
array('!additional_dates' => implode(', ', $values))));
|
||||
}
|
||||
return t('Repeats !interval !bymonth !byday !count !until !except. !additional', $description);
|
||||
$output = t('Repeats !interval !bymonth !byday !count !until !except. !additional', $description);
|
||||
// Removes double whitespaces from Repeat tile.
|
||||
$output = preg_replace('/\s+/', ' ', $output);
|
||||
// Removes whitespace before full stop ".", at the end of the title.
|
||||
$output = str_replace(' .', '.', $output);
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -310,17 +362,17 @@ function date_repeat_split_rrule($rrule) {
|
||||
$additions = array();
|
||||
foreach ($parts as $part) {
|
||||
if (strstr($part, 'RRULE')) {
|
||||
$RRULE = str_replace('RRULE:', '', $part);
|
||||
$rrule = (array) date_ical_parse_rrule('RRULE:', $RRULE);
|
||||
$cleanded_part = str_replace('RRULE:', '', $part);
|
||||
$rrule = (array) date_ical_parse_rrule('RRULE:', $cleanded_part);
|
||||
}
|
||||
elseif (strstr($part, 'EXDATE')) {
|
||||
$EXDATE = str_replace('EXDATE:', '', $part);
|
||||
$exceptions = (array) date_ical_parse_exceptions('EXDATE:', $EXDATE);
|
||||
$exdate = str_replace('EXDATE:', '', $part);
|
||||
$exceptions = (array) date_ical_parse_exceptions('EXDATE:', $exdate);
|
||||
unset($exceptions['DATA']);
|
||||
}
|
||||
elseif (strstr($part, 'RDATE')) {
|
||||
$RDATE = str_replace('RDATE:', '', $part);
|
||||
$additions = (array) date_ical_parse_exceptions('RDATE:', $RDATE);
|
||||
$rdate = str_replace('RDATE:', '', $part);
|
||||
$additions = (array) date_ical_parse_exceptions('RDATE:', $rdate);
|
||||
unset($additions['DATA']);
|
||||
}
|
||||
}
|
||||
@@ -372,7 +424,7 @@ function date_repeat_form_element_radios_process($element) {
|
||||
'#title_display' => 'invisible',
|
||||
'#return_value' => $key,
|
||||
'#default_value' => isset($element['#default_value']) ?
|
||||
$element['#default_value'] : NULL,
|
||||
$element['#default_value'] : NULL,
|
||||
'#attributes' => $element['#attributes'],
|
||||
'#parents' => $element['#parents'],
|
||||
'#id' => drupal_html_id('edit-' . implode('-', $parents_for_id)),
|
||||
|
@@ -53,9 +53,11 @@ function _date_repeat_calc($rrule, $start, $end, $exceptions, $timezone, $additi
|
||||
// Create a date object for the start and end dates.
|
||||
$start_date = new DateObject($start, $timezone);
|
||||
|
||||
// Versions of PHP greater than PHP 5.3.5 require that we set an explicit time when
|
||||
// using date_modify() or the time may not match the original value. Adding this
|
||||
// modifier gives us the same results in both older and newer versions of PHP.
|
||||
// Versions of PHP greater than PHP 5.3.5 require
|
||||
// that we set an explicit time when using date_modify()
|
||||
// or the time may not match the original value.
|
||||
// Adding this modifier gives us the same results in both older
|
||||
// and newer versions of PHP.
|
||||
$modify_time = ' ' . $start_date->format('g:ia');
|
||||
|
||||
// If the rule has an UNTIL, see if that is earlier than the end date.
|
||||
@@ -91,27 +93,32 @@ function _date_repeat_calc($rrule, $start, $end, $exceptions, $timezone, $additi
|
||||
}
|
||||
|
||||
// Make sure DAILY frequency isn't used in places it won't work;
|
||||
if (!empty($rrule['BYMONTHDAY']) && !in_array($rrule['FREQ'], array('MONTHLY', 'YEARLY'))) {
|
||||
if (!empty($rrule['BYMONTHDAY']) &&
|
||||
!in_array($rrule['FREQ'], array('MONTHLY', 'YEARLY'))) {
|
||||
$rrule['FREQ'] = 'MONTHLY';
|
||||
}
|
||||
elseif (!empty($rrule['BYDAY']) && !in_array($rrule['FREQ'], array('MONTHLY', 'WEEKLY', 'YEARLY'))) {
|
||||
elseif (!empty($rrule['BYDAY'])
|
||||
&& !in_array($rrule['FREQ'], array('MONTHLY', 'WEEKLY', 'YEARLY'))) {
|
||||
$rrule['FREQ'] = 'WEEKLY';
|
||||
}
|
||||
}
|
||||
|
||||
// Find the time period to jump forward between dates.
|
||||
switch ($rrule['FREQ']) {
|
||||
case 'DAILY':
|
||||
$jump = $interval . ' days';
|
||||
break;
|
||||
case 'WEEKLY':
|
||||
$jump = $interval . ' weeks';
|
||||
break;
|
||||
case 'MONTHLY':
|
||||
$jump = $interval . ' months';
|
||||
break;
|
||||
case 'YEARLY':
|
||||
$jump = $interval . ' years';
|
||||
break;
|
||||
case 'DAILY':
|
||||
$jump = $interval . ' days';
|
||||
break;
|
||||
|
||||
case 'WEEKLY':
|
||||
$jump = $interval . ' weeks';
|
||||
break;
|
||||
|
||||
case 'MONTHLY':
|
||||
$jump = $interval . ' months';
|
||||
break;
|
||||
|
||||
case 'YEARLY':
|
||||
$jump = $interval . ' years';
|
||||
break;
|
||||
}
|
||||
$rrule = date_repeat_adjust_rrule($rrule, $start_date);
|
||||
|
||||
@@ -135,7 +142,7 @@ function _date_repeat_calc($rrule, $start, $end, $exceptions, $timezone, $additi
|
||||
$direction_days[$day] = array(
|
||||
'direction' => !empty($regs[1]) ? $regs[1] : '+',
|
||||
'direction_count' => $regs[2],
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
while (!$finished) {
|
||||
@@ -198,8 +205,9 @@ function _date_repeat_calc($rrule, $start, $end, $exceptions, $timezone, $additi
|
||||
|
||||
else {
|
||||
|
||||
// More complex searches for day names and criteria like '-1SU' or '2TU,2TH',
|
||||
// require that we interate through the whole time period checking each BYDAY.
|
||||
// More complex searches for day names and criteria
|
||||
// like '-1SU' or '2TU,2TH', require that we interate through
|
||||
// the whole time period checking each BYDAY.
|
||||
|
||||
// Create helper array to pull day names out of iCal day strings.
|
||||
$day_names = date_repeat_dow_day_options(FALSE);
|
||||
@@ -303,7 +311,8 @@ function _date_repeat_calc($rrule, $start, $end, $exceptions, $timezone, $additi
|
||||
// period, then jumping ahead to the next week, month, or year,
|
||||
// an INTERVAL at a time.
|
||||
|
||||
if (!empty($week_days) && in_array($rrule['FREQ'], array('MONTHLY', 'WEEKLY', 'YEARLY'))) {
|
||||
if (!empty($week_days) &&
|
||||
in_array($rrule['FREQ'], array('MONTHLY', 'WEEKLY', 'YEARLY'))) {
|
||||
$finished = FALSE;
|
||||
$current_day = clone($start_date);
|
||||
$format = $rrule['FREQ'] == 'YEARLY' ? 'Y' : 'n';
|
||||
@@ -322,8 +331,9 @@ function _date_repeat_calc($rrule, $start, $end, $exceptions, $timezone, $additi
|
||||
$moved = FALSE;
|
||||
foreach ($week_days as $delta => $day) {
|
||||
// Find the next occurence of each day in this week, only add it
|
||||
// if we are still in the current month or year. The date_repeat_add_dates
|
||||
// function is insufficient to test whether to include this date
|
||||
// if we are still in the current month or year.
|
||||
// The date_repeat_add_dates function is insufficient
|
||||
// to test whether to include this date
|
||||
// if we are using a rule like 'every other month', so we must
|
||||
// explicitly test it here.
|
||||
|
||||
@@ -370,10 +380,12 @@ function _date_repeat_calc($rrule, $start, $end, $exceptions, $timezone, $additi
|
||||
date_modify($current_day, '+1 ' . $week_start_day . $modify_time);
|
||||
date_modify($current_day, '-1 week' . $modify_time);
|
||||
break;
|
||||
|
||||
case 'MONTHLY':
|
||||
date_modify($current_day, '-' . (date_format($current_day, 'j') - 1) . ' days' . $modify_time);
|
||||
date_modify($current_day, '-1 month' . $modify_time);
|
||||
break;
|
||||
|
||||
case 'YEARLY':
|
||||
date_modify($current_day, '-' . date_format($current_day, 'z') . ' days' . $modify_time);
|
||||
date_modify($current_day, '-1 year' . $modify_time);
|
||||
@@ -387,7 +399,7 @@ function _date_repeat_calc($rrule, $start, $end, $exceptions, $timezone, $additi
|
||||
}
|
||||
}
|
||||
|
||||
// add additional dates
|
||||
// Add additional dates.
|
||||
foreach ($additions as $addition) {
|
||||
$date = new dateObject($addition . ' ' . $start_date->format('H:i:s'), $timezone);
|
||||
$days[] = date_format($date, DATE_FORMAT_DATETIME);
|
||||
@@ -426,8 +438,8 @@ function date_repeat_adjust_rrule($rrule, $start_date) {
|
||||
// position rules make no sense in other periods and just add complexity.
|
||||
|
||||
elseif (!empty($rrule['BYDAY']) && !in_array($rrule['FREQ'], array('MONTHLY', 'YEARLY'))) {
|
||||
foreach ($rrule['BYDAY'] as $delta => $BYDAY) {
|
||||
$rrule['BYDAY'][$delta] = substr($BYDAY, -2);
|
||||
foreach ($rrule['BYDAY'] as $delta => $by_day) {
|
||||
$rrule['BYDAY'][$delta] = substr($by_day, -2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -442,7 +454,7 @@ function date_repeat_adjust_rrule($rrule, $start_date) {
|
||||
* and that it meets other criteria in the RRULE.
|
||||
*/
|
||||
function date_repeat_add_dates(&$days, $current_day, $start_date, $end_date, $exceptions, $rrule) {
|
||||
if (isset($rrule['COUNT']) && sizeof($days) >= $rrule['COUNT']) {
|
||||
if (isset($rrule['COUNT']) && count($days) >= $rrule['COUNT']) {
|
||||
return FALSE;
|
||||
}
|
||||
$formatted = date_format($current_day, DATE_FORMAT_DATETIME);
|
||||
@@ -456,13 +468,14 @@ function date_repeat_add_dates(&$days, $current_day, $start_date, $end_date, $ex
|
||||
return FALSE;
|
||||
}
|
||||
if (!empty($rrule['BYDAY'])) {
|
||||
$BYDAYS = $rrule['BYDAY'];
|
||||
foreach ($BYDAYS as $delta => $BYDAY) {
|
||||
$BYDAYS[$delta] = substr($BYDAY, -2);
|
||||
$by_days = $rrule['BYDAY'];
|
||||
foreach ($by_days as $delta => $by_day) {
|
||||
$by_days[$delta] = substr($by_day, -2);
|
||||
}
|
||||
if (!in_array(date_repeat_dow2day(date_format($current_day, 'w')), $BYDAYS)) {
|
||||
if (!in_array(date_repeat_dow2day(date_format($current_day, 'w')), $by_days)) {
|
||||
return FALSE;
|
||||
}}
|
||||
}
|
||||
}
|
||||
if (!empty($rrule['BYYEAR']) && !in_array(date_format($current_day, 'Y'), $rrule['BYYEAR'])) {
|
||||
return FALSE;
|
||||
}
|
||||
@@ -472,17 +485,17 @@ function date_repeat_add_dates(&$days, $current_day, $start_date, $end_date, $ex
|
||||
if (!empty($rrule['BYMONTHDAY'])) {
|
||||
// Test month days, but only if there are no negative numbers.
|
||||
$test = TRUE;
|
||||
$BYMONTHDAYS = array();
|
||||
$by_month_days = array();
|
||||
foreach ($rrule['BYMONTHDAY'] as $day) {
|
||||
if ($day > 0) {
|
||||
$BYMONTHDAYS[] = $day;
|
||||
$by_month_days[] = $day;
|
||||
}
|
||||
else {
|
||||
$test = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($test && !empty($BYMONTHDAYS) && !in_array(date_format($current_day, 'j'), $BYMONTHDAYS)) {
|
||||
if ($test && !empty($by_month_days) && !in_array(date_format($current_day, 'j'), $by_month_days)) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -499,7 +512,7 @@ function date_repeat_add_dates(&$days, $current_day, $start_date, $end_date, $ex
|
||||
* Stop when $current_day is greater than $end_date or $count is reached.
|
||||
*/
|
||||
function date_repeat_is_finished($current_day, $days, $count, $end_date) {
|
||||
if (($count && sizeof($days) >= $count)
|
||||
if (($count && count($days) >= $count)
|
||||
|| (!empty($end_date) && date_format($current_day, 'U') > date_format($end_date, 'U'))) {
|
||||
return TRUE;
|
||||
}
|
||||
@@ -517,7 +530,7 @@ function date_repeat_is_finished($current_day, $days, $count, $end_date) {
|
||||
* If $day is empty, will set to the number of days from the
|
||||
* beginning or end of the month.
|
||||
*/
|
||||
function date_repeat_set_month_day($date_in, $day, $count = 1, $direction = '+', $timezone = 'UTC', $modify_time) {
|
||||
function date_repeat_set_month_day($date_in, $day, $count = 1, $direction = '+', $timezone = 'UTC', $modify_time = '') {
|
||||
if (is_object($date_in)) {
|
||||
$current_month = date_format($date_in, 'n');
|
||||
|
||||
@@ -567,7 +580,7 @@ function date_repeat_set_month_day($date_in, $day, $count = 1, $direction = '+',
|
||||
* If $day is empty, will set to the number of days from the
|
||||
* beginning or end of the year.
|
||||
*/
|
||||
function date_repeat_set_year_day($date_in, $month, $day, $count = 1, $direction = '+', $timezone = 'UTC', $modify_time) {
|
||||
function date_repeat_set_year_day($date_in, $month, $day, $count = 1, $direction = '+', $timezone = 'UTC', $modify_time = '') {
|
||||
if (is_object($date_in)) {
|
||||
$current_year = date_format($date_in, 'Y');
|
||||
|
||||
@@ -620,4 +633,4 @@ function date_repeat_set_year_day($date_in, $month, $day, $count = 1, $direction
|
||||
}
|
||||
}
|
||||
return $date_in;
|
||||
}
|
||||
}
|
||||
|
@@ -30,13 +30,16 @@
|
||||
* BYSETPOS
|
||||
* Seldom used anywhere, so no reason to complicated the code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Generate the repeat setting form.
|
||||
*/
|
||||
function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
|
||||
// If the RRULE field is not visible to the user, needs no processing or validation.
|
||||
// The Date field module is not adding this element to forms if the field is hidden,
|
||||
// If the RRULE field is not visible to the user,
|
||||
// needs no processing or validation.
|
||||
// The Date field module is not adding this element to forms
|
||||
// if the field is hidden,
|
||||
// this test is just in case some other module attempts to do so.
|
||||
|
||||
if (date_hidden_element($element)) {
|
||||
@@ -67,16 +70,16 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
$timezone = !empty($element['#date_timezone']) ? $element['#date_timezone'] : date_default_timezone();
|
||||
$merged_values = date_repeat_merge($rrule, $element);
|
||||
|
||||
$UNTIL = '';
|
||||
$until = '';
|
||||
if (!empty($merged_values['UNTIL']['datetime'])) {
|
||||
$until_date = new DateObject($merged_values['UNTIL']['datetime'], $merged_values['UNTIL']['tz']);
|
||||
date_timezone_set($until_date, timezone_open($timezone));
|
||||
$UNTIL = date_format($until_date, DATE_FORMAT_DATETIME);
|
||||
$until = date_format($until_date, DATE_FORMAT_DATETIME);
|
||||
}
|
||||
|
||||
$COUNT = '';
|
||||
$count = '';
|
||||
if (!empty($merged_values['COUNT'])) {
|
||||
$COUNT = $merged_values['COUNT'];
|
||||
$count = $merged_values['COUNT'];
|
||||
}
|
||||
|
||||
$element['FREQ'] = array(
|
||||
@@ -137,7 +140,7 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
);
|
||||
|
||||
list($prefix, $suffix) = explode('@interval', t('Every @interval days', array(), array('context' => 'Date repeat')));
|
||||
$DAILY_INTERVAL = array(
|
||||
$daily_interval = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Repeats', array(), array('context' => 'Date repeat')),
|
||||
'#title_display' => 'invisible',
|
||||
@@ -210,32 +213,34 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
||||
$DAILY_radios_default = 'INTERVAL';
|
||||
$daily_radios_default = 'INTERVAL';
|
||||
if (isset($rrule['FREQ']) && $rrule['FREQ'] === 'DAILY' && !empty($rrule['BYDAY'])) {
|
||||
switch (count($rrule['BYDAY'])) {
|
||||
case 2:
|
||||
$DAILY_radios_default = 'every_tu_th';
|
||||
$daily_radios_default = 'every_tu_th';
|
||||
break;
|
||||
|
||||
case 3:
|
||||
$DAILY_radios_default = 'every_mo_we_fr';
|
||||
$daily_radios_default = 'every_mo_we_fr';
|
||||
break;
|
||||
|
||||
case 5:
|
||||
$DAILY_radios_default = 'every_weekday';
|
||||
$daily_radios_default = 'every_weekday';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$DAILY_every_weekday = array(
|
||||
$daily_every_weekday = array(
|
||||
'#type' => 'item',
|
||||
'#markup' => '<div>' . t('Every weekday', array(), array('context' => 'Date repeat')) . '</div>',
|
||||
);
|
||||
|
||||
$DAILY_mo_we_fr = array(
|
||||
$daily_mo_we_fr = array(
|
||||
'#type' => 'item',
|
||||
'#markup' => '<div>' . t('Every Mon, Wed, Fri', array(), array('context' => 'Date repeat')) . '</div>',
|
||||
);
|
||||
|
||||
$DAILY_tu_th = array(
|
||||
$daily_tu_th = array(
|
||||
'#type' => 'item',
|
||||
'#markup' => '<div>' . t('Every Tue, Thu', array(), array('context' => 'Date repeat')) . '</div>',
|
||||
);
|
||||
@@ -251,17 +256,17 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
":input[name=\"{$element['#name']}[FREQ]\"]" => array('value' => 'DAILY'),
|
||||
),
|
||||
),
|
||||
'#default_value' => $DAILY_radios_default,
|
||||
'#default_value' => $daily_radios_default,
|
||||
'#options' => array(
|
||||
'INTERVAL' => t('interval'),
|
||||
'every_weekday' => t('every weekday'),
|
||||
'every_mo_we_fr' => t('monday wednesday friday'),
|
||||
'every_tu_th' => t('tuesday thursday'),
|
||||
),
|
||||
'INTERVAL_child' => $DAILY_INTERVAL,
|
||||
'every_weekday_child' => $DAILY_every_weekday,
|
||||
'mo_we_fr_child' => $DAILY_mo_we_fr,
|
||||
'tu_th_child' => $DAILY_tu_th,
|
||||
'INTERVAL_child' => $daily_interval,
|
||||
'every_weekday_child' => $daily_every_weekday,
|
||||
'mo_we_fr_child' => $daily_mo_we_fr,
|
||||
'tu_th_child' => $daily_tu_th,
|
||||
'#div_classes' => array(
|
||||
'container-inline interval',
|
||||
'container-inline weekday',
|
||||
@@ -270,18 +275,18 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
),
|
||||
);
|
||||
|
||||
$MONTHLY_day_month_default = 'BYMONTHDAY_BYMONTH';
|
||||
$monthly_day_month_default = 'BYMONTHDAY_BYMONTH';
|
||||
if (isset($rrule['FREQ']) && $rrule['FREQ'] === 'MONTHLY' && !empty($rrule['BYDAY'])) {
|
||||
$MONTHLY_day_month_default = 'BYDAY_BYMONTH';
|
||||
$monthly_day_month_default = 'BYDAY_BYMONTH';
|
||||
}
|
||||
|
||||
$MONTHLY_on_day_BYMONTHDAY_of_BYMONTH = array(
|
||||
$monthly_on_day_bymonthday_of_bymonth = array(
|
||||
'#type' => 'container',
|
||||
'#tree' => TRUE,
|
||||
);
|
||||
|
||||
list($bymonthday_title, $bymonthday_suffix) = explode('@bymonthday', t('On day @bymonthday of', array(), array('context' => 'Date repeat')));
|
||||
$MONTHLY_on_day_BYMONTHDAY_of_BYMONTH['BYMONTHDAY'] = array(
|
||||
$monthly_on_day_bymonthday_of_bymonth['BYMONTHDAY'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => $bymonthday_title,
|
||||
'#default_value' => !empty($rrule['BYMONTHDAY']) && $rrule['FREQ'] === 'MONTHLY' ? $rrule['BYMONTHDAY'] : '',
|
||||
@@ -292,11 +297,11 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
'#field_suffix' => $bymonthday_suffix,
|
||||
);
|
||||
|
||||
$MONTHLY_on_day_BYMONTHDAY_of_BYMONTH['BYMONTH'] = array(
|
||||
$monthly_on_day_bymonthday_of_bymonth['BYMONTH'] = array(
|
||||
'#type' => 'checkboxes',
|
||||
'#title' => t('Bymonth', array(), array('context' => 'Date repeat')),
|
||||
'#title_display' => 'invisible',
|
||||
'#default_value' => !empty($rrule['BYMONTH']) && $rrule['FREQ'] === 'MONTHLY' && $MONTHLY_day_month_default === 'BYMONTHDAY_BYMONTH' ? $rrule['BYMONTH'] : array(),
|
||||
'#default_value' => !empty($rrule['BYMONTH']) && $rrule['FREQ'] === 'MONTHLY' && $monthly_day_month_default === 'BYMONTHDAY_BYMONTH' ? $rrule['BYMONTH'] : array(),
|
||||
'#options' => date_month_names_abbr(TRUE),
|
||||
'#attributes' => array('class' => array('container-inline')),
|
||||
'#multiple' => TRUE,
|
||||
@@ -304,45 +309,45 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
||||
$MONTHLY_on_the_BYDAY_of_BYMONTH = array(
|
||||
$monthly_on_the_byday_of_bymonth = array(
|
||||
'#type' => 'container',
|
||||
'#tree' => TRUE,
|
||||
);
|
||||
|
||||
$MONTHLY_BYDAY_COUNT = '';
|
||||
$MONTHLY_BYDAY_DAY = '';
|
||||
$monthly_byday_count = '';
|
||||
$monthly_byday_day = '';
|
||||
if (isset($rrule['BYDAY']) && !empty($rrule['BYDAY']) && $rrule['FREQ'] === 'MONTHLY') {
|
||||
$MONTHLY_BYDAY_COUNT = substr($rrule['BYDAY'][0], 0, -2);
|
||||
$MONTHLY_BYDAY_DAY = substr($rrule['BYDAY'][0], -2);;
|
||||
$monthly_byday_count = substr($rrule['BYDAY'][0], 0, -2);
|
||||
$monthly_byday_day = substr($rrule['BYDAY'][0], -2);;
|
||||
}
|
||||
|
||||
list($byday_count_title, $byday_day_title) = explode('@byday', t('On the @byday of', array(), array('context' => 'Date repeat')));
|
||||
$MONTHLY_on_the_BYDAY_of_BYMONTH['BYDAY_COUNT'] = array(
|
||||
$monthly_on_the_byday_of_bymonth['BYDAY_COUNT'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => $byday_count_title,
|
||||
'#default_value' => !empty($MONTHLY_BYDAY_COUNT) ? $MONTHLY_BYDAY_COUNT : '',
|
||||
'#default_value' => !empty($monthly_byday_count) ? $monthly_byday_count : '',
|
||||
'#options' => date_order_translated(),
|
||||
'#multiple' => FALSE,
|
||||
'#prefix' => '<div class="date-repeat-input byday-count">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
||||
$MONTHLY_on_the_BYDAY_of_BYMONTH['BYDAY_DAY'] = array(
|
||||
$monthly_on_the_byday_of_bymonth['BYDAY_DAY'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => $byday_day_title,
|
||||
'#title_display' => 'after',
|
||||
'#default_value' => !empty($MONTHLY_BYDAY_DAY) ? $MONTHLY_BYDAY_DAY : '',
|
||||
'#default_value' => !empty($monthly_byday_day) ? $monthly_byday_day : '',
|
||||
'#options' => date_repeat_dow_day_options(TRUE),
|
||||
'#multiple' => FALSE,
|
||||
'#prefix' => '<div class="date-repeat-input byday-day">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
||||
$MONTHLY_on_the_BYDAY_of_BYMONTH['BYMONTH'] = array(
|
||||
$monthly_on_the_byday_of_bymonth['BYMONTH'] = array(
|
||||
'#type' => 'checkboxes',
|
||||
'#title' => t('Bymonth', array(), array('context' => 'Date repeat')),
|
||||
'#title_display' => 'invisible',
|
||||
'#default_value' => !empty($rrule['BYMONTH']) && $rrule['FREQ'] === 'MONTHLY' && $MONTHLY_day_month_default === 'BYDAY_BYMONTH' ? $rrule['BYMONTH'] : array(),
|
||||
'#default_value' => !empty($rrule['BYMONTH']) && $rrule['FREQ'] === 'MONTHLY' && $monthly_day_month_default === 'BYDAY_BYMONTH' ? $rrule['BYMONTH'] : array(),
|
||||
'#options' => date_month_names_abbr(TRUE),
|
||||
'#attributes' => array('class' => array('container-inline')),
|
||||
'#multiple' => TRUE,
|
||||
@@ -361,31 +366,31 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
),
|
||||
),
|
||||
'#attributes' => array('class' => array('date-repeat-radios clearfix')),
|
||||
'#default_value' => $MONTHLY_day_month_default,
|
||||
'#default_value' => $monthly_day_month_default,
|
||||
'#options' => array(
|
||||
'BYMONTHDAY_BYMONTH' => t('On day ... of ...'),
|
||||
'BYDAY_BYMONTH' => t('On the ... of ...'),
|
||||
),
|
||||
'BYMONTHDAY_BYMONTH_child' => $MONTHLY_on_day_BYMONTHDAY_of_BYMONTH,
|
||||
'BYDAY_BYMONTH_child' => $MONTHLY_on_the_BYDAY_of_BYMONTH,
|
||||
'BYMONTHDAY_BYMONTH_child' => $monthly_on_day_bymonthday_of_bymonth,
|
||||
'BYDAY_BYMONTH_child' => $monthly_on_the_byday_of_bymonth,
|
||||
'#div_classes' => array(
|
||||
'date-repeat-radios-item date-clear clearfix bymonthday-bymonth',
|
||||
'date-repeat-radios-item date-clear clearfix byday-bymonth',
|
||||
),
|
||||
);
|
||||
|
||||
$YEARLY_day_month_default = 'BYMONTHDAY_BYMONTH';
|
||||
$yearly_day_month_default = 'BYMONTHDAY_BYMONTH';
|
||||
if (isset($rrule['FREQ']) && $rrule['FREQ'] === 'YEARLY' && !empty($rrule['BYDAY'])) {
|
||||
$YEARLY_day_month_default = 'BYDAY_BYMONTH';
|
||||
$yearly_day_month_default = 'BYDAY_BYMONTH';
|
||||
}
|
||||
|
||||
$YEARLY_on_day_BYMONTHDAY_of_BYMONTH = array(
|
||||
$yearly_on_day_bymonthday_of_bymonth = array(
|
||||
'#type' => 'container',
|
||||
'#tree' => TRUE,
|
||||
);
|
||||
|
||||
list($bymonthday_title, $bymonthday_suffix) = explode('@bymonthday', t('On day @bymonthday of', array(), array('context' => 'Date repeat')));
|
||||
$YEARLY_on_day_BYMONTHDAY_of_BYMONTH['BYMONTHDAY'] = array(
|
||||
$yearly_on_day_bymonthday_of_bymonth['BYMONTHDAY'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => $bymonthday_title,
|
||||
'#default_value' => !empty($rrule['BYMONTHDAY']) && $rrule['FREQ'] === 'YEARLY' ? $rrule['BYMONTHDAY'] : '',
|
||||
@@ -396,11 +401,11 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
'#field_suffix' => $bymonthday_suffix,
|
||||
);
|
||||
|
||||
$YEARLY_on_day_BYMONTHDAY_of_BYMONTH['BYMONTH'] = array(
|
||||
$yearly_on_day_bymonthday_of_bymonth['BYMONTH'] = array(
|
||||
'#type' => 'checkboxes',
|
||||
'#title' => t('Bymonth', array(), array('context' => 'Date repeat')),
|
||||
'#title_display' => 'invisible',
|
||||
'#default_value' => !empty($rrule['BYMONTH']) && $rrule['FREQ'] === 'YEARLY' && $YEARLY_day_month_default === 'BYMONTHDAY_BYMONTH' ? $rrule['BYMONTH'] : array(),
|
||||
'#default_value' => !empty($rrule['BYMONTH']) && $rrule['FREQ'] === 'YEARLY' && $yearly_day_month_default === 'BYMONTHDAY_BYMONTH' ? $rrule['BYMONTH'] : array(),
|
||||
'#options' => date_month_names_abbr(TRUE),
|
||||
'#attributes' => array('class' => array('container-inline')),
|
||||
'#multiple' => TRUE,
|
||||
@@ -408,45 +413,45 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
||||
$YEARLY_on_the_BYDAY_of_BYMONTH = array(
|
||||
$yearly_on_the_byday_of_bymonth = array(
|
||||
'#type' => 'container',
|
||||
'#tree' => TRUE,
|
||||
);
|
||||
|
||||
$YEARLY_BYDAY_COUNT = '';
|
||||
$YEARLY_BYDAY_DAY = '';
|
||||
$yearly_byday_count = '';
|
||||
$yearly_byday_day = '';
|
||||
if (isset($rrule['BYDAY']) && !empty($rrule['BYDAY']) && $rrule['FREQ'] === 'YEARLY') {
|
||||
$YEARLY_BYDAY_COUNT = substr($rrule['BYDAY'][0], 0, -2);
|
||||
$YEARLY_BYDAY_DAY = substr($rrule['BYDAY'][0], -2);;
|
||||
$yearly_byday_count = substr($rrule['BYDAY'][0], 0, -2);
|
||||
$yearly_byday_day = substr($rrule['BYDAY'][0], -2);;
|
||||
}
|
||||
|
||||
list($byday_count_title, $byday_day_title) = explode('@byday', t('On the @byday of', array(), array('context' => 'Date repeat')));
|
||||
$YEARLY_on_the_BYDAY_of_BYMONTH['BYDAY_COUNT'] = array(
|
||||
$yearly_on_the_byday_of_bymonth['BYDAY_COUNT'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => $byday_count_title,
|
||||
'#default_value' => !empty($YEARLY_BYDAY_COUNT) ? $YEARLY_BYDAY_COUNT : '',
|
||||
'#default_value' => !empty($yearly_byday_count) ? $yearly_byday_count : '',
|
||||
'#options' => date_order_translated(),
|
||||
'#multiple' => FALSE,
|
||||
'#prefix' => '<div class="date-repeat-input byday-count">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
||||
$YEARLY_on_the_BYDAY_of_BYMONTH['BYDAY_DAY'] = array(
|
||||
$yearly_on_the_byday_of_bymonth['BYDAY_DAY'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => $byday_day_title,
|
||||
'#title_display' => 'after',
|
||||
'#default_value' => !empty($YEARLY_BYDAY_DAY) ? $YEARLY_BYDAY_DAY : '',
|
||||
'#default_value' => !empty($yearly_byday_day) ? $yearly_byday_day : '',
|
||||
'#options' => date_repeat_dow_day_options(TRUE),
|
||||
'#multiple' => FALSE,
|
||||
'#prefix' => '<div class="date-repeat-input byday-day">',
|
||||
'#suffix' => '</div>',
|
||||
);
|
||||
|
||||
$YEARLY_on_the_BYDAY_of_BYMONTH['BYMONTH'] = array(
|
||||
$yearly_on_the_byday_of_bymonth['BYMONTH'] = array(
|
||||
'#type' => 'checkboxes',
|
||||
'#title' => t('Bymonth', array(), array('context' => 'Date repeat')),
|
||||
'#title_display' => 'invisible',
|
||||
'#default_value' => !empty($rrule['BYMONTH']) && $rrule['FREQ'] === 'YEARLY' && $YEARLY_day_month_default === 'BYDAY_BYMONTH' ? $rrule['BYMONTH'] : array(),
|
||||
'#default_value' => !empty($rrule['BYMONTH']) && $rrule['FREQ'] === 'YEARLY' && $yearly_day_month_default === 'BYDAY_BYMONTH' ? $rrule['BYMONTH'] : array(),
|
||||
'#options' => date_month_names_abbr(TRUE),
|
||||
'#attributes' => array('class' => array('container-inline')),
|
||||
'#multiple' => TRUE,
|
||||
@@ -465,13 +470,13 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
),
|
||||
),
|
||||
'#attributes' => array('class' => array('date-repeat-radios clearfix')),
|
||||
'#default_value' => $YEARLY_day_month_default,
|
||||
'#default_value' => $yearly_day_month_default,
|
||||
'#options' => array(
|
||||
'BYMONTHDAY_BYMONTH' => t('On day ... of ...'),
|
||||
'BYDAY_BYMONTH' => t('On the ... of ...'),
|
||||
),
|
||||
'BYMONTHDAY_BYMONTH_child' => $YEARLY_on_day_BYMONTHDAY_of_BYMONTH,
|
||||
'BYDAY_BYMONTH_child' => $YEARLY_on_the_BYDAY_of_BYMONTH,
|
||||
'BYMONTHDAY_BYMONTH_child' => $yearly_on_day_bymonthday_of_bymonth,
|
||||
'BYDAY_BYMONTH_child' => $yearly_on_the_byday_of_bymonth,
|
||||
'#div_classes' => array(
|
||||
'date-repeat-radios-item date-clear clearfix bymonthday-bymonth',
|
||||
'date-repeat-radios-item date-clear clearfix byday-bymonth',
|
||||
@@ -482,7 +487,7 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
$count_form_element = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Count', array(), array('context' => 'Date repeat')),
|
||||
'#default_value' => $COUNT,
|
||||
'#default_value' => $count,
|
||||
'#element_validate' => array('element_validate_integer_positive'),
|
||||
'#attributes' => array('placeholder' => array('#')),
|
||||
'#prefix' => $prefix,
|
||||
@@ -499,21 +504,26 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
'#type' => $element['#date_repeat_widget'],
|
||||
'#title' => t('Until', array(), array('context' => 'Date repeat')),
|
||||
'#title_display' => 'invisible',
|
||||
'#default_value' => $UNTIL,
|
||||
'#date_format' => !empty($element['#date_format']) ? date_limit_format($element['#date_format'], array('year', 'month', 'day')) : 'Y-m-d',
|
||||
'#default_value' => $until,
|
||||
'#date_format' => !empty($element['#date_format']) ?
|
||||
date_limit_format($element['#date_format'], array('year', 'month', 'day')) : 'Y-m-d',
|
||||
'#date_timezone' => $timezone,
|
||||
'#date_text_parts' => !empty($element['#date_text_parts']) ? $element['#date_text_parts'] : array(),
|
||||
'#date_year_range' => !empty($element['#date_year_range']) ? $element['#date_year_range'] : '-3:+3',
|
||||
'#date_label_position' => !empty($element['#date_label_position']) ? $element['#date_label_position'] : 'within',
|
||||
'#date_label_position' => !empty($element['#date_label_position']) ?
|
||||
$element['#date_label_position'] : 'within',
|
||||
'#date_flexible' => 0,
|
||||
),
|
||||
'tz' => array('#type' => 'hidden', '#value' => $element['#date_timezone']),
|
||||
'all_day' => array('#type' => 'hidden', '#value' => 1),
|
||||
'granularity' => array('#type' => 'hidden', '#value' => serialize(array('year', 'month', 'day'))),
|
||||
'granularity' => array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => serialize(array('year', 'month', 'day')),
|
||||
),
|
||||
);
|
||||
|
||||
$range_of_repeat_default = 'COUNT';
|
||||
if (!empty($UNTIL)) {
|
||||
if (!empty($until)) {
|
||||
$range_of_repeat_default = 'UNTIL';
|
||||
}
|
||||
$element['range_of_repeat'] = array(
|
||||
@@ -528,7 +538,7 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
":input[name=\"{$element['#name']}[FREQ]\"]" => array('value' => 'NONE'),
|
||||
),
|
||||
),
|
||||
'#default_value' => $range_of_repeat_default,
|
||||
'#default_value' => $range_of_repeat_default,
|
||||
'#options' => array(
|
||||
'COUNT' => t('Count'),
|
||||
'UNTIL' => t('Until'),
|
||||
@@ -544,7 +554,8 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
$parents = $element['#array_parents'];
|
||||
$instance = implode('-', $parents);
|
||||
|
||||
// Make sure this will work right either in the normal form or in an ajax callback from the 'Add more' button.
|
||||
// Make sure this will work right either in the normal
|
||||
// form or in an ajax callback from the 'Add more' button.
|
||||
if (empty($form_state['num_exceptions'][$instance])) {
|
||||
$form_state['num_exceptions'][$instance] = count($exceptions);
|
||||
}
|
||||
@@ -576,33 +587,48 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
),
|
||||
),
|
||||
);
|
||||
for ($i = 0; $i < max($form_state['num_exceptions'][$instance], 1) ; $i++) {
|
||||
$EXCEPT = '';
|
||||
for ($i = 0; $i < max($form_state['num_exceptions'][$instance], 1); $i++) {
|
||||
$except = '';
|
||||
if (!empty($exceptions[$i]['datetime'])) {
|
||||
$ex_date = new DateObject($exceptions[$i]['datetime'], $exceptions[$i]['tz']);
|
||||
date_timezone_set($ex_date, timezone_open($timezone));
|
||||
$EXCEPT = date_format($ex_date, DATE_FORMAT_DATETIME);
|
||||
$except = date_format($ex_date, DATE_FORMAT_DATETIME);
|
||||
}
|
||||
$date_format = 'Y-m-d';
|
||||
if (!empty($element['#date_format'])) {
|
||||
$grans = array('year', 'month', 'day');
|
||||
$date_format = date_limit_format($element['#date_format'], $grans);
|
||||
}
|
||||
$element['exceptions']['EXDATE'][$i] = array(
|
||||
'#tree' => TRUE,
|
||||
'datetime' => array(
|
||||
'#name' => 'exceptions|' . $instance,
|
||||
'#type' => $element['#date_repeat_widget'],
|
||||
'#default_value' => $EXCEPT,
|
||||
'#date_timezone' => !empty($element['#date_timezone']) ? $element['#date_timezone'] : date_default_timezone(),
|
||||
'#date_format' => !empty($element['#date_format']) ? date_limit_format($element['#date_format'], array('year', 'month', 'day')) : 'Y-m-d',
|
||||
'#default_value' => $except,
|
||||
'#date_timezone' => !empty($element['#date_timezone']) ?
|
||||
$element['#date_timezone'] : date_default_timezone(),
|
||||
'#date_format' => $date_format,
|
||||
'#date_text_parts' => !empty($element['#date_text_parts']) ? $element['#date_text_parts'] : array(),
|
||||
'#date_year_range' => !empty($element['#date_year_range']) ? $element['#date_year_range'] : '-3:+3',
|
||||
'#date_label_position' => !empty($element['#date_label_position']) ? $element['#date_label_position'] : 'within',
|
||||
'#date_flexible' => 0,
|
||||
),
|
||||
'tz' => array('#type' => 'hidden', '#value' => $element['#date_timezone']),
|
||||
'all_day' => array('#type' => 'hidden', '#value' => 1),
|
||||
'granularity' => array('#type' => 'hidden', '#value' => serialize(array('year', 'month', 'day'))),
|
||||
);
|
||||
),
|
||||
'tz' => array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => $element['#date_timezone'],
|
||||
),
|
||||
'all_day' => array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => 1,
|
||||
),
|
||||
'granularity' => array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => serialize(array('year', 'month', 'day')),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
// collect additions in the same way as exceptions - implements RDATE.
|
||||
// Collect additions in the same way as exceptions - implements RDATE.
|
||||
if (empty($form_state['num_additions'][$instance])) {
|
||||
$form_state['num_additions'][$instance] = count($additions);
|
||||
}
|
||||
@@ -634,30 +660,45 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
),
|
||||
),
|
||||
);
|
||||
for ($i = 0; $i < max($form_state['num_additions'][$instance], 1) ; $i++) {
|
||||
$RDATE = '';
|
||||
for ($i = 0; $i < max($form_state['num_additions'][$instance], 1); $i++) {
|
||||
$r_date = '';
|
||||
if (!empty($additions[$i]['datetime'])) {
|
||||
$rdate = new DateObject($additions[$i]['datetime'], $additions[$i]['tz']);
|
||||
date_timezone_set($rdate, timezone_open($timezone));
|
||||
$RDATE = date_format($rdate, DATE_FORMAT_DATETIME);
|
||||
$r_date = date_format($rdate, DATE_FORMAT_DATETIME);
|
||||
}
|
||||
$date_format = 'Y-m-d';
|
||||
if (!empty($element['#date_format'])) {
|
||||
$grans = array('year', 'month', 'day');
|
||||
$date_format = date_limit_format($element['#date_format'], $grans);
|
||||
}
|
||||
$element['additions']['RDATE'][$i] = array(
|
||||
'#tree' => TRUE,
|
||||
'datetime' => array(
|
||||
'#type' => $element['#date_repeat_widget'],
|
||||
'#name' => 'additions|' . $instance,
|
||||
'#default_value' => $RDATE,
|
||||
'#date_timezone' => !empty($element['#date_timezone']) ? $element['#date_timezone'] : date_default_timezone(),
|
||||
'#date_format' => !empty($element['#date_format']) ? date_limit_format($element['#date_format'], array('year', 'month', 'day')) : 'Y-m-d',
|
||||
'#default_value' => $r_date,
|
||||
'#date_timezone' => !empty($element['#date_timezone']) ?
|
||||
$element['#date_timezone'] : date_default_timezone(),
|
||||
'#date_format' => $date_format,
|
||||
'#date_text_parts' => !empty($element['#date_text_parts']) ? $element['#date_text_parts'] : array(),
|
||||
'#date_year_range' => !empty($element['#date_year_range']) ? $element['#date_year_range'] : '-3:+3',
|
||||
'#date_label_position' => !empty($element['#date_label_position']) ? $element['#date_label_position'] : 'within',
|
||||
'#date_flexible' => 0,
|
||||
),
|
||||
'tz' => array('#type' => 'hidden', '#value' => $element['#date_timezone']),
|
||||
'all_day' => array('#type' => 'hidden', '#value' => 1),
|
||||
'granularity' => array('#type' => 'hidden', '#value' => serialize(array('year', 'month', 'day'))),
|
||||
);
|
||||
),
|
||||
'tz' => array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => $element['#date_timezone'],
|
||||
),
|
||||
'all_day' => array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => 1,
|
||||
),
|
||||
'granularity' => array(
|
||||
'#type' => 'hidden',
|
||||
'#value' => serialize(array('year', 'month', 'day')),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$element['exceptions']['exceptions_add'] = array(
|
||||
@@ -687,6 +728,9 @@ function _date_repeat_rrule_process($element, &$form_state, $form) {
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add callback to date repeat.
|
||||
*/
|
||||
function date_repeat_add_exception_callback($form, &$form_state) {
|
||||
$parents = $form_state['triggering_element']['#array_parents'];
|
||||
$button_key = array_pop($parents);
|
||||
@@ -694,6 +738,9 @@ function date_repeat_add_exception_callback($form, &$form_state) {
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add addition callback to date repeat.
|
||||
*/
|
||||
function date_repeat_add_addition_callback($form, &$form_state) {
|
||||
$parents = $form_state['triggering_element']['#array_parents'];
|
||||
$button_key = array_pop($parents);
|
||||
@@ -701,6 +748,9 @@ function date_repeat_add_addition_callback($form, &$form_state) {
|
||||
return $element;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add exception to date repeat.
|
||||
*/
|
||||
function date_repeat_add_exception($form, &$form_state) {
|
||||
$parents = $form_state['triggering_element']['#array_parents'];
|
||||
$instance = implode('-', array_slice($parents, 0, count($parents) - 2));
|
||||
@@ -708,6 +758,9 @@ function date_repeat_add_exception($form, &$form_state) {
|
||||
$form_state['rebuild'] = TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add addition to date repeat.
|
||||
*/
|
||||
function date_repeat_add_addition($form, &$form_state) {
|
||||
$parents = $form_state['triggering_element']['#array_parents'];
|
||||
$instance = implode('-', array_slice($parents, 0, count($parents) - 2));
|
||||
@@ -723,8 +776,14 @@ function date_repeat_merge($form_values, $element) {
|
||||
return $form_values;
|
||||
}
|
||||
if (array_key_exists('exceptions', $form_values) || array_key_exists('additions', $form_values)) {
|
||||
if (!array_key_exists('exceptions', $form_values)) $form_values['exceptions'] = array();
|
||||
if (!array_key_exists('additions', $form_values)) $form_values['additions'] = 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['exceptions'], (array) $form_values['additions']);
|
||||
unset($form_values['exceptions']);
|
||||
unset($form_values['additions']);
|
||||
@@ -738,18 +797,22 @@ function date_repeat_merge($form_values, $element) {
|
||||
case 'INTERVAL':
|
||||
$form_values['INTERVAL'] = $form_values['daily']['INTERVAL_child'];
|
||||
break;
|
||||
|
||||
case 'every_weekday':
|
||||
$form_values['BYDAY'] = array('MO', 'TU', 'WE', 'TH', 'FR');
|
||||
break;
|
||||
|
||||
case 'every_mo_we_fr':
|
||||
$form_values['BYDAY'] = array('MO', 'WE', 'FR');
|
||||
break;
|
||||
|
||||
case 'every_tu_th':
|
||||
$form_values['BYDAY'] = array('TU', 'TH');
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'WEEKLY':
|
||||
if (array_key_exists('weekly', $form_values)) {
|
||||
$form_values = array_merge($form_values, (array) $form_values['weekly']);
|
||||
@@ -758,12 +821,14 @@ function date_repeat_merge($form_values, $element) {
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'MONTHLY':
|
||||
if (array_key_exists('monthly', $form_values)) {
|
||||
switch ($form_values['monthly']['day_month']) {
|
||||
case 'BYMONTHDAY_BYMONTH':
|
||||
$form_values['monthly'] = array_merge($form_values['monthly'], (array) $form_values['monthly']['BYMONTHDAY_BYMONTH_child']);
|
||||
break;
|
||||
|
||||
case 'BYDAY_BYMONTH':
|
||||
$form_values['monthly']['BYDAY_BYMONTH_child']['BYDAY'] = $form_values['monthly']['BYDAY_BYMONTH_child']['BYDAY_COUNT'] . $form_values['monthly']['BYDAY_BYMONTH_child']['BYDAY_DAY'];
|
||||
$form_values['monthly'] = array_merge($form_values['monthly'], (array) $form_values['monthly']['BYDAY_BYMONTH_child']);
|
||||
@@ -783,12 +848,14 @@ function date_repeat_merge($form_values, $element) {
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'YEARLY':
|
||||
if (array_key_exists('yearly', $form_values)) {
|
||||
switch ($form_values['yearly']['day_month']) {
|
||||
case 'BYMONTHDAY_BYMONTH':
|
||||
$form_values['yearly'] = array_merge($form_values['yearly'], (array) $form_values['yearly']['BYMONTHDAY_BYMONTH_child']);
|
||||
break;
|
||||
|
||||
case 'BYDAY_BYMONTH':
|
||||
$form_values['yearly']['BYDAY_BYMONTH_child']['BYDAY'] = $form_values['yearly']['BYDAY_BYMONTH_child']['BYDAY_COUNT'] . $form_values['yearly']['BYDAY_BYMONTH_child']['BYDAY_DAY'];
|
||||
$form_values['yearly'] = array_merge($form_values['yearly'], (array) $form_values['yearly']['BYDAY_BYMONTH_child']);
|
||||
@@ -808,6 +875,7 @@ function date_repeat_merge($form_values, $element) {
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -823,6 +891,7 @@ function date_repeat_merge($form_values, $element) {
|
||||
case 'COUNT':
|
||||
$form_values['COUNT'] = $form_values['count_child'];
|
||||
break;
|
||||
|
||||
case 'UNTIL':
|
||||
$form_values['UNTIL'] = $form_values['until_child'];
|
||||
break;
|
||||
@@ -832,14 +901,23 @@ function date_repeat_merge($form_values, $element) {
|
||||
unset($form_values['count_child']);
|
||||
unset($form_values['until_child']);
|
||||
|
||||
if (array_key_exists('BYDAY', $form_values) && is_array($form_values['BYDAY'])) unset($form_values['BYDAY']['']);
|
||||
if (array_key_exists('BYMONTH', $form_values) && is_array($form_values['BYMONTH'])) unset($form_values['BYMONTH']['']);
|
||||
if (array_key_exists('BYMONTHDAY', $form_values) && is_array($form_values['BYMONTHDAY'])) unset($form_values['BYMONTHDAY']['']);
|
||||
if (array_key_exists('BYDAY', $form_values) && is_array($form_values['BYDAY'])) {
|
||||
unset($form_values['BYDAY']['']);
|
||||
}
|
||||
|
||||
if (array_key_exists('BYMONTH', $form_values) && is_array($form_values['BYMONTH'])) {
|
||||
unset($form_values['BYMONTH']['']);
|
||||
}
|
||||
|
||||
if (array_key_exists('BYMONTHDAY', $form_values) && is_array($form_values['BYMONTHDAY'])) {
|
||||
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'] = !empty($element['#date_format']) ? date_limit_format($element['#date_format'], array('year', 'month', 'day')) : 'Y-m-d';
|
||||
$until_element['#date_format'] = !empty($element['#date_format']) ?
|
||||
date_limit_format($element['#date_format'], array('year', 'month', 'day')) : 'Y-m-d';
|
||||
$date = $function($until_element, $form_values['UNTIL']['datetime']);
|
||||
$form_values['UNTIL']['datetime'] = is_object($date) ? $date->format(DATE_FORMAT_DATETIME) : '';
|
||||
}
|
||||
@@ -849,9 +927,14 @@ function date_repeat_merge($form_values, $element) {
|
||||
if (array_key_exists('EXDATE', $form_values) && is_array($form_values['EXDATE'])) {
|
||||
$function = $element['#date_repeat_widget'] . '_input_date';
|
||||
$exdate_element = $element;
|
||||
$date_format = 'Y-m-d';
|
||||
if (!empty($element['#date_format'])) {
|
||||
$grans = array('year', 'month', 'day');
|
||||
$date_format = date_limit_format($element['#date_format'], $grans);
|
||||
}
|
||||
foreach ($form_values['EXDATE'] as $delta => $value) {
|
||||
if (is_array($value['datetime'])) {
|
||||
$exdate_element['#date_format'] = !empty($element['#date_format']) ? date_limit_format($element['#date_format'], array('year', 'month', 'day')) : 'Y-m-d';
|
||||
$exdate_element['#date_format'] = $date_format;
|
||||
$date = $function($exdate_element, $form_values['EXDATE'][$delta]['datetime']);
|
||||
$form_values['EXDATE'][$delta]['datetime'] = is_object($date) ? $date->format(DATE_FORMAT_DATETIME) : '';
|
||||
}
|
||||
@@ -864,9 +947,14 @@ function date_repeat_merge($form_values, $element) {
|
||||
if (array_key_exists('RDATE', $form_values) && is_array($form_values['RDATE'])) {
|
||||
$function = $element['#date_repeat_widget'] . '_input_date';
|
||||
$rdate_element = $element;
|
||||
$date_format = 'Y-m-d';
|
||||
if (!empty($element['#date_format'])) {
|
||||
$grans = array('year', 'month', 'day');
|
||||
$date_format = date_limit_format($element['#date_format'], $grans);
|
||||
}
|
||||
foreach ($form_values['RDATE'] as $delta => $value) {
|
||||
if (is_array($value['datetime'])) {
|
||||
$rdate_element['#date_format'] = !empty($element['#date_format']) ? date_limit_format($element['#date_format'], array('year', 'month', 'day')) : 'Y-m-d';
|
||||
$rdate_element['#date_format'] = $date_format;
|
||||
$date = $function($rdate_element, $form_values['RDATE'][$delta]['datetime']);
|
||||
$form_values['RDATE'][$delta]['datetime'] = is_object($date) ? $date->format(DATE_FORMAT_DATETIME) : '';
|
||||
}
|
||||
@@ -910,7 +998,7 @@ function date_repeat_rrule_validate($element, &$form_state) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme the exception list as a table so the buttons line up
|
||||
* Theme the exception list as a table so the buttons line up.
|
||||
*/
|
||||
function theme_date_repeat_current_exceptions($vars) {
|
||||
$rows = $vars['rows'];
|
||||
@@ -920,11 +1008,14 @@ function theme_date_repeat_current_exceptions($vars) {
|
||||
$rows_info[] = array(drupal_render($value['action']), drupal_render($value['display']));
|
||||
}
|
||||
}
|
||||
return theme('table', array('header' => array(t('Delete'), t('Current exceptions')), 'rows' => $rows_info));
|
||||
return theme('table', array(
|
||||
'header' => array(t('Delete'), t('Current exceptions')),
|
||||
'rows' => $rows_info)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Theme the exception list as a table so the buttons line up
|
||||
/**
|
||||
* Theme the exception list as a table so the buttons line up.
|
||||
*/
|
||||
function theme_date_repeat_current_additions($rows = array()) {
|
||||
$rows_info = array();
|
||||
@@ -933,7 +1024,10 @@ function theme_date_repeat_current_additions($rows = array()) {
|
||||
$rows_info[] = array(drupal_render($value['action']), drupal_render($value['display']));
|
||||
}
|
||||
}
|
||||
return theme('table', array('header' => array(t('Delete'), t('Current additions')), 'rows' => $rows_info));
|
||||
return theme('table', array(
|
||||
'header' => array(t('Delete'), t('Current additions')),
|
||||
'rows' => $rows_info)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -943,7 +1037,13 @@ function theme_date_repeat_rrule($vars) {
|
||||
$element = $vars['element'];
|
||||
$id = drupal_html_id('repeat-settings-fieldset');
|
||||
$parents = $element['#parents'];
|
||||
$selector = "{$parents[0]}[{$parents[1]}][{$parents[2]}][show_repeat_settings]";
|
||||
|
||||
$selector = $parents[0];
|
||||
for ($i = 1; $i < count($parents) - 1; $i++) {
|
||||
$selector .= '[' . $parents[$i] . ']';
|
||||
}
|
||||
$selector .= '[show_repeat_settings]';
|
||||
|
||||
$fieldset = array(
|
||||
'#type' => 'item',
|
||||
'#title' => t('Repeat settings'),
|
||||
@@ -960,6 +1060,9 @@ function theme_date_repeat_rrule($vars) {
|
||||
return drupal_render($fieldset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter non zero values.
|
||||
*/
|
||||
function date_repeat_filter_non_zero_value($value) {
|
||||
return $value !== 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user