/**
  * Draws a delete form for a location or an organizer.
  * 
  * @param
  *        	boolean True if a location should be deleted
  * @param
  *        	object		The object to be deleted
  * @param
  *        	object		The cObject of the mother-class.
  * @param
  *        	object		The rights object.
  * @return string HTML output.
  */
 public function drawDeleteLocationOrOrganizer($isLocation = true, &$object)
 {
     $page = $this->cObj->fileResource($this->conf['view.']['delete_location.']['template']);
     if ($page == '') {
         return '<h3>category: no delete location template file found:</h3>' . $this->conf['view.']['delete_location.']['template'];
     }
     $this->isLocation = $isLocation;
     $this->object = $object;
     if ($isLocation) {
         $this->objectString = 'location';
     } else {
         $this->objectString = 'organizer';
     }
     $rems = array();
     $sims = array();
     $wrapped = array();
     $sims['###UID###'] = $this->conf['uid'];
     $sims['###TYPE###'] = $this->conf['type'];
     $sims['###VIEW###'] = 'remove_' . $this->objectString;
     $sims['###LASTVIEW###'] = $this->controller->extendLastView();
     $sims['###L_DELETE_LOCATION###'] = $this->controller->pi_getLL('l_delete_' . $this->objectString);
     $sims['###L_DELETE###'] = $this->controller->pi_getLL('l_delete');
     $sims['###L_CANCEL###'] = $this->controller->pi_getLL('l_cancel');
     $sims['###ACTION_URL###'] = htmlspecialchars($this->controller->pi_linkTP_keepPIvars_url(array('view' => 'remove_' . $this->objectString)));
     $this->getTemplateSubpartMarker($page, $sims, $rems, $wrapped);
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, array(), $rems, array());
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, $sims, array(), array());
     $sims = array();
     $rems = array();
     $wrapped = array();
     $this->object->getMarker($page, $sims, $rems, $wrapped);
     return \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, $sims, $rems, $wrapped);
 }
Example #2
0
 /**
  * Draws a delete form for a calendar.
  * 
  * @param
  *        	boolean True if a location should be deleted
  * @param
  *        	object		The object to be deleted
  * @param
  *        	object		The cObject of the mother-class.
  * @param
  *        	object		The rights object.
  * @return string HTML output.
  */
 public function drawDeleteCategory(&$category)
 {
     $page = $this->cObj->fileResource($this->conf['view.']['delete_category.']['template']);
     if ($page == '') {
         return '<h3>category: no delete category template file found:</h3>' . $this->conf['view.']['delete_category.']['template'];
     }
     $this->category = $category;
     $rems = array();
     $sims = array();
     $sims['###UID###'] = $this->conf['uid'];
     $sims['###TYPE###'] = $this->conf['type'];
     $sims['###VIEW###'] = 'remove_category';
     $sims['###LASTVIEW###'] = $this->controller->extendLastView();
     $sims['###L_DELETE_CATEGORY###'] = $this->controller->pi_getLL('l_delete_category');
     $sims['###L_DELETE###'] = $this->controller->pi_getLL('l_delete');
     $sims['###L_CANCEL###'] = $this->controller->pi_getLL('l_cancel');
     $sims['###ACTION_URL###'] = htmlspecialchars($this->controller->pi_linkTP_keepPIvars_url(array('view' => 'remove_category')));
     $this->getTemplateSubpartMarker($page, $sims, $rems);
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, array(), $rems, array());
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, $sims, array(), array());
     $sims = array();
     $rems = array();
     $this->getTemplateSingleMarker($page, $sims, $rems);
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, array(), $rems, array());
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, $sims, array(), array());
     return \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, $sims, array(), array());
 }
Example #3
0
 /**
  * Draws a delete form for a calendar.
  * 
  * @param
  *        	boolean True if a location should be deleted
  * @param
  *        	object		The object to be deleted
  * @param
  *        	object		The cObject of the mother-class.
  * @param
  *        	object		The rights object.
  * @return string HTML output.
  */
 public function drawDeleteCalendar(&$calendar)
 {
     $page = $this->cObj->fileResource($this->conf['view.']['delete_calendar.']['template']);
     if ($page == '') {
         return '<h3>calendar: no confirm calendar template file found:</h3>' . $this->conf['view.']['delete_calendar.']['template'];
     }
     $this->object = $calendar;
     if (!$this->object->isUserAllowedToDelete()) {
         return 'You are not allowed to delete this calendar!';
     }
     $rems = array();
     $sims = array();
     $wrapped = array();
     $sims['###UID###'] = $this->conf['uid'];
     $sims['###TYPE###'] = $this->conf['type'];
     $sims['###VIEW###'] = 'save_event';
     $sims['###LASTVIEW###'] = $this->controller->extendLastView();
     $sims['###L_DELETE_CALENDAR###'] = $this->controller->pi_getLL('l_delete_calendar');
     $sims['###L_DELETE###'] = $this->controller->pi_getLL('l_delete');
     $sims['###L_CANCEL###'] = $this->controller->pi_getLL('l_cancel');
     $sims['###ACTION_URL###'] = htmlspecialchars($this->controller->pi_linkTP_keepPIvars_url(array('view' => 'remove_calendar')));
     $this->getTemplateSubpartMarker($page, $sims, $rems, $wrapped);
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, array(), $rems, $wrapped);
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, $sims, array(), array());
     $sims = array();
     $rems = array();
     $wrapped = array();
     $this->getTemplateSingleMarker($page, $sims, $rems, $wrapped);
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, array(), $rems, $wrapped);
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, $sims, array(), array());
     return \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, $sims, array(), array());
 }
Example #4
0
 /**
  * Main function to draw the meeting manager view.
  * 
  * @return string output of the meeting manager.
  */
 public function drawMeetingManager()
 {
     $rems = array();
     $sims = array();
     $wrapped = array();
     $sims['###HEADING###'] = $this->controller->pi_getLL('l_manage_meeting');
     $sims['###STATUS###'] = '';
     $rems['###USER_LOGIN###'] = '';
     $rems['###MEETING_CONTAINER###'] = '';
     /* Get the meeting manager template */
     $page = $this->cObj->fileResource($this->conf['view.']['event.']['meeting.']['managerTemplate']);
     if ($page == '') {
         return '<h3>calendar: no meeting manager template file found:</h3>' . $this->conf['view.']['meeting.']['managerTemplate'];
     }
     $eventUID = $this->conf['uid'];
     $attendeeUid = intval($this->controller->piVars['attendee']);
     $meetingHash = strip_tags($this->controller->piVars['sid']);
     $attendeeStatus = strip_tags($this->controller->piVars['status']);
     /* If we have an event, email, and meeting id, try to subscribe or unsubscribe */
     if ($eventUID > 0 && $attendeeUid && $attendeeStatus && $meetingHash) {
         $event = $this->modelObj->findEvent($eventUID, 'tx_cal_phpicalendar', $this->conf['pidList'], false, false, false, true, true);
         unset($this->controller->piVars['monitor']);
         unset($this->controller->piVars['attendee']);
         unset($this->controller->piVars['sid']);
         $local_rems = array();
         $local_sims = array();
         $local_wrapped = array();
         $status = $this->cObj->getSubpart($page, '###STATUS###');
         switch ($attendeeStatus) {
             case 'accept':
                 /* user comes to the meeting */
                 if ($this->changeStatus($attendeeUid, $event, $meetingHash, 'ACCEPTED')) {
                     $sims['###STATUS###'] = sprintf($this->controller->pi_getLL('l_meeting_accepted'), $event->getTitle());
                 } else {
                     /* No user to unsubscribe. Output a message here? */
                     $sims['###STATUS###'] = sprintf($this->controller->pi_getLL('l_meeting_update_error'), $event->getTitle());
                 }
                 break;
             case 'decline':
                 /* user does not come to the meeting */
                 if ($this->changeStatus($attendeeUid, $event, $meetingHash, 'DECLINE')) {
                     $status = $this->cObj->getSubpart($page, '###STATUS_START###');
                     $sims['###STATUS###'] = sprintf($this->controller->pi_getLL('l_meeting_declined'), $event->getTitle());
                 } else {
                     /* No user to subscribe. Output a message here? */
                     $sims['###STATUS###'] = sprintf($this->controller->pi_getLL('l_meeting_update_error'), $event->getTitle());
                 }
                 break;
         }
     } else {
         $sims['###STATUS###'] = $this->controller->pi_getLL('l_meeting_error');
     }
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, $sims, $rems, $wrapped);
     $rems = array();
     return $this->finish($page, $rems);
 }
 /**
  * Draws a confirm form for a location or an organizer.
  * 
  * @param
  *        	boolean True if a location should be confirmed
  * @param
  *        	object		The cObject of the mother-class.
  * @param
  *        	object		The rights object.
  * @return string HTML output.
  */
 public function drawConfirmLocationOrOrganizer($isLocation = true)
 {
     $this->isLocation = $isLocation;
     $this->isConfirm = true;
     if ($isLocation) {
         $this->objectString = 'location';
     } else {
         $this->objectString = 'organizer';
     }
     $page = $this->cObj->fileResource($this->conf['view.']['confirm_location.']['template']);
     if ($page == '') {
         return '<h3>calendar: no confirm ' . $this->objectString . ' template file found:</h3>' . $this->conf['view.']['confirm_location.']['template'];
     }
     if ($isLocation) {
         $this->object = new \TYPO3\CMS\Cal\Model\Location(null, '');
     } else {
         $this->object = new \TYPO3\CMS\Cal\Model\Organizer(null, '');
     }
     $this->object->updateWithPIVars($this->controller->piVars);
     $lastViewParams = $this->controller->shortenLastViewAndGetTargetViewParameters();
     if (substr($lastViewParams['view'], 0, 4) == 'edit') {
         $this->isEditMode = true;
     }
     $rems = array();
     $sims = array();
     $wrapped = array();
     $sims['###UID###'] = $this->conf['uid'];
     $sims['###TYPE###'] = $this->conf['type'];
     $sims['###VIEW###'] = 'save_' . $this->objectString;
     $sims['###LASTVIEW###'] = $this->controller->extendLastView();
     $sims['###L_CONFIRM_LOCATION###'] = $this->controller->pi_getLL('l_confirm_' . $this->objectString);
     $sims['###L_SAVE###'] = $this->controller->pi_getLL('l_save');
     $sims['###L_CANCEL###'] = $this->controller->pi_getLL('l_cancel');
     $sims['###ACTION_URL###'] = htmlspecialchars($this->controller->pi_linkTP_keepPIvars_url(array('view' => 'save_' . $this->objectString, 'category' => null)));
     $this->getTemplateSubpartMarker($page, $sims, $rems, $wrapped);
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, array(), $rems, $wrapped);
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, $sims, array(), array());
     $sims = array();
     $rems = array();
     $wrapped = array();
     $this->getTemplateSingleMarker($page, $sims, $rems, $wrapped);
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, array(), $rems, $wrapped);
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, $sims, array(), array());
     return \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, $sims, array(), array());
 }
Example #6
0
 public function fillTemplate($subpartMarker)
 {
     $cObj =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'cobj');
     $confArr = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['cal']);
     $modelTemplate = $confArr['todoSubtype'] == 'event' ? 'todoInlineModelTemplate' : 'todoSeparateModelTemplate';
     $page = $cObj->fileResource($this->parentEvent->conf['view.']['todo.'][$modelTemplate]);
     if ($page == '') {
         return '<h3>calendar: no todo model template file found:</h3>' . $this->parentEvent->conf['view.']['todo.'][$modelTemplate];
     }
     $page = $cObj->getSubpart($page, $subpartMarker);
     if (!$page) {
         return 'could not find the >' . str_replace('###', '', $subpartMarker) . '< subpart-marker in ' . $this->parentEvent->conf['view.']['todo.']['todoModelTemplate'];
     }
     $rems = array();
     $sims = array();
     $wrapped = array();
     $this->getMarker($page, $sims, $rems, $wrapped, $this->parentEvent->conf['view']);
     return $this->parentEvent->finish(\TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, $sims, $rems, $wrapped));
 }
Example #7
0
 /**
  * Draws a confirm event form.
  * 
  * @param
  *        	object The cObject of the mother-class
  * @param
  *        	object		The rights object.
  * @return string HTML output.
  */
 function drawConfirmEvent()
 {
     $this->objectString = 'event';
     $this->isConfirm = true;
     unset($this->controller->piVars['formCheck']);
     /* @fixme		Temporarily reverted to using piVars rather than conf */
     // unset($this->controller->piVars['category']);
     $page = $this->cObj->fileResource($this->conf['view.']['confirm_event.']['template']);
     if ($page == '') {
         return '<h3>calendar: no confirm event template file found:</h3>' . $this->conf['view.']['confirm_event.']['template'];
     }
     $this->lastPiVars = $this->controller->piVars;
     $this->object = $this->modelObj->createEvent('tx_cal_phpicalendar');
     $this->object->updateWithPIVars($this->controller->piVars);
     $lastViewParams = $this->controller->shortenLastViewAndGetTargetViewParameters();
     if ($lastViewParams['view'] == 'edit_event') {
         $this->isEditMode = true;
     }
     $rems = array();
     $sims = array();
     $wrapped = array();
     $sims['###UID###'] = $this->conf['uid'];
     $sims['###TYPE###'] = $this->conf['type'];
     $sims['###LASTVIEW###'] = $lastViewParams['lastview'];
     $sims['###OPTION###'] = $this->conf['option'];
     // $sims['###CALENDAR_ID###'] = intval($this->controller->piVars['calendar_id']);
     $sims['###L_CONFIRM_EVENT###'] = $this->controller->pi_getLL('l_confirm_event');
     $sims['###L_SAVE###'] = $this->controller->pi_getLL('l_save');
     $sims['###L_CANCEL###'] = $this->controller->pi_getLL('l_cancel');
     $this->controller->pi_linkTP('|', array('tx_cal_controller[view]' => 'save_event', 'tx_cal_controller[category]' => null, 'tx_cal_controller[getdate]' => $this->conf['getdate']));
     $sims['###ACTION_URL###'] = htmlspecialchars($this->cObj->lastTypoLinkUrl);
     $this->getTemplateSubpartMarker($page, $sims, $rems, $wrapped);
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, array(), $rems, $wrapped);
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, $sims, array(), array());
     $sims = array();
     $rems = array();
     $wrapped = array();
     $this->getTemplateSingleMarker($page, $sims, $rems, $wrapped);
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, array(), $rems, $wrapped);
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, $sims, array(), array());
     return \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, $sims, array(), array());
 }
Example #8
0
 /**
  * The function adds location markers into the event template
  *
  * @param Object $moduleCaller
  *        	Instance of the event model (phpicalendar_model)
  */
 public function start(&$moduleCaller)
 {
     if ($moduleCaller->getLocationId() > 0) {
         $this->modelObj =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'modelcontroller');
         $this->cObj =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'cobj');
         $moduleCaller->confArr = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['cal']);
         $useLocationStructure = $moduleCaller->confArr['useLocationStructure'] ? $moduleCaller->confArr['useLocationStructure'] : 'tx_cal_location';
         $location = $this->modelObj->findLocation($moduleCaller->getLocationId(), $useLocationStructure);
         if (is_object($location)) {
             $page = $this->cObj->fileResource($moduleCaller->conf['module.']['locationloader.']['template']);
             if ($page == '') {
                 return '<h3>module locationloader: no template file found:</h3>' . $moduleCaller->conf['module.']['locationloader.']['template'];
             }
             $sims = array();
             $rems = array();
             $wrapped = array();
             $location->getMarker($page, $sims, $rems, $wrapped);
             return \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, $sims, $rems, array());
         }
     }
     return '';
 }
Example #9
0
 /**
  * Draws a create category form.
  * 
  * @param
  *        	string		Comma separated list of pids.
  * @param
  *        	object		A location or organizer object to be updated
  * @return string HTML output.
  */
 public function drawConfirmCategory()
 {
     $this->objectString = 'category';
     $this->isConfirm = true;
     unset($this->controller->piVars['formCheck']);
     $page = $this->cObj->fileResource($this->conf['view.']['confirm_category.']['template']);
     if ($page == '') {
         return '<h3>category: no create category template file found:</h3>' . $this->conf['view.']['confirm_category.']['template'];
     }
     $a = array();
     $this->object = new \TYPO3\CMS\Cal\Model\CategoryModel($a, '');
     $this->object->updateWithPIVars($this->controller->piVars);
     $lastViewParams = $this->controller->shortenLastViewAndGetTargetViewParameters();
     if ($lastViewParams['view'] == 'edit_category') {
         $this->isEditMode = true;
     }
     $rems = array();
     $sims = array();
     $wrapped = array();
     $sims['###L_CONFIRM_CATEGORY###'] = $this->controller->pi_getLL('l_confirm_category');
     $sims['###UID###'] = $this->conf['uid'];
     $sims['###TYPE###'] = $this->conf['type'];
     $sims['###VIEW###'] = 'save_category';
     $sims['###L_SUBMIT###'] = $this->controller->pi_getLL('l_submit');
     $sims['###L_CANCEL###'] = $this->controller->pi_getLL('l_cancel');
     $sims['###ACTION_URL###'] = htmlspecialchars($this->controller->pi_linkTP_keepPIvars_url(array('view' => 'save_category')));
     $this->getTemplateSubpartMarker($page, $sims, $rems, $wrapped);
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, array(), $rems, $wrapped);
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, $sims, array(), array());
     $sims = array();
     $rems = array();
     $wrapped = array();
     $this->getTemplateSingleMarker($page, $sims, $rems, $wrapped);
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, array(), $rems, $wrapped);
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, $sims, array(), array());
     return \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, $sims, array(), array());
 }
