‪TYPO3CMS  10.4
AboutController.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
18 use Psr\Http\Message\ResponseInterface;
24 use TYPO3\CMS\Core\Package\PackageManager;
27 use TYPO3Fluid\Fluid\View\ViewInterface;
28 
36 {
42  protected ‪$moduleTemplate;
43 
47  protected ‪$view;
48 
52  protected ‪$version;
53 
57  protected ‪$typo3Information;
58 
60  {
61  $this->version = ‪$version;
62  $this->typo3Information = ‪$typo3Information;
63  }
64 
70  public function ‪indexAction(): ResponseInterface
71  {
72  $this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
73  $this->‪initializeView('index');
74  $warnings = [];
75  // Hook for additional warnings
76  foreach (‪$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['displayWarningMessages'] ?? [] as $className) {
77  $hookObj = GeneralUtility::makeInstance($className);
78  if (method_exists($hookObj, 'displayWarningMessages_postProcess')) {
79  $hookObj->displayWarningMessages_postProcess($warnings);
80  }
81  }
82 
83  $this->view->assignMultiple([
84  'copyrightYear' => $this->typo3Information->getCopyrightYear(),
85  'donationUrl' => $this->typo3Information::URL_DONATE,
86  'currentVersion' => $this->version->getVersion(),
87  'loadedExtensions' => $this->getLoadedExtensions(),
88  'copyRightNotice' => $this->typo3Information->getCopyrightNotice(),
89  'warnings' => $warnings,
90  'modules' => $this->getModulesData()
91  ]);
92 
93  $this->moduleTemplate->setContent($this->view->render());
94  return new HtmlResponse($this->moduleTemplate->renderContent());
95  }
96 
103  protected function ‪getModulesData(): array
104  {
105  $loadedModules = GeneralUtility::makeInstance(ModuleLoader::class);
106  $loadedModules->observeWorkspaces = true;
107  $loadedModules->load(‪$GLOBALS['TBE_MODULES']);
108  $mainModulesData = [];
109  foreach ($loadedModules->modules as $moduleName => $moduleInfo) {
110  $moduleLabels = $loadedModules->getLabelsForModule($moduleName);
111  $mainModuleData = [
112  'name' => $moduleName,
113  'label' => $moduleLabels['title']
114  ];
115  if (is_array($moduleInfo['sub']) && !empty($moduleInfo['sub'])) {
116  $mainModuleData['subModules'] = $this->‪getSubModuleData($loadedModules, $moduleName);
117  }
118  $mainModulesData[] = $mainModuleData;
119  }
120  return $mainModulesData;
121  }
122 
130  protected function ‪getSubModuleData(ModuleLoader $loadedModules, $moduleName): array
131  {
132  if (empty($loadedModules->modules[$moduleName]['sub'])) {
133  return [];
134  }
135 
136  $subModulesData = [];
137  foreach ($loadedModules->modules[$moduleName]['sub'] as $subModuleName => $subModuleInfo) {
138  $moduleLabels = $loadedModules->getLabelsForModule($moduleName . '_' . $subModuleName);
139  $subModuleData = [];
140  $subModuleData['name'] = $subModuleName;
141  $subModuleData['icon'] = $subModuleInfo['icon'] ?? null;
142  $subModuleData['iconIdentifier'] = $subModuleInfo['iconIdentifier'] ?? null;
143  $subModuleData['label'] = $moduleLabels['title'] ?? null;
144  $subModuleData['shortDescription'] = $moduleLabels['shortdescription'] ?? null;
145  $subModuleData['longDescription'] = $moduleLabels['description'] ?? null;
146  $subModulesData[] = $subModuleData;
147  }
148  return $subModulesData;
149  }
150 
156  protected function ‪getLoadedExtensions(): array
157  {
158  $extensions = [];
159  $packageManager = GeneralUtility::makeInstance(PackageManager::class);
160  foreach ($packageManager->getActivePackages() as $package) {
161  // Skip system extensions (= type: typo3-cms-framework)
162  if ($package->getValueFromComposerManifest('type') !== 'typo3-cms-extension') {
163  continue;
164  }
165  $extensions[] = [
166  'key' => $package->getPackageKey(),
167  'title' => $package->getPackageMetaData()->getDescription(),
168  'authors' => $package->getValueFromComposerManifest('authors')
169  ];
170  }
171  return $extensions;
172  }
173 
179  protected function ‪initializeView(string $templateName)
180  {
181  $this->view = GeneralUtility::makeInstance(StandaloneView::class);
182  $this->view->setTemplate($templateName);
183  $this->view->setTemplateRootPaths(['EXT:about/Resources/Private/Templates/About']);
184  $this->view->setPartialRootPaths(['EXT:about/Resources/Private/Partials']);
185  $this->view->setLayoutRootPaths(['EXT:about/Resources/Private/Layouts']);
186  }
187 }
‪TYPO3\CMS\Core\Information\Typo3Information
Definition: Typo3Information.php:26
‪TYPO3\CMS\Core\Information\Typo3Version
Definition: Typo3Version.php:21
‪TYPO3\CMS\About\Controller\AboutController\$view
‪ViewInterface $view
Definition: AboutController.php:45
‪TYPO3\CMS\About\Controller\AboutController\getModulesData
‪array getModulesData()
Definition: AboutController.php:99
‪TYPO3\CMS\About\Controller\AboutController\$moduleTemplate
‪ModuleTemplate $moduleTemplate
Definition: AboutController.php:41
‪TYPO3\CMS\About\Controller\AboutController\__construct
‪__construct(Typo3Version $version, Typo3Information $typo3Information)
Definition: AboutController.php:55
‪TYPO3\CMS\Backend\Template\ModuleTemplate
Definition: ModuleTemplate.php:43
‪TYPO3\CMS\About\Controller\AboutController\$version
‪Typo3Version $version
Definition: AboutController.php:49
‪TYPO3\CMS\Backend\Module\ModuleLoader
Definition: ModuleLoader.php:34
‪TYPO3\CMS\About\Controller\AboutController\getSubModuleData
‪array getSubModuleData(ModuleLoader $loadedModules, $moduleName)
Definition: AboutController.php:126
‪TYPO3\CMS\About\Controller\AboutController
Definition: AboutController.php:36
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:34
‪TYPO3\CMS\About\Controller
Definition: AboutController.php:16
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\About\Controller\AboutController\initializeView
‪initializeView(string $templateName)
Definition: AboutController.php:175
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\About\Controller\AboutController\$typo3Information
‪Typo3Information $typo3Information
Definition: AboutController.php:53
‪TYPO3\CMS\About\Controller\AboutController\getLoadedExtensions
‪array getLoadedExtensions()
Definition: AboutController.php:152
‪TYPO3\CMS\About\Controller\AboutController\indexAction
‪ResponseInterface indexAction()
Definition: AboutController.php:66
‪TYPO3\CMS\Backend\Module\ModuleLoader\getLabelsForModule
‪array getLabelsForModule($moduleName)
Definition: ModuleLoader.php:390
‪TYPO3\CMS\Core\Http\HtmlResponse
Definition: HtmlResponse.php:26