From b380d810e41ae674c185de1e3a4d98a5155f0b60 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jasmina=20Lie=C3=9Fmann?= <minapokhalo+typo3@gmail.com>
Date: Tue, 18 Jun 2024 15:52:58 +0200
Subject: [PATCH] [TASK] Add info boxes to "Info" module and its submodules
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

If a user does not have access to the module or no page is selected
when using the module, a corresponding info box will now be displayed.

Resolves: #104148
Releases: main, 12.4
Change-Id: I3603063ce84f3db8ce5dae508df3b44f59fa94a2
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/84778
Reviewed-by: Jasmina Ließmann <minapokhalo+typo3@gmail.com>
Tested-by: core-ci <typo3@b13.com>
Tested-by: Jasmina Ließmann <minapokhalo+typo3@gmail.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Garvin Hicking <gh@faktor-e.de>
Reviewed-by: Garvin Hicking <gh@faktor-e.de>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
---
 .../Language/locallang_mod_web_info.xlf       |  6 --
 .../Private/Language/locallang_webinfo.xlf    | 12 ++++
 .../Resources/Private/Templates/Main.html     |  8 ++-
 .../Private/Templates/PageInformation.html    | 68 ++++++++++++-------
 .../Private/Templates/TranslationStatus.html  | 67 +++++++++++-------
 5 files changed, 103 insertions(+), 58 deletions(-)

diff --git a/typo3/sysext/info/Resources/Private/Language/locallang_mod_web_info.xlf b/typo3/sysext/info/Resources/Private/Language/locallang_mod_web_info.xlf
index ecf481b4e607..116a3224cb74 100644
--- a/typo3/sysext/info/Resources/Private/Language/locallang_mod_web_info.xlf
+++ b/typo3/sysext/info/Resources/Private/Language/locallang_mod_web_info.xlf
@@ -3,12 +3,6 @@
 	<file source-language="en" datatype="plaintext" original="EXT:info/Resources/Private/Language/locallang_mod_web_info.xlf" date="2011-10-17T20:22:34Z" product-name="lang">
 		<header/>
 		<body>
-			<trans-unit id="title" resname="title">
-				<source>Page information</source>
-			</trans-unit>
-			<trans-unit id="message" resname="message">
-				<source>There are no page information available.</source>
-			</trans-unit>
 			<trans-unit id="mlang_labels_tablabel" resname="mlang_labels_tablabel">
 				<source>Page related information, eg. hit statistics, change log, record counts</source>
 			</trans-unit>
diff --git a/typo3/sysext/info/Resources/Private/Language/locallang_webinfo.xlf b/typo3/sysext/info/Resources/Private/Language/locallang_webinfo.xlf
index fa165b5543d8..6e1cf3e2298e 100644
--- a/typo3/sysext/info/Resources/Private/Language/locallang_webinfo.xlf
+++ b/typo3/sysext/info/Resources/Private/Language/locallang_webinfo.xlf
@@ -102,6 +102,18 @@
 			<trans-unit id="moduleFunctions.lang" resname="moduleFunctions.lang">
 				<source>Language</source>
 			</trans-unit>
+			<trans-unit id="error.noAccess.title" resname="error.noAccess.title">
+				<source>No access</source>
+			</trans-unit>
+			<trans-unit id="error.noAccess.message" resname="error.noAccess.message">
+				<source>You don't have access to this module.</source>
+			</trans-unit>
+			<trans-unit id="info.noContent.message" resname="info.noContent.message">
+				<source>There are no page information available.</source>
+			</trans-unit>
+			<trans-unit id="info.noPageSelected.message" resname="info.noPageSelected.message">
+				<source>Please select a page in the page tree.</source>
+			</trans-unit>
 		</body>
 	</file>
 </xliff>
diff --git a/typo3/sysext/info/Resources/Private/Templates/Main.html b/typo3/sysext/info/Resources/Private/Templates/Main.html
index f547787b4c45..d3af01980b6d 100644
--- a/typo3/sysext/info/Resources/Private/Templates/Main.html
+++ b/typo3/sysext/info/Resources/Private/Templates/Main.html
@@ -7,9 +7,11 @@
 
 <f:section name="Content">
 
