Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Correctly show multi-day events if the shortened view is disabled (see
Browse files Browse the repository at this point in the history
  • Loading branch information
leofeyer committed Sep 26, 2017
1 parent 5db1ef7 commit c1748b3
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 72 deletions.
3 changes: 3 additions & 0 deletions system/docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Contao Open Source CMS changelog
Version 3.5.29 (2017-XX-XX)
---------------------------

### Fixed
Correctly show multi-day events if the shortened view is disabled (see #8782).

### Fixed
Do not add a suffix when copying if the "doNotCopy" flag is set (see #8610).

Expand Down
103 changes: 31 additions & 72 deletions system/modules/calendar/classes/Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -369,18 +369,22 @@ protected function addEvent($objEvents, $intStart, $intEnd, $strUrl, $intBegin,
$this->arrEvents[$intKey][$intStart][] = $arrEvent;

// Multi-day event
for ($i=1; $i<=$span && $intDate<=$intLimit; $i++)
for ($i=1; $i<=$span; $i++)
{
// Only show first occurrence
if ($this->cal_noSpan)
{
break;
}

$intDate = strtotime('+ 1 day', $intDate);
$intNextKey = date('Ymd', $intDate);
$intDate = strtotime('+1 day', $intDate);

$this->arrEvents[$intNextKey][$intDate][] = $arrEvent;
if ($intDate > $intLimit)
{
break;
}

$this->arrEvents[date('Ymd', $intDate)][$intDate][] = $arrEvent;
}
}

Expand Down Expand Up @@ -447,134 +451,89 @@ protected function getDatesFromFormat(\Date $objDate, $strFormat)
{
case 'cal_day':
return array($objDate->dayBegin, $objDate->dayEnd, $GLOBALS['TL_LANG']['MSC']['cal_emptyDay']);
break;

default:
case 'cal_month':
return array($objDate->monthBegin, $objDate->monthEnd, $GLOBALS['TL_LANG']['MSC']['cal_emptyMonth']);
break;

case 'cal_year':
return array($objDate->yearBegin, $objDate->yearEnd, $GLOBALS['TL_LANG']['MSC']['cal_emptyYear']);
break;

case 'cal_all': // 1970-01-01 00:00:00 - 2038-01-01 00:00:00
return array(0, 2145913200, $GLOBALS['TL_LANG']['MSC']['cal_empty']);
break;

case 'next_7':
return array(time(), (strtotime('+7 days') - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);
break;
return array(time(), (strtotime('+7 days 23:59:59') - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);

case 'next_14':
return array(time(), (strtotime('+14 days') - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);
break;
return array(time(), (strtotime('+14 days 23:59:59') - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);

case 'next_30':
return array(time(), (strtotime('+1 month') - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);
break;
return array(time(), (strtotime('+1 month 23:59:59') - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);

case 'next_90':
return array(time(), (strtotime('+3 months') - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);
break;
return array(time(), (strtotime('+3 months 23:59:59') - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);

case 'next_180':
return array(time(), (strtotime('+6 months') - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);
break;
return array(time(), (strtotime('+6 months 23:59:59') - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);

case 'next_365':
return array(time(), (strtotime('+1 year') - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);
break;
return array(time(), (strtotime('+1 year 23:59:59') - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);

case 'next_two':
return array(time(), (strtotime('+2 years') - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);
break;
return array(time(), (strtotime('+2 years 23:59:59') - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);

case 'next_cur_month':
$objToday = new \Date();

return array(time(), $objToday->monthEnd, $GLOBALS['TL_LANG']['MSC']['cal_empty']);
break;
return array(time(), strtotime('last day of this month 23:59:59'), $GLOBALS['TL_LANG']['MSC']['cal_empty']);

case 'next_cur_year':
$objToday = new \Date();

return array(time(), $objToday->yearEnd, $GLOBALS['TL_LANG']['MSC']['cal_empty']);
break;
return array(time(), strtotime('last day of december this year 23:59:59'), $GLOBALS['TL_LANG']['MSC']['cal_empty']);

case 'next_next_month':
$objToday = new \Date();

return array(($objToday->monthEnd + 1), strtotime('+1 month', $objToday->monthEnd), $GLOBALS['TL_LANG']['MSC']['cal_empty']);
break;
return array(strtotime('first day of next month 00:00:00'), strtotime('last day of next month 23:59:59'), $GLOBALS['TL_LANG']['MSC']['cal_empty']);

case 'next_next_year':
$objToday = new \Date();

return array(($objToday->yearEnd + 1), strtotime('+1 year', $objToday->yearEnd), $GLOBALS['TL_LANG']['MSC']['cal_empty']);
break;
return array(strtotime('first day of january next year 00:00:00'), strtotime('last day of december next year 23:59:59'), $GLOBALS['TL_LANG']['MSC']['cal_empty']);

case 'next_all': // 2038-01-01 00:00:00
return array(time(), 2145913200, $GLOBALS['TL_LANG']['MSC']['cal_empty']);
break;

case 'past_7':
return array(strtotime('-7 days'), (time() - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);
break;
return array(strtotime('-7 days 00:00:00'), (time() - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);

case 'past_14':
return array(strtotime('-14 days'), (time() - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);
break;
return array(strtotime('-14 days 00:00:00'), (time() - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);

case 'past_30':
return array(strtotime('-1 month'), (time() - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);
break;
return array(strtotime('-1 month 00:00:00'), (time() - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);

case 'past_90':
return array(strtotime('-3 months'), (time() - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);
break;
return array(strtotime('-3 months 00:00:00'), (time() - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);

case 'past_180':
return array(strtotime('-6 months'), (time() - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);
break;
return array(strtotime('-6 months 00:00:00'), (time() - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);

case 'past_365':
return array(strtotime('-1 year'), (time() - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);
break;
return array(strtotime('-1 year 00:00:00'), (time() - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);

case 'past_two':
return array(strtotime('-2 years'), (time() - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);
break;
return array(strtotime('-2 years 00:00:00'), (time() - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);

case 'past_cur_month':
$objToday = new \Date();

return array($objToday->monthBegin, (time() - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);
break;
return array(strtotime('first day of this month 00:00:00'), (time() - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);

case 'past_cur_year':
$objToday = new \Date();

return array($objToday->yearBegin, (time() - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);
break;
return array(strtotime('first day of january this year 00:00:00'), (time() - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);

case 'past_prev_month':
$objToday = new \Date();

return array(strtotime('-1 month', $objToday->monthBegin), ($objToday->monthBegin - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);
break;
return array(strtotime('first day of last month 00:00:00'), strtotime('last day of last month 23:59:59'), $GLOBALS['TL_LANG']['MSC']['cal_empty']);

case 'past_prev_year':
$objToday = new \Date();

return array(strtotime('-1 year', $objToday->yearBegin), ($objToday->yearBegin - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);
break;
return array(strtotime('first day of january last year 00:00:00'), strtotime('last day of december last year 23:59:59'), $GLOBALS['TL_LANG']['MSC']['cal_empty']);

case 'past_all': // 1970-01-01 00:00:00
$objToday = new \Date();

return array(0, ($objToday->dayBegin - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);
break;
return array(0, (time() - 1), $GLOBALS['TL_LANG']['MSC']['cal_empty']);
}
}
}
10 changes: 10 additions & 0 deletions system/modules/calendar/modules/ModuleEventlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,16 @@ protected function compile()
{
foreach ($days as $day=>$events)
{
if (strncmp($this->cal_format, 'next_', 5) === 0 && $day < $intStart)
{
continue;
}

if (strncmp($this->cal_format, 'past_', 5) === 0 && $day >= $intEnd)
{
continue;
}

foreach ($events as $event)
{
// Use repeatEnd if > 0 (see #8447)
Expand Down

0 comments on commit c1748b3

Please sign in to comment.