Пример #1
0
 public function newDrawWeek(&$master_array, $getdate)
 {
     if (!isset($getdate) || $getdate == '') {
         $getdate = new \TYPO3\CMS\Cal\Model\CalDate();
     } else {
         $getdate = new \TYPO3\CMS\Cal\Model\CalDate($getdate);
     }
     $week = $getdate->getWeekOfYear();
     $year = $getdate->year;
     if ($getdate->month == 12 && $week == 1) {
         $year++;
     }
     $weekModel = new \TYPO3\CMS\Cal\View\NewWeekView($week, $year);
     $today = new \TYPO3\CMS\Cal\Model\CalDate();
     $weekModel->setCurrent($today);
     $weekModel->setSelected($getdate);
     $weekdayLength = intval($this->conf['view.']['month.']['weekdayLength' . ucwords($type) . 'Month']);
     if ($weekdayLength > 0) {
         $weekModel->weekDayLength = $weekdayLength;
     }
     $masterArrayKeys = array_keys($master_array);
     foreach ($masterArrayKeys as $dateKey) {
         $dateArray =& $master_array[$dateKey];
         $dateArrayKeys = array_keys($dateArray);
         foreach ($dateArrayKeys as $timeKey) {
             $arrayOfEvents =& $dateArray[$timeKey];
             $eventKeys = array_keys($arrayOfEvents);
             foreach ($eventKeys as $eventKey) {
                 $weekModel->addEvent($arrayOfEvents[$eventKey]);
             }
         }
     }
     $subpart = $this->cObj->fileResource($this->conf['view.']['week.']['newWeekTemplate']);
     $page = $this->cObj->fileResource($this->conf['view.']['week.']['weekTemplate']);
     $page = str_replace('###WEEK###', $weekModel->render($subpart), $page);
     $rems = array();
     return $this->finish($page, $rems);
 }
