示例#1
0
 /**
  * Draws the month view
  *  @param		$page	string		The page template
  *  @param		$offset	integer		The month offset. Default = +0
  *  @param		$type	integer		The date of the event
  *	@return		string		The HTML output.
  */
 function _draw_month($page, $offset = '+0', $type)
 {
     $viewTarget = $this->conf['view.']['monthLinkTarget'];
     $monthTemplate = $this->cObj->getSubpart($page, '###MONTH_TEMPLATE###');
     if ($monthTemplate != '') {
         $loop_wd = $this->cObj->getSubpart($monthTemplate, '###LOOPWEEKDAY###');
         $t_month = $this->cObj->getSubpart($monthTemplate, '###SWITCHMONTHDAY###');
         $startweek = $this->cObj->getSubpart($monthTemplate, '###LOOPMONTHWEEKS_DAYS###');
         $endweek = $this->cObj->getSubpart($monthTemplate, '###LOOPMONTHDAYS_WEEKS###');
         $weeknum = $this->cObj->getSubpart($monthTemplate, '###LOOPWEEK_NUMS###');
         $corner = $this->cObj->getSubpart($monthTemplate, '###CORNER###');
         /* 11.12.2008 Franz:
          * why is there a limitation that only MEDIUM calendar sheets can have absolute offsets and vice versa?
          * I'm commenting this out and make it more flexible.
          */
         #if ($type != 'medium') {  // old one
         if (preg_match('![+|-][0-9]{1,2}!is', $offset)) {
             // new one
             $fake_getdate_time = new \TYPO3\CMS\Cal\Model\CalDate();
             $fake_getdate_time->copy($this->controller->getDateTimeObject);
             $fake_getdate_time->setDay(15);
             if (intval($offset) < 0) {
                 $fake_getdate_time->subtractSeconds(abs(intval($offset)) * 2592000);
             } else {
                 $fake_getdate_time->addSeconds(intval($offset) * 2592000);
             }
         } else {
             $fake_getdate_time = new \TYPO3\CMS\Cal\Model\CalDate();
             $fake_getdate_time->copy($this->controller->getDateTimeObject);
             $fake_getdate_time->setDay(15);
             $fake_getdate_time->setMonth($offset);
         }
         $minical_month = $fake_getdate_time->getMonth();
         $minical_year = $fake_getdate_time->getYear();
         $today = new \TYPO3\CMS\Cal\Model\CalDate();
         $month_title = $fake_getdate_time->format($this->conf['view.'][$viewTarget . '.']['dateFormatMonth']);
         $this->initLocalCObject();
         $this->local_cObj->setCurrentVal($month_title);
         $this->local_cObj->data['view'] = $viewTarget;
         $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('getdate' => $fake_getdate_time->format('%Y%m%d'), 'view' => $viewTarget, $this->pointerName => NULL), $this->conf['cache'], $this->conf['clear_anyway'], $this->conf['view.'][$viewTarget . '.'][$viewTarget . 'ViewPid']);
         $month_title = $this->local_cObj->cObjGetSingle($this->conf['view.'][$viewTarget . '.'][$viewTarget . 'ViewLink'], $this->conf['view.'][$viewTarget . '.'][$viewTarget . 'ViewLink.']);
         $month_date = $fake_getdate_time->format('%Y%m%d');
         $view_array = array();
         if (!$this->viewarray) {
             $this->eventArray = array();
             if (!empty($this->master_array)) {
                 // use array keys for the loop in order to be able to use referenced events instead of copies and save some memory
                 $masterArrayKeys = array_keys($this->master_array);
                 foreach ($masterArrayKeys as $dateKey) {
                     $dateArray =& $this->master_array[$dateKey];
                     $dateArrayKeys = array_keys($dateArray);
                     foreach ($dateArrayKeys as $timeKey) {
                         $arrayOfEvents =& $dateArray[$timeKey];
                         $eventKeys = array_keys($arrayOfEvents);
                         foreach ($eventKeys as $eventKey) {
                             $event =& $arrayOfEvents[$eventKey];
                             $eventReferenceKey = $dateKey . '_' . $event->getType() . '_' . $event->getUid() . '_' . $event->getStart()->format('%Y%m%d%H%M%S');
                             $this->eventArray[$eventReferenceKey] =& $event;
                             $starttime = new \TYPO3\CMS\Cal\Model\CalDate();
                             $starttime->copy($event->getStart());
                             $endtime = new \TYPO3\CMS\Cal\Model\CalDate();
                             $endtime->copy($event->getEnd());
                             if ($timeKey == '-1') {
                                 $endtime->addSeconds(1);
                                 // needed to let allday events show up
                             }
                             $j = new \TYPO3\CMS\Cal\Model\CalDate();
                             $j->copy($starttime);
                             $j->setHour(0);
                             $j->setMinute(0);
                             $j->setSecond(0);
                             for (; $j->before($endtime); $j->addSeconds(60 * 60 * 24)) {
                                 $view_array[$j->format('%Y%m%d')]['000000'][count($view_array[$j->format('%Y%m%d')]['000000'])] = $eventReferenceKey;
                             }
                         }
                     }
                 }
             }
             $this->viewarray =& $view_array;
         }
         $monthTemplate = str_replace('###MONTH_TITLE###', $month_title, $monthTemplate);
         $langtype = $this->conf['view.']['month.']['weekdayFormat' . ucwords($type) . 'Month'];
         $typeSize = intval($this->conf['view.']['month.']['weekdayLength' . ucwords($type) . 'Month']);
         $dateOfWeek = Calc::beginOfWeek(15, $fake_getdate_time->getMonth(), $fake_getdate_time->getYear());
         $start_day = new \TYPO3\CMS\Cal\Model\CalDate($dateOfWeek . '000000');
         // backwardscompatibility with old templates
         if (!empty($corner)) {
             $weekday_loop .= str_replace('###ADDITIONAL_CLASSES###', $this->conf['view.']['month.']['monthCornerStyle'], $corner);
         } else {
             $weekday_loop .= sprintf($weeknum, $this->conf['view.']['month.']['monthCornerStyle'], '');
         }
         for ($i = 0; $i < 7; $i++) {
             $weekday = $start_day->format($langtype);
             $weekdayLong = $start_day->format('%A');
             if ($typeSize) {
                 $weekday = $this->cs_convert->substr(\TYPO3\CMS\Cal\Utility\Functions::getCharset(), $weekday, 0, $typeSize);
             }
             $start_day->addSeconds(86400);
             $additionalClasses = trim(sprintf($this->conf['view.']['month.']['monthDayOfWeekStyle'], $start_day->format('%w')));
             $markerArray = array('###WEEKDAY###' => $weekday, '###WEEKDAY_LONG###' => $weekdayLong, '###ADDITIONAL_CLASSES###' => ' ' . $additionalClasses, '###CLASSES###' => !empty($additionalClasses) ? ' class="' . $additionalClasses . '" ' : '');
             $weekday_loop .= strtr($loop_wd, $markerArray);
         }
         $weekday_loop .= $endweek;
         $dateOfWeek = Calc::beginOfWeek(1, $fake_getdate_time->getMonth(), $fake_getdate_time->getYear());
         $endOfMonth = $this->controller->getListViewTime('monthend', $start_day);
         $start_day = new \TYPO3\CMS\Cal\Model\CalDate($dateOfWeek . '000000');
         $start_day->setTZbyID('UTC');
         $i = 0;
         $whole_month = TRUE;
         $isAllowedToCreateEvent = $this->rightsObj->isAllowedToCreateEvent();
         $createOffset = intval($this->conf['rights.']['create.']['event.']['timeOffset']) * 60;
         $getdate = new \TYPO3\CMS\Cal\Model\CalDate($this->conf['getdate']);
         $getdate->setTZbyID('UTC');
         $startWeekTime = \TYPO3\CMS\Cal\Controller\Calendar::calculateStartWeekTime($getdate);
         $endWeekTime = \TYPO3\CMS\Cal\Controller\Calendar::calculateEndWeekTime($getdate);
         $formattedWeekStartTime = $startWeekTime->format('%Y%m%d');
         $formattedWeekEndTime = $endWeekTime->format('%Y%m%d');
         do {
             $daylink = new \TYPO3\CMS\Cal\Model\CalDate();
             $daylink->copy($start_day);
             $formatedGetdate = $daylink->format('%Y%m%d');
             $formatedDayDate = $daylink->format($this->conf['view.']['month.']['dateFormatDay']);
             $isCurrentWeek = false;
             $isSelectedWeek = false;
             if ($formatedGetdate >= $formattedWeekStartTime && $formatedGetdate <= $formattedWeekEndTime) {
                 $isSelectedWeek = true;
             }
             if ($start_day->format('%Y%U') == $today->format('%Y%U')) {
                 $isCurrentWeek = true;
             }
             if ($i == 0 && !empty($weeknum)) {
                 $start_day->addSeconds(86400);
                 $num = $numPlain = $start_day->getWeekOfYear();
                 $hasEvent = false;
                 $start_day->subtractSeconds(86400);
                 for ($j = 0; $j < 7; $j++) {
                     if (is_array($this->viewarray[$start_day->format('%Y%m%d')]) || $isAllowedToCreateEvent) {
                         $hasEvent = true;
                         break;
                     }
                     $start_day->addSeconds(86400);
                 }
                 $start_day->copy($daylink);
                 $weekLinkViewTarget = $this->conf['view.']['weekLinkTarget'];
                 if (($this->rightsObj->isViewEnabled($weekLinkViewTarget) || $this->conf['view.'][$weekLinkViewTarget . '.'][$weekLinkViewTarget . 'ViewPid']) && $hasEvent) {
                     $this->initLocalCObject();
                     $this->local_cObj->setCurrentVal($num);
                     $this->local_cObj->data['view'] = $weekLinkViewTarget;
                     $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('getdate' => $formatedGetdate, 'view' => $weekLinkViewTarget, $this->pointerName => NULL), $this->conf['cache'], $this->conf['clear_anyway'], $this->conf['view.'][$weekLinkViewTarget . '.'][$weekLinkViewTarget . 'ViewPid']);
                     $num = $this->local_cObj->cObjGetSingle($this->conf['view.'][$weekLinkViewTarget . '.'][$weekLinkViewTarget . 'ViewLink'], $this->conf['view.'][$weekLinkViewTarget . '.'][$weekLinkViewTarget . 'ViewLink.']);
                 }
                 $className = array();
                 if ($isSelectedWeek && !empty($this->conf['view.']['month.']['monthSelectedWeekStyle'])) {
                     $className[] = $this->conf['view.']['month.']['monthSelectedWeekStyle'];
                 }
                 if ($isCurrentWeek && !empty($this->conf['view.']['month.']['monthCurrentWeekStyle'])) {
                     $className[] = $this->conf['view.']['month.']['monthCurrentWeekStyle'];
                 }
                 if ($hasEvent && !empty($this->conf['view.']['month.']['monthWeekWithEventStyle'])) {
                     $className[] = $this->conf['view.']['month.']['monthWeekWithEventStyle'];
                 }
                 $weekClasses = trim(implode(' ', $className));
                 $markerArray = array('###ADDITIONAL_CLASSES###' => $weekClasses ? ' ' . $weekClasses : '', '###CLASSES###' => $weekClasses ? ' class="' . $weekClasses . '" ' : '', '###WEEKNUM###' => $num, '###WEEKNUM_PLAIN###' => $numPlain);
                 $middle .= strtr($startweek, $markerArray);
                 // we do this sprintf all only for backwards compatibility with old templates
                 $middle .= strtr(sprintf($weeknum, $markerArray['###ADDITIONAL_CLASSES###'], $num), $markerArray);
             }
             $i++;
             $switch = array('###ALLDAY###' => '');
             $check_month = $start_day->getMonth();
             $switch['###LINK###'] = $this->getCreateEventLink('month', '', $start_day, $createOffset, $isAllowedToCreateEvent, '', '', $this->conf['view.']['day.']['dayStart']);
             $style = array();
             $dayLinkViewTarget = $this->conf['view.']['dayLinkTarget'];
             if (($this->rightsObj->isViewEnabled($dayLinkViewTarget) || $this->conf['view.'][$dayLinkViewTarget . '.'][$dayLinkViewTarget . 'ViewPid']) && ($this->viewarray[$formatedGetdate] || $isAllowedToCreateEvent)) {
                 $this->initLocalCObject();
                 $this->local_cObj->setCurrentVal($formatedDayDate);
                 $this->local_cObj->data['view'] = $dayLinkViewTarget;
                 $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('getdate' => $formatedGetdate, 'view' => $dayLinkViewTarget, $this->pointerName => NULL), $this->conf['cache'], $this->conf['clear_anyway'], $this->conf['view.'][$dayLinkViewTarget . '.'][$dayLinkViewTarget . 'ViewPid']);
                 $switch['###LINK###'] .= $this->local_cObj->cObjGetSingle($this->conf['view.'][$dayLinkViewTarget . '.'][$dayLinkViewTarget . 'ViewLink'], $this->conf['view.'][$dayLinkViewTarget . '.'][$dayLinkViewTarget . 'ViewLink.']);
                 if ($switch['###LINK###'] === '') {
                     $switch['###LINK###'] .= $formatedDayDate;
                 }
                 $switch['###LINK###'] = $this->cObj->stdWrap($switch['###LINK###'], $this->conf['view.']['month.'][$type . 'Link_stdWrap.']);
             } else {
                 $switch['###LINK###'] .= $formatedDayDate;
             }
             // add a css class if the current day has a event - regardless if linked or not
             if ($this->viewarray[$formatedGetdate]) {
                 $style[] = $this->conf['view.']['month.']['eventDayStyle'];
             }
             $style[] = $this->conf['view.']['month.']['month' . ucfirst($type) . 'Style'];
             if ($check_month != $minical_month) {
                 $style[] = $this->conf['view.']['month.']['monthOffStyle'];
             }
             if ($start_day->format('%w') == 0 || $start_day->format('%w') == 6) {
                 $style[] = $this->conf['view.']['month.']['monthDayWeekendStyle'];
             }
             if ($isSelectedWeek) {
                 $style[] = $this->conf['view.']['month.']['monthDaySelectedWeekStyle'];
             }
             if ($formatedGetdate == $this->conf['getdate']) {
                 $style[] = $this->conf['view.']['month.']['monthSelectedStyle'];
             }
             if ($isCurrentWeek) {
                 $style[] = $this->conf['view.']['month.']['monthDayCurrentWeekStyle'];
             }
             if ($formatedGetdate == $today->format('%Y%m%d')) {
                 $style[] = $this->conf['view.']['month.']['monthTodayStyle'];
             }
             if ($this->conf['view.']['month.']['monthDayOfWeekStyle']) {
                 $style[] = sprintf($this->conf['view.']['month.']['monthDayOfWeekStyle'], $start_day->format('%w'));
             }
             //clean up empty styles (code beautify)
             foreach ($style as $key => $classname) {
                 if ($classname == '') {
                     unset($style[$key]);
                 }
             }
             // Adds hook for processing of extra month day style markers
             if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tx_cal_controller']['extraMonthDayStyleMarkerHook'])) {
                 foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tx_cal_controller']['extraMonthDayStyleMarkerHook'] as $_classRef) {
                     $_procObj =& GeneralUtility::getUserObj($_classRef);
                     if (is_object($_procObj) && method_exists($_procObj, 'extraMonthDayStyleMarkerProcessor')) {
                         $_procObj->extraMonthDayStyleMarkerProcessor($this, $daylink, $switch, $type, $style);
                     }
                 }
             }
             $classesDay = implode(' ', $style);
             $markerArray = array('###STYLE###' => $classesDay, '###ADDITIONAL_CLASSES###' => $classesDay ? ' ' . $classesDay : '', '###CLASSES###' => $classesDay ? ' class="' . $classesDay . '" ' : '', '###DAY_ID###' => $formatedGetdate);
             $temp = strtr($t_month, $markerArray);
             $wraped = array();
             if ($this->viewarray[$formatedGetdate] && preg_match('!\\###EVENT\\###!is', $t_month)) {
                 foreach ($this->viewarray[$formatedGetdate] as $cal_time => $event_times) {
                     foreach ($event_times as $uid => $eventId) {
                         if ($type == 'large') {
                             $switch['###EVENT###'] .= $this->eventArray[$eventId]->renderEventForMonth();
                         } else {
                             if ($type == 'medium') {
                                 $switch['###EVENT###'] .= $this->eventArray[$eventId]->renderEventForYear();
                             } else {
                                 if ($type == 'small') {
                                     $switch['###EVENT###'] .= $this->eventArray[$eventId]->renderEventForMiniMonth();
                                 }
                             }
                         }
                     }
                 }
             }
             if (!isset($switch['###EVENT###'])) {
                 $this->initLocalCObject();
                 $switch['###EVENT###'] = $this->local_cObj->cObjGetSingle($this->conf['view.'][$viewTarget . '.']['event.']['noEventFound'], $this->conf['view.'][$viewTarget . '.']['event.']['noEventFound.']);
             }
             if (!isset($switch['###ALLDAY###'])) {
                 $this->initLocalCObject();
                 $switch['###ALLDAY###'] = $this->local_cObj->cObjGetSingle($this->conf['view.'][$viewTarget . '.']['event.']['noEventFound'], $this->conf['view.'][$viewTarget . '.']['event.']['noEventFound.']);
             }
             // Adds hook for processing of extra month day markers
             if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tx_cal_controller']['extraMonthDayMarkerHook'])) {
                 foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['tx_cal_controller']['extraMonthDayMarkerHook'] as $_classRef) {
                     $_procObj =& GeneralUtility::getUserObj($_classRef);
                     if (is_object($_procObj) && method_exists($_procObj, 'extraMonthDayMarkerProcessor')) {
                         $switch = $_procObj->extraMonthDayMarkerProcessor($this, $daylink, $switch, $type);
                     }
                 }
             }
             $middle .= \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($temp, $switch, array(), $wraped);
             $start_day->addSeconds(86400);
             // 60 * 60 *24 -> strtotime('+1 day', $start_day);
             if ($i == 7) {
                 $i = 0;
                 $middle .= $endweek;
                 $checkagain = $start_day->getMonth();
                 if ($checkagain != $minical_month) {
                     $whole_month = FALSE;
                 }
             }
         } while ($whole_month == TRUE);
         $rems['###LOOPWEEKDAY###'] = $weekday_loop;
         $rems['###LOOPMONTHWEEKS###'] = $middle;
         $rems['###LOOPMONTHWEEKS_DAYS###'] = '';
         $rems['###LOOPWEEK_NUMS###'] = '';
         $rems['###CORNER###'] = '';
         $monthTemplate = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($monthTemplate, array(), $rems, array());
         $monthTemplate .= $ajaxEvents;
         $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, array(), array('###MONTH_TEMPLATE###' => $monthTemplate), array());
     }
     $listTemplate = $this->cObj->getSubpart($page, '###LIST###');
     if ($listTemplate != '') {
         $tx_cal_listview =& GeneralUtility::makeInstanceService('cal_view', 'list', 'list');
         $starttime = gmmktime(0, 0, 0, $this_month, 1, $this_year);
         $endtime = gmmktime(0, 0, 0, $this_month + 1, 1, $this_year);
         $rems['###LIST###'] = $tx_cal_listview->drawList($this->master_array, $listTemplate, $starttime, $endtime);
     }
     $return = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, array(), $rems, array());
     if ($this->rightsObj->isViewEnabled($viewTarget) || $this->conf['view.'][$viewTarget . '.'][$viewTarget . 'ViewPid']) {
         $this->initLocalCObject();
         $this->local_cObj->setCurrentVal($month_title);
         $this->local_cObj->data['view'] = $viewTarget;
         $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('getdate' => $month_date, 'view' => $viewTarget, $this->pointerName => NULL), $this->conf['cache'], $this->conf['clear_anyway'], $this->conf['view.'][$viewTarget . '.'][$viewTarget . 'ViewPid']);
         $month_link = $this->local_cObj->cObjGetSingle($this->conf['view.'][$viewTarget . '.'][$viewTarget . 'ViewLink'], $this->conf['view.'][$viewTarget . '.'][$viewTarget . 'ViewLink.']);
     } else {
         $month_link = $month_title;
     }
     $return = str_replace('###MONTH_LINK###', $month_link, $return);
     return $return;
 }