Example #10
0
 /**
  * Draws the week view.
  * 
  * @param $master_array array
  *        	The events to be drawn.
  * @param $getdate integer
  *        	The date of the event
  * @return string The HTML output.
  */
 public function drawWeek(&$master_array, $getdate)
 {
     if ($this->conf['useNewTemplatesAndRendering']) {
         return $this->newDrawWeek($master_array, $getdate);
     }
     $this->_init($master_array);
     $page = $this->cObj->fileResource($this->conf['view.']['week.']['weekTemplate']);
     if ($page == '') {
         return "<h3>week: no template file found:</h3>" . $this->conf['view.']['week.']['weekTemplate'] . "<br />Please check your template record and add both cal items at 'include static (from extension)'";
     }
     $weekTemplate = $this->cObj->getSubpart($page, '###WEEK_TEMPLATE###');
     if ($weekTemplate == '') {
         $rems = array();
         return $this->finish($page, $rems);
     }
     $dayStart = $this->conf['view.']['day.']['dayStart'];
     // '0700'; // Start time for day grid
     $dayEnd = $this->conf['view.']['day.']['dayEnd'];
     // '2300'; // End time for day grid
     $gridLength = $this->conf['view.']['day.']['gridLength'];
     // '15'; // Grid distance in minutes for day view, multiples of 15 preferred
     if (!isset($getdate) || $getdate == '') {
         $getdate_obj = new \TYPO3\CMS\Cal\Model\CalDate();
         $getdate = $getdate_obj->format('%Y%m%d');
     }
     $day_array2 = array();
     preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})/', $getdate, $day_array2);
     $this_day = $day_array2[3];
     $this_month = $day_array2[2];
     $this_year = $day_array2[1];
     $unix_time = new \TYPO3\CMS\Cal\Model\CalDate($getdate . '000000');
     $today = new \TYPO3\CMS\Cal\Model\CalDate();
     $todayFormatted = $today->format('%Y%m%d');
     $now = new \TYPO3\CMS\Cal\Model\CalDate($getdate . '000000');
     $endOfNextMonth = new \TYPO3\CMS\Cal\Model\CalDate(Calc::endOfNextMonth($this_day, $this_month, $this_year));
     $now->addSeconds(60 * 60 * 24 * 31);
     $next_month = $now->format('%Y%m%d');
     if ($now->after($endOfNextMonth)) {
         $next_month = $endOfNextMonth->format('%Y%m%d');
     }
     $now = new \TYPO3\CMS\Cal\Model\CalDate($getdate . '000000');
     $startOfPrevMonth = new \TYPO3\CMS\Cal\Model\CalDate(Calc::endOfPrevMonth($this_day, $this_month, $this_year));
     $startOfPrevMonth->setDay(1);
     $now->subtractSeconds(60 * 60 * 24 * 31);
     $prev_month = $now->format('%Y%m%d');
     if ($now->before($startOfPrevMonth)) {
         $prev_month = $startOfPrevMonth->format('%Y%m%d');
     }
     $dateOfMonth = Calc::beginOfWeek(1, $this_month, $this_year);
     $start_month_day = new \TYPO3\CMS\Cal\Model\CalDate($dateOfMonth . '000000');
     $thisday2 = $unix_time->format($this->conf['view.']['week.']['dateFormatWeekList']);
     $num_of_events2 = 0;
     $next_week_obj = new \TYPO3\CMS\Cal\Model\CalDate();
     $next_week_obj->copy($unix_time);
     $next_week_obj->addSeconds(60 * 60 * 24 * 7);
     $next_week = $next_week_obj->format('%Y%m%d');
     $next_week_obj->subtractSeconds(60 * 60 * 24 * 7 * 2);
     $prev_week = $next_week_obj->format('%Y%m%d');
     $next_day_obj = $unix_time->getNextDay();
     $next_day = $next_day_obj->format('%Y%m%d');
     $prev_day_obj = $unix_time->getPrevDay();
     $prev_day = $prev_day_obj->format('%Y%m%d');
     $dateOfWeek = Calc::beginOfWeek($unix_time->getDay(), $unix_time->getMonth(), $unix_time->getYear());
     $week_start_day = new \TYPO3\CMS\Cal\Model\CalDate($dateOfWeek . '000000');
     // Nasty fix to work with TS strftime
     $start_week_time = new \TYPO3\CMS\Cal\Model\CalDate($dateOfWeek . '000000');
     $start_week_time->setTZbyID('UTC');
     $end_week_time = new \TYPO3\CMS\Cal\Model\CalDate();
     $end_week_time->copy($start_week_time);
     $end_week_time->addSeconds(604799);
     $GLOBALS['TSFE']->register['cal_week_endtime'] = $end_week_time->getTime();
     $GLOBALS['TSFE']->register['cal_week_starttime'] = $start_week_time->getTime();
     $display_date = $this->cObj->cObjGetSingle($this->conf['view.']['week.']['titleWrap'], $this->conf['view.']['week.']['titleWrap.']);
     $this->initLocalCObject();
     $dayLinkViewTarget =& $this->conf['view.']['dayLinkTarget'];
     $this->local_cObj->data['view'] = $dayLinkViewTarget;
     $this->local_cObj->setCurrentVal($this->conf['view.']['week.']['legendNextDayLink']);
     $legend_next_day_link = $this->local_cObj->cObjGetSingle($this->conf['view.']['week.']['legendNextDayLink'], $this->conf['view.']['week.']['legendNextDayLink.']);
     $this->local_cObj->setCurrentVal($this->conf['view.']['week.']['legendPrevDayLink']);
     $legend_prev_day_link = $this->local_cObj->cObjGetSingle($this->conf['view.']['week.']['legendPrevDayLink'], $this->conf['view.']['week.']['legendPrevDayLink.']);
     // Figure out colspans
     $dayborder = 0;
     $thisdate = $start_week_time;
     $eventArray = array();
     $view_array = array();
     $rowspan_array = array();
     $endOfDay = new \TYPO3\CMS\Cal\Model\CalDate();
     $startOfDay = new \TYPO3\CMS\Cal\Model\CalDate();
     // creating the dateObjects only once:
     $starttime = new \TYPO3\CMS\Cal\Model\CalDate();
     $endtime = new \TYPO3\CMS\Cal\Model\CalDate();
     $j = new \TYPO3\CMS\Cal\Model\CalDate();
     if (count($this->master_array) > 0) {
         $masterKeys = array_keys($this->master_array);
         foreach ($masterKeys as $ovlKey) {
             $dTimeStart = array();
             $dTimeEnd = array();
             $dDate = array();
             preg_match('/([0-9]{2})([0-9]{2})/', $this->conf['view.']['day.']['dayStart'], $dTimeStart);
             preg_match('/([0-9]{2})([0-9]{2})/', $this->conf['view.']['day.']['dayEnd'], $dTimeEnd);
             preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})/', $ovlKey, $dDate);
             $d_start = new \TYPO3\CMS\Cal\Model\CalDate($dDate[1] . $dDate[2] . $dDate[3] . ' ' . $dTimeStart[1] . ':' . sprintf("%02d", $dTimeStart[2]) . ':00');
             $d_start->setTZbyID('UTC');
             $d_end = new \TYPO3\CMS\Cal\Model\CalDate($dDate[1] . $dDate[2] . $dDate[3] . ' ' . $dTimeEnd[1] . ':' . sprintf("%02d", $dTimeEnd[2]) . ':00');
             $d_end->setTZbyID('UTC');
             // minus 1 second to allow endtime 24:00
             $d_end->subtractSeconds(1);
             $ovlTimeKeys = array_keys($this->master_array[$ovlKey]);
             foreach ($ovlTimeKeys as $ovl_time_key) {
                 $ovlDayKeys = array_keys($this->master_array[$ovlKey][$ovl_time_key]);
                 foreach ($ovlDayKeys as $ovl2Key) {
                     $event =& $this->master_array[$ovlKey][$ovl_time_key][$ovl2Key];
                     $eventStart = $event->getStart();
                     $eventMappingKey = $event->getType() . '_' . $event->getUid() . '_' . $eventStart->format('%Y%m%d%H%M');
                     $eventArray[$ovlKey . '_' . $eventMappingKey] =& $event;
                     $starttime->copy($event->getStart());
                     $endtime->copy($event->getEnd());
                     if ($ovl_time_key == '-1') {
                         $j->copy($starttime);
                         $view_array[$j->format('%Y%m%d')]['-1'][] = $ovlKey . '_' . $eventMappingKey;
                         $j->addSeconds(86400);
                         for (; $j->before($endtime) && $j->before($end_week_time); $j->addSeconds(86400)) {
                             $view_array[$j->format('%Y%m%d')]['-1'][] = $ovlKey . '_' . $eventMappingKey;
                         }
                     } else {
                         if ($starttime->before($end_week_time)) {
                             $starttime->subtractSeconds($starttime->getMinute() % $gridLength * 60);
                             $endtime->addSeconds($endtime->getMinute() % $gridLength * 60);
                             $entries = 1;
                             $old_day = new \TYPO3\CMS\Cal\Model\CalDate($ovlKey . '000000');
                             $endOfDay->copy($d_end);
                             $startOfDay->copy($d_start);
                             // get x-array possition
                             for ($k = 0; $k < count($view_array[$ovlKey]); $k++) {
                                 if (empty($view_array[$starttime->format('%Y%m%d')][$starttime->format('%H%M')][$k])) {
                                     break;
                                 }
                             }
                             $j->copy($starttime);
                             if ($j->before($startOfDay)) {
                                 $j->copy($startOfDay);
                             }
                             $counter = 0;
                             while ($j->before($endtime) && $j->before($end_week_time)) {
                                 $counter++;
                                 $view_array[$j->format('%Y%m%d')][$j->format('%H%M')][] = $ovlKey . '_' . $eventMappingKey;
                                 if ($j->after($endOfDay)) {
                                     $rowspan_array[$old_day->format('%Y%m%d')][$eventMappingKey] = $entries - 1;
                                     $endOfDay->addSeconds(86400);
                                     $old_day->copy($endOfDay);
                                     $startOfDay->addSeconds(86400);
                                     $j->addSeconds(86400);
                                     $j->setHour($startOfDay->getHour());
                                     $j->setMinute($startOfDay->getMinute());
                                     $j->subtractSeconds($gridLength * 60);
                                     for ($k = 0; $k < count($view_array[$startOfDay->format('%Y%m%d')]); $k++) {
                                         if (empty($view_array[$startOfDay->format('%Y%m%d')][$startOfDay->format('%H%M')][$k])) {
                                             break;
                                         }
                                     }
                                     $entries = 0;
                                     $eventArray[$startOfDay->format('%Y%m%d') . '_' . $eventMappingKey] =& $event;
                                 }
                                 $j->addSeconds($gridLength * 60);
                                 $entries++;
                             }
                             $rowspan_array[$old_day->format('%Y%m%d')][$eventMappingKey] = $entries - 1;
                         }
                     }
                 }
             }
         }
     }
     if ($this->conf['view.']['week.']['dynamic'] == 1) {
         $dayStart = '2359';
         $dayEnd = '0000';
         $firstStart = true;
         $firstEnd = true;
         $dynamicEnd = intval($end_week_time->format('%Y%m%d'));
         for ($dynamicStart = intval($start_week_time->format('%Y%m%d')); $dynamicStart < $dynamicEnd; $dynamicStart++) {
             if (is_array($view_array[$dynamicStart])) {
                 $timeKeys = array_keys($view_array[$dynamicStart]);
                 $formatedLast = array_pop($timeKeys);
                 while (intval($formatedLast) < 0 && !empty($timeKeys)) {
                     $formatedLast = array_pop($timeKeys);
                 }
                 $formatedFirst = null;
                 if (count($timeKeys) > 0) {
                     do {
                         $formatedFirst = array_shift($timeKeys);
                     } while (intval($formatedFirst) < 0 && !empty($timeKeys));
                 } else {
                     $formatedFirst = $formatedLast;
                 }
                 if (intval($formatedFirst) > 0 && (intval($formatedFirst) < intval($dayStart) || $firstStart)) {
                     $dayStart = sprintf("%04d", $formatedFirst);
                     $firstStart = false;
                 }
                 if (intval($formatedLast) > intval($dayEnd) || $firstEnd) {
                     $dayEnd = sprintf("%04d", $formatedLast + $gridLength);
                     $firstEnd = false;
                 }
             }
         }
         $dayStart = substr($dayStart, 0, 2) . '00';
     }
     $startdate = new \TYPO3\CMS\Cal\Model\CalDate($start_week_time->format('%Y%m%d') . '000000');
     $enddate = new \TYPO3\CMS\Cal\Model\CalDate();
     $enddate->copy($end_week_time);
     for ($i = $startdate; $enddate->after($i); $i->addSeconds(86400)) {
         if (!empty($view_array[$i->format('%Y%m%d')])) {
             $max = array();
             foreach (array_keys($view_array[$i->format('%Y%m%d')]) as $array_time) {
                 $c = count($view_array[$i->format('%Y%m%d')][$array_time]);
                 array_push($max, $c);
             }
             $nbrGridCols[$i->format('%Y%m%d')] = max($max);
         } else {
             $nbrGridCols[$i->format('%Y%m%d')] = 1;
         }
     }
     $t_array = array();
     $pos_array = array();
     preg_match('/([0-9]{2})([0-9]{2})/', $dayStart, $dTimeStart);
     preg_match('/([0-9]{2})([0-9]{2})/', $dayEnd, $dTimeEnd);
     $nd = new \TYPO3\CMS\Cal\Model\CalDate();
     foreach (array_keys($view_array) as $week_key) {
         $week_day =& $view_array[$week_key];
         preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})/', $week_key, $dDate);
         $d_start = new \TYPO3\CMS\Cal\Model\CalDate($dDate[1] . $dDate[2] . $dDate[3] . ' ' . $dTimeStart[1] . ':' . sprintf("%02d", $dTimeStart[2]) . ':00');
         $d_start->setTZbyId('UTC');
         $d_end = new \TYPO3\CMS\Cal\Model\CalDate($dDate[1] . $dDate[2] . $dDate[3] . ' ' . $dTimeEnd[1] . ':' . sprintf("%02d", $dTimeEnd[2]) . ':00');
         $d_end->setTZbyId('UTC');
         $d_start->subtractSeconds($d_start->getMinute() % $gridLength * 60);
         $d_end->addSeconds(($gridLength - $d_end->getMinute() % $gridLength) * 60);
         for ($i->copy($d_start); !$i->after($d_end); $i->addSeconds($gridLength * 60)) {
             $timeKey = $i->format('%H%M');
             if (is_array($view_array[$week_key][$timeKey]) && count($view_array[$week_key][$timeKey]) > 0) {
                 foreach (array_keys($view_array[$week_key][$timeKey]) as $eventKey) {
                     $event =& $eventArray[$view_array[$week_key][$timeKey][$eventKey]];
                     $eventStart = $event->getStart();
                     $startFormatted = $eventStart->format('%Y%m%d%H%M');
                     $eventType = $event->getType();
                     $eventUid = $event->getUid();
                     if (is_array($pos_array[$week_key]) && array_key_exists($eventType . $eventUid . '_' . $startFormatted, $pos_array[$week_key])) {
                         $nd->copy($event->getEnd());
                         $nd->addSeconds(($gridLength - $nd->getMinute() % $gridLength) * 60);
                         if ($nd->before($i)) {
                             $t_array[$week_key][$timeKey][$pos_array[$week_key][$eventType . $eventUid . '_' . $startFormatted]] = array('ended' => $week_key . '_' . $eventType . '_' . $eventUid . '_' . $startFormatted);
                         } else {
                             $t_array[$week_key][$timeKey][$pos_array[$week_key][$eventType . $eventUid . '_' . $startFormatted]] = array('started' => $week_key . '_' . $eventType . '_' . $eventUid . '_' . $startFormatted);
                         }
                     } else {
                         for ($j = 0; $j < $nbrGridCols[$week_key] ? $nbrGridCols[$week_key] : 1; $j++) {
                             if (!isset($t_array[$week_key][$timeKey][$j]) || count($t_array[$week_key][$timeKey][$j]) == 0) {
                                 $pos_array[$week_key][$event->getType() . $event->getUid() . '_' . $startFormatted] = $j;
                                 $t_array[$week_key][$timeKey][$j] = array('begin' => $week_key . '_' . $eventType . '_' . $eventUid . '_' . $startFormatted);
                                 break;
                             }
                         }
                     }
                 }
             } else {
                 $t_array[$week_key][$timeKey] = '';
             }
         }
     }
     $thisdate = new \TYPO3\CMS\Cal\Model\CalDate();
     $thisdate->copy($week_start_day);
     for ($i = 0; $i < 7; $i++) {
         $weekarray[$i] = $thisdate->format('%Y%m%d');
         $thisdate->addSeconds(86400);
     }
     $sims = array('###GETDATE###' => $getdate, '###DISPLAY_DATE###' => $display_date, '###LEGEND_PREV_DAY###' => $legend_prev_day_link, '###LEGEND_NEXT_DAY###' => $legend_next_day_link, '###SIDEBAR_DATE###' => '');
     // Replaces the allday events
     $alldays = $this->cObj->getSubpart($weekTemplate, '###ALLDAYSOFWEEK##');
     foreach ($weekarray as $get_date) {
         $replace = '';
         if (is_array($view_array[$get_date]['-1'])) {
             foreach ($view_array[$get_date]['-1'] as $id => $allday) {
                 $replace .= $eventArray[$allday]->renderEventForAllDay();
             }
         }
         $weekreplace .= \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($alldays, array('###COLSPAN###' => 'colspan="' . ($nbrGridCols[$get_date] ? $nbrGridCols[$get_date] : 1) . '"', '###ALLDAY###' => $replace));
     }
     $rems = array();
     $rems['###ALLDAYSOFWEEK###'] = $weekreplace;
     // Replaces the daysofweek
     $loop_dof = $this->cObj->getSubpart($weekTemplate, '###DAYSOFWEEK###');
     $start_day = new \TYPO3\CMS\Cal\Model\CalDate();
     $start_day->copy($week_start_day);
     $isAllowedToCreateEvent = $this->rightsObj->isAllowedToCreateEvent();
     for ($i = 0; $i < 7; $i++) {
         $day_num = $start_day->format('%w');
         $daylink = $start_day->format('%Y%m%d');
         $weekday = $start_day->format($this->conf['view.']['week.']['dateFormatWeekList']);
         if ($daylink == $getdate) {
             $row1 = 'rowToday';
             $row2 = 'rowOn';
             $row3 = 'rowToday';
         } else {
             $row1 = 'rowOff';
             $row2 = 'rowOn';
             $row3 = 'rowOff';
         }
         $dayLinkViewTarget =& $this->conf['view.']['dayLinkTarget'];
         if (($this->rightsObj->isViewEnabled($dayLinkViewTarget) || $this->conf['view.'][$dayLinkViewTarget . '.'][$dayLinkViewTarget . 'ViewPid']) && ($view_array[$daylink] || $isAllowedToCreateEvent)) {
             $this->initLocalCObject();
             $this->local_cObj->setCurrentVal($weekday);
             if (!empty($this->conf['view.'][$dayLinkViewTarget . '.'][$dayLinkViewTarget . 'ViewPid'])) {
                 $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('getdate' => $daylink, 'view' => $this->conf['view.']['dayLinkTarget'], $this->pointerName => NULL), $this->conf['cache'], $this->conf['clear_anyway'], $this->conf['view.'][$dayLinkViewTarget . '.'][$dayLinkViewTarget . 'ViewPid']);
             } else {
                 $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('getdate' => $daylink, 'view' => $this->conf['view.']['dayLinkTarget'], $this->pointerName => NULL), $this->conf['cache'], $this->conf['clear_anyway']);
             }
             $this->local_cObj->data['view'] = $dayLinkViewTarget;
             $link = $this->local_cObj->cObjGetSingle($this->conf['view.'][$dayLinkViewTarget . '.'][$dayLinkViewTarget . 'ViewLink'], $this->conf['view.'][$dayLinkViewTarget . '.'][$dayLinkViewTarget . 'ViewLink.']);
             $link = $this->cObj->stdWrap($link, $this->conf['view.']['week.']['weekday_stdWrap.']);
         } else {
             $link = $this->cObj->stdWrap($weekday, $this->conf['view.']['week.']['weekday_stdWrap.']);
         }
         $start_day->addSeconds(86400);
         $colspan = 'colspan="' . ($nbrGridCols[$daylink] ? $nbrGridCols[$daylink] : 1) . '"';
         $search = array('###LINK###', '###DAYLINK###', '###ROW1###', '###ROW2###', '###ROW3###', '###COLSPAN###', '###TIME###');
         $replace = array($link, $daylink, $row1, $row2, $row3, $colspan, $start_day->format('%Y %m %d %H %M %s'));
         $loop_tmp = str_replace($search, $replace, $loop_dof);
         $weekday_loop .= $loop_tmp;
     }
     $rems['###DAYSOFWEEK###'] = $weekday_loop;
     // Build the body
     $border = 0;
     $thisdate = $start_week_time;
     $dTimeStart[2] -= $dTimeStart[2] % $gridLength;
     $dTimeEnd[2] -= $dTimeEnd[2] % $gridLength;
     preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})/', $week_key, $dDate);
     $loops = ($dTimeEnd[1] * 60 + $dTimeEnd[2] - ($dTimeStart[1] * 60 + $dTimeStart[2])) / $gridLength;
     $weekdisplay = '';
     $createOffset = intval($this->conf['rights.']['create.']['event.']['timeOffset']) * 60;
     $cal_time_obj = new \TYPO3\CMS\Cal\Model\CalDate();
     $cal_time_obj->copy($week_start_day);
     $cal_time_obj->setHour(intval($dTimeStart[1]));
     $cal_time_obj->setMinute(intval($dTimeStart[2]));
     $start = 0;
     for ($i = $start; $i < $loops; $i++) {
         $time = $cal_time_obj->format('%H%M');
         for ($j = 0; $j < 7; $j++) {
             $day = $cal_time_obj->format('%Y%m%d');
             if ($j == 0) {
                 $key = $cal_time_obj->format('%I:%M');
                 if (preg_match('/([0-9]{1,2}):00/', $key)) {
                     $weekdisplay .= sprintf($this->conf['view.']['week.']['weekDisplayFullHour'], 60 / $gridLength, $cal_time_obj->format($this->conf['view.']['week.']['timeFormatWeek']), $gridLength);
                 } else {
                     $weekdisplay .= sprintf($this->conf['view.']['week.']['weekDisplayInbetween'], $gridLength);
                 }
             }
             $something = $t_array[$day][$time];
             $class = $this->conf['view.']['week.']['classWeekborder'];
             if ($day == $todayFormatted) {
                 $class .= ' ' . $this->conf['view.']['week.']['classTodayWeekborder'];
             }
             if (is_array($something) && $something != "" && count($something) > 0) {
                 for ($k = 0; $k < count($something); $k++) {
                     if (!empty($something[$k])) {
                         $keys = array_keys($something[$k]);
                         switch ($keys[0]) {
                             case 'begin':
                                 $event =& $eventArray[$something[$k][$keys[0]]];
                                 $rest = $event->getEnd()->getMinute() % ($gridLength * 60);
                                 $plus = 0;
                                 if ($rest > 0) {
                                     $plus = 1;
                                 }
                                 $weekdisplay .= sprintf($this->conf['view.']['week.']['weekEventPre'], $rowspan_array[$day][$event->getType() . '_' . $event->getUid() . '_' . $event->getStart()->format('%Y%m%d%H%M')]);
                                 $weekdisplay .= $event->renderEventForWeek();
                                 $weekdisplay .= $this->conf['view.']['week.']['weekEventPost'];
                                 // End event drawing
                                 break;
                         }
                     }
                 }
                 if (count($something) < ($nbrGridCols[$day] ? $nbrGridCols[$day] : 1)) {
                     $remember = 0;
                     for ($l = 0; $l < ($nbrGridCols[$day] ? $nbrGridCols[$day] : 1); $l++) {
                         if (!$something[$l]) {
                             $remember++;
                         } else {
                             if ($remember > 0) {
                                 $weekdisplay .= $this->getCreateEventLink('week', $this->conf['view.']['week.']['normalCell'], $cal_time_obj, $createOffset, $isAllowedToCreateEvent, $remember, $class, $time);
                                 $remember = 0;
                             }
                         }
                     }
                     if ($remember > 0) {
                         $weekdisplay .= $this->getCreateEventLink('week', $this->conf['view.']['week.']['normalCell'], $cal_time_obj, $createOffset, $isAllowedToCreateEvent, $remember, $class, $time);
                         $remember = 0;
                     }
                 }
             } else {
                 $weekdisplay .= $this->getCreateEventLink('week', $this->conf['view.']['week.']['normalCell'], $cal_time_obj, $createOffset, $isAllowedToCreateEvent, $nbrGridCols[$day] ? $nbrGridCols[$day] : 1, $class, $time);
             }
             if ($j == 6) {
                 $weekdisplay .= $this->conf['view.']['week.']['weekFinishRow'];
             }
             $cal_time_obj->addSeconds(86400);
         }
         $cal_time_obj->setYear($week_start_day->getYear());
         $cal_time_obj->setMonth($week_start_day->getMonth());
         $cal_time_obj->setDay($week_start_day->getDay());
         $cal_time_obj->addSeconds($gridLength * 60);
     }
     $weekTemplate = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($weekTemplate, $sims, array(), array());
     $rems['###LOOPEVENTS###'] = $weekdisplay;
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, array(), array('###WEEK_TEMPLATE###' => $weekTemplate), array());
     return $this->finish($page, $rems);
 }
