TYPO3  7.6
ModulesController.php
Go to the documentation of this file.
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 
25 
32 {
38  protected $languageService;
39 
45  protected $defaultViewObjectName = BackendTemplateView::class;
46 
51  {
52  parent::__construct();
53  $this->languageService = $languageService ?: $GLOBALS['LANG'];
54  }
55 
61  protected function initializeView(ViewInterface $view)
62  {
64  parent::initializeView($view);
65  // Disable Path
66  $view->getModuleTemplate()->getDocHeaderComponent()->setMetaInformation([]);
67  }
68 
74  public function indexAction()
75  {
76  $warnings = array();
77  $contentWarnings = '';
78  // Hook for additional warnings
79  if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['displayWarningMessages'])) {
80  foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_befunc.php']['displayWarningMessages'] as $classRef) {
81  $hookObj = GeneralUtility::getUserObj($classRef);
82  if (method_exists($hookObj, 'displayWarningMessages_postProcess')) {
83  $hookObj->displayWarningMessages_postProcess($warnings);
84  }
85  }
86  }
87  if (!empty($warnings)) {
88  if (count($warnings) > 1) {
89  $securityWarnings = '<ul><li>' . implode('</li><li>', $warnings) . '</li></ul>';
90  } else {
91  $securityWarnings = '<p>' . implode('', $warnings) . '</p>';
92  }
93  $securityMessage = GeneralUtility::makeInstance(
94  FlashMessage::class,
95  $securityWarnings,
96  $this->languageService->sL('LLL:EXT:lang/locallang_core.xlf:warning.header'),
98  );
99  $contentWarnings = '<div style="margin: 20px 0;">' . $securityMessage->render() . '</div>';
100  unset($warnings);
101  }
102 
103  $this->view->assignMultiple(
104  array(
105  'TYPO3Version' => TYPO3_version,
106  'copyRightNotice' => BackendUtility::TYPO3_copyRightNotice(),
107  'warningMessages' => $contentWarnings,
108  'modules' => $this->getModulesData()
109  )
110  );
111  }
112 
119  protected function getModulesData()
120  {
122  $loadedModules = GeneralUtility::makeInstance(\TYPO3\CMS\Backend\Module\ModuleLoader::class);
123  $loadedModules->observeWorkspaces = true;
124  $loadedModules->load($GLOBALS['TBE_MODULES']);
125  $mainModulesData = array();
126  foreach ($loadedModules->modules as $moduleName => $moduleInfo) {
127  $mainModuleData = array();
128  $moduleKey = $moduleName . '_tab';
129  $mainModuleData['name'] = $moduleName;
130  $mainModuleData['label'] = $this->languageService->moduleLabels['tabs'][$moduleKey];
131  if (is_array($moduleInfo['sub']) && !empty($moduleInfo['sub'])) {
132  $mainModuleData['subModules'] = $this->getSubModuleData($moduleName, $moduleInfo['sub']);
133  }
134  $mainModulesData[] = $mainModuleData;
135  }
136  return $mainModulesData;
137  }
138 
146  protected function getSubModuleData($moduleName, array $subModulesInfo = array())
147  {
148  $subModulesData = array();
149  foreach ($subModulesInfo as $subModuleName => $subModuleInfo) {
150  $subModuleKey = $moduleName . '_' . $subModuleName . '_tab';
151  $subModuleData = array();
152  $subModuleData['name'] = $subModuleName;
153  $subModuleData['icon'] = PathUtility::stripPathSitePrefix($this->languageService->moduleLabels['tabs_images'][$subModuleKey]);
154  $subModuleData['label'] = $this->languageService->moduleLabels['tabs'][$subModuleKey];
155  $subModuleData['shortDescription'] = $this->languageService->moduleLabels['labels'][$subModuleKey . 'label'];
156  $subModuleData['longDescription'] = $this->languageService->moduleLabels['labels'][$subModuleKey . 'descr'];
157  $subModulesData[] = $subModuleData;
158  }
159  return $subModulesData;
160  }
161 }