[BUGFIX] Label user function for sys_file_reference uses HTML 28/23528/6
authorPhilipp Gampe <philipp.gampe@typo3.org>
Sun, 1 Sep 2013 11:32:02 +0000 (13:32 +0200)
committerGeorg Ringer <georg.ringer@gmail.com>
Tue, 24 Sep 2013 03:16:03 +0000 (05:16 +0200)
The change I7770044c11a6c1a1bcb51a3bfc11b85923653196 added meta
information for the FAL IRRE headers.
It uses a definition list to show certain fields of the related record
inside the title (thus visible if collapsed).
The HTML markup leads to problems in other places of the backend, most
noteable in the workspace module.

Introduce a separate user function only for inline labels,
using the same signature as the normal label_userFunc.

Resolves: #51411
Releases: 6.2
Change-Id: I070a9db3d009c743cb927be90a0aa3903a1bae45
Reviewed-on: https://review.typo3.org/23528
Reviewed-by: Markus Klein
Tested-by: Markus Klein
Reviewed-by: Georg Ringer
Tested-by: Georg Ringer
typo3/sysext/backend/Classes/Form/Element/InlineElement.php
typo3/sysext/core/Configuration/TCA/sys_file_reference.php

index 0206783..c02846b 100644 (file)
@@ -513,15 +513,35 @@ class InlineElement {
                $isOnSymmetricSide = RelationHandler::isOnSymmetricSide($parentUid, $config, $rec);
                $hasForeignLabel = !$isOnSymmetricSide && $config['foreign_label'] ? TRUE : FALSE;
                $hasSymmetricLabel = $isOnSymmetricSide && $config['symmetric_label'] ? TRUE : FALSE;
+
                // Get the record title/label for a record:
-               // render using a self-defined user function
-               if ($GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc']) {
+               // Try using a self-defined user function only for formatted labels
+               if (isset($GLOBALS['TCA'][$foreign_table]['ctrl']['formattedLabel_userFunc'])) {
+                       $params = array(
+                               'table' => $foreign_table,
+                               'row' => $rec,
+                               'title' => '',
+                               'isOnSymmetricSide' => $isOnSymmetricSide,
+                               'options' => isset($GLOBALS['TCA'][$foreign_table]['ctrl']['formattedLabel_userFunc_options'])
+                                       ? $GLOBALS['TCA'][$foreign_table]['ctrl']['formattedLabel_userFunc_options']
+                                       : array(),
+                               'parent' => array(
+                                       'uid' => $parentUid,
+                                       'config' => $config
+                               )
+                       );
+                       // callUserFunction requires a third parameter, but we don't want to give $this as reference!
+                       $null = NULL;
+                       GeneralUtility::callUserFunction($GLOBALS['TCA'][$foreign_table]['ctrl']['formattedLabel_userFunc'], $params, $null);
+                       $recTitle = $params['title'];
+
+               // Try using a normal self-defined user function
+               } elseif (isset($GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc'])) {
                        $params = array(
                                'table' => $foreign_table,
                                'row' => $rec,
                                'title' => '',
                                'isOnSymmetricSide' => $isOnSymmetricSide,
-                               'options' => isset($GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc_options']) ? $GLOBALS['TCA'][$foreign_table]['ctrl']['label_userFunc_options'] : array(),
                                'parent' => array(
                                        'uid' => $parentUid,
                                        'config' => $config
index 7d1b700..bbfddbd 100644 (file)
@@ -3,8 +3,8 @@ return array(
        'ctrl' => array(
                'title' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_reference',
                'label' => 'uid',
-               'label_userFunc' => 'EXT:core/Classes/Resource/Service/UserFileInlineLabelService.php:TYPO3\\CMS\\Core\\Resource\\Service\\UserFileInlineLabelService->getInlineLabel',
-               'label_userFunc_options' => array(
+               'formattedLabel_userFunc' => 'EXT:core/Classes/Resource/Service/UserFileInlineLabelService.php:TYPO3\\CMS\\Core\\Resource\\Service\\UserFileInlineLabelService->getInlineLabel',
+               'formattedLabel_userFunc_options' => array(
                        'sys_file' => array(
                                'title',
                                'name'