Пример #1
0
 private function generateWeeks()
 {
     $date = new \TYPO3\CMS\Cal\Model\CalDate();
     $date->setDay(1);
     $date->setMonth($this->month);
     $date->setYear($this->year);
     $this->monthStartWeekdayNum = $date->format('%w');
     $this->monthLength = $date->getDaysInMonth();
     $monthEnd = \TYPO3\CMS\Cal\Controller\Calendar::calculateEndMonthTime($date);
     $weekEnd = $monthEnd->getWeekOfYear();
     $newDate = \TYPO3\CMS\Cal\Controller\Calendar::calculateStartWeekTime($date);
     $this->weeks = array();
     $weekNumber = $newDate->getWeekOfYear();
     if ($this->month == 12 && $weekEnd == 1) {
         do {
             if ($weekNumber == $weekEnd) {
                 $this->weeks[$newDate->getYear() + 1 . '_' . $weekNumber] = new \TYPO3\CMS\Cal\View\NewWeekView($weekNumber, $newDate->getYear() + 1, $this->month);
             } else {
                 $this->weeks[$newDate->getYear() . '_' . $weekNumber] = new \TYPO3\CMS\Cal\View\NewWeekView($weekNumber, $newDate->getYear(), $this->month);
             }
             $newDate->addSeconds(86400 * 7);
             $weekNumber = $newDate->getWeekOfYear();
             $weekNumberTmp = $weekNumber;
             if ($weekNumber != $weekEnd) {
                 $weekNumberTmp = 0;
             }
         } while ($weekNumberTmp <= $weekEnd && $newDate->year == $this->year);
     } else {
         if ($this->month == 1) {
             do {
                 if ($weekNumber > 6) {
                     $this->weeks[$newDate->getYear() . '_' . $weekNumber] = new \TYPO3\CMS\Cal\View\NewWeekView($weekNumber, $newDate->getYear(), $this->month);
                 } else {
                     $this->weeks[$this->year . '_' . $weekNumber] = new \TYPO3\CMS\Cal\View\NewWeekView($weekNumber, $this->year, $this->month);
                 }
                 $newDate->addSeconds(86400 * 7);
                 $weekNumber = $newDate->getWeekOfYear();
             } while ($weekNumber <= $weekEnd && $newDate->year == $this->year);
         } else {
             do {
                 $this->weeks[$this->year . '_' . $weekNumber] = new \TYPO3\CMS\Cal\View\NewWeekView($weekNumber, $newDate->getYear(), $this->month);
                 $newDate->addSeconds(86400 * 7);
                 $weekNumber = $newDate->getWeekOfYear();
             } while ($weekNumber <= $weekEnd && $newDate->getYear() == $this->year);
         }
     }
     $this->maxWeeksInYear = max($this->maxWeeksInYear, $weekNumber);
 }
