From 07ac900bb99a3e8e1617847be3e40a1719e05d64 Mon Sep 17 00:00:00 2001 From: Marco Huber <mail@marco-huber.de> Date: Tue, 17 Nov 2015 13:56:36 +0100 Subject: [PATCH] [BUGFIX] Show nav title in element browser Show the nav title instead of the page title in the element browser (f.e. in the link wizard), if the user TSconfig setting "options.pageTree.showNavTitle=1" is set. Resolves: #71625 Related: #64492 Releases: master Change-Id: Id6721edf9741d05596342f0fee920cf8068e1354 Reviewed-on: https://review.typo3.org/44747 Reviewed-by: Marco Huber <mail@marco-huber.de> Tested-by: Marco Huber <mail@marco-huber.de> Tested-by: Gianluigi Martino <gmartino27@gmail.com> Reviewed-by: Markus Klein <markus.klein@typo3.org> Tested-by: Markus Klein <markus.klein@typo3.org> --- .../Classes/Tree/View/BrowseTreeView.php | 38 ++++++++++++++----- .../Tree/View/ElementBrowserPageTreeView.php | 5 --- .../Classes/Tree/View/PageTreeView.php | 22 +++++++---- .../backend/Classes/View/PageTreeView.php | 10 ----- 4 files changed, 43 insertions(+), 32 deletions(-) diff --git a/typo3/sysext/backend/Classes/Tree/View/BrowseTreeView.php b/typo3/sysext/backend/Classes/Tree/View/BrowseTreeView.php index a23f6793b90b..f0d47ba499e0 100644 --- a/typo3/sysext/backend/Classes/Tree/View/BrowseTreeView.php +++ b/typo3/sysext/backend/Classes/Tree/View/BrowseTreeView.php @@ -15,6 +15,7 @@ namespace TYPO3\CMS\Backend\Tree\View; */ use TYPO3\CMS\Backend\Utility\BackendUtility; +use TYPO3\CMS\Core\Utility\GeneralUtility; /** * Generate a page-tree, browsable. @@ -64,6 +65,11 @@ class BrowseTreeView extends AbstractTreeView */ public $domIdPrefix = 'pages'; + /** + * @var bool + */ + public $ext_showNavTitle = false; + /** * Initialize, setting what is necessary for browsing pages. * Using the current user. @@ -74,17 +80,17 @@ class BrowseTreeView extends AbstractTreeView */ public function init($clause = '', $orderByFields = '') { - // This will hide records from display - it has nothing todo with user rights!! + // This will hide records from display - it has nothing to do with user rights!! $clauseExcludePidList = ''; - if ($pidList = $GLOBALS['BE_USER']->getTSConfigVal('options.hideRecords.pages')) { - if ($pidList = $GLOBALS['TYPO3_DB']->cleanIntList($pidList)) { + if ($pidList = $this->getBackendUser()->getTSConfigVal('options.hideRecords.pages')) { + if ($pidList = $this->getDatabaseConnection()->cleanIntList($pidList)) { $clauseExcludePidList = ' AND pages.uid NOT IN (' . $pidList . ')'; } } // This is very important for making trees of pages: Filtering out deleted pages, pages with no access to and sorting them correctly: - parent::init(' AND ' . $GLOBALS['BE_USER']->getPagePermsClause(1) . ' ' . $clause . $clauseExcludePidList, 'sorting'); + parent::init(' AND ' . $this->getBackendUser()->getPagePermsClause(1) . ' ' . $clause . $clauseExcludePidList, 'sorting'); $this->title = $GLOBALS['TYPO3_CONF_VARS']['SYS']['sitename']; - $this->MOUNTS = $GLOBALS['BE_USER']->returnWebmounts(); + $this->MOUNTS = $this->getBackendUser()->returnWebmounts(); if ($pidList) { // Remove mountpoint if explicitly set in options.hideRecords.pages (see above) $hideList = explode(',', $pidList); @@ -119,7 +125,8 @@ class BrowseTreeView extends AbstractTreeView if (!$this->ext_IconMode) { $theIcon = BackendUtility::wrapClickMenuOnIcon($icon, $this->treeName, $this->getId($row), 0); } elseif ($this->ext_IconMode === 'titlelink') { - $aOnClick = 'return jumpTo(' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($this->getJumpToParam($row)) . ',this,' . \TYPO3\CMS\Core\Utility\GeneralUtility::quoteJSvalue($this->domIdPrefix . $this->getId($row)) . ',' . $this->bank . ');'; + $aOnClick = 'return jumpTo(' . GeneralUtility::quoteJSvalue($this->getJumpToParam($row)) . ',this,' + . GeneralUtility::quoteJSvalue($this->domIdPrefix . $this->getId($row)) . ',' . $this->bank . ');'; $theIcon = '<a href="#" onclick="' . htmlspecialchars($aOnClick) . '">' . $icon . '</a>'; } return $theIcon; @@ -135,9 +142,22 @@ class BrowseTreeView extends AbstractTreeView */ public function getTitleStr($row, $titleLen = 30) { - $title = parent::getTitleStr($row, $titleLen); - if (isset($row['is_siteroot']) && $row['is_siteroot'] != 0 && $GLOBALS['BE_USER']->getTSConfigVal('options.pageTree.showDomainNameWithTitle')) { - $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('domainName,sorting', 'sys_domain', 'pid=' . $GLOBALS['TYPO3_DB']->quoteStr(($row['uid'] . BackendUtility::deleteClause('sys_domain') . BackendUtility::BEenableFields('sys_domain')), 'sys_domain'), '', 'sorting', 1); + if ($this->ext_showNavTitle && isset($row['nav_title']) && trim($row['nav_title']) !== '') { + $title = parent::getTitleStr(['title' => $row['nav_title']], $titleLen); + } else { + $title = parent::getTitleStr($row, $titleLen); + } + if (!empty($row['is_siteroot']) && $this->getBackendUser()->getTSConfigVal('options.pageTree.showDomainNameWithTitle')) { + $rows = $this->getDatabaseConnection()->exec_SELECTgetRows( + 'domainName,sorting', + 'sys_domain', + 'pid=' . $this->getDatabaseConnection()->quoteStr( + $row['uid'] . BackendUtility::deleteClause('sys_domain') . BackendUtility::BEenableFields('sys_domain'), + 'sys_domain' + ), + '', + 'sorting', + 1); if (is_array($rows) && !empty($rows)) { $title = sprintf('%s [%s]', $title, htmlspecialchars($rows[0]['domainName'])); } diff --git a/typo3/sysext/backend/Classes/Tree/View/ElementBrowserPageTreeView.php b/typo3/sysext/backend/Classes/Tree/View/ElementBrowserPageTreeView.php index 089992236c02..a3ea73ca02ba 100644 --- a/typo3/sysext/backend/Classes/Tree/View/ElementBrowserPageTreeView.php +++ b/typo3/sysext/backend/Classes/Tree/View/ElementBrowserPageTreeView.php @@ -33,11 +33,6 @@ class ElementBrowserPageTreeView extends BrowseTreeView */ public $ext_showPageId = false; - /** - * @var bool - */ - public $ext_showNavTitle = false; - /** * @var bool */ diff --git a/typo3/sysext/backend/Classes/Tree/View/PageTreeView.php b/typo3/sysext/backend/Classes/Tree/View/PageTreeView.php index 484ee34c4bb3..42158b7277e7 100644 --- a/typo3/sysext/backend/Classes/Tree/View/PageTreeView.php +++ b/typo3/sysext/backend/Classes/Tree/View/PageTreeView.php @@ -15,7 +15,6 @@ namespace TYPO3\CMS\Backend\Tree\View; */ use TYPO3\CMS\Core\Utility\GeneralUtility; -use TYPO3\CMS\Lang\LanguageService; /** * Generate a page-tree, non-browsable. @@ -125,16 +124,23 @@ class PageTreeView extends AbstractTreeView */ public function getTitleStr($row, $titleLen = 30) { - /** @var LanguageService $lang */ - $lang = $GLOBALS['LANG']; - if ($this->ext_showNavTitle && trim($row['nav_title']) !== '') { - $title = '<span title="' . $lang->sL('LLL:EXT:lang/locallang_tca.xlf:title', true) . ' ' . htmlspecialchars(trim($row['title'])) . '">' . htmlspecialchars(GeneralUtility::fixed_lgd_cs($row['nav_title'], $titleLen)) . '</span>'; + $lang = $this->getLanguageService(); + if ($this->ext_showNavTitle && isset($row['nav_title']) && trim($row['nav_title']) !== '') { + $title = '<span title="' . $lang->sL('LLL:EXT:lang/locallang_tca.xlf:title', true) . ' ' + . htmlspecialchars(trim($row['title'])) . '">' + . htmlspecialchars(GeneralUtility::fixed_lgd_cs($row['nav_title'], $titleLen)) + . '</span>'; } else { $title = htmlspecialchars(GeneralUtility::fixed_lgd_cs($row['title'], $titleLen)); - if (trim($row['nav_title']) !== '') { - $title = '<span title="' . $lang->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.nav_title', true) . ' ' . htmlspecialchars(trim($row['nav_title'])) . '">' . $title . '</span>'; + if (isset($row['nav_title']) && trim($row['nav_title']) !== '') { + $title = '<span title="' + . $lang->sL('LLL:EXT:frontend/Resources/Private/Language/locallang_tca.xlf:pages.nav_title', true) + . ' ' . htmlspecialchars(trim($row['nav_title'])) . '">' . $title + . '</span>'; } - $title = trim($row['title']) === '' ? '<em>[' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.no_title', true) . ']</em>' : $title; + $title = trim($row['title']) === '' + ? '<em>[' . $lang->sL('LLL:EXT:lang/locallang_core.xlf:labels.no_title', true) . ']</em>' + : $title; } return $title; } diff --git a/typo3/sysext/backend/Classes/View/PageTreeView.php b/typo3/sysext/backend/Classes/View/PageTreeView.php index 30670ddee076..1b0671813c1a 100644 --- a/typo3/sysext/backend/Classes/View/PageTreeView.php +++ b/typo3/sysext/backend/Classes/View/PageTreeView.php @@ -30,16 +30,6 @@ class PageTreeView extends BrowseTreeView */ public $ext_showPageId = false; - /** - * @var bool - */ - public $ext_showNavTitle = false; - - /** - * @var string - */ - public $ext_IconMode; - /** * @var string */ -- GitLab