[BUGFIX] Deduplicate "Hide default translation of page" logic 15/46615/2
authorMathias Brodala <mbrodala@pagemachine.de>
Tue, 2 Feb 2016 16:15:47 +0000 (17:15 +0100)
committerMorton Jonuschat <m.jonuschat@mojocode.de>
Fri, 12 Feb 2016 10:33:08 +0000 (11:33 +0100)
Resolves: #73083
Releases: master, 7.6, 6.2
Change-Id: I35dfbeb2034990b5746568a733c3e11240a4399d
Reviewed-on: https://review.typo3.org/46450
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
Reviewed-by: Markus Sommer <markussom@posteo.de>
Tested-by: Markus Sommer <markussom@posteo.de>
Reviewed-by: Morton Jonuschat <m.jonuschat@mojocode.de>
Tested-by: Morton Jonuschat <m.jonuschat@mojocode.de>
(cherry picked from commit e28c56540792cf19fc3782cd894eb5c9e0af6aa4)
Reviewed-on: https://review.typo3.org/46615

typo3/sysext/frontend/Classes/ContentObject/Menu/AbstractMenuContentObject.php
typo3/sysext/frontend/Classes/Controller/TranslationStatusController.php
typo3/sysext/frontend/Classes/Controller/TypoScriptFrontendController.php

index 180a8af..1e880aa 100644 (file)
@@ -658,7 +658,7 @@ abstract class AbstractMenuContentObject
             }
             // Checking if the "disabled" state should be set.
             if (GeneralUtility::hideIfNotTranslated($tsfe->page['l18n_cfg']) && $sUid &&
-                empty($lRecs) || $tsfe->page['l18n_cfg'] & 1 &&
+                empty($lRecs) || GeneralUtility::hideIfDefaultLanguage($tsfe->page['l18n_cfg']) &&
                 (!$sUid || empty($lRecs)) ||
                 !$this->conf['special.']['normalWhenNoLanguage'] && $sUid && empty($lRecs)
             ) {
@@ -1223,7 +1223,7 @@ abstract class AbstractMenuContentObject
             // Checks if the default language version can be shown:
             // Block page is set, if l18n_cfg allows plus: 1) Either default language or 2) another language but NO overlay record set for page!
             $tsfe = $this->getTypoScriptFrontendController();
-            $blockPage = $data['l18n_cfg'] & 1 && (!$tsfe->sys_language_uid || $tsfe->sys_language_uid && !$data['_PAGES_OVERLAY']);
+            $blockPage = GeneralUtility::hideIfDefaultLanguage($data['l18n_cfg']) && (!$tsfe->sys_language_uid || $tsfe->sys_language_uid && !$data['_PAGES_OVERLAY']);
             if (!$blockPage) {
                 // Checking if a page should be shown in the menu depending on whether a translation exists:
                 $tok = true;
index 3d95be1..ae63078 100644 (file)
@@ -147,7 +147,7 @@ class TranslationStatusController extends \TYPO3\CMS\Backend\Module\AbstractFunc
                     $data['row']['uid'], '', '', '', '', '&L=###LANG_UID###')
                 ) . '" class="btn btn-default" title="' . $lang->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_webinfo.xlf:lang_renderl10n_viewPage') . '">' .
                 $this->iconFactory->getIcon('actions-document-view', Icon::SIZE_SMALL)->render() . '</a>';
-            $status = $data['row']['l18n_cfg'] & 1 ? 'danger' : 'success';
+            $status = GeneralUtility::hideIfDefaultLanguage($data['row']['l18n_cfg']) ? 'danger' : 'success';
             // Create links:
             $editUrl = BackendUtility::getModuleUrl('record_edit', [
                 'edit' => [
@@ -163,7 +163,7 @@ class TranslationStatusController extends \TYPO3\CMS\Backend\Module\AbstractFunc
                 ) . '">' . $this->iconFactory->getIcon('actions-document-open', Icon::SIZE_SMALL)->render() . '</a>';
             $info .= str_replace('###LANG_UID###', '0', $viewPageLink);
             $info .= '&nbsp;';
-            $info .= $data['row']['l18n_cfg'] & 1 ? '<span title="' . $lang->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.l18n_cfg.I.1', true) . '">D</span>' : '&nbsp;';
+            $info .= GeneralUtility::hideIfDefaultLanguage($data['row']['l18n_cfg']) ? '<span title="' . $lang->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.l18n_cfg.I.1', true) . '">D</span>' : '&nbsp;';
             $info .= GeneralUtility::hideIfNotTranslated($data['row']['l18n_cfg']) ? '<span title="' . $lang->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.l18n_cfg.I.2', true) . '">N</span>' : '&nbsp;';
             // Put into cell:
             $tCells[] = '<td class="' . $status . ' col-border-left btn-group">' . $info . '</td>';
@@ -179,7 +179,7 @@ class TranslationStatusController extends \TYPO3\CMS\Backend\Module\AbstractFunc
                     $info = '';
                     if (is_array($row)) {
                         $langRecUids[$langRow['uid']][] = $row['uid'];
-                        $status = $row['_HIDDEN'] ? (GeneralUtility::hideIfNotTranslated($data['row']['l18n_cfg']) || $data['row']['l18n_cfg'] & 1 ? 'danger' : '') : 'success';
+                        $status = $row['_HIDDEN'] ? (GeneralUtility::hideIfNotTranslated($data['row']['l18n_cfg']) || GeneralUtility::hideIfDefaultLanguage($data['row']['l18n_cfg']) ? 'danger' : '') : 'success';
                         $icon = $this->iconFactory->getIconForRecord('pages_language_overlay', $row, Icon::SIZE_SMALL)->render();
                         $info = $icon . htmlspecialchars(
                                 GeneralUtility::fixed_lgd_cs($row['title'], $titleLen)
@@ -219,7 +219,7 @@ class TranslationStatusController extends \TYPO3\CMS\Backend\Module\AbstractFunc
                             $status = 'danger';
                             $info = '';
                         } else {
-                            $status = GeneralUtility::hideIfNotTranslated($data['row']['l18n_cfg']) || $data['row']['l18n_cfg'] & 1 ? 'danger' : '';
+                            $status = GeneralUtility::hideIfNotTranslated($data['row']['l18n_cfg']) || GeneralUtility::hideIfDefaultLanguage($data['row']['l18n_cfg']) ? 'danger' : '';
                             $info = '<input type="checkbox" name="newOL[' . $langRow['uid'] . '][' . $data['row']['uid'] . ']" value="1" />';
                             $newOL_js[$langRow['uid']] .= '
                                                                +(document.webinfoForm['
index d168340..b58d9a4 100644 (file)
@@ -2737,7 +2737,7 @@ class TypoScriptFrontendController
         // Setting sys_language_uid inside sys-page:
         $this->sys_page->sys_language_uid = $this->sys_language_uid;
         // If default translation is not available:
-        if ((!$this->sys_language_uid || !$this->sys_language_content) && $this->page['l18n_cfg'] & 1) {
+        if ((!$this->sys_language_uid || !$this->sys_language_content) && GeneralUtility::hideIfDefaultLanguage($this->page['l18n_cfg'])) {
             $message = 'Page is not available in default language.';
             GeneralUtility::sysLog($message, 'cms', GeneralUtility::SYSLOG_SEVERITY_ERROR);
             $this->pageNotFoundAndExit($message);