Пример #2
0
 function _parseString($value)
 {
     $value = strtolower($value);
     switch ($value) {
         case 'last':
             array_push($this->stack, array('range' => 'last'));
             break;
         case 'next':
             array_push($this->stack, array('range' => 'next'));
             break;
         case 'now':
             array_push($this->stack, array('abs' => $this->timeObj->getTime()));
             break;
         case 'today':
             array_push($this->stack, array('today' => $this->timeObj->getTime()));
             break;
         case 'current':
             array_push($this->stack, array('today' => $this->timeObj->getTime()));
             break;
         case 'tomorrow':
             array_push($this->stack, array('tomorrow' => $this->timeObj->getTime()));
             break;
         case 'yesterday':
             array_push($this->stack, array('yesterday' => $this->timeObj->getTime()));
             break;
         case 'yearstart':
             array_push($this->stack, array('date' => \TYPO3\CMS\Cal\Controller\Calendar::calculateStartYearTime($this->timeObj)));
             break;
         case 'monthstart':
             array_push($this->stack, array('date' => \TYPO3\CMS\Cal\Controller\Calendar::calculateStartMonthTime($this->timeObj)));
             break;
         case 'weekstart':
             array_push($this->stack, array('date' => \TYPO3\CMS\Cal\Controller\Calendar::calculateStartWeekTime($this->timeObj)));
             break;
         case 'weekend':
             array_push($this->stack, array('date' => \TYPO3\CMS\Cal\Controller\Calendar::calculateEndWeekTime($this->timeObj)));
             break;
         case 'monthend':
             array_push($this->stack, array('date' => \TYPO3\CMS\Cal\Controller\Calendar::calculateEndMonthTime($this->timeObj)));
             break;
         case 'yearend':
             array_push($this->stack, array('date' => \TYPO3\CMS\Cal\Controller\Calendar::calculateEndYearTime($this->timeObj)));
             break;
         case 'quarterstart':
             $timeObj = $this->timeObj;
             $startMonth = '01';
             switch ($timeObj->getQuarterOfYear()) {
                 case 2:
                     $startMonth = '04';
                     break;
                 case 3:
                     $startMonth = '07';
                     break;
                 case 4:
                     $startMonth = '10';
                     break;
             }
             $timeObj->setDay(1);
             $timeObj->setMonth($startMonth);
             $timeObj->setHour(0);
             $timeObj->setMinute(0);
             $timeObj->setSecond(0);
             array_push($this->stack, array('date' => $timeObj));
             break;
         case 'quarterend':
             $timeObj = $this->timeObj;
             $endDay = '31';
             $endMonth = '03';
             switch ($timeObj->getQuarterOfYear()) {
                 case 2:
                     $endDay = '30';
                     $endMonth = '06';
                     break;
                 case 3:
                     $endDay = '30';
                     $endMonth = '09';
                     break;
                 case 4:
                     $endDay = '31';
                     $endMonth = '12';
                     break;
             }
             $timeObj->setDay($endDay);
             $timeObj->setMonth($endMonth);
             $timeObj->setHour(23);
             $timeObj->setMinute(59);
             $timeObj->setSecond(59);
             array_push($this->stack, array('date' => $timeObj));
             break;
         case 'day':
         case 'days':
             array_push($this->stack, array('value' => 86400));
             break;
         case 'week':
         case 'weeks':
             array_push($this->stack, array('value' => 604800));
             break;
         case 'h':
         case 'hour':
         case 'hours':
             $value = array_pop(array_pop($this->stack));
             array_push($this->stack, array('range' => $value));
             array_push($this->stack, array('value' => 'hour'));
             break;
         case 'm':
         case 'minute':
         case 'minutes':
             $value = array_pop(array_pop($this->stack));
             array_push($this->stack, array('range' => $value));
             array_push($this->stack, array('value' => 'minute'));
             break;
         case 'month':
         case 'months':
             array_push($this->stack, array('value' => 'month'));
             break;
         case 'year':
         case 'years':
             array_push($this->stack, array('value' => 'year'));
             break;
         case 'mon':
         case 'monday':
             array_push($this->stack, array('weekday' => 1));
             break;
         case 'tue':
         case 'tuesday':
             array_push($this->stack, array('weekday' => 2));
             break;
         case 'wed':
         case 'wednesday':
             array_push($this->stack, array('weekday' => 3));
             break;
         case 'thu':
         case 'thursday':
             array_push($this->stack, array('weekday' => 4));
             break;
         case 'fri':
         case 'friday':
             array_push($this->stack, array('weekday' => 5));
             break;
         case 'sat':
         case 'saturday':
             array_push($this->stack, array('weekday' => 6));
             break;
         case 'sun':
         case 'sunday':
             array_push($this->stack, array('weekday' => 0));
             break;
         case 'jan':
         case 'january':
             array_push($this->stack, array('month' => 1));
             break;
         case 'feb':
         case 'february':
             array_push($this->stack, array('month' => 2));
             break;
         case 'mar':
         case 'march':
             array_push($this->stack, array('month' => 3));
             break;
         case 'apr':
         case 'april':
             array_push($this->stack, array('month' => 4));
             break;
         case 'may':
             array_push($this->stack, array('month' => 5));
             break;
         case 'jun':
         case 'june':
             array_push($this->stack, array('month' => 6));
             break;
         case 'jul':
         case 'july':
             array_push($this->stack, array('month' => 7));
             break;
         case 'aug':
         case 'august':
             array_push($this->stack, array('month' => 8));
             break;
         case 'sep':
         case 'september':
             array_push($this->stack, array('month' => 9));
             break;
         case 'oct':
         case 'october':
             array_push($this->stack, array('month' => 10));
             break;
         case 'nov':
         case 'november':
             array_push($this->stack, array('month' => 11));
             break;
         case 'dec':
         case 'december':
             array_push($this->stack, array('month' => 12));
             break;
         default:
             break;
     }
 }