Пример #2
0
 function processObjects(&$master_array, &$sims, &$rems)
 {
     /* Subtract strtotimeOffset because we're going from GMT back to local time */
     if ($this->reverse) {
         $GLOBALS['TSFE']->register['cal_list_starttime'] = $this->endtime->getTime();
         $GLOBALS['TSFE']->register['cal_list_endtime'] = $this->starttime->getTime();
     } else {
         $GLOBALS['TSFE']->register['cal_list_starttime'] = $this->starttime->getTime();
         $GLOBALS['TSFE']->register['cal_list_endtime'] = $this->endtime->getTime();
     }
     // clear the register
     $GLOBALS['TSFE']->register['cal_list_firstevent'] = 0;
     $GLOBALS['TSFE']->register['cal_list_lastevent'] = 0;
     $GLOBALS['TSFE']->register['cal_list_events_total'] = 0;
     $GLOBALS['TSFE']->register['cal_list_eventcounter'] = 0;
     $GLOBALS['TSFE']->register['cal_list_days_total'] = 0;
     $sectionMenu = '';
     // only proceed if the master_array is not empty
     if (count($master_array)) {
         $this->count = 0;
         $this->eventCounter = array();
         $this->listStartOffsetCounter = 0;
         $this->listStartOffset = intval($this->conf['view.']['list.']['listStartOffset']);
         if ($this->conf['view.']['list.']['pageBrowser.']['usePageBrowser']) {
             $this->offset = intval($this->controller->piVars[$this->pointerName]);
             $this->recordsPerPage = intval($this->conf['view.']['list.']['pageBrowser.']['recordsPerPage']);
         }
         $this->walkThroughMasterArray($master_array, $this->reverse, $firstEventDate);
         if ($firstEventDate) {
             $GLOBALS['TSFE']->register['cal_list_firstevent'] = $firstEventDate->getTime();
         }
         if ($this->count) {
             $GLOBALS['TSFE']->register['cal_list_events_total'] = $this->count;
             // reference the array with all event counts in the TYPO3 register for usage from within hooks or whatever
             $GLOBALS['TSFE']->register['cal_list_eventcounter'] =& $this->eventCounter;
         }
         if ($days = count($this->objectsInList)) {
             $GLOBALS['TSFE']->register['cal_list_days_total'] = $days;
         }
         // start rendering the events
         if (count($this->objectsInList) && $this->count > 0) {
             $times = array_keys($this->objectsInList);
             // preset vars
             $firstTime = true;
             $listItemCount = 0;
             $alternationCount = 0;
             $pageItemCount = $this->recordsPerPage * $this->offset;
             // don't assign these dates in one line like "$date1 = $date2 = $date3 = new CalDate()", as this will make all dates references to each other!!!
             $lastEventDay = new \TYPO3\CMS\Cal\Model\CalDate('000000001000000');
             $lastEventWeek = new \TYPO3\CMS\Cal\Model\CalDate('000000001000000');
             $lastEventMonth = new \TYPO3\CMS\Cal\Model\CalDate('000000001000000');
             $lastEventYear = new \TYPO3\CMS\Cal\Model\CalDate('000000001000000');
             $categoryGroupArray = array();
             $categoryArray = array();
             if ($this->conf['view.']['list.']['enableCategoryWrapper']) {
                 $allCategoryArray = $this->modelObj->findAllCategories('', '', $this->conf['pidList']);
                 $categoryArray = (array) $allCategoryArray['tx_cal_category'][0][0];
             }
             $calendarGroupArray = array();
             $calendarArray = array();
             if ($this->conf['view.']['list.']['enableCalendarWrapper']) {
                 $allCalendarArray = $this->modelObj->findAllCalendar('', $this->conf['pidList']);
                 $calendarArray = (array) $allCalendarArray['tx_cal_calendar'];
             }
             // prepare alternating layouts
             $alternatingLayoutConfig = $this->conf['view.']['list.']['alternatingLayoutMarkers.'];
             if (is_array($alternatingLayoutConfig) && count($alternatingLayoutConfig)) {
                 $alternatingLayouts = array();
                 $layout_keys = array_keys($alternatingLayoutConfig);
                 foreach ($layout_keys as $key) {
                     if (substr($key, strlen($key) - 1) != '.') {
                         $suffix = $this->cObj->stdWrap($alternatingLayoutConfig[$key], $alternatingLayoutConfig[$key . '.']);
                         if ($suffix) {
                             $alternatingLayouts[] = $suffix;
                         }
                     }
                 }
             } else {
                 $alternatingLayouts = array('LIST_ODD', 'LIST_EVEN');
             }
             // Hook: get hook objects for drawList
             $hookObjectsArr = \TYPO3\CMS\Cal\Utility\Functions::getHookObjectsArray('tx_cal_listview', 'drawList', 'view');
             if ($this->reverse) {
                 arsort($times);
             } else {
                 asort($times);
             }
             foreach ($times as $cal_time) {
                 $e_keys = array_keys($this->objectsInList[$cal_time]);
                 // Hook: postSort
                 if (count($hookObjectsArr)) {
                     // use referenced hook objects, so that hook objects can store variables among different hook calls internally and don't have to mess with globals or registers
                     $hookObjectKeys = array_keys($hookObjectsArr);
                     foreach ($hookObjectKeys as $hookObjKey) {
                         $hookObj =& $hookObjectsArr[$hookObjKey];
                         if (method_exists($hookObj, 'postSort')) {
                             $hookObj->postSort($this, $e_keys, $cal_time);
                         }
                     }
                 }
                 unset($calTimeObject);
                 $calTimeObject = new \TYPO3\CMS\Cal\Model\CalDate($cal_time . '000000');
                 $calTimeObject->setTZbyId('UTC');
                 $cal_day = $calTimeObject->getDay();
                 $cal_month = $calTimeObject->getMonth();
                 $cal_year = $calTimeObject->getYear();
                 $cal_week = $calTimeObject->getWeekOfYear();
                 if (count($hookObjectsArr)) {
                     $hookParams = array('cal_day' => &$cal_day, 'cal_month' => &$cal_month, 'cal_year' => &$cal_year, 'cal_week' => &$cal_week, 'alternationCount' => &$alternationCount, 'reverse' => $this->reverse);
                 }
                 if ($firstTime) {
                     $yearItemCounter = (int) $this->eventCounter['byYear'][$cal_year]['previousPages'];
                     $monthItemCounter = (int) $this->eventCounter['byYearMonth'][$cal_year][$cal_month]['previousPages'];
                     $weekItemCounter = (int) $this->eventCounter['byWeek'][$cal_week]['previousPages'];
                     $dayItemCounter = (int) $this->eventCounter['byDate'][$cal_year][$cal_month][$cal_day]['previousPages'];
                 }
                 foreach ($e_keys as $e_key) {
                     $event =& $this->objectsInList[$cal_time][$e_key];
                     if ($firstTime) {
                         $eventStart = $event->getStart();
                         $lastEventDay->copy($eventStart);
                         $lastEventMonth->copy($eventStart);
                         $lastEventWeek->copy($eventStart);
                         $lastEventYear->copy($eventStart);
                     }
                     // Hook: preInnerEventWrapper
                     if (count($hookObjectsArr)) {
                         // use referenced hook objects, so that hook objects can store variables among different hook calls internally and don't have to mess with globals or registers
                         $hookObjectKeys = array_keys($hookObjectsArr);
                         foreach ($hookObjectKeys as $hookObjKey) {
                             $hookObj =& $hookObjectsArr[$hookObjKey];
                             if (method_exists($hookObj, 'preInnerEventWrapper')) {
                                 $hookObj->preInnerEventWrapper($this, $middle, $event, $calTimeObject, $firstTime, $hookParams);
                             }
                         }
                     }
                     // yearwrapper
                     if ($this->conf['view.']['list.']['enableYearWrapper'] && ($this->hasPeriodChanged($lastEventYear->getYear(), $cal_year, $this->reverse) || $firstTime)) {
                         $this->initLocalCObject();
                         if ($this->conf['view.']['list.']['enableSectionMenu']) {
                             $this->local_cObj->setCurrentVal($calTimeObject->format($this->conf['view.']['list.']['yearSectionMenuFormat']));
                             $this->local_cObj->data['link_parameter'] = '#' . $calTimeObject->format('%Y');
                             $sectionMenu .= $this->local_cObj->cObjGetSingle($this->conf['view.']['list.']['sectionMenuItem'], $this->conf['view.']['list.']['sectionMenuItem.']);
                         }
                         $this->local_cObj->setCurrentVal($calTimeObject->format($this->conf['view.']['list.']['yearWrapperFormat']));
                         if (!$firstTime) {
                             $middle .= $this->local_cObj->cObjGetSingle($this->conf['view.']['list.']['yearWrapperEnd'], $this->conf['view.']['list.']['yearWrapperEnd.']);
                         }
                         $middle .= $this->local_cObj->cObjGetSingle($this->conf['view.']['list.']['yearWrapper'], $this->conf['view.']['list.']['yearWrapper.']);
                         $lastEventYear->copy($calTimeObject);
                         if ($this->conf['view.']['list.']['restartAlternationAfterYearWrapper']) {
                             $alternationCount = 0;
                         }
                         if (!$firstTime) {
                             $yearItemCounter = 0;
                         }
                     }
                     // monthwrapper
                     if ($this->conf['view.']['list.']['enableMonthWrapper'] && ($this->hasPeriodChanged($lastEventMonth->format('%Y%m'), $calTimeObject->format('%Y%m'), $this->reverse) || $firstTime || $this->hasPeriodChanged($lastEventMonth->getYear(), $cal_year, $this->reverse))) {
                         $this->initLocalCObject();
                         if ($this->conf['view.']['list.']['enableSectionMenu']) {
                             $this->local_cObj->setCurrentVal($calTimeObject->format($this->conf['view.']['list.']['monthSectionMenuFormat']));
                             $this->local_cObj->data['link_parameter'] = '#' . $calTimeObject->format('%Y%m');
                             $sectionMenu .= $this->local_cObj->cObjGetSingle($this->conf['view.']['list.']['sectionMenuItem'], $this->conf['view.']['list.']['sectionMenuItem.']);
                         }
                         $this->local_cObj->setCurrentVal($calTimeObject->format($this->conf['view.']['list.']['monthWrapperFormat']));
                         if (!$firstTime) {
                             $middle .= $this->local_cObj->cObjGetSingle($this->conf['view.']['list.']['monthWrapperEnd'], $this->conf['view.']['list.']['monthWrapperEnd.']);
                         }
                         $middle .= $this->local_cObj->cObjGetSingle($this->conf['view.']['list.']['monthWrapper'], $this->conf['view.']['list.']['monthWrapper.']);
                         $lastEventMonth->copy($calTimeObject);
                         if ($this->conf['view.']['list.']['restartAlternationAfterMonthWrapper']) {
                             $alternationCount = 0;
                         }
                         if (!$firstTime) {
                             $monthItemCounter = 0;
                         }
                     }
                     // weekwrapper
                     if ($this->conf['view.']['list.']['enableWeekWrapper'] && ($this->hasPeriodChanged($lastEventWeek->getWeekOfYear(), $cal_week, $this->reverse) || $firstTime || $this->hasPeriodChanged($lastEventWeek->getYear(), $cal_year, $this->reverse))) {
                         $this->initLocalCObject();
                         if ($this->conf['view.']['list.']['enableSectionMenu']) {
                             $this->local_cObj->setCurrentVal($calTimeObject->format($this->conf['view.']['list.']['weekSectionMenuFormat']));
                             $this->local_cObj->data['link_parameter'] = '#' . $calTimeObject->format('%Y%U');
                             $sectionMenu .= $this->local_cObj->cObjGetSingle($this->conf['view.']['list.']['sectionMenuItem'], $this->conf['view.']['list.']['sectionMenuItem.']);
                         }
                         $this->local_cObj->setCurrentVal($calTimeObject->format($this->conf['view.']['list.']['weekWrapperFormat']));
                         if (!$firstTime) {
                             $middle .= $this->local_cObj->cObjGetSingle($this->conf['view.']['list.']['weekWrapperEnd'], $this->conf['view.']['list.']['weekWrapperEnd.']);
                         }
                         $middle .= $this->local_cObj->cObjGetSingle($this->conf['view.']['list.']['weekWrapper'], $this->conf['view.']['list.']['weekWrapper.']);
                         $lastEventWeek->copy($calTimeObject);
                         if ($this->conf['view.']['list.']['restartAlternationAfterWeekWrapper']) {
                             $alternationCount = 0;
                         }
                         if (!$firstTime) {
                             $weekItemCounter = 0;
                         }
                     }
                     // daywrapper
                     if ($this->conf['view.']['list.']['enableDayWrapper'] && (($this->reverse ? $lastEventDay->after($calTimeObject) : $lastEventDay->before($calTimeObject)) || $firstTime || $this->hasPeriodChanged($lastEventDay->getYear(), $cal_year, $this->reverse))) {
                         $this->initLocalCObject();
                         if ($this->conf['view.']['list.']['enableSectionMenu']) {
                             $this->local_cObj->setCurrentVal($calTimeObject->format($this->conf['view.']['list.']['daySectionMenuFormat']));
                             $this->local_cObj->data['link_parameter'] = '#' . $calTimeObject->format('%Y%m%d');
                             $sectionMenu .= $this->local_cObj->cObjGetSingle($this->conf['view.']['list.']['sectionMenuItem'], $this->conf['view.']['list.']['sectionMenuItem.']);
                         }
                         $this->local_cObj->setCurrentVal($calTimeObject->format($this->conf['view.']['list.']['dayWrapperFormat']));
                         if (!$firstTime) {
                             $middle .= $this->local_cObj->cObjGetSingle($this->conf['view.']['list.']['dayWrapperEnd'], $this->conf['view.']['list.']['dayWrapperEnd.']);
                         }
                         $middle .= $this->local_cObj->cObjGetSingle($this->conf['view.']['list.']['dayWrapper'], $this->conf['view.']['list.']['dayWrapper.']);
                         $lastEventDay->copy($calTimeObject);
                         if ($this->conf['view.']['list.']['restartAlternationAfterDayWrapper']) {
                             $alternationCount = 0;
                         }
                         if (!$firstTime) {
                             $dayItemCounter = 0;
                         }
                     }
                     // Hook: postInnerEventWrapper
                     if (count($hookObjectsArr)) {
                         // use referenced hook objects, so that hook objects can store variables among different hook calls internally and don't have to mess with globals or registers
                         $hookObjectKeys = array_keys($hookObjectsArr);
                         foreach ($hookObjectKeys as $hookObjKey) {
                             $hookObj =& $hookObjectsArr[$hookObjKey];
                             if (method_exists($hookObj, 'postInnerEventWrapper')) {
                                 $hookObj->postInnerEventWrapper($this, $middle, $event, $calTimeObject, $firstTime, $hookParams);
                             }
                         }
                     }
                     $listItemCount++;
                     $monthItemCounter++;
                     $weekItemCounter++;
                     $dayItemCounter++;
                     $yearItemCounter++;
                     $totalListCount = $listItemCount + $pageItemCount;
                     $GLOBALS['TSFE']->register['cal_event_list_num'] = $listItemCount;
                     $GLOBALS['TSFE']->register['cal_event_list_num_total'] = $totalListCount;
                     $GLOBALS['TSFE']->register['cal_event_list_num_in_day'] = $dayItemCounter;
                     $GLOBALS['TSFE']->register['cal_event_list_num_in_week'] = $weekItemCounter;
                     $GLOBALS['TSFE']->register['cal_event_list_num_in_month'] = $monthItemCounter;
                     $GLOBALS['TSFE']->register['cal_event_list_num_in_year'] = $yearItemCounter;
                     $layoutNum = $alternationCount % count($alternatingLayouts);
                     $layoutSuffix = $alternatingLayouts[$layoutNum];
                     $eventText = '';
                     if ($this->conf['view'] == 'location' || $this->conf['view'] == 'organizer' || $this->conf['view'] == 'event') {
                         $eventText = $event->renderEventForList(strtoupper($this->conf['view']) . '_' . $layoutSuffix);
                     } else {
                         $eventText = $event->renderEventForList($layoutSuffix);
                     }
                     $allowFurtherGrouping = true;
                     // Hook: prepareOuterEventWrapper
                     if (count($hookObjectsArr)) {
                         // use referenced hook objects, so that hook objects can store variables among different hook calls internally and don't have to mess with globals or registers
                         $hookObjectKeys = array_keys($hookObjectsArr);
                         foreach ($hookObjectKeys as $hookObjKey) {
                             $hookObj =& $hookObjectsArr[$hookObjKey];
                             if (method_exists($hookObj, 'prepareOuterEventWrapper')) {
                                 $hookObj->prepareOuterEventWrapper($this, $middle, $event, $calTimeObject, $firstTime, $hookParams, $allowFurtherGrouping);
                             }
                         }
                     }
                     if ($allowFurtherGrouping) {
                         if ($this->conf['view.']['list.']['enableCategoryWrapper']) {
                             $ids = $event->getCategoryUidsAsArray();
                             if (empty($ids)) {
                                 $categoryGroupArray[$this->conf['view.']['list.']['noCategoryWrapper.']['uid']] .= $eventText;
                             } else {
                                 $rememberUid = array();
                                 foreach ($categoryArray as $categoryObject) {
                                     if (!in_array($categoryObject->getUid(), $rememberUid)) {
                                         if (in_array($categoryObject->getUid(), $ids)) {
                                             $categoryGroupArray[$categoryObject->getUid()] .= $eventText;
                                         }
                                         $rememberUid[] = $categoryObject->getUid();
                                     }
                                 }
                             }
                         } else {
                             if ($this->conf['view.']['list.']['enableCalendarWrapper']) {
                                 $id = $event->getCalendarUid();
                                 foreach ($calendarArray as $calendarObject) {
                                     if ($calendarObject->getUid() == $id) {
                                         $calendarGroupArray[$calendarObject->getTitle()] .= $eventText;
                                     }
                                 }
                             } else {
                                 $middle .= $eventText;
                             }
                         }
                     }
                     $alternationCount++;
                     $firstTime = false;
                 }
             }
             $allowFurtherGrouping = true;
             // Hook: applyOuterEventWrapper
             if (count($hookObjectsArr)) {
                 // use referenced hook objects, so that hook objects can store variables among different hook calls internally and don't have to mess with globals or registers
                 $hookObjectKeys = array_keys($hookObjectsArr);
                 foreach ($hookObjectKeys as $hookObjKey) {
                     $hookObj =& $hookObjectsArr[$hookObjKey];
                     if (method_exists($hookObj, 'applyOuterEventWrapper')) {
                         $hookObj->applyOuterEventWrapper($this, $middle, $event, $allowFurtherGrouping);
                     }
                 }
             }
             if ($allowFurtherGrouping) {
                 // additional Wrapper
                 if ($this->conf['view.']['list.']['enableCalendarWrapper']) {
                     $this->initLocalCObject();
                     foreach ($calendarGroupArray as $calTitel => $calendarEntries) {
                         $this->local_cObj->setCurrentVal($calTitel);
                         $middle .= $this->local_cObj->cObjGetSingle($this->conf['view.']['list.']['calendarWrapper'], $this->conf['view.']['list.']['calendarWrapper.']);
                         $middle .= $calendarEntries;
                     }
                 }
                 if ($this->conf['view.']['list.']['enableCategoryWrapper']) {
                     $keys = array_keys($categoryGroupArray);
                     sort($keys);
                     foreach ($keys as $categoryId) {
                         if ($categoryId == $this->conf['view.']['list.']['noCategoryWrapper.']['uid']) {
                             $this->initLocalCObject();
                             $middle .= $this->local_cObj->cObjGetSingle($this->conf['view.']['list.']['noCategoryWrapper'], $this->conf['view.']['list.']['noCategoryWrapper.']);
                         } else {
                             $currentCategory =& $categoryArray[$categoryId];
                             $this->initLocalCObject($currentCategory->getValuesAsArray());
                             $this->local_cObj->setCurrentVal($currentCategory->getTitle());
                             $text = $this->local_cObj->cObjGetSingle($this->conf['view.']['list.']['categoryWrapper.']['10'], $this->conf['view.']['list.']['categoryWrapper.']['10.']);
                             $middle .= str_replace('###CATEGORY_STYLE###', $currentCategory->getHeaderStyle(), $text);
                         }
                         $middle .= $categoryGroupArray[$categoryId];
                     }
                 }
             }
         }
     }
     return $middle;
 }