Example #11
0
 protected function getFileMarker($marker, &$template, &$sims, &$rems)
 {
     if (!$this->isAllowed($marker)) {
         return;
     }
     $max = $GLOBALS['TCA']['tx_cal_' . $this->objectString]['columns'][$marker]['config']['maxitems'];
     $sims['###' . strtoupper($marker) . '###'] = '';
     $sims['###' . strtoupper($marker) . '_VALUE###'] = '';
     $sims['###' . strtoupper($marker) . '_CAPTION###'] = '';
     $sims['###' . strtoupper($marker) . '_CAPTION_VALUE###'] = '';
     if ($this->isConfirm) {
         $sims['###' . strtoupper($marker) . '###'] = '';
         $fileFunc = new \TYPO3\CMS\Core\Utility\File\BasicFileUtility();
         $all_files = array();
         $all_files['webspace']['allow'] = '*';
         $all_files['webspace']['deny'] = '';
         $fileFunc->init('', $all_files);
         $allowedExt = array();
         $denyExt = array();
         if ($marker == 'image') {
             $allowedExt = explode(',', $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']);
         } else {
             if ($marker == 'attachment') {
                 $allowedExt = explode(',', $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']['webspace']['allow']);
                 $denyExt = explode(',', $GLOBALS['TYPO3_CONF_VARS']['BE']['fileExtensions']['webspace']['deny']);
             }
         }
         $i = 0;
         // new files
         if (is_array($_FILES[$this->prefixId]['name'])) {
             foreach ($_FILES[$this->prefixId]['name'][$marker] as $id => $filename) {
                 $theDestFile = '';
                 $iConf = $this->conf['view.'][$this->conf['view'] . '.'][strtolower($marker) . '_stdWrap.'];
                 if ($_FILES[$this->prefixId]['error'][$marker][$id]) {
                     continue;
                 } else {
                     $theFile = GeneralUtility::upload_to_tempfile($_FILES[$this->prefixId]['tmp_name'][$marker][$id]);
                     $fI = GeneralUtility::split_fileref($filename);
                     if (in_array($fI['fileext'], $denyExt)) {
                         continue;
                     } else {
                         if ($marker == 'image' && !in_array($fI['fileext'], $allowedExt)) {
                             continue;
                         }
                     }
                     $theDestFile = $fileFunc->getUniqueName($fileFunc->cleanFileName($fI['file']), 'typo3temp');
                     GeneralUtility::upload_copy_move($theFile, $theDestFile);
                     $iConf['file'] = $theDestFile;
                     $return = '__NEW__' . basename($theDestFile);
                 }
                 $temp_sims = array();
                 $temp_sims['###INDEX###'] = $id;
                 $temp_sims['###' . strtoupper($marker) . '_VALUE###'] = $return;
                 $temp = '';
                 if ($marker == 'image') {
                     $temp = $this->renderImage($iConf['file'], $this->controller->piVars[$marker . '_caption'][$id], $this->controller->piVars[$marker . '_title'][$id], $marker, true);
                 } else {
                     if ($marker == 'attachment' || $marker == 'ics_file') {
                         $temp = $this->renderFile($iConf['file'], $this->controller->piVars[$marker . '_caption'][$id], $this->controller->piVars[$marker . '_title'][$id], $marker, true);
                     }
                 }
                 if ($this->isAllowed($marker . '_caption')) {
                     $temp .= $this->applyStdWrap($this->controller->piVars[$marker . '_caption'][$id], $marker . '_caption_stdWrap');
                 }
                 if ($this->isAllowed($marker . '_title')) {
                     $temp .= $this->applyStdWrap($this->controller->piVars[$marker . '_title'][$id], $marker . '_title_stdWrap');
                 }
                 $sims['###' . strtoupper($marker) . '###'] .= \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($temp, $temp_sims, array(), array());
                 $i++;
             }
         }
         $removeFiles = $this->controller->piVars['remove_' . $marker] ? $this->controller->piVars['remove_' . $marker] : array();
         $where = 'uid_foreign = ' . $this->conf['uid'] . ' AND  tablenames=\'tx_cal_' . $this->objectString . '\' AND fieldname=\'' . $marker . '\' AND deleted=0';
         if (!empty($removeFiles)) {
             $where .= ' AND uid not in (' . implode(',', array_values($removeFiles)) . ')';
         }
         $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_file_reference', $where);
         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
             if ($marker == 'image') {
                 $temp = $this->renderImage($row, $row['description'], $row['title'], $marker, false);
             } else {
                 if ($marker == 'attachment' || $marker == 'ics_file') {
                     $temp = $this->renderFile($row, $row['description'], $row['title'], $marker, false);
                 }
             }
             $temp_sims = array();
             $temp_sims['###' . strtoupper($marker) . '_VALUE###'] = $row['uid'];
             foreach ($this->controller->piVars[$marker] as $index => $image) {
                 if ($image == $row['uid']) {
                     if (isset($this->controller->piVars[$marker . '_caption'][$index])) {
                         $row['description'] = $this->controller->piVars[$marker . '_caption'][$index];
                     }
                     if (isset($this->controller->piVars[$marker . '_title'][$index])) {
                         $row['title'] = $this->controller->piVars[$marker . '_title'][$index];
                     }
                     $temp_sims['###INDEX###'] = $index;
                     break;
                 }
             }
             if ($this->isAllowed($marker . '_caption')) {
                 $temp .= $this->applyStdWrap($row['description'], $marker . '_caption_stdWrap');
             }
             if ($this->isAllowed($marker . '_title')) {
                 $temp .= $this->applyStdWrap($row['title'], $marker . '_title_stdWrap');
             }
             $sims['###' . strtoupper($marker) . '###'] .= \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($temp, $temp_sims, array(), array());
         }
         $GLOBALS['TYPO3_DB']->sql_free_result($result);
         foreach ($removeFiles as $removeFile) {
             $sims['###' . strtoupper($marker) . '###'] .= '<input type="hidden" name="tx_cal_controller[remove_' . $marker . '][]" value="' . $removeFile . '">';
         }
     } else {
         if ($this->isEditMode && $this->rightsObj->isAllowedTo('edit', $this->objectString, $marker)) {
             $sims['###' . strtoupper($marker) . '###'] = '';
             $i = 0;
             $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_file_reference', 'uid_foreign = ' . $this->conf['uid'] . ' AND  tablenames=\'tx_cal_' . $this->objectString . '\' AND fieldname=\'' . $marker . '\' AND deleted=0');
             while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
                 $temp_sims = array();
                 $temp_sims['###' . strtoupper($marker) . '_VALUE###'] = $row['uid'];
                 $temp = $this->cObj->stdWrap('', $this->conf['view.'][$this->conf['view'] . '.'][strtolower($marker) . '_stdWrap.']);
                 if ($marker == 'image') {
                     $temp_sims['###' . strtoupper($marker) . '_PREVIEW###'] = $this->renderImage($row, $row['description'], $row['title'], $marker, false);
                 } else {
                     if ($marker == 'attachment' || $marker == 'ics_file') {
                         $temp_sims['###' . strtoupper($marker) . '_PREVIEW###'] = $this->renderFile($row, $row['description'], $row['title'], $marker, false);
                     }
                 }
                 $temp = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($temp, $temp_sims, array(), array());
                 if ($this->isAllowed($marker . '_caption')) {
                     $temp .= $this->applyStdWrap($row['description'], $marker . '_caption_stdWrap');
                 }
                 if ($this->isAllowed($marker . '_title')) {
                     $temp .= $this->applyStdWrap($row['title'], $marker . '_title_stdWrap');
                 }
                 $temp_sims['###INDEX###'] = $i;
                 $sims['###' . strtoupper($marker) . '###'] .= \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($temp, $temp_sims, array(), array());
                 $i++;
             }
             $GLOBALS['TYPO3_DB']->sql_free_result($result);
             $upload = '';
             for (; $i < $max; $i++) {
                 $temp_sims = array();
                 $upload .= $this->cObj->stdWrap('', $this->conf['view.'][$this->conf['view'] . '.'][$marker . 'Upload_stdWrap.']);
                 if ($this->isAllowed($marker . '_caption')) {
                     $upload .= $this->applyStdWrap('', $marker . '_caption_stdWrap');
                 }
                 if ($this->isAllowed($marker . '_title')) {
                     $upload .= $this->applyStdWrap('', $marker . '_title_stdWrap');
                 }
                 $temp_sims['###INDEX###'] = $i;
                 $upload = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($upload, $temp_sims, array(), array());
             }
             $sims['###' . strtoupper($marker) . '###'] .= $upload;
         } else {
             if (!$this->isEditMode && $this->rightsObj->isAllowedTo('create', $this->objectString, $marker)) {
                 for ($i = 0; $i < $max; $i++) {
                     $value = '';
                     $upload = $this->cObj->stdWrap($value, $this->conf['view.'][$this->conf['view'] . '.'][$marker . 'Upload_stdWrap.']);
                     $value = '';
                     if ($this->isAllowed($marker . '_caption')) {
                         $upload .= $this->applyStdWrap('', $marker . '_caption_stdWrap');
                     }
                     if ($this->isAllowed($marker . '_title')) {
                         $upload .= $this->applyStdWrap('', $marker . '_title_stdWrap');
                     }
                     $temp_sims['###INDEX###'] = $i;
                     $sims['###' . strtoupper($marker) . '###'] .= \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($upload, $temp_sims, array(), array());
                 }
             }
         }
     }
 }
 /**
  * Draws a create location or organizer form.
  * 
  * @param
  *        	boolean		True if a location should be confirmed
  * @param
  *        	string		Comma separated list of pids.
  * @param
  *        	object		A location or organizer object to be updated
  * @return string HTML output.
  */
 public function drawCreateLocationOrOrganizer($isLocation = true, $pidList, $object = '')
 {
     $this->isLocation = $isLocation;
     if ($isLocation) {
         $this->objectString = 'location';
     } else {
         $this->objectString = 'organizer';
     }
     if (is_object($object)) {
         $this->conf['view'] = 'edit_' . $this->objectString;
     } else {
         $this->conf['view'] = 'create_' . $this->objectString;
         unset($this->controller->piVars['uid']);
     }
     $requiredFieldSims = array();
     $allRequiredFieldsAreFilled = $this->checkRequiredFields($requiredFieldsSims);
     if ($allRequiredFieldsAreFilled) {
         $this->conf['lastview'] = $this->controller->extendLastView();
         $this->conf['view'] = 'confirm_' . $this->objectString;
         if ($isLocation) {
             return $this->controller->confirmLocation();
         }
         return $this->controller->confirmOrganizer();
     }
     // Needed for translation options:
     $this->serviceName = 'cal_' . $this->objectString . '_model';
     $this->table = 'tx_cal_' . $this->objectString;
     $page = $this->cObj->fileResource($this->conf['view.']['create_location.']['template']);
     if ($page == '') {
         return '<h3>calendar: no create location template file found:</h3>' . $this->conf['view.']['create_location.']['template'];
     }
     if (is_object($object) && !$object->isUserAllowedToEdit()) {
         return $this->controller->pi_getLL('l_not_allowed_edit') . $this->objectString;
     } else {
         if (!is_object($object) && !$this->rightsObj->isAllowedTo('create', $this->objectString, '')) {
             return $this->controller->pi_getLL('l_not_allowed_create') . $this->objectString;
         }
     }
     // If an object has been passed on the form is a edit form
     if (is_object($object) && $object->isUserAllowedToEdit()) {
         $this->isEditMode = true;
         $this->object = $object;
     } else {
         if ($isLocation) {
             $this->object = new \TYPO3\CMS\Cal\Model\Location(null, '');
         } else {
             $this->object = new \TYPO3\CMS\Cal\Model\Organizer(null, '');
         }
         $allValues = array_merge($this->getDefaultValues(), $this->controller->piVars);
         $this->object->updateWithPIVars($allValues);
     }
     $sims = array();
     $rems = array();
     $wrapped = array();
     $sims['###TYPE###'] = $this->object->getType();
     $this->getTemplateSubpartMarker($page, $sims, $rems, $wrapped, $this->conf['view']);
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, array(), $rems, $wrapped);
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, $sims, array(), array());
     $sims = array();
     $rems = array();
     $wrapped = array();
     $sims['###L_CREATE_LOCATION###'] = $this->controller->pi_getLL('l_' . $this->conf['view']);
     $this->getTemplateSingleMarker($page, $sims, $rems, $this->conf['view']);
     $sims['###ACTION_URL###'] = htmlspecialchars($this->controller->pi_linkTP_keepPIvars_url(array('view' => $this->conf['view'], 'formCheck' => '1')));
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, array(), $rems, $wrapped);
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, $sims, array(), array());
     return \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, $requiredFieldsSims, array(), array());
 }
