[TASK] Cleanup EM Code
authorHelmut Hummel <helmut.hummel@typo3.org>
Fri, 19 Oct 2012 16:32:00 +0000 (18:32 +0200)
committerHelmut Hummel <helmut.hummel@typo3.org>
Sat, 20 Oct 2012 09:53:02 +0000 (11:53 +0200)
* Use controller arguments for actions
* Simplify contollers

Releases: 6.0
Resolves: #42163

Change-Id: I211d58e0dbbed083bb7a643a89da764bb4a186a3
Reviewed-on: http://review.typo3.org/15823
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Helmut Hummel
Tested-by: Helmut Hummel
typo3/sysext/extensionmanager/Classes/Controller/ConfigurationController.php
typo3/sysext/extensionmanager/Classes/Controller/DownloadController.php
typo3/sysext/extensionmanager/Classes/Controller/ListController.php
typo3/sysext/extensionmanager/Classes/Controller/UpdateFromTerController.php
typo3/sysext/extensionmanager/Classes/ViewHelpers/ShowExtensionVersionsViewHelper.php
typo3/sysext/extensionmanager/Resources/Private/Layouts/Main.html

index 11955ed..694da55 100644 (file)
@@ -52,10 +52,9 @@ class ConfigurationController extends \TYPO3\CMS\Extensionmanager\Controller\Abs
         * Show the extension configuration form. The whole form field handling is done
         * in the corresponding view helper
         *
         * Show the extension configuration form. The whole form field handling is done
         * in the corresponding view helper
         *
-        * @return void
+        * @param array $extension
         */
         */
