[BUGFIX] TCEFORM language selector: wrong relations
authorThorsten Kahler <thorsten.kahler@dkd.de>
Sun, 5 Jun 2011 18:46:37 +0000 (20:46 +0200)
committerAndreas Wolf <andreas.wolf@ikt-werk.de>
Mon, 6 Jun 2011 10:45:28 +0000 (12:45 +0200)
The language selector in the top of BE forms is intended to show (and
switch between) all translations of a certain record. All records in
non-default languages, that are not bound to a record in the default
language are shown as translations of each other.
The patch adds a distinction between translated records and records in
a non-default language to render the dropdowns labels and functions.
Additionally fixes PHPDoc and indentation of
SC_alt_doc::languageSwitch().

Change-Id: I6292578a2e4b3807cb333ff85a6d6309b7d4c754
Resolves: #24958
Reviewed-on: http://review.typo3.org/2533
Reviewed-by: Thorsten Kahler
Tested-by: Thorsten Kahler
Reviewed-by: Andreas Wolf
Tested-by: Andreas Wolf
typo3/alt_doc.php

index 6fd9173..baa4fb6 100644 (file)
@@ -1097,34 +1097,36 @@ class SC_alt_doc {
                                        // get record in current language
                                $rowCurrent = t3lib_befunc::getLiveVersionOfRecord($table, $uid, $fetchFields);
                                if (!is_array($rowCurrent)) {
-                               $rowCurrent = t3lib_befunc::getRecord($table, $uid, $fetchFields);
+                                       $rowCurrent = t3lib_befunc::getRecord($table, $uid, $fetchFields);
                                }
 
                                $currentLanguage = $rowCurrent[$languageField];
 
-                               if ($currentLanguage>-1)        {       // Disabled for records with [all] language!
+                               if ($currentLanguage > -1) {    // Disabled for records with [all] language!
                                                // get record in default language if needed
-                                       if ($currentLanguage) {
+                                       if ($currentLanguage && $rowCurrent[$transOrigPointerField]) {
                                                $rowsByLang[0] = t3lib_befunc::getLiveVersionOfRecord($table, $rowCurrent[$transOrigPointerField], $fetchFields);
                                                if (!is_array($rowsByLang[0])) {
-                                               $rowsByLang[0] = t3lib_befunc::getRecord($table, $rowCurrent[$transOrigPointerField], $fetchFields);
+                                                       $rowsByLang[0] = t3lib_befunc::getRecord($table, $rowCurrent[$transOrigPointerField], $fetchFields);
                                                }
                                        } else {
-                                               $rowsByLang[0] = $rowCurrent;
+                                               $rowsByLang[$rowCurrent[$languageField]] = $rowCurrent;
                                        }
 
-                                               // get record in other languages to see what's already available
-                                       $translations = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
-                                               $fetchFields,
-                                               $table,
-                                               'pid='.intval($pid).
-                                                       ' AND '.$languageField.'>0'.
-                                                       ' AND '.$transOrigPointerField.'='.intval($rowsByLang[0]['uid']).
-                                                       t3lib_BEfunc::deleteClause($table).
-                                                       t3lib_BEfunc::versioningPlaceholderClause($table)
-                                       );
-                                       foreach ($translations as $row) {
-                                               $rowsByLang[$row[$languageField]] = $row;
+                                       if ($rowCurrent[$transOrigPointerField] || $currentLanguage === '0') {
+                                                       // get record in other languages to see what's already available
+                                               $translations = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
+                                                       $fetchFields,
+                                                       $table,
+                                                       'pid='.intval($pid).
+                                                               ' AND '.$languageField.'>0'.
+                                                               ' AND '.$transOrigPointerField.'='.intval($rowsByLang[0]['uid']).
+                                                               t3lib_BEfunc::deleteClause($table).
+                                                               t3lib_BEfunc::versioningPlaceholderClause($table)
+                                               );
+                                               foreach ($translations as $row) {
+                                                       $rowsByLang[$row[$languageField]] = $row;
+                                               }
                                        }
 
                                        $langSelItems=array();