Example #13
0
 /**
  * 
  * @param array $tags
  * @param string $page
  * @return string
  */
 public static function replace_tags($tags = array(), $page)
 {
     if (sizeof($tags) > 0) {
         $sims = array();
         foreach ($tags as $tag => $data) {
             // This replaces any tags
             $sims['###' . strtoupper($tag) . '###'] = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($data, '###' . strtoupper($tag) . '###', array(), array());
         }
         $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, $sims, array(), array());
     } else {
         //die('No tags designated for replacement.');
     }
     return $page;
 }
Example #14
0
 function getPageBrowser($template)
 {
     $pb = '';
     // render PageBrowser
     if ($this->conf['view.']['list.']['pageBrowser.']['usePageBrowser']) {
         $this->controller->pointerName = $this->pointerName;
         // Hook: getPageBrowser
         $hookObjectsArr = \TYPO3\CMS\Cal\Utility\Functions::getHookObjectsArray('tx_cal_listview', 'getPageBrowser', 'view');
         if (count($hookObjectsArr)) {
             foreach ($hookObjectsArr as $hookObj) {
                 if (method_exists($hookObj, 'renderPageBrowser')) {
                     $hookObj->renderPageBrowser($this, $pb, $this->count, $this->recordsPerPage, $template);
                 }
             }
             if ($pb != '') {
                 return $pb;
             }
         }
         // use the piPageBrowser
         if ($this->conf['view.']['list.']['pageBrowser.']['useType'] == 'piPageBrowser') {
             $browserConfig =& $this->conf['view.']['list.']['pageBrowser.']['piPageBrowser.'];
             $this->controller->internal['res_count'] = $this->count;
             $this->controller->internal['results_at_a_time'] = $this->recordsPerPage;
             if ($maxPages = intval($this->conf['view.']['list.']['pageBrowser.']['pagesCount'])) {
                 $this->controller->internal['maxPages'] = $maxPages;
             }
             $this->controller->internal['pagefloat'] = $browserConfig['pagefloat'];
             $this->controller->internal['showFirstLast'] = $browserConfig['showFirstLast'];
             $this->controller->internal['showRange'] = $browserConfig['showRange'];
             $this->controller->internal['dontLinkActivePage'] = $browserConfig['dontLinkActivePage'];
             $wrapArrFields = explode(',', 'disabledLinkWrap,inactiveLinkWrap,activeLinkWrap,browseLinksWrap,showResultsWrap,showResultsNumbersWrap,browseBoxWrap');
             $wrapArr = array();
             foreach ($wrapArrFields as $key) {
                 if ($browserConfig[$key]) {
                     $wrapArr[$key] = $browserConfig[$key];
                 }
             }
             if ($wrapArr['showResultsNumbersWrap'] && strpos($this->controller->LOCAL_LANG[$this->controller->LLkey]['pi_list_browseresults_displays'], '%s')) {
                 // if the advanced pagebrowser is enabled and the "pi_list_browseresults_displays" label contains %s it will be replaced with the content of the label "pi_list_browseresults_displays_advanced"
                 $this->controller->LOCAL_LANG[$this->controller->LLkey]['pi_list_browseresults_displays'] = $this->controller->LOCAL_LANG[$this->controller->LLkey]['pi_list_browseresults_displays_advanced'];
             }
             if (!$browserConfig['showPBrowserText']) {
                 $this->controller->LOCAL_LANG[$this->controller->LLkey]['pi_list_browseresults_page'] = '';
             }
             $this->controller->pi_alwaysPrev = $browserConfig['alwaysPrev'];
             // if there is a GETvar in the URL that is not in this list, caching will be disabled for the pagebrowser links
             $this->controller->pi_isOnlyFields = $this->pointerName . ',view,model,category,type,getdate,uid';
             // pi_lowerThan limits the amount of cached pageversions for the list view. Caching will be disabled if one of the vars in $this->pi_isOnlyFields has a value greater than $this->pi_lowerThan
             // $this->pi_lowerThan = ceil($this->internal['res_count']/$this->internal['results_at_a_time']);
             $pi_isOnlyFieldsArr = explode(',', $this->controller->pi_isOnlyFields);
             $highestVal = 0;
             foreach ($pi_isOnlyFieldsArr as $k => $v) {
                 $val = $this->controller->piVars[$v];
                 if (is_array($this->controller->piVars[$v])) {
                     $val = $this->controller->piVars[$v][0];
                 }
                 if ($val > $highestVal) {
                     $highestVal = $val;
                 }
             }
             $this->controller->pi_lowerThan = $highestVal + 1;
             $pb = $this->controller->pi_list_browseresults($browserConfig['showResultCount'], $browserConfig['tableParams'], $wrapArr, $this->pointerName, $browserConfig['hscText']);
         } else {
             // use default page browser of cal
             $browserConfig = $this->conf['view.']['list.']['pageBrowser.']['default.'];
             $this->offset = intval($this->controller->piVars[$this->pointerName]);
             $pagesTotal = intval($this->recordsPerPage) == 0 ? 1 : ceil($this->count / $this->recordsPerPage);
             $nextPage = $this->offset + 1;
             $previousPage = $this->offset - 1;
             $pagesCount = $this->conf['view.']['list.']['pageBrowser.']['pagesCount'] - 1;
             $min = 1;
             $max = $pagesTotal;
             if ($pagesTotal > $pagesCount + 1 && $pagesCount > 0) {
                 $pstart = $this->offset - ceil(($pagesCount - 2) / 2);
                 if ($pstart < 1) {
                     $pstart = 1;
                 }
                 $pend = $pstart + $pagesCount;
                 if ($pend > $pagesTotal - 1) {
                     $pend = $pagesTotal - 1;
                 }
                 $spacer = $this->local_cObj->cObjGetSingle($browserConfig['spacer'], $browserConfig['spacer.']);
             } else {
                 $pstart = $min;
                 $pend = $pagesTotal;
             }
             $pbMarker['###PAGEOF###'] = sprintf($this->controller->pi_getLL('l_page_of'), $this->offset + 1, $pagesTotal);
             // Extra Single Marker
             $pbMarker['###PAGE###'] = $this->offset + 1;
             $pbMarker['###PAGETOTAL###'] = $pagesTotal;
             // next+previous
             $this->initLocalCObject();
             $pbMarker['###NEXT###'] = '';
             if ($nextPage + 1 <= $pagesTotal) {
                 $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array($this->pointerName => $nextPage), $this->conf['cache']);
                 $pbMarker['###NEXT###'] = $this->local_cObj->cObjGetSingle($browserConfig['nextLink'], $browserConfig['nextLink.']);
             }
             $pbMarker['###PREVIOUS###'] = '';
             if ($previousPage >= 0) {
                 $previousPage = $previousPage == 0 ? NULL : $previousPage;
                 $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array($this->pointerName => $previousPage), $this->conf['cache']);
                 $pbMarker['###PREVIOUS###'] = $this->local_cObj->cObjGetSingle($browserConfig['prevLink'], $browserConfig['prevLink.']);
             }
             for ($i = $min; $i <= $max; $i++) {
                 if ($this->offset + 1 == $i) {
                     $pbMarker['###PAGES###'] .= $this->cObj->stdWrap($i, $browserConfig['actPage_stdWrap.']);
                 } else {
                     if ($i == 1 || $i == $max || $i > 1 && $i >= $pstart && $i <= $pend && $i < $max) {
                         $this->local_cObj->setCurrentVal($i);
                         $pageNum = $i - 1;
                         $pageNum = $pageNum == 0 ? NULL : $pageNum;
                         $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array($this->pointerName => $pageNum), $this->conf['cache']);
                         $pbMarker['###PAGES###'] .= $this->local_cObj->cObjGetSingle($browserConfig['pageLink'], $browserConfig['pageLink.']);
                     } elseif ($i == 2 && $i < $pstart || $i == $pend + 1 && $i < $max) {
                         unset($this->local_cObj->data['link_parameter']);
                         $pbMarker['###PAGES###'] .= $spacer;
                     }
                 }
             }
             $pb = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($template, $pbMarker, array(), array());
         }
     }
     return $pb;
 }
Example #15
0
 function getCreateExceptionMarker(&$template, &$sims, &$rems, &$wrapped)
 {
     if ($this->object->isClone() && $this->rightsObj->isAllowedToCreateExceptionEvent()) {
         $local_sims['###ACTION_EXCEPTION_URL###'] = $this->controller->pi_linkTP_keepPIvars_url(array('view' => 'save_exception_event', 'type' => null, 'uid' => null));
         $local_sims['###L_CREATE_EXCEPTION###'] = $this->controller->pi_getLL('l_create_exception');
         $local_sims['###L_TITLE###'] = $this->controller->pi_getLL('l_event_title');
         $eventStart = $this->object->getStart();
         $eventEnd = $this->object->getEnd();
         $local_sims['###EVENT_START_DAY###'] = $eventStart->format('%Y%m%d');
         $local_sims['###EVENT_END_DAY###'] = $eventEnd->format('%Y%m%d');
         $local_sims['###EVENT_START_TIME###'] = $eventStart->format('%H%M');
         $local_sims['###EVENT_END_TIME###'] = $eventEnd->format('%H%M');
         $local_sims['###EVENT_UID###'] = $this->object->getUid();
         $rems['###CREATE_EXCEPTION###'] = $this->cObj->getSubpart($template, '###CREATE_EXCEPTION###');
         $rems['###CREATE_EXCEPTION###'] = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($rems['###CREATE_EXCEPTION###'], $local_sims, array(), array());
     } else {
         $rems['###CREATE_EXCEPTION###'] = '';
     }
 }
Example #16
0
 public function getFormStartMarker(&$template, &$sims, &$rems, &$wrapped)
 {
     $temp = $this->cObj->getSubpart($template, '###FORM_START###');
     $temp_sims = array();
     $temp_sims['###L_CREATE_CATEGORY###'] = $this->controller->pi_getLL('l_create_category');
     $temp_sims['###UID###'] = '';
     if ($this->isEditMode) {
         $temp_sims['###L_CREATE_CATEGORY###'] = $this->controller->pi_getLL('l_edit_category');
         $temp_sims['###UID###'] = $this->object->getUid();
     }
     $temp_sims['###TYPE###'] = 'tx_cal_category';
     $rems['###FORM_START###'] = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($temp, $temp_sims, array(), array());
 }
Example #17
0
 public function fillTemplate($subpartMarker)
 {
     $cObj =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'cobj');
     $page = $cObj->fileResource($this->templatePath);
     if ($page == '') {
         return \TYPO3\CMS\Cal\Utility\Functions::createErrorMessage('No ' . $this->objectType . ' template file found at: >' . $this->templatePath . '<.', 'Please make sure the path is correct and that you included the static template and double-check the path using the Typoscript Object Browser.');
     }
     $page = $cObj->getSubpart($page, $subpartMarker);
     if (!$page) {
         return \TYPO3\CMS\Cal\Utility\Functions::createErrorMessage('Could not find the >' . str_replace('###', '', $subpartMarker) . '< subpart-marker in ' . $this->templatePath, 'Please add the subpart >' . str_replace('###', '', $subpartMarker) . '< to your ' . $this->templatePath);
     }
     $rems = array();
     $sims = array();
     $wrapped = array();
     $this->getMarker($page, $sims, $rems, $wrapped);
     return $this->finish(\TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, $sims, $rems, $wrapped));
 }