示例#2
0
 public function getEventsColumnMarker(&$template, &$sims, &$rems, &$wrapped, $view)
 {
     $content = '';
     $conf =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'conf');
     $dayStart = $conf['view.']['day.']['dayStart'];
     // '0700'; // Start time for day grid
     $dayEnd = $conf['view.']['day.']['dayEnd'];
     // '2300'; // End time for day grid
     $gridLength = $conf['view.']['day.']['gridLength'];
     // '15'; // Grid distance in minutes for day view, multiples of 15 preferred
     while (strlen($dayStart) < 6) {
         $dayStart .= '0';
     }
     while (strlen($dayEnd) < 6) {
         $dayEnd .= '0';
     }
     if ($gridLength == 0) {
         $gridLength = 15;
     }
     $d_start = new \TYPO3\CMS\Cal\Model\CalDate($this->Ymd . $dayStart);
     $d_start->setTZbyId('UTC');
     $d_end = new \TYPO3\CMS\Cal\Model\CalDate($this->Ymd . $dayEnd);
     $d_end->setTZbyId('UTC');
     // splitting the events into H:M, to find out if events run in parallel
     $i = new \TYPO3\CMS\Cal\Model\CalDate();
     $eventArray = array();
     $viewArray = array();
     $positionArray = array();
     $timeKeys = array_keys($this->events);
     // Sort by starttime, otherwise $pos_array keys may be assigned multiple times and events may therefore overwrite each other
     asort($timeKeys);
     foreach ($timeKeys as $timeKey) {
         $eventKeys = array_keys($this->events[$timeKey]);
         foreach ($eventKeys as $eventKey) {
             if (!$this->events[$timeKey][$eventKey]->isAllday() && $this->events[$timeKey][$eventKey]->getStart()->format('%Y%m%d') == $this->events[$timeKey][$eventKey]->getEnd()->format('%Y%m%d')) {
                 $eventMappingKey = $this->events[$timeKey][$eventKey]->getType() . '_' . $this->events[$timeKey][$eventKey]->getUid() . '_' . $this->events[$timeKey][$eventKey]->getStart()->format('%Y%m%d%H%M%S');
                 $eventArray[$eventMappingKey] =& $this->events[$timeKey][$eventKey];
                 $i->copy($this->events[$timeKey][$eventKey]->getStart());
                 $time = $i->getTime();
                 $time = $time - $time % ($gridLength * 60);
                 $i = new \TYPO3\CMS\Cal\Model\CalDate($time);
                 if ($i->before($d_start)) {
                     $i->copy($d_start);
                 }
                 $entries = 0;
                 for (; $i->before($this->events[$timeKey][$eventKey]->getEnd()); $i->addSeconds($gridLength * 60)) {
                     $ymd = $i->format('%Y%m%d');
                     $hm = $i->format('%H%M');
                     $viewArray[$ymd][$hm][] = $eventMappingKey;
                     $entries++;
                     $count = count($viewArray[$ymd][$hm]);
                     foreach ($viewArray[$ymd][$hm] as $mappingKey) {
                         if (!$positionArray[$mappingKey] || $positionArray[$mappingKey] < $count) {
                             $positionArray[$mappingKey] = $count;
                         }
                     }
                 }
                 $rowspan_array[$this->Ymd][$eventMappingKey] = $entries;
             }
         }
     }
     if (!empty($viewArray[$this->Ymd])) {
         $max = array();
         foreach ($viewArray[$this->Ymd] as $array_time => $time_val) {
             $c = count($viewArray[$this->Ymd][$array_time]);
             array_push($max, $c);
         }
         $nbrGridCols = max($max);
     } else {
         $nbrGridCols = 1;
     }
     // splitting the events into H:M, to find out if events run in parallel
     $pos_array = array();
     $i->copy($d_start);
     $t_array = array();
     while ($i->before($d_end)) {
         $i_formatted = $i->format('%H%M');
         if (is_array($viewArray[$this->Ymd][$i_formatted]) && count($viewArray[$this->Ymd][$i_formatted]) > 0) {
             foreach ($viewArray[$this->Ymd][$i_formatted] as $eventKey) {
                 $event =& $eventArray[$eventKey];
                 $eventStart = $event->getStart();
                 $eventMappingKey = $event->getType() . '_' . $event->getUid() . '_' . $eventStart->format('%Y%m%d%H%M%S');
                 if (array_key_exists($eventMappingKey, $pos_array)) {
                     $eventEnd = $event->getEnd();
                     $eventEnd->subtractSeconds($eventEnd->getMinute() % $gridLength * 60);
                     if ($i_formatted >= $eventEnd->format('%H%M')) {
                         $t_array[$i_formatted][$pos_array[$eventMappingKey]] = array('ended' => $eventMappingKey);
                     } else {
                         $t_array[$i_formatted][$pos_array[$eventMappingKey]] = array('started' => $eventMappingKey);
                     }
                 } else {
                     for ($j = 0; $j < $nbrGridCols; $j++) {
                         if (count($t_array[$i_formatted][$j]) == 0 || !isset($t_array[$i_formatted][$j])) {
                             $pos_array[$eventMappingKey] = $j;
                             $t_array[$i_formatted][$j] = array('begin' => $eventMappingKey);
                             break;
                         }
                     }
                 }
             }
         } else {
             $t_array[$i_formatted] = '';
         }
         $i->addSeconds($gridLength * 60);
     }
     $sims['###EVENTS_COLUMN###'] = $this->renderEventsColumn($eventArray, $d_start, $d_end, $viewArray, $t_array, $positionArray);
 }
