Ejemplo 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());
     }
 }
Ejemplo n.º 2
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 = '';
     }
 }
 /**
  * @test
  */
 public function executeCallsUpdateExtListOfRepositoryHelper()
 {
     $this->repositoryHelper->expects($this->once())->method('updateExtList');
     $objectManagerMock = $this->getMock(\TYPO3\CMS\Extbase\Object\ObjectManager::class);
     $objectManagerMock->expects($this->at(0))->method('get')->with(\TYPO3\CMS\Extensionmanager\Utility\Repository\Helper::class)->will($this->returnValue($this->repositoryHelper));
     $persistenceManagerMock = $this->getMock(\TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::class);
     $objectManagerMock->expects($this->at(1))->method('get')->will($this->returnValue($persistenceManagerMock));
     \TYPO3\CMS\Core\Utility\GeneralUtility::setSingletonInstance(\TYPO3\CMS\Extbase\Object\ObjectManager::class, $objectManagerMock);
     $task = $this->getMock(\TYPO3\CMS\Extensionmanager\Task\UpdateExtensionListTask::class, array('dummy'), array(), '', FALSE);
     $task->execute();
 }
 /**
  * Update extension list from TER
  *
  * @param boolean $forceUpdateCheck
  * @return void
  */
 public function updateExtensionListFromTerAction($forceUpdateCheck = FALSE)
 {
     $updated = FALSE;
     $errorMessage = '';
     if ($this->extensionRepository->countAll() === 0 || $forceUpdateCheck) {
         try {
             $updated = $this->repositoryHelper->updateExtList();
         } catch (\TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException $e) {
             $errorMessage = $e->getMessage();
         }
     }
     /** @var $repository \TYPO3\CMS\Extensionmanager\Domain\Model\Repository */
     $repository = $this->repositoryRepository->findByUid((int) $this->settings['repositoryUid']);
     $this->view->assign('updated', $updated)->assign('repository', $repository)->assign('errorMessage', $errorMessage);
 }
Ejemplo n.º 5
0
 /**
  * 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;
 }
Ejemplo n.º 6
0
 /**
  * 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;
 }
Ejemplo n.º 7
0
 /**
  * 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;
 }
 /**
  * Update extension list from TER
  *
  * @param boolean $forceUpdateCheck
  * @return void
  */
 public function updateExtensionListFromTerAction($forceUpdateCheck = FALSE)
 {
     $updated = FALSE;
     $errorMessage = '';
     /** @var $repository \TYPO3\CMS\Extensionmanager\Domain\Model\Repository */
     $repository = $this->repositoryRepository->findOneByUid((int) $this->settings['repositoryUid']);
     if ($repository->getLastUpdate()->getTimestamp() < $GLOBALS['EXEC_TIME'] - 24 * 60 * 60 || $forceUpdateCheck) {
         try {
             $updated = $this->repositoryHelper->updateExtList();
         } catch (\TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException $e) {
             $errorMessage = $e->getMessage();
         }
     }
     $this->view->assign('updated', $updated)->assign('repository', $repository)->assign('errorMessage', $errorMessage);
 }