Example #18
0
    public function drawIcs(&$master_array, $getdate, $sendHeaders = true, $limitAttendeeToThisEmail = '')
    {
        $this->_init($master_array);
        $this->limitAttendeeToThisEmail = $limitAttendeeToThisEmail;
        $absFile = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($this->conf['view.']['ics.']['icsTemplate']);
        $page = \TYPO3\CMS\Core\Utility\GeneralUtility::getURL($absFile);
        if ($page == '') {
            // return '<h3>calendar: no ics template file found:</h3>'.$this->conf['view.']['ics.']['icsTemplate'];
            // falling back to default:
            $page = 'BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//TYPO3/NONSGML Calendar Base (cal) V###CAL_VERSION###//EN
METHOD:###METHOD###
<!--###EVENT### start-->
<!--###EVENT### end-->
END:VCALENDAR
			';
        }
        $ics_events = '';
        $select = 'tx_cal_event_deviation.*,tx_cal_index.start_datetime,tx_cal_index.end_datetime';
        $table = 'tx_cal_event_deviation right outer join tx_cal_index on tx_cal_event_deviation.uid = tx_cal_index.event_deviation_uid';
        $oldView = $this->conf['view'];
        $this->conf['view'] = 'single_ics';
        foreach ($this->master_array as $eventDate => $eventTimeArray) {
            if (is_subclass_of($eventTimeArray, 'TYPO3\\CMS\\Cal\\Model\\Model')) {
                $ics_events .= $eventTimeArray->renderEventFor('ics');
            } else {
                foreach ($eventTimeArray as $key => $eventArray) {
                    foreach ($eventArray as $eventUid => $event) {
                        if (is_object($event)) {
                            $ics_events .= $event->renderEventFor('ics');
                            $where = 'tx_cal_event_deviation.parentid = ' . $event->getUid() . $this->cObj->enableFields('tx_cal_event_deviation');
                            $deviationResult = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where);
                            if ($deviationResult) {
                                while ($deviationRow = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($deviationResult)) {
                                    $start = new \TYPO3\CMS\Cal\Model\CalDate(substr($deviationRow['start_datetime'], 0, 8));
                                    $start->setHour(substr($deviationRow['start_datetime'], 8, 2));
                                    $start->setMinute(substr($deviationRow['start_datetime'], 10, 2));
                                    $end = new \TYPO3\CMS\Cal\Model\CalDate(substr($deviationRow['end_datetime'], 0, 8));
                                    $end->setHour(substr($deviationRow['end_datetime'], 8, 2));
                                    $end->setMinute(substr($deviationRow['end_datetime'], 10, 2));
                                    unset($deviationRow['start_datetime']);
                                    unset($deviationRow['end_datetime']);
                                    $new_event = new \TYPO3\CMS\Cal\Model\EventRecDeviationModel($event, $deviationRow, $start, $end);
                                    $ics_events .= $new_event->renderEventFor('ics');
                                }
                                $GLOBALS['TYPO3_DB']->sql_free_result($deviationResult);
                            }
                        }
                    }
                }
            }
        }
        $this->conf['view'] = $oldView;
        $rems = array();
        $rems['###EVENT###'] = strip_tags($ics_events);
        $title = '';
        if (!empty($this->master_array)) {
            if (is_subclass_of($this->master_array[0], 'TYPO3\\CMS\\Cal\\Model\\Model')) {
                $title = $this->master_array[0]->getTitle();
            } else {
                $title = $this->appendCalendarTitle($title);
                $title = $this->appendCategoryTitle($title);
            }
        } else {
            $title = $this->appendCalendarTitle($title);
            $title = $this->appendCategoryTitle($title);
        }
        if ($title == '') {
            $title = $getdate;
        }
        $title .= '.ics';
        $title = strtr($title, array(' ' => '', ',' => '_'));
        if ($sendHeaders) {
            header('Expires: 0');
            header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
            header('Content-Disposition: attachment; filename=' . $title);
            header('Content-Type: text/ics');
            header('Pragma: ');
            header('Cache-Control:');
        }
        include \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('cal') . 'ext_emconf.php';
        $myem_conf = array_pop($EM_CONF);
        $method = 'PUBLISH';
        if ($this->limitAttendeeToThisEmail) {
            $method = 'REQUEST';
        }
        $return = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, array('###CAL_VERSION###' => $myem_conf['version'], '###METHOD###' => $method, '###TIMEZONE###' => $this->cObj->cObjGetSingle($this->conf['view.']['ics.']['timezone'], $this->conf['view.']['ics.']['timezone.'])), $rems, array());
        return \TYPO3\CMS\Cal\Utility\Functions::removeEmptyLines($return);
    }
Example #19
0
 function sendNotification(&$event, $email, $templatePath, $titleText, $unsubscribeLink, $acceptLink = '', $declineLink = '', $ics = '')
 {
     $absFile = GeneralUtility::getFileAbsFileName($templatePath);
     $template = GeneralUtility::getURL($absFile);
     $htmlTemplate = $this->cObj->getSubpart($template, '###HTML###');
     $plainTemplate = $this->cObj->getSubpart($template, '###PLAIN###');
     $switch = array();
     $rems = array();
     $wrapped = array();
     $event->getMarker($htmlTemplate, $switch, $rems, $wrapped, 'notification');
     $switch['###CURRENT_USER###'] = $this->getModifyingUser($template);
     $switch['###UNSUBSCRIBE_LINK###'] = $unsubscribeLink;
     $switch['###ACCEPT_LINK###'] = $acceptLink;
     $switch['###DECLINE_LINK###'] = $declineLink;
     $htmlTemplate = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($htmlTemplate, $switch, $rems, $wrapped);
     $switch = array();
     $rems = array();
     $wrapped = array();
     $event->getMarker($plainTemplate, $switch, $rems, $wrapped, 'notification');
     $switch['###UNSUBSCRIBE_LINK###'] = $unsubscribeLink;
     $switch['###ACCEPT_LINK###'] = $acceptLink;
     $switch['###DECLINE_LINK###'] = $declineLink;
     $plainTemplate = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($plainTemplate, $switch, $rems, $wrapped);
     $plainTemplate = $event->finish($plainTemplate);
     $htmlTemplate = $event->finish($htmlTemplate);
     $switch = array();
     $rems = array();
     $wrapped = array();
     $event->getMarker($titleText, $switch, $rems, $wrapped, 'title');
     if (\TYPO3\CMS\Core\Utility\VersionNumberUtility::convertVersionNumberToInteger(TYPO3_version) < 4005010) {
         $this->mailer->subject = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($titleText, $switch, $rems, $wrapped);
     } else {
         $this->mailer->setSubject(\TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($titleText, $switch, $rems, $wrapped));
     }
     $this->sendEmail($email, $htmlTemplate, $plainTemplate);
 }
Example #20
0
 function getSubscriptionMarker(&$template, &$sims, &$rems, &$wrapped, $view)
 {
     $uid = $this->conf['uid'];
     $type = $this->conf['type'];
     $monitoring = $this->conf['monitor'];
     $getdate = $this->conf['getdate'];
     $captchaStr = 0;
     $rems['###SUBSCRIPTION###'] = '';
     $sims['###NOTLOGGEDIN_NOMONITORING_HEADING###'] = '';
     $sims['###NOTLOGGEDIN_NOMONITORING_SUBMIT###'] = '';
     $sims['###NOTLOGGEDIN_MONITORING_HEADING###'] = '';
     $sims['###NOTLOGGEDIN_MONITORING_SUBMIT###'] = '';
     $sims_temp['L_CAPTCHA_START_SUCCESS'] = '';
     $sims_temp['L_CAPTCHA_STOP_SUCCESS'] = '';
     // controller = &\TYPO3\CMS\Cal\Utility\Registry::Registry('basic','controller');
     $rightsObj =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'rightscontroller');
     // cObj = &\TYPO3\CMS\Cal\Utility\Registry::Registry('basic','cobj');
     $cObj =& $this->controller->cObj;
     if (($this->conf['allowSubscribe'] == 1 || $this->conf['subscribeFeUser'] == 1 && $rightsObj->isLoggedIn()) && $uid) {
         if ($monitoring != null && $monitoring != '') {
             $user_uid = $rightsObj->getUserId();
             switch ($monitoring) {
                 case 'start':
                     if ($user_uid > 0) {
                         $table = 'tx_cal_fe_user_event_monitor_mm';
                         $fields_values = array('uid_local' => $uid, 'uid_foreign' => $user_uid, 'tablenames' => 'fe_users', 'sorting' => 1, 'pid' => $this->conf['rights.']['create.']['event.']['saveEventToPid'], 'offset' => $this->conf['view.']['event.']['remind.']['time']);
                         $result = $GLOBALS['TYPO3_DB']->exec_INSERTquery($table, $fields_values);
                         if (FALSE === $result) {
                             throw new \RuntimeException('Could not write ' . $table . ' record to database: ' . $GLOBALS['TYPO3_DB']->sql_error(), 1431458137);
                         }
                         $pageTSConf = \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($this->conf['rights.']['create.']['event.']['saveEventToPid']);
                         $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($uid);
                     } else {
                         if ($this->conf['subscribeWithCaptcha'] == 1 && \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('captcha')) {
                             session_start();
                             $captchaStr = $_SESSION['tx_captcha_string'];
                             $_SESSION['tx_captcha_string'] = '';
                         } else {
                             $captchaStr = -1;
                         }
                         if ($captchaStr && $this->controller->piVars['captcha'] === $captchaStr || $this->conf['subscribeWithCaptcha'] == 0) {
                             // send confirm email!!
                             $email = $this->controller->piVars['email'];
                             $mailer = $mail = new \TYPO3\CMS\Core\Mail\MailMessage();
                             if (GeneralUtility::validEmail($this->conf['view.']['event.']['notify.']['emailAddress'])) {
                                 $mailer->setFrom(array($this->conf['view.']['event.']['notify.']['emailAddress'] => $this->conf['view.']['event.']['notify.']['fromName']));
                             }
                             if (GeneralUtility::validEmail($this->conf['view.']['event.']['notify.']['emailReplyAddress'])) {
                                 $mailer->setReplyTo(array($this->conf['view.']['event.']['notify.']['emailReplyAddress'] => $this->conf['view.']['event.']['notify.']['replyToName']));
                             }
                             $mailer->getHeaders()->addTextHeader('Organization: ', $this->conf['view.']['event.']['notify.']['organisation']);
                             $local_template = $cObj->fileResource($this->conf['view.']['event.']['notify.']['confirmTemplate']);
                             $htmlTemplate = $cObj->getSubpart($local_template, '###HTML###');
                             $plainTemplate = $cObj->getSubpart($local_template, '###PLAIN###');
                             $local_switch = array();
                             $local_rems = array();
                             $local_wrapped = array();
                             $this->getMarker($htmlTemplate, $local_switch, $local_rems, $local_wrapped, 'event');
                             $this->getMarker($plainTemplate, $local_switch, $local_rems, $local_wrapped, 'event');
                             $local_switch['###CONFIRM_LINK###'] = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $this->controller->pi_getPageLink($this->conf['view.']['event.']['notify.']['subscriptionViewPid'], '', array('tx_cal_controller[view]' => 'subscription', 'tx_cal_controller[monitor]' => 'start', 'tx_cal_controller[email]' => $email, 'tx_cal_controller[uid]' => $this->getUid(), 'tx_cal_controller[sid]' => md5($this->getUid() . $email . $this->getCreationDate())));
                             $local_switch['###EVENT_LINK###'] = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $this->controller->pi_getPageLink($this->conf['view.']['event.']['eventViewPid'], '', array('tx_cal_controller[view]' => 'event', 'tx_cal_controller[uid]' => $this->getUid(), 'tx_cal_controller[type]' => $this->getType(), 'tx_cal_controller[getdate]' => $this->getStart->format('%Y%m%d')));
                             $htmlTemplate = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($htmlTemplate, $local_switch, $local_rems, $local_wrapped);
                             $htmlTemplate = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($htmlTemplate, $local_switch, $local_rems, $local_wrapped);
                             $plainTemplate = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($plainTemplate, $local_switch, $local_rems, $local_wrapped);
                             $mailer->setSubject($this->conf['view.']['event.']['notify.']['confirmTitle']);
                             $rems['###SUBSCRIPTION###'] = $this->controller->pi_getLL('l_monitor_start_thanks');
                             $this->controller->finish($htmlTemplate);
                             $this->controller->finish($plainTemplate);
                             $mailer->setTo(array($email));
                             $mailer->setBody(strip_tags($plainTemplate), 'text/plain');
                             $mailer->addPart(\TYPO3\CMS\Cal\Utility\Functions::fixURI($htmlTemplate), 'text/html');
                             $mailer->send();
                             return;
                         } else {
                             $sims_temp['L_CAPTCHA_START_SUCCESS'] = $this->controller->pi_getLL('l_monitor_wrong_captcha');
                         }
                     }
                     break;
                 case 'stop':
                     if ($user_uid > 0) {
                         $table = 'tx_cal_fe_user_event_monitor_mm';
                         $where = 'uid_foreign = ' . $user_uid . ' AND uid_local = ' . $uid . ' AND tablenames = "fe_users"';
                         $GLOBALS['TYPO3_DB']->exec_DELETEquery($table, $where);
                     } else {
                         if ($this->conf['subscribeWithCaptcha'] == 1 && \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('captcha')) {
                             session_start();
                             $captchaStr = $_SESSION['tx_captcha_string'];
                             $_SESSION['tx_captcha_string'] = '';
                         } else {
                             $captchaStr = -1;
                         }
                         if ($captchaStr && $this->controller->piVars['captcha'] === $captchaStr || $this->conf['subscribeWithCaptcha'] == 0) {
                             $email = $this->controller->piVars['email'];
                             $table = 'tx_cal_unknown_users';
                             $select = 'crdate';
                             $where = 'email = "' . $email . '"';
                             $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where);
                             $crdate = 0;
                             if ($result) {
                                 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
                                     $crdate = $row['crdate'];
                                     break;
                                 }
                                 $GLOBALS['TYPO3_DB']->sql_free_result($result);
                             }
                             $mailer = $mail = new \TYPO3\CMS\Core\Mail\MailMessage();
                             $mailer->setFrom(array($this->conf['view.']['event.']['notify.']['emailAddress'] => $this->conf['view.']['event.']['notify.']['fromName']));
                             $mailer->setReplyTo(array($this->conf['view.']['event.']['notify.']['emailReplyAddress'] => $this->conf['view.']['event.']['notify.']['replyToName']));
                             $mailer->getHeaders()->addTextHeader('Organization: ', $this->conf['view.']['event.']['notify.']['organisation']);
                             $local_template = $cObj->fileResource($this->conf['view.']['event.']['notify.']['unsubscribeConfirmTemplate']);
                             $htmlTemplate = $cObj->getSubpart($local_template, '###HTML###');
                             $plainTemplate = $cObj->getSubpart($local_template, '###PLAIN###');
                             $local_switch = array();
                             $local_rems = array();
                             $local_wrapped = array();
                             $this->getMarker($htmlTemplate, $local_switch, $local_rems, $local_wrapped, 'event');
                             $local_switch['###CONFIRM_LINK###'] = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $this->controller->pi_getPageLink($this->conf['view.']['event.']['notify.']['subscriptionViewPid'], '', array('tx_cal_controller[view]' => 'subscription', 'tx_cal_controller[monitor]' => 'stop', 'tx_cal_controller[email]' => $email, 'tx_cal_controller[uid]' => $this->getUid(), 'tx_cal_controller[sid]' => md5($this->getUid() . $email . $crdate)));
                             $htmlTemplate = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($htmlTemplate, $local_switch, $local_rems, $local_wrapped);
                             $local_switch = array();
                             $local_rems = array();
                             $local_wrapped = array();
                             $this->getMarker($plainTemplate, $local_switch, $local_rems, $local_wrapped, 'event');
                             $local_switch['###CONFIRM_LINK###'] = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $this->controller->pi_getPageLink($this->conf['view.']['event.']['notify.']['subscriptionViewPid'], '', array('tx_cal_controller[view]' => 'subscription', 'tx_cal_controller[monitor]' => 'stop', 'tx_cal_controller[email]' => $email, 'tx_cal_controller[uid]' => $this->getUid(), 'tx_cal_controller[sid]' => md5($this->getUid() . $email . $crdate)));
                             $plainTemplate = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($plainTemplate, $local_switch, $local_rems, $local_wrapped);
                             $mailer->setSubject($this->conf['view.']['event.']['notify.']['unsubscribeConfirmTitle']);
                             $rems['###SUBSCRIPTION###'] = $this->controller->pi_getLL('l_monitor_stop_thanks');
                             $this->controller->finish($htmlTemplate);
                             $this->controller->finish($plainTemplate);
                             $mailer->setTo(array($email));
                             $mailer->setBody(strip_tags($plainTemplate), 'text/plain');
                             $mailer->addPart(\TYPO3\CMS\Cal\Utility\Functions::fixURI($htmlTemplate), 'text/html');
                             $mailer->send();
                             return;
                         } else {
                             $sims_temp['L_CAPTCHA_STOP_SUCCESS'] = $this->controller->pi_getLL('l_monitor_wrong_captcha');
                         }
                     }
                     break;
             }
         }
         /* If we have a logged in user */
         if ($rightsObj->isLoggedIn()) {
             $select = '*';
             $from_table = 'tx_cal_fe_user_event_monitor_mm';
             $whereClause = 'uid_foreign = ' . $rightsObj->getUserId() . ' AND uid_local = ' . $uid;
             $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $from_table, $whereClause, $groupBy = '', $orderBy = '', $limit = '');
             $found_one = false;
             // create a local cObj with a customized data array, that is allowed to be changed
             $this->initLocalCObject($this->getValuesAsArray());
             $this->local_cObj->setCurrentVal($this->controller->pi_getLL('l_monitor_event_logged_in_monitoring'));
             if ($result) {
                 while ($row1 = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
                     $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('view' => 'event', 'monitor' => 'stop', 'type' => $type, 'uid' => $uid), $this->conf['cache'], $this->conf['clear_anyway']);
                     $rems['###SUBSCRIPTION###'] = $this->local_cObj->cObjGetSingle($this->conf['view.'][$view . '.']['event.']['isMonitoringEventLink'], $this->conf['view.'][$view . '.']['event.']['isMonitoringEventLink.']);
                     $found_one = true;
                 }
                 $GLOBALS['TYPO3_DB']->sql_free_result($result);
             }
             if (!$found_one) {
                 $this->local_cObj->setCurrentVal($this->controller->pi_getLL('l_monitor_event_logged_in_nomonitoring'));
                 $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('view' => 'event', 'monitor' => 'start', 'type' => $type, 'uid' => $uid), $this->conf['cache'], $this->conf['clear_anyway']);
                 $rems['###SUBSCRIPTION###'] = $this->local_cObj->cObjGetSingle($this->conf['view.'][$view . '.']['event.']['isNotMonitoringEventLink'], $this->conf['view.'][$view . '.']['event.']['isNotMonitoringEventLink.']);
             }
         } else {
             /* Not a logged in user */
             /* If a CAPTCHA is required to subscribe, add a couple extra markers */
             if ($this->conf['subscribeWithCaptcha'] == 1 && \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('captcha')) {
                 $sims_temp['CAPTCHA_SRC'] = '<img src="' . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::siteRelPath('captcha') . 'captcha/captcha.php' . '" alt="" />';
                 $sims_temp['L_CAPTCHA_TEXT'] = $this->controller->pi_getLL('l_captcha_text');
                 $sims_temp['CAPTCHA_TEXT'] = '<input type="text" size=10 name="tx_cal_controller[captcha]" value="">';
             } else {
                 $sims_temp['CAPTCHA_SRC'] = '';
                 $sims_temp['L_CAPTCHA_TEXT'] = '';
                 $sims_temp['CAPTCHA_TEXT'] = '';
             }
             $notLoggedinNoMonitoring = $cObj->getSubpart($template, '###NOTLOGGEDIN_NOMONITORING###');
             $parameter = array('no_cache' => 1, 'view' => 'event', 'monitor' => 'start', 'type' => $type, 'uid' => $uid);
             $actionUrl = htmlspecialchars($this->controller->pi_linkTP_keepPIvars_url($parameter));
             $parameter2 = array('no_cache' => 1, 'getdate' => $getdate, 'view' => 'event', 'monitor' => 'stop');
             $actionUrl2 = htmlspecialchars($this->controller->pi_linkTP_keepPIvars_url($parameter2));
             $sims_temp['NOTLOGGEDIN_NOMONITORING_HEADING'] = $this->controller->pi_getLL('l_monitor_event_logged_in_nomonitoring');
             $sims_temp['NOTLOGGEDIN_NOMONITORING_SUBMIT'] = $this->controller->pi_getLL('l_submit');
             $sims_temp['L_ENTER_EMAIL'] = $this->controller->pi_getLL('l_enter_email');
             $sims_temp['ACTIONURL'] = $actionUrl;
             $monitor = \TYPO3\CMS\Cal\Controller\Controller::replace_tags($sims_temp, $notLoggedinNoMonitoring);
             $sims_temp['ACTIONURL'] = $actionUrl2;
             $notLoggedinMonitoring = $cObj->getSubpart($template, '###NOTLOGGEDIN_MONITORING###');
             $sims_temp['NOTLOGGEDIN_MONITORING_HEADING'] = $this->controller->pi_getLL('l_monitor_event_logged_in_monitoring');
             $sims_temp['NOTLOGGEDIN_MONITORING_SUBMIT'] = $this->controller->pi_getLL('l_submit');
             $sims_temp['L_ENTER_EMAIL'] = $this->controller->pi_getLL('l_enter_email');
             $monitor .= \TYPO3\CMS\Cal\Controller\Controller::replace_tags($sims_temp, $notLoggedinMonitoring);
             $rems['###SUBSCRIPTION###'] = $monitor;
         }
     } else {
         $rems['###SUBSCRIPTION###'] = '';
     }
 }