Пример #3
0
 function getListMarker(&$page, &$sims, &$rems, &$wrapped)
 {
     $rems['###LIST###'] = '';
     $starttime = new \TYPO3\CMS\Cal\Model\CalDate($this->conf['getdate'] . '000000');
     $starttime->setTZbyId('UTC');
     $tx_cal_listview = GeneralUtility::makeInstanceService('cal_view', 'list', 'list');
     // set alternate rendering view, so that the rendering of the attached listView can be customized
     $tempAlternateRenderingView = $tx_cal_listview->conf['alternateRenderingView'];
     $renderingView = $this->conf['view.'][$this->conf['view'] . '.']['useListEventRenderSettingsView'];
     $tx_cal_listview->conf['alternateRenderingView'] = $renderingView ? $renderingView : 'list';
     $listSubpart = $this->cObj->getSubpart($page, '###LIST###');
     if ($this->conf['view'] == 'month' && $this->conf['view.']['month.']['showListInMonthView']) {
         $starttime = \TYPO3\CMS\Cal\Controller\Calendar::calculateStartMonthTime($starttime);
         $endtime = \TYPO3\CMS\Cal\Controller\Calendar::calculateEndMonthTime($starttime);
         $rems['###LIST###'] = $tx_cal_listview->drawList($this->master_array, $listSubpart, $starttime, $endtime);
     } else {
         if ($this->conf['view'] == 'day') {
             $starttime = \TYPO3\CMS\Cal\Controller\Calendar::calculateStartDayTime($starttime);
             $endtime = \TYPO3\CMS\Cal\Controller\Calendar::calculateEndDayTime($starttime);
             $rems['###LIST###'] = $tx_cal_listview->drawList($this->master_array, $listSubpart, $starttime, $endtime);
         } else {
             if ($this->conf['view'] == 'week') {
                 $starttime = \TYPO3\CMS\Cal\Controller\Calendar::calculateStartWeekTime($starttime);
                 $endtime = \TYPO3\CMS\Cal\Controller\Calendar::calculateEndWeekTime($starttime);
                 $rems['###LIST###'] = $tx_cal_listview->drawList($this->master_array, $listSubpart, $starttime, $endtime);
             } else {
                 if ($this->conf['view'] == 'year') {
                     $starttime = \TYPO3\CMS\Cal\Controller\Calendar::calculateStartYearTime($starttime);
                     $endtime = \TYPO3\CMS\Cal\Controller\Calendar::calculateEndYearTime($starttime);
                     $rems['###LIST###'] = $tx_cal_listview->drawList($this->master_array, $listSubpart, $starttime, $endtime);
                 }
             }
         }
     }
     $tx_cal_listview->conf['alternateRenderingView'] = $tempAlternateRenderingView;
 }
Пример #4
0
 function findTodosForMonth(&$dateObject, $type = '', $pidList = '', $eventType = '4')
 {
     $starttime = \TYPO3\CMS\Cal\Controller\Calendar::calculateStartMonthTime($dateObject);
     $endtime = \TYPO3\CMS\Cal\Controller\Calendar::calculateEndMonthTime($dateObject);
     return $this->findAllWithin('cal_event_model', $starttime, $endtime, $type, $this->todoSubtype, $pidList, $eventType);
 }
Пример #5
0
 function getMonthDaysAccordingly(&$event, $month, $year)
 {
     $byDayArray = $event->getByDay();
     $byMonthDays = $event->getByMonthDay();
     $resultDays = array();
     if (count($byDayArray) == 0) {
         $resultDays = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31);
         return $resultDays;
     }
     for ($i = 0; $i < count($byDayArray); $i++) {
         if (preg_match('/([-\\+]{0,1})?([0-9]{1})?([A-Z]{2})/', $byDayArray[$i], $byDaySplit)) {
             $dayOfWeekday = \TYPO3\CMS\Cal\Controller\Calendar::two2threeCharDays($byDaySplit[3], false);
             $monthStartTime = new \TYPO3\CMS\Cal\Model\CalDate($year . '-' . sprintf("%02d", $month) . '-01 00:00:00');
             $monthStartTime->setTZbyId('UTC');
             $monthEndTime = \TYPO3\CMS\Cal\Controller\Calendar::calculateEndMonthTime($monthStartTime);
             if ($byDaySplit[2] > 0) {
                 if ($byDaySplit[1] == '-') {
                     $monthTime = new \TYPO3\CMS\Cal\Model\CalDate(Calc::prevDayOfWeek($dayOfWeekday, $monthEndTime->getDay(), $monthEndTime->getMonth(), $monthEndTime->getYear(), '%Y%m%d', true));
                     $monthTime->setTZbyId('UTC');
                     $monthTime->subtractSeconds(($byDaySplit[2] - 1) * 604800);
                 } else {
                     $monthTime = new \TYPO3\CMS\Cal\Model\CalDate(Calc::nextDayOfWeek($dayOfWeekday, $monthStartTime->getDay(), $monthStartTime->getMonth(), $monthStartTime->getYear(), '%Y%m%d', true));
                     $monthTime->setTZbyId('UTC');
                     $monthTime->addSeconds(($byDaySplit[2] - 1) * 604800);
                 }
                 if ($monthTime->getMonth() == $month && in_array($monthTime->getDay(), $byMonthDays)) {
                     $resultDays[] = $monthTime->getDay();
                 }
             } else {
                 $monthTime = new \TYPO3\CMS\Cal\Model\CalDate(Calc::prevDayOfWeek($dayOfWeekday, $monthStartTime->getDay(), $monthStartTime->getMonth(), $monthStartTime->getYear(), '%Y%m%d', true));
                 $monthTime->setTZbyId('UTC');
                 if ($monthTime->before($monthStartTime)) {
                     $monthTime->addSeconds(604800);
                 }
                 while ($monthTime->before($monthEndTime)) {
                     $resultDays[] = $monthTime->getDay();
                     $monthTime->addSeconds(604800);
                 }
             }
         }
     }
     $resultDays = array_intersect($resultDays, $event->getByMonthDay());
     sort($resultDays);
     return $resultDays;
 }