[TASK] Remove overkill extension classes in about module
[Packages/TYPO3.CMS.git] / typo3 / sysext / about / Classes / Controller / AboutController.php
1 <?php
2 namespace TYPO3\CMS\About\Controller;
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 TYPO3\CMS\Backend\Module\ModuleLoader;
18 use TYPO3\CMS\Backend\Utility\BackendUtility;
19 use TYPO3\CMS\Backend\View\BackendTemplateView;
20 use TYPO3\CMS\Core\Package\PackageManager;
21 use TYPO3\CMS\Core\Utility\GeneralUtility;
22 use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
23 use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
24
25 /**
26 * Module 'about' shows some standard information for TYPO3 CMS: About-text, version number, available modules and so on.
27 */
28 class AboutController extends ActionController
29 {
30 /**
31 * @var ViewInterface
32 */
33 protected $defaultViewObjectName = BackendTemplateView::class;
34
35 /**
36 * Set up the doc header properly here
37 *
38 * @param ViewInterface $view
39 */
40 protected function initializeView(ViewInterface $view)
41 {
42 /** @var BackendTemplateView $view */
43 parent::initializeView($view);
44 // Disable Path
45 $view->getModuleTemplate()->getDocHeaderComponent()->setMetaInformation([]);
46 }
47
48 /**
49 * Main action: Show standard information
50 */
51 public function indexAction()
52 {
53 $warnings = [];
54 // Hook for additional warnings
55 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['displayWarningMessages'] ?? [] as $className) {
56 $hookObj = GeneralUtility::makeInstance($className);
57 if (method_exists($hookObj, 'displayWarningMessages_postProcess')) {
58 $hookObj->displayWarningMessages_postProcess($warnings);
59 }
60 }
61
62 $this->view->assignMultiple([
63 'copyrightYear' => TYPO3_copyright_year,
64 'donationUrl' => TYPO3_URL_DONATE,
65 'currentVersion' => TYPO3_version,
66 'loadedExtensions' => $this->getLoadedExtensions(),
67 'copyRightNotice' => BackendUtility::TYPO3_copyRightNotice(),
68 'warnings' => $warnings,
69 'modules' => $this->getModulesData()
70 ]);
71 }
72
73 /**
74 * Create array with data of all main modules (Web, File, ...)
75 * and its nested sub modules
76 *
77 * @return array
78 */
79 protected function getModulesData()
80 {
81 $loadedModules = GeneralUtility::makeInstance(ModuleLoader::class);
82 $loadedModules->observeWorkspaces = true;
83 $loadedModules->load($GLOBALS['TBE_MODULES']);
84 $mainModulesData = [];
85 foreach ($loadedModules->modules as $moduleName => $moduleInfo) {
86 $moduleLabels = $loadedModules->getLabelsForModule($moduleName);
87 $mainModuleData = [
88 'name' => $moduleName,
89 'label' => $moduleLabels['title']
90 ];
91 if (is_array($moduleInfo['sub']) && !empty($moduleInfo['sub'])) {
92 $mainModuleData['subModules'] = $this->getSubModuleData($loadedModules, $moduleName);
93 }
94 $mainModulesData[] = $mainModuleData;
95 }
96 return $mainModulesData;
97 }
98
99 /**
100 * Create array with data of all subModules of a specific main module
101 *
102 * @param ModuleLoader $loadedModules the module loader instance
103 * @param string $moduleName Name of the main module
104 * @return array
105 */
106 protected function getSubModuleData(ModuleLoader $loadedModules, $moduleName)
107 {
108 $subModulesData = [];
109 foreach ($loadedModules->modules[$moduleName]['sub'] as $subModuleName => $subModuleInfo) {
110 $moduleLabels = $loadedModules->getLabelsForModule($moduleName . '_' . $subModuleName);
111 $subModuleData = [];
112 $subModuleData['name'] = $subModuleName;
113 $subModuleData['icon'] = $subModuleInfo['icon'];
114 $subModuleData['iconIdentifier'] = $subModuleInfo['iconIdentifier'];
115 $subModuleData['label'] = $moduleLabels['title'];
116 $subModuleData['shortDescription'] = $moduleLabels['shortdescription'];
117 $subModuleData['longDescription'] = $moduleLabels['description'];
118 $subModulesData[] = $subModuleData;
119 }
120 return $subModulesData;
121 }
122
123 /**
124 * Fetches a list of all active (loaded) extensions in the current system
125 *
126 * @return array
127 */
128 protected function getLoadedExtensions(): array
129 {
130 $extensions = [];
131 $packageManager = GeneralUtility::makeInstance(PackageManager::class);
132 foreach ($packageManager->getActivePackages() as $package) {
133 // Skip system extensions (= type: typo3-cms-framework)
134 if ($package->getValueFromComposerManifest('type') !== 'typo3-cms-extension') {
135 continue;
136 }
137 $extensions[] = [
138 'key' => $package->getPackageKey(),
139 'title' => $package->getPackageMetaData()->getDescription(),
140 'authors' => $package->getValueFromComposerManifest('authors')
141 ];
142 }
143 return $extensions;
144 }
145 }