Example #21
0
 function getFormStartMarker(&$template, &$sims, &$rems)
 {
     $temp = $this->cObj->getSubpart($template, '###FORM_START###');
     $temp_sims = array();
     $temp_sims['###L_WRONG_SPLIT_SYMBOL_MSG###'] = str_replace('###DATE_SPLIT_SYMBOL###', $this->conf['dateConfig.']['splitSymbol'], $this->controller->pi_getLL('l_wrong_split_symbol_msg'));
     $temp_sims['###L_WRONG_DATE_MSG###'] = $this->controller->pi_getLL('l_wrong_date');
     $temp_sims['###L_WRONG_TIME_MSG###'] = $this->controller->pi_getLL('l_wrong_time');
     $temp_sims['###L_IS_IN_PAST_MSG###'] = $this->controller->pi_getLL('l_is_in_past');
     $rems['###FORM_START###'] = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($temp, $temp_sims, array(), array());
 }
Example #22
0
 public function getRssFromEvent($eventDate, &$event, $template)
 {
     $eventTemplate = $this->cObj->getSubpart($template, '###EVENT###');
     $rems = array();
     $sims = array();
     $wrapped = array();
     $event->getMarker($eventTemplate, $sims, $rems, $wrapped);
     $rssUrl = $this->config['siteUrl'] . $event->getLinkToEvent('', 'event', $eventDate, true);
     // replace square brackets [] in links with their URLcodes and replace the &-sign with its ASCII code
     $sims['###LINK###'] = preg_replace(array('/\\[/', '/\\]/', '/&/'), array('%5B', '%5D', '&#38;'), $rssUrl);
     $sims['###TITLE###'] = str_replace('&', '&amp;', $sims['###TITLE###']);
     // date should be ok
     $sims['###CREATE_DATE###'] = date('D, d M Y H:i:s O', $event->row['crdate']);
     if ($this->conf['view.']['rss.']['xmlFormat'] == 'atom03' || $this->conf['view.']['rss.']['xmlFormat'] == 'atom1') {
         $sims['###CREATE_DATE###'] = $this->getW3cDate($event->row['crdate']);
     }
     return \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($eventTemplate, $sims, $rems, array());
 }
Example #23
0
 function drawAdminPage()
 {
     $a = array();
     $rems = array();
     $this->_init($a);
     $this->checkAction();
     $page = $this->cObj->fileResource($this->conf['view.']['admin.']['adminTemplate']);
     if ($page == '') {
         return '<h3>calendar: no adminTemplate file found:</h3>' . $this->conf['view.']['admin.']['adminTemplate'];
     }
     $return = $page;
     $showCalendarForm = false;
     $showCategoryForm = false;
     $showEventForm = false;
     $showLocationForm = false;
     $showOrganizerForm = false;
     $this->initLocalCObject($this->getValuesAsArray());
     $feUserUid = $this->rightsObj->getUserId();
     $feGroupsArray = $this->rightsObj->getUserGroups();
     $isAdmin = $this->rightsObj->isCalAdmin();
     $createCalendarLink = '';
     if ($this->rightsObj->isAllowedTo("create", "calendar") && $this->rightsObj->isViewEnabled('create_calendar')) {
         $this->local_cObj->setCurrentVal($this->controller->pi_getLL('l_create_calendar'));
         $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('view' => 'create_calendar', 'type' => 'tx_cal_calendar'), $this->conf['cache'], $this->conf['clear_anyway'], $this->conf['view.']['calendar.']['createCalendarViewPid']);
         $createCalendarLink .= $this->local_cObj->cObjGetSingle($this->conf['view.']['calendar.']['calendar.']['addLink'], $this->conf['view.']['calendar.']['calendar.']['addLink.']);
         $showCalendarForm = true;
     } else {
         $rems['###CREATE_CALENDAR###'] = '';
     }
     if (!$this->rightsObj->isAllowedTo("edit", "calendar") || !$this->rightsObj->isViewEnabled('edit_calendar')) {
         $rems['###EDIT_CALENDAR###'] = '';
     } else {
         $showCalendarForm = true;
     }
     if (!$this->rightsObj->isAllowedTo("delete", "calendar") || !$this->rightsObj->isViewEnabled('delete_calendar')) {
         $rems['###DELETE_CALENDAR###'] = '';
     } else {
         $showCalendarForm = true;
     }
     if (!$this->rightsObj->isAllowedTo("delete", "calendar") && !$this->rightsObj->isAllowedTo("edit", "calendar")) {
         $rems['###CHOOSE_CALENDAR###'] = '';
     }
     if (!$showCalendarForm) {
         $rems['###CALENDAR_FORM###'] = '';
     }
     $createCategoryLink = '';
     if ($this->rightsObj->isAllowedTo("create", "category") && $this->rightsObj->isViewEnabled('create_category')) {
         $this->local_cObj->setCurrentVal($this->controller->pi_getLL('l_create_category'));
         $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('view' => 'create_category', 'type' => 'tx_cal_category'), $this->conf['cache'], $this->conf['clear_anyway'], $this->conf['view.']['category.']['createCategoryViewPid']);
         $createCategoryLink .= $this->local_cObj->cObjGetSingle($this->conf['view.']['category.']['category.']['addLink'], $this->conf['view.']['category.']['category.']['addLink.']);
         $showCategoryForm = true;
     } else {
         $rems['###CREATE_CATEGORY###'] = '';
     }
     if (!$this->rightsObj->isAllowedTo("edit", "category") || !$this->rightsObj->isViewEnabled('edit_category')) {
         $rems['###EDIT_CATEGORY###'] = '';
     } else {
         $showCategoryForm = true;
     }
     if (!$this->rightsObj->isAllowedTo("delete", "category") || !$this->rightsObj->isViewEnabled('delete_category')) {
         $rems['###DELETE_CATEGORY###'] = '';
     } else {
         $showCategoryForm = true;
     }
     if (!$this->rightsObj->isAllowedTo("delete", "category") && !$this->rightsObj->isAllowedTo("edit", "category")) {
         $rems['###CHOOSE_CATEGORY###'] = '';
     }
     if (!$showCategoryForm) {
         $rems['###CATEGORY_FORM###'] = '';
     }
     $createOrganizerLink = '';
     if ($this->rightsObj->isAllowedTo("create", "organizer") && $this->rightsObj->isViewEnabled('create_organizer')) {
         $this->local_cObj->setCurrentVal($this->controller->pi_getLL('l_create_organizer'));
         $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('view' => 'create_organizer'), $this->conf['cache'], $this->conf['clear_anyway'], $this->conf['view.']['organizer.']['createOrganizerViewPid']);
         $createOrganizerLink .= $this->local_cObj->cObjGetSingle($this->conf['view.']['organizer.']['organizer.']['addLink'], $this->conf['view.']['organizer.']['organizer.']['addLink.']);
         $showOrganizerForm = true;
     } else {
         $rems['###CREATE_ORGANIZER###'] = '';
     }
     if (!$this->rightsObj->isAllowedTo("edit", "organizer") || !$this->rightsObj->isViewEnabled('edit_organizer')) {
         $rems['###EDIT_ORGANIZER###'] = '';
     } else {
         $showOrganizerForm = true;
     }
     if (!$this->rightsObj->isAllowedTo("delete", "organizer") || !$this->rightsObj->isViewEnabled('delete_organizer')) {
         $rems['###DELETE_ORGANIZER###'] = '';
     } else {
         $showOrganizerForm = true;
     }
     if (!$this->rightsObj->isAllowedTo("delete", "organizer") && !$this->rightsObj->isAllowedTo("edit", "organizer")) {
         $rems['###CHOOSE_ORGANIZER###'] = '';
     }
     if (!$showOrganizerForm) {
         $rems['###ORGANIZER_FORM###'] = '';
     }
     $createLocationLink = '';
     if ($this->rightsObj->isAllowedTo("create", "location") && $this->rightsObj->isViewEnabled('create_location')) {
         $this->local_cObj->setCurrentVal($this->controller->pi_getLL('l_create_location'));
         $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('view' => 'create_location'), $this->conf['cache'], $this->conf['clear_anyway'], $this->conf['view.']['location.']['createLocationViewPid']);
         $createLocationLink .= $this->local_cObj->cObjGetSingle($this->conf['view.']['location.']['location.']['addLink'], $this->conf['view.']['location.']['location.']['addLink.']);
         $showLocationForm = true;
     } else {
         $rems['###CREATE_LOCATION###'] = '';
     }
     if (!$this->rightsObj->isAllowedTo("edit", "location") || !$this->rightsObj->isViewEnabled('edit_location')) {
         $rems['###EDIT_LOCATION###'] = '';
     } else {
         $showLocationForm = true;
     }
     if (!$this->rightsObj->isAllowedTo("delete", "location") || !$this->rightsObj->isViewEnabled('delete_location')) {
         $rems['###DELETE_LOCATION###'] = '';
     } else {
         $showLocationForm = true;
     }
     if (!$this->rightsObj->isAllowedTo("delete", "location") && !$this->rightsObj->isAllowedTo("edit", "location")) {
         $rems['###CHOOSE_LOCATION###'] = '';
     }
     if (!$showLocationForm) {
         $rems['###LOCATION_FORM###'] = '';
     }
     $createEventLink = '';
     if ($this->rightsObj->isAllowedTo("create", "event") && $this->rightsObj->isViewEnabled('create_event')) {
         $this->local_cObj->setCurrentVal($this->controller->pi_getLL('l_create_event'));
         $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('view' => 'create_event'), $this->conf['cache'], $this->conf['clear_anyway'], $this->conf['view.']['event.']['createEventViewPid']);
         $createEventLink .= $this->local_cObj->cObjGetSingle($this->conf['view.']['event.']['event.']['addLink'], $this->conf['view.']['event.']['event.']['addLink.']);
         $showEventForm = true;
     } else {
         $rems['###CREATE_EVENT###'] = '';
     }
     if (!$this->rightsObj->isAllowedTo("edit", "event") || !$this->rightsObj->isViewEnabled('edit_event')) {
         $rems['###EDIT_EVENT###'] = '';
     } else {
         $showEventForm = true;
     }
     if (!$this->rightsObj->isAllowedTo("delete", "event") || !$this->rightsObj->isViewEnabled('delete_event')) {
         $rems['###DELETE_EVENT###'] = '';
     } else {
         $showEventForm = true;
     }
     if (!$this->rightsObj->isAllowedTo("delete", "event") && !$this->rightsObj->isAllowedTo("edit", "event")) {
         $rems['###CHOOSE_EVENT###'] = '';
     }
     if (!$showEventForm) {
         $rems['###EVENT_FORM###'] = '';
     }
     // CALENDAR
     $calendarArray = $this->modelObj->findAllCalendar('tx_cal_calendar', $this->conf['pidList']);
     $editCalendarOptions = '<option value="">' . $this->controller->pi_getLL('l_select') . '</option>';
     foreach ($calendarArray['tx_cal_calendar'] as $calendar) {
         if ($calendar->isUserAllowedToEdit() || $calendar->isUserAllowedToDelete()) {
             $editCalendarOptions .= '<option value="' . $calendar->getUID() . '">' . $calendar->getTitle() . '</option>';
         }
     }
     $params = array('view' => 'edit_calendar', 'type' => 'tx_cal_calendar');
     $editCalendarParams = '';
     foreach ($params as $key => $value) {
         $editCalendarParams .= '<input type="hidden" value="' . $value . '" id="calendar_' . $key . '" name="' . $this->prefixId . '[' . $key . ']"/>';
     }
     // CATEGORY
     $categoryArrays = $this->modelObj->findAllCategories('cal_category_model', 'tx_cal_category', $this->conf['pidList']);
     $categoryArray = $categoryArrays['tx_cal_category'][0][0];
     $editCategoryOptions = '<option value="">' . $this->controller->pi_getLL('l_select') . '</option>';
     foreach ($categoryArray as $category) {
         if ($category->isUserAllowedToEdit() || $category->isUserAllowedToDelete()) {
             $editCategoryOptions .= '<option value="' . $category->getUid() . '" >' . $category->getTitle() . '</option>';
         }
     }
     $params = array('view' => 'edit_category', 'type' => 'tx_cal_category');
     $editCategoryParams = '';
     foreach ($params as $key => $value) {
         $editCategoryParams .= '<input type="hidden" value="' . $value . '" id="category_' . $key . '" name="' . $this->prefixId . '[' . $key . ']"/>';
     }
     // EVENT
     /*
      * $editEventOptions = '<option value="">'.$this->controller->pi_getLL('l_select').'</option>'; $eventArray = $this->modelObj->findAll('cal_event_model','tx_cal_phpicalendar','event', $this->conf['pidList']); unset($eventArray['legend']); foreach($eventArray as $timeArray){ foreach($timeArray as $eventArray){ foreach($eventArray as $event){ $editEventOptions .= '<option value="'.$event->getUid().'" >'.$event->getTitle().'</option>'; } } } $params = array ( 'view' => 'edit_event', 'type' => 'tx_cal_phpicalendar'); foreach($params as $key => $value){ $editEventParams .= '<input type="hidden" value="'.$value.'" name="'.$this->prefixId.'['.$key.']"/>'; } $params = array ( 'view' => 'delete_event', 'type' => 'tx_cal_phpicalendar'); foreach($params as $key => $value){ $deleteEventParams .= '<input type="hidden" value="'.$value.'" name="'.$this->prefixId.'['.$key.']"/>'; }
      */
     $confArr = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['cal']);
     $locationModel = $confArr['useLocationStructure'] ? $confArr['useLocationStructure'] : 'tx_cal_location';
     $organizerModel = $confArr['useOrganizerStructure'] ? $confArr['useOrganizerStructure'] : 'tx_cal_organizer';
     // LOCATION
     $locationArray = $this->modelObj->findAllLocations($locationModel, $this->conf['pidList']);
     $editLocationOptions = '<option value="">' . $this->controller->pi_getLL('l_select') . '</option>';
     foreach ((array) $locationArray as $location) {
         if ($location->isUserAllowedToEdit()) {
             $editLocationOptions .= '<option value="' . $location->getUID() . '" >' . $location->getName() . '</option>';
         }
     }
     $params = array('view' => 'edit_location', 'type' => $locationModel);
     $editLocationParams = '';
     foreach ($params as $key => $value) {
         $editLocationParams .= '<input type="hidden" value="' . $value . '" id="location_' . $key . '" name="' . $this->prefixId . '[' . $key . ']"/>';
     }
     // ORGANIZER
     $organizerArray = $this->modelObj->findAllOrganizer($organizerModel, $this->conf['pidList']);
     $editOrganizerOptions = '<option value="">' . $this->controller->pi_getLL('l_select') . '</option>';
     foreach ((array) $organizerArray as $organizer) {
         if ($organizer->isUserAllowedToEdit()) {
             $editOrganizerOptions .= '<option value="' . $organizer->getUID() . '" >' . $organizer->getName() . '</option>';
         }
     }
     $params = array('view' => 'edit_organizer', 'type' => $organizerModel);
     $editOrganizerParams = '';
     foreach ($params as $key => $value) {
         $editOrganizerParams .= '<input type="hidden" value="' . $value . '" id="organizer_' . $key . '" name="' . $this->prefixId . '[' . $key . ']"/>';
     }
     $selfUrl = $this->controller->pi_linkTP_keepPIvars_url();
     $sims = array('###L_ADMINISTRATION_VIEW###' => $this->controller->pi_getLL('l_administration_view'), '###L_CREATE###' => $this->controller->pi_getLL('l_create'), '###L_EDIT###' => $this->controller->pi_getLL('l_edit'), '###L_DELETE###' => $this->controller->pi_getLL('l_delete'), '###L_EVENT_LABEL###' => $this->controller->pi_getLL('l_event'), '###CREATE_CALENDAR_LINK###' => $createCalendarLink, '###CREATE_CATEGORY_LINK###' => $createCategoryLink, '###CREATE_ORGANIZER_LINK###' => $createOrganizerLink, '###CREATE_LOCATION_LINK###' => $createLocationLink, '###CREATE_EVENT_LINK###' => $createEventLink, '###EDIT_EVENT_URL###' => $editEventLink .= $selfUrl, '###EDIT_EVENT_PARAMETER###' => $editEventParams, '###EDIT_EVENT_OPTIONS###' => $editEventOptions, '###DELETE_EVENT_URL###' => $deleteEventLink .= $selfUrl, '###DELETE_EVENT_PARAMETER###' => $deleteEventParams, '###DELETE_EVENT_OPTIONS###' => $editEventOptions, '###L_CALENDAR_LABEL###' => $this->controller->pi_getLL('l_calendar'), '###EDIT_CALENDAR_URL###' => $editCalendarLink .= $selfUrl, '###EDIT_CALENDAR_PARAMETER###' => $editCalendarParams, '###EDIT_CALENDAR_OPTIONS###' => $editCalendarOptions, '###DELETE_CALENDAR_URL###' => $deleteCalendarLink .= $selfUrl, '###DELETE_CALENDAR_PARAMETER###' => $deleteCalendarParams, '###DELETE_CALENDAR_OPTIONS###' => $editCalendarOptions, '###L_CATEGORY_LABEL###' => $this->controller->pi_getLL('l_category'), '###EDIT_CATEGORY_URL###' => $editCategoryLink .= $selfUrl, '###EDIT_CATEGORY_PARAMETER###' => $editCategoryParams, '###EDIT_CATEGORY_OPTIONS###' => $editCategoryOptions, '###DELETE_CATEGORY_URL###' => $deleteCategoryLink .= $selfUrl, '###DELETE_CATEGORY_PARAMETER###' => $deleteCategoryParams, '###DELETE_CATEGORY_OPTIONS###' => $editCategoryOptions, '###L_LOCATION_LABEL###' => $this->controller->pi_getLL('l_location'), '###EDIT_LOCATION_URL###' => $editLocationLink .= $selfUrl, '###EDIT_LOCATION_PARAMETER###' => $editLocationParams, '###EDIT_LOCATION_OPTIONS###' => $editLocationOptions, '###DELETE_LOCATION_URL###' => $deleteLocationLink .= $selfUrl, '###DELETE_LOCATION_PARAMETER###' => $deleteLocationParams, '###DELETE_LOCATION_OPTIONS###' => $editLocationOptions, '###L_ORGANIZER_LABEL###' => $this->controller->pi_getLL('l_organizer'), '###EDIT_ORGANIZER_URL###' => $editOrganizerLink .= $selfUrl, '###EDIT_ORGANIZER_PARAMETER###' => $editOrganizerParams, '###EDIT_ORGANIZER_OPTIONS###' => $editOrganizerOptions, '###DELETE_ORGANIZER_URL###' => $deleteOrganizerLink .= $selfUrl, '###DELETE_ORGANIZER_PARAMETER###' => $deleteOrganizerParams, '###DELETE_ORGANIZER_OPTIONS###' => $editOrganizerOptions);
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, $sims, array(), array());
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, array(), $rems, array());
     $a = array();
     return $this->finish($page, $a);
 }
