* Feature #6770: Flexform DataStructure pointerFields:
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_extmgm.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2006 Kasper Skaarhoj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Contains a class with Extension Management functions
29 *
30 * $Id$
31 * Revised for TYPO3 3.6 July/2003 by Kasper Skaarhoj
32 *
33 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
34 */
35 /**
36 * [CLASS/FUNCTION INDEX of SCRIPT]
37 *
38 *
39 *
40 * 114: class t3lib_extMgm
41 *
42 * SECTION: PATHS and other evaluation
43 * 131: function isLoaded($key,$exitOnError=0)
44 * 147: function extPath($key,$script='')
45 * 165: function extRelPath($key)
46 * 182: function siteRelPath($key)
47 * 194: function getCN($key)
48 *
49 * SECTION: Adding BACKEND features
50 * 227: function addTCAcolumns($table,$columnArray,$addTofeInterface=0)
51 * 251: function addToAllTCAtypes($table,$str,$specificTypesList='',$position='')
52 * 309: function allowTableOnStandardPages($table)
53 * 326: function addModule($main,$sub='',$position='',$path='')
54 * 389: function insertModuleFunction($modname,$className,$classPath,$title,$MM_key='function',$WS='')
55 * 408: function addPageTSConfig($content)
56 * 422: function addUserTSConfig($content)
57 * 437: function addLLrefForTCAdescr($tca_descr_key,$file_ref)
58 *
59 * SECTION: Adding SERVICES features
60 * 479: function addService($extKey, $serviceType, $serviceKey, $info)
61 * 547: function findService($serviceType, $serviceSubType='', $excludeServiceKeys=array())
62 * 618: function deactivateService($serviceType, $serviceKey)
63 *
64 * SECTION: Adding FRONTEND features
65 * 657: function addPlugin($itemArray,$type='list_type')
66 * 682: function addPiFlexFormValue($piKeyToMatch,$value)
67 * 702: function addToInsertRecords($table,$content_table='tt_content',$content_field='records')
68 * 733: function addPItoST43($key,$classFile='',$prefix='',$type='list_type',$cached=0)
69 * 808: function addStaticFile($extKey,$path,$title)
70 * 827: function addTypoScriptSetup($content)
71 * 841: function addTypoScriptConstants($content)
72 * 858: function addTypoScript($key,$type,$content,$afterStaticUid=0)
73 *
74 * SECTION: INTERNAL EXTENSION MANAGEMENT:
75 * 921: function typo3_loadExtensions()
76 * 998: function _makeIncludeHeader($key,$file)
77 * 1019: function isCacheFilesAvailable($cacheFilePrefix)
78 * 1032: function isLocalconfWritable()
79 * 1045: function cannotCacheFilesWritable($cacheFilePrefix)
80 * 1069: function currentCacheFiles()
81 * 1092: function writeCacheFiles($extensions,$cacheFilePrefix)
82 * 1130: function removeCacheFiles()
83 *
84 * TOTAL FUNCTIONS: 32
85 * (This index is automatically created/updated by the extension "extdeveval")
86 *
87 */
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104 /**
105 * Extension Management functions
106 *
107 * This class is never instantiated, rather the methods inside is called as functions like
108 * t3lib_extMgm::isLoaded('my_extension');
109 *
110 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
111 * @package TYPO3
112 * @subpackage t3lib
113 */
114 class t3lib_extMgm {
115
116
117 /**************************************
118 *
119 * PATHS and other evaluation
120 *
121 ***************************************/
122
123 /**
124 * Returns true if the extension with extension key $key is loaded.
125 * Usage: 109
126 *
127 * @param string Extension key to test
128 * @param boolean If $exitOnError is true and the extension is not loaded the function will die with an error message
129 * @return boolean
130 */
131 function isLoaded($key,$exitOnError=0) {
132 global $TYPO3_LOADED_EXT;
133 if ($exitOnError && !isset($TYPO3_LOADED_EXT[$key])) die('Fatal Error: Extension "'.$key.'" was not loaded.');
134 return isset($TYPO3_LOADED_EXT[$key]);
135 }
136
137 /**
138 * Returns the absolute path to the extension with extension key $key
139 * If the extension is not loaded the function will die with an error message
140 * Useful for internal fileoperations
141 * Usage: 136
142 *
143 * @param string Extension key
144 * @param string $script is appended to the output if set.
145 * @return string
146 */
147 function extPath($key,$script='') {
148 global $TYPO3_LOADED_EXT;
149 if (!isset($TYPO3_LOADED_EXT[$key])) {
150 #debug(array(debug_backtrace()));
151 die('TYPO3 Fatal Error: Extension key "'.$key.'" was NOT loaded! (t3lib_extMgm::extPath)');
152 }
153 return PATH_site.$TYPO3_LOADED_EXT[$key]['siteRelPath'].$script;
154 }
155
156 /**
157 * Returns the relative path to the extension as measured from from the TYPO3_mainDir
158 * If the extension is not loaded the function will die with an error message
159 * Useful for images and links from backend
160 * Usage: 54
161 *
162 * @param string Extension key
163 * @return string
164 */
165 function extRelPath($key) {
166 global $TYPO3_LOADED_EXT;
167 if (!isset($TYPO3_LOADED_EXT[$key])) {
168 die('TYPO3 Fatal Error: Extension key "'.$key.'" was NOT loaded! (t3lib_extMgm::extRelPath)');
169 }
170 return $TYPO3_LOADED_EXT[$key]['typo3RelPath'];
171 }
172
173 /**
174 * Returns the relative path to the extension as measured from the PATH_site (frontend)
175 * If the extension is not loaded the function will die with an error message
176 * Useful for images and links from the frontend
177 * Usage: 6
178 *
179 * @param string Extension key
180 * @return string
181 */
182 function siteRelPath($key) {
183 return substr(t3lib_extMgm::extPath($key),strlen(PATH_site));
184 }
185
186 /**
187 * Returns the correct class name prefix for the extension key $key
188 * Usage: 3
189 *
190 * @param string Extension key
191 * @return string
192 * @internal
193 */
194 function getCN($key) {
195 return substr($key,0,5)=='user_' ? 'user_'.str_replace('_','',substr($key,5)) : 'tx_'.str_replace('_','',$key);
196 }
197
198
199
200
201
202
203
204
205
206
207 /**************************************
208 *
209 * Adding BACKEND features
210 * (related to core features)
211 *
212 ***************************************/
213
214 /**
215 * Adding fields to an existing table definition in $TCA
216 * Adds an array with $TCA column-configuration to the $TCA-entry for that table.
217 * This function adds the configuration needed for rendering of the field in TCEFORMS - but it does NOT add the field names to the types lists!
218 * So to have the fields displayed you must also call fx. addToAllTCAtypes or manually add the fields to the types list.
219 * FOR USE IN ext_tables.php FILES
220 * Usage: 4
221 *
222 * @param string $table is the table name of a table already present in $TCA with a columns section
223 * @param array $columnArray is the array with the additional columns (typical some fields an extension wants to add)
224 * @param boolean If $addTofeInterface is true the list of fields are also added to the fe_admin_fieldList.
225 * @return void
226 */
227 function addTCAcolumns($table,$columnArray,$addTofeInterface=0) {
228 global $TCA;
229 t3lib_div::loadTCA($table);
230 if (is_array($columnArray) && is_array($TCA[$table]) && is_array($TCA[$table]['columns'])) {
231 $TCA[$table]['columns'] = array_merge($TCA[$table]['columns'],$columnArray); // Candidate for t3lib_div::array_merge() if integer-keys will some day make trouble...
232 if ($addTofeInterface) $TCA[$table]['feInterface']['fe_admin_fieldList'].=','.implode(',',array_keys($columnArray));
233 }
234 }
235
236 /**
237 * Makes fields visible in the TCEforms, adding them to the end of (all) "types"-configurations
238 *
239 * Adds a string $str (comma list of field names) to all ["types"][xxx]["showitem"] entries for table $table (unless limited by $specificTypesList)
240 * This is needed to have new fields shown automatically in the TCEFORMS of a record from $table.
241 * Typically this function is called after having added new columns (database fields) with the addTCAcolumns function
242 * FOR USE IN ext_tables.php FILES
243 * Usage: 1
244 *
245 * @param string Table name
246 * @param string Field list to add.
247 * @param string List of specific types to add the field list to. (If empty, all type entries are affected)
248 * @param string Insert fields before (default) or after one of this fields (commalist with "before:" or "after:" commands). Example: "before:keywords,--palette--;;4,after:description". Palettes must be passed like in the example no matter how the palette definition looks like in TCA.
249 * @return void
250 */
251 function addToAllTCAtypes($table,$str,$specificTypesList='',$position='') {
252 global $TCA;
253
254 $positionArr=t3lib_div::trimExplode(',',$position,1);
255 $insert=count($position);
256
257 t3lib_div::loadTCA($table);
258 $str = trim($str);
259 if ($str && is_array($TCA[$table]) && is_array($TCA[$table]['types'])) {
260 foreach($TCA[$table]['types'] as $k => $v) {
261 if (!$specificTypesList || t3lib_div::inList($specificTypesList,$k)) {
262 if ($insert) {
263 if (count($positionArr)) {
264 $append=true;
265 $showItem = t3lib_div::trimExplode(',',$TCA[$table]['types'][$k]['showitem'],1);
266 foreach($showItem as $key => $fieldInfo) {
267
268 $parts = explode(';',$fieldInfo);
269 $theField = trim($parts[0]);
270 $palette = trim($parts[0]).';;'.trim($parts[2]);
271
272 // insert before: find exact field name or palette with number
273 if (in_array($theField, $positionArr) || in_array($palette, $positionArr) || in_array('before:'.$theField, $positionArr) || in_array('before:'.$palette, $positionArr)) {
274 $showItem[$key]=$str.', '.$fieldInfo;
275 $append=false;
276 break;
277 }
278 // insert after
279 if (in_array('after:'.$theField, $positionArr) || in_array('after:'.$palette, $positionArr)) {
280 $showItem[$key]=$fieldInfo.', '.$str;
281 $append=false;
282 break;
283 }
284 }
285
286 // Not found? Then append.
287 if($append) {
288 $showItem[]=$str;
289 }
290
291 $TCA[$table]['types'][$k]['showitem']=implode(', ', $showItem);
292 }
293 else {
294 $TCA[$table]['types'][$k]['showitem'] .= ', ' . $str;
295 }
296
297 } else {
298 $TCA[$table]['types'][$k]['showitem'].=', ' . $str;
299 }
300 }
301 }
302 }
303 }
304
305
306 /**
307 * Add tablename to default list of allowed tables on pages (in $PAGES_TYPES)
308 * Will add the $table to the list of tables allowed by default on pages as setup by $PAGES_TYPES['default']['allowedTables']
309 * FOR USE IN ext_tables.php FILES
310 * Usage: 11
311 *
312 * @param string Table name
313 * @return void
314 */
315 function allowTableOnStandardPages($table) {
316 global $PAGES_TYPES;
317
318 $PAGES_TYPES['default']['allowedTables'].=','.$table;
319 }
320
321 /**
322 * Adds a module (main or sub) to the backend interface
323 * FOR USE IN ext_tables.php FILES
324 * Usage: 18
325 *
326 * @param string $main is the main module key, $sub is the submodule key. So $main would be an index in the $TBE_MODULES array and $sub could be an element in the lists there.
327 * @param string $sub is the submodule key. If $sub is not set a blank $main module is created.
328 * @param string $position can be used to set the position of the $sub module within the list of existing submodules for the main module. $position has this syntax: [cmd]:[submodule-key]. cmd can be "after", "before" or "top" (or blank which is default). If "after"/"before" then submodule will be inserted after/before the existing submodule with [submodule-key] if found. If not found, the bottom of list. If "top" the module is inserted in the top of the submodule list.
329 * @param string $path is the absolute path to the module. If this value is defined the path is added as an entry in $TBE_MODULES['_PATHS'][ main_sub ]=$path; and thereby tells the backend where the newly added modules is found in the system.
330 * @return void
331 */
332 function addModule($main,$sub='',$position='',$path='') {
333 global $TBE_MODULES;
334
335 if (isset($TBE_MODULES[$main]) && $sub) { // If there is already a main module by this name:
336
337 // Adding the submodule to the correct position:
338 list($place,$modRef)=t3lib_div::trimExplode(':',$position,1);
339 $mods = t3lib_div::trimExplode(',',$TBE_MODULES[$main],1);
340 if (!in_array($sub,$mods)) {
341 switch(strtolower($place)) {
342 case 'after':
343 case 'before':
344 $pointer=0;
345 reset($mods);
346 while(list($k,$m)=each($mods)) {
347 if (!strcmp($m,$modRef)) {
348 $pointer=strtolower($place)=='after'?$k+1:$k;
349 }
350 }
351 array_splice(
352 $mods, // The modules array
353 $pointer, // To insert one position from the end of the list
354 0, // Don't remove any items, just insert
355 $sub // Module to insert
356 );
357 break;
358 default:
359 if (strtolower($place)=='top') {
360 array_unshift($mods,$sub);
361 } else {
362 array_push($mods,$sub);
363 }
364 break;
365 }
366 }
367 // Re-inserting the submodule list:
368 $TBE_MODULES[$main]=implode(',',$mods);
369 } else { // Create new main modules with only one submodule, $sub (or none if $sub is blank)
370 $TBE_MODULES[$main]=$sub;
371 }
372
373 // Adding path:
374 if ($path) {
375 $TBE_MODULES['_PATHS'][$main.($sub?'_'.$sub:'')]=$path;
376 }
377 }
378
379 /**
380 * Adds a module path to TBE_MODULES for used with the module dispatcher, mod.php
381 * Used only for modules that are not placed in the main/sub menu hierarchy by the traditional mechanism of addModule()
382 * Examples for this is context menu functionality (like import/export) which runs as an independent module through mod.php
383 * FOR USE IN ext_tables.php FILES
384 * Example: t3lib_extMgm::addModulePath('xMOD_tximpexp',t3lib_extMgm::extPath($_EXTKEY).'app/');
385 *
386 * @param string $name is the name of the module, refer to conf.php of the module.
387 * @param string $path is the absolute path to the module directory inside of which "index.php" and "conf.php" is found.
388 * @return void
389 */
390 function addModulePath($name,$path) {
391 global $TBE_MODULES;
392
393 $TBE_MODULES['_PATHS'][$name] = $path;
394 }
395
396 /**
397 * Adding an application for the top menu. These are regular modules but is required to respond with Ajax content in case of certain parameters sent to them.
398 *
399 * @param string $name is the name of the module, refer to conf.php of the module.
400 * @param string $path is the absolute path to the module directory inside of which "index.php" and "conf.php" is found.
401 * @param boolean If set, the application is placed in the shortcut bar below the menu bar.
402 * @param array Options
403 * @return void
404 */
405 function addTopApp($name,$path,$iconPane=FALSE,$options=array()) {
406 global $TBE_MODULES,$TYPO3_CONF_VARS;
407
408 $TYPO3_CONF_VARS['SC_OPTIONS']['GLOBAL']['topApps'][$iconPane?'icons':'menu'][$name] = $options;
409
410 // Set path for TBE-modules:
411 $TBE_MODULES['_PATHS'][$name] = $path;
412 }
413
414 /**
415 * Adds a "Function menu module" ('third level module') to an existing function menu for some other backend module
416 * The arguments values are generally determined by which function menu this is supposed to interact with
417 * See Inside TYPO3 for information on how to use this function.
418 * FOR USE IN ext_tables.php FILES
419 * Usage: 26
420 *
421 * @param string Module name
422 * @param string Class name
423 * @param string Class path
424 * @param string Title of module
425 * @param string Menu array key - default is "function"
426 * @param string Workspace conditions. Blank means all workspaces, any other string can be a comma list of "online", "offline" and "custom"
427 * @return void
428 * @see t3lib_SCbase::mergeExternalItems()
429 */
430 function insertModuleFunction($modname,$className,$classPath,$title,$MM_key='function',$WS='') {
431 global $TBE_MODULES_EXT;
432 $TBE_MODULES_EXT[$modname]['MOD_MENU'][$MM_key][$className]=array(
433 'name' => $className,
434 'path' => $classPath,
435 'title' => $title,
436 'ws' => $WS
437 );
438 }
439
440 /**
441 * Adds $content to the default Page TSconfig as set in $TYPO3_CONF_VARS[BE]['defaultPageTSconfig']
442 * Prefixed with a [GLOBAL] line
443 * FOR USE IN ext_tables.php/ext_locallang.php FILES
444 * Usage: 5
445 *
446 * @param string Page TSconfig content
447 * @return void
448 */
449 function addPageTSConfig($content) {
450 global $TYPO3_CONF_VARS;
451 $TYPO3_CONF_VARS['BE']['defaultPageTSconfig'].="\n[GLOBAL]\n".$content;
452 }
453
454 /**
455 * Adds $content to the default User TSconfig as set in $TYPO3_CONF_VARS[BE]['defaultUserTSconfig']
456 * Prefixed with a [GLOBAL] line
457 * FOR USE IN ext_tables.php/ext_locallang.php FILES
458 * Usage: 3
459 *
460 * @param string User TSconfig content
461 * @return void
462 */
463 function addUserTSConfig($content) {
464 global $TYPO3_CONF_VARS;
465 $TYPO3_CONF_VARS['BE']['defaultUserTSconfig'].="\n[GLOBAL]\n".$content;
466 }
467
468 /**
469 * Adds a reference to a locallang file with TCA_DESCR labels
470 * FOR USE IN ext_tables.php FILES
471 * eg. t3lib_extMgm::addLLrefForTCAdescr('pages','EXT:lang/locallang_csh_pages.xml'); for the pages table or t3lib_extMgm::addLLrefForTCAdescr('_MOD_web_layout','EXT:cms/locallang_csh_weblayout.php'); for the Web > Page module.
472 * Usage: 31
473 *
474 * @param string Description key. Typically a database table (like "pages") but for applications can be other strings, but prefixed with "_MOD_")
475 * @param string File reference to locallang file, eg. "EXT:lang/locallang_csh_pages.php" (or ".xml")
476 * @return void
477 */
478 function addLLrefForTCAdescr($tca_descr_key,$file_ref) {
479 global $TCA_DESCR;
480 if ($tca_descr_key) {
481 if (!is_array($TCA_DESCR[$tca_descr_key])) {
482 $TCA_DESCR[$tca_descr_key]=array();
483 }
484 if (!is_array($TCA_DESCR[$tca_descr_key]['refs'])) {
485 $TCA_DESCR[$tca_descr_key]['refs']=array();
486 }
487 $TCA_DESCR[$tca_descr_key]['refs'][]=$file_ref;
488 }
489 }
490
491
492
493
494
495
496
497
498
499
500
501
502 /**************************************
503 *
504 * Adding SERVICES features
505 *
506 * @author René Fritz <r.fritz@colorcube.de>
507 *
508 ***************************************/
509
510 /**
511 * Adds a service to the global services array
512 *
513 * @param string Extension key
514 * @param string Service type, cannot be prefixed "tx_"
515 * @param string Service key, must be prefixed "tx_" or "user_"
516 * @param array Service description array
517 * @return void
518 * @author René Fritz <r.fritz@colorcube.de>
519 */
520 function addService($extKey, $serviceType, $serviceKey, $info) {
521 global $T3_SERVICES,$TYPO3_CONF_VARS;
522
523 // even not available services will be included to make it possible to give the admin a feedback of non-available services.
524 // but maybe it's better to move non-available services to a different array??
525
526 if ($serviceType &&
527 !t3lib_div::isFirstPartOfStr($serviceType, 'tx_') &&
528 (t3lib_div::isFirstPartOfStr($serviceKey, 'tx_') || t3lib_div::isFirstPartOfStr($serviceKey, 'user_')) &&
529 is_array($info)) {
530
531 $info['priority'] = max(0,min(100,$info['priority']));
532
533 $T3_SERVICES[$serviceType][$serviceKey]=$info;
534
535 $T3_SERVICES[$serviceType][$serviceKey]['extKey'] = $extKey;
536 $T3_SERVICES[$serviceType][$serviceKey]['serviceKey'] = $serviceKey;
537 $T3_SERVICES[$serviceType][$serviceKey]['serviceType'] = $serviceType;
538
539
540 // mapping a service key to a service type
541 // all service keys begin with tx_ - service types don't
542 // this way a selection of a special service key as service type is easy
543 $T3_SERVICES[$serviceKey][$serviceKey] = &$T3_SERVICES[$serviceType][$serviceKey];
544
545
546 // change the priority (and other values) from TYPO3_CONF_VARS
547 // $TYPO3_CONF_VARS['T3_SERVICES'][$serviceType][$serviceKey]['priority']
548 // even the activation is possible (a unix service might be possible on windows for some reasons)
549 if (is_array($TYPO3_CONF_VARS['T3_SERVICES'][$serviceType][$serviceKey])) {
550
551 // no check is done here - there might be configuration values only the service type knows about, so we pass everything
552 $T3_SERVICES[$serviceType][$serviceKey] = array_merge ($T3_SERVICES[$serviceType][$serviceKey],$TYPO3_CONF_VARS['T3_SERVICES'][$serviceType][$serviceKey]);
553 }
554
555
556 // OS check
557 // empty $os means 'not limited to one OS', therefore a check is not needed
558 if ($T3_SERVICES[$serviceType][$serviceKey]['available'] && $T3_SERVICES[$serviceType][$serviceKey]['os']!='') {
559
560 // TYPO3_OS is not yet defined
561 $os_type = stristr(PHP_OS,'win')&&!stristr(PHP_OS,'darwin')?'WIN':'UNIX';
562
563 $os = t3lib_div::trimExplode(',',strtoupper($T3_SERVICES[$serviceType][$serviceKey]['os']));
564
565 if (!in_array($os_type,$os)) {
566 t3lib_extMgm::deactivateService($serviceType, $serviceKey);
567 }
568 }
569
570 // convert subtype list to array for quicker access
571 $T3_SERVICES[$serviceType][$serviceKey]['serviceSubTypes'] = array();
572 $serviceSubTypes = t3lib_div::trimExplode(',',$info['subtype']);
573 foreach ($serviceSubTypes as $subtype) {
574 $T3_SERVICES[$serviceType][$serviceKey]['serviceSubTypes'][$subtype] = $subtype;
575 }
576 }
577 }
578
579 /**
580 * Find the available service with highest priority
581 *
582 * @param string Service type
583 * @param string Service sub type
584 * @param mixed Service keys that should be excluded in the search for a service. Array or comma list.
585 * @return mixed Service info array if a service was found, FLASE otherwise
586 * @author René Fritz <r.fritz@colorcube.de>
587 */
588 function findService($serviceType, $serviceSubType='', $excludeServiceKeys=array()) {
589 global $T3_SERVICES, $T3_VAR, $TYPO3_CONF_VARS;
590
591 $serviceKey = FALSE;
592 $serviceInfo = FALSE;
593 $priority = 0;
594 $quality = 0;
595
596 if (!is_array($excludeServiceKeys) ) {
597 $excludeServiceKeys = t3lib_div::trimExplode(',', $excludeServiceKeys, 1);
598 }
599
600 if (is_array($T3_SERVICES[$serviceType])) {
601 foreach($T3_SERVICES[$serviceType] as $key => $info) {
602
603 if (in_array($key, $excludeServiceKeys)) {
604 continue;
605 }
606
607 // select a subtype randomly
608 // usefull to start a service by service key without knowing his subtypes - for testing purposes
609 if ($serviceSubType=='*') {
610 $serviceSubType = key($info['serviceSubTypes']);
611 }
612
613 // this matches empty subtype too
614 if ($info['available'] && ($info['subtype']==$serviceSubType || $info['serviceSubTypes'][$serviceSubType]) && $info['priority']>=$priority ) {
615
616 // has a lower quality than the already found, therefore we skip this service
617 if($info['priority']==$priority && $info['quality']<$quality) {
618 continue;
619 }
620
621 // service depends on external programs - check if they exists
622 if(trim($info['exec'])) {
623 require_once(PATH_t3lib.'class.t3lib_exec.php');
624
625 $executables = t3lib_div::trimExplode(',', $info['exec'],1);
626 foreach($executables as $executable) {
627 if(!t3lib_exec::checkCommand($executable)) {
628 t3lib_extMgm::deactivateService($serviceType, $key);
629 $info['available']=FALSE;
630 break;
631 }
632 }
633 }
634
635 // still available after exec check?
636 if($info['available']) {
637 $serviceKey = $key;
638 $priority = $info['priority'];
639 $quality = $info['quality'];
640 }
641 }
642 }
643 }
644
645 if ($serviceKey) {
646 $serviceInfo = $T3_SERVICES[$serviceType][$serviceKey];
647 }
648 return $serviceInfo;
649 }
650
651 /**
652 * Deactivate a service
653 *
654 * @param string Service type
655 * @param string Service key
656 * @return void
657 * @author René Fritz <r.fritz@colorcube.de>
658 */
659 function deactivateService($serviceType, $serviceKey) {
660 global $T3_SERVICES;
661
662 // ... maybe it's better to move non-available services to a different array??
663 $T3_SERVICES[$serviceType][$serviceKey]['available'] = FALSE;
664 }
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679 /**************************************
680 *
681 * Adding FRONTEND features
682 * (related specifically to "cms" extension)
683 *
684 ***************************************/
685
686 /**
687 * Adds an entry to the list of plugins in content elements of type "Insert plugin"
688 * Takes the $itemArray (label,value[,icon]) and adds to the items-array of $TCA[tt_content] elements with CType "listtype" (or another field if $type points to another fieldname)
689 * If the value (array pos. 1) is already found in that items-array, the entry is substituted, otherwise the input array is added to the bottom.
690 * Use this function to add a frontend plugin to this list of plugin-types - or more generally use this function to add an entry to any selectorbox/radio-button set in the TCEFORMS
691 * FOR USE IN ext_tables.php FILES
692 * Usage: 13
693 *
694 * @param array Item Array
695 * @param string Type (eg. "list_type") - basically a field from "tt_content" table
696 * @return void
697 */
698 function addPlugin($itemArray,$type='list_type') {
699 global $TCA;
700 t3lib_div::loadTCA('tt_content');
701 if (is_array($TCA['tt_content']['columns']) && is_array($TCA['tt_content']['columns'][$type]['config']['items'])) {
702 reset($TCA['tt_content']['columns'][$type]['config']['items']);
703 while(list($k,$v)=each($TCA['tt_content']['columns'][$type]['config']['items'])) {
704 if (!strcmp($v[1],$itemArray[1])) {
705 $TCA['tt_content']['columns'][$type]['config']['items'][$k]=$itemArray;
706 return;
707 }
708 }
709 $TCA['tt_content']['columns'][$type]['config']['items'][]=$itemArray;
710 }
711 }
712
713 /**
714 * Adds an entry to the "ds" array of the tt_content field "pi_flexform".
715 * This is used by plugins to add a flexform XML reference / content for use when they are selected as plugin or content element.
716 * Usage: 0
717 *
718 * @param string Plugin key as used in the list_type field. Use the asterisk * to match all list_type values.
719 * @param string Either a reference to a flex-form XML file (eg. "FILE:EXT:newloginbox/flexform_ds.xml") or the XML directly.
720 * @param string Value of tt_content.CType (Content Type) to match. The default is "list" which corresponds to the "Insert Plugin" content element. Use the asterisk * to match all CType values.
721 * @return void
722 * @see addPlugin()
723 */
724 function addPiFlexFormValue($piKeyToMatch, $value, $CTypeToMatch='list') {
725 global $TCA;
726 t3lib_div::loadTCA('tt_content');
727
728 if (is_array($TCA['tt_content']['columns']) && is_array($TCA['tt_content']['columns']['pi_flexform']['config']['ds'])) {
729 $TCA['tt_content']['columns']['pi_flexform']['config']['ds'][$piKeyToMatch.','.$CTypeToMatch] = $value;
730 }
731 }
732
733 /**
734 * Adds the $table tablename to the list of tables allowed to be includes by content element type "Insert records"
735 * By using $content_table and $content_field you can also use the function for other tables.
736 * FOR USE IN ext_tables.php FILES
737 * Usage: 9
738 *
739 * @param string Table name to allow for "insert record"
740 * @param string Table name TO WHICH the $table name is applied. See $content_field as well.
741 * @param string Field name in the database $content_table in which $table is allowed to be added as a reference ("Insert Record")
742 * @return void
743 */
744 function addToInsertRecords($table,$content_table='tt_content',$content_field='records') {
745 global $TCA;
746 t3lib_div::loadTCA($content_table);
747 if (is_array($TCA[$content_table]['columns']) && isset($TCA[$content_table]['columns'][$content_field]['config']['allowed'])) {
748 $TCA[$content_table]['columns'][$content_field]['config']['allowed'].=','.$table;
749 }
750 }
751
752 /**
753 * Add PlugIn to Static Template #43
754 *
755 * When adding a frontend plugin you will have to add both an entry to the TCA definition of tt_content table AND to the TypoScript template which must initiate the rendering.
756 * Since the static template with uid 43 is the "content.default" and practically always used for rendering the content elements it's very useful to have this function automatically adding the necessary TypoScript for calling your plugin. It will also work for the extension "css_styled_content"
757 * $type determines the type of frontend plugin:
758 * "list_type" (default) - the good old "Insert plugin" entry
759 * "menu_type" - a "Menu/Sitemap" entry
760 * "splash_layout" - a "Textbox" entry
761 * "CType" - a new content element type
762 * "header_layout" - an additional header type (added to the selection of layout1-5)
763 * "includeLib" - just includes the library for manual use somewhere in TypoScript.
764 * (Remember that your $type definition should correspond to the column/items array in $TCA[tt_content] where you added the selector item for the element! See addPlugin() function)
765 * FOR USE IN ext_locallang.php FILES
766 * Usage: 2
767 *
768 * @param string $key is the extension key
769 * @param string $classFile is the PHP-class filename relative to the extension root directory. If set to blank a default value is chosen according to convensions.
770 * @param string $prefix is used as a - yes, suffix - of the class name (fx. "_pi1")
771 * @param string $type, see description above
772 * @param boolean If $cached is set as USER content object (cObject) is created - otherwise a USER_INT object is created.
773 * @return void
774 */
775 function addPItoST43($key,$classFile='',$prefix='',$type='list_type',$cached=0) {
776 global $TYPO3_LOADED_EXT;
777 $classFile = $classFile ? $classFile : 'pi/class.tx_'.str_replace('_','',$key).$prefix.'.php';
778 $cN = t3lib_extMgm::getCN($key);
779
780 // General plugin:
781 if ($cached) {
782 $pluginContent = trim('
783 includeLibs.'.$cN.$prefix.' = '.$TYPO3_LOADED_EXT[$key]['siteRelPath'].$classFile.'
784 plugin.'.$cN.$prefix.' = USER
785 plugin.'.$cN.$prefix.' {
786 userFunc = '.$cN.$prefix.'->main
787 }');
788 } else {
789 $pluginContent = trim('
790 plugin.'.$cN.$prefix.' = USER_INT
791 plugin.'.$cN.$prefix.' {
792 includeLibs = '.$TYPO3_LOADED_EXT[$key]['siteRelPath'].$classFile.'
793 userFunc = '.$cN.$prefix.'->main
794 }');
795 }
796 t3lib_extMgm::addTypoScript($key,'setup','
797 # Setting '.$key.' plugin TypoScript
798 '.$pluginContent);
799
800 // After ST43:
801 switch($type) {
802 case 'list_type':
803 $addLine = 'tt_content.list.20.'.$key.$prefix.' = < plugin.'.$cN.$prefix;
804 break;
805 case 'menu_type':
806 $addLine = 'tt_content.menu.20.'.$key.$prefix.' = < plugin.'.$cN.$prefix;
807 break;
808 case 'splash_layout':
809 $addLine = 'tt_content.splash.'.$key.$prefix.' = < plugin.'.$cN.$prefix;
810 break;
811 case 'CType':
812 $addLine = trim('
813 tt_content.'.$key.$prefix.' = COA
814 tt_content.'.$key.$prefix.' {
815 10 = < lib.stdheader
816 20 = < plugin.'.$cN.$prefix.'
817 }
818 ');
819 break;
820 case 'header_layout':
821 $addLine = 'lib.stdheader.10.'.$key.$prefix.' = < plugin.'.$cN.$prefix;
822 break;
823 case 'includeLib':
824 $addLine = 'page.1000 = < plugin.'.$cN.$prefix;
825 break;
826 default:
827 $addLine = '';
828 break;
829 }
830 if ($addLine) {
831 t3lib_extMgm::addTypoScript($key,'setup','
832 # Setting '.$key.' plugin TypoScript
833 '.$addLine.'
834 ',43);
835 }
836 }
837
838 /**
839 * Call this method to add an entry in the static template list found in sys_templates
840 * "static template files" are the modern equalent (provided from extensions) to the traditional records in "static_templates"
841 * FOR USE IN ext_locallang.php FILES
842 * Usage: 3
843 *
844 * @param string $extKey is of course the extension key
845 * @param string $path is the path where the template files (fixed names) include_static.txt (integer list of uids from the table "static_templates"), constants.txt, setup.txt, editorcfg.txt, and include_static_file.txt is found (relative to extPath, eg. 'static/'). The file include_static_file.txt, allows you to include other static templates defined in files, from your static template, and thus corresponds to the field 'include_static_file' in the sys_template table. The syntax for this is a commaseperated list of static templates to include, like: EXT:css_styled_content/static/,EXT:da_newsletter_subscription/static/,EXT:cc_random_image/pi2/static/
846 * @param string $title is the title in the selector box.
847 * @return void
848 * @see addTypoScript()
849 */
850 function addStaticFile($extKey,$path,$title) {
851 global $TCA;
852 t3lib_div::loadTCA('sys_template');
853 if ($extKey && $path && is_array($TCA['sys_template']['columns'])) {
854 $value = str_replace(',','','EXT:'.$extKey.'/'.$path);
855 $itemArray=array(trim($title.' ('.$extKey.')'),$value);
856 $TCA['sys_template']['columns']['include_static_file']['config']['items'][]=$itemArray;
857 }
858 }
859
860 /**
861 * Adds $content to the default TypoScript setup code as set in $TYPO3_CONF_VARS[FE]['defaultTypoScript_setup']
862 * Prefixed with a [GLOBAL] line
863 * FOR USE IN ext_locallang.php FILES
864 * Usage: 6
865 *
866 * @param string TypoScript Setup string
867 * @return void
868 */
869 function addTypoScriptSetup($content) {
870 global $TYPO3_CONF_VARS;
871 $TYPO3_CONF_VARS['FE']['defaultTypoScript_setup'].="\n[GLOBAL]\n".$content;
872 }
873
874 /**
875 * Adds $content to the default TypoScript constants code as set in $TYPO3_CONF_VARS[FE]['defaultTypoScript_constants']
876 * Prefixed with a [GLOBAL] line
877 * FOR USE IN ext_locallang.php FILES
878 * Usage: 0
879 *
880 * @param string TypoScript Constants string
881 * @return void
882 */
883 function addTypoScriptConstants($content) {
884 global $TYPO3_CONF_VARS;
885 $TYPO3_CONF_VARS['FE']['defaultTypoScript_constants'].="\n[GLOBAL]\n".$content;
886 }
887
888 /**
889 * Adds $content to the default TypoScript code for either setup, constants or editorcfg as set in $TYPO3_CONF_VARS[FE]['defaultTypoScript_*']
890 * (Basically this function can do the same as addTypoScriptSetup and addTypoScriptConstants - just with a little more hazzle, but also with some more options!)
891 * FOR USE IN ext_locallang.php FILES
892 * Usage: 7
893 *
894 * @param string $key is the extension key (informative only).
895 * @param string $type is either "setup", "constants" or "editorcfg" and obviously determines which kind of TypoScript code we are adding.
896 * @param string $content is the TS content, prefixed with a [GLOBAL] line and a comment-header.
897 * @param string $afterStaticUid is either an integer pointing to a uid of a static_template or a string pointing to the "key" of a static_file template ([reduced extension_key]/[local path]). The points is that the TypoScript you add is included only IF that static template is included (and in that case, right after). So effectively the TypoScript you set can specifically overrule settings from those static templates.
898 * @return void
899 */
900 function addTypoScript($key,$type,$content,$afterStaticUid=0) {
901 global $TYPO3_CONF_VARS;
902
903 if ($type=='setup' || $type=='editorcfg' || $type=='constants') {
904 $content = '
905
906 [GLOBAL]
907 #############################################
908 ## TypoScript added by extension "'.$key.'"
909 #############################################
910
911 '.$content;
912 if ($afterStaticUid) {
913 $TYPO3_CONF_VARS['FE']['defaultTypoScript_'.$type.'.'][$afterStaticUid].=$content;
914 if ($afterStaticUid==43) { // If 'content (default)' is targeted, also add to other 'content rendering templates', eg. css_styled_content
915 $TYPO3_CONF_VARS['FE']['defaultTypoScript_'.$type.'.']['cssstyledcontent/static/'].=$content;
916 }
917 } else {
918 $TYPO3_CONF_VARS['FE']['defaultTypoScript_'.$type].=$content;
919 }
920 }
921 }
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940 /**************************************
941 *
942 * INTERNAL EXTENSION MANAGEMENT:
943 *
944 ***************************************/
945
946 /**
947 * Loading extensions configured in $TYPO3_CONF_VARS['EXT']['extList']
948 *
949 * CACHING ON: ($TYPO3_CONF_VARS['EXT']['extCache'] = 1 or 2)
950 * If caching is enabled (and possible), the output will be $extensions['_CACHEFILE'] set to the cacheFilePrefix. Subsequently the cache files must be included then since those will eventually set up the extensions.
951 * If cachefiles are not found they will be generated
952 * CACHING OFF: ($TYPO3_CONF_VARS['EXT']['extCache'] = 0)
953 * The returned value will be an array where each key is an extension key and the value is an array with filepaths for the extension.
954 * This array will later be set in the global var $TYPO3_LOADED_EXT
955 *
956 * Usages of this function can be seen in config_default.php
957 * Extensions are always detected in the order local - global - system.
958 * Usage: 1
959 *
960 * @return array Extension Array
961 * @internal
962 */
963 function typo3_loadExtensions() {
964 global $TYPO3_CONF_VARS;
965
966 // Full list of extensions includes both required and extList:
967 $rawExtList = $TYPO3_CONF_VARS['EXT']['requiredExt'].','.$TYPO3_CONF_VARS['EXT']['extList'];
968
969 // Empty array as a start.
970 $extensions = array();
971
972 //
973 if ($rawExtList) {
974 // The cached File prefix.
975 $cacheFilePrefix = 'temp_CACHED';
976 // Setting the name for the cache files:
977 if (intval($TYPO3_CONF_VARS['EXT']['extCache'])==1) $cacheFilePrefix.= '_ps'.substr(t3lib_div::shortMD5(PATH_site.'|'.$GLOBALS['TYPO_VERSION']),0,4);
978 if (intval($TYPO3_CONF_VARS['EXT']['extCache'])==2) $cacheFilePrefix.= '_'.t3lib_div::shortMD5($rawExtList);
979
980 // If cache files available, set cache file prefix and return:
981 if ($TYPO3_CONF_VARS['EXT']['extCache'] && t3lib_extMgm::isCacheFilesAvailable($cacheFilePrefix)) {
982 // Return cache file prefix:
983 $extensions['_CACHEFILE'] = $cacheFilePrefix;
984 } else { // ... but if not, configure...
985
986 // Prepare reserved filenames:
987 $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);
988
989 // Traverse extensions and check their existence:
990 clearstatcache(); // Clear file state cache to make sure we get good results from is_dir()
991 $temp_extensions = array_unique(t3lib_div::trimExplode(',',$rawExtList,1));
992 foreach($temp_extensions as $temp_extKey) {
993 // Check local, global and system locations:
994 if (@is_dir(PATH_typo3conf.'ext/'.$temp_extKey.'/')) {
995 $extensions[$temp_extKey] = array('type'=>'L', 'siteRelPath'=>'typo3conf/ext/'.$temp_extKey.'/', 'typo3RelPath'=>'../typo3conf/ext/'.$temp_extKey.'/');
996 } elseif (@is_dir(PATH_typo3.'ext/'.$temp_extKey.'/')) {
997 $extensions[$temp_extKey] = array('type'=>'G', 'siteRelPath'=>TYPO3_mainDir.'ext/'.$temp_extKey.'/', 'typo3RelPath'=>'ext/'.$temp_extKey.'/');
998 } elseif (@is_dir(PATH_typo3.'sysext/'.$temp_extKey.'/')) {
999 $extensions[$temp_extKey] = array('type'=>'S', 'siteRelPath'=>TYPO3_mainDir.'sysext/'.$temp_extKey.'/', 'typo3RelPath'=>'sysext/'.$temp_extKey.'/');
1000 }
1001
1002 // If extension was found, check for reserved filenames:
1003 if (isset($extensions[$temp_extKey])) {
1004 foreach($files as $fName) {
1005 $temp_filename = PATH_site.$extensions[$temp_extKey]['siteRelPath'].trim($fName);
1006 if (is_array($extensions[$temp_extKey]) && @is_file($temp_filename)) {
1007 $extensions[$temp_extKey][$fName] = $temp_filename;
1008 }
1009 }
1010 }
1011 }
1012 unset($extensions['_CACHEFILE']);
1013
1014 // write cache?
1015 if ($TYPO3_CONF_VARS['EXT']['extCache'] &&
1016 @is_dir(PATH_typo3.'sysext/') &&
1017 @is_dir(PATH_typo3.'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!
1018 $wrError = t3lib_extMgm::cannotCacheFilesWritable($cacheFilePrefix);
1019 if ($wrError) {
1020 $TYPO3_CONF_VARS['EXT']['extCache']=0;
1021 } else {
1022 // Write cache files:
1023 $extensions = t3lib_extMgm::writeCacheFiles($extensions,$cacheFilePrefix);
1024 }
1025 }
1026 }
1027 }
1028
1029 return $extensions;
1030 }
1031
1032 /**
1033 * Returns the section headers for the compiled cache-files.
1034 *
1035 * @param string $key is the extension key
1036 * @param string $file is the filename (only informative for comment)
1037 * @return string
1038 * @internal
1039 */
1040 function _makeIncludeHeader($key,$file) {
1041 return '<?php
1042 ###########################
1043 ## EXTENSION: '.$key.'
1044 ## FILE: '.$file.'
1045 ###########################
1046
1047 $_EXTKEY = \''.$key.'\';
1048 $_EXTCONF = $TYPO3_CONF_VARS[\'EXT\'][\'extConf\'][$_EXTKEY];
1049
1050 ?>';
1051 }
1052
1053 /**
1054 * Returns true if both the localconf and tables cache file exists (with $cacheFilePrefix)
1055 * Usage: 2
1056 *
1057 * @param string Prefix of the cache file to check
1058 * @return boolean
1059 * @internal
1060 */
1061 function isCacheFilesAvailable($cacheFilePrefix) {
1062 return
1063 @is_file(PATH_typo3conf.$cacheFilePrefix.'_ext_localconf.php') &&
1064 @is_file(PATH_typo3conf.$cacheFilePrefix.'_ext_tables.php');
1065 }
1066
1067 /**
1068 * Returns true if the "localconf.php" file in "typo3conf/" is writable
1069 * Usage: 1
1070 *
1071 * @return boolean
1072 * @internal
1073 */
1074 function isLocalconfWritable() {
1075 return @is_writable(PATH_typo3conf) && @is_writable(PATH_typo3conf.'localconf.php');
1076 }
1077
1078 /**
1079 * Returns an error string if typo3conf/ or cache-files with $cacheFilePrefix are NOT writable
1080 * Returns false if no problem.
1081 * Usage: 1
1082 *
1083 * @param string Prefix of the cache file to check
1084 * @return string
1085 * @internal
1086 */
1087 function cannotCacheFilesWritable($cacheFilePrefix) {
1088 $error=array();
1089 if (!@is_writable(PATH_typo3conf)) {
1090 $error[]=PATH_typo3conf;
1091 }
1092 if (@is_file(PATH_typo3conf.$cacheFilePrefix.'_ext_localconf.php') &&
1093 !@is_writable(PATH_typo3conf.$cacheFilePrefix.'_ext_localconf.php')) {
1094 $error[]=PATH_typo3conf.$cacheFilePrefix.'_ext_localconf.php';
1095 }
1096 if (@is_file(PATH_typo3conf.$cacheFilePrefix.'_ext_tables.php') &&
1097 !@is_writable(PATH_typo3conf.$cacheFilePrefix.'_ext_tables.php')) {
1098 $error[]=PATH_typo3conf.$cacheFilePrefix.'_ext_tables.php';
1099 }
1100 return implode(', ',$error);
1101 }
1102
1103 /**
1104 * Returns an array with the two cache-files (0=>localconf, 1=>tables) from typo3conf/ if they (both) exist. Otherwise false.
1105 * Evaluation relies on $TYPO3_LOADED_EXT['_CACHEFILE']
1106 * Usage: 2
1107 *
1108 * @return array
1109 * @internal
1110 */
1111 function currentCacheFiles() {
1112 global $TYPO3_LOADED_EXT;
1113
1114 if ($TYPO3_LOADED_EXT['_CACHEFILE']) {
1115 if (t3lib_extMgm::isCacheFilesAvailable($TYPO3_LOADED_EXT['_CACHEFILE'])) {
1116 return array(
1117 PATH_typo3conf.$TYPO3_LOADED_EXT['_CACHEFILE'].'_ext_localconf.php',
1118 PATH_typo3conf.$TYPO3_LOADED_EXT['_CACHEFILE'].'_ext_tables.php'
1119 );
1120 }
1121 }
1122 }
1123
1124 /**
1125 * Compiles/Creates the two cache-files in typo3conf/ based on $cacheFilePrefix
1126 * Returns a array with the key "_CACHEFILE" set to the $cacheFilePrefix value
1127 * Usage: 1
1128 *
1129 * @param array Extension information array
1130 * @param string Prefix for the cache files
1131 * @return array
1132 * @internal
1133 */
1134 function writeCacheFiles($extensions,$cacheFilePrefix) {
1135 // Making cache files:
1136 $extensions['_CACHEFILE'] = $cacheFilePrefix;
1137 $cFiles=array();
1138 $cFiles['ext_localconf'].='<?php
1139
1140 $TYPO3_LOADED_EXT = unserialize(stripslashes(\''.addslashes(serialize($extensions)).'\'));
1141
1142 ?>';
1143
1144 reset($extensions);
1145 while(list($key,$conf)=each($extensions)) {
1146 if (is_array($conf)) {
1147 if ($conf['ext_localconf.php']) {
1148 $cFiles['ext_localconf'].=t3lib_extMgm::_makeIncludeHeader($key,$conf['ext_localconf.php']);
1149 $cFiles['ext_localconf'].=trim(t3lib_div::getUrl($conf['ext_localconf.php']));
1150 }
1151 if ($conf['ext_tables.php']) {
1152 $cFiles['ext_tables'].=t3lib_extMgm::_makeIncludeHeader($key,$conf['ext_tables.php']);
1153 $cFiles['ext_tables'].=trim(t3lib_div::getUrl($conf['ext_tables.php']));
1154 }
1155 }
1156 }
1157
1158 t3lib_div::writeFile(PATH_typo3conf.$cacheFilePrefix.'_ext_localconf.php',$cFiles['ext_localconf']);
1159 t3lib_div::writeFile(PATH_typo3conf.$cacheFilePrefix.'_ext_tables.php',$cFiles['ext_tables']);
1160
1161 $extensions=array();
1162 $extensions['_CACHEFILE'] = $cacheFilePrefix;
1163
1164 return $extensions;
1165 }
1166
1167 /**
1168 * Unlink (delete) cache files
1169 *
1170 * @return integer Number of deleted files.
1171 */
1172 function removeCacheFiles() {
1173 $cacheFiles = t3lib_extMgm::currentCacheFiles();
1174 $out = 0;
1175 if (is_array($cacheFiles)) {
1176 reset($cacheFiles);
1177 foreach($cacheFiles as $cfile) {
1178 @unlink($cfile);
1179 clearstatcache();
1180 $out++;
1181 }
1182 }
1183 return $out;
1184 }
1185 }
1186
1187 ?>