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