Пример #1
0
 /**
  * Constructor.
  */
 public function __construct($day, $month, $year, $parentMonth = -1)
 {
     parent::__construct();
     $this->mySubpart = 'DAY_SUBPART';
     $this->day = intval($day);
     $this->month = intval($month);
     $this->year = intval($year);
     $date = new \TYPO3\CMS\Cal\Model\CalDate();
     $date->setDay($this->day);
     $date->setMonth($this->month);
     $date->setYear($this->year);
     $this->weekdayNumber = $date->format('%w');
     $this->Ymd = $date->format('%Y%m%d');
     $this->time = $date->getTime();
     if ($parentMonth >= 0) {
         $this->setParentMonth(intval($parentMonth));
     } else {
         $this->setParentMonth($this->month);
     }
 }
Пример #2
0
 function evaluateRange(&$date, $range, $rangeValue)
 {
     if (!is_numeric($range)) {
         if ($range == 'last') {
             $range = -1;
         } else {
             if ($range == 'next') {
                 $range = 1;
             }
         }
     }
     if (is_numeric($rangeValue)) {
         $date->addSeconds($rangeValue * $range);
     } else {
         if (is_array($rangeValue)) {
             foreach ($rangeValue as $key => $value) {
                 if ($key == 'weekday' && $range > 0) {
                     for ($i = 0; $i < $range; $i++) {
                         $formatedDate = Calc::nextDayOfWeek($value, $date->getDay(), $date->getMonth(), $date->getYear());
                         $date = new \TYPO3\CMS\Cal\Model\CalDate($formatedDate);
                         $date->setTZbyId('UTC');
                     }
                 } else {
                     if ($key == 'weekday' && $range < 0) {
                         for ($i = 0; $i > $range; $i--) {
                             $formatedDate = Calc::prevDayOfWeek($value, $date->getDay(), $date->getMonth(), $date->getYear());
                             $date = new \TYPO3\CMS\Cal\Model\CalDate($formatedDate);
                             $date->setTZbyId('UTC');
                         }
                     } else {
                         if ($value == 'week' && $range > 0) {
                             $date->addSeconds($range * 604800);
                         } else {
                             if ($value == 'week' && $range < 0) {
                                 $date->subtractSeconds($range * 604800);
                             }
                         }
                     }
                 }
             }
         } else {
             if ($range > 0) {
                 if ($rangeValue == 'month') {
                     for ($i = 0; $i < $range; $i++) {
                         $days = Calc::daysInMonth($date->getMonth(), $date->getYear());
                         $endOfNextMonth = new \TYPO3\CMS\Cal\Model\CalDate(Calc::endOfNextMonth($date->getDay(), $date->getMonth(), $date->getYear()));
                         $date->addSeconds(60 * 60 * 24 * $days);
                         if ($date->after($endOfNextMonth)) {
                             $date->setDay($endOfNextMonth->getDay());
                             $date->setMonth($endOfNextMonth->getMonth());
                             $date->setYear($endOfNextMonth->getYear());
                         }
                     }
                 } else {
                     if ($rangeValue == 'year') {
                         $date->setYear($date->getYear() + $range);
                     } else {
                         if ($rangeValue == 'hour') {
                             $date->addSeconds($range * 3600);
                         } else {
                             if ($rangeValue == 'minute') {
                                 $date->addSeconds($range * 60);
                             } else {
                                 $date->addSeconds($range * 86400);
                             }
                         }
                     }
                 }
             } else {
                 if ($range < 0) {
                     if ($rangeValue == 'month') {
                         for ($i = 0; $i > $range; $i--) {
                             $endOfPrevMonth = new \TYPO3\CMS\Cal\Model\CalDate(Calc::endOfPrevMonth($date->getDay(), $date->getMonth(), $date->getYear()));
                             $days = Calc::daysInMonth($endOfPrevMonth->getMonth(), $endOfPrevMonth->getYear());
                             $date->subtractSeconds(60 * 60 * 24 * $days);
                         }
                     } else {
                         if ($rangeValue == 'year') {
                             $date->setYear($date->getYear() - abs($range));
                         } else {
                             if ($rangeValue == 'hour') {
                                 $date->subtractSeconds(abs($range) * 3600);
                             } else {
                                 if ($rangeValue == 'minute') {
                                     $date->subtractSeconds(abs($range) * 60);
                                 } else {
                                     $date->subtractSeconds(abs($range) * 86400);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     $date->subtractSeconds(1);
 }
Пример #3
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;
 }
Пример #4
0
 function processObject(&$event, &$cal_time, &$firstEventDate)
 {
     $eventStart = $event->getStart();
     $eventEnd = $event->getEnd();
     if ($eventEnd->before($this->starttime) || $eventStart->after($this->endtime)) {
         return;
     }
     /* If we haven't saved an event date already, save this one */
     if (!$firstEventDate) {
         $firstEventDate = new \TYPO3\CMS\Cal\Model\CalDate();
         if ($this->reverse) {
             $firstEventDate->copy($eventEnd);
         } else {
             $firstEventDate->copy($eventStart);
         }
     }
     /* Always save the current event date as the last one and let it fall through */
     if ($this->reverse) {
         $lastEventDate = $eventStart;
     } else {
         $lastEventDate = $eventEnd;
     }
     $year = $eventStart->getYear();
     $month = $eventStart->getMonth();
     $day = $eventStart->getDay();
     $week = $eventStart->getWeekOfYear();
     $this->eventCounter['byDate'][$year][$month][$day]['total']++;
     $this->eventCounter['byWeek'][$week]['total']++;
     $this->eventCounter['byYear'][$year]['total']++;
     $this->eventCounter['byMonth'][$month]['total']++;
     $this->eventCounter['byDay'][$day]['total']++;
     $this->eventCounter['byYearMonth'][$year][$month]['total']++;
     $this->eventCounter['byYearDay'][$year][$day]['total']++;
     // Pagebrowser
     if ($this->conf['view.']['list.']['pageBrowser.']['usePageBrowser']) {
         if ($this->count < $this->recordsPerPage * $this->offset) {
             $this->eventCounter['byDate'][$year][$month][$day]['previousPages']++;
             $this->eventCounter['byWeek'][$week]['previousPages']++;
             $this->eventCounter['byYear'][$year]['previousPages']++;
             $this->eventCounter['byMonth'][$month]['previousPages']++;
             $this->eventCounter['byYearMonth'][$year][$month]['previousPages']++;
             $this->eventCounter['byDay'][$day]['previousPages']++;
             $this->eventCounter['byYearDay'][$year][$day]['previousPages']++;
         } else {
             if ($this->count > $this->recordsPerPage * $this->offset + $this->recordsPerPage - 1) {
                 $this->eventCounter['byDate'][$year][$month][$day]['nextPages']++;
                 $this->eventCounter['byWeek'][$week]['nextPages']++;
                 $this->eventCounter['byYear'][$year]['nextPages']++;
                 $this->eventCounter['byMonth'][$month]['nextPages']++;
                 $this->eventCounter['byYearMonth'][$year][$month]['nextPages']++;
                 $this->eventCounter['byDay'][$day]['nextPages']++;
                 $this->eventCounter['byYearDay'][$year][$day]['nextPages']++;
             } else {
                 $this->eventCounter['byDate'][$year][$month][$day]['currentPage']++;
                 $this->eventCounter['byWeek'][$week]['currentPage']++;
                 $this->eventCounter['byYear'][$year]['currentPage']++;
                 $this->eventCounter['byMonth'][$month]['currentPage']++;
                 $this->eventCounter['byYearMonth'][$year][$month]['currentPage']++;
                 $this->eventCounter['byDay'][$day]['currentPage']++;
                 $this->eventCounter['byYearDay'][$year][$day]['currentPage']++;
             }
         }
         if ($this->count < $this->recordsPerPage * $this->offset || $this->count > $this->recordsPerPage * $this->offset + $this->recordsPerPage - 1) {
             $this->count++;
             if ($this->count == intval($this->conf['view.']['list.']['maxEvents'])) {
                 $finished = true;
             }
             return $finished;
         }
     }
     $GLOBALS['TSFE']->register['cal_list_lastevent'] = $event->getStart()->getTime();
     // reference the event in the rendering array
     $hookObjectsArr = \TYPO3\CMS\Cal\Utility\Functions::getHookObjectsArray('tx_cal_listview', 'sorting', 'view');
     if (count($hookObjectsArr)) {
         foreach ($hookObjectsArr as $hookObj) {
             if (method_exists($hookObj, 'sorting')) {
                 $hookObj->sorting($this, $cal_time, $event);
             }
         }
     } else {
         $this->objectsInList[$cal_time][] =& $event;
     }
     if ($this->conf['view.']['list.']['showLongEventsInEachWrapper']) {
         if ($this->conf['view.']['list.']['enableDayWrapper'] && $eventStart->format('%Y%m%d') != $eventEnd->format('%Y%m%d')) {
             $tempEventStart = new \TYPO3\CMS\Cal\Model\CalDate();
             $tempEventStart->copy($eventStart);
             while ($tempEventStart->format('%Y%m%d') != $eventEnd->format('%Y%m%d')) {
                 $tempEventStart->addSeconds(60 * 60 * 24);
                 $this->objectsInList[$tempEventStart->format('%Y%m%d')][] =& $event;
             }
         }
         if ($this->conf['view.']['list.']['enableWeekWrapper'] && $eventStart->format('%Y%U') != $eventEnd->format('%Y%U')) {
             $tempEventStart = new \TYPO3\CMS\Cal\Model\CalDate();
             $tempEventStart->copy($eventStart);
             while ($tempEventStart->format('%Y%U') != $eventEnd->format('%Y%U')) {
                 $tempEventStart->addSeconds(60 * 60 * 24 * 7);
                 $this->objectsInList[$tempEventStart->format('%Y%m%d')][] =& $event;
             }
         }
         if ($this->conf['view.']['list.']['enableMonthWrapper'] && $eventStart->format('%Y%m') != $eventEnd->format('%Y%m')) {
             $tempEventStart = new \TYPO3\CMS\Cal\Model\CalDate();
             $tempEventStart->copy($eventStart);
             while ($tempEventStart->format('%Y%m') != $eventEnd->format('%Y%m')) {
                 $tempEventStart->setMonth($tempEventStart->getMonth() + 1);
                 $this->objectsInList[$tempEventStart->format('%Y%m01')][] =& $event;
             }
         }
         if ($this->conf['view.']['list.']['enableYearWrapper'] && $eventStart->format('%Y') != $eventEnd->format('%Y')) {
             $tempEventStart = new \TYPO3\CMS\Cal\Model\CalDate();
             $tempEventStart->copy($eventStart);
             while ($tempEventStart->format('%Y') != $eventEnd->format('%Y')) {
                 $tempEventStart->setYear($tempEventStart->getYear() + 1);
                 $this->objectsInList[$tempEventStart->format('%Y0101')][] =& $event;
             }
         }
     }
     $this->count++;
     if ($this->count == intval($this->conf['view.']['list.']['maxEvents'])) {
         $finished = true;
     }
     return $finished;
 }
Пример #5
0
 public function getCreateEventLinkMarker(&$template, &$sims, &$rems, &$wrapped, $view)
 {
     $sims['###CREATE_EVENT_LINK###'] = '';
     $rightsObj =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'rightscontroller');
     $conf =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'conf');
     $controller =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'controller');
     if (!$rightsObj->isViewEnabled('create_event')) {
         return;
     }
     $than = new \TYPO3\CMS\Cal\Model\CalDate();
     $than->setTZbyId('UTC');
     $than->addSeconds($createOffset);
     $date = new \TYPO3\CMS\Cal\Model\CalDate();
     $date->setDay($this->day);
     $date->setMonth($this->month);
     $date->setYear($this->year);
     $date->setHour($this->hour);
     $date->setMinute($this->minute);
     if ($rightsObj->isAllowedToCreateEventForTodayAndFuture()) {
         $date->setHour(23);
         $date->setMinute(59);
     }
     if (($date->after($than) || $rightsObj->isAllowedToCreateEventInPast()) && $rightsObj->isAllowedToCreateEvent()) {
         $local_cObj = $this->getLocalCObject();
         $timeParams = '';
         if ($view == 'day' || $view == 'week') {
             $timeParams = '&tx_cal_controller[gettime]=' . $date->format('%H%M');
         } else {
             if ($conf['rights.']['create.']['event.']['fields.']['starttime.']['default'] == 'now') {
                 $now = new \TYPO3\CMS\Cal\Model\CalDate();
                 $than->setTZbyId('UTC');
                 $timeParams = '&tx_cal_controller[gettime]=' . $now->format('%H%M');
             }
         }
         $local_cObj->setCurrentVal($conf['view.'][$view . '.']['event.']['addIcon']);
         // linkConf = Array();
         $local_cObj->data['link_useCacheHash'] = 0;
         $local_cObj->data['link_no_cache'] = 1;
         $local_cObj->data['link_additionalParams'] = $timeParams . '&tx_cal_controller[startdate]=' . $date->format('%Y%m%d') . '&tx_cal_controller[lastview]=' . $controller->extendLastView() . '&tx_cal_controller[view]=create_event';
         $local_cObj->data['link_section'] = 'default';
         $local_cObj->data['link_parameter'] = $conf['view.']['event.']['createEventViewPid'] ? $conf['view.']['event.']['createEventViewPid'] : $GLOBALS['TSFE']->id;
         $sims['###CREATE_EVENT_LINK###'] .= $local_cObj->cObjGetSingle($conf['view.'][$view . '.']['event.']['addLink'], $conf['view.'][$view . '.']['event.']['addLink.']);
     }
 }
Пример #6
0
 function getMonthTitleMarker(&$template, &$sims, &$rems, &$wrapped, $view)
 {
     $current_month = new \TYPO3\CMS\Cal\Model\CalDate();
     $current_month->setMonth($this->month);
     $current_month->setYear($this->year);
     $conf =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'conf');
     $sims['###MONTH_TITLE###'] = $current_month->format($conf['view.'][$view . '.']['dateFormatMonth']);
 }