示例#3
0
 function processObjects(&$master_array, &$sims, &$rems)
 {
     /* Subtract strtotimeOffset because we're going from GMT back to local time */
     if ($this->reverse) {
         $GLOBALS['TSFE']->register['cal_list_starttime'] = $this->endtime->getTime();
         $GLOBALS['TSFE']->register['cal_list_endtime'] = $this->starttime->getTime();
     } else {
         $GLOBALS['TSFE']->register['cal_list_starttime'] = $this->starttime->getTime();
         $GLOBALS['TSFE']->register['cal_list_endtime'] = $this->endtime->getTime();
     }
     // clear the register
     $GLOBALS['TSFE']->register['cal_list_firstevent'] = 0;
     $GLOBALS['TSFE']->register['cal_list_lastevent'] = 0;
     $GLOBALS['TSFE']->register['cal_list_events_total'] = 0;
     $GLOBALS['TSFE']->register['cal_list_eventcounter'] = 0;
     $GLOBALS['TSFE']->register['cal_list_days_total'] = 0;
     $sectionMenu = '';
     // only proceed if the master_array is not empty
     if (count($master_array)) {
         $this->count = 0;
         $this->eventCounter = array();
         $this->listStartOffsetCounter = 0;
         $this->listStartOffset = intval($this->conf['view.']['list.']['listStartOffset']);
         if ($this->conf['view.']['list.']['pageBrowser.']['usePageBrowser']) {
             $this->offset = intval($this->controller->piVars[$this->pointerName]);
             $this->recordsPerPage = intval($this->conf['view.']['list.']['pageBrowser.']['recordsPerPage']);
         }
         $this->walkThroughMasterArray($master_array, $this->reverse, $firstEventDate);
         if ($firstEventDate) {
             $GLOBALS['TSFE']->register['cal_list_firstevent'] = $firstEventDate->getTime();
         }
         if ($this->count) {
             $GLOBALS['TSFE']->register['cal_list_events_total'] = $this->count;
             // reference the array with all event counts in the TYPO3 register for usage from within hooks or whatever
             $GLOBALS['TSFE']->register['cal_list_eventcounter'] =& $this->eventCounter;
         }
         if ($days = count($this->objectsInList)) {
             $GLOBALS['TSFE']->register['cal_list_days_total'] = $days;
         }
         // start rendering the events
         if (count($this->objectsInList) && $this->count > 0) {
             $times = array_keys($this->objectsInList);
             // preset vars
             $firstTime = true;
             $listItemCount = 0;
             $alternationCount = 0;
             $pageItemCount = $this->recordsPerPage * $this->offset;
             // don't assign these dates in one line like "$date1 = $date2 = $date3 = new CalDate()", as this will make all dates references to each other!!!
             $lastEventDay = new \TYPO3\CMS\Cal\Model\CalDate('000000001000000');
             $lastEventWeek = new \TYPO3\CMS\Cal\Model\CalDate('000000001000000');
             $lastEventMonth = new \TYPO3\CMS\Cal\Model\CalDate('000000001000000');
             $lastEventYear = new \TYPO3\CMS\Cal\Model\CalDate('000000001000000');
             $categoryGroupArray = array();
             $categoryArray = array();
             if ($this->conf['view.']['list.']['enableCategoryWrapper']) {
                 $allCategoryArray = $this->modelObj->findAllCategories('', '', $this->conf['pidList']);
                 $categoryArray = (array) $allCategoryArray['tx_cal_category'][0][0];
             }
             $calendarGroupArray = array();
             $calendarArray = array();
             if ($this->conf['view.']['list.']['enableCalendarWrapper']) {
                 $allCalendarArray = $this->modelObj->findAllCalendar('', $this->conf['pidList']);
                 $calendarArray = (array) $allCalendarArray['tx_cal_calendar'];
             }
             // prepare alternating layouts
             $alternatingLayoutConfig = $this->conf['view.']['list.']['alternatingLayoutMarkers.'];
             if (is_array($alternatingLayoutConfig) && count($alternatingLayoutConfig)) {
                 $alternatingLayouts = array();
                 $layout_keys = array_keys($alternatingLayoutConfig);
                 foreach ($layout_keys as $key) {
                     if (substr($key, strlen($key) - 1) != '.') {
                         $suffix = $this->cObj->stdWrap($alternatingLayoutConfig[$key], $alternatingLayoutConfig[$key . '.']);
                         if ($suffix) {
                             $alternatingLayouts[] = $suffix;
                         }
                     }
                 }
             } else {
                 $alternatingLayouts = array('LIST_ODD', 'LIST_EVEN');
             }
             // Hook: get hook objects for drawList
             $hookObjectsArr = \TYPO3\CMS\Cal\Utility\Functions::getHookObjectsArray('tx_cal_listview', 'drawList', 'view');
             if ($this->reverse) {
                 arsort($times);
             } else {
                 asort($times);
             }
             foreach ($times as $cal_time) {
                 $e_keys = array_keys($this->objectsInList[$cal_time]);
                 // Hook: postSort
                 if (count($hookObjectsArr)) {
                     // use referenced hook objects, so that hook objects can store variables among different hook calls internally and don't have to mess with globals or registers
                     $hookObjectKeys = array_keys($hookObjectsArr);
                     foreach ($hookObjectKeys as $hookObjKey) {
                         $hookObj =& $hookObjectsArr[$hookObjKey];
                         if (method_exists($hookObj, 'postSort')) {
                             $hookObj->postSort($this, $e_keys, $cal_time);
                         }
                     }
                 }
                 unset($calTimeObject);
                 $calTimeObject = new \TYPO3\CMS\Cal\Model\CalDate($cal_time . '000000');
                 $calTimeObject->setTZbyId('UTC');
                 $cal_day = $calTimeObject->getDay();
                 $cal_month = $calTimeObject->getMonth();
                 $cal_year = $calTimeObject->getYear();
                 $cal_week = $calTimeObject->getWeekOfYear();
                 if (count($hookObjectsArr)) {
                     $hookParams = array('cal_day' => &$cal_day, 'cal_month' => &$cal_month, 'cal_year' => &$cal_year, 'cal_week' => &$cal_week, 'alternationCount' => &$alternationCount, 'reverse' => $this->reverse);
                 }
                 if ($firstTime) {
                     $yearItemCounter = (int) $this->eventCounter['byYear'][$cal_year]['previousPages'];
                     $monthItemCounter = (int) $this->eventCounter['byYearMonth'][$cal_year][$cal_month]['previousPages'];
                     $weekItemCounter = (int) $this->eventCounter['byWeek'][$cal_week]['previousPages'];
                     $dayItemCounter = (int) $this->eventCounter['byDate'][$cal_year][$cal_month][$cal_day]['previousPages'];
                 }
                 foreach ($e_keys as $e_key) {
                     $event =& $this->objectsInList[$cal_time][$e_key];
                     if ($firstTime) {
                         $eventStart = $event->getStart();
                         $lastEventDay->copy($eventStart);
                         $lastEventMonth->copy($eventStart);
                         $lastEventWeek->copy($eventStart);
                         $lastEventYear->copy($eventStart);
                     }
                     // Hook: preInnerEventWrapper
                     if (count($hookObjectsArr)) {
                         // use referenced hook objects, so that hook objects can store variables among different hook calls internally and don't have to mess with globals or registers
                         $hookObjectKeys = array_keys($hookObjectsArr);
                         foreach ($hookObjectKeys as $hookObjKey) {
                             $hookObj =& $hookObjectsArr[$hookObjKey];
                             if (method_exists($hookObj, 'preInnerEventWrapper')) {
                                 $hookObj->preInnerEventWrapper($this, $middle, $event, $calTimeObject, $firstTime, $hookParams);
                             }
                         }
                     }
                     // yearwrapper
                     if ($this->conf['view.']['list.']['enableYearWrapper'] && ($this->hasPeriodChanged($lastEventYear->getYear(), $cal_year, $this->reverse) || $firstTime)) {
                         $this->initLocalCObject();
                         if ($this->conf['view.']['list.']['enableSectionMenu']) {
                             $this->local_cObj->setCurrentVal($calTimeObject->format($this->conf['view.']['list.']['yearSectionMenuFormat']));
                             $this->local_cObj->data['link_parameter'] = '#' . $calTimeObject->format('%Y');
                             $sectionMenu .= $this->local_cObj->cObjGetSingle($this->conf['view.']['list.']['sectionMenuItem'], $this->conf['view.']['list.']['sectionMenuItem.']);
                         }
                         $this->local_cObj->setCurrentVal($calTimeObject->format($this->conf['view.']['list.']['yearWrapperFormat']));
                         if (!$firstTime) {
                             $middle .= $this->local_cObj->cObjGetSingle($this->conf['view.']['list.']['yearWrapperEnd'], $this->conf['view.']['list.']['yearWrapperEnd.']);
                         }
                         $middle .= $this->local_cObj->cObjGetSingle($this->conf['view.']['list.']['yearWrapper'], $this->conf['view.']['list.']['yearWrapper.']);
                         $lastEventYear->copy($calTimeObject);
                         if ($this->conf['view.']['list.']['restartAlternationAfterYearWrapper']) {
                             $alternationCount = 0;
                         }
                         if (!$firstTime) {
                             $yearItemCounter = 0;
                         }
                     }
                     // monthwrapper
                     if ($this->conf['view.']['list.']['enableMonthWrapper'] && ($this->hasPeriodChanged($lastEventMonth->format('%Y%m'), $calTimeObject->format('%Y%m'), $this->reverse) || $firstTime || $this->hasPeriodChanged($lastEventMonth->getYear(), $cal_year, $this->reverse))) {
                         $this->initLocalCObject();
                         if ($this->conf['view.']['list.']['enableSectionMenu']) {
                             $this->local_cObj->setCurrentVal($calTimeObject->format($this->conf['view.']['list.']['monthSectionMenuFormat']));
                             $this->local_cObj->data['link_parameter'] = '#' . $calTimeObject->format('%Y%m');
                             $sectionMenu .= $this->local_cObj->cObjGetSingle($this->conf['view.']['list.']['sectionMenuItem'], $this->conf['view.']['list.']['sectionMenuItem.']);
                         }
                         $this->local_cObj->setCurrentVal($calTimeObject->format($this->conf['view.']['list.']['monthWrapperFormat']));
                         if (!$firstTime) {
                             $middle .= $this->local_cObj->cObjGetSingle($this->conf['view.']['list.']['monthWrapperEnd'], $this->conf['view.']['list.']['monthWrapperEnd.']);
                         }
                         $middle .= $this->local_cObj->cObjGetSingle($this->conf['view.']['list.']['monthWrapper'], $this->conf['view.']['list.']['monthWrapper.']);
                         $lastEventMonth->copy($calTimeObject);
                         if ($this->conf['view.']['list.']['restartAlternationAfterMonthWrapper']) {
                             $alternationCount = 0;
                         }
                         if (!$firstTime) {
                             $monthItemCounter = 0;
                         }
                     }
                     // weekwrapper
                     if ($this->conf['view.']['list.']['enableWeekWrapper'] && ($this->hasPeriodChanged($lastEventWeek->getWeekOfYear(), $cal_week, $this->reverse) || $firstTime || $this->hasPeriodChanged($lastEventWeek->getYear(), $cal_year, $this->reverse))) {
                         $this->initLocalCObject();
                         if ($this->conf['view.']['list.']['enableSectionMenu']) {
                             $this->local_cObj->setCurrentVal($calTimeObject->format($this->conf['view.']['list.']['weekSectionMenuFormat']));
                             $this->local_cObj->data['link_parameter'] = '#' . $calTimeObject->format('%Y%U');
                             $sectionMenu .= $this->local_cObj->cObjGetSingle($this->conf['view.']['list.']['sectionMenuItem'], $this->conf['view.']['list.']['sectionMenuItem.']);
                         }
                         $this->local_cObj->setCurrentVal($calTimeObject->format($this->conf['view.']['list.']['weekWrapperFormat']));
                         if (!$firstTime) {
                             $middle .= $this->local_cObj->cObjGetSingle($this->conf['view.']['list.']['weekWrapperEnd'], $this->conf['view.']['list.']['weekWrapperEnd.']);
                         }
                         $middle .= $this->local_cObj->cObjGetSingle($this->conf['view.']['list.']['weekWrapper'], $this->conf['view.']['list.']['weekWrapper.']);
                         $lastEventWeek->copy($calTimeObject);
                         if ($this->conf['view.']['list.']['restartAlternationAfterWeekWrapper']) {
                             $alternationCount = 0;
                         }
                         if (!$firstTime) {
                             $weekItemCounter = 0;
                         }
                     }
                     // daywrapper
                     if ($this->conf['view.']['list.']['enableDayWrapper'] && (($this->reverse ? $lastEventDay->after($calTimeObject) : $lastEventDay->before($calTimeObject)) || $firstTime || $this->hasPeriodChanged($lastEventDay->getYear(), $cal_year, $this->reverse))) {
                         $this->initLocalCObject();
                         if ($this->conf['view.']['list.']['enableSectionMenu']) {
                             $this->local_cObj->setCurrentVal($calTimeObject->format($this->conf['view.']['list.']['daySectionMenuFormat']));
                             $this->local_cObj->data['link_parameter'] = '#' . $calTimeObject->format('%Y%m%d');
                             $sectionMenu .= $this->local_cObj->cObjGetSingle($this->conf['view.']['list.']['sectionMenuItem'], $this->conf['view.']['list.']['sectionMenuItem.']);
                         }
                         $this->local_cObj->setCurrentVal($calTimeObject->format($this->conf['view.']['list.']['dayWrapperFormat']));
                         if (!$firstTime) {
                             $middle .= $this->local_cObj->cObjGetSingle($this->conf['view.']['list.']['dayWrapperEnd'], $this->conf['view.']['list.']['dayWrapperEnd.']);
                         }
                         $middle .= $this->local_cObj->cObjGetSingle($this->conf['view.']['list.']['dayWrapper'], $this->conf['view.']['list.']['dayWrapper.']);
                         $lastEventDay->copy($calTimeObject);
                         if ($this->conf['view.']['list.']['restartAlternationAfterDayWrapper']) {
                             $alternationCount = 0;
                         }
                         if (!$firstTime) {
                             $dayItemCounter = 0;
                         }
                     }
                     // Hook: postInnerEventWrapper
                     if (count($hookObjectsArr)) {
                         // use referenced hook objects, so that hook objects can store variables among different hook calls internally and don't have to mess with globals or registers
                         $hookObjectKeys = array_keys($hookObjectsArr);
                         foreach ($hookObjectKeys as $hookObjKey) {
                             $hookObj =& $hookObjectsArr[$hookObjKey];
                             if (method_exists($hookObj, 'postInnerEventWrapper')) {
                                 $hookObj->postInnerEventWrapper($this, $middle, $event, $calTimeObject, $firstTime, $hookParams);
                             }
                         }
                     }
                     $listItemCount++;
                     $monthItemCounter++;
                     $weekItemCounter++;
                     $dayItemCounter++;
                     $yearItemCounter++;
                     $totalListCount = $listItemCount + $pageItemCount;
                     $GLOBALS['TSFE']->register['cal_event_list_num'] = $listItemCount;
                     $GLOBALS['TSFE']->register['cal_event_list_num_total'] = $totalListCount;
                     $GLOBALS['TSFE']->register['cal_event_list_num_in_day'] = $dayItemCounter;
                     $GLOBALS['TSFE']->register['cal_event_list_num_in_week'] = $weekItemCounter;
                     $GLOBALS['TSFE']->register['cal_event_list_num_in_month'] = $monthItemCounter;
                     $GLOBALS['TSFE']->register['cal_event_list_num_in_year'] = $yearItemCounter;
                     $layoutNum = $alternationCount % count($alternatingLayouts);
                     $layoutSuffix = $alternatingLayouts[$layoutNum];
                     $eventText = '';
                     if ($this->conf['view'] == 'location' || $this->conf['view'] == 'organizer' || $this->conf['view'] == 'event') {
                         $eventText = $event->renderEventForList(strtoupper($this->conf['view']) . '_' . $layoutSuffix);
                     } else {
                         $eventText = $event->renderEventForList($layoutSuffix);
                     }
                     $allowFurtherGrouping = true;
                     // Hook: prepareOuterEventWrapper
                     if (count($hookObjectsArr)) {
                         // use referenced hook objects, so that hook objects can store variables among different hook calls internally and don't have to mess with globals or registers
                         $hookObjectKeys = array_keys($hookObjectsArr);
                         foreach ($hookObjectKeys as $hookObjKey) {
                             $hookObj =& $hookObjectsArr[$hookObjKey];
                             if (method_exists($hookObj, 'prepareOuterEventWrapper')) {
                                 $hookObj->prepareOuterEventWrapper($this, $middle, $event, $calTimeObject, $firstTime, $hookParams, $allowFurtherGrouping);
                             }
                         }
                     }
                     if ($allowFurtherGrouping) {
                         if ($this->conf['view.']['list.']['enableCategoryWrapper']) {
                             $ids = $event->getCategoryUidsAsArray();
                             if (empty($ids)) {
                                 $categoryGroupArray[$this->conf['view.']['list.']['noCategoryWrapper.']['uid']] .= $eventText;
                             } else {
                                 $rememberUid = array();
                                 foreach ($categoryArray as $categoryObject) {
                                     if (!in_array($categoryObject->getUid(), $rememberUid)) {
                                         if (in_array($categoryObject->getUid(), $ids)) {
                                             $categoryGroupArray[$categoryObject->getUid()] .= $eventText;
                                         }
                                         $rememberUid[] = $categoryObject->getUid();
                                     }
                                 }
                             }
                         } else {
                             if ($this->conf['view.']['list.']['enableCalendarWrapper']) {
                                 $id = $event->getCalendarUid();
                                 foreach ($calendarArray as $calendarObject) {
                                     if ($calendarObject->getUid() == $id) {
                                         $calendarGroupArray[$calendarObject->getTitle()] .= $eventText;
                                     }
                                 }
                             } else {
                                 $middle .= $eventText;
                             }
                         }
                     }
                     $alternationCount++;
                     $firstTime = false;
                 }
             }
             $allowFurtherGrouping = true;
             // Hook: applyOuterEventWrapper
             if (count($hookObjectsArr)) {
                 // use referenced hook objects, so that hook objects can store variables among different hook calls internally and don't have to mess with globals or registers
                 $hookObjectKeys = array_keys($hookObjectsArr);
                 foreach ($hookObjectKeys as $hookObjKey) {
                     $hookObj =& $hookObjectsArr[$hookObjKey];
                     if (method_exists($hookObj, 'applyOuterEventWrapper')) {
                         $hookObj->applyOuterEventWrapper($this, $middle, $event, $allowFurtherGrouping);
                     }
                 }
             }
             if ($allowFurtherGrouping) {
                 // additional Wrapper
                 if ($this->conf['view.']['list.']['enableCalendarWrapper']) {
                     $this->initLocalCObject();
                     foreach ($calendarGroupArray as $calTitel => $calendarEntries) {
                         $this->local_cObj->setCurrentVal($calTitel);
                         $middle .= $this->local_cObj->cObjGetSingle($this->conf['view.']['list.']['calendarWrapper'], $this->conf['view.']['list.']['calendarWrapper.']);
                         $middle .= $calendarEntries;
                     }
                 }
                 if ($this->conf['view.']['list.']['enableCategoryWrapper']) {
                     $keys = array_keys($categoryGroupArray);
                     sort($keys);
                     foreach ($keys as $categoryId) {
                         if ($categoryId == $this->conf['view.']['list.']['noCategoryWrapper.']['uid']) {
                             $this->initLocalCObject();
                             $middle .= $this->local_cObj->cObjGetSingle($this->conf['view.']['list.']['noCategoryWrapper'], $this->conf['view.']['list.']['noCategoryWrapper.']);
                         } else {
                             $currentCategory =& $categoryArray[$categoryId];
                             $this->initLocalCObject($currentCategory->getValuesAsArray());
                             $this->local_cObj->setCurrentVal($currentCategory->getTitle());
                             $text = $this->local_cObj->cObjGetSingle($this->conf['view.']['list.']['categoryWrapper.']['10'], $this->conf['view.']['list.']['categoryWrapper.']['10.']);
                             $middle .= str_replace('###CATEGORY_STYLE###', $currentCategory->getHeaderStyle(), $text);
                         }
                         $middle .= $categoryGroupArray[$categoryId];
                     }
                 }
             }
         }
     }
     return $middle;
 }
