[TASK] Add tool-function to strip PATH_site-part of paths
[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-2013 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 */
37 class ModulesController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
38
39 /**
40 * Show general information and the installed modules
41 *
42 * @return void
43 */
44 public function indexAction() {
45 $warnings = array();
46 // Hook for additional warnings
47 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['displayWarningMessages'])) {
48 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['displayWarningMessages'] as $classRef) {
49 $hookObj = \TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef);
50 if (method_exists($hookObj, 'displayWarningMessages_postProcess')) {
51 $hookObj->displayWarningMessages_postProcess($warnings);
52 }
53 }
54 }
55 if (count($warnings)) {
56 if (count($warnings) > 1) {
57 $securityWarnings = '<ul><li>' . implode('</li><li>', $warnings) . '</li></ul>';
58 } else {
59 $securityWarnings = '<p>' . implode('', $warnings) . '</p>';
60 }
61 $securityMessage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(
62 'TYPO3\\CMS\\Core\\Messaging\\FlashMessage',
63 $securityWarnings,
64 $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xlf:warning.header'),
65 \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR
66 );
67 $contentWarnings = '<div style="margin: 20px 0px;">' . $securityMessage->render() . '</div>';
68 unset($warnings);
69 }
70
71 $this->view->assignMultiple(
72 array(
73 'TYPO3Version' => TYPO3_version,
74 'copyRightNotice' => \TYPO3\CMS\Backend\Utility\BackendUtility::TYPO3_copyRightNotice(),
75 'warningMessages' => $contentWarnings,
76 'modules' => $this->getModulesData()
77 )
78 );
79 }
80
81 /**
82 * Create array with data of all main modules (Web, File, ...)
83 * and its nested sub modules
84 *
85 * @return array
86 */
87 protected function getModulesData() {
88 /** @var $loadedModules \TYPO3\CMS\Backend\Module\ModuleLoader */
89 $loadedModules = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Module\\ModuleLoader');
90 $loadedModules->observeWorkspaces = TRUE;
91 $loadedModules->load($GLOBALS['TBE_MODULES']);
92 $mainModulesData = array();
93 foreach ($loadedModules->modules as $moduleName => $moduleInfo) {
94 $mainModuleData = array();
95 $moduleKey = $moduleName . '_tab';
96 $mainModuleData['name'] = $moduleName;
97 $mainModuleData['label'] = $GLOBALS['LANG']->moduleLabels['tabs'][$moduleKey];
98 if (is_array($moduleInfo['sub']) && count($moduleInfo['sub']) > 0) {
99 $mainModuleData['subModules'] = $this->getSubModuleData($moduleName, $moduleInfo['sub']);
100 }
101 $mainModulesData[] = $mainModuleData;
102 }
103 return $mainModulesData;
104 }
105
106 /**
107 * Create array with data of all subModules of a specific main module
108 *
109 * @param string $moduleName Name of the main module
110 * @param array $subModulesInfo Sub module information
111 * @return array
112 */
113 protected function getSubModuleData($moduleName, array $subModulesInfo = array()) {
114 $subModulesData = array();
115 foreach ($subModulesInfo as $subModuleName => $subModuleInfo) {
116 $subModuleKey = $moduleName . '_' . $subModuleName . '_tab';
117 $subModuleData = array();
118 $subModuleData['name'] = $subModuleName;
119 $subModuleData['icon'] = \TYPO3\CMS\Core\Utility\PathUtility::stripPathSitePrefix($GLOBALS['LANG']->moduleLabels['tabs_images'][$subModuleKey]);
120 $subModuleData['label'] = $GLOBALS['LANG']->moduleLabels['tabs'][$subModuleKey];
121 $subModuleData['shortDescription'] = $GLOBALS['LANG']->moduleLabels['labels'][$subModuleKey . 'label'];
122 $subModuleData['longDescription'] = $GLOBALS['LANG']->moduleLabels['labels'][$subModuleKey . 'descr'];
123 $subModulesData[] = $subModuleData;
124 }
125 return $subModulesData;
126 }
127
128 }