[FEATURE] Make list of fields configurable in Pagetree overview 41/55241/5
authorGeorg Ringer <georg.ringer@gmail.com>
Tue, 2 Jan 2018 13:41:08 +0000 (14:41 +0100)
committerAndreas Fernandez <typo3@scripting-base.de>
Thu, 4 Jan 2018 09:37:29 +0000 (10:37 +0100)
By using pageTsConfig it is now possible to change the available fields
and add additional entries to the selectbox.

Resolves: #83449
Releases: master
Change-Id: I0985185b3711173387b68f7a3254082faa421476
Reviewed-on: https://review.typo3.org/55241
Reviewed-by: Reiner Teubner <rteubner@me.com>
Tested-by: Reiner Teubner <rteubner@me.com>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Andreas Fernandez <typo3@scripting-base.de>
Tested-by: Andreas Fernandez <typo3@scripting-base.de>
typo3/sysext/core/Configuration/DefaultConfiguration.php
typo3/sysext/core/Documentation/Changelog/master/Feature-83449-MakeListOfFieldsConfigurableInPagetreeOverviewInInfoModule.rst [new file with mode: 0644]
typo3/sysext/info/Classes/Controller/PageInformationController.php

index 6edf83a..eba8751 100644 (file)
@@ -974,6 +974,20 @@ return [
                 iphone4.height = 480
 
             }
+            mod.web_info.fieldDefinitions {
+                0 {
+                    label = LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:pages_0
+                    fields = title,uid,alias,starttime,endtime,fe_group,target,url,shortcut,shortcut_mode
+                }
+                1 {
+                    label = LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:pages_1
+                    fields = title,uid,###ALL_TABLES###
+                }
+                2 {
+                    label = LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:pages_2
+                    fields = title,uid,lastUpdated,newUntil,cache_timeout,php_tree_stop,TSconfig,is_siteroot,fe_login_mode
+                }
+            }
         ',
         // String (exclude).Enter lines of default Page TSconfig.
         'defaultPermissions' => [],
diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-83449-MakeListOfFieldsConfigurableInPagetreeOverviewInInfoModule.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-83449-MakeListOfFieldsConfigurableInPagetreeOverviewInInfoModule.rst
new file mode 100644 (file)
index 0000000..b3b04a8
--- /dev/null
@@ -0,0 +1,35 @@
+.. include:: ../../Includes.txt
+
+======================================================================================
+Feature: #83449 - Make list of fields configurable in Pagetree overview in Info module
+======================================================================================
+
+See :issue:`83449`
+
+Description
+===========
+
+The available fields in the module "Pagetree overview" in the Info module have been hardcoded to the entries "Basic settings", "Cache and age" and "Record overview".
+
+By using pageTsConfig it is now possible to change the available fields and add additional entries to the selectbox.
+
+.. code-block:: typoscript
+
+            mod.web_info.fieldDefinitions {
+                0 {
+                    label = LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:pages_0
+                    fields = title,uid,alias,starttime,endtime,fe_group,target,url,shortcut,shortcut_mode
+                }
+                1 {
+                    label = LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:pages_1
+                    fields = title,uid,###ALL_TABLES###
+                }
+                2 {
+                    label = LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:pages_2
+                    fields = title,uid,lastUpdated,newUntil,cache_timeout,php_tree_stop,TSconfig,is_siteroot,fe_login_mode
+                }
+            }
+
+The string `###ALL_TABLES###` is replaced with a list of table names an editor has access to.
+
+.. index:: Backend, NotScanned
index e3487c6..a39c437 100644 (file)
@@ -24,6 +24,10 @@ use TYPO3\CMS\Core\Utility\GeneralUtility;
  */
 class PageInformationController extends \TYPO3\CMS\Backend\Module\AbstractFunctionModule
 {
+
+    /** @var array */
+    protected $fieldConfiguration = [];
+
     /**
      * Returns the menu array
      *
@@ -31,12 +35,8 @@ class PageInformationController extends \TYPO3\CMS\Backend\Module\AbstractFuncti
      */
     public function modMenu()
     {
-        return [
-            'pages' => [
-                0 => $GLOBALS['LANG']->sL('LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:pages_0'),
-                2 => $GLOBALS['LANG']->sL('LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:pages_2'),
-                1 => $GLOBALS['LANG']->sL('LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:pages_1')
-            ],
+        $menu = [
+            'pages' => [],
             'depth' => [
                 0 => $GLOBALS['LANG']->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.depth_0'),
                 1 => $GLOBALS['LANG']->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.depth_1'),
@@ -46,6 +46,12 @@ class PageInformationController extends \TYPO3\CMS\Backend\Module\AbstractFuncti
                 999 => $GLOBALS['LANG']->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.depth_infi')
             ]
         ];
+
+        $this->fillFieldConfiguration($this->pObj->id);
+        foreach ($this->fieldConfiguration as $key => $item) {
+            $menu['pages'][$key] = $item['label'];
+        }
+        return $menu;
     }
 
     /**
@@ -55,6 +61,7 @@ class PageInformationController extends \TYPO3\CMS\Backend\Module\AbstractFuncti
      */
     public function main()
     {
+        $this->fillFieldConfiguration($this->pObj->id);
         $theOutput = '<h1>' . htmlspecialchars($this->getLanguageService()->sL('LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:page_title')) . '</h1>';
         $dblist = GeneralUtility::makeInstance(PageLayoutView::class);
         $dblist->descrTable = '_MOD_web_info';
@@ -67,36 +74,8 @@ class PageInformationController extends \TYPO3\CMS\Backend\Module\AbstractFuncti
         $dblist->agePrefixes = $GLOBALS['LANG']->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.minutesHoursDaysYears');
         $dblist->pI_showUser = true;
 
-        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',
-                    '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'
-                ];
+        if (isset($this->fieldConfiguration[$this->pObj->MOD_SETTINGS['pages']])) {
+            $dblist->fieldArray = $this->fieldConfiguration[$this->pObj->MOD_SETTINGS['pages']]['fields'];
         }
 
         // PAGES:
@@ -106,13 +85,12 @@ class PageInformationController extends \TYPO3\CMS\Backend\Module\AbstractFuncti
         $h_func .= BackendUtility::getDropdownMenu($this->pObj->id, 'SET[pages]', $this->pObj->MOD_SETTINGS['pages'], $this->pObj->MOD_MENU['pages']);
         $dblist->start($this->pObj->id, 'pages', 0);
         $dblist->generateList();
-        // CSH
-        $optionKey = $this->pObj->MOD_SETTINGS['pages'];
-        $cshPagetreeOverview = BackendUtility::cshItem($dblist->descrTable, 'func_' . $optionKey, null, '<span class="btn btn-default btn-sm">|</span>');
 
         $theOutput .= '<div class="form-inline form-inline-spaced">'
             . $h_func
-            . '<div class="form-group">' . $cshPagetreeOverview . '</div>'
+            . '<div class="form-group">'
+            . BackendUtility::cshItem($dblist->descrTable, 'func_' . $this->pObj->MOD_SETTINGS['pages'], null, '<span class="btn btn-default btn-sm">|</span>')
+            . '</div>'
             . '</div>'
             . $dblist->HTMLcode;
 
@@ -125,13 +103,13 @@ class PageInformationController extends \TYPO3\CMS\Backend\Module\AbstractFuncti
     }
 
     /**
-     * Function, which fills in the internal array, $this->allowedTableNames with all tables to
+     * Function, which returns all tables to
      * which the user has access. Also a set of standard tables (pages, sys_filemounts, etc...)
      * are filtered out. So what is left is basically all tables which makes sense to list content from.
      *
-     * @return string[]
+     * @return string
      */
-    protected function cleanTableNames()
+    protected function cleanTableNames(): string
     {
         // Get all table names:
         $tableNames = array_flip(array_keys($GLOBALS['TCA']));
@@ -151,7 +129,27 @@ class PageInformationController extends \TYPO3\CMS\Backend\Module\AbstractFuncti
                 }
             }
         }
-        return $allowedTableNames;
+        return implode(',', array_keys($allowedTableNames));
+    }
+
+    /**
+     * Generate configuration for field selection
+     *
+     * @param int $pageId current page id
+     */
+    protected function fillFieldConfiguration(int $pageId)
+    {
+        $modTSconfig = BackendUtility::getModTSconfig($pageId, 'mod.web_info.fieldDefinitions');
+
+        foreach ($modTSconfig['properties'] as $key => $item) {
+            $fieldList = str_replace('###ALL_TABLES###', $this->cleanTableNames(), $item['fields']);
+            $fields = GeneralUtility::trimExplode(',', $fieldList, true);
+            $key = trim($key, '.');
+            $this->fieldConfiguration[$key] = [
+                'label' => $item['label'] ? $GLOBALS['LANG']->sL($item['label']) : $key,
+                'fields' => $fields
+            ];
+        }
     }
 
     /**