Exemplo n.º 1
0
 /**
  * Example:
  * require_once ('class.tx_cal_api.php');
  * $calAPI = new Api($this->cObj, &$conf);
  * $event = $calAPI->findEvent('2','tx_cal_phpicalendar');
  */
 function tx_cal_api_with(&$cObj, &$conf)
 {
     $this->cObj =& $cObj;
     $this->conf =& $conf;
     if (!$GLOBALS['TCA']) {
         $GLOBALS['TSFE']->includeTCA();
     }
     $this->conf['useInternalCaching'] = 1;
     $this->conf['cachingEngine'] = 'cachingFramework';
     $this->conf['writeCachingInfoToDevlog'] = 0;
     $GLOBALS['TSFE']->settingLocale();
     $this->controller = GeneralUtility::makeInstance('TYPO3\\CMS\\Cal\\Controller\\Controller');
     $this->controller->cObj =& $this->cObj;
     $this->controller->conf =& $this->conf;
     $this->controller->setWeekStartDay();
     $this->controller->cleanPiVarParam($this->piVars);
     $this->controller->clearPiVarParams();
     $this->controller->getParamsFromSession();
     $this->controller->initCaching();
     $this->controller->initConfigs();
     \TYPO3\CMS\Cal\Controller\Controller::initRegistry($this->controller);
     $this->rightsObj =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'rightscontroller');
     $this->rightsObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstanceService('cal_rights_model', 'rights');
     $this->rightsObj->setDefaultSaveToPage();
     $this->modelObj =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'modelcontroller');
     $this->modelObj = new \TYPO3\CMS\Cal\Controller\ModelController();
     $this->viewObj =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'viewcontroller');
     $this->viewObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Cal\\Controller\\ViewController');
     /*
      * $this->rightsObj = &\TYPO3\CMS\Cal\Utility\Registry::Registry('basic','rightscontroller'); $this->modelObj = &\TYPO3\CMS\Cal\Utility\Registry::Registry('basic','modelcontroller'); $this->viewObj = &\TYPO3\CMS\Cal\Utility\Registry::Registry('basic','viewcontroller');
      */
     return $this;
 }
