Public Member Functions | |
load ($modulesArray, $BE_USER='') | |
Init. | |
checkExtensionModule ($name) | |
If the module name ($name) is a module from an extension (has path in $this->absPathArray) then that path is returned relative to PATH_site. | |
checkMod ($name, $fullpath) | |
Here we check for the module. | |
checkModAccess ($name, $MCONF) | |
Returns true if the internal BE_USER has access to the module $name with $MCONF (based on security level set for that module). | |
parseModulesArray ($arr) | |
Parses the moduleArray ($TBE_MODULES) into a internally useful structure. | |
cleanName ($str) | |
The $str is cleaned so that it contains alphanumerical characters only. | |
getRelativePath ($baseDir, $destDir) | |
Get relative path for $destDir compared to $baseDir. | |
Public Attributes | |
$modules = Array() | |
$absPathArray = array() | |
$modListGroup = Array() | |
$modListUser = Array() | |
$BE_USER = '' |
|
If the module name ($name) is a module from an extension (has path in $this->absPathArray) then that path is returned relative to PATH_site.
Definition at line 366 of file class.t3lib_loadmodules.php. References PATH_site. Referenced by load(). 00366 { 00367 global $TYPO3_LOADED_EXT; 00368 00369 if (isset($this->absPathArray[$name])) { 00370 return ereg_replace ('\/$', '', substr($this->absPathArray[$name],strlen(PATH_site))); 00371 } 00372 }
|
|
Here we check for the module. Return values: 'notFound': If the module was not found in the path (no "conf.php" file) false: If no access to the module (access check failed) array(): Configuration array, in case a valid module where access IS granted exists.
Definition at line 385 of file class.t3lib_loadmodules.php. References $MCONF, $MLANG, checkModAccess(), getRelativePath(), and PATH_site. Referenced by load(). 00385 { 00386 $modconf=Array(); 00387 $path = ereg_replace ('/[^/.]+/\.\./', '/', $fullpath); // because 'path/../path' does not work 00388 if (@is_dir($path) && @file_exists($path.'/conf.php')) { 00389 include($path.'/conf.php'); // The conf-file is included. This must be valid PHP. 00390 if (!$MCONF['shy'] && $this->checkModAccess($name,$MCONF)) { 00391 $modconf['name']=$name; 00392 // language processing. This will add module labels and image reference to the internal ->moduleLabels array of the LANG object. 00393 if (is_object($GLOBALS['LANG'])) { 00394 // $MLANG['default']['tabs_images']['tab'] is for modules the reference to the module icon. 00395 // Here the path is transformed to an absolute reference. 00396 if ($MLANG['default']['tabs_images']['tab']) { 00397 00398 // Initializing search for alternative icon: 00399 $altIconKey = 'MOD:'.$name.'/'.$MLANG['default']['tabs_images']['tab']; // Alternative icon key (might have an alternative set in $TBE_STYLES['skinImg'] 00400 $altIconAbsPath = is_array($GLOBALS['TBE_STYLES']['skinImg'][$altIconKey]) ? t3lib_div::resolveBackPath(PATH_typo3.$GLOBALS['TBE_STYLES']['skinImg'][$altIconKey][0]) : ''; 00401 00402 // Setting icon, either default or alternative: 00403 if ($altIconAbsPath && @is_file($altIconAbsPath)) { 00404 $MLANG['default']['tabs_images']['tab']=$this->getRelativePath(PATH_typo3,$altIconAbsPath); 00405 } else { 00406 // Setting default icon: 00407 $MLANG['default']['tabs_images']['tab']=$this->getRelativePath(PATH_typo3,$fullpath.'/'.$MLANG['default']['tabs_images']['tab']); 00408 } 00409 00410 // Finally, setting the icon with correct path: 00411 if (substr($MLANG['default']['tabs_images']['tab'],0,3)=='../') { 00412 $MLANG['default']['tabs_images']['tab'] = PATH_site.substr($MLANG['default']['tabs_images']['tab'],3); 00413 } else { 00414 $MLANG['default']['tabs_images']['tab'] = PATH_typo3.$MLANG['default']['tabs_images']['tab']; 00415 } 00416 } 00417 00418 // If LOCAL_LANG references are used for labels of the module: 00419 if ($MLANG['default']['ll_ref']) { 00420 // Now the 'default' key is loaded with the CURRENT language - not the english translation... 00421 $MLANG['default']['labels']['tablabel'] = $GLOBALS['LANG']->sL($MLANG['default']['ll_ref'].':mlang_labels_tablabel'); 00422 $MLANG['default']['labels']['tabdescr'] = $GLOBALS['LANG']->sL($MLANG['default']['ll_ref'].':mlang_labels_tabdescr'); 00423 $MLANG['default']['tabs']['tab'] = $GLOBALS['LANG']->sL($MLANG['default']['ll_ref'].':mlang_tabs_tab'); 00424 $GLOBALS['LANG']->addModuleLabels($MLANG['default'],$name.'_'); 00425 } else { // ... otherwise use the old way: 00426 $GLOBALS['LANG']->addModuleLabels($MLANG['default'],$name.'_'); 00427 $GLOBALS['LANG']->addModuleLabels($MLANG[$GLOBALS['LANG']->lang],$name.'_'); 00428 } 00429 } 00430 00431 // Default script setup 00432 if ($MCONF['script'] && @file_exists($path.'/'.$MCONF['script'])) { 00433 $modconf['script'] = $this->getRelativePath(PATH_typo3,$fullpath.'/'.$MCONF['script']); 00434 } else { 00435 $modconf['script'] = 'dummy.php'; 00436 } 00437 // Default tab setting 00438 if ($MCONF['defaultMod']) { 00439 $modconf['defaultMod'] = $MCONF['defaultMod']; 00440 } 00441 // Navigation Frame Script (GET params could be added) 00442 if ($MCONF['navFrameScript']) { 00443 $navFrameScript = explode('?', $MCONF['navFrameScript']); 00444 $navFrameScript = $navFrameScript[0]; 00445 if (@file_exists($path.'/'.$navFrameScript)) { 00446 $modconf['navFrameScript'] = $this->getRelativePath(PATH_typo3,$fullpath.'/'.$MCONF['navFrameScript']); 00447 } 00448 } 00449 // additional params for Navigation Frame Script: "&anyParam=value&moreParam=1" 00450 if ($MCONF['navFrameScriptParam']) { 00451 $modconf['navFrameScriptParam'] = $MCONF['navFrameScriptParam']; 00452 } 00453 } else return false; 00454 } else $modconf = 'notFound'; 00455 return $modconf; 00456 }
|
|
Returns true if the internal BE_USER has access to the module $name with $MCONF (based on security level set for that module).
Definition at line 465 of file class.t3lib_loadmodules.php. References $MCONF. Referenced by checkMod(). 00465 { 00466 if ($MCONF['access']) { 00467 $access=strtolower($MCONF['access']); 00468 // Checking if admin-access is required 00469 if (strstr($access,'admin')) { // If admin-permissions is required then return true if user is admin 00470 if ($this->BE_USER->isAdmin()) {return true;} 00471 } 00472 // This will add modules to the select-lists of user and groups 00473 if (strstr($access,'user')) { $this->modListUser[]=$name; } 00474 if (strstr($access,'group')) { $this->modListGroup[]=$name; } 00475 // This checks if a user is permitted to access the module 00476 if ($this->BE_USER->isAdmin() || $this->BE_USER->check('modules',$name)) {return true;} // If admin you can always access a module 00477 00478 } else return true; // If conf[access] is not set, then permission IS granted! 00479 }
|
|
The $str is cleaned so that it contains alphanumerical characters only. Modules must only consist of these characters
Definition at line 517 of file class.t3lib_loadmodules.php. Referenced by parseModulesArray(). 00517 { 00518 return ereg_replace('[^A-Za-z0-9]*','',$str); 00519 }
|
|
Get relative path for $destDir compared to $baseDir.
Definition at line 528 of file class.t3lib_loadmodules.php. Referenced by checkMod(). 00528 { 00529 // By Rene Fritz 00530 // a special case , the dirs are equals 00531 if ($baseDir == $destDir){ 00532 return './'; 00533 } 00534 00535 $baseDir = ereg_replace ('^/', '', $baseDir); // remove beginning 00536 $destDir = ereg_replace ('^/', '', $destDir); 00537 00538 $found = true; 00539 $slash_pos=0; 00540 00541 do { 00542 $slash_pos = strpos ($destDir, '/'); 00543 if (substr($destDir, 0, $slash_pos) == substr($baseDir, 0, $slash_pos)){ 00544 $baseDir = substr($baseDir, $slash_pos+1); 00545 $destDir = substr($destDir, $slash_pos+1); 00546 } else { 00547 $found = false; 00548 } 00549 } while($found == true); 00550 00551 $slashes = strlen ($baseDir) - strlen (str_replace('/', '', $baseDir)); 00552 for($i=0;$i < $slashes;$i++) { 00553 $destDir = '../'.$destDir; 00554 } 00555 return $destDir; 00556 }
|
|
Init. The outcome of the load() function will be a $this->modules array populated with the backend module structure available to the BE_USER Further the global var $LANG will have labels and images for the modules loaded in an internal array.
Definition at line 97 of file class.t3lib_loadmodules.php. References checkExtensionModule(), checkMod(), parseModulesArray(), and PATH_site. 00097 { 00098 // Setting the backend user for use internally 00099 if (is_object($BE_USER)) { 00100 $this->BE_USER = $BE_USER; 00101 } else { 00102 $this->BE_USER = $GLOBALS['BE_USER']; 00103 } 00104 00105 /* 00106 00107 $modulesArray might look like this when entering this function. 00108 Notice the two modules added by extensions - they have a path attached 00109 00110 Array 00111 ( 00112 [web] => list,info,perm,func 00113 [file] => list 00114 [doc] => 00115 [user] => 00116 [tools] => em,install,txphpmyadmin 00117 [help] => about 00118 [_PATHS] => Array 00119 ( 00120 [tools_install] => /www/htdocs/typo3/32/coreinstall/typo3/ext/install/mod/ 00121 [tools_txphpmyadmin] => /www/htdocs/typo3/32/coreinstall/typo3/ext/phpmyadmin/modsub/ 00122 ) 00123 00124 ) 00125 00126 */ 00127 // 00128 $this->absPathArray = $modulesArray['_PATHS']; 00129 unset($modulesArray['_PATHS']); 00130 00131 /* 00132 With the above data for modules the result of this function call will be: 00133 00134 Array 00135 ( 00136 [web] => Array 00137 ( 00138 [0] => list 00139 [1] => info 00140 [2] => perm 00141 [3] => func 00142 ) 00143 00144 [file] => Array 00145 ( 00146 [0] => list 00147 ) 00148 00149 [doc] => 1 00150 [user] => 1 00151 [tools] => Array 00152 ( 00153 [0] => em 00154 [1] => install 00155 [2] => txphpmyadmin 00156 ) 00157 00158 [help] => Array 00159 ( 00160 [0] => about 00161 ) 00162 00163 ) 00164 */ 00165 $theMods = $this->parseModulesArray($modulesArray); 00166 00167 /* 00168 Originally modules were found in typo3/mod/ 00169 User defined modules were found in ../typo3conf/ 00170 00171 Today almost all modules reside in extensions and they are found by the _PATHS array of the incoming $TBE_MODULES array 00172 */ 00173 // Setting paths for 1) core modules (old concept from mod/) and 2) user-defined modules (from ../typo3conf) 00174 $paths = array(); 00175 $paths['defMods'] = PATH_typo3.'mod/'; // Path of static modules 00176 $paths['userMods'] = PATH_typo3.'../typo3conf/'; // local modules (maybe frontend specific) 00177 00178 // Traverses the module setup and creates the internal array $this->modules 00179 foreach($theMods as $mods => $subMod) { 00180 unset ($path); 00181 00182 $extModRelPath = $this->checkExtensionModule($mods); 00183 if ($extModRelPath) { // EXTENSION module: 00184 $theMainMod = $this->checkMod($mods,PATH_site.$extModRelPath); 00185 if (is_array($theMainMod) || $theMainMod!='notFound') { 00186 $path = 1; // ... just so it goes on... submodules cannot be within this path! 00187 } 00188 } else { // 'CLASSIC' module 00189 // Checking for typo3/mod/ module existence... 00190 $theMainMod = $this->checkMod($mods,$paths['defMods'].$mods); 00191 if (is_array($theMainMod) || $theMainMod!='notFound') { 00192 $path = $paths['defMods']; 00193 } else { 00194 // If not typo3/mod/ then it could be user-defined in typo3conf/ ...? 00195 $theMainMod = $this->checkMod($mods,$paths['userMods'].$mods); 00196 if (is_array($theMainMod) || $theMainMod!='notFound') { 00197 $path = $paths['userMods']; 00198 } 00199 } 00200 } 00201 00202 // if $theMainMod is not set (false) there is no access to the module !(?) 00203 if ($theMainMod && isset($path)) { 00204 $this->modules[$mods] = $theMainMod; 00205 00206 // SUBMODULES - if any - are loaded (The 'doc' module cannot have submodules...) 00207 if ($mods!='doc' && is_array($subMod)) { 00208 foreach($subMod as $valsub) { 00209 $extModRelPath = $this->checkExtensionModule($mods.'_'.$valsub); 00210 if ($extModRelPath) { // EXTENSION submodule: 00211 $theTempSubMod = $this->checkMod($mods.'_'.$valsub,PATH_site.$extModRelPath); 00212 if (is_array($theTempSubMod)) { // default sub-module in either main-module-path, be it the default or the userdefined. 00213 $this->modules[$mods]['sub'][$valsub] = $theTempSubMod; 00214 } 00215 } else { // 'CLASSIC' submodule 00216 // Checking for typo3/mod/xxx/ module existence... 00217 $theTempSubMod = $this->checkMod($mods.'_'.$valsub,$path.$mods.'/'.$valsub); 00218 if (is_array($theTempSubMod)) { // default sub-module in either main-module-path, be it the default or the userdefined. 00219 $this->modules[$mods]['sub'][$valsub] = $theTempSubMod; 00220 } elseif ($path == $paths['defMods']) { // If the submodule did not exist in the default module path, then check if there is a submodule in the submodule path! 00221 $theTempSubMod = $this->checkMod($mods.'_'.$valsub,$paths['userMods'].$mods.'/'.$valsub); 00222 if (is_array($theTempSubMod)) { 00223 $this->modules[$mods]['sub'][$valsub] = $theTempSubMod; 00224 } 00225 } 00226 } 00227 } 00228 } 00229 } else { // This must be done in order to fill out the select-lists for modules correctly!! 00230 if ($mods!='doc' && is_array($subMod)) { 00231 foreach($subMod as $valsub) { 00232 $this->checkMod($mods.'_'.$valsub,$path.$mods.'/'.$valsub); 00233 } 00234 } 00235 } 00236 } 00237 /* 00238 At this point $this->modules should look like this: 00239 Only modules which were accessible to the $BE_USER is listed in this array. 00240 00241 Array 00242 ( 00243 [web] => Array 00244 ( 00245 [name] => web 00246 [script] => dummy.php 00247 [defaultMod] => list 00248 [sub] => Array 00249 ( 00250 [list] => Array 00251 ( 00252 [name] => web_list 00253 [script] => mod/web/list/../../../db_list.php 00254 ) 00255 00256 [info] => Array 00257 ( 00258 [name] => web_info 00259 [script] => mod/web/info/index.php 00260 ) 00261 00262 [perm] => Array 00263 ( 00264 [name] => web_perm 00265 [script] => mod/web/perm/index.php 00266 ) 00267 00268 [func] => Array 00269 ( 00270 [name] => web_func 00271 [script] => mod/web/func/index.php 00272 ) 00273 00274 ) 00275 00276 ) 00277 00278 [file] => Array 00279 ( 00280 [name] => file 00281 [script] => dummy.php 00282 [sub] => Array 00283 ( 00284 [list] => Array 00285 ( 00286 [name] => file_list 00287 [script] => mod/file/list/../../../file_list.php 00288 ) 00289 00290 ) 00291 00292 ) 00293 00294 [doc] => Array 00295 ( 00296 [name] => doc 00297 [script] => mod/doc/../../alt_doc.php 00298 ) 00299 00300 [user] => Array 00301 ( 00302 [name] => user 00303 [script] => dummy.php 00304 [defaultMod] => task 00305 ) 00306 00307 [tools] => Array 00308 ( 00309 [name] => tools 00310 [script] => dummy.php 00311 [sub] => Array 00312 ( 00313 [em] => Array 00314 ( 00315 [name] => tools_em 00316 [script] => mod/tools/em/index.php 00317 ) 00318 00319 [install] => Array 00320 ( 00321 [name] => tools_install 00322 [script] => ext/install/mod/../../../install/index.php 00323 ) 00324 00325 [txphpmyadmin] => Array 00326 ( 00327 [name] => tools_txphpmyadmin 00328 [script] => ext/phpmyadmin/modsub/index.php 00329 ) 00330 00331 ) 00332 00333 ) 00334 00335 [help] => Array 00336 ( 00337 [name] => help 00338 [script] => dummy.php 00339 [defaultMod] => welcome 00340 [sub] => Array 00341 ( 00342 [about] => Array 00343 ( 00344 [name] => help_about 00345 [script] => mod/help/about/index.php 00346 ) 00347 00348 ) 00349 00350 ) 00351 00352 ) 00353 00354 */ 00355 00356 #debug($this->modules); 00357 #debug($GLOBALS['LANG']->moduleLabels); 00358 }
|
|
Parses the moduleArray ($TBE_MODULES) into a internally useful structure. Returns an array where the keys are names of the module and the values may be true (only module) or an array (of submodules)
Definition at line 488 of file class.t3lib_loadmodules.php. References cleanName(). Referenced by load(). 00488 { 00489 $theMods = Array(); 00490 if (is_array($arr)) { 00491 foreach($arr as $mod => $subs) { 00492 $mod = $this->cleanName($mod); // clean module name to alphanum 00493 if ($mod) { 00494 if ($subs) { 00495 $subsArr = t3lib_div::trimExplode(',', $subs); 00496 foreach($subsArr as $subMod) { 00497 $subMod = $this->cleanName($subMod); 00498 if ($subMod) { 00499 $theMods[$mod][] = $subMod; 00500 } 00501 } 00502 } else { 00503 $theMods[$mod] = 1; 00504 } 00505 } 00506 } 00507 } 00508 return $theMods; 00509 }
|
|
Definition at line 80 of file class.t3lib_loadmodules.php. |
|
Definition at line 85 of file class.t3lib_loadmodules.php. |
|
Definition at line 82 of file class.t3lib_loadmodules.php. |
|
Definition at line 83 of file class.t3lib_loadmodules.php. |
|
Definition at line 79 of file class.t3lib_loadmodules.php. |