Пример #3
0
 /**
  * Returns a array with fields/parameters that can be used for link rendering in typoscript.
  * It's based on the link functions from \TYPO3\CMS\Frontend\Plugin\AbstractPlugin.
  *
  * @param
  *        	array			Referenced array in which the parameters get merged into
  * @param
  *        	array			Array with parameter=>value pairs of piVars that should override present piVars
  * @param
  *        	boolean		Flag that indicates if the linktarget is allowed to be cached (takes care of cacheHash and no_cache parameter)
  * @param
  *        	boolean		Flag that's clearing all present piVars, thus only piVars defined in $overrulePIvars are kept
  * @param
  *        	integer		Alternative ID of a page that should be used as link target. If empty or 0, current page is used
  * @return nothing
  *
  */
 public function getParametersForTyposcriptLink(&$parameterArray, $overrulePIvars = array(), $cache = false, $clearAnyway = false, $altPageId = 0)
 {
     // copied from function 'pi_linkTP_keepPIvars'
     if (is_array($this->piVars) && is_array($overrulePIvars) && !$clearAnyway) {
         $piVars = $this->piVars;
         unset($piVars['DATA']);
         if (\TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) < '6002000') {
             $piVars = GeneralUtility::array_merge_recursive_overrule($piVars, $overrulePIvars);
         } else {
             \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($piVars, $overrulePIvars);
         }
         $overrulePIvars = $piVars;
         if ($this->pi_autoCacheEn) {
             $cache = $this->pi_autoCache($overrulePIvars);
         }
     }
     $piVars = array($this->prefixId => $overrulePIvars);
     /* TEST */
     if ($piVars[$this->prefixId]['getdate']) {
         $date = new \TYPO3\CMS\Cal\Model\CalDate($piVars[$this->prefixId]['getdate']);
         $sessionVars = array();
         switch ($piVars[$this->prefixId]['view']) {
             case 'week':
                 $piVars[$this->prefixId]['year'] = $date->getYear();
                 $piVars[$this->prefixId]['week'] = $date->getWeekOfYear();
                 $piVars[$this->prefixId]['weekday'] = $date->getDayOfWeek();
                 $sessionVars['month'] = substr($piVars[$this->prefixId]['getdate'], 4, 2);
                 $sessionVars['day'] = substr($piVars[$this->prefixId]['getdate'], 6, 2);
                 if ($date->getMonth() == 12 && $piVars[$this->prefixId]['week'] == 1) {
                     $piVars[$this->prefixId]['year']++;
                 }
                 unset($piVars[$this->prefixId]['view']);
                 unset($piVars[$this->prefixId]['getdate']);
                 break;
             case 'event':
             case 'todo':
                 $piVars[$this->prefixId]['year'] = substr($piVars[$this->prefixId]['getdate'], 0, 4);
                 $piVars[$this->prefixId]['month'] = substr($piVars[$this->prefixId]['getdate'], 4, 2);
                 $piVars[$this->prefixId]['day'] = substr($piVars[$this->prefixId]['getdate'], 6, 2);
                 unset($piVars[$this->prefixId]['getdate']);
                 break;
             case 'day':
                 $piVars[$this->prefixId]['year'] = substr($piVars[$this->prefixId]['getdate'], 0, 4);
                 $piVars[$this->prefixId]['month'] = substr($piVars[$this->prefixId]['getdate'], 4, 2);
                 $piVars[$this->prefixId]['day'] = substr($piVars[$this->prefixId]['getdate'], 6, 2);
             case 'month':
                 $piVars[$this->prefixId]['year'] = substr($piVars[$this->prefixId]['getdate'], 0, 4);
                 $piVars[$this->prefixId]['month'] = substr($piVars[$this->prefixId]['getdate'], 4, 2);
                 $sessionVars['day'] = substr($piVars[$this->prefixId]['getdate'], 6, 2);
             case 'year':
                 $piVars[$this->prefixId]['year'] = substr($piVars[$this->prefixId]['getdate'], 0, 4);
                 $sessionVars['month'] = substr($piVars[$this->prefixId]['getdate'], 4, 2);
                 $sessionVars['day'] = substr($piVars[$this->prefixId]['getdate'], 6, 2);
                 unset($piVars[$this->prefixId]['view']);
                 unset($piVars[$this->prefixId]['getdate']);
         }
         foreach ($sessionVars as $key => $value) {
             //$_SESSION[$this->prefixId][$key] = $value;
         }
     }
     /* TEST */
     // use internal method for cleaning up piVars
     $this->cleanupUrlParameter($piVars);
     // copied and modified logic of function 'pi_linkTP'
     # once useCacheHash property in typolinks has stdWrap, we can use this flag - until then it's unfortunately useless :(
     #$parameterArray['link_useCacheHash'] = $this->pi_USER_INT_obj ? 0 : $cache;
     $parameterArray['link_no_cache'] = $this->pi_USER_INT_obj ? 0 : !$cache;
     $parameterArray['link_parameter'] = $altPageId ? $altPageId : ($this->pi_tmpPageId ? $this->pi_tmpPageId : $GLOBALS['TSFE']->id);
     $parameterArray['link_additionalParams'] = $this->conf['parent.']['addParams'] . GeneralUtility::implodeArrayForUrl('', $piVars, '', true) . $this->pi_moreParams;
     $parameterArray['link_ATagParams'] = 'class="url"';
     # add time/date related parameters to all link objects, so that they can use them e.g. to display the monthname etc.
     $parameterArray['getdate'] = $this->conf['getdate'];
     if ($overrulePIvars['getdate'] && is_object($date)) {
         $parameterArray['link_timestamp'] = $date->getTime();
         $parameterArray['link_getdate'] = $overrulePIvars['getdate'];
     }
 }
