[BUGFIX] Hide language switcher if record has no default translation 98/50298/2
authorChristina Hauk <chauk@plan2.net>
Tue, 11 Oct 2016 13:43:18 +0000 (15:43 +0200)
committerTymoteusz Motylewski <t.motylewski@gmail.com>
Mon, 7 Nov 2016 20:38:50 +0000 (21:38 +0100)
Disable further language menu options in free mode. If language record
doesn't have a record in the default language there are no more options
in the language menu needed.

Resolves: #72797
Releases: master, 7.6
Change-Id: Ic5211f99c3c53f3097057ba580e3394896b81170
Reviewed-on: https://review.typo3.org/50298
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Josef Glatz <josef.glatz@typo3.org>
Tested-by: Josef Glatz <josef.glatz@typo3.org>
Reviewed-by: Joerg Boesche <typo3@joergboesche.de>
Tested-by: Joerg Boesche <typo3@joergboesche.de>
Reviewed-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
Tested-by: Tymoteusz Motylewski <t.motylewski@gmail.com>
typo3/sysext/backend/Classes/Controller/EditDocumentController.php

index bacb271..eb6949f 100644 (file)
@@ -1611,28 +1611,36 @@ class EditDocumentController extends AbstractModule
                         if ($this->getBackendUser()->checkLanguageAccess($lang['uid'])) {
                             $newTranslation = isset($rowsByLang[$lang['uid']]) ? '' : ' [' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:lang/locallang_core.xlf:labels.new')) . ']';
                             // Create url for creating a localized record
+                            $addOption = true;
                             if ($newTranslation) {
                                 $redirectUrl = BackendUtility::getModuleUrl('record_edit', [
                                     'justLocalized' => $table . ':' . $rowsByLang[0]['uid'] . ':' . $lang['uid'],
                                     'returnUrl' => $this->retUrl
                                 ]);
-                                $href = BackendUtility::getLinkToDataHandlerAction(
-                                    '&cmd[' . $table . '][' . $rowsByLang[0]['uid'] . '][localize]=' . $lang['uid'],
-                                    $redirectUrl
-                                );
+
+                                if ($currentLanguage === 0) {
+                                    $href = BackendUtility::getLinkToDataHandlerAction(
+                                        '&cmd[' . $table . '][' . $rowsByLang[0]['uid'] . '][localize]=' . $lang['uid'],
+                                        $redirectUrl
+                                    );
+                                } else {
+                                    $addOption = false;
+                                }
                             } else {
                                 $href = BackendUtility::getModuleUrl('record_edit', [
                                     'edit[' . $table . '][' . $rowsByLang[$lang['uid']]['uid'] . ']' => 'edit',
                                     'returnUrl' => $this->retUrl
                                 ]);
                             }
-                            $menuItem = $languageMenu->makeMenuItem()
-                                ->setTitle($lang['title'] . $newTranslation)
-                                ->setHref($href);
-                            if ((int)$lang['uid'] === $currentLanguage) {
-                                $menuItem->setActive(true);
+                            if ($addOption) {
+                                $menuItem = $languageMenu->makeMenuItem()
+                                                         ->setTitle($lang['title'] . $newTranslation)
+                                                         ->setHref($href);
+                                if ((int)$lang['uid'] === $currentLanguage) {
+                                    $menuItem->setActive(true);
+                                }
+                                $languageMenu->addMenuItem($menuItem);
                             }
-                            $languageMenu->addMenuItem($menuItem);
                         }
                     }
                     $this->moduleTemplate->getDocHeaderComponent()->getMenuRegistry()->addMenu($languageMenu);