From 6d5469838677cd978d361d49d7cf36d50667e981 Mon Sep 17 00:00:00 2001
From: Michael Oehlhof <typo3@oehlhof.de>
Date: Sun, 25 Dec 2016 22:57:29 +0100
Subject: [PATCH] [BUGFIX] EXT:info_pagetsconfig Optimized view on page 0

If there are no pages containing Page TSconfig settings in the page
configuration an info FlashMessage is shown instead of an empty table.

Resolves: #78509
Releases: master
Change-Id: I4a5cda38746187a1147e5500e77b516cb9a85fd6
Reviewed-on: https://review.typo3.org/51043
Reviewed-by: Josef Glatz <josef.glatz@typo3.org>
Tested-by: Josef Glatz <josef.glatz@typo3.org>
Tested-by: Riccardo De Contardi <erredeco@gmail.com>
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 .../InfoPageTyposcriptConfigController.php    |  7 +++-
 .../Resources/Private/Language/locallang.xlf  |  3 ++
 .../Resources/Private/Partials/PageZero.html  | 39 +++++++++++--------
 3 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/typo3/sysext/info_pagetsconfig/Classes/Controller/InfoPageTyposcriptConfigController.php b/typo3/sysext/info_pagetsconfig/Classes/Controller/InfoPageTyposcriptConfigController.php
index 689eddea452b..7418c96d75bd 100644
--- a/typo3/sysext/info_pagetsconfig/Classes/Controller/InfoPageTyposcriptConfigController.php
+++ b/typo3/sysext/info_pagetsconfig/Classes/Controller/InfoPageTyposcriptConfigController.php
@@ -95,7 +95,10 @@ class InfoPageTyposcriptConfigController extends \TYPO3\CMS\Backend\Module\Abstr
 
         if ($pageId === 0) {
             $this->view->assign('pageZero', 1);
-            $this->view->assign('overviewOfPagesUsingTSConfig', $this->getOverviewOfPagesUsingTSConfig());
+            $pagesUsingTSConfig = $this->getOverviewOfPagesUsingTSConfig();
+            if (count($pagesUsingTSConfig) > 0) {
+                $this->view->assign('overviewOfPagesUsingTSConfig', $pagesUsingTSConfig);
+            }
         } else {
             if ($this->pObj->MOD_SETTINGS['tsconf_parts'] == 99) {
                 $TSparts = BackendUtility::getPagesTSconfig($this->pObj->id, null, true);
@@ -328,7 +331,7 @@ class InfoPageTyposcriptConfigController extends \TYPO3\CMS\Backend\Module\Abstr
                 continue;
             }
             $line = [];
-            $line['padding'] = ($pageDepth * 20);
+            $line['padding'] = ($pageDepth * 20) + 10;
             if (isset($pageArray[$identifier . '_'])) {
                 $line['link'] = GeneralUtility::linkThisScript(['id' => $identifier]);
                 $line['icon'] = $this->iconFactory->getIconForRecord('pages', BackendUtility::getRecordWSOL('pages', $identifier), Icon::SIZE_SMALL)->render();
diff --git a/typo3/sysext/info_pagetsconfig/Resources/Private/Language/locallang.xlf b/typo3/sysext/info_pagetsconfig/Resources/Private/Language/locallang.xlf
index e67c8c58b08e..78ed91b265d8 100644
--- a/typo3/sysext/info_pagetsconfig/Resources/Private/Language/locallang.xlf
+++ b/typo3/sysext/info_pagetsconfig/Resources/Private/Language/locallang.xlf
@@ -63,6 +63,9 @@
 			<trans-unit id="written_tsconfig_lines">
 				<source>Lines:</source>
 			</trans-unit>
+			<trans-unit id="tsconf_noPageTSconfig">
+				<source>There are no pages containing custom Page TSconfig settings in the page configuration.</source>
+			</trans-unit>
 		</body>
 	</file>
 </xliff>
diff --git a/typo3/sysext/info_pagetsconfig/Resources/Private/Partials/PageZero.html b/typo3/sysext/info_pagetsconfig/Resources/Private/Partials/PageZero.html
index 5ce6e459d18d..fbeafd8f24ed 100644
--- a/typo3/sysext/info_pagetsconfig/Resources/Private/Partials/PageZero.html
+++ b/typo3/sysext/info_pagetsconfig/Resources/Private/Partials/PageZero.html
@@ -1,18 +1,25 @@
 <div class="nowrap">
-    <div class="table-fit">
-        <table class="table table-striped table-hover" id="tsconfig-overview">
-            <thead>
-                <tr>
-                    <th>{f:translate(key: 'LLL:EXT:info_pagetsconfig/Resources/Private/Language/locallang.xlf:pagetitle')}</th>
-                    <th>{f:translate(key: 'LLL:EXT:info_pagetsconfig/Resources/Private/Language/locallang.xlf:included_tsconfig_files')}</th>
-                    <th>{f:translate(key: 'LLL:EXT:info_pagetsconfig/Resources/Private/Language/locallang.xlf:written_tsconfig_lines')}</th>
-                </tr>
-            </thead>
-            <tbody>
-                <f:for each="{overviewOfPagesUsingTSConfig}" as="line">
-                    <f:render partial="PageZeroTableRow" arguments="{line: line}" />
-                </f:for>
-            </tbody>
-        </table>
-    </div>
+    <f:if condition="{overviewOfPagesUsingTSConfig}">
+        <f:then>
+            <div class="table-fit">
+                <table class="table table-striped table-hover" id="tsconfig-overview">
+                    <thead>
+                        <tr>
+                            <th>{f:translate(key: 'LLL:EXT:info_pagetsconfig/Resources/Private/Language/locallang.xlf:pagetitle')}</th>
+                            <th>{f:translate(key: 'LLL:EXT:info_pagetsconfig/Resources/Private/Language/locallang.xlf:included_tsconfig_files')}</th>
+                            <th>{f:translate(key: 'LLL:EXT:info_pagetsconfig/Resources/Private/Language/locallang.xlf:written_tsconfig_lines')}</th>
+                        </tr>
+                    </thead>
+                    <tbody>
+                        <f:for each="{overviewOfPagesUsingTSConfig}" as="line">
+                            <f:render partial="PageZeroTableRow" arguments="{line: line}" />
+                        </f:for>
+                    </tbody>
+                </table>
+            </div>
+        </f:then>
+        <f:else>
+            <f:be.infobox message="{f:translate(key: 'LLL:EXT:info_pagetsconfig/Resources/Private/Language/locallang.xlf:tsconf_noPageTSconfig')}" state="-1" />
+        </f:else>
+    </f:if>
 </div>
\ No newline at end of file
-- 
GitLab