Пример #4
0
 public static function getDayByWeek($year, $week, $weekday)
 {
     $date = new \TYPO3\CMS\Cal\Model\CalDate($year . '0101');
     $date->setTZbyID('UTC');
     $offset = $weekday - $date->format('%w');
     // correct weekday
     $date->addSeconds($offset * 86400);
     $oldYearWeek = $date->getWeekOfYear() > 1 ? '0' : '1';
     // correct week
     $date->addSeconds(($week - $oldYearWeek) * 7 * 86400);
     return $date->format('%Y%m%d');
 }
Пример #5
0
 public function addEvent(&$event)
 {
     $eventStart = new \TYPO3\CMS\Cal\Model\CalDate();
     $eventStart->copy($event->getStart());
     $eventStartFormatted = $eventStart->format('%Y%m%d');
     $eventStartYear = $eventStart->year;
     $eventEndFormatted = $event->getEnd()->format('%Y%m%d');
     $eventEndYear = $event->getEnd()->year;
     $eventStartWeek = $event->getStart()->getWeekOfYear();
     $eventEndWeek = $event->getEnd()->getWeekOfYear();
     if (($eventStartWeek == 52 || $eventStartWeek == 53) && $event->getStart()->month == 1) {
         $eventStartYear--;
     }
     if (($eventEndWeek == 52 || $eventEndWeek == 53) && $event->getEnd()->month == 1) {
         $eventEndYear--;
     }
     if ($eventStartWeek == 1 && $event->getStart()->month == 12) {
         $eventStartYear++;
     }
     if ($eventEndWeek == 1 && $event->getEnd()->month == 12) {
         $eventEndYear++;
     }
     if ($event->isAllday() || $eventStartFormatted != $eventEndFormatted) {
         $eventYearEnd = $event->getEnd()->year;
         if ($event->getEnd()->month == 12 && $event->getEnd()->getWeekOfYear() == 1) {
             $eventYearEnd++;
         }
         if (!($eventStartYear == $this->year && $eventStart->getWeekOfYear() == $this->week) && $eventStart->year . sprintf("%02d", $eventStart->getWeekOfYear()) < $this->year . sprintf("%02d", $this->week) && $eventYearEnd . sprintf("%02d", $event->getEnd()->getWeekOfYear()) >= $this->year . sprintf("%02d", $this->week)) {
             do {
                 $eventStart->addSeconds(86400);
                 $eventStartYear = $eventStart->year;
                 $eventWeek = $eventStart->getWeekOfYear();
                 if ($eventStart->month == 1 && $eventWeek > 50) {
                     $eventStartYear--;
                 }
             } while ($eventStartYear . sprintf("%02d", $eventWeek) < $this->year . sprintf("%02d", $this->week));
             $eventStartFormatted = $eventStart->format('%Y%m%d');
         }
         if ($eventStartYear == $this->year && $eventStart->getWeekOfYear() == $this->week) {
             $this->alldays[$eventStartFormatted][] = $event;
             $this->weekHasEvent = true;
             $first = true;
             do {
                 $this->dayHasEvent[$eventStart->getDayOfWeek()] = true;
                 if (is_object($this->days[$eventStart->format('%Y%m%d')])) {
                     $this->days[$eventStart->format('%Y%m%d')]->hasAlldayEvents = true;
                     if ($first) {
                         $this->days[$eventStart->format('%Y%m%d')]->addEvent($event);
                         $first = false;
                     }
                 }
                 $eventStart->addSeconds(86400);
                 $eventStartYear = $eventStart->year;
                 $eventWeek = $eventStart->getWeekOfYear();
                 if ($eventStart->month == 1 && $eventWeek > 50) {
                     $eventStartYear--;
                 }
             } while ($eventStart->format('%Y%m%d') <= $eventEndFormatted && $eventStartYear . sprintf("%02d", $eventStart->getWeekOfYear()) <= $this->year . sprintf("%02d", $this->week));
         }
     } else {
         do {
             if ($eventStartYear == $this->year && $eventStartWeek == $this->week) {
                 $this->dayHasEvent[$eventStart->getDayOfWeek()] = true;
                 if (is_object($this->days[$eventStart->format('%Y%m%d')])) {
                     $this->days[$eventStart->format('%Y%m%d')]->addEvent($event);
                 }
                 $this->weekHasEvent = true;
             }
             $eventStart->addSeconds(86400);
             $eventStartYear = $eventStart->year;
             if ($eventStart->month == 1 && $eventWeek > 50) {
                 $eventStartYear--;
             }
             $eventStartWeek = $eventStart->getWeekOfYear();
         } while ($eventStart->format('%Y%m%d') <= $eventEndFormatted && $eventStartWeek <= $this->week);
     }
 }