2 namespace TYPO3\CMS\Backend\Module;
97 $this->BE_USER = $beUser ?:
$GLOBALS[
'BE_USER'];
113 $this->absPathArray = $modulesArray[
'_PATHS'];
114 unset($modulesArray[
'_PATHS']);
117 unset($modulesArray[
'_dispatcher']);
119 unset($modulesArray[
'_configuration']);
120 $this->navigationComponents = $modulesArray[
'_navigationComponents'];
121 unset($modulesArray[
'_navigationComponents']);
129 $paths[
'defMods'] = PATH_typo3 .
'mod/';
131 $paths[
'userMods'] = PATH_typo3 .
'../typo3conf/';
133 foreach ($theMods as $mods => $subMod) {
137 if ($extModRelPath) {
138 $theMainMod = $this->
checkMod($mods, PATH_site . $extModRelPath);
139 if (is_array($theMainMod) || $theMainMod !=
'notFound') {
146 $theMainMod = $this->
checkMod($mods, $paths[
'defMods'] . $mods);
147 if (is_array($theMainMod) || $theMainMod !=
'notFound') {
148 $path = $paths[
'defMods'];
151 $theMainMod = $this->
checkMod($mods, $paths[
'userMods'] . $mods);
152 if (is_array($theMainMod) || $theMainMod !=
'notFound') {
153 $path = $paths[
'userMods'];
158 if ($theMainMod && !is_null($path)) {
159 $this->modules[$mods] = $theMainMod;
161 if (is_array($subMod)) {
162 foreach ($subMod as $valsub) {
164 if ($extModRelPath) {
166 $theTempSubMod = $this->
checkMod($mods .
'_' . $valsub, PATH_site . $extModRelPath);
168 if (is_array($theTempSubMod)) {
169 $this->modules[$mods][
'sub'][$valsub] = $theTempSubMod;
175 $theTempSubMod = $this->
checkMod($mods .
'_' . $valsub, $path . $mods .
'/' . $valsub);
177 if (is_array($theTempSubMod)) {
178 $this->modules[$mods][
'sub'][$valsub] = $theTempSubMod;
179 }
elseif ($path == $paths[
'defMods']) {
181 $theTempSubMod = $this->
checkMod($mods .
'_' . $valsub, $paths[
'userMods'] . $mods .
'/' . $valsub);
182 if (is_array($theTempSubMod)) {
183 $this->modules[$mods][
'sub'][$valsub] = $theTempSubMod;
191 if (is_array($subMod)) {
192 foreach ($subMod as $valsub) {
194 $this->
checkMod($mods .
'_' . $valsub, $path . $mods .
'/' . $valsub);
210 if (isset($this->absPathArray[$name])) {
234 if (is_array(
$GLOBALS[
'TBE_MODULES'][
'_configuration'][$name][
'configureModuleFunction'])) {
235 $obj =
$GLOBALS[
'TBE_MODULES'][
'_configuration'][$name][
'configureModuleFunction'];
236 if (is_callable($obj)) {
237 $MCONF = call_user_func($obj, $name, $fullPath);
250 if (empty($setupInformation[
'configuration'])) {
254 $setupInformation[
'configuration'][
'shy']
255 || !$this->
checkModAccess($name, $setupInformation[
'configuration'])
260 $finalModuleConfiguration = $setupInformation[
'configuration'];
261 $finalModuleConfiguration[
'name'] = $name;
264 if (is_object(
$lang)) {
267 $defaultLabels = $setupInformation[
'labels'][
'default'];
270 if ($defaultLabels[
'tabs_images'][
'tab']) {
273 $altIconKey =
'MOD:' . $name .
'/' . $defaultLabels[
'tabs_images'][
'tab'];
276 if ($altIconAbsPath && @is_file($altIconAbsPath)) {
277 $defaultLabels[
'tabs_images'][
'tab'] = $altIconAbsPath;
279 if (\TYPO3\CMS\Core\Utility\StringUtility::beginsWith($defaultLabels[
'tabs_images'][
'tab'],
'EXT:')) {
280 list($extensionKey, $relativePath) = explode(
'/', substr($defaultLabels[
'tabs_images'][
'tab'], 4), 2);
283 $defaultLabels[
'tabs_images'][
'tab'] = $fullPath .
'/' . $defaultLabels[
'tabs_images'][
'tab'];
287 $defaultLabels[
'tabs_images'][
'tab'] = $this->
getRelativePath(PATH_typo3, $defaultLabels[
'tabs_images'][
'tab']);
290 if (substr($defaultLabels[
'tabs_images'][
'tab'], 0, 3) ===
'../') {
291 $defaultLabels[
'tabs_images'][
'tab'] = PATH_site . substr($defaultLabels[
'tabs_images'][
'tab'], 3);
293 $defaultLabels[
'tabs_images'][
'tab'] = PATH_typo3 . $defaultLabels[
'tabs_images'][
'tab'];
298 if ($defaultLabels[
'll_ref']) {
300 $defaultLabels[
'labels'][
'tablabel'] =
$lang->sL($defaultLabels[
'll_ref'] .
':mlang_labels_tablabel');
301 $defaultLabels[
'labels'][
'tabdescr'] =
$lang->sL($defaultLabels[
'll_ref'] .
':mlang_labels_tabdescr');
302 $defaultLabels[
'tabs'][
'tab'] =
$lang->sL($defaultLabels[
'll_ref'] .
':mlang_tabs_tab');
303 $lang->addModuleLabels($defaultLabels, $name .
'_');
306 $lang->addModuleLabels($defaultLabels, $name .
'_');
307 $lang->addModuleLabels($setupInformation[
'labels'][
$lang->lang], $name .
'_');
312 if ($setupInformation[
'configuration'][
'script'] ===
'_DISPATCH' || isset($setupInformation[
'configuration'][
'routeTarget'])) {
313 if ($setupInformation[
'configuration'][
'extbase']) {
314 $finalModuleConfiguration[
'script'] = BackendUtility::getModuleUrl(
'Tx_' . $name);
317 $finalModuleConfiguration[
'script'] = BackendUtility::getModuleUrl($name);
319 }
elseif ($setupInformation[
'configuration'][
'script'] && file_exists($setupInformation[
'path'] .
'/' . $setupInformation[
'configuration'][
'script'])) {
320 GeneralUtility::deprecationLog(
'Loading module "' . $name .
'" as a standalone script. Script-based modules are deprecated since TYPO3 CMS 7. Support will be removed with TYPO3 CMS 8, use the "routeTarget" option or dispatched modules instead.');
321 $finalModuleConfiguration[
'script'] = $this->
getRelativePath(PATH_typo3, $fullPath .
'/' . $setupInformation[
'configuration'][
'script']);
323 $finalModuleConfiguration[
'script'] = BackendUtility::getModuleUrl(
'dummy');
326 if (!empty($setupInformation[
'configuration'][
'navigationFrameModule'])) {
327 $finalModuleConfiguration[
'navFrameScript'] = BackendUtility::getModuleUrl(
328 $setupInformation[
'configuration'][
'navigationFrameModule'],
329 !empty($setupInformation[
'configuration'][
'navigationFrameModuleParameters'])
330 ? $setupInformation[
'configuration'][
'navigationFrameModuleParameters']
333 }
elseif (!empty($setupInformation[
'configuration'][
'navFrameScript'])) {
334 GeneralUtility::deprecationLog(
'Loading navFrameScript "' . $setupInformation[
'configuration'][
'navFrameScript'] .
'" as a standalone script. Script-based navigation frames are deprecated since TYPO3 CMS 7. Support will be removed with TYPO3 CMS 8, use "navigationFrameModule" option or the "navigationComponentId" option instead.');
336 $navFrameScript = explode(
'?', $setupInformation[
'configuration'][
'navFrameScript']);
337 $navFrameScript = $navFrameScript[0];
338 if (file_exists($setupInformation[
'path'] .
'/' . $navFrameScript)) {
339 $finalModuleConfiguration[
'navFrameScript'] = $this->
getRelativePath(PATH_typo3, $fullPath .
'/' . $setupInformation[
'configuration'][
'navFrameScript']);
342 if ($setupInformation[
'configuration'][
'navFrameScriptParam']) {
343 $finalModuleConfiguration[
'navFrameScriptParam'] = $setupInformation[
'configuration'][
'navFrameScriptParam'];
349 if (strpos($name,
'_') !==
false) {
350 list($mainModule, ) = explode(
'_', $name, 2);
354 if (is_array($this->navigationComponents[$name])) {
355 $finalModuleConfiguration[
'navigationComponentId'] = $this->navigationComponents[$name][
'componentId'];
357 }
elseif ($mainModule && is_array($this->navigationComponents[$mainModule]) && $setupInformation[
'configuration'][
'inheritNavigationComponentFromMainModule'] !==
false) {
358 $finalModuleConfiguration[
'navigationComponentId'] = $this->navigationComponents[$mainModule][
'componentId'];
360 return $finalModuleConfiguration;
375 $path = preg_replace(
'/\\/[^\\/.]+\\/\\.\\.\\//',
'/', $pathToModuleDirectory);
377 $moduleSetupInformation = array(
378 'configuration' => array(),
383 if (@is_dir($path) && file_exists($path .
'/conf.php')) {
388 include $path .
'/conf.php';
392 $moduleSetupInformation[
'configuration'] =
$MCONF;
394 $moduleSetupInformation[
'configuration'] = array();
396 $moduleSetupInformation[
'labels'] = $MLANG;
399 $moduleConfiguration = !empty(
$GLOBALS[
'TBE_MODULES'][
'_configuration'][$moduleName])
400 ?
$GLOBALS[
'TBE_MODULES'][
'_configuration'][$moduleName]
402 if ($moduleConfiguration !== null) {
404 if (!empty($moduleConfiguration[
'labels']) && is_array($moduleConfiguration[
'labels'])) {
405 if (empty($moduleSetupInformation[
'labels'][
'default']) || !is_array($moduleSetupInformation[
'labels'][
'default'])) {
406 $moduleSetupInformation[
'labels'][
'default'] = $moduleConfiguration[
'labels'];
408 $moduleSetupInformation[
'labels'][
'default'] = array_replace_recursive($moduleSetupInformation[
'labels'][
'default'], $moduleConfiguration[
'labels']);
410 unset($moduleConfiguration[
'labels']);
413 if (is_array($moduleConfiguration)) {
414 $moduleSetupInformation[
'configuration'] = array_replace_recursive($moduleSetupInformation[
'configuration'], $moduleConfiguration);
419 if (!isset($moduleSetupInformation[
'configuration'][
'inheritNavigationComponentFromMainModule'])) {
420 $moduleSetupInformation[
'configuration'][
'inheritNavigationComponentFromMainModule'] =
true;
423 return $moduleSetupInformation;
435 if (empty(
$MCONF[
'access'])) {
438 $access = strtolower(
$MCONF[
'access']);
441 if (strpos($access,
'admin') !==
false && $this->BE_USER->isAdmin()) {
445 if (strpos($access,
'user') !==
false) {
446 $this->modListUser[] = $name;
448 if (strpos($access,
'group') !==
false) {
449 $this->modListGroup[] = $name;
452 if ($this->BE_USER->isAdmin() || $this->BE_USER->check(
'modules', $name)) {
468 if (!$this->observeWorkspaces) {
472 if (!empty(
$MCONF[
'workspaces'])) {
476 }
elseif ($this->BE_USER->workspace === -99) {
492 if (is_array($arr)) {
493 foreach ($arr as $mod => $subs) {
499 foreach ($subsArr as $subMod) {
502 $theMods[$mod][] = $subMod;
523 return preg_replace(
'/[^a-z0-9]/i',
'', $str);
541 $destDir = ltrim($destDir,
'/');
544 $slash_pos = strpos($destDir,
'/');
545 if ($slash_pos !==
false && substr($destDir, 0, $slash_pos) == substr(
$baseDir, 0, $slash_pos)) {
547 $destDir = substr($destDir, $slash_pos + 1);
553 for ($i = 0; $i < $slashes; $i++) {
554 $destDir =
'../' . $destDir;