Пример #1
0
 function getDateObjectFromStack()
 {
     $date = new \TYPO3\CMS\Cal\Model\CalDate();
     $date->setTZbyId('UTC');
     $date->copy($this->timeObj);
     $lastKey = '';
     $post = array();
     $foundMonth = false;
     $range = '';
     $rangeValue = '';
     while (!empty($this->stack)) {
         $valueArray = array_shift($this->stack);
         foreach ($valueArray as $key => $value) {
             switch ($key) {
                 case 'year':
                     if (strlen($value) == 8) {
                         $date->setYear(intval(substr($value, 0, 4)));
                         $date->setMonth(intval(substr($value, 4, 2)));
                         $date->setDay(intval(substr($value, 6, 2)));
                     } else {
                         $date->setYear($value);
                     }
                     $date->setMinute(0);
                     $date->setSecond(0);
                     $date->setHour(0);
                     break;
                 case 'month':
                     $date->setMonth($value);
                     $date->setMinute(0);
                     $date->setSecond(0);
                     $date->setHour(0);
                     $foundMonth = true;
                     break;
                 case 'day':
                     $date->setDay($value);
                     $date->setMinute(0);
                     $date->setSecond(0);
                     $date->setHour(0);
                     break;
                 case 'week':
                     $date->setMinute(0);
                     $date->setSecond(0);
                     $date->setHour(0);
                     $date->addSeconds($value);
                     break;
                 case 'hour':
                     $date->setDay(0);
                     $date->setMinute(0);
                     $date->setSecond(0);
                     $date->setHour($value);
                     break;
                 case 'minute':
                     $date->setDay(0);
                     $date->setMinute($value);
                     $date->setSecond(0);
                     $date->setHour(0);
                     break;
                 case '?':
                     if ($lastKey == 'month') {
                         $date->setDay($value);
                         $date->setMinute(0);
                         $date->setSecond(0);
                         $date->setHour(0);
                         $key = 'day';
                     } else {
                         if ($lastKey == 'year') {
                             if ($this->conf['USmode']) {
                                 $date->setDay($value);
                                 $date->setMinute(0);
                                 $date->setSecond(0);
                                 $date->setHour(0);
                                 $key = 'day';
                             } else {
                                 $date->setMonth($value);
                                 $date->setMinute(0);
                                 $date->setSecond(0);
                                 $date->setHour(0);
                                 $foundMonth = true;
                                 $key = 'month';
                             }
                         } else {
                             if ($lastKey == 'day') {
                                 $date->setMonth($value);
                                 $date->setMinute(0);
                                 $date->setSecond(0);
                                 $date->setHour(0);
                                 $foundMonth = true;
                                 $key = 'month';
                             } else {
                                 $post[] = $valueArray;
                             }
                         }
                     }
                     break;
                 case 'range':
                     $range = $value;
                     if ($rangeValue) {
                         $this->evaluateRange($date, $range, $rangeValue);
                         // after parsing the rangeValue, clear it so that a new range can start
                         $range = false;
                     }
                     break;
                 case 'value':
                 case 'weekday':
                     $rangeValue = $value;
                     if ($range) {
                         $this->evaluateRange($date, $range, $rangeValue);
                         // after parsing the range, clear it so that a new range can start
                         $rangeValue = false;
                     }
                     break;
                 case 'today':
                     $date->setMinute(0);
                     $date->setSecond(0);
                     $date->setHour(0);
                     break;
                 case 'tomorrow':
                     $date->setMinute(0);
                     $date->setSecond(0);
                     $date->setHour(0);
                     $date->addSeconds(86400);
                     break;
                 case 'yesterday':
                     $date->setMinute(0);
                     $date->setSecond(0);
                     $date->setHour(0);
                     $date->subtractSeconds(86400);
                     break;
                 case 'date':
                     $date->copy($value);
                 default:
                     $post[] = $valueArray;
                     break;
             }
             $lastKey = $key;
         }
     }
     while (!empty($post)) {
         $valueArray = array_pop($post);
         foreach ($valueArray as $key => $value) {
             switch ($key) {
                 case '?':
                     if ($foundMonth) {
                         $date->setDay($value);
                     } else {
                         if ($this->conf['USmode']) {
                             $date->setDay($value);
                         } else {
                             $date->setMonth($value);
                             $foundMonth = true;
                         }
                     }
                     break;
             }
         }
     }
     return $date;
 }
