[TASK] Enable EM offline mode when using composer 25/44025/4
authorNicole Cordes <typo3@cordes.co>
Tue, 13 Oct 2015 08:28:45 +0000 (10:28 +0200)
committerHelmut Hummel <helmut.hummel@typo3.org>
Wed, 14 Oct 2015 12:29:17 +0000 (14:29 +0200)
If the composer mode is activated, the Extension Manager is set to
offline mode. Downloading extensions from TER and uploading extension
files is disabled.

Resolves: #70605
Releases: master
Change-Id: Idb116d7b4b0b9cafa625116e9caadd4c7c37b922
Reviewed-on: http://review.typo3.org/44025
Reviewed-by: Stephan GroƟberndt <stephan@grossberndt.de>
Reviewed-by: Michael Oehlhof <typo3@oehlhof.de>
Tested-by: Michael Oehlhof <typo3@oehlhof.de>
Reviewed-by: Daniel Maier <dani-maier@gmx.de>
Tested-by: Daniel Maier <dani-maier@gmx.de>
Reviewed-by: Helmut Hummel <helmut.hummel@typo3.org>
Tested-by: Helmut Hummel <helmut.hummel@typo3.org>
typo3/sysext/extensionmanager/Classes/Controller/ListController.php
typo3/sysext/extensionmanager/Classes/Controller/UploadExtensionFileController.php
typo3/sysext/extensionmanager/Classes/Utility/Connection/TerUtility.php
typo3/sysext/extensionmanager/Resources/Private/Language/locallang.xlf
typo3/sysext/extensionmanager/Resources/Private/Layouts/Main.html
typo3/sysext/extensionmanager/Resources/Private/Templates/List/Index.html
typo3/sysext/extensionmanager/Resources/Private/Templates/List/Ter.html

index 9a79afc..570dc08 100644 (file)
@@ -102,6 +102,9 @@ class ListController extends AbstractController
         if ($this->configurationUtility->getCurrentConfiguration('extensionmanager')['offlineMode']['value']) {
             $this->settings['offlineMode'] = true;
         }
