[TASK] Clean-up EXT: aboutmodules, adapt to "TYPO3 CMS"
[Packages/TYPO3.CMS.git] / typo3 / sysext / aboutmodules / Classes / Controller / ModulesController.php
1 <?php
2 namespace TYPO3\CMS\Aboutmodules\Controller;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2012 Christian Kuhn <lolli@schwarzbu.ch>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29 /**
30 * 'About modules' script - the default start-up module.
31 * Will display the list of main- and sub-modules available to the user.
32 * Each module will be show with description and a link to the module.
33 *
34 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
35 * @author Christian Kuhn <lolli@schwarzbu.ch>
36 * @package TYPO3
37 * @subpackage aboutmodules
38 */
39 class ModulesController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
40
41 /**
42 * Show general information and the installed modules
43 *
44 * @return void
45 */
46 public function indexAction() {
47 $this->view->assignMultiple(
48 array(
49 'TYPO3Version' => TYPO3_version,
50 'copyRightNotice' => \TYPO3\CMS\Backend\Utility\BackendUtility::TYPO3_copyRightNotice(),
51 'warningMessages' => \TYPO3\CMS\Backend\Utility\BackendUtility::displayWarningMessages(),
52 'modules' => $this->getModulesData()
53 )
54 );
55 }
56
57 /**
58 * Create array with data of all main modules (Web, File, ...)
59 * and its nested sub modules
60 *
61 * @return array
62 */
63 protected function getModulesData() {
64 /** @var $loadedModules \TYPO3\CMS\Backend\Module\ModuleLoader */
65 $loadedModules = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Module\\ModuleLoader');
66 $loadedModules->observeWorkspaces = TRUE;
67 $loadedModules->load($GLOBALS['TBE_MODULES']);
68 $mainModulesData = array();
69 foreach ($loadedModules->modules as $moduleName => $moduleInfo) {
70 $mainModuleData = array();
71 $moduleKey = $moduleName . '_tab';
72 $mainModuleData['name'] = $moduleName;
73 $mainModuleData['icon'] = substr($GLOBALS['LANG']->moduleLabels['tabs_images'][$moduleKey], strlen(PATH_site));
74 $mainModuleData['label'] = $GLOBALS['LANG']->moduleLabels['tabs'][$moduleKey];
75 if (is_array($moduleInfo['sub']) && count($moduleInfo['sub']) > 0) {
76 $mainModuleData['subModules'] = $this->getSubModuleData($moduleName, $moduleInfo['sub']);
77 }
78 $mainModulesData[] = $mainModuleData;
79 }
80 return $mainModulesData;
81 }
82
83 /**
84 * Create array with data of all subModules of a specific main module
85 *
86 * @param string $moduleName Name of the main module
87 * @param array $subModulesInfo Sub module information
88 * @return array
89 */
90 protected function getSubModuleData($moduleName, array $subModulesInfo = array()) {
91 $subModulesData = array();
92 foreach ($subModulesInfo as $subModuleName => $subModuleInfo) {
93 $subModuleKey = $moduleName . '_' . $subModuleName . '_tab';
94 $subModuleData = array();
95 $subModuleData['name'] = $subModuleName;
96 $subModuleData['icon'] = substr($GLOBALS['LANG']->moduleLabels['tabs_images'][$subModuleKey], strlen(PATH_site));
97 $subModuleData['label'] = $GLOBALS['LANG']->moduleLabels['tabs'][$subModuleKey];
98 $subModuleData['shortDescription'] = $GLOBALS['LANG']->moduleLabels['labels'][$subModuleKey . 'label'];
99 $subModuleData['longDescription'] = $GLOBALS['LANG']->moduleLabels['labels'][$subModuleKey . 'descr'];
100 $subModulesData[] = $subModuleData;
101 }
102 return $subModulesData;
103 }
104
105 }
106
107
108 ?>