[BUGFIX] EM: Adjust import-handling for deactivated auto-install 24/42324/3
authorDaniel Goerz <ervaude@gmail.com>
Thu, 6 Aug 2015 15:38:57 +0000 (17:38 +0200)
committerAndreas Fernandez <typo3@scripting-base.de>
Thu, 6 Aug 2015 17:48:36 +0000 (19:48 +0200)
If automaticInstallation is turned off in extension manager settings,
dependency-checks are not done anymore (as no installation is done in
that case).

The tooltip in the "Get Extensions" list has also been adjusted:
- "Import" if automaticInstallation is turned off
- "Import and install" if automaticInstallation is turned on

Change-Id: I9d1a9105c4f76baf94d74a69d2d425a949fb8bc7
Resolves: #66302
Releases: master
Reviewed-on: http://review.typo3.org/42324
Reviewed-by: Sascha Wilking <sascha.wilking@hmmh.de>
Tested-by: Sascha Wilking <sascha.wilking@hmmh.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
typo3/sysext/extensionmanager/Classes/Controller/DownloadController.php
typo3/sysext/extensionmanager/Classes/Utility/DownloadUtility.php
typo3/sysext/extensionmanager/Classes/ViewHelpers/DownloadExtensionViewHelper.php
typo3/sysext/extensionmanager/Resources/Private/Language/locallang.xlf
typo3/sysext/extensionmanager/Resources/Private/Templates/Download/CheckDependencies.json

index 6fa10b8..cd4c691 100644 (file)
@@ -105,34 +105,41 @@ class DownloadController extends AbstractController {
                $title = '';
                $hasDependencies = FALSE;
                $hasErrors = FALSE;
-               try {
-                       $dependencyTypes = $this->managementService->getAndResolveDependencies($extension);
-                       if (!empty($dependencyTypes)) {
-                               $hasDependencies = TRUE;
-                               $message = '<p>' . $this->translate('downloadExtension.dependencies.headline') . '</p>';
-                               foreach ($dependencyTypes as $dependencyType => $dependencies) {
-                                       $extensions = '';
-                                       foreach ($dependencies as $extensionKey => $dependency) {
-                                               $extensions .= $this->translate('downloadExtension.dependencies.extensionWithVersion', array(
-                                                               $extensionKey, $dependency->getVersion()
-                                                       )) . '<br />';
+               if ($this->configurationUtility->getCurrentConfiguration('extensionmanager')['automaticInstallation']['value']) {
+                       $action = 'installFromTer';
+                       try {
+                               $dependencyTypes = $this->managementService->getAndResolveDependencies($extension);
+                               if (!empty($dependencyTypes)) {
+                                       $hasDependencies = TRUE;
+                                       $message = '<p>' . $this->translate('downloadExtension.dependencies.headline') . '</p>';
+                                       foreach ($dependencyTypes as $dependencyType => $dependencies) {
+                                               $extensions = '';
+                                               foreach ($dependencies as $extensionKey => $dependency) {
+                                                       $extensions .= $this->translate('downloadExtension.dependencies.extensionWithVersion', array(
+                                                                       $extensionKey, $dependency->getVersion()
+                                                               )) . '<br />';
+                                               }
+                                               $message .= $this->translate('downloadExtension.dependencies.typeHeadline',
+                                                       array(
+                                                               $this->translate('downloadExtension.dependencyType.' . $dependencyType),
+                                                               $extensions
+                                                       )
+                                               );
                                        }
-                                       $message .= $this->translate('downloadExtension.dependencies.typeHeadline',
-                                               array(
-                                                       $this->translate('downloadExtension.dependencyType.' . $dependencyType),
-                                                       $extensions
-                                               )
-                                       );
+                                       $title = $this->translate('downloadExtension.dependencies.resolveAutomatically');
                                }
-                               $title = $this->translate('downloadExtension.dependencies.resolveAutomatically');
+                               $this->view->assign('dependencies', $dependencyTypes);
+                       } catch (\Exception $e) {
+                               $hasErrors = TRUE;
+                               $title = $this->translate('downloadExtension.dependencies.errorTitle');
+                               $message = $e->getMessage();
                        }
-                       $this->view->assign('dependencies', $dependencyTypes);
-               } catch (\Exception $e) {
-                       $hasErrors = TRUE;
-                       $title = $this->translate('downloadExtension.dependencies.errorTitle');
-                       $message = $e->getMessage();
+               } else {
+                       // if automatic installation is deactivated, no dependency check is needed (download only)
+                       $action = 'installExtensionWithoutSystemDependencyCheck';
                }
                $this->view->assign('extension', $extension)
+                       ->assign('action', $action)
                        ->assign('hasDependencies', $hasDependencies)
                        ->assign('hasErrors', $hasErrors)
                        ->assign('message', $message)
@@ -282,7 +289,7 @@ class DownloadController extends AbstractController {
        }
 
        /**
-        * Install an action from TER
+        * Install an extension from TER
         * Downloads the extension, resolves dependencies and installs it
         *
         * @param \TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension
index 03f8da6..a32f93b 100644 (file)
@@ -15,7 +15,7 @@ namespace TYPO3\CMS\Extensionmanager\Utility;
  */
 
 /**
- * Utility for dealing with ext_emconf
+ * Utility for Downloading Extensions
  */
 class DownloadUtility implements \TYPO3\CMS\Core\SingletonInterface {
 
index f2b0134..1102953 100644 (file)
@@ -28,6 +28,18 @@ class DownloadExtensionViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\FormViewH
        protected $tagName = 'form';
 
        /**
+        * @var \TYPO3\CMS\Extensionmanager\Utility\ConfigurationUtility
+        */
+       protected $configurationUtility;
+
+       /**
+        * @param \TYPO3\CMS\Extensionmanager\Utility\ConfigurationUtility $configurationUtility
+        */
+       public function injectConfigurationUtility(\TYPO3\CMS\Extensionmanager\Utility\ConfigurationUtility $configurationUtility) {
+               $this->configurationUtility = $configurationUtility;
+       }
+
+       /**
         * Renders a download link
         *
         * @param \TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension
@@ -55,13 +67,15 @@ class DownloadExtensionViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\FormViewH
                ), 'Download');
                $this->tag->addAttribute('data-href', $uri);
 
+               $automaticInstallation = $this->configurationUtility->getCurrentConfiguration('extensionmanager')['automaticInstallation']['value'];
+               $labelKeySuffix = $automaticInstallation ? '' : '.downloadOnly';
                $label = '
                        <div class="btn-group">
                                <button
-                                       title="' . LocalizationUtility::translate('extensionList.downloadViewHelper.submit', 'extensionmanager') . '"
+                                       title="' . LocalizationUtility::translate('extensionList.downloadViewHelper.submit' . $labelKeySuffix, 'extensionmanager') . '"
                                        type="submit"
                                        class="btn btn-default"
-                                       value="' . LocalizationUtility::translate('extensionList.downloadViewHelper.submit', 'extensionmanager') . '"
+                                       value="' . LocalizationUtility::translate('extensionList.downloadViewHelper.submit' . $labelKeySuffix, 'extensionmanager') . '"
                                >
                                        <span class="t3-icon fa fa-cloud-download"></span>
                                </button>
index 6579040..1b21bb4 100644 (file)
                        <trans-unit id="extensionList.downloadViewHelper.submit">
                                <source>Import and Install</source>
                        </trans-unit>
+                       <trans-unit id="extensionList.downloadViewHelper.submit.downloadOnly">
+                               <source>Import</source>
+                       </trans-unit>
                        <trans-unit id="extensionList.showAllVersions.label">
                                <source>Show all versions</source>
                        </trans-unit>
index 2a4742d..ab5e0ed 100644 (file)
@@ -1,6 +1,6 @@
 {namespace em=TYPO3\CMS\Extensionmanager\ViewHelpers}
 <em:format.jsonEncode additionalAttributes="{dependencies:dependencies,
-url:'{f:uri.action(action:\"installFromTer\", controller:\"Download\", arguments:\"{extension:extension.uid, format:\'json\'}\")}',
+url:'{f:uri.action(action:action, controller:\"Download\", arguments:\"{extension:extension.uid, format:\'json\'}\")}',
 message: '{message}',
 hasErrors: '{hasErrors}',
 hasDependencies: '{hasDependencies}',