/**
  * Update extension list
  *
  * @throws tx_em_ConnectionException if fetch from mirror fails
  * @return void
  */
 protected function updateExtensionlist()
 {
     // get repositories
     $repositories = tx_em_Database::getRepositories();
     if (!is_array($repositories)) {
         return;
     }
     // update all repositories
     foreach ($repositories as $repository) {
         /* @var $objRepository tx_em_Repository */
         $objRepository = t3lib_div::makeInstance('tx_em_Repository', $repository['uid']);
         /* @var $objRepositoryUtility tx_em_Repository_Utility */
         $objRepositoryUtility = t3lib_div::makeInstance('tx_em_Repository_Utility', $objRepository);
         $count = $objRepositoryUtility->updateExtList(FALSE);
         unset($objRepository, $objRepositoryUtility);
     }
 }
 /**
  * Method initializes parsing of extension.xml.gz file.
  *
  * @access  public
  * @param   string   $localExtListFile  absolute path to (gzipped) local extension list xml file
  * @param   integer  $repositoryUID	 UID of repository to be used when inserting records into DB
  * @return  integer  total number of imported extension versions
  */
 public function import($localExtListFile, $repositoryUID = NULL)
 {
     if (!is_null($repositoryUID) && is_int($repositoryUID)) {
         $this->repositoryUID = $repositoryUID;
     }
     $zlibStream = 'compress.zlib://';
     $this->sumRecords = 0;
     $this->parser->parseXML($zlibStream . $localExtListFile);
     // flush last rows to database if existing
     if (count($this->arrRows)) {
         $GLOBALS['TYPO3_DB']->exec_INSERTmultipleRows('cache_extensions', self::$fieldNames, $this->arrRows, self::$fieldIndicesNoQuote);
     }
     $extensions = tx_em_Database::insertLastVersion($this->repositoryUID);
     tx_em_Database::updateRepositoryCount($extensions, $this->repositoryUID);
     return $this->sumRecords;
 }
 /**
  * Insert main repository if not present
  *
  * @return void
  */
 protected function fixMainRepository()
 {
     $this->setTitle('TYPO3.org Main Repository');
     $this->setId('1');
     $this->setPriority(1);
     $this->setDescription('Main repository on typo3.org. For extension download there are mirrors available.');
     $this->setMirrorListUrl('http://repositories.typo3.org/mirrors.xml.gz');
     $this->setWsdlUrl('http://typo3.org/wsdl/tx_ter_wsdl.php');
     tx_em_Database::insertRepository($this);
 }
Пример #4
0
    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>&nbsp;<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;
    }
 /**
  * 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;
 }
 /**
  * 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);
         }
     }
 }
 /**
  * Get the selected repository
  *
  * @return array
  */
 protected function getSelectedRepository()
 {
     $settings = $this->getSettings();
     $repositories = tx_em_Database::getRepositories();
     $selectedRepository = array();
     foreach ($repositories as $uid => $repository) {
         if ($repository['uid'] == $settings['selectedRepository']) {
             $selectedRepository = array('title' => $repository['title'], 'uid' => $repository['uid'], 'description' => $repository['description'], 'wsdl_url' => $repository['wsdl_url'], 'mirror_url' => $repository['mirror_url'], 'count' => $repository['extCount'], 'updated' => $repository['lastUpdated'] ? date('d/m/Y H:i', $repository['lastUpdated']) : 'never', 'selected' => $repository['uid'] === $settings['selectedRepository']);
         }
     }
     return $selectedRepository;
 }