Example #24
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;
 }
Example #25
0
 public function initTemplate(&$page)
 {
     if ($page == '') {
         $page = $this->cObj->fileResource($this->conf['view.']['search.']['searchResult' . ucwords($this->objectType) . 'Template']);
         if ($page == '') {
             $this->error = true;
             $this->errorMessage = 'No search ' . $this->objectType . ' result template file found for "view.search.searchResult' . ucwords($this->objectType) . 'Template" at >' . $this->conf['view.']['search.']['searchResult' . ucwords($this->objectType) . 'Template'] . '<';
             $this->suggestMessage = 'Please make sure the path is correct and that you included the static template and double-check the path using the Typoscript Object Browser.';
             return;
         }
     }
     if ($this->conf['view'] == 'search_all') {
         $rems['###SEARCHFORM###'] = '';
         $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, array(), $rems, array());
     }
     $this->page = $page;
 }
Example #26
0
 function fillTemplate($subpartMarker)
 {
     $cObj =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'cobj');
     $templatePath = $this->parentEvent->conf['view.']['event.']['eventModelTemplate'];
     $page = $cObj->fileResource($templatePath);
     if ($page == '') {
         return '<h3>calendar: no event model template file found:</h3>' . $templatePath;
     }
     $page = $cObj->getSubpart($page, $subpartMarker);
     if (!$page) {
         return 'could not find the >' . str_replace('###', '', $subpartMarker) . '< subpart-marker in ' . $templatePath;
     }
     $rems = array();
     $sims = array();
     $wrapped = array();
     $this->getMarker($page, $sims, $rems, $wrapped, $this->parentEvent->conf['alternateRenderingView'] ? $this->parentEvent->conf['alternateRenderingView'] : '');
     return $this->parentEvent->finish(\TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, $sims, $rems, $wrapped));
 }
Example #27
0
 protected function translateLanguageMarker(&$content)
 {
     // translate leftover markers
     preg_match_all('!(###|%%%)([A-Z0-9_-|]*)\\_LABEL\\1!is', $content, $match);
     $allLanguageMarkers = array_unique($match[2]);
     if (count($allLanguageMarkers)) {
         $controller =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'controller');
         $sims = array();
         foreach ($allLanguageMarkers as $key => $marker) {
             $wrapper = $match[1][$key];
             $label = $controller->pi_getLL('l_' . strtolower($marker));
             if ($label == '') {
                 $label = $controller->pi_getLL('l_event_' . strtolower($marker));
             }
             $sims[$wrapper . $marker . '_LABEL' . $wrapper] = $label;
         }
         if (count($sims)) {
             $content = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($content, $sims, array(), array());
         }
     }
     return $content;
 }
Example #28
0
 /**
  * Main function to draw the subscription manager view.
  * 
  * @return string output of the subscription manager.
  */
 function drawSubscriptionManager()
 {
     $rems = array();
     $sims = array();
     $wrapped = array();
     $sims['###HEADING###'] = $this->controller->pi_getLL('l_manage_subscription');
     $sims['###STATUS###'] = '';
     $rems['###USER_LOGIN###'] = '';
     $rems['###SUBSCRIPTION_CONTAINER###'] = '';
     /* Get the subscription manager template */
     $page = $this->cObj->fileResource($this->conf['view.']['event.']['subscriptionManagerTemplate']);
     if ($page == '') {
         return '<h3>calendar: no event template file found:</h3>' . $this->conf['view.']['event.']['subscriptionManagerTemplate'];
     }
     $eventUID = strip_tags($this->controller->piVars['uid']);
     $email = strip_tags($this->controller->piVars['email']);
     $subscriptionHash = strip_tags($this->controller->piVars['sid']);
     /* If we have an event, email, and subscription id, try to subscribe or unsubscribe */
     if ($eventUID > 0 && $email && $subscriptionHash) {
         $event = $this->modelObj->findEvent($eventUID, 'tx_cal_phpicalendar', $this->conf['pidList']);
         if (is_object($event)) {
             unset($this->controller->piVars['monitor']);
             unset($this->controller->piVars['email']);
             unset($this->controller->piVars['sid']);
             $local_rems = array();
             $local_sims = array();
             $local_wrapped = array();
             $status = $this->cObj->getSubpart($page, '###STATUS###');
             switch ($this->conf['monitor']) {
                 case 'stop':
                     /* Unsubscribe a user */
                     if ($this->unsubscribe($email, $event, $subscriptionHash)) {
                         $sims['###STATUS###'] = sprintf($this->controller->pi_getLL('l_monitor_event_unsubscribe_successful'), $event->getTitle());
                     } else {
                         /* No user to unsubscribe. Output a message here? */
                         $sims['###STATUS###'] = sprintf($this->controller->pi_getLL('l_monitor_event_unsubscribe_error'), $event->getTitle());
                     }
                     break;
                 case 'start':
                     /* Subscribe a user */
                     if ($this->subscribe($email, $event, $subscriptionHash)) {
                         $status = $this->cObj->getSubpart($page, '###STATUS_START###');
                         $sims['###STATUS###'] = sprintf($this->controller->pi_getLL('l_monitor_event_subscribe_successful'), $event->getTitle());
                     } else {
                         /* No user to subscribe. Output a message here? */
                         $sims['###STATUS###'] = sprintf($this->controller->pi_getLL('l_monitor_event_subscribe_error'), $event->getTitle());
                     }
                     break;
             }
             // $event->getMarker($status, $local_rems, $local_sims, $local_wrapped);
             // $rems['###STATUS###'] = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($status, $local_sims, $local_rems, $local_wrapped);
         } else {
             $noeventmessage = $this->conf['monitor'] == 'stop' ? 'l_monitor_event_unsubscribe_noevent' : 'l_monitor_event_subscribe_noevent';
             $sims['###STATUS###'] = sprintf($this->controller->pi_getLL($noeventmessage));
         }
     } else {
         /* If there's a logged in user, show the subscription container */
         if ($this->conf['subscribeFeUser'] && $this->rightsObj->isLoggedIn()) {
             $subscriptionContainer = $this->cObj->getSubpart($page, '###SUBSCRIPTION_CONTAINER###');
             $return = '';
             $select = '*';
             $table = 'tx_cal_fe_user_event_monitor_mm, tx_cal_event';
             $where = 'tx_cal_event.uid = tx_cal_fe_user_event_monitor_mm.uid_local AND tx_cal_fe_user_event_monitor_mm.uid_foreign IN (' . $this->rightsObj->getUserId() . ')';
             $where .= ' AND tx_cal_event.deleted = 0 AND tx_cal_event.hidden = 0';
             $where .= ' AND tx_cal_event.pid IN (' . $this->conf['pidList'] . ')';
             /* Save to temporary variables */
             $remUid = $this->conf['uid'];
             $remType = $this->conf['type'];
             $result = $GLOBALS['TYPO3_DB']->exec_SELECTquery($select, $table, $where);
             $eventList = array();
             while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($result)) {
                 $local_rems = array();
                 $local_sims = array();
                 $local_wrapped = array();
                 $subscriptionContainer = $this->cObj->getSubpart($page, '###SUBSCRIPTION_CONTAINER###');
                 $event = $this->modelObj->findEvent($row['uid'], 'tx_cal_phpicalendar', $this->conf['pidList']);
                 $this->conf['uid'] = $row['uid'];
                 $this->conf['type'] = $event->getType();
                 $event->getMarker($subscriptionContainer, $local_sims, $local_rems, $local_wrapped);
                 $eventList[] = '<li>' . \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($subscriptionContainer, $local_sims, $local_rems, $local_wrapped) . '</li>';
             }
             $GLOBALS['TYPO3_DB']->sql_free_result($result);
             /* Restore from temporary variables */
             $this->conf['uid'] = $remUid;
             $this->conf['type'] = $remType;
             if (empty($eventList)) {
                 $return = 'No events found.';
             } else {
                 $return = '<ul>' . implode(chr(10), $eventList) . '</ul>';
             }
             $rems['###SUBSCRIPTION_CONTAINER###'] = $return;
         } else {
             /* Otherwise, request login or captcha validation */
             $sims['###STATUS###'] = 'You must be logged in to manage your event notifications.';
         }
     }
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, $sims, $rems, $wrapped);
     $rems = array();
     return $this->finish($page, $rems);
 }