示例#4
0
 function getMonthDaysAccordingly(&$event, $month, $year)
 {
     $byDayArray = $event->getByDay();
     $byMonthDays = $event->getByMonthDay();
     $resultDays = array();
     if (count($byDayArray) == 0) {
         $resultDays = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31);
         return $resultDays;
     }
     for ($i = 0; $i < count($byDayArray); $i++) {
         if (preg_match('/([-\\+]{0,1})?([0-9]{1})?([A-Z]{2})/', $byDayArray[$i], $byDaySplit)) {
             $dayOfWeekday = \TYPO3\CMS\Cal\Controller\Calendar::two2threeCharDays($byDaySplit[3], false);
             $monthStartTime = new \TYPO3\CMS\Cal\Model\CalDate($year . '-' . sprintf("%02d", $month) . '-01 00:00:00');
             $monthStartTime->setTZbyId('UTC');
             $monthEndTime = \TYPO3\CMS\Cal\Controller\Calendar::calculateEndMonthTime($monthStartTime);
             if ($byDaySplit[2] > 0) {
                 if ($byDaySplit[1] == '-') {
                     $monthTime = new \TYPO3\CMS\Cal\Model\CalDate(Calc::prevDayOfWeek($dayOfWeekday, $monthEndTime->getDay(), $monthEndTime->getMonth(), $monthEndTime->getYear(), '%Y%m%d', true));
                     $monthTime->setTZbyId('UTC');
                     $monthTime->subtractSeconds(($byDaySplit[2] - 1) * 604800);
                 } else {
                     $monthTime = new \TYPO3\CMS\Cal\Model\CalDate(Calc::nextDayOfWeek($dayOfWeekday, $monthStartTime->getDay(), $monthStartTime->getMonth(), $monthStartTime->getYear(), '%Y%m%d', true));
                     $monthTime->setTZbyId('UTC');
                     $monthTime->addSeconds(($byDaySplit[2] - 1) * 604800);
                 }
                 if ($monthTime->getMonth() == $month && in_array($monthTime->getDay(), $byMonthDays)) {
                     $resultDays[] = $monthTime->getDay();
                 }
             } else {
                 $monthTime = new \TYPO3\CMS\Cal\Model\CalDate(Calc::prevDayOfWeek($dayOfWeekday, $monthStartTime->getDay(), $monthStartTime->getMonth(), $monthStartTime->getYear(), '%Y%m%d', true));
                 $monthTime->setTZbyId('UTC');
                 if ($monthTime->before($monthStartTime)) {
                     $monthTime->addSeconds(604800);
                 }
                 while ($monthTime->before($monthEndTime)) {
                     $resultDays[] = $monthTime->getDay();
                     $monthTime->addSeconds(604800);
                 }
             }
         }
     }
     $resultDays = array_intersect($resultDays, $event->getByMonthDay());
     sort($resultDays);
     return $resultDays;
 }