-       public function showConfigurationFormAction() {
-               $extension = $this->request->getArgument('extension');
+       public function showConfigurationFormAction($extension) {
                $extension = array_merge($extension, $GLOBALS['TYPO3_LOADED_EXT'][$extension['key']]);
                $configuration = $this->configurationItemRepository->findByExtension($extension);
                $this->view->assign('configuration', $configuration)->assign('extension', $extension);
                $extension = array_merge($extension, $GLOBALS['TYPO3_LOADED_EXT'][$extension['key']]);
                $configuration = $this->configurationItemRepository->findByExtension($extension);
                $this->view->assign('configuration', $configuration)->assign('extension', $extension);
index 31cc8d9..500e496 100644 (file)
@@ -56,6 +56,11 @@ class DownloadController extends \TYPO3\CMS\Extensionmanager\Controller\Abstract
        protected $installUtility;
 
        /**
        protected $installUtility;
 
        /**
+        * @var \TYPO3\CMS\Extensionmanager\Utility\DownloadUtility
+        */
+       protected $downloadUtility;
+
+       /**
         * @param \TYPO3\CMS\Extensionmanager\Utility\InstallUtility $installUtility
         * @return void
         */
         * @param \TYPO3\CMS\Extensionmanager\Utility\InstallUtility $installUtility
         * @return void
         */
@@ -90,11 +95,6 @@ class DownloadController extends \TYPO3\CMS\Extensionmanager\Controller\Abstract
        }
 
        /**
        }
 
        /**
-        * @var \TYPO3\CMS\Extensionmanager\Utility\DownloadUtility
-        */
-       protected $downloadUtility;
-
-       /**
         * @param \TYPO3\CMS\Extensionmanager\Utility\DownloadUtility $downloadUtility
         * @return void
         */
         * @param \TYPO3\CMS\Extensionmanager\Utility\DownloadUtility $downloadUtility
         * @return void
         */
@@ -105,16 +105,10 @@ class DownloadController extends \TYPO3\CMS\Extensionmanager\Controller\Abstract
        /**
         * Check extension dependencies
         *
        /**
         * Check extension dependencies
         *
+        * @param \TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension
         * @throws \Exception
         * @throws \Exception
-        * @return void
         */
         */
-       public function checkDependenciesAction() {
-               if (!$this->request->hasArgument('extension')) {
-                       throw new \Exception('Required argument extension not set.', 1334433342);
-               }
-               $extensionUid = $this->request->getArgument('extension');
-               /** @var $extension \TYPO3\CMS\Extensionmanager\Domain\Model\Extension */
-               $extension = $this->extensionRepository->findByUid(intval($extensionUid));
+       public function checkDependenciesAction(\TYPO3\CMS\Extensionmanager\Domain\Model\Extension $extension) {
                $dependencyTypes = $this->managementService->getAndResolveDependencies($extension);
                $message = '';
                if (count($dependencyTypes) > 0) {
                $dependencyTypes = $this->managementService->getAndResolveDependencies($extension);
                $message = '';
                if (count($dependencyTypes) > 0) {
index af93757..0ef1a21 100644 (file)
@@ -77,14 +77,19 @@ class ListController extends \TYPO3\CMS\Extensionmanager\Controller\AbstractCont
        }
 
        /**
        }
 
        /**
+        * Add the needed JavaScript files for all actions
+        */
+       public function initializeAction() {
+               $this->pageRenderer->addJsFile('../t3lib/js/extjs/notifications.js');
+               $this->pageRenderer->addInlineLanguageLabelFile('EXT:extensionmanager/Resources/Private/Language/locallang.xlf');
+       }
+
+       /**
         * Shows list of extensions present in the system
         *
         * @return void
         */
        public function indexAction() {
         * Shows list of extensions present in the system
         *
         * @return void
         */
        public function indexAction() {
-               $this->pageRenderer->addJsFile('../t3lib/js/extjs/notifications.js');
-               $this->pageRenderer->addInlineLanguageLabelFile('EXT:extensionmanager/Resources/Private/Language/locallang.xlf');
-               $this->pageRenderer->addJsFile(\TYPO3\CMS\Core\Extension\ExtensionManager::extRelPath('lang') . 'res/js/be/typo3lang.js');
                $availableExtensions = $this->listUtility->getAvailableExtensions();
                $availableAndInstalledExtensions = $this->listUtility->getAvailableAndInstalledExtensions($availableExtensions);
                $availableAndInstalledExtensions = $this->listUtility->enrichExtensionsWithEmConfAndTerInformation($availableAndInstalledExtensions);
                $availableExtensions = $this->listUtility->getAvailableExtensions();
                $availableAndInstalledExtensions = $this->listUtility->getAvailableAndInstalledExtensions($availableExtensions);
                $availableAndInstalledExtensions = $this->listUtility->enrichExtensionsWithEmConfAndTerInformation($availableAndInstalledExtensions);
@@ -95,67 +100,28 @@ class ListController extends \TYPO3\CMS\Extensionmanager\Controller\AbstractCont
         * Shows extensions from TER
         * Either all extensions or depending on a search param
         *
         * Shows extensions from TER
         * Either all extensions or depending on a search param
         *
-        * @return void
+        * @param string $search
         */
         */
-       public function terAction() {
-               $this->pageRenderer->addJsFile('../t3lib/js/extjs/notifications.js');
-               $search = $this->getSearchParam();
-               $availableAndInstalledExtensions = $this->listUtility->getAvailableAndInstalledExtensionsWithAdditionalInformation();
-               if (is_string($search) && !empty($search)) {
+       public function terAction($search = '') {
+               if (!empty($search)) {
                        $extensions = $this->extensionRepository->findByTitleOrAuthorNameOrExtensionKey($search);
                } else {
                        $extensions = $this->extensionRepository->findAll();
                }
                        $extensions = $this->extensionRepository->findByTitleOrAuthorNameOrExtensionKey($search);
                } else {
                        $extensions = $this->extensionRepository->findAll();
                }
-               $this->view->assign('extensions', $extensions)->assign('search', $search)->assign('availableAndInstalled', $availableAndInstalledExtensions);
+               $availableAndInstalledExtensions = $this->listUtility->getAvailableAndInstalledExtensionsWithAdditionalInformation();
+               $this->view->assign('extensions', $extensions)
+                               ->assign('search', $search)
+                               ->assign('availableAndInstalled', $availableAndInstalledExtensions);
        }
 
        /**
         * Shows all versions of a specific extension
         *
        }
 
        /**
         * Shows all versions of a specific extension
         *
-        * @return void
+        * @param string $extensionKey
         */
         */
-       public function showAllVersionsAction() {
-               $this->pageRenderer->addJsFile($this->backPath . '../t3lib/js/extjs/notifications.js');
-               $extensions = array();
-               $extensionKey = '';
-               if ($this->request->hasArgument('allVersions') && $this->request->getArgument('allVersions') == 1 && $this->request->hasArgument('extensionKey') && is_string($this->request->getArgument('extensionKey'))) {
-                       $extensionKey = $this->request->getArgument('extensionKey');
-                       $extensions = $this->extensionRepository->findByExtensionKeyOrderedByVersion($extensionKey);
-               } else {
-                       $this->redirect('ter');
-               }
+       public function showAllVersionsAction($extensionKey) {
+               $extensions = $this->extensionRepository->findByExtensionKeyOrderedByVersion($extensionKey);
                $this->view->assign('extensions', $extensions)->assign('extensionKey', $extensionKey);
        }
                $this->view->assign('extensions', $extensions)->assign('extensionKey', $extensionKey);
        }
-
-       /**
-        * Gets the search parameter either from the url or out
-        * of the session if present
-        *
-        * @return string
-        */
-       public function getSearchParam() {
-               $search = '';
-               if ($this->request->hasArgument('search') && is_string($this->request->getArgument('search'))) {
-                       $search = $this->request->getArgument('search');
-               }
-               return $search;
-       }
-
-       /**
-        * Gets instance of template if exists or create a new one.
-        * Saves instance in viewHelperVariableContainer
-        *
-        * @return \TYPO3\CMS\Backend\Template\DocumentTemplate $doc
-        */
-       public function getDocInstance() {
-               if (!isset($GLOBALS['SOBE']->doc)) {
-                       $GLOBALS['SOBE']->doc = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
-                       $GLOBALS['SOBE']->doc->backPath = $GLOBALS['BACK_PATH'];
-               }
-               return $GLOBALS['SOBE']->doc;
-       }
-
 }
 }
-
-
 ?>
\ No newline at end of file
 ?>
\ No newline at end of file
index 562981e..fdca2b1 100644 (file)
@@ -113,8 +113,5 @@ class UpdateFromTerController extends \TYPO3\CMS\Extensionmanager\Controller\Abs
                }
                $this->view->assign('updated', $updated)->assign('repository', $repository)->assign('errorMessage', $errorMessage);
        }
                }
                $this->view->assign('updated', $updated)->assign('repository', $repository)->assign('errorMessage', $errorMessage);
        }
-
 }
 }
