Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 3
0
 function _draw_month_new($offset = '+0', $type)
 {
     if (preg_match('![+|-][0-9]{1,2}!is', $offset)) {
         // new one
         $monthDate = new \TYPO3\CMS\Cal\Model\CalDate();
         $monthDate->copy($this->controller->getDateTimeObject);
         $monthDate->setDay(15);
         if (intval($offset) < 0) {
             $monthDate->subtractSeconds(abs(intval($offset)) * 2592000);
         } else {
             $monthDate->addSeconds(intval($offset) * 2592000);
         }
     } else {
         $monthDate = new \TYPO3\CMS\Cal\Model\CalDate();
         $monthDate->copy($this->controller->getDateTimeObject);
         $monthDate->setDay(15);
         if (intval($offset) > 12) {
             $monthDate->setYear($monthDate->getYear() + ($offset - $offset % 12) / 12);
             $monthDate->setMonth($offset % 12);
         } else {
             $monthDate->setMonth($offset);
         }
     }
     $page = $this->cObj->fileResource($this->conf['view.']['month.']['new' . ucwords($type) . 'MonthTemplate']);
     $monthModel = \TYPO3\CMS\Cal\View\NewMonthView::getMonth($monthDate->month, $monthDate->year);
     $today = new \TYPO3\CMS\Cal\Model\CalDate();
     $monthModel->setCurrent($today);
     $selected = new \TYPO3\CMS\Cal\Model\CalDate($this->conf['getdate']);
     $monthModel->setSelected($selected);
     $monthModel->weekDayFormat = $this->conf['view.'][$this->conf['view'] . '.']['weekdayFormat' . ucwords($type) . 'Month'];
     $weekdayLength = intval($this->conf['view.'][$this->conf['view'] . '.']['weekdayLength' . ucwords($type) . 'Month']);
     if ($weekdayLength > 0) {
         $monthModel->weekDayLength = $weekdayLength;
     }
     $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) {
                 $monthModel->addEvent($arrayOfEvents[$eventKey]);
             }
         }
     }
     return $monthModel->render($page);
 }
Ejemplo n.º 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;
 }
Ejemplo n.º 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.']);
     }
 }
Ejemplo n.º 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']);
 }