示例#5
0
 /**
  * Draws the week view.
  * 
  * @param $master_array array
  *        	The events to be drawn.
  * @param $getdate integer
  *        	The date of the event
  * @return string The HTML output.
  */
 public function drawWeek(&$master_array, $getdate)
 {
     if ($this->conf['useNewTemplatesAndRendering']) {
         return $this->newDrawWeek($master_array, $getdate);
     }
     $this->_init($master_array);
     $page = $this->cObj->fileResource($this->conf['view.']['week.']['weekTemplate']);
     if ($page == '') {
         return "<h3>week: no template file found:</h3>" . $this->conf['view.']['week.']['weekTemplate'] . "<br />Please check your template record and add both cal items at 'include static (from extension)'";
     }
     $weekTemplate = $this->cObj->getSubpart($page, '###WEEK_TEMPLATE###');
     if ($weekTemplate == '') {
         $rems = array();
         return $this->finish($page, $rems);
     }
     $dayStart = $this->conf['view.']['day.']['dayStart'];
     // '0700'; // Start time for day grid
     $dayEnd = $this->conf['view.']['day.']['dayEnd'];
     // '2300'; // End time for day grid
     $gridLength = $this->conf['view.']['day.']['gridLength'];
     // '15'; // Grid distance in minutes for day view, multiples of 15 preferred
     if (!isset($getdate) || $getdate == '') {
         $getdate_obj = new \TYPO3\CMS\Cal\Model\CalDate();
         $getdate = $getdate_obj->format('%Y%m%d');
     }
     $day_array2 = array();
     preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})/', $getdate, $day_array2);
     $this_day = $day_array2[3];
     $this_month = $day_array2[2];
     $this_year = $day_array2[1];
     $unix_time = new \TYPO3\CMS\Cal\Model\CalDate($getdate . '000000');
     $today = new \TYPO3\CMS\Cal\Model\CalDate();
     $todayFormatted = $today->format('%Y%m%d');
     $now = new \TYPO3\CMS\Cal\Model\CalDate($getdate . '000000');
     $endOfNextMonth = new \TYPO3\CMS\Cal\Model\CalDate(Calc::endOfNextMonth($this_day, $this_month, $this_year));
     $now->addSeconds(60 * 60 * 24 * 31);
     $next_month = $now->format('%Y%m%d');
     if ($now->after($endOfNextMonth)) {
         $next_month = $endOfNextMonth->format('%Y%m%d');
     }
     $now = new \TYPO3\CMS\Cal\Model\CalDate($getdate . '000000');
     $startOfPrevMonth = new \TYPO3\CMS\Cal\Model\CalDate(Calc::endOfPrevMonth($this_day, $this_month, $this_year));
     $startOfPrevMonth->setDay(1);
     $now->subtractSeconds(60 * 60 * 24 * 31);
     $prev_month = $now->format('%Y%m%d');
     if ($now->before($startOfPrevMonth)) {
         $prev_month = $startOfPrevMonth->format('%Y%m%d');
     }
     $dateOfMonth = Calc::beginOfWeek(1, $this_month, $this_year);
     $start_month_day = new \TYPO3\CMS\Cal\Model\CalDate($dateOfMonth . '000000');
     $thisday2 = $unix_time->format($this->conf['view.']['week.']['dateFormatWeekList']);
     $num_of_events2 = 0;
     $next_week_obj = new \TYPO3\CMS\Cal\Model\CalDate();
     $next_week_obj->copy($unix_time);
     $next_week_obj->addSeconds(60 * 60 * 24 * 7);
     $next_week = $next_week_obj->format('%Y%m%d');
     $next_week_obj->subtractSeconds(60 * 60 * 24 * 7 * 2);
     $prev_week = $next_week_obj->format('%Y%m%d');
     $next_day_obj = $unix_time->getNextDay();
     $next_day = $next_day_obj->format('%Y%m%d');
     $prev_day_obj = $unix_time->getPrevDay();
     $prev_day = $prev_day_obj->format('%Y%m%d');
     $dateOfWeek = Calc::beginOfWeek($unix_time->getDay(), $unix_time->getMonth(), $unix_time->getYear());
     $week_start_day = new \TYPO3\CMS\Cal\Model\CalDate($dateOfWeek . '000000');
     // Nasty fix to work with TS strftime
     $start_week_time = new \TYPO3\CMS\Cal\Model\CalDate($dateOfWeek . '000000');
     $start_week_time->setTZbyID('UTC');
     $end_week_time = new \TYPO3\CMS\Cal\Model\CalDate();
     $end_week_time->copy($start_week_time);
     $end_week_time->addSeconds(604799);
     $GLOBALS['TSFE']->register['cal_week_endtime'] = $end_week_time->getTime();
     $GLOBALS['TSFE']->register['cal_week_starttime'] = $start_week_time->getTime();
     $display_date = $this->cObj->cObjGetSingle($this->conf['view.']['week.']['titleWrap'], $this->conf['view.']['week.']['titleWrap.']);
     $this->initLocalCObject();
     $dayLinkViewTarget =& $this->conf['view.']['dayLinkTarget'];
     $this->local_cObj->data['view'] = $dayLinkViewTarget;
     $this->local_cObj->setCurrentVal($this->conf['view.']['week.']['legendNextDayLink']);
     $legend_next_day_link = $this->local_cObj->cObjGetSingle($this->conf['view.']['week.']['legendNextDayLink'], $this->conf['view.']['week.']['legendNextDayLink.']);
     $this->local_cObj->setCurrentVal($this->conf['view.']['week.']['legendPrevDayLink']);
     $legend_prev_day_link = $this->local_cObj->cObjGetSingle($this->conf['view.']['week.']['legendPrevDayLink'], $this->conf['view.']['week.']['legendPrevDayLink.']);
     // Figure out colspans
     $dayborder = 0;
     $thisdate = $start_week_time;
     $eventArray = array();
     $view_array = array();
     $rowspan_array = array();
     $endOfDay = new \TYPO3\CMS\Cal\Model\CalDate();
     $startOfDay = new \TYPO3\CMS\Cal\Model\CalDate();
     // creating the dateObjects only once:
     $starttime = new \TYPO3\CMS\Cal\Model\CalDate();
     $endtime = new \TYPO3\CMS\Cal\Model\CalDate();
     $j = new \TYPO3\CMS\Cal\Model\CalDate();
     if (count($this->master_array) > 0) {
         $masterKeys = array_keys($this->master_array);
         foreach ($masterKeys as $ovlKey) {
             $dTimeStart = array();
             $dTimeEnd = array();
             $dDate = array();
             preg_match('/([0-9]{2})([0-9]{2})/', $this->conf['view.']['day.']['dayStart'], $dTimeStart);
             preg_match('/([0-9]{2})([0-9]{2})/', $this->conf['view.']['day.']['dayEnd'], $dTimeEnd);
             preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})/', $ovlKey, $dDate);
             $d_start = new \TYPO3\CMS\Cal\Model\CalDate($dDate[1] . $dDate[2] . $dDate[3] . ' ' . $dTimeStart[1] . ':' . sprintf("%02d", $dTimeStart[2]) . ':00');
             $d_start->setTZbyID('UTC');
             $d_end = new \TYPO3\CMS\Cal\Model\CalDate($dDate[1] . $dDate[2] . $dDate[3] . ' ' . $dTimeEnd[1] . ':' . sprintf("%02d", $dTimeEnd[2]) . ':00');
             $d_end->setTZbyID('UTC');
             // minus 1 second to allow endtime 24:00
             $d_end->subtractSeconds(1);
             $ovlTimeKeys = array_keys($this->master_array[$ovlKey]);
             foreach ($ovlTimeKeys as $ovl_time_key) {
                 $ovlDayKeys = array_keys($this->master_array[$ovlKey][$ovl_time_key]);
                 foreach ($ovlDayKeys as $ovl2Key) {
                     $event =& $this->master_array[$ovlKey][$ovl_time_key][$ovl2Key];
                     $eventStart = $event->getStart();
                     $eventMappingKey = $event->getType() . '_' . $event->getUid() . '_' . $eventStart->format('%Y%m%d%H%M');
                     $eventArray[$ovlKey . '_' . $eventMappingKey] =& $event;
                     $starttime->copy($event->getStart());
                     $endtime->copy($event->getEnd());
                     if ($ovl_time_key == '-1') {
                         $j->copy($starttime);
                         $view_array[$j->format('%Y%m%d')]['-1'][] = $ovlKey . '_' . $eventMappingKey;
                         $j->addSeconds(86400);
                         for (; $j->before($endtime) && $j->before($end_week_time); $j->addSeconds(86400)) {
                             $view_array[$j->format('%Y%m%d')]['-1'][] = $ovlKey . '_' . $eventMappingKey;
                         }
                     } else {
                         if ($starttime->before($end_week_time)) {
                             $starttime->subtractSeconds($starttime->getMinute() % $gridLength * 60);
                             $endtime->addSeconds($endtime->getMinute() % $gridLength * 60);
                             $entries = 1;
                             $old_day = new \TYPO3\CMS\Cal\Model\CalDate($ovlKey . '000000');
                             $endOfDay->copy($d_end);
                             $startOfDay->copy($d_start);
                             // get x-array possition
                             for ($k = 0; $k < count($view_array[$ovlKey]); $k++) {
                                 if (empty($view_array[$starttime->format('%Y%m%d')][$starttime->format('%H%M')][$k])) {
                                     break;
                                 }
                             }
                             $j->copy($starttime);
                             if ($j->before($startOfDay)) {
                                 $j->copy($startOfDay);
                             }
                             $counter = 0;
                             while ($j->before($endtime) && $j->before($end_week_time)) {
                                 $counter++;
                                 $view_array[$j->format('%Y%m%d')][$j->format('%H%M')][] = $ovlKey . '_' . $eventMappingKey;
                                 if ($j->after($endOfDay)) {
                                     $rowspan_array[$old_day->format('%Y%m%d')][$eventMappingKey] = $entries - 1;
                                     $endOfDay->addSeconds(86400);
                                     $old_day->copy($endOfDay);
                                     $startOfDay->addSeconds(86400);
                                     $j->addSeconds(86400);
                                     $j->setHour($startOfDay->getHour());
                                     $j->setMinute($startOfDay->getMinute());
                                     $j->subtractSeconds($gridLength * 60);
                                     for ($k = 0; $k < count($view_array[$startOfDay->format('%Y%m%d')]); $k++) {
                                         if (empty($view_array[$startOfDay->format('%Y%m%d')][$startOfDay->format('%H%M')][$k])) {
                                             break;
                                         }
                                     }
                                     $entries = 0;
                                     $eventArray[$startOfDay->format('%Y%m%d') . '_' . $eventMappingKey] =& $event;
                                 }
                                 $j->addSeconds($gridLength * 60);
                                 $entries++;
                             }
                             $rowspan_array[$old_day->format('%Y%m%d')][$eventMappingKey] = $entries - 1;
                         }
                     }
                 }
             }
         }
     }
     if ($this->conf['view.']['week.']['dynamic'] == 1) {
         $dayStart = '2359';
         $dayEnd = '0000';
         $firstStart = true;
         $firstEnd = true;
         $dynamicEnd = intval($end_week_time->format('%Y%m%d'));
         for ($dynamicStart = intval($start_week_time->format('%Y%m%d')); $dynamicStart < $dynamicEnd; $dynamicStart++) {
             if (is_array($view_array[$dynamicStart])) {
                 $timeKeys = array_keys($view_array[$dynamicStart]);
                 $formatedLast = array_pop($timeKeys);
                 while (intval($formatedLast) < 0 && !empty($timeKeys)) {
                     $formatedLast = array_pop($timeKeys);
                 }
                 $formatedFirst = null;
                 if (count($timeKeys) > 0) {
                     do {
                         $formatedFirst = array_shift($timeKeys);
                     } while (intval($formatedFirst) < 0 && !empty($timeKeys));
                 } else {
                     $formatedFirst = $formatedLast;
                 }
                 if (intval($formatedFirst) > 0 && (intval($formatedFirst) < intval($dayStart) || $firstStart)) {
                     $dayStart = sprintf("%04d", $formatedFirst);
                     $firstStart = false;
                 }
                 if (intval($formatedLast) > intval($dayEnd) || $firstEnd) {
                     $dayEnd = sprintf("%04d", $formatedLast + $gridLength);
                     $firstEnd = false;
                 }
             }
         }
         $dayStart = substr($dayStart, 0, 2) . '00';
     }
     $startdate = new \TYPO3\CMS\Cal\Model\CalDate($start_week_time->format('%Y%m%d') . '000000');
     $enddate = new \TYPO3\CMS\Cal\Model\CalDate();
     $enddate->copy($end_week_time);
     for ($i = $startdate; $enddate->after($i); $i->addSeconds(86400)) {
         if (!empty($view_array[$i->format('%Y%m%d')])) {
             $max = array();
             foreach (array_keys($view_array[$i->format('%Y%m%d')]) as $array_time) {
                 $c = count($view_array[$i->format('%Y%m%d')][$array_time]);
                 array_push($max, $c);
             }
             $nbrGridCols[$i->format('%Y%m%d')] = max($max);
         } else {
             $nbrGridCols[$i->format('%Y%m%d')] = 1;
         }
     }
     $t_array = array();
     $pos_array = array();
     preg_match('/([0-9]{2})([0-9]{2})/', $dayStart, $dTimeStart);
     preg_match('/([0-9]{2})([0-9]{2})/', $dayEnd, $dTimeEnd);
     $nd = new \TYPO3\CMS\Cal\Model\CalDate();
     foreach (array_keys($view_array) as $week_key) {
         $week_day =& $view_array[$week_key];
         preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})/', $week_key, $dDate);
         $d_start = new \TYPO3\CMS\Cal\Model\CalDate($dDate[1] . $dDate[2] . $dDate[3] . ' ' . $dTimeStart[1] . ':' . sprintf("%02d", $dTimeStart[2]) . ':00');
         $d_start->setTZbyId('UTC');
         $d_end = new \TYPO3\CMS\Cal\Model\CalDate($dDate[1] . $dDate[2] . $dDate[3] . ' ' . $dTimeEnd[1] . ':' . sprintf("%02d", $dTimeEnd[2]) . ':00');
         $d_end->setTZbyId('UTC');
         $d_start->subtractSeconds($d_start->getMinute() % $gridLength * 60);
         $d_end->addSeconds(($gridLength - $d_end->getMinute() % $gridLength) * 60);
         for ($i->copy($d_start); !$i->after($d_end); $i->addSeconds($gridLength * 60)) {
             $timeKey = $i->format('%H%M');
             if (is_array($view_array[$week_key][$timeKey]) && count($view_array[$week_key][$timeKey]) > 0) {
                 foreach (array_keys($view_array[$week_key][$timeKey]) as $eventKey) {
                     $event =& $eventArray[$view_array[$week_key][$timeKey][$eventKey]];
                     $eventStart = $event->getStart();
                     $startFormatted = $eventStart->format('%Y%m%d%H%M');
                     $eventType = $event->getType();
                     $eventUid = $event->getUid();
                     if (is_array($pos_array[$week_key]) && array_key_exists($eventType . $eventUid . '_' . $startFormatted, $pos_array[$week_key])) {
                         $nd->copy($event->getEnd());
                         $nd->addSeconds(($gridLength - $nd->getMinute() % $gridLength) * 60);
                         if ($nd->before($i)) {
                             $t_array[$week_key][$timeKey][$pos_array[$week_key][$eventType . $eventUid . '_' . $startFormatted]] = array('ended' => $week_key . '_' . $eventType . '_' . $eventUid . '_' . $startFormatted);
                         } else {
                             $t_array[$week_key][$timeKey][$pos_array[$week_key][$eventType . $eventUid . '_' . $startFormatted]] = array('started' => $week_key . '_' . $eventType . '_' . $eventUid . '_' . $startFormatted);
                         }
                     } else {
                         for ($j = 0; $j < $nbrGridCols[$week_key] ? $nbrGridCols[$week_key] : 1; $j++) {
                             if (!isset($t_array[$week_key][$timeKey][$j]) || count($t_array[$week_key][$timeKey][$j]) == 0) {
                                 $pos_array[$week_key][$event->getType() . $event->getUid() . '_' . $startFormatted] = $j;
                                 $t_array[$week_key][$timeKey][$j] = array('begin' => $week_key . '_' . $eventType . '_' . $eventUid . '_' . $startFormatted);
                                 break;
                             }
                         }
                     }
                 }
             } else {
                 $t_array[$week_key][$timeKey] = '';
             }
         }
     }
     $thisdate = new \TYPO3\CMS\Cal\Model\CalDate();
     $thisdate->copy($week_start_day);
     for ($i = 0; $i < 7; $i++) {
         $weekarray[$i] = $thisdate->format('%Y%m%d');
         $thisdate->addSeconds(86400);
     }
     $sims = array('###GETDATE###' => $getdate, '###DISPLAY_DATE###' => $display_date, '###LEGEND_PREV_DAY###' => $legend_prev_day_link, '###LEGEND_NEXT_DAY###' => $legend_next_day_link, '###SIDEBAR_DATE###' => '');
     // Replaces the allday events
     $alldays = $this->cObj->getSubpart($weekTemplate, '###ALLDAYSOFWEEK##');
     foreach ($weekarray as $get_date) {
         $replace = '';
         if (is_array($view_array[$get_date]['-1'])) {
             foreach ($view_array[$get_date]['-1'] as $id => $allday) {
                 $replace .= $eventArray[$allday]->renderEventForAllDay();
             }
         }
         $weekreplace .= \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($alldays, array('###COLSPAN###' => 'colspan="' . ($nbrGridCols[$get_date] ? $nbrGridCols[$get_date] : 1) . '"', '###ALLDAY###' => $replace));
     }
     $rems = array();
     $rems['###ALLDAYSOFWEEK###'] = $weekreplace;
     // Replaces the daysofweek
     $loop_dof = $this->cObj->getSubpart($weekTemplate, '###DAYSOFWEEK###');
     $start_day = new \TYPO3\CMS\Cal\Model\CalDate();
     $start_day->copy($week_start_day);
     $isAllowedToCreateEvent = $this->rightsObj->isAllowedToCreateEvent();
     for ($i = 0; $i < 7; $i++) {
         $day_num = $start_day->format('%w');
         $daylink = $start_day->format('%Y%m%d');
         $weekday = $start_day->format($this->conf['view.']['week.']['dateFormatWeekList']);
         if ($daylink == $getdate) {
             $row1 = 'rowToday';
             $row2 = 'rowOn';
             $row3 = 'rowToday';
         } else {
             $row1 = 'rowOff';
             $row2 = 'rowOn';
             $row3 = 'rowOff';
         }
         $dayLinkViewTarget =& $this->conf['view.']['dayLinkTarget'];
         if (($this->rightsObj->isViewEnabled($dayLinkViewTarget) || $this->conf['view.'][$dayLinkViewTarget . '.'][$dayLinkViewTarget . 'ViewPid']) && ($view_array[$daylink] || $isAllowedToCreateEvent)) {
             $this->initLocalCObject();
             $this->local_cObj->setCurrentVal($weekday);
             if (!empty($this->conf['view.'][$dayLinkViewTarget . '.'][$dayLinkViewTarget . 'ViewPid'])) {
                 $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('getdate' => $daylink, 'view' => $this->conf['view.']['dayLinkTarget'], $this->pointerName => NULL), $this->conf['cache'], $this->conf['clear_anyway'], $this->conf['view.'][$dayLinkViewTarget . '.'][$dayLinkViewTarget . 'ViewPid']);
             } else {
                 $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('getdate' => $daylink, 'view' => $this->conf['view.']['dayLinkTarget'], $this->pointerName => NULL), $this->conf['cache'], $this->conf['clear_anyway']);
             }
             $this->local_cObj->data['view'] = $dayLinkViewTarget;
             $link = $this->local_cObj->cObjGetSingle($this->conf['view.'][$dayLinkViewTarget . '.'][$dayLinkViewTarget . 'ViewLink'], $this->conf['view.'][$dayLinkViewTarget . '.'][$dayLinkViewTarget . 'ViewLink.']);
             $link = $this->cObj->stdWrap($link, $this->conf['view.']['week.']['weekday_stdWrap.']);
         } else {
             $link = $this->cObj->stdWrap($weekday, $this->conf['view.']['week.']['weekday_stdWrap.']);
         }
         $start_day->addSeconds(86400);
         $colspan = 'colspan="' . ($nbrGridCols[$daylink] ? $nbrGridCols[$daylink] : 1) . '"';
         $search = array('###LINK###', '###DAYLINK###', '###ROW1###', '###ROW2###', '###ROW3###', '###COLSPAN###', '###TIME###');
         $replace = array($link, $daylink, $row1, $row2, $row3, $colspan, $start_day->format('%Y %m %d %H %M %s'));
         $loop_tmp = str_replace($search, $replace, $loop_dof);
         $weekday_loop .= $loop_tmp;
     }
     $rems['###DAYSOFWEEK###'] = $weekday_loop;
     // Build the body
     $border = 0;
     $thisdate = $start_week_time;
     $dTimeStart[2] -= $dTimeStart[2] % $gridLength;
     $dTimeEnd[2] -= $dTimeEnd[2] % $gridLength;
     preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})/', $week_key, $dDate);
     $loops = ($dTimeEnd[1] * 60 + $dTimeEnd[2] - ($dTimeStart[1] * 60 + $dTimeStart[2])) / $gridLength;
     $weekdisplay = '';
     $createOffset = intval($this->conf['rights.']['create.']['event.']['timeOffset']) * 60;
     $cal_time_obj = new \TYPO3\CMS\Cal\Model\CalDate();
     $cal_time_obj->copy($week_start_day);
     $cal_time_obj->setHour(intval($dTimeStart[1]));
     $cal_time_obj->setMinute(intval($dTimeStart[2]));
     $start = 0;
     for ($i = $start; $i < $loops; $i++) {
         $time = $cal_time_obj->format('%H%M');
         for ($j = 0; $j < 7; $j++) {
             $day = $cal_time_obj->format('%Y%m%d');
             if ($j == 0) {
                 $key = $cal_time_obj->format('%I:%M');
                 if (preg_match('/([0-9]{1,2}):00/', $key)) {
                     $weekdisplay .= sprintf($this->conf['view.']['week.']['weekDisplayFullHour'], 60 / $gridLength, $cal_time_obj->format($this->conf['view.']['week.']['timeFormatWeek']), $gridLength);
                 } else {
                     $weekdisplay .= sprintf($this->conf['view.']['week.']['weekDisplayInbetween'], $gridLength);
                 }
             }
             $something = $t_array[$day][$time];
             $class = $this->conf['view.']['week.']['classWeekborder'];
             if ($day == $todayFormatted) {
                 $class .= ' ' . $this->conf['view.']['week.']['classTodayWeekborder'];
             }
             if (is_array($something) && $something != "" && count($something) > 0) {
                 for ($k = 0; $k < count($something); $k++) {
                     if (!empty($something[$k])) {
                         $keys = array_keys($something[$k]);
                         switch ($keys[0]) {
                             case 'begin':
                                 $event =& $eventArray[$something[$k][$keys[0]]];
                                 $rest = $event->getEnd()->getMinute() % ($gridLength * 60);
                                 $plus = 0;
                                 if ($rest > 0) {
                                     $plus = 1;
                                 }
                                 $weekdisplay .= sprintf($this->conf['view.']['week.']['weekEventPre'], $rowspan_array[$day][$event->getType() . '_' . $event->getUid() . '_' . $event->getStart()->format('%Y%m%d%H%M')]);
                                 $weekdisplay .= $event->renderEventForWeek();
                                 $weekdisplay .= $this->conf['view.']['week.']['weekEventPost'];
                                 // End event drawing
                                 break;
                         }
                     }
                 }
                 if (count($something) < ($nbrGridCols[$day] ? $nbrGridCols[$day] : 1)) {
                     $remember = 0;
                     for ($l = 0; $l < ($nbrGridCols[$day] ? $nbrGridCols[$day] : 1); $l++) {
                         if (!$something[$l]) {
                             $remember++;
                         } else {
                             if ($remember > 0) {
                                 $weekdisplay .= $this->getCreateEventLink('week', $this->conf['view.']['week.']['normalCell'], $cal_time_obj, $createOffset, $isAllowedToCreateEvent, $remember, $class, $time);
                                 $remember = 0;
                             }
                         }
                     }
                     if ($remember > 0) {
                         $weekdisplay .= $this->getCreateEventLink('week', $this->conf['view.']['week.']['normalCell'], $cal_time_obj, $createOffset, $isAllowedToCreateEvent, $remember, $class, $time);
                         $remember = 0;
                     }
                 }
             } else {
                 $weekdisplay .= $this->getCreateEventLink('week', $this->conf['view.']['week.']['normalCell'], $cal_time_obj, $createOffset, $isAllowedToCreateEvent, $nbrGridCols[$day] ? $nbrGridCols[$day] : 1, $class, $time);
             }
             if ($j == 6) {
                 $weekdisplay .= $this->conf['view.']['week.']['weekFinishRow'];
             }
             $cal_time_obj->addSeconds(86400);
         }
         $cal_time_obj->setYear($week_start_day->getYear());
         $cal_time_obj->setMonth($week_start_day->getMonth());
         $cal_time_obj->setDay($week_start_day->getDay());
         $cal_time_obj->addSeconds($gridLength * 60);
     }
     $weekTemplate = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($weekTemplate, $sims, array(), array());
     $rems['###LOOPEVENTS###'] = $weekdisplay;
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, array(), array('###WEEK_TEMPLATE###' => $weekTemplate), array());
     return $this->finish($page, $rems);
 }