Пример #2
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;
 }
Пример #3
0
 /**
  *
  * @param
  *        	array	iCalendar component array
  * @return array
  */
 function insertCalEventsIntoDB($iCalendarComponentArray = array(), $calId, $pid = '', $cruserId = '', $isTemp = 1, $deleteNotUsedCategories = true)
 {
     $insertedOrUpdatedEventUids = array();
     $insertedOrUpdatedCategoryUids = array();
     if (empty($iCalendarComponentArray)) {
         return $insertedOrUpdatedEventUids;
     }
     $offsetArray = array();
     foreach ($iCalendarComponentArray as $component) {
         $table = 'tx_cal_event';
         $insertFields = array();
         $insertFields['isTemp'] = $isTemp;
         $insertFields['tstamp'] = time();
         $insertFields['crdate'] = time();
         $insertFields['pid'] = $pid;
         if (is_a($component, '\\TYPO3\\CMS\\Cal\\Model\\ICalendar\\vevent')) {
             $insertFields['cruser_id'] = $cruserId;
             $insertFields['calendar_id'] = $calId;
             if ($component->getAttribute('DTSTART')) {
                 $startdate = $component->getAttribute('DTSTART');
                 if (is_array($startdate)) {
                     $dateTime = new \TYPO3\CMS\Cal\Model\CalDate($startdate['year'] . $startdate['month'] . $startdate['mday'] . '000000');
                 } else {
                     $dateTime = new \TYPO3\CMS\Cal\Model\CalDate($startdate);
                 }
                 $params = $component->getAttributeParameters('DTSTART');
                 $timezone = $params['TZID'];
                 if ($timezone) {
                     $dateTime->convertTZbyID($timezone);
                 }
                 $insertFields['start_date'] = $dateTime->format('%Y%m%d');
                 $insertFields['start_time'] = $dateTime->hour * 3600 + $dateTime->minute * 60;
             } else {
                 continue;
             }
             if ($component->getAttribute('DTEND')) {
                 $enddate = $component->getAttribute('DTEND');
                 if (is_array($enddate)) {
                     $dateTime = new \TYPO3\CMS\Cal\Model\CalDate($enddate['year'] . $enddate['month'] . $enddate['mday'] . '000000');
                 } else {
                     $dateTime = new \TYPO3\CMS\Cal\Model\CalDate($enddate);
                 }
                 $params = $component->getAttributeParameters('DTEND');
                 $timezone = $params['TZID'];
                 if ($timezone) {
                     $dateTime->convertTZbyID($timezone);
                 }
                 $insertFields['end_date'] = $dateTime->format('%Y%m%d');
                 $insertFields['end_time'] = $dateTime->hour * 3600 + $dateTime->minute * 60;
             }
             if ($component->getAttribute('DURATION')) {
                 $enddate = $insertFields['start_time'] + $component->getAttribute('DURATION');
                 $dateTime = new \TYPO3\CMS\Cal\Model\CalDate($insertFields['start_date']);
                 $dateTime->addSeconds($enddate);
                 $params = $component->getAttributeParameters('DURATION');
                 $timezone = $params['TZID'];
                 if ($timezone) {
                     $dateTime->convertTZbyID($timezone);
                 }
                 $insertFields['end_date'] = $dateTime->format('%Y%m%d');
                 $insertFields['end_time'] = $dateTime->hour * 3600 + $dateTime->minute * 60;
             }
             $insertFields['icsUid'] = $component->getAttribute('UID');
             $insertFields['title'] = $component->getAttribute('SUMMARY');
             if ($component->organizerName()) {
                 $insertFields['organizer'] = str_replace('"', '', $component->organizerName());
             }
             $insertFields['location'] = $component->getAttribute('LOCATION');
             if ($insertFields['location'] == null) {
                 $insertFields['location'] = '';
             }
             $insertFields['description'] = $component->getAttribute('DESCRIPTION');
             $categoryString = $component->getAttribute('CATEGORY');
             if ($categoryString == "") {
                 $categoryString = $component->getAttribute('CATEGORIES');
             }
             $categories = GeneralUtility::trimExplode(',', $categoryString, 1);
             $categoryUids = array();
             foreach ($categories as $category) {
                 $category = trim($category);
                 $categorySelect = '*';
                 $categoryTable = 'tx_cal_category';
                 $categoryWhere = 'calendar_id = ' . intval($calId) . ' AND title =' . $GLOBALS['TYPO3_DB']->fullQuoteStr($category, $categoryTable);
                 $foundCategory = false;
                 $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery($categorySelect, $categoryTable, $categoryWhere);
                 if ($result) {
                     while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
                         $foundCategory = true;
                         $categoryUids[] = $row['uid'];
                     }
                     $GLOBALS['TYPO3_DB']->sql_free_result($result);
                 }
                 if (!$foundCategory) {
                     $result = $GLOBALS['TYPO3_DB']->exec_INSERTquery($categoryTable, array('tstamp' => $insertFields['tstamp'], 'crdate' => $insertFields['crdate'], 'pid' => $pid, 'title' => $category, 'calendar_id' => $calId));
                     if (FALSE === $result) {
                         throw new \RuntimeException('Could not write ' . $categoryTable . ' record to database: ' . $GLOBALS['TYPO3_DB']->sql_error(), 1431458143);
                     }
                     $categoryUids[] = $GLOBALS['TYPO3_DB']->sql_insert_id();
                 }
             }
             if ($component->getAttribute('RRULE')) {
                 $rrule = $component->getAttribute('RRULE');
                 $this->insertRuleValues($rrule, $insertFields);
             }
             if ($component->getAttribute('RDATE')) {
                 $rdate = $component->getAttribute('RDATE');
                 if (is_array($rdate)) {
                     $insertFields['rdate'] = implode(',', $rdate);
                 } else {
                     $insertFields['rdate'] = $rdate;
                 }
                 if ($component->getAttributeParameters('RDATE')) {
                     $parameterArray = $component->getAttributeParameters('RDATE');
                     $keys = array_keys($parameterArray);
                     $insertFields['rdate_type'] = strtolower($keys[0]);
                 } else {
                     $insertFields['rdate_type'] = 'date_time';
                 }
             }
             // Fix for allday events
             if ($insertFields['start_time'] == 0 && $insertFields['end_time'] == 0) {
                 $date = new \TYPO3\CMS\Cal\Model\CalDate($insertFields['end_date'] . '000000');
                 $date->setTZbyId('UTC');
                 $date->subtractSeconds(86400);
                 $insertFields['end_date'] = $date->format('%Y%m%d');
             }
             $eventRow = BackendUtility::getRecordRaw('tx_cal_event', 'icsUid="' . $insertFields['icsUid'] . '"');
             if ($eventRow['uid']) {
                 $result = $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . $eventRow['uid'], $insertFields);
                 $eventUid = $eventRow['uid'];
             } else {
                 $result = $GLOBALS['TYPO3_DB']->exec_INSERTquery($table, $insertFields);
                 if (FALSE === $result) {
                     throw new \RuntimeException('Could not write ' . $table . ' record to database: ' . $GLOBALS['TYPO3_DB']->sql_error(), 1431458144);
                 }
                 $eventUid = $GLOBALS['TYPO3_DB']->sql_insert_id();
             }
             $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['cal']);
             if ($component->getAttribute('RECURRENCE-ID')) {
                 $recurrenceIdStart = new \TYPO3\CMS\Cal\Model\CalDate($component->getAttribute('RECURRENCE-ID'));
                 $params = $component->getAttributeParameters('RECURRENCE-ID');
                 $timezone = $params['TZID'];
                 if ($timezone) {
                     $recurrenceIdStart->convertTZbyID($timezone);
                 }
                 $indexEntry = BackendUtility::getRecordRaw('tx_cal_index', 'event_uid="' . $eventUid . '" AND start_datetime="' . $recurrenceIdStart->format('%Y%m%d%H%M%S') . '"');
                 if ($indexEntry) {
                     $origStartDate = new \TYPO3\CMS\Cal\Model\CalDate();
                     $origStartDate = new \TYPO3\CMS\Cal\Model\CalDate();
                     $table = 'tx_cal_event_deviation';
                     $insertFields['parentid'] = $eventUid;
                     $insertFields['orig_start_time'] = $recurrenceIdStart->getHour() * 3600 + $recurrenceIdStart->getMinute() * 60;
                     $recurrenceIdStart->setHour(0);
                     $recurrenceIdStart->setMinute(0);
                     $recurrenceIdStart->setSecond(0);
                     $insertFields['orig_start_date'] = $recurrenceIdStart->getTime();
                     unset($insertFields['calendar_id']);
                     if ($indexEntry['event_deviation_uid'] > 0) {
                         $result = $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . $indexEntry['event_deviation_uid'], $insertFields);
                         $eventDeviationUid = $indexEntry['event_deviation_uid'];
                     } else {
                         $result = $GLOBALS['TYPO3_DB']->exec_INSERTquery($table, $insertFields);
                         if (FALSE === $result) {
                             throw new \RuntimeException('Could not write ' . $table . ' record to database: ' . $GLOBALS['TYPO3_DB']->sql_error(), 1431458145);
                         }
                         $eventDeviationUid = $GLOBALS['TYPO3_DB']->sql_insert_id();
                     }
                     $GLOBALS['TYPO3_DB']->exec_UPDATEquery('tx_cal_index', 'uid=' . $indexEntry['uid'], array('event_deviation_uid' => $eventDeviationUid));
                 }
             } else {
                 /* Delete the old exception relations */
                 $exceptionEventUidsToBeDeleted = array();
                 $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_cal_exception_event.uid', 'tx_cal_exception_event,tx_cal_exception_event_mm', 'tx_cal_exception_event.uid = tx_cal_exception_event_mm.uid_foreign AND tx_cal_exception_event_mm.uid_local=' . $eventUid);
                 if ($result) {
                     while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
                         $exceptionEventUidsToBeDeleted[] = $row['uid'];
                     }
                     $GLOBALS['TYPO3_DB']->sql_free_result($result);
                 }
                 if (!empty($exceptionEventUidsToBeDeleted)) {
                     $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_cal_exception_event', 'uid in (' . implode(',', $exceptionEventUidsToBeDeleted) . ')');
                 }
                 $exceptionEventGroupUidsToBeDeleted = array();
                 $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('tx_cal_exception_event_group.uid', 'tx_cal_exception_event_group,tx_cal_exception_event_group_mm', 'tx_cal_exception_event_group.uid = tx_cal_exception_event_group_mm.uid_foreign AND tx_cal_exception_event_group_mm.uid_local=' . $eventUid);
                 if ($result) {
                     while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
                         $exceptionEventGroupUidsToBeDeleted[] = $row['uid'];
                     }
                     $GLOBALS['TYPO3_DB']->sql_free_result($result);
                 }
                 if (!empty($exceptionEventGroupUidsToBeDeleted)) {
                     $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_cal_exception_event_group', 'uid in (' . implode(',', $exceptionEventGroupUidsToBeDeleted) . ')');
                 }
                 $where = ' uid_local=' . $eventUid;
                 $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_cal_exception_event_mm', $where);
                 $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_cal_exception_event_group_mm', $where);
                 // Exceptions:
                 if ($component->getAttribute('EXDATE')) {
                     if (is_array($component->getAttribute('EXDATE'))) {
                         foreach ($component->getAttribute('EXDATE') as $exceptionDescription) {
                             $this->createException($pid, $cruserId, $eventUid, $exceptionDescription);
                         }
                     } else {
                         $this->createException($pid, $cruserId, $eventUid, $component->getAttribute('EXDATE'));
                     }
                 }
                 if ($component->getAttribute('EXRULE')) {
                     if (is_array($component->getAttribute('EXRULE'))) {
                         foreach ($component->getAttribute('EXRULE') as $exceptionDescription) {
                             $this->createExceptionRule($pid, $cruserId, $eventUid, $exceptionDescription);
                         }
                     } else {
                         $this->createExceptionRule($pid, $cruserId, $eventUid, $component->getAttribute('EXRULE'));
                     }
                 }
                 $pageTSConf = BackendUtility::getPagesTSconfig($pid);
                 if ($pageTSConf['options.']['tx_cal_controller.']['pageIDForPlugin']) {
                     $pageIDForPlugin = $pageTSConf['options.']['tx_cal_controller.']['pageIDForPlugin'];
                 } else {
                     $pageIDForPlugin = $pid;
                 }
                 /** @var \TYPO3\CMS\Cal\Utility\RecurrenceGenerator $rgc */
                 $rgc = GeneralUtility::makeInstance('TYPO3\\CMS\\Cal\\Utility\\RecurrenceGenerator', $pageIDForPlugin);
                 $rgc->generateIndexForUid($eventUid, 'tx_cal_event');
                 if ($this->conf['view.']['event.']['remind']) {
                     /* Schedule reminders for new and changed events */
                     $pageTSConf = BackendUtility::getPagesTSconfig($pid);
                     $offset = is_numeric($pageTSConf['options.']['tx_cal_controller.']['view.']['event.']['remind.']['time']) ? $pageTSConf['options.']['tx_cal_controller.']['view.']['event.']['remind.']['time'] * 60 : 0;
                     $date = new \TYPO3\CMS\Cal\Model\CalDate($insertFields['start_date'] . '000000');
                     $date->setTZbyId('UTC');
                     $reminderTimestamp = $date->getTime() + $insertFields['start_time'] - $offset;
                     $reminderService =& \TYPO3\CMS\Cal\Utility\Functions::getReminderService();
                     $reminderService->scheduleReminder($eventUid);
                 }
                 /* Delete the old category relations */
                 $where = ' uid_local=' . $eventUid;
                 $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_cal_event_category_mm', $where);
                 foreach ($categoryUids as $uid) {
                     $result = $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_cal_event_category_mm', array('uid_local' => $eventUid, 'uid_foreign' => $uid));
                     if (FALSE === $result) {
                         throw new \RuntimeException('Could not write tx_cal_event_category_mm record to database: ' . $GLOBALS['TYPO3_DB']->sql_error(), 1431458146);
                     }
                 }
                 $insertedOrUpdatedEventUids[] = $eventUid;
                 $insertedOrUpdatedCategoryUids = array_merge($insertedOrUpdatedCategoryUids, $categoryUids);
                 // Hook: insertCalEventsIntoDB
                 $hookObjectsArr = \TYPO3\CMS\Cal\Utility\Functions::getHookObjectsArray('tx_cal_icalendar_service', 'iCalendarServiceClass', 'service');
                 foreach ($hookObjectsArr as $hookObj) {
                     if (method_exists($hookObj, 'insertCalEventsIntoDB')) {
                         $hookObj->insertCalEventsIntoDB($this, $eventUid, $component);
                     }
                 }
             }
         }
     }
     if ($deleteNotUsedCategories) {
         /* Delete the categories */
         $where = ' calendar_id=' . $calId;
         if (!empty($insertedOrUpdatedCategoryUids)) {
             array_unique($insertedOrUpdatedCategoryUids);
             $where .= ' AND uid NOT IN (' . implode(',', $insertedOrUpdatedCategoryUids) . ')';
         }
         $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['cal']);
         $GLOBALS['TYPO3_DB']->exec_DELETEquery($extConf['categoryService'], $where);
     }
     return $insertedOrUpdatedEventUids;
 }
