Fixed bug #13675: Performance improvement: Use array_walk() for t3lib_div::intExplode
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_loadmodules.php
index 27493fc..c712590 100644 (file)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2006 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2009 Kasper Skaarhoj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -83,7 +83,12 @@ class t3lib_loadModules {
        var $modListGroup = Array();            // this array will hold the elements that should go into the select-list of modules for groups...
        var $modListUser = Array();             // this array will hold the elements that should go into the select-list of modules for users...
 
-       var $BE_USER = '';      // The backend user for use internally
+       /**
+        * The backend user for use internally
+        *
+        * @var t3lib_beUserAuth
+        */
+       var $BE_USER;
        var $observeWorkspaces = FALSE;         // If set true, workspace "permissions" will be observed so non-allowed modules will not be included in the array of modules.
 
 
@@ -113,7 +118,6 @@ class t3lib_loadModules {
                        (
                            [web] => list,info,perm,func
                            [file] => list
-                           [doc] =>
                            [user] =>
                            [tools] => em,install,txphpmyadmin
                            [help] => about
@@ -148,7 +152,6 @@ class t3lib_loadModules {
                                            [0] => list
                                        )
 
-                                   [doc] => 1
                                    [user] => 1
                                    [tools] => Array
                                        (
@@ -205,8 +208,8 @@ class t3lib_loadModules {
                        if ($theMainMod && !is_null($path))     {
                                $this->modules[$mods] = $theMainMod;
 
-                                       // SUBMODULES - if any - are loaded (The 'doc' module cannot have submodules...)
-                               if ($mods!='doc' && is_array($subMod))  {
+                                       // SUBMODULES - if any - are loaded
+                               if (is_array($subMod))  {
                                        foreach($subMod as $valsub)     {
                                                $extModRelPath = $this->checkExtensionModule($mods.'_'.$valsub);
                                                if ($extModRelPath)     {       // EXTENSION submodule:
@@ -230,7 +233,7 @@ class t3lib_loadModules {
                                        }
                                }
                        } else {        // This must be done in order to fill out the select-lists for modules correctly!!
-                               if ($mods!='doc' && is_array($subMod))  {
+                               if (is_array($subMod))  {
                                        foreach($subMod as $valsub)     {
 // FIXME path can only be NULL here, or not?
                                                $this->checkMod($mods.'_'.$valsub,$path.$mods.'/'.$valsub);
@@ -295,12 +298,6 @@ class t3lib_loadModules {
 
                        )
 
-                   [doc] => Array
-                       (
-                           [name] => doc
-                           [script] => mod/doc/../../alt_doc.php
-                       )
-
                    [user] => Array
                        (
                            [name] => user
@@ -371,7 +368,7 @@ class t3lib_loadModules {
                global $TYPO3_LOADED_EXT;
 
                if (isset($this->absPathArray[$name]))  {
-                       return ereg_replace ('\/$', '', substr($this->absPathArray[$name],strlen(PATH_site)));
+                       return rtrim(substr($this->absPathArray[$name],strlen(PATH_site)), '/');
                }
        }
 
@@ -387,9 +384,21 @@ class t3lib_loadModules {
         * @return      mixed           See description of function
         */
        function checkMod($name, $fullpath)     {
-               $modconf=Array();
-               $path = ereg_replace ('/[^/.]+/\.\./', '/', $fullpath); // because 'path/../path' does not work
-               if (@is_dir($path) && @file_exists($path.'/conf.php'))  {
+               if ($name == 'user_ws' && !t3lib_extMgm::isLoaded('version')) {
+                       return FALSE;
+               }
+
+                       // Check for own way of configuring module
+               if (is_array($GLOBALS['TBE_MODULES'][$name]['configureModuleFunction'])) {
+                       $obj = $GLOBALS['TBE_MODULES'][$name]['configureModuleFunction'];
+                       if (is_callable($obj)) {
+                               return call_user_func($obj, $name, $fullpath);
+                       }
+               }
+
+               $modconf = array();
+               $path = preg_replace('/\/[^\/.]+\/\.\.\//', '/', $fullpath); // because 'path/../path' does not work
+               if (@is_dir($path) && file_exists($path.'/conf.php'))   {
                        $MCONF = array();
                        $MLANG = array();
                        include($path.'/conf.php');     // The conf-file is included. This must be valid PHP.
@@ -435,7 +444,13 @@ class t3lib_loadModules {
                                }
 
                                        // Default script setup
-                               if ($MCONF['script'] && @file_exists($path.'/'.$MCONF['script']))       {
+                               if ($MCONF['script']==='_DISPATCH')     {
+                                       if ($MCONF['extbase']) {
+                                               $modconf['script'] = 'mod.php?M=Tx_' . rawurlencode($name);
+                                       } else {
+                                               $modconf['script'] = 'mod.php?M=' . rawurlencode($name);
+                                       }
+                               } elseif ($MCONF['script'] && file_exists($path.'/'.$MCONF['script']))  {
                                        $modconf['script'] = $this->getRelativePath(PATH_typo3,$fullpath.'/'.$MCONF['script']);
                                } else {
                                        $modconf['script'] = 'dummy.php';
@@ -448,7 +463,7 @@ class t3lib_loadModules {
                                if ($MCONF['navFrameScript']) {
                                        $navFrameScript = explode('?', $MCONF['navFrameScript']);
                                        $navFrameScript = $navFrameScript[0];
-                                       if (@file_exists($path.'/'.$navFrameScript))    {
+                                       if (file_exists($path.'/'.$navFrameScript))     {
                                                $modconf['navFrameScript'] = $this->getRelativePath(PATH_typo3,$fullpath.'/'.$MCONF['navFrameScript']);
                                        }
                                }
@@ -563,8 +578,8 @@ class t3lib_loadModules {
                        return './';
                }
 
-               $baseDir = ereg_replace ('^/', '', $baseDir);   // remove beginning
-               $destDir = ereg_replace ('^/', '', $destDir);
+               $baseDir = ltrim($baseDir, '/');        // remove beginning
+               $destDir = ltrim($destDir, '/');
 
                $found = true;
                $slash_pos=0;
@@ -591,4 +606,5 @@ class t3lib_loadModules {
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_loadmodules.php'])      {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_loadmodules.php']);
 }
+
 ?>
\ No newline at end of file