/**
  * @test
  */
 public function extensionAlteringTable()
 {
     if (!t3lib_extMgm::isLoaded('aaa') || !t3lib_extMgm::isLoaded('bbb')) {
         $this->markTestSkipped('This test can only be run if the extensions aaa and bbb ' . 'from tests/res are installed.');
     }
     $this->importExtensions(array('bbb'), TRUE);
     $tableNames = $this->getDatabaseTables();
     $this->assertContains('tx_bbb_test', $tableNames, 'Check that extension bbb is installed. The extension can be found in Tests/Unit/Fixtures/Extensions/.');
     $this->assertContains('tx_aaa_test', $tableNames, 'Check that extension aaa is installed. The extension can be found in Tests/Unit/Fixtures/Extensions/.');
     // extension BBB extends an AAA table
     $columns = $this->db->admin_get_fields('tx_aaa_test');
     $this->assertContains('tx_bbb_test', array_keys($columns), self::DB_PERMISSIONS_MESSAGE);
 }
 /**
  * Init Function: here all the needed configuration values are stored in class variables..
  */
 function init()
 {
     $this->db = $GLOBALS['TYPO3_DB'];
     $this->tsfe = $GLOBALS['TSFE'];
     $this->pi_loadLL();
     // Loading language-labels
     $this->pi_setPiVarDefaults();
     // Set default piVars from TS
     $this->SIM_ACCESS_TIME = $GLOBALS['SIM_ACCESS_TIME'];
     // fallback for TYPO3 < 4.2
     if (!$this->SIM_ACCESS_TIME) {
         $simTime = $GLOBALS['SIM_EXEC_TIME'];
         $this->SIM_ACCESS_TIME = $simTime - $simTime % 60;
     }
     $this->initCaching();
     $this->local_cObj = t3lib_div::makeInstance('tslib_cObj');
     // Local cObj.
     $this->enableFields = $this->getEnableFields('tt_news');
     if ($this->tt_news_uid === 0) {
         // no tt_news_uid set by displayCurrentRecord
         $this->tt_news_uid = intval($this->piVars['tt_news']);
         // Get the submitted uid of a news (if any)
     }
     if (!isset($this->conf['compatVersion']) || !preg_match('/^\\d+\\.\\d+\\.\\d+$/', $this->conf['compatVersion'])) {
         $this->conf['compatVersion'] = $this->hObj->getCurrentVersion();
     }
     $this->token = md5(microtime());
     if (t3lib_extMgm::isLoaded('version')) {
         $this->versioningEnabled = true;
     }
     // load available syslanguages
     $this->initLanguages();
     // sys_language_mode defines what to do if the requested translation is not found
     $this->sys_language_mode = $this->conf['sys_language_mode'] ? $this->conf['sys_language_mode'] : $this->tsfe->sys_language_mode;
     if ($this->conf['searchFieldList']) {
         // get fieldnames from the tt_news db-table
         $this->fieldNames = array_keys($this->db->admin_get_fields('tt_news'));
         $searchFieldList = $this->hObj->validateFields($this->conf['searchFieldList'], $this->fieldNames);
         if ($searchFieldList) {
             $this->searchFieldList = $searchFieldList;
         }
     }
     // Archive:
     $archiveMode = trim($this->conf['archiveMode']);
     // month, quarter or year listing in AMENU
     $this->config['archiveMode'] = $archiveMode ? $archiveMode : 'month';
     // arcExclusive : -1=only non-archived; 0=don't care; 1=only archived
     $arcExclusive = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'archive', 'sDEF');
     $this->arcExclusive = $arcExclusive ? $arcExclusive : intval($this->conf['archive']);
     $this->config['datetimeDaysToArchive'] = intval($this->conf['datetimeDaysToArchive']);
     $this->config['datetimeHoursToArchive'] = intval($this->conf['datetimeHoursToArchive']);
     $this->config['datetimeMinutesToArchive'] = intval($this->conf['datetimeMinutesToArchive']);
     if ($this->conf['useHRDates']) {
         $this->hObj->convertDates();
     }
     // list of pages where news records will be taken from
     if (!$this->conf['dontUsePidList']) {
         $this->initPidList();
     }
     // itemLinkTarget is only used for categoryLinkMode 3 (catselector) in framesets
     $this->conf['itemLinkTarget'] = trim($this->conf['itemLinkTarget']);
     // id of the page where the search results should be displayed
     $this->config['searchPid'] = intval($this->conf['searchPid']);
     // pages in Single view will be divided by this token
     $this->config['pageBreakToken'] = trim($this->conf['pageBreakToken']) ? trim($this->conf['pageBreakToken']) : '<---newpage--->';
     $this->config['singleViewPointerName'] = trim($this->conf['singleViewPointerName']) ? trim($this->conf['singleViewPointerName']) : 'sViewPointer';
     $maxWordsInSingleView = intval($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'maxWordsInSingleView', 's_misc'));
     $maxWordsInSingleView = $maxWordsInSingleView ? $maxWordsInSingleView : intval($this->conf['maxWordsInSingleView']);
     $this->config['maxWordsInSingleView'] = $maxWordsInSingleView ? $maxWordsInSingleView : 0;
     $this->config['useMultiPageSingleView'] = $this->conf['useMultiPageSingleView'];
     // pid of the page with the single view. the old var PIDitemDisplay is still processed if no other value is found
     $singlePid = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'PIDitemDisplay', 's_misc');
     $this->config['singlePid'] = $singlePid ? $singlePid : intval($this->cObj->stdWrap($this->conf['singlePid'], $this->conf['singlePid.']));
     if (!$this->config['singlePid']) {
         $this->errors[] = 'No singlePid defined';
     }
     // pid to return to when leaving single view
     $backPid = intval($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'backPid', 's_misc'));
     $backPid = $backPid ? $backPid : intval($this->conf['backPid']);
     $backPid = $backPid ? $backPid : intval($this->piVars['backPid']);
     $backPid = $backPid ? $backPid : $this->tsfe->id;
     $this->config['backPid'] = $backPid;
     // max items per page
     $FFlimit = $this->compatibility()->intInRange($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'listLimit', 's_template'), 0, 1000);
     $limit = $this->compatibility()->intInRange($this->cObj->stdWrap($this->conf['limit'], $this->conf['limit.']), 0, 1000);
     $limit = $limit ? $limit : 50;
     $this->config['limit'] = $FFlimit ? $FFlimit : $limit;
     $latestLimit = $this->compatibility()->intInRange($this->cObj->stdWrap($this->conf['latestLimit'], $this->conf['latestLimit.']), 0, 1000);
     $latestLimit = $latestLimit ? $latestLimit : 10;
     $this->config['latestLimit'] = $FFlimit ? $FFlimit : $latestLimit;
     // orderBy and groupBy statements for the list Query
     $orderBy = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'listOrderBy', 'sDEF');
     $orderByTS = trim($this->conf['listOrderBy']);
     $orderBy = $orderBy ? $orderBy : $orderByTS;
     $this->config['orderBy'] = $orderBy;
     if ($orderBy) {
         $ascDesc = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'ascDesc', 'sDEF');
         $this->config['ascDesc'] = $ascDesc;
         if ($this->config['ascDesc']) {
             // remove ASC/DESC from 'orderBy' if it is already set from TS
             $this->config['orderBy'] = preg_replace('/( DESC| ASC)\\b/i', '', $this->config['orderBy']);
         }
     }
     $this->config['groupBy'] = trim($this->conf['listGroupBy']);
     // if this is set, the first image is handled as preview image, which is only shown in list view
     $fImgPreview = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'firstImageIsPreview', 's_misc');
     $this->config['firstImageIsPreview'] = $fImgPreview ? $fImgPreview : $this->conf['firstImageIsPreview'];
     $forcefImgPreview = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'forceFirstImageIsPreview', 's_misc');
     $this->config['forceFirstImageIsPreview'] = $forcefImgPreview ? $fImgPreview : $this->conf['forceFirstImageIsPreview'];
     // List start id
     //		$listStartId = intval($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'listStartId', 's_misc'));
     //		$this->config['listStartId'] = /*$listStartId?$listStartId:*/intval($this->conf['listStartId']);
     // supress pagebrowser
     $noPageBrowser = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'noPageBrowser', 's_template');
     $this->config['noPageBrowser'] = $noPageBrowser ? $noPageBrowser : $this->conf['noPageBrowser'];
     // image sizes/optionSplit given from FlexForms
     $this->config['FFimgH'] = trim($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'imageMaxHeight', 's_template'));
     $this->config['FFimgW'] = trim($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'imageMaxWidth', 's_template'));
     // Get number of alternative Layouts (loop layout in LATEST and LIST view) default is 2:
     $altLayouts = intval($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'alternatingLayouts', 's_template'));
     $altLayouts = $altLayouts ? $altLayouts : intval($this->conf['alternatingLayouts']);
     $this->alternatingLayouts = $altLayouts ? $altLayouts : 2;
     $altLayouts = trim($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'altLayoutsOptionSplit', 's_template'));
     $this->config['altLayoutsOptionSplit'] = $altLayouts ? $altLayouts : trim($this->conf['altLayoutsOptionSplit']);
     // Get cropping length
     $croppingLenghtOptionSplit = trim($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'croppingLenghtOptionSplit', 's_template'));
     $this->config['croppingLenghtOptionSplit'] = $croppingLenghtOptionSplit ? $croppingLenghtOptionSplit : trim($this->conf['croppingLenghtOptionSplit']);
     $this->config['croppingLenght'] = trim($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'croppingLenght', 's_template'));
     $this->initTemplate();
     // Configure caching
     $this->allowCaching = $this->conf['allowCaching'] ? 1 : 0;
     if (!$this->allowCaching) {
         $this->tsfe->set_no_cache();
     }
     // get siteUrl for links in rss feeds. the 'dontInsert' option seems to be needed in some configurations depending on the baseUrl setting
     if (!$this->conf['displayXML.']['dontInsertSiteUrl']) {
         $this->config['siteUrl'] = t3lib_div::getIndpEnv('TYPO3_SITE_URL');
     }
     if ($this->debugTimes) {
         $this->hObj->getParsetime(__METHOD__);
     }
 }
Example #3
0
 /**
  * Tests if a given table contains a given field.
  *
  * @param string $tablename Table name for which to check whether a given field exists in
  * @param string $fieldname Field name for which to check whether it exists in the given table
  * @param array $info Additional info, will be displayed as debug message, if a key "message" exists this will be appended to the error message
  */
 public static function tableAndFieldExist($tablename, $fieldname, $info = array())
 {
     self::initializeDbObj();
     return self::isArrayKey($fieldname, self::$dbObj->admin_get_fields($tablename), $info);
 }