TYPO3 CMS  TYPO3_6-2
ModuleController.php
Go to the documentation of this file.
1 <?php
3 
23 
27  protected $moduleMenu;
28 
33 
37  public function __construct() {
38  $this->moduleMenu = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Module\\ModuleStorage');
39  $this->moduleMenuRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Domain\\Repository\\Module\\BackendModuleRepository');
40  }
41 
49  public function createModuleMenu() {
50  if (count($this->moduleMenu->getEntries()) === 0) {
52  $moduleMenu = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\View\\ModuleMenuView');
53  $rawData = $moduleMenu->getRawModuleData();
56  }
57  }
58 
66  protected function convertRawModuleDataToModuleMenuObject(array $rawModuleData) {
67  foreach ($rawModuleData as $module) {
68  $entry = $this->createEntryFromRawData($module);
69  if (isset($module['subitems']) && count($module['subitems']) > 0) {
70  foreach ($module['subitems'] as $subitem) {
71  $subEntry = $this->createEntryFromRawData($subitem);
72  $entry->addChild($subEntry);
73  }
74  }
75  $this->moduleMenu->attachEntry($entry);
76  }
77  }
78 
85  protected function createEntryFromRawData(array $module) {
87  $entry = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Domain\\Model\\Module\\BackendModule');
88  if (!empty($module['name']) && is_string($module['name'])) {
89  $entry->setName($module['name']);
90  }
91  if (!empty($module['title']) && is_string($module['title'])) {
92  $entry->setTitle($this->getLanguageService()->sL($module['title']));
93  }
94  if (!empty($module['onclick']) && is_string($module['onclick'])) {
95  $entry->setOnClick($module['onclick']);
96  }
97  if (!empty($module['link']) && is_string($module['link'])) {
98  $entry->setLink($module['link']);
99  }
100  if (empty($module['link']) && !empty($module['path']) && is_string($module['path'])) {
101  $entry->setLink($module['path']);
102  }
103  if (!empty($module['description']) && is_string($module['description'])) {
104  $entry->setDescription($module['description']);
105  }
106  if (!empty($module['icon']) && is_array($module['icon'])) {
107  $entry->setIcon($module['icon']);
108  }
109  if (!empty($module['navigationComponentId']) && is_string($module['navigationComponentId'])) {
110  $entry->setNavigationComponentId($module['navigationComponentId']);
111  }
112  return $entry;
113  }
114 
121  protected function createMenuEntriesForTbeModulesExt() {
122  foreach ($GLOBALS['TBE_MODULES_EXT'] as $mainModule => $tbeModuleExt) {
123  list($main) = explode('_', $mainModule);
124  $mainEntry = $this->moduleMenuRepository->findByModuleName($main);
125  if ($mainEntry !== FALSE) {
126  $subEntries = $mainEntry->getChildren();
127  if (count($subEntries) > 0) {
128  $matchingSubEntry = $this->moduleMenuRepository->findByModuleName($mainModule);
129  if ($matchingSubEntry !== FALSE) {
130  if (array_key_exists('MOD_MENU', $tbeModuleExt) && array_key_exists('function', $tbeModuleExt['MOD_MENU'])) {
131  foreach ($tbeModuleExt['MOD_MENU']['function'] as $subModule) {
132  $entry = $this->createEntryFromRawData($subModule);
133  $matchingSubEntry->addChild($entry);
134  }
135  }
136  }
137  }
138  }
139  }
140  }
141 
147  protected function getLanguageService() {
148  return $GLOBALS['LANG'];
149  }
150 }
convertRawModuleDataToModuleMenuObject(array $rawModuleData)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]