-
-
 ?>
\ No newline at end of file
 ?>
\ No newline at end of file
index 524b412..a6d25b3 100644 (file)
@@ -51,7 +51,6 @@ class ShowExtensionVersionsViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Link\
                $action = 'showAllVersions';
                $uri = $uriBuilder->reset()->uriFor($action, array(
                        'extensionKey' => $extension->getExtensionKey(),
                $action = 'showAllVersions';
                $uri = $uriBuilder->reset()->uriFor($action, array(
                        'extensionKey' => $extension->getExtensionKey(),
-                       'allVersions' => TRUE
                ), 'List');
                $this->tag->addAttribute('href', $uri);
                $label = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('extensionList.showAllVersions.label', 'extensionmanager');
                ), 'List');
                $this->tag->addAttribute('href', $uri);
                $label = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('extensionList.showAllVersions.label', 'extensionmanager');
index 810f13f..a7cd9ac 100644 (file)
@@ -44,7 +44,7 @@
                                        </li>
                                        <f:if condition="{0: actionName} == {0: 'showAllVersions'}">
                                                <li>
                                        </li>
                                        <f:if condition="{0: actionName} == {0: 'showAllVersions'}">
                                                <li>
-                                                       <f:link.action action="showAllVersions" controller="List" class="current">
+                                                       <f:link.action action="ter" controller="List" class="current">
                                                                <f:translate key="showAllVersions" /> "{extensionKey}"
                                                        </f:link.action>
                                                </li>
                                                                <f:translate key="showAllVersions" /> "{extensionKey}"
                                                        </f:link.action>
                                                </li>