Example #29
0
 /**
  * Draws the day view
  * 
  * @param $master_array array
  *        	to be drawn.
  * @param $getdate integer
  *        	of the event
  * @return string HTML output.
  */
 public function drawDay(&$master_array, $getdate)
 {
     $this->_init($master_array);
     if ($this->conf['useNewTemplatesAndRendering']) {
         return $this->newDrawDay($master_array, $getdate);
     }
     $page = $this->cObj->fileResource($this->conf['view.']['day.']['dayTemplate']);
     if ($page == '') {
         return "<h3>day: no template file found:</h3>" . $this->conf['view.']['day.']['dayTemplate'] . "<br />Please check your template record and add both cal items at 'include static (from extension)'";
     }
     $dayTemplate = $this->cObj->getSubpart($page, '###DAY_TEMPLATE###');
     if ($dayTemplate == '') {
         $rems = array();
         return $this->finish($page, $rems);
     }
     $dayStart = $this->conf['view.']['day.']['dayStart'];
     // '0700'; // Start time for day grid
     $dayEnd = $this->conf['view.']['day.']['dayEnd'];
     // '2300'; // End time for day grid
     $gridLength = $this->conf['view.']['day.']['gridLength'];
     // '15'; // Grid distance in minutes for day view, multiples of 15 preferred
     if (!isset($getdate) || $getdate == '') {
         $getdate_obj = new \TYPO3\CMS\Cal\Model\CalDate();
         $getdate = $getdate_obj->format('%Y%m%d');
     }
     $day_array2 = array();
     preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})/', $getdate, $day_array2);
     $this_day = $day_array2[3];
     $this_month = $day_array2[2];
     $this_year = $day_array2[1];
     $unix_time = new \TYPO3\CMS\Cal\Model\CalDate($getdate . '000000');
     $this->initLocalCObject();
     $this->local_cObj->setCurrentVal($this->conf['view.']['day.']['legendNextDayLink']);
     $legend_next_day_link = $this->local_cObj->cObjGetSingle($this->conf['view.']['day.']['legendNextDayLink'], $this->conf['view.']['day.']['legendNextDayLink.']);
     $this->local_cObj->setCurrentVal($this->conf['view.']['day.']['legendPrevDayLink']);
     $legend_prev_day_link = $this->local_cObj->cObjGetSingle($this->conf['view.']['day.']['legendPrevDayLink'], $this->conf['view.']['day.']['legendPrevDayLink.']);
     $next_month_obj = new \TYPO3\CMS\Cal\Model\CalDate();
     $next_month_obj->copy($unix_time);
     $next_month_obj->addSeconds(604800);
     $next_month = $next_month_obj->format('%Y%m%d');
     $prev_month_obj = new \TYPO3\CMS\Cal\Model\CalDate();
     $prev_month_obj->copy($unix_time);
     $prev_month_obj->subtractSeconds(604801);
     $prev_month = $prev_month_obj->format('%Y%m%d');
     $dateOfWeek = Calc::beginOfWeek($this_day, $this_month, $this_year);
     $week_start_day = new \TYPO3\CMS\Cal\Model\CalDate($dateOfWeek . '000000');
     $start_day = $unix_time;
     $start_week_time = $start_day;
     $end_week_time = new \TYPO3\CMS\Cal\Model\CalDate();
     $end_week_time->copy($start_week_time);
     $end_week_time->addSeconds(604799);
     // Nasty fix to work with TS strftime
     $start_day_time = new \TYPO3\CMS\Cal\Model\CalDate($getdate . '000000');
     $start_day_time->setTZbyId('UTC');
     $end_day_time = \TYPO3\CMS\Cal\Controller\Calendar::calculateEndDayTime($start_day_time);
     $GLOBALS['TSFE']->register['cal_day_starttime'] = $start_day_time->getTime();
     $GLOBALS['TSFE']->register['cal_day_endtime'] = $end_day_time->getTime();
     $display_date = $this->cObj->cObjGetSingle($this->conf['view.']['day.']['titleWrap'], $this->conf['view.']['day.']['titleWrap.'], $TSkey = '__');
     $dayTemplate = $this->cObj->fileResource($this->conf['view.']['day.']['dayTemplate']);
     if ($dayTemplate == '') {
         return '<h3>calendar: no template file found:</h3>' . $this->conf['view.']['day.']['dayTemplate'] . '<br />Please check your template record and add both cal items at "include static (from extension)"';
     }
     $dayTemplate = $this->replace_files($dayTemplate, array('sidebar' => $this->conf['view.']['other.']['sidebarTemplate']));
     $sims = array('###GETDATE###' => $getdate, '###DISPLAY_DATE###' => $display_date, '###LEGEND_PREV_DAY###' => $legend_prev_day_link, '###LEGEND_NEXT_DAY###' => $legend_next_day_link, '###SIDEBAR_DATE###' => '');
     // Replaces the daysofweek
     $loop_dof = $this->cObj->getSubpart($dayTemplate, '###DAYSOFWEEK###');
     // Build the body
     $dayborder = 0;
     $out = '';
     $fillTime = sprintf('%04d', $dayStart);
     $day_array = array();
     while ($fillTime < $dayEnd) {
         array_push($day_array, $fillTime);
         $dTime = array();
         preg_match('/([0-9]{2})([0-9]{2})/', $fillTime, $dTime);
         $fill_h = $dTime[1];
         $fill_min = $dTime[2];
         $fill_min = sprintf('%02d', $fill_min + $gridLength);
         if ($fill_min == 60) {
             $fill_h = sprintf('%02d', $fill_h + 1);
             $fill_min = '00';
         }
         $fillTime = $fill_h . $fill_min;
     }
     $nbrGridCols = array();
     $dayborder = 0;
     $view_array = array();
     $rowspan_array = array();
     $eventArray = array();
     $endOfDay = new \TYPO3\CMS\Cal\Model\CalDate();
     $startOfDay = new \TYPO3\CMS\Cal\Model\CalDate();
     if (!empty($this->master_array)) {
         foreach ($this->master_array as $ovlKey => $ovlValue) {
             $dTimeStart = array();
             $dTimeEnd = array();
             $dDate = array();
             preg_match('/([0-9]{2})([0-9]{2})/', $dayStart, $dTimeStart);
             preg_match('/([0-9]{2})([0-9]{2})/', $dayEnd, $dTimeEnd);
             preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})/', $ovlKey, $dDate);
             $d_start = new \TYPO3\CMS\Cal\Model\CalDate($dDate[1] . $dDate[2] . $dDate[3] . ' ' . $dTimeStart[1] . ':' . $dTimeStart[2] . ':00');
             $d_start->setTZbyId('UTC');
             $d_end = new \TYPO3\CMS\Cal\Model\CalDate($dDate[1] . $dDate[2] . $dDate[3] . ' ' . $dTimeEnd[1] . ':' . $dTimeEnd[2] . ':00');
             $d_end->setTZbyId('UTC');
             foreach ($ovlValue as $ovl_time_key => $ovl_time_Value) {
                 foreach ($ovl_time_Value as $event) {
                     $eventStart = $event->getStart();
                     $eventArray[$event->getType() . '_' . $event->getUid() . '_' . $eventStart->format('%Y%m%d%H%M')] = $event;
                     $starttime = new \TYPO3\CMS\Cal\Model\CalDate();
                     $endtime = new \TYPO3\CMS\Cal\Model\CalDate();
                     $j = new \TYPO3\CMS\Cal\Model\CalDate();
                     if ($ovl_time_key == '-1') {
                         $starttime->copy($event->getStart());
                         $endtime->copy($event->getEnd());
                         $endtime->addSeconds(1);
                         for ($j->copy($starttime); $j->before($endtime) && $j->before($end_week_time); $j->addSeconds(86400)) {
                             $view_array[$j->format('%Y%m%d')]['-1'][] = $event->getType() . '_' . $event->getUid() . '_' . $eventStart->format('%Y%m%d%H%M');
                         }
                     } else {
                         $starttime->copy($event->getStart());
                         $starttime->subtractSeconds($starttime->getMinute() % $gridLength * 60);
                         $endtime->copy($event->getEnd());
                         $endtime->subtractSeconds($endtime->getMinute() % $gridLength * 60);
                         $entries = 1;
                         $old_day = new \TYPO3\CMS\Cal\Model\CalDate($ovlKey . '000000');
                         $old_day->setTZbyId('UTC');
                         $endOfDay->copy($d_end);
                         $startOfDay->copy($d_start);
                         // $d_start -= $gridLength * 60;
                         for ($k = 0; $k < count($view_array[$ovlKey]); $k++) {
                             if (empty($view_array[$starttime->format('%Y%m%d')][$starttime->format('%H%M')][$k])) {
                                 break;
                             }
                         }
                         $j->copy($starttime);
                         if ($j->before($startOfDay)) {
                             $j->copy($startOfDay);
                         }
                         while ($j->before($endtime) && $j->before($end_week_time)) {
                             if ($j->after($endOfDay)) {
                                 $rowspan_array[$old_day->format('%Y%m%d')][$event->getType() . '_' . $event->getUid() . '_' . $eventStart->format('%Y%m%d%H%M')] = $entries - 1;
                                 $endOfDay->addSeconds(60 * 60 * 24);
                                 $old_day->copy($endOfDay);
                                 $startOfDay->addSeconds(60 * 60 * 24);
                                 $j->copy($startOfDay);
                                 $entries = 0;
                                 for ($k = 0; $k < count($view_array[$startOfDay->format('%Y%m%d')]); $k++) {
                                     if (empty($view_array[$d_start->format('%Y%m%d')][$startOfDay->format('%H%M')][$k])) {
                                         break;
                                     }
                                 }
                             } else {
                                 $view_array[$j->format('%Y%m%d')][$j->format('%H%M')][] = $event->getType() . '_' . $event->getUid() . '_' . $eventStart->format('%Y%m%d%H%M');
                                 $j->addSeconds($gridLength * 60);
                             }
                             $entries++;
                         }
                         $rowspan_array[$old_day->format('%Y%m%d')][$event->getType() . '_' . $event->getUid() . '_' . $eventStart->format('%Y%m%d%H%M')] = $entries - 1;
                     }
                 }
             }
         }
     }
     if ($this->conf['view.']['day.']['dynamic'] == 1) {
         $dayStart = '2359';
         $dayEnd = '0000';
         if (is_array($view_array[$getdate])) {
             $timeKeys = array_keys($view_array[$getdate]);
             $formatedLast = array_pop($timeKeys);
             $formatedFirst = $formatedLast;
             foreach ($timeKeys as $timeKey) {
                 if ($timeKey > 0) {
                     $formatedFirst = $timeKey;
                     break;
                 }
             }
             if (intval($formatedFirst) > 0 && intval($formatedFirst) < intval($dayStart)) {
                 $dayStart = sprintf("%04d", $formatedFirst);
             }
             if (intval($formatedLast) > intval($dayEnd)) {
                 $dayEnd = sprintf("%04d", $formatedLast + $gridLength);
             }
         }
         $dayStart = substr($dayStart, 0, 2) . '00';
     }
     if (!empty($view_array[$getdate])) {
         $max = array();
         foreach ($view_array[$getdate] as $array_time => $time_val) {
             $c = count($view_array[$getdate][$array_time]);
             array_push($max, $c);
         }
         $nbrGridCols[$getdate] = max($max);
     } else {
         $nbrGridCols[$getdate] = 1;
     }
     $isAllowedToCreateEvent = $this->rightsObj->isAllowedToCreateEvent();
     $start_day = $week_start_day;
     for ($i = 0; $i < 7; $i++) {
         $day_num = $start_day->format('%w');
         $daylink = $start_day->format('%Y%m%d');
         $weekday = $start_day->format($this->conf['view.']['day.']['dateFormatDay']);
         if ($daylink == $getdate) {
             $row1 = 'rowToday';
             $row2 = 'rowOn';
             $row3 = 'rowToday';
         } else {
             $row1 = 'rowOff';
             $row2 = 'rowOn';
             $row3 = 'rowOff';
         }
         $dayLinkViewTarget = $this->conf['view.']['dayLinkTarget'];
         if (($this->rightsObj->isViewEnabled($dayLinkViewTarget) || $this->conf['view.'][$dayLinkViewTarget . '.'][$dayLinkViewTarget . 'ViewPid']) && ($view_array[$daylink] || $isAllowedToCreateEvent)) {
             $this->initLocalCObject();
             $this->local_cObj->setCurrentVal($weekday);
             $this->local_cObj->data['view'] = $dayLinkViewTarget;
             $this->controller->getParametersForTyposcriptLink($this->local_cObj->data, array('getdate' => $daylink, 'view' => $dayLinkViewTarget, $this->pointerName => NULL), $this->conf['cache'], $this->conf['clear_anyway'], $this->conf['view.'][$dayLinkViewTarget . '.'][$dayLinkViewTarget . 'ViewPid']);
             $link = $this->local_cObj->cObjGetSingle($this->conf['view.'][$dayLinkViewTarget . '.'][$dayLinkViewTarget . 'ViewLink'], $this->conf['view.'][$dayLinkViewTarget . '.'][$dayLinkViewTarget . 'ViewLink.']);
         } else {
             $link = $weekday;
         }
         $start_day->addSeconds(86400);
         $search = array('###LINK###', '###DAYLINK###', '###ROW1###', '###ROW2###', '###ROW3###');
         $replace = array($link, $daylink, $row1, $row2, $row3);
         $loop_tmp = str_replace($search, $replace, $loop_dof);
         $weekday_loop .= $loop_tmp;
     }
     $rems['###DAYSOFWEEK###'] = $weekday_loop;
     // Replaces the allday events
     $replace = '';
     if (is_array($view_array[$getdate]['-1'])) {
         $loop_ad = $this->cObj->getSubpart($dayTemplate, '###LOOPALLDAY###');
         foreach ($view_array[$getdate]['-1'] as $uid => $allday) {
             $replace .= $eventArray[$allday]->renderEventForAllDay();
         }
     }
     $sims['###ALLDAY###'] = $replace;
     $view_array = $view_array[$getdate];
     $nbrGridCols = $nbrGridCols[$getdate] ? $nbrGridCols[$getdate] : 1;
     $t_array = array();
     $pos_array = array();
     preg_match('/([0-9]{4})([0-9]{2})([0-9]{2})/', $getdate, $dDate);
     preg_match('/([0-9]{2})([0-9]{2})/', $dayStart, $dTimeStart);
     preg_match('/([0-9]{2})([0-9]{2})/', $dayEnd, $dTimeEnd);
     $dTimeStart[2] -= $dTimeStart[2] % $gridLength;
     $dTimeEnd[2] -= $dTimeEnd[2] % $gridLength;
     $d_start = new \TYPO3\CMS\Cal\Model\CalDate($dDate[1] . $dDate[2] . $dDate[3] . ' ' . $dTimeStart[1] . ':' . sprintf("%02d", $dTimeStart[2]) . ':00');
     $d_start->setTZbyId('UTC');
     $d_end = new \TYPO3\CMS\Cal\Model\CalDate($dDate[1] . $dDate[2] . $dDate[3] . ' ' . $dTimeEnd[1] . ':' . sprintf("%02d", $dTimeEnd[2]) . ':00');
     $d_end->setTZbyId('UTC');
     $i = new \TYPO3\CMS\Cal\Model\CalDate();
     $i->copy($d_start);
     $i->setTZbyId('UTC');
     while ($i->before($d_end)) {
         $i_formatted = $i->format('%H%M');
         if (is_array($view_array[$i_formatted]) && count($view_array[$i_formatted]) > 0) {
             foreach ($view_array[$i_formatted] as $eventKey) {
                 $event =& $eventArray[$eventKey];
                 $eventStart = $event->getStart();
                 if (array_key_exists($event->getType() . $event->getUid() . '_' . $eventStart->format('%Y%m%d%H%M'), $pos_array)) {
                     $eventEnd = $event->getEnd();
                     $nd = $eventEnd->subtractSeconds($eventEnd->getMinute() % $gridLength * 60);
                     if ($i_formatted >= $nd) {
                         $t_array[$i_formatted][$pos_array[$event->getType() . $event->getUid() . '_' . $eventStart->format('%Y%m%d%H%M')]] = array('ended' => $event->getType() . '_' . $event->getUid() . '_' . $eventStart->format('%Y%m%d%H%M'));
                     } else {
                         $t_array[$i_formatted][$pos_array[$event->getType() . $event->getUid() . '_' . $eventStart->format('%Y%m%d%H%M')]] = array('started' => $event->getType() . '_' . $event->getUid() . '_' . $eventStart->format('%Y%m%d%H%M'));
                     }
                 } else {
                     for ($j = 0; $j < $nbrGridCols; $j++) {
                         if (count($t_array[$i_formatted][$j]) == 0 || !isset($t_array[$i_formatted][$j])) {
                             $pos_array[$event->getType() . $event->getUid() . '_' . $eventStart->format('%Y%m%d%H%M')] = $j;
                             $t_array[$i_formatted][$j] = array('begin' => $event->getType() . '_' . $event->getUid() . '_' . $eventStart->format('%Y%m%d%H%M'));
                             break;
                         }
                     }
                 }
             }
         } else {
             $t_array[$i_formatted] = '';
         }
         $i->addSeconds($gridLength * 60);
     }
     $event_length = array();
     $border = 0;
     $createOffset = intval($this->conf['rights.']['create.']['event.']['timeOffset']) * 60;
     $cal_time_obj = new \TYPO3\CMS\Cal\Model\CalDate($getdate . '000000');
     $cal_time_obj->setTZbyId('UTC');
     foreach ($t_array as $cal_time => $val) {
         preg_match('/([0-9]{2})([0-9]{2})/', $cal_time, $dTimeStart);
         $cal_time_obj->setHour($dTimeStart[1]);
         $cal_time_obj->setMinute($dTimeStart[2]);
         $key = $cal_time_obj->format($this->conf['view.']['day.']['timeFormatDay']);
         if (intval($dTimeStart[2]) == 0) {
             $daydisplay .= sprintf($this->conf['view.']['day.']['dayTimeCell'], 60 / $gridLength, $key, $gridLength);
         } elseif ($cal_time_obj->equals($d_start)) {
             $size_tmp = 60 - (int) substr($cal_time, 2, 2);
             $daydisplay .= sprintf($this->conf['view.']['day.']['dayTimeCell'], $size_tmp / $gridLength, $key, $gridLength);
         } else {
             $daydisplay .= sprintf($this->conf['view.']['day.']['dayTimeCell2'], $gridLength);
         }
         if ($dayborder == 0) {
             $class = ' ' . $this->conf['view.']['day.']['classDayborder'];
             $dayborder++;
         } else {
             $class = ' ' . $this->conf['view.']['day.']['classDayborder2'];
             $dayborder = 0;
         }
         if ($val != '' && count($val) > 0) {
             for ($i = 0; $i < count($val); $i++) {
                 if (!empty($val[$i])) {
                     $keys = array_keys($val[$i]);
                     switch ($keys[0]) {
                         case 'begin':
                             $event =& $eventArray[$val[$i][$keys[0]]];
                             $dayEndTime = new \TYPO3\CMS\Cal\Model\CalDate();
                             $dayEndTime->copy($event->getEnd());
                             $dayStartTime = new \TYPO3\CMS\Cal\Model\CalDate();
                             $dayStartTime->copy($event->getStart());
                             $rest = $dayStartTime->getMinute() % $gridLength;
                             $plus = 0;
                             if ($rest > 0) {
                                 $plus = 1;
                             }
                             if ($dayEndTime->after($d_end)) {
                                 $dayEndTime = $d_end;
                             }
                             if ($dayStartTime->before($d_start)) {
                                 $dayStartTime = $d_start;
                             }
                             $colSpan = $rowspan_array[$getdate][$val[$i][$keys[0]]];
                             $daydisplay .= sprintf($this->conf['view.']['day.']['dayEventPre'], $colSpan);
                             $daydisplay .= $event->renderEventForDay();
                             $daydisplay .= $this->conf['view.']['day.']['dayEventPost'];
                             // End event drawing
                             break;
                     }
                 }
             }
             if (count($val) < $nbrGridCols) {
                 $remember = 0;
                 // Render cells with events
                 for ($l = 0; $l < $nbrGridCols; $l++) {
                     if (!$val[$l]) {
                         $remember++;
                     } else {
                         if ($remember > 0) {
                             $daydisplay .= $this->getCreateEventLink('day', $this->conf['view.']['day.']['normalCell'], $cal_time_obj, $createOffset, $isAllowedToCreateEvent, $remember, $class, $cal_time);
                             $remember = 0;
                         }
                     }
                 }
                 // Render cells next to events
                 if ($remember > 0) {
                     $daydisplay .= $this->getCreateEventLink('day', $this->conf['view.']['day.']['normalCell'], $cal_time_obj, $createOffset, $isAllowedToCreateEvent, $remember, $class, $cal_time);
                     $remember = 0;
                 }
             }
         } else {
             // Render cells without events
             $daydisplay .= $this->getCreateEventLink('day', $this->conf['view.']['day.']['normalCell'], $cal_time_obj, $createOffset, $isAllowedToCreateEvent, $nbrGridCols, $class, $cal_time);
         }
         $daydisplay .= $this->conf['view.']['day.']['dayFinishRow'];
     }
     $dayTemplate = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($dayTemplate, $sims, array(), array());
     $rems['###DAYEVENTS###'] = $daydisplay;
     $page = \TYPO3\CMS\Cal\Utility\Functions::substituteMarkerArrayNotCached($page, array(), array('###DAY_TEMPLATE###' => $dayTemplate), array());
     return $this->finish($page, $rems);
 }