Пример #4
0
 function getToday()
 {
     $today = new \TYPO3\CMS\Cal\Model\CalDate();
     $today->setTZbyId('UTC');
     $today->setHour(0);
     $today->setMinute(0);
     $today->setSecond(0);
     return $today;
 }
Пример #5
0
 function getRecurringEventsFromIndex($event, $ex_event_dates = array())
 {
     $maxRecurringEvents = (int) $this->conf['view.'][$this->conf['view'] . '.']['maxRecurringEvents'];
     $maxRecurringEvents = !empty($maxRecurringEvents) ? $maxRecurringEvents : 99999;
     $master_array = array();
     $startDate = $event->getStart();
     $dontShowOldEvents = (int) $this->conf['view.'][$this->conf['view'] . '.']['dontShowOldEvents'];
     if ($dontShowOldEvents > 0) {
         $now = new \TYPO3\CMS\Cal\Model\CalDate();
         if ($dontShowOldEvents == 2) {
             $now->setHour(0);
             $now->setMinute(0);
             $now->setSecond(0);
         }
         if ($startDate->getTime() > $now->getTime() && !$ex_event_dates[$startDate->format('%Y%m%d')]) {
             $master_array[$startDate->format('%Y%m%d')][$event->isAllday() ? '-1' : $startDate->format('%H%M')][$event->getUid()] =& $event;
         }
     } else {
         if (!$ex_event_dates[$startDate->format('%Y%m%d')] && !$event->getStart()->after($this->endtime) && !$event->getEnd()->before($this->starttime)) {
             $master_array[$startDate->format('%Y%m%d')][$event->isAllday() ? '-1' : $startDate->format('%H%M')][$event->getUid()] =& $event;
         }
     }
     $added = 0;
     // if the 'parent' event is still in future, set $added to 1, because we already have one instance of this event
     $now = new \TYPO3\CMS\Cal\Model\CalDate();
     if (intval($now->format('%Y%m%d%H%M%S')) < intval($event->getStart()->format('%Y%m%d%H%M%S'))) {
         $added = 1;
     }
     $select = '*';
     $table = 'tx_cal_index';
     $where = 'event_uid = ' . $event->getUid() . ' AND start_datetime >= ' . $this->starttime->format('%Y%m%d%H%M%S') . ' AND start_datetime <= ' . $this->endtime->format('%Y%m%d%H%M%S') . ' AND tablename = "' . ($event->getType() == 'tx_cal_phpicalendar' ? $event->isException ? 'tx_cal_exception_event' : 'tx_cal_event' : $event->getType()) . '"';
     $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where, '', 'start_datetime');
     if ($result) {
         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
             if ($added < $maxRecurringEvents) {
                 $nextOccuranceTime = new \TYPO3\CMS\Cal\Model\CalDate($row['start_datetime']);
                 $nextOccuranceEndTime = new \TYPO3\CMS\Cal\Model\CalDate($row['end_datetime']);
                 $new_event = null;
                 if ($row['event_deviation_uid'] > 0) {
                     $result2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'tx_cal_event_deviation', 'uid=' . $row['event_deviation_uid'] . $this->cObj->enableFields('tx_cal_event_deviation'));
                     if ($result2) {
                         while ($row2 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result2)) {
                             $new_event = new \TYPO3\CMS\Cal\Model\EventRecDeviationModel($event, $row2, $nextOccuranceTime, $nextOccuranceEndTime);
                         }
                     }
                 } else {
                     $new_event = new \TYPO3\CMS\Cal\Model\EventRecModel($event, $nextOccuranceTime, $nextOccuranceEndTime);
                 }
                 if (!$ex_event_dates[$new_event->getStart()->format('%Y%m%d')]) {
                     if ($new_event->isAllday()) {
                         $master_array[$nextOccuranceTime->format('%Y%m%d')]['-1'][$event->getUid()] = $new_event;
                     } else {
                         $master_array[$nextOccuranceTime->format('%Y%m%d')][$nextOccuranceTime->format('%H%M')][$event->getUid()] = $new_event;
                     }
                     $added++;
                 }
             }
         }
         $GLOBALS['TYPO3_DB']->sql_free_result($result);
     }
     return $master_array;
 }
