Esempio n. 1
0
 /**
  * Download an extension
  *
  * @param \TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension
  * @return void
  */
 public function download(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension)
 {
     $mirrorUrl = $this->repositoryHelper->getMirrors()->getMirrorUrl();
     $fetchedExtension = $this->terUtility->fetchExtension($extension->getExtensionKey(), $extension->getVersion(), $extension->getMd5hash(), $mirrorUrl);
     if (isset($fetchedExtension['extKey']) && !empty($fetchedExtension['extKey']) && is_string($fetchedExtension['extKey'])) {
         $this->fileHandlingUtility->unpackExtensionFromExtensionDataArray($fetchedExtension, $extension, $this->getDownloadPath());
     }
 }
 /**
  * Check translation(s) for extension
  *
  * @param array $languages
  * @param string $extensionKey
  * @return array
  */
 public function checkTranslationForExtension($languages, $extensionKey)
 {
     $result = array();
     /** @var $terConnection \TYPO3\CMS\Lang\Utility\Connection\Ter */
     $terConnection = $this->objectManager->create('TYPO3\\CMS\\Lang\\Utility\\Connection\\Ter');
     $mirrorUrl = $this->repositoryHelper->getMirrors()->getMirrorUrl();
     $fetch = $terConnection->fetchTranslationStatus($extensionKey, $mirrorUrl);
     foreach ($languages as $lang) {
         if (!isset($fetch[$lang])) {
             // No translation available
             $result[$lang] = array('icon' => $this->icons['unavailable'], 'message' => 'translation_n_a');
         } else {
             $zip = PATH_site . 'typo3temp' . DIRECTORY_SEPARATOR . $extensionKey . '-l10n-' . $lang . '.zip';
             $md5OfTranslationFile = '';
             if (is_file($zip)) {
                 $md5OfTranslationFile = md5_file($zip);
             }
             if ($md5OfTranslationFile !== $fetch[$lang]['md5']) {
                 $update = $terConnection->updateTranslation($extensionKey, $lang, $mirrorUrl);
                 $result[$lang] = $update ? array('icon' => $this->icons['ok'], 'message' => 'translation_msg_updated') : array('icon' => $this->icons['failed'], 'message' => 'translation_msg_failed');
             } else {
                 // Translation is up to date
                 $result[$lang] = array('icon' => $this->icons['ok'], 'message' => 'translation_status_uptodate');
             }
         }
     }
     return $result;
 }
Esempio n. 3
0
 /**
  * @param \TYPO3\CMS\Extensionmanager\Utility\Repository\Helper $helper The helper
  */
 public function injectRepositoryHelper(Helper $helper)
 {
     try {
         $this->mirrorUrl = $helper->getMirrors(false)->getMirrorUrl();
     } catch (ExtensionManagerException $e) {
         $this->mirrorUrl = '';
     }
 }
 /**
  * Update the translation for an extension
  *
  * @param string $extensionKey The extension key
  * @param string $locale Locale to update
  * @return integer Translation state
  */
 protected function updateTranslationForExtension($extensionKey, $locale)
 {
     if (empty($extensionKey) || empty($locale)) {
         return static::TRANSLATION_INVALID;
     }
     $state = static::TRANSLATION_FAILED;
     $mirrorUrl = $this->repositoryHelper->getMirrors()->getMirrorUrl();
     $updateResult = $this->terConnection->updateTranslation($extensionKey, $locale, $mirrorUrl);
     if ($updateResult === TRUE) {
         $state = static::TRANSLATION_UPDATED;
     }
     return $state;
 }
 /**
  * Fetch an extension from TER.
  *
  * @param string $extensionKey     The extension key
  * @param string $location         Where to import the extension. System = typo3/sysext, Global = typo3/ext, Local = typo3conf/ext
  * @param bool   $overwrite        Overwrite the extension if it already exists
  * @param int    $mirror           The mirror to fetch the extension from
  *
  * @throws \RuntimeException
  * @throws \InvalidArgumentException
  * @return array
  */
 public function fetchExtension($extensionKey, $version = '', $location = 'Local', $overwrite = FALSE, $mirror = -1)
 {
     if (!is_numeric($mirror)) {
         throw new InvalidArgumentException('Option --mirror must be a number. Run the command extensionapi:listmirrors to get the list of all available repositories');
     }
     if ($version === '') {
         $extension = $this->extensionRepository->findHighestAvailableVersion($extensionKey);
         if ($extension === NULL) {
             throw new InvalidArgumentException(sprintf('Extension "%s" was not found on TER', $extensionKey));
         }
     } else {
         $extension = $this->extensionRepository->findOneByExtensionKeyAndVersion($extensionKey, $version);
         if ($extension === NULL) {
             throw new InvalidArgumentException(sprintf('Version %s of extension "%s" does not exist', $version, $extensionKey));
         }
     }
     if (!$overwrite) {
         $comingExtPath = $this->fileHandlingUtility->getExtensionDir($extensionKey, $location);
         if (@is_dir($comingExtPath)) {
             throw new InvalidArgumentException(sprintf('Extension "%s" already exists at "%s"!', $extensionKey, $comingExtPath));
         }
     }
     $mirrors = $this->repositoryHelper->getMirrors();
     if ($mirrors === NULL) {
         throw new RuntimeException('No mirrors found!');
     }
     if ($mirror === -1) {
         $mirrors->setSelect();
     } elseif ($mirror > 0 && $mirror <= count($mirrors->getMirrors())) {
         $mirrors->setSelect($mirror);
     } else {
         throw new InvalidArgumentException(sprintf('Mirror "%s" does not exist', $mirror));
     }
     /**
      * @var \TYPO3\CMS\Extensionmanager\Utility\DownloadUtility $downloadUtility
      */
     $downloadUtility = $this->objectManager->get('TYPO3\\CMS\\Extensionmanager\\Utility\\DownloadUtility');
     $downloadUtility->setDownloadPath($location);
     $this->extensionManagementService->downloadMainExtension($extension);
     $return = array();
     $extensionDir = $this->fileHandlingUtility->getExtensionDir($extensionKey, $location);
     if (is_dir($extensionDir)) {
         $return['main']['extKey'] = $extension->getExtensionKey();
         $return['main']['version'] = $extension->getVersion();
     } else {
         throw new RuntimeException(sprintf('Extension "%s" version %s could not installed!', $extensionKey, $extension->getVersion()));
     }
     return $return;
 }
 /**
  * @param \TYPO3\CMS\Extensionmanager\Utility\Repository\Helper $helper The helper
  */
 public function injectRepositoryHelper(\TYPO3\CMS\Extensionmanager\Utility\Repository\Helper $helper)
 {
     $this->mirrorUrl = $helper->getMirrors(false)->getMirrorUrl();
 }
 /**
  * @param \TYPO3\CMS\Extensionmanager\Utility\Repository\Helper $helper The helper
  */
 public function injectRepositoryHelper(Helper $helper)
 {
     $this->mirrorUrl = $helper->getMirrors(false)->getMirrorUrl();
 }
 /**
  * Returns the mirror URL for a given extension.
  *
  * @param string $extensionKey
  * @return string
  */
 protected function getMirrorUrl($extensionKey)
 {
     $mirrorUrl = $this->repositoryHelper->getMirrors(FALSE)->getMirrorUrl();
     $mirrorUrl = $this->emitPostProcessMirrorUrlSignal($extensionKey, $mirrorUrl);
     return $mirrorUrl;
 }