Exemplo n.º 2
0
 /**
  * 
  */
 public function initConfigs()
 {
     // If an event record has been added through Insert Records, set some defaults.
     if ($this->conf['displayCurrentRecord']) {
         $data =& $this->cObj->data;
         $this->conf['pidList'] = $data['pid'];
         $this->conf['view.']['allowedViews'] = 'event';
         $this->conf['getdate'] = $this->conf['_DEFAULT_PI_VARS.']['getdate'] = $data['start_date'];
         $this->conf['uid'] = $this->conf['_DEFAULT_PI_VARS.']['uid'] = $data['uid'];
         $this->conf['type'] = $this->conf['_DEFAULT_PI_VARS.']['type'] = 'tx_cal_phpicalendar';
         $this->conf['view'] = $this->conf['_DEFAULT_PI_VARS.']['view'] = 'event';
     }
     if (!$this->conf['dontListenToPiVars']) {
         $this->pi_setPiVarDefaults();
         // Set default piVars from TS
     }
     // Jan 18032006 start
     if ($this->cObj->data['pi_flexform']) {
         $this->pi_initPIflexForm();
         // Init and get the flexform data of the plugin
         $piFlexForm = $this->cObj->data['pi_flexform'];
         $this->updateConfWithFlexform($piFlexForm);
     }
     // apply stdWrap to pages and pidList
     $this->conf['pages'] = $this->cObj->stdWrap($this->conf['pages'], $this->conf['pages.']);
     $this->conf['pidList'] = $this->cObj->stdWrap($this->conf['pidList'], $this->conf['pidList.']);
     Controller::updateIfNotEmpty($this->conf['pages'], $this->cObj->data['pages']);
     // don't use "updateIfNotEmpty" here, as the default value of "recursive" is 0 and thus not empty and will always override TS settings.
     if ($this->cObj->data['recursive']) {
         $this->conf['recursive'] = $this->cObj->data['recursive'];
     }
     $this->conf['pidList'] = $this->pi_getPidList($this->conf['pages'] . ',' . $this->conf['pidList'], $this->conf['recursive']);
     if (!$this->conf['pidList'] || $this->conf['pidList'] == '') {
         $this->error = true;
         return '<b>Calendar error: please configure the pidList (calendar plugin -> startingpoints or plugin.tx_cal_controller.pidList or for ics in constants)</b>';
     }
     if ($this->conf['language']) {
         $this->LLkey = $this->conf['language'];
     }
     $tempScriptRelPath = $this->scriptRelPath;
     $this->scriptRelPath = $this->locallangPath;
     $this->pi_loadLL();
     $this->scriptRelPath = $tempScriptRelPath;
     $this->conf['cache'] = 1;
     $GLOBALS['TSFE']->addCacheTags(array('cal'));
     $location = Controller::convertLinkVarArrayToList($this->piVars['location_ids']);
     if ($this->piVars['view'] == $this->piVars['lastview']) {
         unset($this->piVars['lastview']);
     }
     if ($this->piVars['getdate'] == '') {
         $this->conf['getdate'] = date('Ymd');
     } else {
         $this->conf['getdate'] = intval($this->piVars['getdate']);
     }
     if ($this->piVars['jumpto']) {
         $dp = GeneralUtility::makeInstance('TYPO3\\CMS\\Cal\\Controller\\DateParser');
         $dp->parse($this->piVars['jumpto'], $this->conf['dateParserConf.']);
         $newGetdate = $dp->getDateObjectFromStack();
         $this->conf['getdate'] = $newGetdate->format('%Y%m%d');
         unset($this->piVars['getdate']);
         unset($this->piVars['jumpto']);
     }
     // date and strtotime should be ok here
     if ($this->conf['getdate'] <= date('Ymd', strtotime($this->conf['view.']['startLinkRange'])) || $this->conf['getdate'] >= date('Ymd', strtotime($this->conf['view.']['endLinkRange']))) {
         // Set additional META-Tag for google et al
         $GLOBALS['TSFE']->additionalHeaderData['cal'] = '<meta name="robots" content="index,nofollow" />';
         // Set / override no_search for current page-object
         $GLOBALS['TSFE']->page['no_search'] = 0;
     }
     if (!$this->conf['dontListenToPiVars']) {
         $this->conf['view'] = htmlspecialchars(strip_tags($this->piVars['view']));
         $this->conf['lastview'] = htmlspecialchars(strip_tags($this->piVars['lastview']));
         $this->conf['uid'] = intval($this->piVars['uid']);
         $this->conf['type'] = htmlspecialchars(strip_tags($this->piVars['type']));
         $this->conf['monitor'] = htmlspecialchars(strip_tags($this->piVars['monitor']));
         $this->conf['gettime'] = intval($this->piVars['gettime']);
         $this->conf['postview'] = intval($this->piVars['postview']);
         $this->conf['page_id'] = intval($this->piVars['page_id']);
         $this->conf['option'] = htmlspecialchars(strip_tags($this->piVars['option']));
         $this->conf['switch_calendar'] = intval($this->piVars['switch_calendar']);
         $this->conf['location'] = $location;
         $this->conf['preview'] = intval($this->piVars['preview']);
     }
     if (!is_array($this->conf['view.']['allowedViews'])) {
         $this->conf['view.']['allowedViews'] = array_unique(GeneralUtility::trimExplode(',', str_replace('~', ',', $this->conf['view.']['allowedViews'])));
     }
     // only merge customViews if not empty. Otherwhise the array with allowedViews will have empty entries which will end up in wrong behavior in the rightsServies, which is checking for the number of allowed views.
     if (!empty($this->conf['view.']['customViews'])) {
         $this->conf['view.']['allowedViews'] = array_unique(array_merge($this->conf['view.']['allowedViews'], GeneralUtility::trimExplode(',', $this->conf['view.']['customViews'], 1)));
     }
     $allowedViewsByViewPid = $this->getAllowedViewsByViewPid();
     $this->conf['view.']['allowedViewsToLinkTo'] = array_unique(array_merge($this->conf['view.']['allowedViews'], $allowedViewsByViewPid));
     // change by Franz: if there is no view parameter given (empty), fall back to the first allowed view
     // This is necessary when you're not passing the viewParameter within the URL and like to handle the correct views based on seperate pages for each view.
     if (!$this->conf['view'] && $this->conf['view.']['allowedViews'][0]) {
         $this->conf['view'] = $this->conf['view.']['allowedViews'][0];
     }
     $this->getDateTimeObject = new \TYPO3\CMS\Cal\Model\CalDate($this->conf['getdate'] . '000000');
     if ($this->getDateTimeObject->month > 12) {
         $this->getDateTimeObject->month = 12;
     } else {
         if ($this->getDateTimeObject->month < 1) {
             $this->getDateTimeObject->month = 1;
         }
     }
     while (!\TYPO3\CMS\Cal\Model\Pear\Date\Calc::isValidDate($this->getDateTimeObject->day, $this->getDateTimeObject->month, $this->getDateTimeObject->year)) {
         if ($this->getDateTimeObject->day > 28) {
             $this->getDateTimeObject->day--;
         } else {
             if ($this->getDateTimeObject->day < 1) {
                 $this->getDateTimeObject->day = 1;
             }
         }
     }
     $this->getDateTimeObject->setTZbyId('UTC');
     $this->conf['day'] = $this->getDateTimeObject->getDay();
     $this->conf['month'] = $this->getDateTimeObject->getMonth();
     $this->conf['year'] = $this->getDateTimeObject->getYear();
     Controller::initRegistry($this);
     $rightsObj =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'rightscontroller');
     $rightsObj = GeneralUtility::makeInstanceService('cal_rights_model', 'rights');
     $rightsObj->setDefaultSaveToPage();
     $modelObj =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'modelcontroller');
     $modelObj = new \TYPO3\CMS\Cal\Controller\ModelController();
     $viewObj =& \TYPO3\CMS\Cal\Utility\Registry::Registry('basic', 'viewcontroller');
     $viewObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Cal\\Controller\\ViewController');
     $this->checkCalendarAndCategory();
     $this->conf['view'] = $rightsObj->checkView($this->conf['view']);
     $this->pointerName = $this->conf['view.']['list.']['pageBrowser.']['pointer'] ? $this->conf['view.']['list.']['pageBrowser.']['pointer'] : $this->pointerName;
     // links to files will be rendered with an absolute path
     if (in_array($this->conf['view'], array('ics', 'rss', 'singl_ics'))) {
         $GLOBALS['TSFE']->absRefPrefix = GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
     }
     $hookObjectsArr = $this->getHookObjectsArray('controllerClass');
     // Hook: configuration
     foreach ($hookObjectsArr as $hookObj) {
         if (method_exists($hookObj, 'configuration')) {
             $hookObj->configuration($this);
         }
     }
 }