Пример #6
0
 public function findAllWithin(&$start_date, &$end_date, $pidList, $eventType = '0,1,2,3', $additionalWhere = '')
 {
     // How to get the events
     // 1st get Calendar specified
     // 2nd get categories specified
     // 3rd get all related events
     // make an array out of the list, so we can handle it better
     $includeRecurring = true;
     if ($this->conf['view'] == 'ics' || $this->conf['view'] == 'single_ics') {
         $includeRecurring = false;
     }
     $this->setStartAndEndPoint($start_date, $end_date);
     $dontShowOldEvents = (int) $this->conf['view.'][$this->conf['view'] . '.']['dontShowOldEvents'];
     if ($dontShowOldEvents > 0) {
         $now = new \TYPO3\CMS\Cal\Model\CalDate();
         if ($dontShowOldEvents == 2) {
             $now->setHour(0);
             $now->setMinute(0);
             $now->setSecond(0);
         }
         if ($start_date->getTime() <= $now->getTime()) {
             $start_date->copy($now);
         }
         if ($end_date->getTime() <= $now->getTime()) {
             $end_date->copy($now);
             $end_date->addSeconds(86400);
         }
         $this->starttime->copy($start_date);
         $this->endtime->copy($end_date);
     }
     $formattedStarttime = $this->starttime->format('%Y%m%d');
     $formattedEndtime = $this->endtime->format('%Y%m%d');
     $calendarService =& $this->modelObj->getServiceObjByKey('cal_calendar_model', 'calendar', 'tx_cal_calendar');
     $categoryService =& $this->modelObj->getServiceObjByKey('cal_category_model', 'category', $this->extConf['categoryService']);
     $calendarSearchString = $this->getFreeAndBusyCalendarSearchString($pidList, true, $this->conf['calendar'] ? $this->conf['calendar'] : '');
     $recurringClause = '';
     // only include the recurring clause if we don't use the new recurring model or a view not needing recurring events.
     if ($includeRecurring) {
         // get the uids of recurring events from index
         $select = 'event_uid';
         $table = 'tx_cal_index';
         $where = 'start_datetime >= ' . $this->starttime->format('%Y%m%d%H%M%S') . ' AND start_datetime <= ' . $this->endtime->format('%Y%m%d%H%M%S');
         $group = 'event_uid';
         $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where, $group);
         $tmpUids = array();
         if ($result) {
             while ($tmp = $GLOBALS['TYPO3_DB']->sql_fetch_row($result)) {
                 $tmpUids[] = $tmp[0];
             }
             $GLOBALS['TYPO3_DB']->sql_free_result($result);
         }
         if (count($tmpUids)) {
             $recurringClause = ' OR (tx_cal_event.uid IN (' . implode(',', $tmpUids) . ')) ';
         }
     }
     // putting everything together
     // Franz: added simple check/include for rdate events at the end of this where clause.
     // But we need to find a way to only include rdate events within the searched timerange
     // - otherwise we'll flood the results after some time. I think we need a mm-table for that!
     $additionalWhere = $calendarSearchString . ' AND tx_cal_event.pid IN (' . $pidList . ') ' . $this->cObj->enableFields('tx_cal_event') . ' AND ((tx_cal_event.start_date>=' . $formattedStarttime . ' AND tx_cal_event.start_date<=' . $formattedEndtime . ') OR (tx_cal_event.end_date<=' . $formattedEndtime . ' AND tx_cal_event.end_date>=' . $formattedStarttime . ') OR (tx_cal_event.end_date>=' . $formattedEndtime . ' AND tx_cal_event.start_date<=' . $formattedStarttime . ')' . $recurringClause . ')' . $additionalWhere;
     // $additionalWhere = $calendarSearchString.' AND tx_cal_event.pid IN ('.$pidList.') '.$this->cObj->enableFields('tx_cal_event').' AND ((tx_cal_event.start_date>='.$formattedEndtime.' OR tx_cal_event.end_date>='.$formattedStarttime.')' . $recurringClause . ')'.$additionalWhere;
     // creating the arrays the user is allowed to see
     $categories = array();
     $categoryService->getCategoryArray($pidList, $categories);
     // creating events
     return $this->getEventsFromTable($categories[0][0], $includeRecurring, $additionalWhere, $this->getServiceKey(), true, false, $eventType);
 }
