[TASK] Re-work/simplify copyright header in PHP files - Part 8
[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 * 'About modules' script - the default start-up module.
18 * Will display the list of main- and sub-modules available to the user.
19 * Each module will be show with description and a link to the module.
20 *
21 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
22 * @author Christian Kuhn <lolli@schwarzbu.ch>
23 */
24 class ModulesController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
25
26 /**
27 * Show general information and the installed modules
28 *
29 * @return void
30 */
31 public function indexAction() {
32 $warnings = array();
33 // Hook for additional warnings
34 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['displayWarningMessages'])) {
35 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['displayWarningMessages'] as $classRef) {
36 $hookObj = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef);
37 if (method_exists($hookObj, 'displayWarningMessages_postProcess')) {
38 $hookObj->displayWarningMessages_postProcess($warnings);
39 }
40 }
41 }
42 if (count($warnings)) {
43 if (count($warnings) > 1) {
44 $securityWarnings = '<ul><li>' . implode('</li><li>', $warnings) . '</li></ul>';
45 } else {
46 $securityWarnings = '<p>' . implode('', $warnings) . '</p>';
47 }
48 $securityMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
49 'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
50 $securityWarnings,
51 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.header'),
52 \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR
53 );
54 $contentWarnings = '<div style="margin: 20px 0px;">' . $securityMessage->render() . '</div>';
55 unset($warnings);
56 }
57
58 $this->view->assignMultiple(
59 array(
60 'TYPO3Version' => TYPO3_version,
61 'copyRightNotice' => \TYPO3\CMS\Backend\Utility\BackendUtility::TYPO3_copyRightNotice(),
62 'warningMessages' => $contentWarnings,
63 'modules' => $this->getModulesData()
64 )
65 );
66 }
67
68 /**
69 * Create array with data of all main modules (Web, File, ...)
70 * and its nested sub modules
71 *
72 * @return array
73 */
74 protected function getModulesData() {
75 /** @var $loadedModules \TYPO3\CMS\Backend\Module\ModuleLoader */
76 $loadedModules = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Module\\ModuleLoader');
77 $loadedModules->observeWorkspaces = TRUE;
78 $loadedModules->load($GLOBALS['TBE_MODULES']);
79 $mainModulesData = array();
80 foreach ($loadedModules->modules as $moduleName => $moduleInfo) {
81 $mainModuleData = array();
82 $moduleKey = $moduleName . '_tab';
83 $mainModuleData['name'] = $moduleName;
84 $mainModuleData['label'] = $GLOBALS['LANG']->moduleLabels['tabs'][$moduleKey];
85 if (is_array($moduleInfo['sub']) && count($moduleInfo['sub']) > 0) {
86 $mainModuleData['subModules'] = $this->getSubModuleData($moduleName, $moduleInfo['sub']);
87 }
88 $mainModulesData[] = $mainModuleData;
89 }
90 return $mainModulesData;
91 }
92
93 /**
94 * Create array with data of all subModules of a specific main module
95 *
96 * @param string $moduleName Name of the main module
97 * @param array $subModulesInfo Sub module information
98 * @return array
99 */
100 protected function getSubModuleData($moduleName, array $subModulesInfo = array()) {
101 $subModulesData = array();
102 foreach ($subModulesInfo as $subModuleName => $subModuleInfo) {
103 $subModuleKey = $moduleName . '_' . $subModuleName . '_tab';
104 $subModuleData = array();
105 $subModuleData['name'] = $subModuleName;
106 $subModuleData['icon'] = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($GLOBALS['LANG']->moduleLabels['tabs_images'][$subModuleKey]);
107 $subModuleData['label'] = $GLOBALS['LANG']->moduleLabels['tabs'][$subModuleKey];
108 $subModuleData['shortDescription'] = $GLOBALS['LANG']->moduleLabels['labels'][$subModuleKey . 'label'];
109 $subModuleData['longDescription'] = $GLOBALS['LANG']->moduleLabels['labels'][$subModuleKey . 'descr'];
110 $subModulesData[] = $subModuleData;
111 }
112 return $subModulesData;
113 }
114
115 }