From e5b5fea68a4410d791ed39c0a82cba10145dae26 Mon Sep 17 00:00:00 2001 From: Frans Saris <franssaris@gmail.com> Date: Mon, 24 Feb 2014 21:55:40 +0100 Subject: [PATCH] [BUGFIX] Wrong file icon in info popup In the info popup of a file/folder the wrong icon is shown. This patch changes it so IconUtility::getSpriteIconForResource() is used and moves the rendering of the header to the DocumentTemplate. Resolves: #56251 Releases: 6.2 Change-Id: I7fc40af85b8bc623112bcec29c2409221a937718 Reviewed-on: https://review.typo3.org/27819 Reviewed-by: Wouter Wolters Tested-by: Wouter Wolters Reviewed-by: Christian Kuhn Tested-by: Christian Kuhn --- .../ElementInformationController.php | 7 ++++-- .../Classes/Template/DocumentTemplate.php | 23 ++++++++++++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/typo3/sysext/backend/Classes/Controller/ContentElement/ElementInformationController.php b/typo3/sysext/backend/Classes/Controller/ContentElement/ElementInformationController.php index 4a8eea292664..590b59c679eb 100644 --- a/typo3/sysext/backend/Classes/Controller/ContentElement/ElementInformationController.php +++ b/typo3/sysext/backend/Classes/Controller/ContentElement/ElementInformationController.php @@ -229,8 +229,11 @@ class ElementInformationController { */ protected function renderPageTitle() { if ($this->type === 'folder') { - $title = IconUtility::getSpriteIcon('apps-filetree-folder-default') . ' ' . - $this->folderObject->getName(); + $table = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xlf:folder'); + $title = $this->doc->getResourceHeader($this->folderObject, array(' ', '')); + } elseif ($this->type === 'file') { + $table = $GLOBALS['LANG']->sL($GLOBALS['TCA'][$this->table]['ctrl']['title']); + $title = $this->doc->getResourceHeader($this->fileObject, array(' ', '')); } else { $table = $GLOBALS['LANG']->sL($GLOBALS['TCA'][$this->table]['ctrl']['title']); $title = $this->doc->getHeader($this->table, $this->row, $this->pageinfo['_thePath'], 1, array(' ', '')); diff --git a/typo3/sysext/backend/Classes/Template/DocumentTemplate.php b/typo3/sysext/backend/Classes/Template/DocumentTemplate.php index 509779fac8e1..e326a696e644 100644 --- a/typo3/sysext/backend/Classes/Template/DocumentTemplate.php +++ b/typo3/sysext/backend/Classes/Template/DocumentTemplate.php @@ -565,6 +565,26 @@ function jumpToUrl(URL) { return '<span class="typo3-moduleHeader">' . $this->wrapClickMenuOnIcon($iconImgTag, $table, $row['uid']) . $viewPage . $tWrap[0] . htmlspecialchars(GeneralUtility::fixed_lgd_cs($title, 45)) . $tWrap[1] . '</span>'; } + /** + * Like ->getHeader() but for files and folders + * Returns the icon with the path of the file/folder set in the alt/title attribute. Shows the name after the icon. + * + * @param \TYPO3\CMS\Core\Resource\ResourceInterface $resource + * @param array $tWrap is an array with indexes 0 and 1 each representing HTML-tags (start/end) which will wrap the title + * @return string + */ + public function getResourceHeader(\TYPO3\CMS\Core\Resource\ResourceInterface $resource, $tWrap = array('', '')) { + $path = $resource->getStorage()->getName() . $resource->getParentFolder()->getIdentifier(); + $iconImgTag = IconUtility::getSpriteIconForResource($resource, array('title' => htmlspecialchars($path))); + + if ($resource instanceof \TYPO3\CMS\Core\Resource\File) { + $metaData = $resource->_getMetaData(); + $iconImgTag = $this->wrapClickMenuOnIcon($iconImgTag, 'sys_file_metadata', $metaData['uid']); + } + + return '<span class="typo3-moduleHeader">' . $iconImgTag . $tWrap[0] . htmlspecialchars(GeneralUtility::fixed_lgd_cs($resource->getName(), 45)) . $tWrap[1] . '</span>'; + } + /** * Like ->getHeader() but for files in the File>* main module/submodules * Returns the file-icon with the path of the file set in the alt/title attribute. Shows the file-name after the icon. @@ -573,9 +593,10 @@ function jumpToUrl(URL) { * @param string $path Alt text * @param string $iconfile The icon file (relative to TYPO3 dir) * @return string HTML content - * @todo Define visibility + * @deprecated since 6.2 remove 2 version later use getResourceHeader() instead */ public function getFileheader($title, $path, $iconfile) { + GeneralUtility::logDeprecatedFunction(); $fileInfo = GeneralUtility::split_fileref($title); $title = htmlspecialchars(GeneralUtility::fixed_lgd_cs($fileInfo['path'], -35)) . '<strong>' . htmlspecialchars($fileInfo['file']) . '</strong>'; return '<span class="typo3-moduleHeader"><img' . IconUtility::skinImg($this->backPath, $iconfile, 'width="18" height="16"') . ' title="' . htmlspecialchars($path) . '" alt="" />' . $title . '</span>'; -- GitLab