[TASK] Unify references for backend modules icons
[Packages/TYPO3.CMS.git] / typo3 / sysext / about / Classes / Controller / ModulesController.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\Utility\GeneralUtility;
21 use TYPO3\CMS\Core\Utility\PathUtility;
22 use TYPO3\CMS\Extbase\Mvc\Controller\ActionController;
23 use TYPO3\CMS\Extbase\Mvc\View\ViewInterface;
24 use TYPO3\CMS\Lang\LanguageService;
25
26 /**
27 * 'About modules' script - the default start-up module.
28 * Will display the list of main- and sub-modules available to the user.
29 * Each module will be show with description and a link to the module.
30 */
31 class ModulesController extends ActionController
32 {
33 /**
34 * Language Service property. Used to access localized labels
35 *
36 * @var LanguageService
37 */
38 protected $languageService;
39
40 /**
41 * BackendTemplateView Container
42 *
43 * @var BackendTemplateView
44 */
45 protected $defaultViewObjectName = BackendTemplateView::class;
46
47 /**
48 * @param LanguageService $languageService Language Service to inject
49 */
50 public function __construct(LanguageService $languageService = null)
51 {
52 parent::__construct();
53 $this->languageService = $languageService ?: $GLOBALS['LANG'];
54 }
55
56 /**
57 * Set up the doc header properly here
58 *
59 * @param ViewInterface $view
60 */
61 protected function initializeView(ViewInterface $view)
62 {
63 /** @var BackendTemplateView $view */
64 parent::initializeView($view);
65 // Disable Path
66 $view->getModuleTemplate()->getDocHeaderComponent()->setMetaInformation([]);
67 }
68
69 /**
70 * Show general information and the installed modules
71 *
72 * @return void
73 */
74 public function indexAction()
75 {
76 $warnings = array();
77 $securityWarnings = '';
78 // Hook for additional warnings
79 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['displayWarningMessages'])) {
80 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['displayWarningMessages'] as $classRef) {
81 $hookObj = GeneralUtility::getUserObj($classRef);
82 if (method_exists($hookObj, 'displayWarningMessages_postProcess')) {
83 $hookObj->displayWarningMessages_postProcess($warnings);
84 }
85 }
86 }
87 if (!empty($warnings)) {
88 if (count($warnings) > 1) {
89 $securityWarnings = '<ul><li>' . implode('</li><li>', $warnings) . '</li></ul>';
90 } else {
91 $securityWarnings = '<p>' . implode('', $warnings) . '</p>';
92 }
93 unset($warnings);
94 }
95
96 $this->view->assignMultiple(
97 array(
98 'TYPO3Version' => TYPO3_version,
99 'copyRightNotice' => BackendUtility::TYPO3_copyRightNotice(),
100 'warningMessages' => $securityWarnings,
101 'warningTitle' => $this->languageService->sL('LLL:EXT:lang/locallang_core.xlf:warning.header'),
102 'modules' => $this->getModulesData()
103 )
104 );
105 }
106
107 /**
108 * Create array with data of all main modules (Web, File, ...)
109 * and its nested sub modules
110 *
111 * @return array
112 */
113 protected function getModulesData()
114 {
115 /** @var $loadedModules ModuleLoader */
116 $loadedModules = GeneralUtility::makeInstance(ModuleLoader::class);
117 $loadedModules->observeWorkspaces = true;
118 $loadedModules->load($GLOBALS['TBE_MODULES']);
119 $mainModulesData = array();
120 foreach ($loadedModules->modules as $moduleName => $moduleInfo) {
121 $mainModuleData = array();
122 $moduleKey = $moduleName . '_tab';
123 $mainModuleData['name'] = $moduleName;
124 $mainModuleData['label'] = $this->languageService->moduleLabels['tabs'][$moduleKey];
125 if (is_array($moduleInfo['sub']) && !empty($moduleInfo['sub'])) {
126 $mainModuleData['subModules'] = $this->getSubModuleData($moduleName, $moduleInfo['sub']);
127 }
128 $mainModulesData[] = $mainModuleData;
129 }
130 return $mainModulesData;
131 }
132
133 /**
134 * Create array with data of all subModules of a specific main module
135 *
136 * @param string $moduleName Name of the main module
137 * @param array $subModulesInfo Sub module information
138 * @return array
139 */
140 protected function getSubModuleData($moduleName, array $subModulesInfo = array())
141 {
142 $subModulesData = array();
143 foreach ($subModulesInfo as $subModuleName => $subModuleInfo) {
144 $subModuleKey = $moduleName . '_' . $subModuleName . '_tab';
145 $subModuleData = array();
146 $subModuleData['name'] = $subModuleName;
147 $subModuleData['icon'] = PathUtility::getAbsoluteWebPath($subModuleInfo['icon']);
148 $subModuleData['label'] = $this->languageService->moduleLabels['tabs'][$subModuleKey];
149 $subModuleData['shortDescription'] = $this->languageService->moduleLabels['labels'][$subModuleKey . 'label'];
150 $subModuleData['longDescription'] = $this->languageService->moduleLabels['labels'][$subModuleKey . 'descr'];
151 $subModulesData[] = $subModuleData;
152 }
153 return $subModulesData;
154 }
155 }