"TYPO3 4.0.1: typo3_src-4.0.1/t3lib/class.t3lib_extmgm.php Source File", "datetime" => "Sat Dec 2 19:22:18 2006", "date" => "2 Dec 2006", "doxygenversion" => "1.4.6", "projectname" => "TYPO3 4.0.1", "projectnumber" => "4.0.1" ); get_header($doxygen_vars); ?>
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2006 Kasper Skaarhoj (kasperYYYY@typo3.com) 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00114 class t3lib_extMgm { 00115 00116 00117 /************************************** 00118 * 00119 * PATHS and other evaluation 00120 * 00121 ***************************************/ 00122 00131 function isLoaded($key,$exitOnError=0) { 00132 global $TYPO3_LOADED_EXT; 00133 if ($exitOnError && !isset($TYPO3_LOADED_EXT[$key])) die('Fatal Error: Extension "'.$key.'" was not loaded.'); 00134 return isset($TYPO3_LOADED_EXT[$key]); 00135 } 00136 00147 function extPath($key,$script='') { 00148 global $TYPO3_LOADED_EXT; 00149 if (!isset($TYPO3_LOADED_EXT[$key])) { 00150 #debug(array(debug_backtrace())); 00151 die('TYPO3 Fatal Error: Extension key "'.$key.'" was NOT loaded! (t3lib_extMgm::extPath)'); 00152 } 00153 return PATH_site.$TYPO3_LOADED_EXT[$key]['siteRelPath'].$script; 00154 } 00155 00165 function extRelPath($key) { 00166 global $TYPO3_LOADED_EXT; 00167 if (!isset($TYPO3_LOADED_EXT[$key])) { 00168 die('TYPO3 Fatal Error: Extension key "'.$key.'" was NOT loaded! (t3lib_extMgm::extRelPath)'); 00169 } 00170 return $TYPO3_LOADED_EXT[$key]['typo3RelPath']; 00171 } 00172 00182 function siteRelPath($key) { 00183 return substr(t3lib_extMgm::extPath($key),strlen(PATH_site)); 00184 } 00185 00194 function getCN($key) { 00195 return substr($key,0,5)=='user_' ? 'user_'.str_replace('_','',substr($key,5)) : 'tx_'.str_replace('_','',$key); 00196 } 00197 00198 00199 00200 00201 00202 00203 00204 00205 00206 00207 /************************************** 00208 * 00209 * Adding BACKEND features 00210 * (related to core features) 00211 * 00212 ***************************************/ 00213 00227 function addTCAcolumns($table,$columnArray,$addTofeInterface=0) { 00228 global $TCA; 00229 t3lib_div::loadTCA($table); 00230 if (is_array($columnArray) && is_array($TCA[$table]) && is_array($TCA[$table]['columns'])) { 00231 $TCA[$table]['columns'] = array_merge($TCA[$table]['columns'],$columnArray); // Candidate for t3lib_div::array_merge() if integer-keys will some day make trouble... 00232 if ($addTofeInterface) $TCA[$table]['feInterface']['fe_admin_fieldList'].=','.implode(',',array_keys($columnArray)); 00233 } 00234 } 00235 00251 function addToAllTCAtypes($table,$str,$specificTypesList='',$position='') { 00252 global $TCA; 00253 00254 $positionArr=t3lib_div::trimExplode(',',$position,1); 00255 $insert=count($position); 00256 00257 t3lib_div::loadTCA($table); 00258 if (trim($str) && is_array($TCA[$table]) && is_array($TCA[$table]['types'])) { 00259 foreach($TCA[$table]['types'] as $k => $v) { 00260 if (!$specificTypesList || t3lib_div::inList($specificTypesList,$k)) { 00261 if ($insert) { 00262 $append=true; 00263 $showItem = t3lib_div::trimExplode(',',$TCA[$table]['types'][$k]['showitem'],1); 00264 foreach($showItem as $key => $fieldInfo) { 00265 00266 $parts = explode(';',$fieldInfo); 00267 $theField = trim($parts[0]); 00268 $palette = trim($parts[0]).';;'.trim($parts[2]); 00269 00270 // insert before: find exact field name or palette with number 00271 if (in_array($theField, $positionArr) || in_array($palette, $positionArr) || in_array('before:'.$theField, $positionArr) || in_array('before:'.$palette, $positionArr)) { 00272 $showItem[$key]=trim($str).', '.$fieldInfo; 00273 $append=false; 00274 break; 00275 } 00276 // insert after 00277 if (in_array('after:'.$theField, $positionArr) || in_array('after:'.$palette, $positionArr)) { 00278 $showItem[$key]=$fieldInfo.', '.trim($str); 00279 $append=false; 00280 break; 00281 } 00282 } 00283 00284 // Not found? Then append. 00285 if($append) { 00286 $showItem[]=trim($str); 00287 } 00288 00289 $TCA[$table]['types'][$k]['showitem']=implode(', ', $showItem); 00290 00291 } else { 00292 $TCA[$table]['types'][$k]['showitem'].=', '.trim($str); 00293 } 00294 } 00295 } 00296 } 00297 } 00298 00299 00309 function allowTableOnStandardPages($table) { 00310 global $PAGES_TYPES; 00311 00312 $PAGES_TYPES['default']['allowedTables'].=','.$table; 00313 } 00314 00326 function addModule($main,$sub='',$position='',$path='') { 00327 global $TBE_MODULES; 00328 00329 if (isset($TBE_MODULES[$main]) && $sub) { // If there is already a main module by this name: 00330 00331 // Adding the submodule to the correct position: 00332 list($place,$modRef)=t3lib_div::trimExplode(':',$position,1); 00333 $mods = t3lib_div::trimExplode(',',$TBE_MODULES[$main],1); 00334 if (!in_array($sub,$mods)) { 00335 switch(strtolower($place)) { 00336 case 'after': 00337 case 'before': 00338 $pointer=0; 00339 reset($mods); 00340 while(list($k,$m)=each($mods)) { 00341 if (!strcmp($m,$modRef)) { 00342 $pointer=strtolower($place)=='after'?$k+1:$k; 00343 } 00344 } 00345 array_splice( 00346 $mods, // The modules array 00347 $pointer, // To insert one position from the end of the list 00348 0, // Don't remove any items, just insert 00349 $sub // Module to insert 00350 ); 00351 break; 00352 default: 00353 if (strtolower($place)=='top') { 00354 array_unshift($mods,$sub); 00355 } else { 00356 array_push($mods,$sub); 00357 } 00358 break; 00359 } 00360 } 00361 // Re-inserting the submodule list: 00362 $TBE_MODULES[$main]=implode(',',$mods); 00363 } else { // Create new main modules with only one submodule, $sub (or none if $sub is blank) 00364 $TBE_MODULES[$main]=$sub; 00365 } 00366 00367 // Adding path: 00368 if ($path) { 00369 $TBE_MODULES['_PATHS'][$main.($sub?'_'.$sub:'')]=$path; 00370 } 00371 } 00372 00389 function insertModuleFunction($modname,$className,$classPath,$title,$MM_key='function',$WS='') { 00390 global $TBE_MODULES_EXT; 00391 $TBE_MODULES_EXT[$modname]['MOD_MENU'][$MM_key][$className]=array( 00392 'name' => $className, 00393 'path' => $classPath, 00394 'title' => $title, 00395 'ws' => $WS 00396 ); 00397 } 00398 00408 function addPageTSConfig($content) { 00409 global $TYPO3_CONF_VARS; 00410 $TYPO3_CONF_VARS['BE']['defaultPageTSconfig'].="\n[GLOBAL]\n".$content; 00411 } 00412 00422 function addUserTSConfig($content) { 00423 global $TYPO3_CONF_VARS; 00424 $TYPO3_CONF_VARS['BE']['defaultUserTSconfig'].="\n[GLOBAL]\n".$content; 00425 } 00426 00437 function addLLrefForTCAdescr($tca_descr_key,$file_ref) { 00438 global $TCA_DESCR; 00439 if ($tca_descr_key) { 00440 if (!is_array($TCA_DESCR[$tca_descr_key])) { 00441 $TCA_DESCR[$tca_descr_key]=array(); 00442 } 00443 if (!is_array($TCA_DESCR[$tca_descr_key]['refs'])) { 00444 $TCA_DESCR[$tca_descr_key]['refs']=array(); 00445 } 00446 $TCA_DESCR[$tca_descr_key]['refs'][]=$file_ref; 00447 } 00448 } 00449 00450 00451 00452 00453 00454 00455 00456 00457 00458 00459 00460 00461 /************************************** 00462 * 00463 * Adding SERVICES features 00464 * 00465 * @author René Fritz <r.fritz@colorcube.de> 00466 * 00467 ***************************************/ 00468 00479 function addService($extKey, $serviceType, $serviceKey, $info) { 00480 global $T3_SERVICES,$TYPO3_CONF_VARS; 00481 00482 // even not available services will be included to make it possible to give the admin a feedback of non-available services. 00483 // but maybe it's better to move non-available services to a different array?? 00484 00485 if ($serviceType AND 00486 !t3lib_div::isFirstPartOfStr($serviceType, 'tx_') AND 00487 (t3lib_div::isFirstPartOfStr($serviceKey, 'tx_') OR t3lib_div::isFirstPartOfStr($serviceKey, 'user_')) AND 00488 is_array($info)) { 00489 00490 $info['priority'] = max(0,min(100,$info['priority'])); 00491 00492 $T3_SERVICES[$serviceType][$serviceKey]=$info; 00493 00494 $T3_SERVICES[$serviceType][$serviceKey]['extKey'] = $extKey; 00495 $T3_SERVICES[$serviceType][$serviceKey]['serviceKey'] = $serviceKey; 00496 $T3_SERVICES[$serviceType][$serviceKey]['serviceType'] = $serviceType; 00497 00498 00499 // mapping a service key to a service type 00500 // all service keys begin with tx_ - service types don't 00501 // this way a selection of a special service key as service type is easy 00502 $T3_SERVICES[$serviceKey][$serviceKey] = &$T3_SERVICES[$serviceType][$serviceKey]; 00503 00504 00505 // change the priority (and other values) from TYPO3_CONF_VARS 00506 // $TYPO3_CONF_VARS['T3_SERVICES'][$serviceType][$serviceKey]['priority'] 00507 // even the activation is possible (a unix service might be possible on windows for some reasons) 00508 if (is_array($TYPO3_CONF_VARS['T3_SERVICES'][$serviceType][$serviceKey])) { 00509 00510 // no check is done here - there might be configuration values only the service type knows about, so we pass everything 00511 $T3_SERVICES[$serviceType][$serviceKey] = array_merge ($T3_SERVICES[$serviceType][$serviceKey],$TYPO3_CONF_VARS['T3_SERVICES'][$serviceType][$serviceKey]); 00512 } 00513 00514 00515 // OS check 00516 // empty $os means 'not limited to one OS', therefore a check is not needed 00517 if ($T3_SERVICES[$serviceType][$serviceKey]['available'] AND $T3_SERVICES[$serviceType][$serviceKey]['os']!='') { 00518 00519 // TYPO3_OS is not yet defined 00520 $os_type = stristr(PHP_OS,'win')&&!stristr(PHP_OS,'darwin')?'WIN':'UNIX'; 00521 00522 $os = t3lib_div::trimExplode(',',strtoupper($T3_SERVICES[$serviceType][$serviceKey]['os'])); 00523 00524 if (!in_array($os_type,$os)) { 00525 t3lib_extMgm::deactivateService($serviceType, $serviceKey); 00526 } 00527 } 00528 00529 // convert subtype list to array for quicker access 00530 $T3_SERVICES[$serviceType][$serviceKey]['serviceSubTypes'] = array(); 00531 $serviceSubTypes = t3lib_div::trimExplode(',',$info['subtype']); 00532 foreach ($serviceSubTypes as $subtype) { 00533 $T3_SERVICES[$serviceType][$serviceKey]['serviceSubTypes'][$subtype] = $subtype; 00534 } 00535 } 00536 } 00537 00547 function findService($serviceType, $serviceSubType='', $excludeServiceKeys=array()) { 00548 global $T3_SERVICES, $T3_VAR, $TYPO3_CONF_VARS; 00549 00550 $serviceKey = FALSE; 00551 $serviceInfo = FALSE; 00552 $priority = 0; 00553 $quality = 0; 00554 00555 if (!is_array($excludeServiceKeys) ) { 00556 $excludeServiceKeys = t3lib_div::trimExplode(',', $excludeServiceKeys, 1); 00557 } 00558 00559 if (is_array($T3_SERVICES[$serviceType])) { 00560 foreach($T3_SERVICES[$serviceType] as $key => $info) { 00561 00562 if (in_array($key, $excludeServiceKeys)) { 00563 continue; 00564 } 00565 00566 // select a subtype randomly 00567 // usefull to start a service by service key without knowing his subtypes - for testing purposes 00568 if ($serviceSubType=='*') { 00569 $serviceSubType = key($info['serviceSubTypes']); 00570 } 00571 00572 // this matches empty subtype too 00573 if( $info['available'] AND ($info['subtype']==$serviceSubType OR $info['serviceSubTypes'][$serviceSubType]) AND $info['priority']>=$priority ) { 00574 00575 // has a lower quality than the already found, therefore we skip this service 00576 if($info['priority']==$priority AND $info['quality']<$quality) { 00577 continue; 00578 } 00579 00580 // service depends on external programs - check if they exists 00581 if(trim($info['exec'])) { 00582 require_once(PATH_t3lib.'class.t3lib_exec.php'); 00583 00584 $executables = t3lib_div::trimExplode(',', $info['exec'],1); 00585 foreach($executables as $executable) { 00586 if(!t3lib_exec::checkCommand($executable)) { 00587 t3lib_extMgm::deactivateService($serviceType, $key); 00588 $info['available']=FALSE; 00589 break; 00590 } 00591 } 00592 } 00593 00594 // still available after exec check? 00595 if($info['available']) { 00596 $serviceKey = $key; 00597 $priority = $info['priority']; 00598 $quality = $info['quality']; 00599 } 00600 } 00601 } 00602 } 00603 00604 if ($serviceKey) { 00605 $serviceInfo = $T3_SERVICES[$serviceType][$serviceKey]; 00606 } 00607 return $serviceInfo; 00608 } 00609 00618 function deactivateService($serviceType, $serviceKey) { 00619 global $T3_SERVICES; 00620 00621 // ... maybe it's better to move non-available services to a different array?? 00622 $T3_SERVICES[$serviceType][$serviceKey]['available'] = FALSE; 00623 } 00624 00625 00626 00627 00628 00629 00630 00631 00632 00633 00634 00635 00636 00637 00638 /************************************** 00639 * 00640 * Adding FRONTEND features 00641 * (related specifically to "cms" extension) 00642 * 00643 ***************************************/ 00644 00657 function addPlugin($itemArray,$type='list_type') { 00658 global $TCA; 00659 t3lib_div::loadTCA('tt_content'); 00660 if (is_array($TCA['tt_content']['columns']) && is_array($TCA['tt_content']['columns'][$type]['config']['items'])) { 00661 reset($TCA['tt_content']['columns'][$type]['config']['items']); 00662 while(list($k,$v)=each($TCA['tt_content']['columns'][$type]['config']['items'])) { 00663 if (!strcmp($v[1],$itemArray[1])) { 00664 $TCA['tt_content']['columns'][$type]['config']['items'][$k]=$itemArray; 00665 return; 00666 } 00667 } 00668 $TCA['tt_content']['columns'][$type]['config']['items'][]=$itemArray; 00669 } 00670 } 00671 00682 function addPiFlexFormValue($piKeyToMatch,$value) { 00683 global $TCA; 00684 t3lib_div::loadTCA('tt_content'); 00685 00686 if (is_array($TCA['tt_content']['columns']) && is_array($TCA['tt_content']['columns']['pi_flexform']['config']['ds'])) { 00687 $TCA['tt_content']['columns']['pi_flexform']['config']['ds'][$piKeyToMatch] = $value; 00688 } 00689 } 00690 00702 function addToInsertRecords($table,$content_table='tt_content',$content_field='records') { 00703 global $TCA; 00704 t3lib_div::loadTCA($content_table); 00705 if (is_array($TCA[$content_table]['columns']) && isset($TCA[$content_table]['columns'][$content_field]['config']['allowed'])) { 00706 $TCA[$content_table]['columns'][$content_field]['config']['allowed'].=','.$table; 00707 } 00708 } 00709 00733 function addPItoST43($key,$classFile='',$prefix='',$type='list_type',$cached=0) { 00734 global $TYPO3_LOADED_EXT; 00735 $classFile = $classFile ? $classFile : 'pi/class.tx_'.str_replace('_','',$key).$prefix.'.php'; 00736 $cN = t3lib_extMgm::getCN($key); 00737 00738 // General plugin: 00739 if ($cached) { 00740 $pluginContent = trim(' 00741 includeLibs.'.$cN.$prefix.' = '.$TYPO3_LOADED_EXT[$key]['siteRelPath'].$classFile.' 00742 plugin.'.$cN.$prefix.' = USER 00743 plugin.'.$cN.$prefix.' { 00744 userFunc = '.$cN.$prefix.'->main 00745 }'); 00746 } else { 00747 $pluginContent = trim(' 00748 plugin.'.$cN.$prefix.' = USER_INT 00749 plugin.'.$cN.$prefix.' { 00750 includeLibs = '.$TYPO3_LOADED_EXT[$key]['siteRelPath'].$classFile.' 00751 userFunc = '.$cN.$prefix.'->main 00752 }'); 00753 } 00754 t3lib_extMgm::addTypoScript($key,'setup',' 00755 # Setting '.$key.' plugin TypoScript 00756 '.$pluginContent); 00757 00758 // After ST43: 00759 switch($type) { 00760 case 'list_type': 00761 $addLine = 'tt_content.list.20.'.$key.$prefix.' = < plugin.'.$cN.$prefix; 00762 break; 00763 case 'menu_type': 00764 $addLine = 'tt_content.menu.20.'.$key.$prefix.' = < plugin.'.$cN.$prefix; 00765 break; 00766 case 'splash_layout': 00767 $addLine = 'tt_content.splash.'.$key.$prefix.' = < plugin.'.$cN.$prefix; 00768 break; 00769 case 'CType': 00770 $addLine = trim(' 00771 tt_content.'.$key.$prefix.' = COA 00772 tt_content.'.$key.$prefix.' { 00773 10 = < lib.stdheader 00774 20 = < plugin.'.$cN.$prefix.' 00775 } 00776 '); 00777 break; 00778 case 'header_layout': 00779 $addLine = 'lib.stdheader.10.'.$key.$prefix.' = < plugin.'.$cN.$prefix; 00780 break; 00781 case 'includeLib': 00782 $addLine = 'page.1000 = < plugin.'.$cN.$prefix; 00783 break; 00784 default: 00785 $addLine = ''; 00786 break; 00787 } 00788 if ($addLine) { 00789 t3lib_extMgm::addTypoScript($key,'setup',' 00790 # Setting '.$key.' plugin TypoScript 00791 '.$addLine.' 00792 ',43); 00793 } 00794 } 00795 00808 function addStaticFile($extKey,$path,$title) { 00809 global $TCA; 00810 t3lib_div::loadTCA('sys_template'); 00811 if ($extKey && $path && is_array($TCA['sys_template']['columns'])) { 00812 $value = str_replace(',','','EXT:'.$extKey.'/'.$path); 00813 $itemArray=array(trim($title.' ('.$extKey.')'),$value); 00814 $TCA['sys_template']['columns']['include_static_file']['config']['items'][]=$itemArray; 00815 } 00816 } 00817 00827 function addTypoScriptSetup($content) { 00828 global $TYPO3_CONF_VARS; 00829 $TYPO3_CONF_VARS['FE']['defaultTypoScript_setup'].="\n[GLOBAL]\n".$content; 00830 } 00831 00841 function addTypoScriptConstants($content) { 00842 global $TYPO3_CONF_VARS; 00843 $TYPO3_CONF_VARS['FE']['defaultTypoScript_constants'].="\n[GLOBAL]\n".$content; 00844 } 00845 00858 function addTypoScript($key,$type,$content,$afterStaticUid=0) { 00859 global $TYPO3_CONF_VARS; 00860 00861 if ($type=='setup' || $type=='editorcfg' || $type=='constants') { 00862 $content = ' 00863 00864 [GLOBAL] 00865 ############################################# 00866 ## TypoScript added by extension "'.$key.'" 00867 ############################################# 00868 00869 '.$content; 00870 if ($afterStaticUid) { 00871 $TYPO3_CONF_VARS['FE']['defaultTypoScript_'.$type.'.'][$afterStaticUid].=$content; 00872 if ($afterStaticUid==43) { // If 'content (default)' is targeted, also add to other 'content rendering templates', eg. css_styled_content 00873 $TYPO3_CONF_VARS['FE']['defaultTypoScript_'.$type.'.']['cssstyledcontent/static/'].=$content; 00874 } 00875 } else { 00876 $TYPO3_CONF_VARS['FE']['defaultTypoScript_'.$type].=$content; 00877 } 00878 } 00879 } 00880 00881 00882 00883 00884 00885 00886 00887 00888 00889 00890 00891 00892 00893 00894 00895 00896 00897 00898 /************************************** 00899 * 00900 * INTERNAL EXTENSION MANAGEMENT: 00901 * 00902 ***************************************/ 00903 00921 function typo3_loadExtensions() { 00922 global $TYPO3_CONF_VARS; 00923 00924 // Full list of extensions includes both required and extList: 00925 $rawExtList = $TYPO3_CONF_VARS['EXT']['requiredExt'].','.$TYPO3_CONF_VARS['EXT']['extList']; 00926 00927 // Empty array as a start. 00928 $extensions = array(); 00929 00930 // 00931 if ($rawExtList) { 00932 // The cached File prefix. 00933 $cacheFilePrefix = 'temp_CACHED'; 00934 // Setting the name for the cache files: 00935 if (intval($TYPO3_CONF_VARS['EXT']['extCache'])==1) $cacheFilePrefix.= '_ps'.substr(t3lib_div::shortMD5(PATH_site.'|'.$GLOBALS['TYPO_VERSION']),0,4); 00936 if (intval($TYPO3_CONF_VARS['EXT']['extCache'])==2) $cacheFilePrefix.= '_'.t3lib_div::shortMD5($rawExtList); 00937 00938 // If cache files available, set cache file prefix and return: 00939 if ($TYPO3_CONF_VARS['EXT']['extCache'] && t3lib_extMgm::isCacheFilesAvailable($cacheFilePrefix)) { 00940 // Return cache file prefix: 00941 $extensions['_CACHEFILE'] = $cacheFilePrefix; 00942 } else { // ... but if not, configure... 00943 00944 // Prepare reserved filenames: 00945 $files = t3lib_div::trimExplode(',','ext_localconf.php,ext_tables.php,ext_tables.sql,ext_tables_static+adt.sql,ext_typoscript_constants.txt,ext_typoscript_editorcfg.txt,ext_typoscript_setup.txt',1); 00946 00947 // Traverse extensions and check their existence: 00948 clearstatcache(); // Clear file state cache to make sure we get good results from is_dir() 00949 $temp_extensions = array_unique(t3lib_div::trimExplode(',',$rawExtList,1)); 00950 foreach($temp_extensions as $temp_extKey) { 00951 // Check local, global and system locations: 00952 if (@is_dir(PATH_site.'typo3conf/ext/'.$temp_extKey.'/')) { 00953 $extensions[$temp_extKey] = array('type'=>'L', 'siteRelPath'=>'typo3conf/ext/'.$temp_extKey.'/', 'typo3RelPath'=>'../typo3conf/ext/'.$temp_extKey.'/'); 00954 } elseif (@is_dir(PATH_site.TYPO3_mainDir.'ext/'.$temp_extKey.'/')) { 00955 $extensions[$temp_extKey] = array('type'=>'G', 'siteRelPath'=>TYPO3_mainDir.'ext/'.$temp_extKey.'/', 'typo3RelPath'=>'ext/'.$temp_extKey.'/'); 00956 } elseif (@is_dir(PATH_site.TYPO3_mainDir.'sysext/'.$temp_extKey.'/')) { 00957 $extensions[$temp_extKey] = array('type'=>'S', 'siteRelPath'=>TYPO3_mainDir.'sysext/'.$temp_extKey.'/', 'typo3RelPath'=>'sysext/'.$temp_extKey.'/'); 00958 } 00959 00960 // If extension was found, check for reserved filenames: 00961 if (isset($extensions[$temp_extKey])) { 00962 foreach($files as $fName) { 00963 $temp_filename = PATH_site.$extensions[$temp_extKey]['siteRelPath'].trim($fName); 00964 if (is_array($extensions[$temp_extKey]) && @is_file($temp_filename)) { 00965 $extensions[$temp_extKey][$fName] = $temp_filename; 00966 } 00967 } 00968 } 00969 } 00970 unset($extensions['_CACHEFILE']); 00971 00972 // write cache? 00973 if ($TYPO3_CONF_VARS['EXT']['extCache'] && 00974 @is_dir(PATH_site.TYPO3_mainDir.'sysext/') && 00975 @is_dir(PATH_site.TYPO3_mainDir.'ext/')) { // Must also find global and system extension directories to exist, otherwise caching cannot be allowed (since it is most likely a temporary server problem). This might fix a rare, unrepeatable bug where global/system extensions are not loaded resulting in fatal errors if that is cached! 00976 $wrError = t3lib_extMgm::cannotCacheFilesWritable($cacheFilePrefix); 00977 if ($wrError) { 00978 $TYPO3_CONF_VARS['EXT']['extCache']=0; 00979 } else { 00980 // Write cache files: 00981 $extensions = t3lib_extMgm::writeCacheFiles($extensions,$cacheFilePrefix); 00982 } 00983 } 00984 } 00985 } 00986 00987 return $extensions; 00988 } 00989 00998 function _makeIncludeHeader($key,$file) { 00999 return '<?php 01000 ########################### 01001 ## EXTENSION: '.$key.' 01002 ## FILE: '.$file.' 01003 ########################### 01004 01005 $_EXTKEY = \''.$key.'\'; 01006 $_EXTCONF = $TYPO3_CONF_VARS[\'EXT\'][\'extConf\'][$_EXTKEY]; 01007 01008 ?>'; 01009 } 01010 01019 function isCacheFilesAvailable($cacheFilePrefix) { 01020 return 01021 @is_file(PATH_typo3conf.$cacheFilePrefix.'_ext_localconf.php') && 01022 @is_file(PATH_typo3conf.$cacheFilePrefix.'_ext_tables.php'); 01023 } 01024 01032 function isLocalconfWritable() { 01033 return @is_writable(PATH_typo3conf) && @is_writable(PATH_typo3conf.'localconf.php'); 01034 } 01035 01045 function cannotCacheFilesWritable($cacheFilePrefix) { 01046 $error=array(); 01047 if (!@is_writable(PATH_typo3conf)) { 01048 $error[]=PATH_typo3conf; 01049 } 01050 if (@is_file(PATH_typo3conf.$cacheFilePrefix.'_ext_localconf.php') && 01051 !@is_writable(PATH_typo3conf.$cacheFilePrefix.'_ext_localconf.php')) { 01052 $error[]=PATH_typo3conf.$cacheFilePrefix.'_ext_localconf.php'; 01053 } 01054 if (@is_file(PATH_typo3conf.$cacheFilePrefix.'_ext_tables.php') && 01055 !@is_writable(PATH_typo3conf.$cacheFilePrefix.'_ext_tables.php')) { 01056 $error[]=PATH_typo3conf.$cacheFilePrefix.'_ext_tables.php'; 01057 } 01058 return implode(', ',$error); 01059 } 01060 01069 function currentCacheFiles() { 01070 global $TYPO3_LOADED_EXT; 01071 01072 if ($TYPO3_LOADED_EXT['_CACHEFILE']) { 01073 if (t3lib_extMgm::isCacheFilesAvailable($TYPO3_LOADED_EXT['_CACHEFILE'])) { 01074 return array( 01075 PATH_typo3conf.$TYPO3_LOADED_EXT['_CACHEFILE'].'_ext_localconf.php', 01076 PATH_typo3conf.$TYPO3_LOADED_EXT['_CACHEFILE'].'_ext_tables.php' 01077 ); 01078 } 01079 } 01080 } 01081 01092 function writeCacheFiles($extensions,$cacheFilePrefix) { 01093 // Making cache files: 01094 $extensions['_CACHEFILE'] = $cacheFilePrefix; 01095 $cFiles=array(); 01096 $cFiles['ext_localconf'].='<?php 01097 01098 $TYPO3_LOADED_EXT = unserialize(stripslashes(\''.addslashes(serialize($extensions)).'\')); 01099 01100 ?>'; 01101 01102 reset($extensions); 01103 while(list($key,$conf)=each($extensions)) { 01104 if (is_array($conf)) { 01105 if ($conf['ext_localconf.php']) { 01106 $cFiles['ext_localconf'].=t3lib_extMgm::_makeIncludeHeader($key,$conf['ext_localconf.php']); 01107 $cFiles['ext_localconf'].=trim(t3lib_div::getUrl($conf['ext_localconf.php'])); 01108 } 01109 if ($conf['ext_tables.php']) { 01110 $cFiles['ext_tables'].=t3lib_extMgm::_makeIncludeHeader($key,$conf['ext_tables.php']); 01111 $cFiles['ext_tables'].=trim(t3lib_div::getUrl($conf['ext_tables.php'])); 01112 } 01113 } 01114 } 01115 01116 t3lib_div::writeFile(PATH_typo3conf.$cacheFilePrefix.'_ext_localconf.php',$cFiles['ext_localconf']); 01117 t3lib_div::writeFile(PATH_typo3conf.$cacheFilePrefix.'_ext_tables.php',$cFiles['ext_tables']); 01118 01119 $extensions=array(); 01120 $extensions['_CACHEFILE'] = $cacheFilePrefix; 01121 01122 return $extensions; 01123 } 01124 01130 function removeCacheFiles() { 01131 $cacheFiles = t3lib_extMgm::currentCacheFiles(); 01132 $out = 0; 01133 if (is_array($cacheFiles)) { 01134 reset($cacheFiles); 01135 foreach($cacheFiles as $cfile) { 01136 @unlink($cfile); 01137 clearstatcache(); 01138 $out++; 01139 } 01140 } 01141 return $out; 01142 } 01143 } 01144 01145 ?>