[BUGFIX] Show data of valid columns in element info 62/37462/2
authorMarc Bastian Heinrichs <typo3@mbh-software.de>
Wed, 5 Feb 2014 15:18:42 +0000 (16:18 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Mon, 2 Mar 2015 16:37:16 +0000 (17:37 +0100)
The element information show rows for the data from
the special fields crdate, cruser_id and tstamp also if they
are not defined in TCA. They are also hardcoded and
doesn't rely on the settings in TCA ctrl.

Resolves: #55699
Releases: master, 6.2
Change-Id: I7c9a387c75d367618117ffcb6f04592ee519cecc
Reviewed-on: http://review.typo3.org/37462
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/backend/Classes/Controller/ContentElement/ElementInformationController.php

index a338585..65401ef 100644 (file)
@@ -306,9 +306,18 @@ class ElementInformationController {
                        $extraFields['crdate'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationDate', TRUE);
                        $extraFields['cruser_id'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.creationUserId', TRUE);
                        $extraFields['tstamp'] = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_general.xlf:LGL.timestamp', TRUE);
+
+                       // check if the special fields are defined in the TCA ctrl section of the table
+                       foreach ($extraFields as $fieldName => $fieldLabel) {
+                               if (isset($GLOBALS['TCA'][$this->table]['ctrl'][$fieldName])) {
+                                       $extraFields[$GLOBALS['TCA'][$this->table]['ctrl'][$fieldName]] = $fieldLabel;
+                               } else {
+                                       unset($extraFields[$fieldName]);
+                               }
+                       }
                }
 
-               foreach ($extraFields as $name => $value) {
+               foreach ($extraFields as $name => $fieldLabel) {
                        $rowValue = '';
                        if (!isset($this->row[$name])) {
                                $resourceObject = $this->fileObject ?: $this->folderObject;
@@ -322,8 +331,9 @@ class ElementInformationController {
                        } else {
                                $rowValue = BackendUtility::getProcessedValueExtra($this->table, $name, $this->row[$name]);
                        }
+                       // show the backend username who created the issue
                        if ($name === 'cruser_id' && $rowValue) {
-                               $userTemp = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('username, realName', 'be_users', 'uid = ' . (int)$rowValue);
+                               $userTemp = $GLOBALS['TYPO3_DB']->exec_SELECTgetSingleRow('username, realName', 'be_users', 'uid = ' . (int)$rowValue);
                                if ($userTemp[0]['username'] !== '') {
                                        $rowValue = $userTemp[0]['username'];
                                        if ($userTemp[0]['realName'] !== '') {
@@ -333,7 +343,7 @@ class ElementInformationController {
                        }
                        $tableRows[] = '
                                <tr>
-                                       <td><strong>' . rtrim($value, ':') . '</strong></td>
+                                       <th>' . rtrim($fieldLabel, ':') . '</th>
                                        <td>' . htmlspecialchars($rowValue) . '</td>
                                </tr>';
                }
@@ -642,4 +652,4 @@ class ElementInformationController {
                );
        }
 
-}
+}
\ No newline at end of file