-    <f:be.infobox title="{f:translate(key: 'LLL:EXT:info/Resources/Private/Language/locallang_mod_web_info.xlf:title')}" state="2">
-        <p><f:translate key="LLL:EXT:info/Resources/Private/Language/locallang_mod_web_info.xlf:message" /></p>
-    </f:be.infobox>
+    <f:be.infobox
+        title="{f:translate(key:'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:error.noAccess.title')}"
+        message="{f:translate(key:'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:error.noAccess.message')}"
+        state="2"
+    />
 
 </f:section>
 
diff --git a/typo3/sysext/info/Resources/Private/Templates/PageInformation.html b/typo3/sysext/info/Resources/Private/Templates/PageInformation.html
index db24f00a9761..694fc812ee7e 100644
--- a/typo3/sysext/info/Resources/Private/Templates/PageInformation.html
+++ b/typo3/sysext/info/Resources/Private/Templates/PageInformation.html
@@ -25,35 +25,51 @@
 
     <f:if condition="{accessContent}">
         <f:then>
-            <h1>
-                <f:translate key="LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:page_title"/>
-            </h1>
-            <f:if condition="{content}">
-
-                <form action="{f:be.uri(route: 'web_info_overview', parameters: '{id: pageUid}')}" method="post">
-                    <div class="form-row">
-                        <div class="form-group">
-                            <label class="form-label" for="depth">
-                                <f:translate key="LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:moduleFunctions.depth"/>
-                            </label>
-                            <f:render partial="DropdownMenu" arguments="{name: 'depth', id: 'depth', options: depthDropdownOptions, currentValue: depthDropdownCurrentValue}"/>
-                        </div>
-                        <div class="form-group">
-                            <label class="form-label" for="pages">
-                                <f:translate key="LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:moduleFunctions.type"/>
-                            </label>
-                            <f:render partial="DropdownMenu" arguments="{name: 'pages', id: 'pages', options: pagesDropdownOptions, currentValue: pagesDropdownCurrentValue}"/>
-                        </div>
-                    </div>
-                </form>
-
-                <f:format.raw>{content}</f:format.raw>
+            <h1><f:translate key="LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:page_title" /></h1>
+            <f:if condition="{pageUid}">
+                <f:then>
+                    <f:if condition="{content}">
+                        <f:then>
+                            <form action="{f:be.uri(route: 'web_info_overview', parameters: '{id: pageUid}')}" method="post">
+                                <div class="form-row">
+                                    <div class="form-group">
+                                        <label class="form-label" for="depth">
+                                            <f:translate key="LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:moduleFunctions.depth"/>
+                                        </label>
+                                        <f:render partial="DropdownMenu" arguments="{name: 'depth', id: 'depth', options: depthDropdownOptions, currentValue: depthDropdownCurrentValue}"/>
+                                    </div>
+                                    <div class="form-group">
+                                        <label class="form-label" for="pages">
+                                            <f:translate key="LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:moduleFunctions.type"/>
+                                        </label>
+                                        <f:render partial="DropdownMenu" arguments="{name: 'pages', id: 'pages', options: pagesDropdownOptions, currentValue: pagesDropdownCurrentValue}"/>
+                                    </div>
+                                </div>
+                            </form>
+                            <f:format.raw>{content}</f:format.raw>
+                        </f:then>
+                        <f:else>
+                            <f:be.infobox
+                                message="{f:translate(key:'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:info.noContent.message')}"
+                                state="-2"
+                            />
+                        </f:else>
+                    </f:if>
+                </f:then>
+                <f:else>
+                    <f:be.infobox
+                        message="{f:translate(key:'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:info.noPageSelected.message')}"
+                        state="-1"
+                    />
+                </f:else>
             </f:if>
         </f:then>
         <f:else>
-            <f:be.infobox title="{f:translate(key: 'LLL:EXT:info/Resources/Private/Language/locallang_mod_web_info.xlf:title')}" state="2">
-                <p><f:translate key="LLL:EXT:info/Resources/Private/Language/locallang_mod_web_info.xlf:message"/></p>
-            </f:be.infobox>
+            <f:be.infobox
+                title="{f:translate(key:'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:error.noAccess.title')}"
+                message="{f:translate(key:'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:error.noAccess.message')}"
+                state="2"
+            />
         </f:else>
     </f:if>
 
