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