Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Page title providers visible in admin panel
The PageTitleProviders are now visible within the adminpanel debug panel. Since this information is in no way available when the page is cached, there's a message to view the page in uncached mode. Resolves: #88609 Releases: master Change-Id: I15b3187fb219ea488ea88950906545391994bc24 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/61116 Tested-by: TYPO3com <noreply@typo3.com> Tested-by: Susanne Moog <look@susi.dev> Tested-by: Daniel Goerz <daniel.goerz@posteo.de> Reviewed-by: Susanne Moog <look@susi.dev> Reviewed-by: Daniel Goerz <daniel.goerz@posteo.de>
- Loading branch information
Showing
5 changed files
with
237 additions
and
3 deletions.
There are no files selected for viewing
124 changes: 124 additions & 0 deletions
124
typo3/sysext/adminpanel/Classes/Modules/Debug/PageTitle.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace TYPO3\CMS\Adminpanel\Modules\Debug; | ||
|
||
/* | ||
* This file is part of the TYPO3 CMS project. | ||
* | ||
* It is free software; you can redistribute it and/or modify it under | ||
* the terms of the GNU General Public License, either version 2 | ||
* of the License, or any later version. | ||
* | ||
* For the full copyright and license information, please read the | ||
* LICENSE.txt file that was distributed with this source code. | ||
* | ||
* The TYPO3 project - inspiring people to share! | ||
*/ | ||
|
||
use Psr\Http\Message\ServerRequestInterface; | ||
use TYPO3\CMS\Adminpanel\Log\InMemoryLogWriter; | ||
use TYPO3\CMS\Adminpanel\ModuleApi\AbstractSubModule; | ||
use TYPO3\CMS\Adminpanel\ModuleApi\DataProviderInterface; | ||
use TYPO3\CMS\Adminpanel\ModuleApi\ModuleData; | ||
use TYPO3\CMS\Fluid\View\StandaloneView; | ||
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; | ||
|
||
/** | ||
* Admin Panel Page Title module for showing the Page title providers | ||
* | ||
* @internal | ||
*/ | ||
class PageTitle extends AbstractSubModule implements DataProviderInterface | ||
{ | ||
/** | ||
* Log component | ||
*/ | ||
protected const LOG_COMPONENT = 'TYPO3.CMS.Core.PageTitle.PageTitleProviderManager'; | ||
|
||
/** | ||
* Identifier for this Sub-module, | ||
* for example "preview" or "cache" | ||
* | ||
* @return string | ||
*/ | ||
public function getIdentifier(): string | ||
{ | ||
return 'debug_pagetitle'; | ||
} | ||
|
||
/** | ||
* Sub-Module label | ||
* | ||
* @return string | ||
*/ | ||
public function getLabel(): string | ||
{ | ||
return $this->getLanguageService()->sL( | ||
'LLL:EXT:adminpanel/Resources/Private/Language/locallang_debug.xlf:submodule.pageTitle.label' | ||
); | ||
} | ||
|
||
/** | ||
* @param ServerRequestInterface $request | ||
* @return \TYPO3\CMS\Adminpanel\ModuleApi\ModuleData | ||
*/ | ||
public function getDataToStore(ServerRequestInterface $request): ModuleData | ||
{ | ||
if ($this->isNoCacheEnabled()) { | ||
$data = [ | ||
'orderedProviders' => [], | ||
'usedProvider' => null, | ||
'skippedProviders' => [] | ||
]; | ||
|
||
$log = InMemoryLogWriter::$log; | ||
/** @var \TYPO3\CMS\Core\Log\LogRecord $logEntry */ | ||
foreach ($log as $logEntry) { | ||
if ($logEntry->getComponent() === self::LOG_COMPONENT) { | ||
if (isset($logEntry->getData()['orderedTitleProviders'])) { | ||
$data['orderedProviders'] = $logEntry->getData()['orderedTitleProviders']; | ||
} elseif (isset($logEntry->getData()['providerUsed'])) { | ||
$data['usedProvider'] = $logEntry->getData(); | ||
} elseif (isset($logEntry->getData()['skippedProvider'])) { | ||
$data['skippedProviders'][] = $logEntry->getData(); | ||
} | ||
} | ||
} | ||
} else { | ||
$data['cacheEnabled'] = true; | ||
} | ||
return new ModuleData($data); | ||
} | ||
|
||
/** | ||
* @param \TYPO3\CMS\Adminpanel\ModuleApi\ModuleData $data | ||
* @return string Returns content of admin panel | ||
*/ | ||
public function getContent(ModuleData $data): string | ||
{ | ||
$view = new StandaloneView(); | ||
$view->setTemplatePathAndFilename( | ||
'EXT:adminpanel/Resources/Private/Templates/Modules/Debug/PageTitle.html' | ||
); | ||
$this->getLanguageService()->includeLLFile('EXT:adminpanel/Resources/Private/Language/locallang_debug.xlf'); | ||
$view->assignMultiple($data->getArrayCopy()); | ||
return $view->render(); | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
protected function isNoCacheEnabled(): bool | ||
{ | ||
return (bool)$this->getTypoScriptFrontendController()->no_cache; | ||
} | ||
|
||
/** | ||
* @return TypoScriptFrontendController | ||
*/ | ||
protected function getTypoScriptFrontendController(): TypoScriptFrontendController | ||
{ | ||
return $GLOBALS['TSFE']; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
typo3/sysext/adminpanel/Resources/Private/Templates/Modules/Debug/PageTitle.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" data-namespace-typo3-fluid="true"> | ||
<f:if condition="{cacheEnabled}"> | ||
<f:then> | ||
<p><f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang_debug.xlf:submodule.pageTitle.cacheEnabled" /></p> | ||
<p><f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang_debug.xlf:submodule.pageTitle.cacheEnabled.extraInfo" /></p> | ||
</f:then> | ||
<f:else> | ||
<h2 class="typo3-adminPanel-headline"><f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang_debug.xlf:submodule.pageTitle.usedProvider" /></h2> | ||
<div class="typo3-adminPanel-table-overflow"> | ||
<table class="typo3-adminPanel-table typo3-adminPanel-table-debug"> | ||
<thead> | ||
<tr> | ||
<th scope="col" class="typo3-adminPanel-table-cell-key"><f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang_debug.xlf:submodule.pageTitle.title" /></th> | ||
<th scope="col" class="typo3-adminPanel-table-cell-key"><f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang_debug.xlf:submodule.pageTitle.provider" /></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr> | ||
<td>{usedProvider.title}</td> | ||
<td>{usedProvider.providerUsed}</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
<h2 class="typo3-adminPanel-headline"><f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang_debug.xlf:submodule.pageTitle.skippedProviders" /></h2> | ||
<div class="typo3-adminPanel-table-overflow"> | ||
<table class="typo3-adminPanel-table typo3-adminPanel-table-debug"> | ||
<thead> | ||
<tr> | ||
<th scope="col" class="typo3-adminPanel-table-cell-key"><f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang_debug.xlf:submodule.pageTitle.name" /></th> | ||
<th scope="col" class="typo3-adminPanel-table-cell-key"><f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang_debug.xlf:submodule.pageTitle.provider" /></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<f:for each="{skippedProviders}" as="providerInformation"> | ||
<tr> | ||
<td>{providerInformation.name}</td> | ||
<td>{providerInformation.skippedProvider}</td> | ||
</tr> | ||
</f:for> | ||
</tbody> | ||
</table> | ||
</div> | ||
<h2 class="typo3-adminPanel-headline"><f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang_debug.xlf:submodule.pageTitle.allProviders" /></h2> | ||
<div class="typo3-adminPanel-table-overflow"> | ||
<table class="typo3-adminPanel-table typo3-adminPanel-table-debug"> | ||
<thead> | ||
<tr> | ||
<th scope="col" class="typo3-adminPanel-table-cell-key"><f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang_debug.xlf:submodule.pageTitle.name" /></th> | ||
<th scope="col" class="typo3-adminPanel-table-cell-key"><f:translate key="LLL:EXT:adminpanel/Resources/Private/Language/locallang_debug.xlf:submodule.pageTitle.provider" /></th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<f:for each="{orderedProviders}" as="providerInformation" key="name"> | ||
<tr> | ||
<td>{name}</td> | ||
<td>{providerInformation.provider}</td> | ||
</tr> | ||
</f:for> | ||
</tbody> | ||
</table> | ||
</div> | ||
</f:else> | ||
</f:if> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters