[BUGFIX] EXT:lang: Hide useless UI if no language is selected 36/34436/9
authorAndreas Fernandez <andreas.fernandez@aspedia.de>
Fri, 21 Nov 2014 10:27:57 +0000 (11:27 +0100)
committerTymoteusz Motylewski <t.motylewski@gmail.com>
Sat, 29 Nov 2014 13:41:27 +0000 (14:41 +0100)
In EXT:lang, the update button is displayed if no language is selected.
Clicking on that button will display several FlashMessages and PHP
throws an exception due to missing arguments.

This patch takes care of it and simply hides the button if no
language is selected.
Furthermore it hides the righthand side of the table too.

Resolves: #63124
Releases: master
Change-Id: Ica69a257ff5f36eda789051b194ef33c47e699fc
Reviewed-on: http://review.typo3.org/34436
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Felix Kopp <felix-source@phorax.com>
Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Tested-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
typo3/sysext/lang/Classes/Controller/LanguageController.php
typo3/sysext/lang/Classes/Domain/Model/LanguageSelectionForm.php
typo3/sysext/lang/Resources/Private/Templates/Language/Index.html

index b0a12dd..172cc77 100644 (file)
@@ -78,10 +78,12 @@ class LanguageController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionControl
                        $languageSelectionForm->setSelectedLanguages($this->languageRepository->findSelected());
                }
 
-               if (empty($extensions)) {
+               $hasSelectedLanguages = !empty($languageSelectionForm->getSelectedLanguages());
+               if ($hasSelectedLanguages && empty($extensions)) {
                        $extensions = $this->extensionRepository->findAll();
                }
 
+               $this->view->assign('hasSelectedLanguages', $hasSelectedLanguages);
                $this->view->assign('languageSelectionForm', $languageSelectionForm);
                $this->view->assign('extensions', $extensions);
        }
index ccea98d..a7f752c 100644 (file)
@@ -52,7 +52,7 @@ class LanguageSelectionForm extends \TYPO3\CMS\Extbase\DomainObject\AbstractEnti
        /**
         * Setter for the selected languages
         *
-        * @param array $locale Selected languages
+        * @param array $selectedLanguages Selected languages
         * @return void
         */
        public function setSelectedLanguages(array $selectedLanguages) {
index 4bcd419..f332826 100644 (file)
@@ -3,9 +3,11 @@
 <f:layout name="Default"/>
 
 <f:section name="iconButtons">
-       <span class="menuItem updateItem"><lang:be.spriteIcon icon="actions-system-extension-download" title="{f:translate(key:'button.update')}" /><f:translate key="button.update"/></span>
-       &nbsp;
-       <span class="menuItem cancelItem"><lang:be.spriteIcon icon="status-status-permission-denied" title="{f:translate(key:'button.cancel')}" /><f:translate key="button.cancel"/></span>
+       <f:if condition="{hasSelectedLanguages}">
+               <span class="menuItem updateItem"><lang:be.spriteIcon icon="actions-system-extension-download" title="{f:translate(key:'button.update')}" /><f:translate key="button.update"/></span>
+               &nbsp;
+               <span class="menuItem cancelItem"><lang:be.spriteIcon icon="status-status-permission-denied" title="{f:translate(key:'button.cancel')}" /><f:translate key="button.cancel"/></span>
+       </f:if>
 </f:section>
 
 
@@ -13,7 +15,6 @@
        <h1><f:translate key="header.module" /></h1>
 
        <f:flashMessages renderMode="div" />
-
        <table border="0" cellpadding="0" cellspacing="0">
                <tr>
                        <td class="languageSelectionListContainer">
                                <f:render partial="LanguageSelectionList" arguments="{_all}" />
                        </td>
                        <td class="translationUpdateListContainer">
-                               <h3><f:translate key="header.translationUpdateList" /></h3>
-                               <f:render partial="TranslationUpdateList" arguments="{_all}" />
+                               <f:if condition="{hasSelectedLanguages}">
+                                       <h3><f:translate key="header.translationUpdateList" /></h3>
+                                       <f:render partial="TranslationUpdateList" arguments="{_all}" />
+                               </f:if>
                        </td>
                </tr>
        </table>