Пример #7
0
 /**
  * 
  * @return string
  */
 public function searchEvent()
 {
     $type = $this->conf['type'];
     $pidList = $this->conf['pidList'];
     $hookObjectsArr = $this->getHookObjectsArray('drawSearchClass');
     $start_day = $this->piVars['start_day'];
     $end_day = $this->piVars['end_day'];
     $searchword = preg_replace('/["\']/', '', strip_tags($this->piVars['query']));
     $this->piVars['query'] = $searchword;
     if (!$start_day) {
         $start_day = $this->getListViewTime($this->conf['view.']['search.']['defaultValues.']['start_day']);
         $start_day = \TYPO3\CMS\Cal\Controller\Calendar::calculateStartDayTime($start_day);
     } else {
         $start_day = new \TYPO3\CMS\Cal\Model\CalDate(\TYPO3\CMS\Cal\Utility\Functions::getYmdFromDateString($this->conf, $start_day) . '000000');
         $start_day->setHour(0);
         $start_day->setMinute(0);
         $start_day->setSecond(0);
         $start_day->setTZbyId('UTC');
     }
     if (!$end_day) {
         $end_day = $this->getListViewTime($this->conf['view.']['search.']['defaultValues.']['end_day']);
         $end_day = \TYPO3\CMS\Cal\Controller\Calendar::calculateEndDayTime($end_day);
     } else {
         $end_day = new \TYPO3\CMS\Cal\Model\CalDate(\TYPO3\CMS\Cal\Utility\Functions::getYmdFromDateString($this->conf, $end_day) . '000000');
         $end_day->setHour(23);
         $end_day->setMinute(59);
         $end_day->setSecond(59);
         $end_day->setTZbyId('UTC');
     }
     if ($this->piVars['single_date']) {
         $start_day = new \TYPO3\CMS\Cal\Model\CalDate(\TYPO3\CMS\Cal\Utility\Functions::getYmdFromDateString($this->conf, $this->piVars['single_date']));
         $start_day->setHour(0);
         $start_day->setMinute(0);
         $start_day->setSecond(0);
         $start_day->setTZbyId('UTC');
         $end_day = new \TYPO3\CMS\Cal\Model\CalDate();
         $end_day->copy($start_day);
         $end_day->addSeconds(86399);
     }
     $minStarttime = new \TYPO3\CMS\Cal\Model\CalDate($this->conf['view.']['search.']['startRange'] . '000000');
     $maxEndtime = new \TYPO3\CMS\Cal\Model\CalDate($this->conf['view.']['search.']['endRange'] . '000000');
     if ($start_day->before($minStarttime)) {
         $start_day->copy($minStarttime);
     }
     if ($start_day->after($maxEndtime)) {
         $start_day->copy($maxEndtime);
     }
     if ($end_day->before($minStarttime)) {
         $end_day->copy($minStarttime);
     }
     if ($end_day->after($maxEndtime)) {
         $end_day->copy($maxEndtime);
     }
     if ($end_day->before($start_day)) {
         $end_day->copy($start_day);
     }
     $locationIds = strip_tags(Controller::convertLinkVarArrayToList($this->piVars['location_ids']));
     $organizerIds = strip_tags(Controller::convertLinkVarArrayToList($this->piVars['organizer_ids']));
     $this->getDateTimeObject->copy($start_day);
     $modelObj =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'modelcontroller');
     $list = array();
     if ($this->piVars['submit'] || !$this->conf['view.']['search.']['startSearchAfterSubmit']) {
         $list = $modelObj->searchEvents($type, $pidList, $start_day, $end_day, $searchword, $locationIds, $organizerIds);
     }
     // Hook: preSearchEventRendering
     foreach ($hookObjectsArr as $hookObj) {
         if (method_exists($hookObj, 'preSearchEventRendering')) {
             $hookObj->preSearchEventRendering($list, $this);
         }
     }
     if ($this->conf['view.']['enableAjax']) {
         $ajaxStringArray = array();
         foreach ($list as $event) {
             $ajaxStringArray[] = '{' . $this->getEventAjaxString($event) . '}';
         }
         return '[' . implode(',', $ajaxStringArray) . ']';
     }
     $viewObj =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'viewcontroller');
     $drawnList = $viewObj->drawSearchEventResult($list, $start_day, $end_day, $searchword, $locationIds, $organizerIds);
     // Hook: postSearchEventRendering
     foreach ($hookObjectsArr as $hookObj) {
         if (method_exists($hookObj, 'postSearchEventRendering')) {
             $hookObj->postSearchEventRendering($drawnList, $list, $this);
         }
     }
     return $drawnList;
 }
Пример #8
0
 /**
  * 
  * @param string $dateObject
  * @return \TYPO3\CMS\Cal\Model\CalDate
  */
 public static function calculateEndDayTime($dateObject = '')
 {
     $timeObj = new \TYPO3\CMS\Cal\Model\CalDate();
     $timeObj->setTZbyId('UTC');
     if ($dateObject) {
         $timeObj->copy($dateObject);
     }
     $timeObj->setHour(23);
     $timeObj->setMinute(59);
     $timeObj->setSecond(59);
     return $timeObj;
 }