示例#6
0
 /**
  * 
  * @return string|unknown
  */
 public function searchAll()
 {
     $type = $this->conf['type'];
     $pidList = $this->conf['pidList'];
     $hookObjectsArr = $this->getHookObjectsArray('drawSearchAllClass');
     if (intval($this->piVars['start_day']) == 0) {
         $starttime = $this->getListViewTime($this->conf['view.']['search.']['defaultValues.']['start_day']);
     } else {
         $starttime = new \TYPO3\CMS\Cal\Model\CalDate(intval($this->piVars['start_day']) . '000000');
     }
     if (intval($this->piVars['end_day']) == 0) {
         $endtime = $this->getListViewTime($this->conf['view.']['search.']['defaultValues.']['end_day']);
     } else {
         $endtime = new \TYPO3\CMS\Cal\Model\CalDate(intval($this->piVars['end_day']) . '000000');
     }
     $searchword = strip_tags($this->piVars['query']);
     if ($searchword == '') {
         $searchword = $this->cObj->stdWrap($this->conf['view.']['search.']['defaultValues.']['query'], $this->conf['view.']['search.']['event.']['defaultValues.']['query.']);
     }
     $endtime->addSeconds(86399);
     /* Get the boundaries for allowed search dates */
     $minStarttime = new \TYPO3\CMS\Cal\Model\CalDate(intval($this->conf['view.']['search.']['startRange']) . '000000');
     $maxEndtime = new \TYPO3\CMS\Cal\Model\CalDate(intval($this->conf['view.']['search.']['endRange']) . '000000');
     /* Check starttime against boundaries */
     if ($starttime->before($minStarttime)) {
         $starttime->copy($minStarttime);
     }
     if ($starttime->after($maxEndtime)) {
         $starttime->copy($maxEndtime);
     }
     /* Check endtime against boundaries */
     if ($endtime->before($minStarttime)) {
         $endtime->copy($minStarttime);
     }
     if ($endtime->after($maxEndtime)) {
         $endtime->copy($maxEndtime);
     }
     /* Check endtime against starttime */
     if ($endtime->before($starttime)) {
         $endtime->copy($starttime);
     }
     $locationIds = strip_tags(Controller::convertLinkVarArrayToList($this->piVars['location_ids']));
     $organizerIds = strip_tags(Controller::convertLinkVarArrayToList($this->piVars['organizer_ids']));
     $modelObj =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'modelcontroller');
     $list = array();
     if ($this->piVars['query'] && ($this->piVars['submit'] || !$this->conf['view.']['search.']['startSearchAfterSubmit'])) {
         $list['phpicalendar_event'] = $modelObj->searchEvents($type, $pidList, $starttime, $endtime, $searchword, $locationIds, $organizerIds);
         $list['location'] = $modelObj->searchLocation($type, $pidList, $searchword);
         $list['organizer'] = $modelObj->searchOrganizer($type, $pidList, $searchword);
     }
     // Hook: preSearchAllRendering
     if (is_array($hookObjectsArr)) {
         foreach ($hookObjectsArr as $hookObj) {
             if (method_exists($hookObj, 'preSearchAllRendering')) {
                 $hookObj->preSearchAllRendering($list, $this);
             }
         }
     }
     if ($this->conf['view.']['enableAjax']) {
         $ajaxStringArray = array();
         foreach ($list as $location) {
             $ajaxStringArray[] = '{' . $this->getEventAjaxString($location) . '}';
         }
         return '[' . implode(',', $ajaxStringArray) . ']';
     }
     $viewObj =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'viewcontroller');
     $drawnList = $viewObj->drawSearchAllResult($list, $starttime, $endtime, $searchword, $locationIds, $organizerIds);
     // Hook: postSearchAllRendering
     if (is_array($hookObjectsArr)) {
         foreach ($hookObjectsArr as $hookObj) {
             if (method_exists($hookObj, 'postSearchAllRendering')) {
                 $hookObj->postSearchAllRendering($drawnList, $list, $this);
             }
         }
     }
     return $drawnList;
 }