Ejemplo n.º 9
0
 /**
  * Update extension list from TER
  *
  * @param bool $forceUpdateCheck
  * @return void
  */
 public function updateExtensionListFromTerAction($forceUpdateCheck = false)
 {
     $updated = false;
     $errorMessage = '';
     if ($this->extensionRepository->countAll() === 0 || $forceUpdateCheck) {
         try {
             $updated = $this->repositoryHelper->updateExtList();
         } catch (\TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException $e) {
             $errorMessage = $e->getMessage();
         }
     }
     /** @var $repository \TYPO3\CMS\Extensionmanager\Domain\Model\Repository */
     $repository = $this->repositoryRepository->findByUid((int) $this->settings['repositoryUid']);
     $timeFormat = $this->getLanguageService()->sL('LLL:EXT:extensionmanager/Resources/Private/Language/locallang.xlf:extensionList.updateFromTer.lastUpdate.fullTimeFormat');
     $lastUpdateTime = $repository->getLastUpdate();
     if (null === $lastUpdateTime) {
         $lastUpdatedSince = $this->getLanguageService()->sL('LLL:EXT:extensionmanager/Resources/Private/Language/locallang.xlf:extensionList.updateFromTer.never');
         $lastUpdateTime = date($timeFormat);
     } else {
         $lastUpdatedSince = \TYPO3\CMS\Backend\Utility\BackendUtility::calcAge(time() - $lastUpdateTime->format('U'), $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.minutesHoursDaysYears'));
         $lastUpdateTime = $lastUpdateTime->format($timeFormat);
     }
     $this->view->assign('value', ['updated' => $updated, 'lastUpdateTime' => $lastUpdateTime, 'timeSinceLastUpdate' => $lastUpdatedSince, 'errorMessage' => $errorMessage]);
 }
Ejemplo n.º 10
0
	/**
	 * @test
	 * @return void
	 */
	public function updateExtensionListFromTerCallsUpdateExtListIfForceUpdateCheckIsSet() {
		$controllerMock = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Controller\UpdateFromTerController::class, array('dummy'));
		$repositoryModelMock = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Domain\Model\Repository::class, array('getLastUpdate'));
		$viewMock = $this->getAccessibleMock(\TYPO3\CMS\Fluid\View\TemplateView::class, array('assign'), array(), '', FALSE);
		$requestMock = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Request::class, array('hasArgument', 'getArgument'));
		$viewMock->expects($this->any())->method('assign')->will($this->returnValue($viewMock));
		$this->repositoryRepositoryMock->expects($this->once())->method('findByUid')->with(1)->will($this->returnValue($repositoryModelMock));
		$this->repositoryHelperMock->expects($this->once())->method('updateExtList');
		$this->extensionRepositoryMock->expects($this->once())->method('countAll')->will($this->returnValue(100));
		$controllerMock->_set('extensionRepository', $this->extensionRepositoryMock);
		$controllerMock->_set('repositoryRepository', $this->repositoryRepositoryMock);
		$controllerMock->_set('repositoryHelper', $this->repositoryHelperMock);
		$controllerMock->_set('settings', array('repositoryUid' => 1));
		$controllerMock->_set('view', $viewMock);
		$controllerMock->_set('request', $requestMock);
		$controllerMock->updateExtensionListFromTerAction(TRUE);
	}
 /**
  * @test
  * @return void
  */
 public function updateExtensionListFromTerCallsUpdateExtListIfForceUpdateCheckIsSet()
 {
     /** @var \PHPUnit_Framework_MockObject_MockObject|AccessibleObjectInterface|UpdateFromTerController $controllerMock */
     $controllerMock = $this->getAccessibleMock(UpdateFromTerController::class, array('getLanguageService'));
     $controllerMock->expects($this->any())->method('getLanguageService')->will($this->returnValue($this->languageServiceMock));
     $repositoryModelMock = $this->getAccessibleMock(\TYPO3\CMS\Extensionmanager\Domain\Model\Repository::class, array('getLastUpdate'));
     $viewMock = $this->getAccessibleMock(\TYPO3\CMS\Fluid\View\TemplateView::class, array('assign'), array(), '', false);
     $requestMock = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Request::class, array('hasArgument', 'getArgument'));
     $viewMock->expects($this->any())->method('assign')->will($this->returnValue($viewMock));
     $this->repositoryRepositoryMock->expects($this->once())->method('findByUid')->with(1)->will($this->returnValue($repositoryModelMock));
     $this->repositoryHelperMock->expects($this->once())->method('updateExtList');
     $this->extensionRepositoryMock->expects($this->once())->method('countAll')->will($this->returnValue(100));
     $controllerMock->_set('extensionRepository', $this->extensionRepositoryMock);
     $controllerMock->_set('repositoryRepository', $this->repositoryRepositoryMock);
     $controllerMock->_set('repositoryHelper', $this->repositoryHelperMock);
     $controllerMock->_set('settings', array('repositoryUid' => 1));
     $controllerMock->_set('view', $viewMock);
     $controllerMock->_set('request', $requestMock);
     $controllerMock->updateExtensionListFromTerAction(true);
 }
Ejemplo n.º 12
0
 /**
  * @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();
 }
Ejemplo n.º 13
0
 /**
  * @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;
 }