‪TYPO3CMS  10.4
GeneralInformation.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
20 use Psr\Http\Message\ServerRequestInterface;
31 
39 {
43  public function ‪getDataToStore(ServerRequestInterface $request): ‪ModuleData
44  {
46  $frontendUserAspect = GeneralUtility::makeInstance(Context::class)->getAspect('frontend.user');
47  $tsfe = $this->‪getTypoScriptFrontendController();
48  return new ‪ModuleData(
49  [
50  'post' => $_POST,
51  'get' => $_GET,
52  'cookie' => $_COOKIE,
53  'server' => $_SERVER,
54  'info' => [
55  'pageUid' => $tsfe->id,
56  'pageType' => $tsfe->type,
57  'groupList' => implode(',', $frontendUserAspect->getGroupIds()),
58  'noCache' => $this->isNoCacheEnabled(),
59  'countUserInt' => count($tsfe->config['INTincScript'] ?? []),
60  'totalParsetime' => $this->getTimeTracker()->getParseTime(),
61  'feUser' => [
62  'uid' => $frontendUserAspect->get('id') ?: 0,
63  'username' => $frontendUserAspect->get('username') ?: '',
64  ],
65  'imagesOnPage' => $this->collectImagesOnPage(),
66  'documentSize' => $this->collectDocumentSize(),
67  ],
68  ]
69  );
70  }
71 
79  public function ‪getContent(‪ModuleData $data): string
80  {
81  $view = GeneralUtility::makeInstance(StandaloneView::class);
82  $templateNameAndPath = 'EXT:adminpanel/Resources/Private/Templates/Modules/Info/General.html';
83  $view->setTemplatePathAndFilename(GeneralUtility::getFileAbsFileName($templateNameAndPath));
84  $view->setPartialRootPaths(['EXT:adminpanel/Resources/Private/Partials']);
85 
86  $view->assignMultiple($data->getArrayCopy());
87  $view->assign('languageKey', $this->‪getBackendUser()->user['lang']);
88 
89  return $view->render();
90  }
91 
98  public function ‪getIdentifier(): string
99  {
100  return 'info_general';
101  }
102 
106  public function ‪getLabel(): string
107  {
108  return $this->‪getLanguageService()->‪sL(
109  'LLL:EXT:adminpanel/Resources/Private/Language/locallang_info.xlf:sub.general.label'
110  );
111  }
112 
119  protected function ‪collectImagesOnPage(): array
120  {
121  $imagesOnPage = [
122  'files' => [],
123  'total' => 0,
124  'totalSize' => 0,
125  'totalSizeHuman' => GeneralUtility::formatSize(0),
126  ];
127 
128  if ($this->‪isNoCacheEnabled() === false) {
129  return $imagesOnPage;
130  }
131 
132  $count = 0;
133  $totalImageSize = 0;
134  foreach (GeneralUtility::makeInstance(AssetCollector::class)->getMedia() as $file => $information) {
135  $fileSize = (int)@filesize($file);
136  $imagesOnPage['files'][] = [
137  'name' => $file,
138  'size' => $fileSize,
139  'sizeHuman' => GeneralUtility::formatSize($fileSize),
140  ];
141  $totalImageSize += $fileSize;
142  $count++;
143  }
144  $imagesOnPage['totalSize'] = GeneralUtility::formatSize($totalImageSize);
145  $imagesOnPage['total'] = $count;
146  return $imagesOnPage;
147  }
148 
154  protected function ‪collectDocumentSize(): string
155  {
156  $documentSize = 0;
157  if ($this->‪isNoCacheEnabled() === true) {
158  $documentSize = mb_strlen($this->‪getTypoScriptFrontendController()->content, 'UTF-8');
159  }
160 
161  return GeneralUtility::formatSize($documentSize);
162  }
163 
167  protected function ‪isNoCacheEnabled(): bool
168  {
169  return (bool)$this->‪getTypoScriptFrontendController()->no_cache;
170  }
171 
176  {
177  return ‪$GLOBALS['TSFE'];
178  }
179 
183  protected function ‪getTimeTracker(): ‪TimeTracker
184  {
185  return GeneralUtility::makeInstance(TimeTracker::class);
186  }
187 }
‪TYPO3\CMS\Adminpanel\Modules\Info\GeneralInformation\getLabel
‪getLabel()
Definition: GeneralInformation.php:106
‪TYPO3\CMS\Core\Page\AssetCollector
Definition: AssetCollector.php:44
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractSubModule\getLanguageService
‪LanguageService getLanguageService()
Definition: AbstractSubModule.php:35
‪TYPO3\CMS\Adminpanel\Modules\Info\GeneralInformation\getTimeTracker
‪TimeTracker getTimeTracker()
Definition: GeneralInformation.php:183
‪TYPO3\CMS\Adminpanel\Modules\Info\GeneralInformation\collectImagesOnPage
‪array collectImagesOnPage()
Definition: GeneralInformation.php:119
‪TYPO3\CMS\Adminpanel\Modules\Info\GeneralInformation\getIdentifier
‪string getIdentifier()
Definition: GeneralInformation.php:98
‪TYPO3\CMS\Adminpanel\ModuleApi\DataProviderInterface
Definition: DataProviderInterface.php:30
‪TYPO3\CMS\Core\Localization\LanguageService\sL
‪string sL($input)
Definition: LanguageService.php:194
‪TYPO3\CMS\Core\Context\Context
Definition: Context.php:53
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractSubModule\getBackendUser
‪getBackendUser()
Definition: AbstractSubModule.php:40
‪TYPO3\CMS\Adminpanel\Modules\Info\GeneralInformation\getTypoScriptFrontendController
‪TypoScriptFrontendController getTypoScriptFrontendController()
Definition: GeneralInformation.php:175
‪TYPO3\CMS\Adminpanel\Modules\Info\GeneralInformation\getDataToStore
‪getDataToStore(ServerRequestInterface $request)
Definition: GeneralInformation.php:43
‪TYPO3\CMS\Adminpanel\Modules\Info
Definition: GeneralInformation.php:18
‪TYPO3\CMS\Adminpanel\Modules\Info\GeneralInformation\getContent
‪string getContent(ModuleData $data)
Definition: GeneralInformation.php:79
‪TYPO3\CMS\Adminpanel\Modules\Info\GeneralInformation\collectDocumentSize
‪string collectDocumentSize()
Definition: GeneralInformation.php:154
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:34
‪TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
Definition: TypoScriptFrontendController.php:98
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Adminpanel\Modules\Info\GeneralInformation\isNoCacheEnabled
‪bool isNoCacheEnabled()
Definition: GeneralInformation.php:167
‪TYPO3\CMS\Adminpanel\ModuleApi\ModuleData
Definition: ModuleData.php:27
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\TimeTracker\TimeTracker
Definition: TimeTracker.php:30
‪TYPO3\CMS\Adminpanel\ModuleApi\AbstractSubModule
Definition: AbstractSubModule.php:29
‪TYPO3\CMS\Core\Context\UserAspect
Definition: UserAspect.php:38
‪TYPO3\CMS\Adminpanel\Modules\Info\GeneralInformation
Definition: GeneralInformation.php:39