From a04cfb80c2c43f5165ddf633a507a10b4823f543 Mon Sep 17 00:00:00 2001
From: Mathias Brodala <mbrodala@pagemachine.de>
Date: Wed, 3 May 2017 09:27:21 +0200
Subject: [PATCH] [BUGFIX] Let ElementInfo Template take care of proper title
 crop

If the title is too long, it gets cropped. Then, the link title must
contain the whole string in order to provide a proper tooltip.

Resolves: #81124
Releases: master, 8.7
Change-Id: I55b4784c431b4a495dc4089ab954eb3c7e1ca435
Reviewed-on: https://review.typo3.org/52692
Reviewed-by: Mathias Brodala <mbrodala@pagemachine.de>
Tested-by: Mathias Brodala <mbrodala@pagemachine.de>
Reviewed-by: Elmar Hinz <t3elmar@gmail.com>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 .../ElementInformationController.php          |  7 ++++---
 .../ContentElement/ElementInformation.html    | 19 ++++++++++---------
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/typo3/sysext/backend/Classes/Controller/ContentElement/ElementInformationController.php b/typo3/sysext/backend/Classes/Controller/ContentElement/ElementInformationController.php
index d8f62f59d5f8..93b35ca7d733 100644
--- a/typo3/sysext/backend/Classes/Controller/ContentElement/ElementInformationController.php
+++ b/typo3/sysext/backend/Classes/Controller/ContentElement/ElementInformationController.php
@@ -237,6 +237,7 @@ class ElementInformationController
             $view->assignMultiple($this->getPropertiesForTable());
             $view->assignMultiple($this->getReferences());
             $view->assignMultiple($this->getBackButton());
+            $view->assign('maxTitleLength', $this->getBackendUser()->uc['titleLen'] ?? 20);
             $content .=  $view->render();
         }
         $this->moduleTemplate->setContent($content);
