[TASK] Hide page alias in pagetree overview with sites 04/58204/3
authorChristian Kuhn <lolli@schwarzbu.ch>
Thu, 6 Sep 2018 15:42:46 +0000 (17:42 +0200)
committerAndreas Fernandez <a.fernandez@scripting-base.de>
Fri, 7 Sep 2018 15:09:48 +0000 (17:09 +0200)
If rendering page trees in Info -> Pagetree overview that has
a full Site configuration, hide the "alias" field - it is not
shown in FormEngine, either.
If rendering a PseudoSite (no site configuration), hide the
slug field.

Resolves: #86175
Releases: master
Change-Id: I46ccb150184e4b76799ab8636ac280eda269c76b
Reviewed-on: https://review.typo3.org/58204
Tested-by: TYPO3com <no-reply@typo3.com>
Tested-by: Joerg Kummer <typo3@enobe.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: rolandgolla <rolandgolla@gmail.com>
Tested-by: rolandgolla <rolandgolla@gmail.com>
Reviewed-by: Andreas Fernandez <a.fernandez@scripting-base.de>
Tested-by: Andreas Fernandez <a.fernandez@scripting-base.de>
typo3/sysext/core/Configuration/DefaultConfiguration.php
typo3/sysext/info/Classes/Controller/PageInformationController.php

index 8d2d52e..c5e5bcc 100644 (file)
@@ -1218,7 +1218,7 @@ return [
             mod.web_info.fieldDefinitions {
                 0 {
                     label = LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:pages_0
-                    fields = title,uid,alias,slug,starttime,endtime,fe_group,target,url,shortcut,shortcut_mode
+                    fields = title,uid,slug,alias,starttime,endtime,fe_group,target,url,shortcut,shortcut_mode
                 }
                 1 {
                     label = LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:pages_1
index c4f4c86..38f1bd6 100644 (file)
@@ -14,9 +14,13 @@ namespace TYPO3\CMS\Info\Controller;
  * The TYPO3 project - inspiring people to share!
  */
 
+use Psr\Http\Message\ServerRequestInterface;
 use TYPO3\CMS\Backend\Utility\BackendUtility;
 use TYPO3\CMS\Backend\View\PageLayoutView;
 use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
+use TYPO3\CMS\Core\Site\Entity\NullSite;
+use TYPO3\CMS\Core\Site\Entity\PseudoSite;
+use TYPO3\CMS\Core\Site\Entity\Site;
 use TYPO3\CMS\Core\Utility\GeneralUtility;
 
 /**
@@ -47,7 +51,9 @@ class PageInformationController extends \TYPO3\CMS\Backend\Module\AbstractFuncti
             ]
         ];
 
-        $this->fillFieldConfiguration($this->pObj->id);
+        // Using $GLOBALS['TYPO3_REQUEST'] since $request is not available at this point
+        // @todo: Refactor AbstractFunctionModule mess and have $request available
+        $this->fillFieldConfiguration($this->pObj->id, $GLOBALS['TYPO3_REQUEST']);
         foreach ($this->fieldConfiguration as $key => $item) {
             $menu['pages'][$key] = $item['label'];
         }
@@ -61,7 +67,6 @@ 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';
@@ -136,13 +141,24 @@ class PageInformationController extends \TYPO3\CMS\Backend\Module\AbstractFuncti
      * Generate configuration for field selection
      *
      * @param int $pageId current page id
+     * @param ServerRequestInterface $request
      */
-    protected function fillFieldConfiguration(int $pageId)
+    protected function fillFieldConfiguration(int $pageId, ServerRequestInterface $request)
     {
         $modTSconfig = BackendUtility::getPagesTSconfig($pageId)['mod.']['web_info.']['fieldDefinitions.'] ?? [];
         foreach ($modTSconfig as $key => $item) {
             $fieldList = str_replace('###ALL_TABLES###', $this->cleanTableNames(), $item['fields']);
             $fields = GeneralUtility::trimExplode(',', $fieldList, true);
+            if ((int)$key === 0) {
+                // If "Basic settings" is rendered, hide the alias field on trees that have a site configuration
+                // and hide the slug field on PseudoSites. On NullSites (pid 0), show both.
+                $site = $request->getAttribute('site');
+                if ($site instanceof PseudoSite) {
+                    $fields = array_diff($fields, ['slug']);
+                } elseif ($site instanceof Site && !$site instanceof NullSite) {
+                    $fields = array_diff($fields, ['alias']);
+                }
+            }
             $key = trim($key, '.');
             $this->fieldConfiguration[$key] = [
                 'label' => $item['label'] ? $GLOBALS['LANG']->sL($item['label']) : $key,