From 9e3cca871764f6464f2e5d6f54b06c0bf5804013 Mon Sep 17 00:00:00 2001 From: Georg Ringer <georg.ringer@gmail.com> Date: Thu, 13 Oct 2016 20:04:37 +0200 Subject: [PATCH] [TASK] Move code from PageLayoutView to proper class The code is only used in PageInformationController and should therefore reside in this class instead of PageLayoutView. Resolves: #78289 Releases: master Change-Id: I049782082a4cea9df2d777093c387b3b45756957 Reviewed-on: https://review.typo3.org/50220 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: Benni Mack <benni@typo3.org> Tested-by: Benni Mack <benni@typo3.org> --- .../backend/Classes/View/PageLayoutView.php | 65 ---------------- .../Controller/PageInformationController.php | 74 +++++++++++++++++++ 2 files changed, 74 insertions(+), 65 deletions(-) diff --git a/typo3/sysext/backend/Classes/View/PageLayoutView.php b/typo3/sysext/backend/Classes/View/PageLayoutView.php index be8ab0fe32f6..b8f0357b1a29 100644 --- a/typo3/sysext/backend/Classes/View/PageLayoutView.php +++ b/typo3/sysext/backend/Classes/View/PageLayoutView.php @@ -325,40 +325,6 @@ class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRe } // If there was found a page: if (is_array($row)) { - // Select which fields to show: - $pKey = $this->getPageLayoutController()->MOD_SETTINGS['pages']; - switch ($pKey) { - case 1: - $this->fieldArray = ['title', 'uid'] + array_keys($this->cleanTableNames()); - break; - case 2: - $this->fieldArray = [ - 'title', - 'uid', - 'lastUpdated', - 'newUntil', - 'no_cache', - 'cache_timeout', - 'php_tree_stop', - 'TSconfig', - 'is_siteroot', - 'fe_login_mode' - ]; - break; - default: - $this->fieldArray = [ - 'title', - 'uid', - 'alias', - 'starttime', - 'endtime', - 'fe_group', - 'target', - 'url', - 'shortcut', - 'shortcut_mode' - ]; - } // Getting select-depth: $depth = (int)$this->getPageLayoutController()->MOD_SETTINGS['pages_levels']; // Overriding a few things: @@ -2358,37 +2324,6 @@ class PageLayoutView extends \TYPO3\CMS\Recordlist\RecordList\AbstractDatabaseRe return '<span title="' . $title . '">' . $this->iconFactory->getIcon('status-status-edit-read-only', Icon::SIZE_SMALL)->render() . '</span>'; } - /** - * Function, which fills in the internal array, $this->allowedTableNames with all tables to - * which the user has access. Also a set of standard tables (pages, static_template, sys_filemounts, etc...) - * are filtered out. So what is left is basically all tables which makes sense to list content from. - * - * @return array - */ - protected function cleanTableNames() - { - // Get all table names: - $tableNames = array_flip(array_keys($GLOBALS['TCA'])); - // Unset common names: - unset($tableNames['pages']); - unset($tableNames['static_template']); - unset($tableNames['sys_filemounts']); - unset($tableNames['sys_action']); - unset($tableNames['sys_workflows']); - unset($tableNames['be_users']); - unset($tableNames['be_groups']); - $allowedTableNames = []; - // Traverse table names and set them in allowedTableNames array IF they can be read-accessed by the user. - if (is_array($tableNames)) { - foreach ($tableNames as $k => $v) { - if (!$GLOBALS['TCA'][$k]['ctrl']['hideTable'] && $this->getBackendUser()->check('tables_select', $k)) { - $allowedTableNames['table_' . $k] = $k; - } - } - } - return $allowedTableNames; - } - /***************************************** * * External renderings diff --git a/typo3/sysext/frontend/Classes/Controller/PageInformationController.php b/typo3/sysext/frontend/Classes/Controller/PageInformationController.php index a12057adbad0..3c60dd0d803d 100644 --- a/typo3/sysext/frontend/Classes/Controller/PageInformationController.php +++ b/typo3/sysext/frontend/Classes/Controller/PageInformationController.php @@ -16,6 +16,7 @@ namespace TYPO3\CMS\Frontend\Controller; use TYPO3\CMS\Backend\Utility\BackendUtility; use TYPO3\CMS\Backend\View\PageLayoutView; +use TYPO3\CMS\Core\Authentication\BackendUserAuthentication; use TYPO3\CMS\Core\Utility\GeneralUtility; /** @@ -63,6 +64,40 @@ class PageInformationController extends \TYPO3\CMS\Backend\Module\AbstractFuncti $dblist->setLMargin = 0; $dblist->agePrefixes = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:labels.minutesHoursDaysYears'); $dblist->pI_showUser = 1; + + switch ((int)$this->pObj->MOD_SETTINGS['pages']) { + case 1: + $dblist->fieldArray = ['title', 'uid'] + array_keys($this->cleanTableNames()); + break; + case 2: + $dblist->fieldArray = [ + 'title', + 'uid', + 'lastUpdated', + 'newUntil', + 'no_cache', + 'cache_timeout', + 'php_tree_stop', + 'TSconfig', + 'is_siteroot', + 'fe_login_mode' + ]; + break; + default: + $dblist->fieldArray = [ + 'title', + 'uid', + 'alias', + 'starttime', + 'endtime', + 'fe_group', + 'target', + 'url', + 'shortcut', + 'shortcut_mode' + ]; + } + // PAGES: $this->pObj->MOD_SETTINGS['pages_levels'] = $this->pObj->MOD_SETTINGS['depth']; // ONLY for the sake of dblist module which uses this value. @@ -88,4 +123,43 @@ class PageInformationController extends \TYPO3\CMS\Backend\Module\AbstractFuncti } return $theOutput; } + + /** + * Function, which fills in the internal array, $this->allowedTableNames with all tables to + * which the user has access. Also a set of standard tables (pages, static_template, sys_filemounts, etc...) + * are filtered out. So what is left is basically all tables which makes sense to list content from. + * + * @return string[] + */ + protected function cleanTableNames() + { + // Get all table names: + $tableNames = array_flip(array_keys($GLOBALS['TCA'])); + // Unset common names: + unset($tableNames['pages']); + unset($tableNames['static_template']); + unset($tableNames['sys_filemounts']); + unset($tableNames['sys_action']); + unset($tableNames['sys_workflows']); + unset($tableNames['be_users']); + unset($tableNames['be_groups']); + $allowedTableNames = []; + // Traverse table names and set them in allowedTableNames array IF they can be read-accessed by the user. + if (is_array($tableNames)) { + foreach ($tableNames as $k => $v) { + if (!$GLOBALS['TCA'][$k]['ctrl']['hideTable'] && $this->getBackendUser()->check('tables_select', $k)) { + $allowedTableNames['table_' . $k] = $k; + } + } + } + return $allowedTableNames; + } + + /** + * @return BackendUserAuthentication + */ + protected function getBackendUser() + { + return $GLOBALS['BE_USER']; + } } -- GitLab