/** * Method updates TYPO3 database with up-to-date * extension version records. * * @access public * @param boolean $renderFlashMessage if method should return flashmessage or raw integer * @return mixed either sum of imported extensions or instance of t3lib_FlashMessage * @see isExtListUpdateNecessary() */ public function updateExtList($renderFlashMessage = FALSE) { if ($renderFlashMessage) { /* @var $flashMessage t3lib_FlashMessage */ $flashMessage = t3lib_div::makeInstance('t3lib_FlashMessage', $GLOBALS['LANG']->getLL('ext_import_list_unchanged_header'), $GLOBALS['LANG']->getLL('ext_import_list_unchanged'), t3lib_FlashMessage::INFO); } $sumRecords = 0; $updateNecessity = $this->isExtListUpdateNecessary(); if ($updateNecessity !== 0) { // retrieval of file necessary $tmpBitmask = self::PROBLEM_EXTENSION_FILE_NOT_EXISTING | self::PROBLEM_EXTENSION_HASH_CHANGED; if (($tmpBitmask & $updateNecessity) > 0) { $this->fetchExtListFile(); $updateNecessity &= ~$tmpBitmask; } // database table cleanup if ($updateNecessity & self::PROBLEM_NO_VERSIONS_IN_DATABASE) { $updateNecessity &= ~self::PROBLEM_NO_VERSIONS_IN_DATABASE; } else { $GLOBALS['TYPO3_DB']->exec_DELETEquery('cache_extensions', 'repository=' . $this->getRepositoryUID()); } // no further problems - start of import process if ($updateNecessity === 0) { $uid = $this->getRepositoryUID(TRUE); /* @var $objExtListImporter tx_em_Import_ExtensionListImporter */ $objExtListImporter = t3lib_div::makeInstance('tx_em_Import_ExtensionListImporter'); $objExtListImporter->import($this->getLocalExtListFile(), $uid); $sumRecords = tx_em_Database::getExtensionCountFromRepository($uid); if ($renderFlashMessage) { $flashMessage->setTitle($GLOBALS['LANG']->getLL('ext_import_extlist_updated_header')); $flashMessage->setMessage(sprintf($GLOBALS['LANG']->getLL('ext_import_extlist_updated'), tx_em_Database::getExtensionCountFromRepository())); $flashMessage->setSeverity(t3lib_FlashMessage::OK); } } } return $renderFlashMessage ? $flashMessage : $sumRecords; }
function showRepositoryUpdateForm() { $content = '<div class="em-repupdate"><strong>Repository:</strong>'; // print registered repositories /* @var $settings em_settings */ $settings = t3lib_div::makeInstance('tx_em_Settings'); $registeredRepos = $settings->getRegisteredRepositories(); $content .= '<select>'; foreach ($registeredRepos as $repository) { $content .= '<option>' . $repository->getTitle() . '</option>'; } $content .= '</select>'; $selectedRepo = $settings->getSelectedRepository(); /* @var $repoUtility em_repository_utility */ $repoUtility = t3lib_div::makeInstance('tx_em_Repository_Utility'); $repoUtility->setRepository($selectedRepo); $onCLick = 'window.location.href="' . t3lib_div::linkThisScript(array('CMD[fetchMetaData]' => 'extensions')) . '";return false;'; $content .= ' <input type="button" value="' . $GLOBALS['LANG']->getLL('retrieve_update') . '" onclick="' . htmlspecialchars($onCLick) . '" />'; if (is_file($repoUtility->getLocalExtListFile())) { $dateFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['ddmmyy']; $timeFormat = $GLOBALS['TYPO3_CONF_VARS']['SYS']['hhmm']; $count = tx_em_Database::getExtensionCountFromRepository($repoUtility->getRepositoryUID()); $content .= '<span style="margin-left:10px;padding-right: 50px;" class="typo3-message message-notice">' . sprintf($GLOBALS['LANG']->getLL('ext_list_last_updated'), date($dateFormat . ', ' . $timeFormat, filemtime($repoUtility->getLocalExtListFile())), $count) . '</span>'; } else { $content .= '<span style="margin-left:10px;padding-right: 50px;" class="typo3-message message-error">There are no extensions available, please update!</span>'; } $content .= '<br> <br>'; if ($this->CMD['fetchMetaData'] && $this->CMD['fetchMetaData'] == 'extensions') { // fetches mirror/extension data from online rep. $content .= $repoUtility->updateExtList(TRUE)->render(); } $content .= '</div>'; return $content; }
/** * Check integrity of repository entry in sys_ter * * @return void */ protected function checkRepository() { /** @var $repository tx_em_Repository */ $repository = t3lib_div::makeInstance('tx_em_Repository'); if ($repository->getLastUpdate() == 0) { $extCount = tx_em_Database::getExtensionCountFromRepository($repository); if ($extCount > 0) { $repository->setExtensionCount($extCount); $repository->setLastUpdate(time()); tx_em_Database::updateRepository($repository); } } }