[TASK] Move code from PageLayoutView to proper class 20/50220/5
authorGeorg Ringer <georg.ringer@gmail.com>
Thu, 13 Oct 2016 18:04:37 +0000 (20:04 +0200)
committerBenni Mack <benni@typo3.org>
Wed, 26 Oct 2016 10:11:19 +0000 (12:11 +0200)
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>
typo3/sysext/backend/Classes/View/PageLayoutView.php
typo3/sysext/frontend/Classes/Controller/PageInformationController.php

index be8ab0f..b8f0357 100644 (file)
@@ -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
index a12057a..3c60dd0 100644 (file)
@@ -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'];
+    }
 }