diff --git a/typo3/sysext/info/Resources/Private/Templates/TranslationStatus.html b/typo3/sysext/info/Resources/Private/Templates/TranslationStatus.html
index c172fc743f3a..e8ad3d12720f 100644
--- a/typo3/sysext/info/Resources/Private/Templates/TranslationStatus.html
+++ b/typo3/sysext/info/Resources/Private/Templates/TranslationStatus.html
@@ -27,32 +27,53 @@
     <f:if condition="{accessContent}">
         <f:then>
             <h1><f:translate key="LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:lang_title" /></h1>
-            <f:if condition="{content}">
-                <form action="{f:be.uri(route: 'web_info_translations', parameters: '{id: pageUid}')}" method="post" id="InfoModuleController" name="webinfoForm">
-                    <div class="form-row">
-                        <div class="form-group">
-                            <label class="form-label" for="depth">
-                                <f:translate key="LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:moduleFunctions.depth" />
-                            </label>
-                            <f:render partial="DropdownMenu" arguments="{name: 'depth', id: 'depth', options: depthDropdownOptions, currentValue: depthDropdownCurrentValue}"/>
-                        </div>
-                        <f:if condition="{displayLangDropdown}">
-                            <div class="form-group">
-                                <label class="form-label" for="lang">
-                                    <f:translate key="LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:moduleFunctions.lang" />
-                                </label>
-                                <f:render partial="DropdownMenu" arguments="{name: 'lang', id: 'lang', options: langDropdownOptions, currentValue: langDropdownCurrentValue}"/>
-                            </div>
-                        </f:if>
-                    </div>
-                    <f:format.raw>{content}</f:format.raw>
-                </form>
+            <f:if condition="{pageUid}">
+                <f:then>
+                    <f:if condition="{content}">
+                        <f:then>
+                            <form action="{f:be.uri(route: 'web_info_translations', parameters: '{id: pageUid}')}" method="post" id="InfoModuleController" name="webinfoForm">
+                                <div class="form-row">
+                                    <div class="form-group">
+                                        <label class="form-label" for="depth">
+                                            <f:translate key="LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:moduleFunctions.depth" />
+                                        </label>
+                                        <f:render partial="DropdownMenu" arguments="{name: 'depth', id: 'depth', options: depthDropdownOptions, currentValue: depthDropdownCurrentValue}"/>
+                                    </div>
+                                    <f:if condition="{displayLangDropdown}">
+                                        <div class="form-group">
+                                            <label class="form-label" for="lang">
+                                                <f:translate key="LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:moduleFunctions.lang" />
+                                            </label>
+                                            <f:render partial="DropdownMenu" arguments="{name: 'lang', id: 'lang', options: langDropdownOptions, currentValue: langDropdownCurrentValue}"/>
+                                        </div>
+                                    </f:if>
+                                </div>
+                                <f:format.raw>{content}</f:format.raw>
+                            </form>
+                        </f:then>
+                        <f:else>
+                            <f:be.infobox
+                                message="{f:translate(key:'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:info.noContent.message')}"
+                                state="-2"
+                            />
+                        </f:else>
+                    </f:if>
+                </f:then>
+                <f:else>
+                    <f:be.infobox
+                        message="{f:translate(key:'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:info.noPageSelected.message')}"
+                        state="-1"
+                    />
+                </f:else>
             </f:if>
         </f:then>
         <f:else>
-            <f:be.infobox title="{f:translate(key: 'LLL:EXT:info/Resources/Private/Language/locallang_mod_web_info.xlf:title')}" state="2">
-                <p><f:translate key="LLL:EXT:info/Resources/Private/Language/locallang_mod_web_info.xlf:message" /></p>
-            </f:be.infobox>
+            <f:be.infobox
+                title="{f:translate(key:'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:error.noAccess.title')}"
+                message="{f:translate(key:'LLL:EXT:info/Resources/Private/Language/locallang_webinfo.xlf:error.noAccess.message')}"
+                state="2"
+            />
+
         </f:else>
     </f:if>
 
-- 
GitLab