‪TYPO3CMS  9.5
AboutController.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
17 use Psr\Http\Message\ResponseInterface;
22 use TYPO3\CMS\Core\Package\PackageManager;
25 use TYPO3Fluid\Fluid\View\ViewInterface;
26 
34 {
40  protected ‪$moduleTemplate;
41 
45  protected ‪$view;
46 
52  public function ‪indexAction(): ResponseInterface
53  {
54  $this->moduleTemplate = GeneralUtility::makeInstance(ModuleTemplate::class);
55  $this->‪initializeView('index');
56  $warnings = [];
57  // Hook for additional warnings
58  foreach (‪$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['displayWarningMessages'] ?? [] as $className) {
59  $hookObj = GeneralUtility::makeInstance($className);
60  if (method_exists($hookObj, 'displayWarningMessages_postProcess')) {
61  $hookObj->displayWarningMessages_postProcess($warnings);
62  }
63  }
64 
65  $this->view->assignMultiple([
66  'copyrightYear' => TYPO3_copyright_year,
67  'donationUrl' => TYPO3_URL_DONATE,
68  'currentVersion' => TYPO3_version,
69  'loadedExtensions' => $this->‪getLoadedExtensions(),
70  'copyRightNotice' => ‪BackendUtility::TYPO3_copyRightNotice(),
71  'warnings' => $warnings,
72  'modules' => $this->‪getModulesData()
73  ]);
74 
75  $this->moduleTemplate->setContent($this->view->render());
76  return new ‪HtmlResponse($this->moduleTemplate->renderContent());
77  }
78 
85  protected function ‪getModulesData(): array
86  {
87  $loadedModules = GeneralUtility::makeInstance(ModuleLoader::class);
88  $loadedModules->observeWorkspaces = true;
89  $loadedModules->load(‪$GLOBALS['TBE_MODULES']);
90  $mainModulesData = [];
91  foreach ($loadedModules->modules as $moduleName => $moduleInfo) {
92  $moduleLabels = $loadedModules->getLabelsForModule($moduleName);
93  $mainModuleData = [
94  'name' => $moduleName,
95  'label' => $moduleLabels['title']
96  ];
97  if (is_array($moduleInfo['sub']) && !empty($moduleInfo['sub'])) {
98  $mainModuleData['subModules'] = $this->‪getSubModuleData($loadedModules, $moduleName);
99  }
100  $mainModulesData[] = $mainModuleData;
101  }
102  return $mainModulesData;
103  }
104 
112  protected function ‪getSubModuleData(‪ModuleLoader $loadedModules, $moduleName): array
113  {
114  if (empty($loadedModules->modules[$moduleName]['sub'])) {
115  return [];
116  }
117 
118  $subModulesData = [];
119  foreach ($loadedModules->modules[$moduleName]['sub'] as $subModuleName => $subModuleInfo) {
120  $moduleLabels = $loadedModules->‪getLabelsForModule($moduleName . '_' . $subModuleName);
121  $subModuleData = [];
122  $subModuleData['name'] = $subModuleName;
123  $subModuleData['icon'] = $subModuleInfo['icon'] ?? null;
124  $subModuleData['iconIdentifier'] = $subModuleInfo['iconIdentifier'] ?? null;
125  $subModuleData['label'] = $moduleLabels['title'] ?? null;
126  $subModuleData['shortDescription'] = $moduleLabels['shortdescription'] ?? null;
127  $subModuleData['longDescription'] = $moduleLabels['description'] ?? null;
128  $subModulesData[] = $subModuleData;
129  }
130  return $subModulesData;
131  }
132 
138  protected function ‪getLoadedExtensions(): array
139  {
140  $extensions = [];
141  $packageManager = GeneralUtility::makeInstance(PackageManager::class);
142  foreach ($packageManager->getActivePackages() as $package) {
143  // Skip system extensions (= type: typo3-cms-framework)
144  if ($package->getValueFromComposerManifest('type') !== 'typo3-cms-extension') {
145  continue;
146  }
147  $extensions[] = [
148  'key' => $package->getPackageKey(),
149  'title' => $package->getPackageMetaData()->getDescription(),
150  'authors' => $package->getValueFromComposerManifest('authors')
151  ];
152  }
153  return $extensions;
154  }
155 
161  protected function ‪initializeView(string $templateName)
162  {
163  $this->view = GeneralUtility::makeInstance(StandaloneView::class);
164  $this->view->setTemplate($templateName);
165  $this->view->setTemplateRootPaths(['EXT:about/Resources/Private/Templates/About']);
166  $this->view->setPartialRootPaths(['EXT:about/Resources/Private/Partials']);
167  $this->view->setLayoutRootPaths(['EXT:about/Resources/Private/Layouts']);
168  }
169 }
‪TYPO3\CMS\About\Controller\AboutController\$view
‪ViewInterface $view
Definition: AboutController.php:43
‪TYPO3\CMS\About\Controller\AboutController\getModulesData
‪array getModulesData()
Definition: AboutController.php:83
‪TYPO3\CMS\About\Controller\AboutController\$moduleTemplate
‪ModuleTemplate $moduleTemplate
Definition: AboutController.php:39
‪TYPO3\CMS\Backend\Template\ModuleTemplate
Definition: ModuleTemplate.php:40
‪TYPO3\CMS\Backend\Module\ModuleLoader
Definition: ModuleLoader.php:32
‪TYPO3\CMS\About\Controller\AboutController\getSubModuleData
‪array getSubModuleData(ModuleLoader $loadedModules, $moduleName)
Definition: AboutController.php:110
‪TYPO3\CMS\About\Controller\AboutController
Definition: AboutController.php:34
‪TYPO3\CMS\Backend\Utility\BackendUtility
Definition: BackendUtility.php:72
‪TYPO3\CMS\Fluid\View\StandaloneView
Definition: StandaloneView.php:32
‪TYPO3\CMS\About\Controller
Definition: AboutController.php:2
‪$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:159
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\About\Controller\AboutController\getLoadedExtensions
‪array getLoadedExtensions()
Definition: AboutController.php:136
‪TYPO3\CMS\About\Controller\AboutController\indexAction
‪ResponseInterface indexAction()
Definition: AboutController.php:50
‪TYPO3\CMS\Backend\Module\ModuleLoader\getLabelsForModule
‪array getLabelsForModule($moduleName)
Definition: ModuleLoader.php:402
‪TYPO3\CMS\Backend\Utility\BackendUtility\TYPO3_copyRightNotice
‪static string TYPO3_copyRightNotice()
Definition: BackendUtility.php:4370
‪TYPO3\CMS\Core\Http\HtmlResponse
Definition: HtmlResponse.php:25