@@ -250,7 +251,7 @@ class ElementInformationController
     protected function getPageTitle() : array
     {
         $pageTitle = [
-            'title' => strip_tags(BackendUtility::getRecordTitle($this->table, $this->row))
+            'title' => BackendUtility::getRecordTitle($this->table, $this->row, false)
         ];
         if ($this->type === 'folder') {
             $pageTitle['table'] = $this->getLanguageService()->sL('LLL:EXT:lang/Resources/Private/Language/locallang_common.xlf:folder');
@@ -585,7 +586,7 @@ class ElementInformationController
                 $line['icon'] = $this->iconFactory->getIconForRecord($row['tablename'], $record, Icon::SIZE_SMALL)->render();
                 $line['row'] = $row;
                 $line['record'] = $record;
-                $line['recordTitle'] = BackendUtility::getRecordTitle($row['tablename'], $record, true);
+                $line['recordTitle'] = BackendUtility::getRecordTitle($row['tablename'], $record, false, true);
                 $line['parentRecordTitle'] = $parentRecordTitle;
                 $line['title'] = $lang->sL($GLOBALS['TCA'][$row['tablename']]['ctrl']['title']);
                 $line['labelForTableColumn'] = $this->getLabelForTableColumn($row['tablename'], $row['field']);
@@ -649,7 +650,7 @@ class ElementInformationController
                 $line['icon'] = $this->iconFactory->getIconForRecord($row['tablename'], $record, Icon::SIZE_SMALL)->render();
                 $line['row'] = $row;
                 $line['record'] = $record;
-                $line['recordTitle'] = BackendUtility::getRecordTitle($row['ref_table'], $record, true);
+                $line['recordTitle'] = BackendUtility::getRecordTitle($row['ref_table'], $record, false, true);
                 $line['title'] = $lang->sL($GLOBALS['TCA'][$row['ref_table']]['ctrl']['title']);
                 $line['labelForTableColumn'] = $this->getLabelForTableColumn($table, $row['field']);
                 $line['actions'] = $this->getRecordActions($row['ref_table'], $row['ref_uid']);
diff --git a/typo3/sysext/backend/Resources/Private/Templates/ContentElement/ElementInformation.html b/typo3/sysext/backend/Resources/Private/Templates/ContentElement/ElementInformation.html
index 7191778b4c26..ed1f2407f13e 100644
--- a/typo3/sysext/backend/Resources/Private/Templates/ContentElement/ElementInformation.html
+++ b/typo3/sysext/backend/Resources/Private/Templates/ContentElement/ElementInformation.html
@@ -1,6 +1,7 @@
 <h1>
     <f:if condition="{table}">
-        <small>{table}</small><br />{icon -> f:format.raw()}{title}
+      <small>{table}</small><br />{icon -> f:format.raw()}
+      <span title="{title}">{title -> f:format.crop(maxCharacters: maxTitleLength)}</span>
     </f:if>
 </h1>
 <f:if condition="{missingFile}">
@@ -62,7 +63,7 @@
             </thead>
             <tbody>
                 <f:for each="{refLines}" as="refLine">
-                    <f:render section="refLineRow" arguments="{line: refLine}" />
+                    <f:render section="refLineRow" arguments="{line: refLine, maxTitleLength: maxTitleLength}" />
                 </f:for>
             </tbody>
         </table>
@@ -88,7 +89,7 @@
             </thead>
             <tbody>
                 <f:for each="{refFromLines}" as="refFromLine">
-                    <f:render section="refFromLineRow" arguments="{line: refFromLine}" />
+                    <f:render section="refFromLineRow" arguments="{line: refFromLine, maxTitleLength: maxTitleLength}" />
                 </f:for>
             </tbody>
         </table>
@@ -129,8 +130,8 @@
     <tr>
         <f:if condition="{line.record}">
             <f:then>
-                <td class="col-icon"><a href="{line.url}" title="id={line.record.uid}">{line.icon -> f:format.raw()}</a></td>
-                <td class="col-title"><a href="{line.url}" title="id={line.record.uid}" >{line.recordTitle}</a></td>
+                <td class="col-icon"><f:link.page pageUid="{line.url}" title="id={line.record.uid}">{line.icon -> f:format.raw()}</f:link.page></td>
+                <td class="col-title"><f:link.page pageUid="{line.url}" title="[id={line.record.uid}] {line.recordTitle}">{line.recordTitle -> f:format.crop(maxCharacters: maxTitleLength)}</f:link.page></td>
                 <td>{line.title}</td>
                 <td><span title="{f:translate(key: 'LLL:EXT:lang/Resources/Private/Language/locallang_common.xlf:page')}: {line.parentRecordTitle} (uid={line.record.pid})">
                         {line.record.uid}
@@ -157,8 +158,8 @@
     <tr>
         <f:if condition="{line.record}">
             <f:then>
-                <td class="col-icon"><a href="{line.url}" title="id={line.record.uid}">{line.icon -> f:format.raw()}</a></td>
-                <td class="col-title"><a href="{line.url}" title="id={line.record.uid}" >{line.recordTitle}</a></td>
+                <td class="col-icon"><f:link.page pageUid="{line.url}" title="id={line.record.uid}">{line.icon -> f:format.raw()}</f:link.page></td>
+                <td class="col-title"><f:link.page pageUid="{line.url}" title="[id={line.record.uid}] {line.recordTitle}">{line.recordTitle -> f:format.crop(maxCharacters: maxTitleLength)}</f:link.page></td>
                 <td>{line.title}</td>
                 <td>{line.row.ref_uid}</td>
             </f:then>
@@ -182,11 +183,11 @@
 
 <f:section name="action">
     <div class="btn-group" role="group">
-	<f:if condition="{line.webListUrl}">
+        <f:if condition="{line.webListUrl}">
             <a class="btn btn-default btn-sm" href="#" onclick="{line.viewOnClick}" title="{f:translate(key: 'LLL:EXT:lang/Resources/Private/Language/locallang_common.xlf:labels.showPage')}">
                 <core:icon identifier="actions-document-view" size="small" />
             </a>
-	</f:if>
+        </f:if>
         <a class="btn btn-default btn-sm" href="{line.recordEditUrl}">
             <core:icon identifier="actions-open" size="small" />
         </a>
-- 
GitLab