/** * Initialize open authentication */ protected function initOAuth() { $this->oAuth = new Dropbox_OAuth_PHP($this->configuration->getDropboxConsumerKey(), $this->configuration->getDropboxConsumerSecret()); $oAuthTokens = $this->registry->get('tx_dlDropbox', 'oauth_tokens'); if (is_array($oAuthTokens) && array_key_exists('token_secret', $oAuthTokens) && $oAuthTokens['token_secret']) { $this->oAuth->setToken($oAuthTokens); $this->isAuthenticated = TRUE; } }
/** * @return void */ public function indexAction() { $selectedThemes = $this->registry->get('tx_yag', 'rfcSelectedThemes', serialize(array())); $selectedThemesArray = unserialize($selectedThemes); $themes = array(); $themeCollection = $this->configurationBuilder->buildThemeConfigurationCollection(); foreach ($themeCollection as $theme) { /** @var $theme Tx_Yag_Domain_Configuration_Theme_ThemeConfiguration */ $themes[$theme->getName()] = array('title' => $theme->getTitle(), 'description' => $theme->getDescription(), 'selected' => in_array($theme->getName(), $selectedThemesArray) ? $selectedThemesArray[$theme->getName()] : FALSE, 'system' => $theme->getName() == 'backend' ? TRUE : FALSE); } $this->view->assign('themes', $themes); }
/** * Delete all index elements that are older than starting timestamp in registry * * @return string content for BE */ function cleanUpIndex() { $content = ''; $startMicrotime = microtime(true); $table = 'tx_kesearch_index'; // select all index records older than the beginning of the indexing process $where = 'tstamp < ' . $this->registry->get('tx_kesearch', 'startTimeOfIndexer'); // hook for cleanup if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['cleanup'])) { foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['ke_search']['cleanup'] as $_classRef) { if (TYPO3_VERSION_INTEGER >= 7000000) { $_procObj =& TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($_classRef); } else { $_procObj =& t3lib_div::getUserObj($_classRef); } $content .= $_procObj->cleanup($where, $this); } } // count and delete old index records $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', $table, $where); $GLOBALS['TYPO3_DB']->exec_DELETEquery($table, $where); // check if Sphinx is enabled // in this case we have to update sphinx index, too. if ($this->extConfPremium['enableSphinxSearch']) { if (!$this->extConfPremium['sphinxIndexerName']) { $this->extConfPremium['sphinxIndexerConf'] = '--all'; } if (is_file($this->extConfPremium['sphinxIndexerPath']) && is_executable($this->extConfPremium['sphinxIndexerPath']) && file_exists($this->extConfPremium['sphinxSearchdPath']) && is_executable($this->extConfPremium['sphinxIndexerPath'])) { $found = preg_match_all('/exec|system/', ini_get('disable_functions'), $match); if ($found === 0) { // executables are allowed $ret = system($this->extConfPremium['sphinxIndexerPath'] . ' --rotate ' . $this->extConfPremium['sphinxIndexerName']); if (strpos($ret, 'WARNING') !== FALSE) { $warning = strstr($ret, 'WARNING'); $content .= '<div class="error">SPHINX ' . $warning . '</div>'; } $content .= $ret; } elseif ($found === 1) { // one executable is allowed if ($match[0] == 'system') { $ret = system($this->extConfPremium['sphinxIndexerPath'] . ' --rotate ' . $this->extConfPremium['sphinxIndexerName']); } else { // use exec exec($this->extConfPremium['sphinxIndexerPath'] . ' --rotate ' . $this->extConfPremium['sphinxIndexerName'], $retArr); foreach ($retArr as $retRow) { if (strpos($retRow, 'WARNING') !== FALSE) { $content .= '<div class="error">SPHINX ' . $retRow . '</div>'; } } $ret = implode(';', $retArr); } $content .= $ret; } else { $content .= '<div class="error">Check your php.ini configuration for disable_functions. For now it is not allowed to execute a shell script.</div>'; } } else { $content .= '<div class="error">We can\'t find the sphinx executables or execution permission is missing.</div>'; } } $content .= '<p><b>Index cleanup:</b><br />' . "\n"; $content .= $count . ' entries deleted.<br />' . "\n"; // calculate duration of indexing process $duration = ceil((microtime(true) - $startMicrotime) * 1000); $content .= '<i>Cleanup process took ' . $duration . ' ms.</i></p>' . "\n"; return $content; }
/** * @test */ public function getReturnsTheDefaultValueIfTheRequestedKeyWasNotFound() { $defaultValue = 'getReturnsTheDefaultValueIfTheRequestedKeyWasNotFound'; $GLOBALS['TYPO3_DB']->expects($this->once())->method('exec_SELECTgetRows')->with('*', 'sys_registry', 'entry_namespace = \'tx_phpunit\'')->will($this->returnValue(array(array('entry_key' => 'foo', 'entry_value' => 'bar')))); $this->assertEquals($defaultValue, $this->registry->get('tx_phpunit', 'someNonExistingKey', $defaultValue), 'A value other than the default value was returned.'); }