cc1e69218126fa7c9dd60afc0f6881d928a3c9f4
[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->assign('TYPO3Version', TYPO3_version)->assign('copyRightNotice', \TYPO3\CMS\Backend\Utility\BackendUtility::TYPO3_copyRightNotice())->assign('warningMessages', \TYPO3\CMS\Backend\Utility\BackendUtility::displayWarningMessages())->assign('modules', $this->getModulesData());
48 }
49
50 /**
51 * Create array with data of all main modules (Web, File, ...)
52 * and its nested sub modules
53 *
54 * @return array
55 */
56 protected function getModulesData() {
57 /** @var $loadedModules \TYPO3\CMS\Backend\Module\ModuleLoader */
58 $loadedModules = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Module\\ModuleLoader');
59 $loadedModules->observeWorkspaces = TRUE;
60 $loadedModules->load($GLOBALS['TBE_MODULES']);
61 $mainModulesData = array();
62 foreach ($loadedModules->modules as $moduleName => $moduleInfo) {
63 $mainModuleData = array();
64 $moduleKey = $moduleName . '_tab';
65 $mainModuleData['name'] = $moduleName;
66 $mainModuleData['icon'] = substr($GLOBALS['LANG']->moduleLabels['tabs_images'][$moduleKey], strlen(PATH_site));
67 $mainModuleData['label'] = $GLOBALS['LANG']->moduleLabels['tabs'][$moduleKey];
68 if (is_array($moduleInfo['sub']) && count($moduleInfo['sub']) > 0) {
69 $mainModuleData['subModules'] = $this->getSubModuleData($moduleName, $moduleInfo['sub']);
70 }
71 $mainModulesData[] = $mainModuleData;
72 }
73 return $mainModulesData;
74 }
75
76 /**
77 * Create array with data of all subModules of a specific main module
78 *
79 * @param string $moduleName Name of the main module
80 * @param array $subModulesInfo Sub module information
81 * @return array
82 */
83 protected function getSubModuleData($moduleName, array $subModulesInfo = array()) {
84 $subModulesData = array();
85 foreach ($subModulesInfo as $subModuleName => $subModuleInfo) {
86 $subModuleKey = $moduleName . '_' . $subModuleName . '_tab';
87 $subModuleData = array();
88 $subModuleData['name'] = $subModuleName;
89 $subModuleData['icon'] = substr($GLOBALS['LANG']->moduleLabels['tabs_images'][$subModuleKey], strlen(PATH_site));
90 $subModuleData['label'] = $GLOBALS['LANG']->moduleLabels['tabs'][$subModuleKey];
91 $subModuleData['shortDescription'] = $GLOBALS['LANG']->moduleLabels['labels'][$subModuleKey . 'label'];
92 $subModuleData['longDescription'] = $GLOBALS['LANG']->moduleLabels['labels'][$subModuleKey . 'descr'];
93 $subModulesData[] = $subModuleData;
94 }
95 return $subModulesData;
96 }
97
98 }
99
100
101 ?>