示例#7
0
文件: DayView.php 项目: ulrikkold/cal
 /**
  * Draws the day view
  * 
  * @param $master_array array
  *        	to be drawn.
  * @param $getdate integer
  *        	of the event
  * @return string HTML output.
  */
 public function drawDay(&$master_array, $getdate)
 {
     $this->_init($master_array);
     if ($this->conf['useNewTemplatesAndRendering']) {
         return $this->newDrawDay($master_array, $getdate);
     }
     $page = $this->cObj->fileResource($this->conf['view.']['day.']['dayTemplate']);
     if ($page == '') {
         return "<h3>day: no template file found:</h3>" . $this->conf['view.']['day.']['dayTemplate'] . "<br />Please check your template record and add both cal items at 'include static (from extension)'";
     }
     $dayTemplate = $this->cObj->getSubpart($page, '###DAY_TEMPLATE###');
     if ($dayTemplate == '') {
         $rems = array();
         return $this->finish($page, $rems);
     }
     $dayStart = $this->conf['view.']['day.']['dayStart'];
     // '0700'; // Start time for day grid
     $dayEnd = $this->conf['view.']['day.']['dayEnd'];
     // '2300'; // End time for day grid
     $gridLength = $this->conf['view.']['day.']['gridLength'];
     // '15'; // Grid distance in minutes for day view, multiples of 15 preferred
     if (!isset($getdate) || $getdate == '') {
         $getdate_obj = new \TYPO3\CMS\Cal\Model\CalDate();
         $getdate = $getdate_obj->format('%Y%m%d');
     }
     $day_array2 = array();
     preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})/', $getdate, $day_array2);
     $this_day = $day_array2[3];
     $this_month = $day_array2[2];
     $this_year = $day_array2[1];
     $unix_time = new \TYPO3\CMS\Cal\Model\CalDate($getdate . '000000');
     $this->initLocalCObject();
     $this->local_cObj->setCurrentVal($this->conf['view.']['day.']['legendNextDayLink']);
     $legend_next_day_link = $this->local_cObj->cObjGetSingle($this->conf['view.']['day.']['legendNextDayLink'], $this->conf['view.']['day.']['legendNextDayLink.']);
     $this->local_cObj->setCurrentVal($this->conf['view.']['day.']['legendPrevDayLink']);
     $legend_prev_day_link = $this->local_cObj->cObjGetSingle($this->conf['view.']['day.']['legendPrevDayLink'], $this->conf['view.']['day.']['legendPrevDayLink.']);
     $next_month_obj = new \TYPO3\CMS\Cal\Model\CalDate();
     $next_month_obj->copy($unix_time);
     $next_month_obj->addSeconds(604800);
     $next_month = $next_month_obj->format('%Y%m%d');
     $prev_month_obj = new \TYPO3\CMS\Cal\Model\CalDate();
     $prev_month_obj->copy($unix_time);
     $prev_month_obj->subtractSeconds(604801);
     $prev_month = $prev_month_obj->format('%Y%m%d');
     $dateOfWeek = Calc::beginOfWeek($this_day, $this_month, $this_year);
     $week_start_day = new \TYPO3\CMS\Cal\Model\CalDate($dateOfWeek . '000000');
     $start_day = $unix_time;
     $start_week_time = $start_day;
     $end_week_time = new \TYPO3\CMS\Cal\Model\CalDate();
     $end_week_time->copy($start_week_time);
     $end_week_time->addSeconds(604799);
     // Nasty fix to work with TS strftime
     $start_day_time = new \TYPO3\CMS\Cal\Model\CalDate($getdate . '000000');
     $start_day_time->setTZbyId('UTC');
     $end_day_time = \TYPO3\CMS\Cal\Controller\Calendar::calculateEndDayTime($start_day_time);
     $GLOBALS['TSFE']->register['cal_day_starttime'] = $start_day_time->getTime();
     $GLOBALS['TSFE']->register['cal_day_endtime'] = $end_day_time->getTime();
     $display_date = $this->cObj->cObjGetSingle($this->conf['view.']['day.']['titleWrap'], $this->conf['view.']['day.']['titleWrap.'], $TSkey = '__');
     $dayTemplate = $this->cObj->fileResource($this->conf['view.']['day.']['dayTemplate']);
     if ($dayTemplate == '') {
         return '<h3>calendar: no template file found:</h3>' . $this->conf['view.']['day.']['dayTemplate'] . '<br />Please check your template record and add both cal items at "include static (from extension)"';
     }
     $dayTemplate = $this->replace_files($dayTemplate, array('sidebar' => $this->conf['view.']['other.']['sidebarTemplate']));
     $sims = array('###GETDATE###' => $getdate, '###DISPLAY_DATE###' => $display_date, '###LEGEND_PREV_DAY###' => $legend_prev_day_link, '###LEGEND_NEXT_DAY###' => $legend_next_day_link, '###SIDEBAR_DATE###' => '');
     // Replaces the daysofweek
     $loop_dof = $this->cObj->getSubpart($dayTemplate, '###DAYSOFWEEK###');
     // Build the body
     $dayborder = 0;
     $out = '';
     $fillTime = sprintf('%04d', $dayStart);
     $day_array = array();
     while ($fillTime < $dayEnd) {
         array_push($day_array, $fillTime);
         $dTime = array();
         preg_match('/([0-9]{2})([0-9]{2})/', $fillTime, $dTime);
         $fill_h = $dTime[1];
         $fill_min = $dTime[2];
         $fill_min = sprintf('%02d', $fill_min + $gridLength);
         if ($fill_min == 60) {
             $fill_h = sprintf('%02d', $fill_h + 1);
             $fill_min = '00';
         }
         $fillTime = $fill_h . $fill_min;
     }
     $nbrGridCols = array();
     $dayborder = 0;
     $view_array = array();
     $rowspan_array = array();
     $eventArray = array();
     $endOfDay = new \TYPO3\CMS\Cal\Model\CalDate();
     $startOfDay = new \TYPO3\CMS\Cal\Model\CalDate();
     if (!empty($this->master_array)) {
         foreach ($this->master_array as $ovlKey => $ovlValue) {
             $dTimeStart = array();
             $dTimeEnd = array();
             $dDate = array();
             preg_match('/([0-9]{2})([0-9]{2})/', $dayStart, $dTimeStart);
             preg_match('/([0-9]{2})([0-9]{2})/', $dayEnd, $dTimeEnd);
             preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})/', $ovlKey, $dDate);
             $d_start = new \TYPO3\CMS\Cal\Model\CalDate($dDate[1] . $dDate[2] . $dDate[3] . ' ' . $dTimeStart[1] . ':' . $dTimeStart[2] . ':00');
             $d_start->setTZbyId('UTC');
             $d_end = new \TYPO3\CMS\Cal\Model\CalDate($dDate[1] . $dDate[2] . $dDate[3] . ' ' . $dTimeEnd[1] . ':' . $dTimeEnd[2] . ':00');
             $d_end->setTZbyId('UTC');
             foreach ($ovlValue as $ovl_time_key => $ovl_time_Value) {
                 foreach ($ovl_time_Value as $event) {
                     $eventStart = $event->getStart();
                     $eventArray[$event->getType() . '_' . $event->getUid() . '_' . $eventStart->format('%Y%m%d%H%M')] = $event;
                     $starttime = new \TYPO3\CMS\Cal\Model\CalDate();
                     $endtime = new \TYPO3\CMS\Cal\Model\CalDate();
                     $j = new \TYPO3\CMS\Cal\Model\CalDate();
                     if ($ovl_time_key == '-1') {
                         $starttime->copy($event->getStart());
                         $endtime->copy($event->getEnd());
                         $endtime->addSeconds(1);
                         for ($j->copy($starttime); $j->before($endtime) && $j->before($end_week_time); $j->addSeconds(86400)) {
                             $view_array[$j->format('%Y%m%d')]['-1'][] = $event->getType() . '_' . $event->getUid() . '_' . $eventStart->format('%Y%m%d%H%M');
                         }
                     } else {
                         $starttime->copy($event->getStart());
                         $starttime->subtractSeconds($starttime->getMinute() % $gridLength * 60);
                         $endtime->copy($event->getEnd());
                         $endtime->subtractSeconds($endtime->getMinute() % $gridLength * 60);
                         $entries = 1;
                         $old_day = new \TYPO3\CMS\Cal\Model\CalDate($ovlKey . '000000');
                         $old_day->setTZbyId('UTC');
                         $endOfDay->copy($d_end);
                         $startOfDay->copy($d_start);
                         // $d_start -= $gridLength * 60;
                         for ($k = 0; $k < count($view_array[$ovlKey]); $k++) {
                             if (empty($view_array[$starttime->format('%Y%m%d')][$starttime->format('%H%M')][$k])) {
                                 break;
                             }
                         }
                         $j->copy($starttime);
                         if ($j->before($startOfDay)) {
                             $j->copy($startOfDay);
                         }
                         while ($j->before($endtime) && $j->before($end_week_time)) {
                             if ($j->after($endOfDay)) {
                                 $rowspan_array[$old_day->format('%Y%m%d')][$event->getType() . '_' . $event->getUid() . '_' . $eventStart->format('%Y%m%d%H%M')] = $entries - 1;
                                 $endOfDay->addSeconds(60 * 60 * 24);
                                 $old_day->copy($endOfDay);
                                 $startOfDay->addSeconds(60 * 60 * 24);
                                 $j->copy($startOfDay);
                                 $entries = 0;
                                 for ($k = 0; $k < count($view_array[$startOfDay->format('%Y%m%d')]); $k++) {
                                     if (empty($view_array[$d_start->format('%Y%m%d')][$startOfDay->format('%H%M')][$k])) {
                                         break;
                                     }
                                 }
                             } else {
                                 $view_array[$j->format('%Y%m%d')][$j->format('%H%M')][] = $event->getType() . '_' . $event->getUid() . '_' . $eventStart->format('%Y%m%d%H%M');
                                 $j->addSeconds($gridLength * 60);
                             }
                             $entries++;
                         }
                         $rowspan_array[$old_day->format('%Y%m%d')][$event->getType() . '_' . $event->getUid() . '_' . $eventStart->format('%Y%m%d%H%M')] = $entries - 1;
                     }
                 }
             }
         }
     }
     if ($this->conf['view.']['day.']['dynamic'] == 1) {
         $dayStart = '2359';
         $dayEnd = '0000';
         if (is_array($view_array[$getdate])) {
             $timeKeys = array_keys($view_array[$getdate]);
             $formatedLast = array_pop($timeKeys);
             $formatedFirst = $formatedLast;
             foreach ($timeKeys as $timeKey) {
                 if ($timeKey > 0) {
                     $formatedFirst = $timeKey;
                     break;
                 }
             }
             if (intval($formatedFirst) > 0 && intval($formatedFirst) < intval($dayStart)) {
                 $dayStart = sprintf("%04d", $formatedFirst);
             }
             if (intval($formatedLast) > intval($dayEnd)) {
                 $dayEnd = sprintf("%04d", $formatedLast + $gridLength);
             }
         }
         $dayStart = substr($dayStart, 0, 2) . '00';
     }
     if (!empty($view_array[$getdate])) {
         $max = array();
         foreach ($view_array[$getdate] as $array_time => $time_val) {
             $c = count($view_array[$getdate][$array_time]);
             array_push($max, $c);
         }
         $nbrGridCols[$getdate] = max($max);
     } else {
         $nbrGridCols[$getdate] = 1;
     }
     $isAllowedToCreateEvent = $this->rightsObj->isAllowedToCreateEvent();
     $start_day = $week_start_day;
     for ($i = 0; $i < 7; $i++) {
         $day_num = $start_day->format('%w');
         $daylink = $start_day->format('%Y%m%d');
         $weekday = $start_day->format($this->conf['view.']['day.']['dateFormatDay']);
         if ($daylink == $getdate) {
             $row1 = 'rowToday';
             $row2 = 'rowOn';
             $row3 = 'rowToday';
         } else {
             $row1 = 'rowOff';
             $row2 = 'rowOn';
             $row3 = 'rowOff';
         }
         $dayLinkViewTarget = $this->conf['view.']['dayLinkTarget'];
         if (($this->rightsObj->isViewEnabled($dayLinkViewTarget) || $this->conf['view.'][$dayLinkViewTarget . '.'][$dayLinkViewTarget . 'ViewPid']) && ($view_array[$daylink] || $isAllowedToCreateEvent)) {
             $this->initLocalCObject();
             $this->local_cObj->setCurrentVal($weekday);
             $this->local_cObj->data['view'] = $dayLinkViewTarget;
             $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('getdate' => $daylink, 'view' => $dayLinkViewTarget, $this->pointerName => NULL), $this->conf['cache'], $this->conf['clear_anyway'], $this->conf['view.'][$dayLinkViewTarget . '.'][$dayLinkViewTarget . 'ViewPid']);
             $link = $this->local_cObj->cObjGetSingle($this->conf['view.'][$dayLinkViewTarget . '.'][$dayLinkViewTarget . 'ViewLink'], $this->conf['view.'][$dayLinkViewTarget . '.'][$dayLinkViewTarget . 'ViewLink.']);
         } else {
             $link = $weekday;
         }
         $start_day->addSeconds(86400);
         $search = array('###LINK###', '###DAYLINK###', '###ROW1###', '###ROW2###', '###ROW3###');
         $replace = array($link, $daylink, $row1, $row2, $row3);
         $loop_tmp = str_replace($search, $replace, $loop_dof);
         $weekday_loop .= $loop_tmp;
     }
     $rems['###DAYSOFWEEK###'] = $weekday_loop;
     // Replaces the allday events
     $replace = '';
     if (is_array($view_array[$getdate]['-1'])) {
         $loop_ad = $this->cObj->getSubpart($dayTemplate, '###LOOPALLDAY###');
         foreach ($view_array[$getdate]['-1'] as $uid => $allday) {
             $replace .= $eventArray[$allday]->renderEventForAllDay();
         }
     }
     $sims['###ALLDAY###'] = $replace;
     $view_array = $view_array[$getdate];
     $nbrGridCols = $nbrGridCols[$getdate] ? $nbrGridCols[$getdate] : 1;
     $t_array = array();
     $pos_array = array();
     preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})/', $getdate, $dDate);
     preg_match('/([0-9]{2})([0-9]{2})/', $dayStart, $dTimeStart);
     preg_match('/([0-9]{2})([0-9]{2})/', $dayEnd, $dTimeEnd);
     $dTimeStart[2] -= $dTimeStart[2] % $gridLength;
     $dTimeEnd[2] -= $dTimeEnd[2] % $gridLength;
     $d_start = new \TYPO3\CMS\Cal\Model\CalDate($dDate[1] . $dDate[2] . $dDate[3] . ' ' . $dTimeStart[1] . ':' . sprintf("%02d", $dTimeStart[2]) . ':00');
     $d_start->setTZbyId('UTC');
     $d_end = new \TYPO3\CMS\Cal\Model\CalDate($dDate[1] . $dDate[2] . $dDate[3] . ' ' . $dTimeEnd[1] . ':' . sprintf("%02d", $dTimeEnd[2]) . ':00');
     $d_end->setTZbyId('UTC');
     $i = new \TYPO3\CMS\Cal\Model\CalDate();
     $i->copy($d_start);
     $i->setTZbyId('UTC');
     while ($i->before($d_end)) {
         $i_formatted = $i->format('%H%M');
         if (is_array($view_array[$i_formatted]) && count($view_array[$i_formatted]) > 0) {
             foreach ($view_array[$i_formatted] as $eventKey) {
                 $event =& $eventArray[$eventKey];
                 $eventStart = $event->getStart();
                 if (array_key_exists($event->getType() . $event->getUid() . '_' . $eventStart->format('%Y%m%d%H%M'), $pos_array)) {
                     $eventEnd = $event->getEnd();
                     $nd = $eventEnd->subtractSeconds($eventEnd->getMinute() % $gridLength * 60);
                     if ($i_formatted >= $nd) {
                         $t_array[$i_formatted][$pos_array[$event->getType() . $event->getUid() . '_' . $eventStart->format('%Y%m%d%H%M')]] = array('ended' => $event->getType() . '_' . $event->getUid() . '_' . $eventStart->format('%Y%m%d%H%M'));
                     } else {
                         $t_array[$i_formatted][$pos_array[$event->getType() . $event->getUid() . '_' . $eventStart->format('%Y%m%d%H%M')]] = array('started' => $event->getType() . '_' . $event->getUid() . '_' . $eventStart->format('%Y%m%d%H%M'));
                     }
                 } else {
                     for ($j = 0; $j < $nbrGridCols; $j++) {
                         if (count($t_array[$i_formatted][$j]) == 0 || !isset($t_array[$i_formatted][$j])) {
                             $pos_array[$event->getType() . $event->getUid() . '_' . $eventStart->format('%Y%m%d%H%M')] = $j;
                             $t_array[$i_formatted][$j] = array('begin' => $event->getType() . '_' . $event->getUid() . '_' . $eventStart->format('%Y%m%d%H%M'));
                             break;
                         }
                     }
                 }
             }
         } else {
             $t_array[$i_formatted] = '';
         }
         $i->addSeconds($gridLength * 60);
     }
     $event_length = array();
     $border = 0;
     $createOffset = intval($this->conf['rights.']['create.']['event.']['timeOffset']) * 60;
     $cal_time_obj = new \TYPO3\CMS\Cal\Model\CalDate($getdate . '000000');
     $cal_time_obj->setTZbyId('UTC');
     foreach ($t_array as $cal_time => $val) {
         preg_match('/([0-9]{2})([0-9]{2})/', $cal_time, $dTimeStart);
         $cal_time_obj->setHour($dTimeStart[1]);
         $cal_time_obj->setMinute($dTimeStart[2]);
         $key = $cal_time_obj->format($this->conf['view.']['day.']['timeFormatDay']);
         if (intval($dTimeStart[2]) == 0) {
             $daydisplay .= sprintf($this->conf['view.']['day.']['dayTimeCell'], 60 / $gridLength, $key, $gridLength);
         } elseif ($cal_time_obj->equals($d_start)) {
             $size_tmp = 60 - (int) substr($cal_time, 2, 2);
             $daydisplay .= sprintf($this->conf['view.']['day.']['dayTimeCell'], $size_tmp / $gridLength, $key, $gridLength);
         } else {
             $daydisplay .= sprintf($this->conf['view.']['day.']['dayTimeCell2'], $gridLength);
         }
         if ($dayborder == 0) {
             $class = ' ' . $this->conf['view.']['day.']['classDayborder'];
             $dayborder++;
         } else {
             $class = ' ' . $this->conf['view.']['day.']['classDayborder2'];
             $dayborder = 0;
         }
         if ($val != '' && count($val) > 0) {
             for ($i = 0; $i < count($val); $i++) {
                 if (!empty($val[$i])) {
                     $keys = array_keys($val[$i]);
                     switch ($keys[0]) {
                         case 'begin':
                             $event =& $eventArray[$val[$i][$keys[0]]];
                             $dayEndTime = new \TYPO3\CMS\Cal\Model\CalDate();
                             $dayEndTime->copy($event->getEnd());
                             $dayStartTime = new \TYPO3\CMS\Cal\Model\CalDate();
                             $dayStartTime->copy($event->getStart());
                             $rest = $dayStartTime->getMinute() % $gridLength;
                             $plus = 0;
                             if ($rest > 0) {
                                 $plus = 1;
                             }
                             if ($dayEndTime->after($d_end)) {
                                 $dayEndTime = $d_end;
                             }
                             if ($dayStartTime->before($d_start)) {
                                 $dayStartTime = $d_start;
                             }
                             $colSpan = $rowspan_array[$getdate][$val[$i][$keys[0]]];
                             $daydisplay .= sprintf($this->conf['view.']['day.']['dayEventPre'], $colSpan);
                             $daydisplay .= $event->renderEventForDay();
                             $daydisplay .= $this->conf['view.']['day.']['dayEventPost'];
                             // End event drawing
                             break;
                     }
                 }
             }
             if (count($val) < $nbrGridCols) {
                 $remember = 0;
                 // Render cells with events
                 for ($l = 0; $l < $nbrGridCols; $l++) {
                     if (!$val[$l]) {
                         $remember++;
                     } else {
                         if ($remember > 0) {
                             $daydisplay .= $this->getCreateEventLink('day', $this->conf['view.']['day.']['normalCell'], $cal_time_obj, $createOffset, $isAllowedToCreateEvent, $remember, $class, $cal_time);
                             $remember = 0;
                         }
                     }
                 }
                 // Render cells next to events
                 if ($remember > 0) {
                     $daydisplay .= $this->getCreateEventLink('day', $this->conf['view.']['day.']['normalCell'], $cal_time_obj, $createOffset, $isAllowedToCreateEvent, $remember, $class, $cal_time);
                     $remember = 0;
                 }
             }
         } else {
             // Render cells without events
             $daydisplay .= $this->getCreateEventLink('day', $this->conf['view.']['day.']['normalCell'], $cal_time_obj, $createOffset, $isAllowedToCreateEvent, $nbrGridCols, $class, $cal_time);
         }
         $daydisplay .= $this->conf['view.']['day.']['dayFinishRow'];
     }
     $dayTemplate = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($dayTemplate, $sims, array(), array());
     $rems['###DAYEVENTS###'] = $daydisplay;
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, array(), array('###DAY_TEMPLATE###' => $dayTemplate), array());
     return $this->finish($page, $rems);
 }