[TASK] Remove language "default" from Alternative Page Language and 95/35695/7
authorBenjamin Mack <benni@typo3.org>
Sat, 3 Jan 2015 11:34:53 +0000 (12:34 +0100)
committerBenjamin Mack <benni@typo3.org>
Sat, 3 Jan 2015 13:46:14 +0000 (14:46 +0100)
hide record type when not necessary

The pages_language_overlay table has a sys_language_uid
field, but (like all other records) it is filled with "default".
However, due to the concept of two tables for translations
with pages and pages_language_overlay, the default
value does not make any sense and rather causes trouble
within the core when set to "0" / "default".

The patch removes the static entry from the language
dropdown of a pages_language_overlay record.

See also further discussion on forge.

Releases: master
Resolves: #34823
Change-Id: I258a8e2e31411779cc46005d56bc54e2a7a78b7d
Reviewed-on: http://review.typo3.org/35695
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Tested-by: Mathias Schreiber <mathias.schreiber@wmdb.de>
Reviewed-by: Benjamin Mack <benni@typo3.org>
Tested-by: Benjamin Mack <benni@typo3.org>
typo3/sysext/backend/Classes/Controller/NewRecordController.php
typo3/sysext/frontend/Configuration/TCA/pages_language_overlay.php

index 7d05a0c..defae04 100644 (file)
@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Backend\Controller;
 
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\Utility\IconUtility;
+use TYPO3\CMS\Core\Database\DatabaseConnection;
 use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
@@ -466,6 +467,9 @@ class NewRecordController {
                                                                        $iconFile[$_EXTKEY] = '';
                                                                }
                                                        } else {
+                                                               if ($table === 'pages_language_overlay' && !$this->checkIfLanguagesExist()) {
+                                                                       continue;
+                                                               }
                                                                $_EXTKEY = 'system';
                                                                $thisTitle = $GLOBALS['LANG']->getLL('system_records');
                                                                $iconFile['system'] = IconUtility::getSpriteIcon('apps-pagetree-root');
@@ -651,6 +655,19 @@ class NewRecordController {
        }
 
        /**
+        * Checks if sys_language records are present
+        *
+        * @return bool
+        */
+       protected function checkIfLanguagesExist() {
+               $languageCount = $this->getDatabaseConnection()->exec_SELECTcountRows('uid', 'sys_language', '1=1');
+               if ($languageCount) {
+                       $languageCount = TRUE;
+               }
+               return $languageCount;
+       }
+
+       /**
         * Returns the global BackendUserAuthentication object.
         *
         * @return \TYPO3\CMS\Core\Authentication\BackendUserAuthentication
@@ -659,4 +676,13 @@ class NewRecordController {
                return $GLOBALS['BE_USER'];
        }
 
+       /**
+        * Returns the database connection
+        *
+        * @return DatabaseConnection
+        */
+       protected function getDatabaseConnection() {
+               return $GLOBALS['TYPO3_DB'];
+       }
+
 }
index 546b1da..dbba852 100644 (file)
@@ -208,9 +208,7 @@ return array(
                                'type' => 'select',
                                'foreign_table' => 'sys_language',
                                'foreign_table_where' => 'ORDER BY sys_language.title',
-                               'items' => array(
-                                       array('LLL:EXT:lang/locallang_general.xlf:LGL.default_value', 0)
-                               )
+                               'items' => array() // no default language here, as the pages table is always the default language
                        )
                ),
                'tx_impexp_origuid' => array('config' => array('type' => 'passthrough')),