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