+        if (Bootstrap::usesComposerClassLoading()) {
+            $this->settings['composerMode'] = true;
+        }
     }
 
     /**
index 49f73be..fc4ff3c 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Extensionmanager\Controller;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Bootstrap;
 use TYPO3\CMS\Core\Messaging\FlashMessage;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 use TYPO3\CMS\Extensionmanager\Exception\DependencyConfigurationNotFoundException;
@@ -115,6 +116,12 @@ class UploadExtensionFileController extends AbstractController
      */
     public function formAction()
     {
+        if (Bootstrap::usesComposerClassLoading()) {
+            throw new ExtensionManagerException(
+                'Composer mode is active. You are not allowed to upload any extension file.',
+                1444725828821
+            );
+        }
     }
 
     /**
@@ -126,6 +133,12 @@ class UploadExtensionFileController extends AbstractController
      */
     public function extractAction($overwrite = false)
     {
+        if (Bootstrap::usesComposerClassLoading()) {
+            throw new ExtensionManagerException(
+                'Composer mode is active. You are not allowed to upload any extension file.',
+                1444725853814
+            );
+        }
         $file = $_FILES['tx_extensionmanager_tools_extensionmanagerextensionmanager'];
         $fileName = pathinfo($file['name']['extensionFile'], PATHINFO_BASENAME);
         try {
index 17db960..a24913f 100644 (file)
@@ -14,6 +14,7 @@ namespace TYPO3\CMS\Extensionmanager\Utility\Connection;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Core\Bootstrap;
 use TYPO3\CMS\Extensionmanager\Exception\ExtensionManagerException;
 
 /**
@@ -53,7 +54,10 @@ class TerUtility
      */
     public function fetchExtension($extensionKey, $version, $expectedMd5, $mirrorUrl)
     {
-        if (!empty($this->configurationUtility->getCurrentConfiguration('extensionmanager')['offlineMode']['value'])) {
+        if (
+            !empty($this->configurationUtility->getCurrentConfiguration('extensionmanager')['offlineMode']['value'])
+            || Bootstrap::usesComposerClassLoading()
+        ) {
             throw new ExtensionManagerException('Extension Manager is in offline mode. No TER connection available.', 1437078620);
         }
         $extensionPath = \TYPO3\CMS\Core\Utility\GeneralUtility::strtolower($extensionKey);
index 91da95c..fb92dc2 100644 (file)
@@ -16,7 +16,7 @@
                                <source>Composer mode</source>
                        </trans-unit>
                        <trans-unit id="composerMode.message">
-                               <source>The system is set to composer mode. Please notice that it might break if you try to add an extension with the Extension Manager. You should rather use composer to add further extensions to your system.</source>
+                               <source>The system is set to composer mode. Please notice that it is not possible to add an extension with the Extension Manager. You have to use composer to add further extensions to your system.</source>
                        </trans-unit>
                        <trans-unit id="installedExtensions">
                                <source>Installed Extensions</source>
index 29d8105..664d4f1 100644 (file)
                <div class="typo3-docheader-functions">
                        <f:be.menus.actionMenu>
                                <f:be.menus.actionMenuItem label="{f:translate(key: 'installedExtensions')}" controller="List" action="index" />
-                               <f:if condition="{settings.offlineMode}">
-                                       <f:else>
-                                               <f:be.menus.actionMenuItem label="{f:translate(key: 'getExtensions')}" controller="List" action="ter" />
-                                               <f:be.menus.actionMenuItem label="{f:translate(key: 'distributions')}" controller="List" action="distributions" />
-                                               <f:if condition="{actionName} == 'showAllVersions'">
-                                                       <f:be.menus.actionMenuItem label="{f:translate(key: 'showAllVersions')} {extensionKey}" controller="List" action="showAllVersions" />
+                               <f:if condition="{settings.offlineMode} == 0">
+                                       <f:then>
+                                               <f:if condition="{settings.composerMode} == 0">
+                                                       <f:then>
+                                                               <f:be.menus.actionMenuItem label="{f:translate(key: 'getExtensions')}" controller="List" action="ter" />
+                                                               <f:be.menus.actionMenuItem label="{f:translate(key: 'distributions')}" controller="List" action="distributions" />
+                                                               <f:if condition="{actionName} == 'showAllVersions'">
+                                                                       <f:be.menus.actionMenuItem label="{f:translate(key: 'showAllVersions')} {extensionKey}" controller="List" action="showAllVersions" />
+                                                               </f:if>
+                                                       </f:then>
                                                </f:if>
-                                       </f:else>
+                                       </f:then>
                                </f:if>
                        </f:be.menus.actionMenu>
                </div>
index dc81370..c1a1ed4 100644 (file)
@@ -4,11 +4,15 @@
 <f:layout name="main" />
 
 <f:section name="docheader-buttons">
-       <div id="upload-button-wrap">
-               <a href="{f:uri.action(action:'form',controller:'UploadExtensionFile')}" title="{f:translate(key:'extensionList.uploadExtension')}">
-                       <core:icon identifier="actions-edit-upload" />
-               </a>
-       </div>
+       <f:if condition="{settings.composerMode} == 0">
+               <f:then>
+                       <div id="upload-button-wrap">
+                               <a href="{f:uri.action(action:'form',controller:'UploadExtensionFile')}" title="{f:translate(key:'extensionList.uploadExtension')}">
+                                       <core:icon identifier="actions-edit-upload" />
+                               </a>
+                       </div>
+               </f:then>
+       </f:if>
 </f:section>
 
 <f:section name="module-headline">
index f7d2f92..c3b6d1b 100644 (file)
@@ -3,11 +3,15 @@
 <f:layout name="main"/>
 
 <f:section name="docheader-buttons">
-       <div id="upload-button-wrap">
-               <a href="{f:uri.action(action:'form',controller:'UploadExtensionFile')}" title="{f:translate(key:'extensionList.uploadExtension')}">
-                       <core:icon identifier="actions-edit-upload" />
-               </a>
-       </div>
+       <f:if condition="{settings.composerMode} == 0">
+               <f:then>
+                       <div id="upload-button-wrap">
+                               <a href="{f:uri.action(action:'form',controller:'UploadExtensionFile')}" title="{f:translate(key:'extensionList.uploadExtension')}">
+                                       <core:icon identifier="actions-edit-upload" />
+                               </a>
+                       </div>
+               </f:then>
+       </f:if>
 </f:section>
 
 <f:section name="module-headline">