make t3lib_svbase abstract and remove unused references to T3_VAR
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_extmgm.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2008 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 final 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 public static 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 public static 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 public static 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 public static 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 public static 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 public static 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 public static 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 public static 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 public static 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 public static function addModulePath($name, $path) {
391 global $TBE_MODULES;
392
393 $TBE_MODULES['_PATHS'][$name] = $path;
394 }
395
396 /**
397 * Adds a "Function menu module" ('third level module') to an existing function menu for some other backend module
398 * The arguments values are generally determined by which function menu this is supposed to interact with
399 * See Inside TYPO3 for information on how to use this function.
400 * FOR USE IN ext_tables.php FILES
401 * Usage: 26
402 *
403 * @param string Module name
404 * @param string Class name
405 * @param string Class path
406 * @param string Title of module
407 * @param string Menu array key - default is "function"
408 * @param string Workspace conditions. Blank means all workspaces, any other string can be a comma list of "online", "offline" and "custom"
409 * @return void
410 * @see t3lib_SCbase::mergeExternalItems()
411 */
412 public static function insertModuleFunction($modname, $className, $classPath, $title, $MM_key = 'function', $WS = '') {
413 global $TBE_MODULES_EXT;
414 $TBE_MODULES_EXT[$modname]['MOD_MENU'][$MM_key][$className] = array(
415 'name' => $className,
416 'path' => $classPath,
417 'title' => $title,
418 'ws' => $WS
419 );
420 }
421
422 /**
423 * Adds $content to the default Page TSconfig as set in $TYPO3_CONF_VARS[BE]['defaultPageTSconfig']
424 * Prefixed with a [GLOBAL] line
425 * FOR USE IN ext_tables.php/ext_locallang.php FILES
426 * Usage: 5
427 *
428 * @param string Page TSconfig content
429 * @return void
430 */
431 public static function addPageTSConfig($content) {
432 global $TYPO3_CONF_VARS;
433 $TYPO3_CONF_VARS['BE']['defaultPageTSconfig'].="\n[GLOBAL]\n".$content;
434 }
435
436 /**
437 * Adds $content to the default User TSconfig as set in $TYPO3_CONF_VARS[BE]['defaultUserTSconfig']
438 * Prefixed with a [GLOBAL] line
439 * FOR USE IN ext_tables.php/ext_locallang.php FILES
440 * Usage: 3
441 *
442 * @param string User TSconfig content
443 * @return void
444 */
445 public static function addUserTSConfig($content) {
446 global $TYPO3_CONF_VARS;
447 $TYPO3_CONF_VARS['BE']['defaultUserTSconfig'].="\n[GLOBAL]\n".$content;
448 }
449
450 /**
451 * Adds a reference to a locallang file with TCA_DESCR labels
452 * FOR USE IN ext_tables.php FILES
453 * 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.
454 * Usage: 31
455 *
456 * @param string Description key. Typically a database table (like "pages") but for applications can be other strings, but prefixed with "_MOD_")
457 * @param string File reference to locallang file, eg. "EXT:lang/locallang_csh_pages.php" (or ".xml")
458 * @return void
459 */
460 public static function addLLrefForTCAdescr($tca_descr_key, $file_ref) {
461 global $TCA_DESCR;
462 if ($tca_descr_key) {
463 if (!is_array($TCA_DESCR[$tca_descr_key])) {
464 $TCA_DESCR[$tca_descr_key] = array();
465 }
466 if (!is_array($TCA_DESCR[$tca_descr_key]['refs'])) {
467 $TCA_DESCR[$tca_descr_key]['refs'] = array();
468 }
469 $TCA_DESCR[$tca_descr_key]['refs'][] = $file_ref;
470 }
471 }
472
473
474
475
476
477
478
479
480
481
482
483
484 /**************************************
485 *
486 * Adding SERVICES features
487 *
488 * @author Ren� Fritz <r.fritz@colorcube.de>
489 *
490 ***************************************/
491
492 /**
493 * Adds a service to the global services array
494 *
495 * @param string Extension key
496 * @param string Service type, cannot be prefixed "tx_"
497 * @param string Service key, must be prefixed "tx_" or "user_"
498 * @param array Service description array
499 * @return void
500 * @author Ren� Fritz <r.fritz@colorcube.de>
501 */
502 public static function addService($extKey, $serviceType, $serviceKey, $info) {
503 global $T3_SERVICES, $TYPO3_CONF_VARS;
504
505 // even not available services will be included to make it possible to give the admin a feedback of non-available services.
506 // but maybe it's better to move non-available services to a different array??
507
508 if ($serviceType &&
509 !t3lib_div::isFirstPartOfStr($serviceType, 'tx_') &&
510 (t3lib_div::isFirstPartOfStr($serviceKey, 'tx_') || t3lib_div::isFirstPartOfStr($serviceKey, 'user_')) &&
511 is_array($info)) {
512
513 $info['priority'] = max(0, min(100, $info['priority']));
514
515 $T3_SERVICES[$serviceType][$serviceKey] = $info;
516
517 $T3_SERVICES[$serviceType][$serviceKey]['extKey'] = $extKey;
518 $T3_SERVICES[$serviceType][$serviceKey]['serviceKey'] = $serviceKey;
519 $T3_SERVICES[$serviceType][$serviceKey]['serviceType'] = $serviceType;
520
521
522 // mapping a service key to a service type
523 // all service keys begin with tx_ - service types don't
524 // this way a selection of a special service key as service type is easy
525 $T3_SERVICES[$serviceKey][$serviceKey] = &$T3_SERVICES[$serviceType][$serviceKey];
526
527
528 // change the priority (and other values) from TYPO3_CONF_VARS
529 // $TYPO3_CONF_VARS['T3_SERVICES'][$serviceType][$serviceKey]['priority']
530 // even the activation is possible (a unix service might be possible on windows for some reasons)
531 if (is_array($TYPO3_CONF_VARS['T3_SERVICES'][$serviceType][$serviceKey])) {
532
533 // no check is done here - there might be configuration values only the service type knows about, so we pass everything
534 $T3_SERVICES[$serviceType][$serviceKey] = array_merge ($T3_SERVICES[$serviceType][$serviceKey], $TYPO3_CONF_VARS['T3_SERVICES'][$serviceType][$serviceKey]);
535 }
536
537
538 // OS check
539 // empty $os means 'not limited to one OS', therefore a check is not needed
540 if ($T3_SERVICES[$serviceType][$serviceKey]['available'] && $T3_SERVICES[$serviceType][$serviceKey]['os']!='') {
541
542 // TYPO3_OS is not yet defined
543 $os_type = stristr(PHP_OS, 'win')&&!stristr(PHP_OS, 'darwin')?'WIN':'UNIX';
544
545 $os = t3lib_div::trimExplode(',', strtoupper($T3_SERVICES[$serviceType][$serviceKey]['os']));
546
547 if (!in_array($os_type, $os)) {
548 t3lib_extMgm::deactivateService($serviceType, $serviceKey);
549 }
550 }
551
552 // convert subtype list to array for quicker access
553 $T3_SERVICES[$serviceType][$serviceKey]['serviceSubTypes'] = array();
554 $serviceSubTypes = t3lib_div::trimExplode(',', $info['subtype']);
555 foreach ($serviceSubTypes as $subtype) {
556 $T3_SERVICES[$serviceType][$serviceKey]['serviceSubTypes'][$subtype] = $subtype;
557 }
558 }
559 }
560
561 /**
562 * Find the available service with highest priority
563 *
564 * @param string Service type
565 * @param string Service sub type
566 * @param mixed Service keys that should be excluded in the search for a service. Array or comma list.
567 * @return mixed Service info array if a service was found, FLASE otherwise
568 * @author Ren� Fritz <r.fritz@colorcube.de>
569 */
570 public static function findService($serviceType, $serviceSubType = '', $excludeServiceKeys = array()) {
571 global $T3_SERVICES, $TYPO3_CONF_VARS;
572
573 $serviceKey = FALSE;
574 $serviceInfo = FALSE;
575 $priority = 0;
576 $quality = 0;
577
578 if (!is_array($excludeServiceKeys) ) {
579 $excludeServiceKeys = t3lib_div::trimExplode(',', $excludeServiceKeys, 1);
580 }
581
582 if (is_array($T3_SERVICES[$serviceType])) {
583 foreach($T3_SERVICES[$serviceType] as $key => $info) {
584
585 if (in_array($key, $excludeServiceKeys)) {
586 continue;
587 }
588
589 // select a subtype randomly
590 // usefull to start a service by service key without knowing his subtypes - for testing purposes
591 if ($serviceSubType=='*') {
592 $serviceSubType = key($info['serviceSubTypes']);
593 }
594
595 // this matches empty subtype too
596 if ($info['available'] && ($info['subtype']==$serviceSubType || $info['serviceSubTypes'][$serviceSubType]) && $info['priority']>=$priority ) {
597
598 // has a lower quality than the already found, therefore we skip this service
599 if($info['priority']==$priority && $info['quality']<$quality) {
600 continue;
601 }
602
603 // service depends on external programs - check if they exists
604 if(trim($info['exec'])) {
605 require_once(PATH_t3lib.'class.t3lib_exec.php');
606
607 $executables = t3lib_div::trimExplode(',', $info['exec'], 1);
608 foreach($executables as $executable) {
609 if(!t3lib_exec::checkCommand($executable)) {
610 t3lib_extMgm::deactivateService($serviceType, $key);
611 $info['available'] = FALSE;
612 break;
613 }
614 }
615 }
616
617 // still available after exec check?
618 if($info['available']) {
619 $serviceKey = $key;
620 $priority = $info['priority'];
621 $quality = $info['quality'];
622 }
623 }
624 }
625 }
626
627 if ($serviceKey) {
628 $serviceInfo = $T3_SERVICES[$serviceType][$serviceKey];
629 }
630 return $serviceInfo;
631 }
632
633 /**
634 * Deactivate a service
635 *
636 * @param string Service type
637 * @param string Service key
638 * @return void
639 * @author Ren� Fritz <r.fritz@colorcube.de>
640 */
641 public static function deactivateService($serviceType, $serviceKey) {
642 global $T3_SERVICES;
643
644 // ... maybe it's better to move non-available services to a different array??
645 $T3_SERVICES[$serviceType][$serviceKey]['available'] = FALSE;
646 }
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661 /**************************************
662 *
663 * Adding FRONTEND features
664 * (related specifically to "cms" extension)
665 *
666 ***************************************/
667
668 /**
669 * Adds an entry to the list of plugins in content elements of type "Insert plugin"
670 * 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)
671 * 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.
672 * 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
673 * FOR USE IN ext_tables.php FILES
674 * Usage: 13
675 *
676 * @param array Item Array
677 * @param string Type (eg. "list_type") - basically a field from "tt_content" table
678 * @return void
679 */
680 public static function addPlugin($itemArray, $type = 'list_type') {
681 global $TCA;
682
683 $_EXTKEY = $GLOBALS['_EXTKEY'];
684 if ($_EXTKEY && !$itemArray[2]) {
685 $itemArray[2] = t3lib_extMgm::extRelPath($_EXTKEY) . 'ext_icon.gif';
686 }
687
688 t3lib_div::loadTCA('tt_content');
689 if (is_array($TCA['tt_content']['columns']) && is_array($TCA['tt_content']['columns'][$type]['config']['items'])) {
690 reset($TCA['tt_content']['columns'][$type]['config']['items']);
691 while(list($k, $v) = each($TCA['tt_content']['columns'][$type]['config']['items'])) {
692 if (!strcmp($v[1], $itemArray[1])) {
693 $TCA['tt_content']['columns'][$type]['config']['items'][$k] = $itemArray;
694 return;
695 }
696 }
697 $TCA['tt_content']['columns'][$type]['config']['items'][] = $itemArray;
698 }
699 }
700
701 /**
702 * Adds an entry to the "ds" array of the tt_content field "pi_flexform".
703 * This is used by plugins to add a flexform XML reference / content for use when they are selected as plugin or content element.
704 * Usage: 0
705 *
706 * @param string Plugin key as used in the list_type field. Use the asterisk * to match all list_type values.
707 * @param string Either a reference to a flex-form XML file (eg. "FILE:EXT:newloginbox/flexform_ds.xml") or the XML directly.
708 * @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.
709 * @return void
710 * @see addPlugin()
711 */
712 public static function addPiFlexFormValue($piKeyToMatch, $value, $CTypeToMatch = 'list') {
713 global $TCA;
714 t3lib_div::loadTCA('tt_content');
715
716 if (is_array($TCA['tt_content']['columns']) && is_array($TCA['tt_content']['columns']['pi_flexform']['config']['ds'])) {
717 $TCA['tt_content']['columns']['pi_flexform']['config']['ds'][$piKeyToMatch.','.$CTypeToMatch] = $value;
718 }
719 }
720
721 /**
722 * Adds the $table tablename to the list of tables allowed to be includes by content element type "Insert records"
723 * By using $content_table and $content_field you can also use the function for other tables.
724 * FOR USE IN ext_tables.php FILES
725 * Usage: 9
726 *
727 * @param string Table name to allow for "insert record"
728 * @param string Table name TO WHICH the $table name is applied. See $content_field as well.
729 * @param string Field name in the database $content_table in which $table is allowed to be added as a reference ("Insert Record")
730 * @return void
731 */
732 public static function addToInsertRecords($table, $content_table = 'tt_content', $content_field = 'records') {
733 global $TCA;
734 t3lib_div::loadTCA($content_table);
735 if (is_array($TCA[$content_table]['columns']) && isset($TCA[$content_table]['columns'][$content_field]['config']['allowed'])) {
736 $TCA[$content_table]['columns'][$content_field]['config']['allowed'].=','.$table;
737 }
738 }
739
740 /**
741 * Add PlugIn to Static Template #43
742 *
743 * 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.
744 * 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"
745 * $type determines the type of frontend plugin:
746 * "list_type" (default) - the good old "Insert plugin" entry
747 * "menu_type" - a "Menu/Sitemap" entry
748 * "splash_layout" - a "Textbox" entry
749 * "CType" - a new content element type
750 * "header_layout" - an additional header type (added to the selection of layout1-5)
751 * "includeLib" - just includes the library for manual use somewhere in TypoScript.
752 * (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)
753 * FOR USE IN ext_locallang.php FILES
754 * Usage: 2
755 *
756 * @param string $key is the extension key
757 * @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.
758 * @param string $prefix is used as a - yes, suffix - of the class name (fx. "_pi1")
759 * @param string $type, see description above
760 * @param boolean If $cached is set as USER content object (cObject) is created - otherwise a USER_INT object is created.
761 * @return void
762 */
763 public static function addPItoST43($key, $classFile = '', $prefix = '', $type = 'list_type', $cached = 0) {
764 global $TYPO3_LOADED_EXT;
765 $classFile = $classFile ? $classFile : 'pi/class.tx_'.str_replace('_', '', $key).$prefix.'.php';
766 $cN = t3lib_extMgm::getCN($key);
767
768 // General plugin:
769 if ($cached) {
770 $pluginContent = trim('
771 includeLibs.'.$cN.$prefix.' = '.$TYPO3_LOADED_EXT[$key]['siteRelPath'].$classFile.'
772 plugin.'.$cN.$prefix.' = USER
773 plugin.'.$cN.$prefix.' {
774 userFunc = '.$cN.$prefix.'->main
775 }');
776 } else {
777 $pluginContent = trim('
778 plugin.'.$cN.$prefix.' = USER_INT
779 plugin.'.$cN.$prefix.' {
780 includeLibs = '.$TYPO3_LOADED_EXT[$key]['siteRelPath'].$classFile.'
781 userFunc = '.$cN.$prefix.'->main
782 }');
783 }
784 t3lib_extMgm::addTypoScript($key, 'setup', '
785 # Setting '.$key.' plugin TypoScript
786 '.$pluginContent);
787
788 // After ST43:
789 switch($type) {
790 case 'list_type':
791 $addLine = 'tt_content.list.20.'.$key.$prefix.' = < plugin.'.$cN.$prefix;
792 break;
793 case 'menu_type':
794 $addLine = 'tt_content.menu.20.'.$key.$prefix.' = < plugin.'.$cN.$prefix;
795 break;
796 case 'splash_layout':
797 $addLine = 'tt_content.splash.'.$key.$prefix.' = < plugin.'.$cN.$prefix;
798 break;
799 case 'CType':
800 $addLine = trim('
801 tt_content.'.$key.$prefix.' = COA
802 tt_content.'.$key.$prefix.' {
803 10 = < lib.stdheader
804 20 = < plugin.'.$cN.$prefix.'
805 }
806 ');
807 break;
808 case 'header_layout':
809 $addLine = 'lib.stdheader.10.'.$key.$prefix.' = < plugin.'.$cN.$prefix;
810 break;
811 case 'includeLib':
812 $addLine = 'page.1000 = < plugin.'.$cN.$prefix;
813 break;
814 default:
815 $addLine = '';
816 break;
817 }
818 if ($addLine) {
819 t3lib_extMgm::addTypoScript($key, 'setup', '
820 # Setting '.$key.' plugin TypoScript
821 '.$addLine.'
822 ', 43);
823 }
824 }
825
826 /**
827 * Call this method to add an entry in the static template list found in sys_templates
828 * "static template files" are the modern equalent (provided from extensions) to the traditional records in "static_templates"
829 * FOR USE IN ext_locallang.php FILES
830 * Usage: 3
831 *
832 * @param string $extKey is of course the extension key
833 * @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/
834 * @param string $title is the title in the selector box.
835 * @return void
836 * @see addTypoScript()
837 */
838 public static function addStaticFile($extKey, $path, $title) {
839 global $TCA;
840 t3lib_div::loadTCA('sys_template');
841 if ($extKey && $path && is_array($TCA['sys_template']['columns'])) {
842 $value = str_replace(',', '', 'EXT:'.$extKey.'/'.$path);
843 $itemArray = array(trim($title.' ('.$extKey.')'), $value);
844 $TCA['sys_template']['columns']['include_static_file']['config']['items'][] = $itemArray;
845 }
846 }
847
848 /**
849 * Adds $content to the default TypoScript setup code as set in $TYPO3_CONF_VARS[FE]['defaultTypoScript_setup']
850 * Prefixed with a [GLOBAL] line
851 * FOR USE IN ext_locallang.php FILES
852 * Usage: 6
853 *
854 * @param string TypoScript Setup string
855 * @return void
856 */
857 public static function addTypoScriptSetup($content) {
858 global $TYPO3_CONF_VARS;
859 $TYPO3_CONF_VARS['FE']['defaultTypoScript_setup'].="\n[GLOBAL]\n".$content;
860 }
861
862 /**
863 * Adds $content to the default TypoScript constants code as set in $TYPO3_CONF_VARS[FE]['defaultTypoScript_constants']
864 * Prefixed with a [GLOBAL] line
865 * FOR USE IN ext_locallang.php FILES
866 * Usage: 0
867 *
868 * @param string TypoScript Constants string
869 * @return void
870 */
871 public static function addTypoScriptConstants($content) {
872 global $TYPO3_CONF_VARS;
873 $TYPO3_CONF_VARS['FE']['defaultTypoScript_constants'].="\n[GLOBAL]\n".$content;
874 }
875
876 /**
877 * Adds $content to the default TypoScript code for either setup, constants or editorcfg as set in $TYPO3_CONF_VARS[FE]['defaultTypoScript_*']
878 * (Basically this function can do the same as addTypoScriptSetup and addTypoScriptConstants - just with a little more hazzle, but also with some more options!)
879 * FOR USE IN ext_locallang.php FILES
880 * Usage: 7
881 *
882 * @param string $key is the extension key (informative only).
883 * @param string $type is either "setup", "constants" or "editorcfg" and obviously determines which kind of TypoScript code we are adding.
884 * @param string $content is the TS content, prefixed with a [GLOBAL] line and a comment-header.
885 * @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.
886 * @return void
887 */
888 public static function addTypoScript($key, $type, $content, $afterStaticUid = 0) {
889 global $TYPO3_CONF_VARS;
890
891 if ($type=='setup' || $type=='editorcfg' || $type=='constants') {
892 $content = '
893
894 [GLOBAL]
895 #############################################
896 ## TypoScript added by extension "'.$key.'"
897 #############################################
898
899 '.$content;
900 if ($afterStaticUid) {
901 $TYPO3_CONF_VARS['FE']['defaultTypoScript_'.$type.'.'][$afterStaticUid].=$content;
902 if ($afterStaticUid==43) { // If 'content (default)' is targeted, also add to other 'content rendering templates', eg. css_styled_content
903 $TYPO3_CONF_VARS['FE']['defaultTypoScript_'.$type.'.']['cssstyledcontent/static/'].=$content;
904 }
905 } else {
906 $TYPO3_CONF_VARS['FE']['defaultTypoScript_'.$type].=$content;
907 }
908 }
909 }
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928 /**************************************
929 *
930 * INTERNAL EXTENSION MANAGEMENT:
931 *
932 ***************************************/
933
934 /**
935 * Loading extensions configured in $TYPO3_CONF_VARS['EXT']['extList']
936 *
937 * CACHING ON: ($TYPO3_CONF_VARS['EXT']['extCache'] = 1 or 2)
938 * 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.
939 * If cachefiles are not found they will be generated
940 * CACHING OFF: ($TYPO3_CONF_VARS['EXT']['extCache'] = 0)
941 * 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.
942 * This array will later be set in the global var $TYPO3_LOADED_EXT
943 *
944 * Usages of this function can be seen in config_default.php
945 * Extensions are always detected in the order local - global - system.
946 * Usage: 1
947 *
948 * @return array Extension Array
949 * @internal
950 */
951 public static function typo3_loadExtensions() {
952 global $TYPO3_CONF_VARS;
953
954 // Full list of extensions includes both required and extList:
955 $rawExtList = $TYPO3_CONF_VARS['EXT']['requiredExt'].','.$TYPO3_CONF_VARS['EXT']['extList'];
956
957 // Empty array as a start.
958 $extensions = array();
959
960 //
961 if ($rawExtList) {
962 // The cached File prefix.
963 $cacheFilePrefix = 'temp_CACHED';
964 // Setting the name for the cache files:
965 if (intval($TYPO3_CONF_VARS['EXT']['extCache'])==1) $cacheFilePrefix.= '_ps'.substr(t3lib_div::shortMD5(PATH_site.'|'.$GLOBALS['TYPO_VERSION']), 0, 4);
966 if (intval($TYPO3_CONF_VARS['EXT']['extCache'])==2) $cacheFilePrefix.= '_'.t3lib_div::shortMD5($rawExtList);
967
968 // If cache files available, set cache file prefix and return:
969 if ($TYPO3_CONF_VARS['EXT']['extCache'] && t3lib_extMgm::isCacheFilesAvailable($cacheFilePrefix)) {
970 // Return cache file prefix:
971 $extensions['_CACHEFILE'] = $cacheFilePrefix;
972 } else { // ... but if not, configure...
973
974 // Prepare reserved filenames:
975 $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);
976
977 // Traverse extensions and check their existence:
978 clearstatcache(); // Clear file state cache to make sure we get good results from is_dir()
979 $temp_extensions = array_unique(t3lib_div::trimExplode(',', $rawExtList, 1));
980 foreach($temp_extensions as $temp_extKey) {
981 // Check local, global and system locations:
982 if (@is_dir(PATH_typo3conf.'ext/'.$temp_extKey.'/')) {
983 $extensions[$temp_extKey] = array('type'=>'L', 'siteRelPath'=>'typo3conf/ext/'.$temp_extKey.'/', 'typo3RelPath'=>'../typo3conf/ext/'.$temp_extKey.'/');
984 } elseif (@is_dir(PATH_typo3.'ext/'.$temp_extKey.'/')) {
985 $extensions[$temp_extKey] = array('type'=>'G', 'siteRelPath'=>TYPO3_mainDir.'ext/'.$temp_extKey.'/', 'typo3RelPath'=>'ext/'.$temp_extKey.'/');
986 } elseif (@is_dir(PATH_typo3.'sysext/'.$temp_extKey.'/')) {
987 $extensions[$temp_extKey] = array('type'=>'S', 'siteRelPath'=>TYPO3_mainDir.'sysext/'.$temp_extKey.'/', 'typo3RelPath'=>'sysext/'.$temp_extKey.'/');
988 }
989
990 // If extension was found, check for reserved filenames:
991 if (isset($extensions[$temp_extKey])) {
992 foreach($files as $fName) {
993 $temp_filename = PATH_site.$extensions[$temp_extKey]['siteRelPath'].trim($fName);
994 if (is_array($extensions[$temp_extKey]) && @is_file($temp_filename)) {
995 $extensions[$temp_extKey][$fName] = $temp_filename;
996 }
997 }
998 }
999 }
1000 unset($extensions['_CACHEFILE']);
1001
1002 // write cache?
1003 if ($TYPO3_CONF_VARS['EXT']['extCache'] &&
1004 @is_dir(PATH_typo3.'sysext/') &&
1005 @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!
1006 $wrError = t3lib_extMgm::cannotCacheFilesWritable($cacheFilePrefix);
1007 if ($wrError) {
1008 $TYPO3_CONF_VARS['EXT']['extCache'] = 0;
1009 } else {
1010 // Write cache files:
1011 $extensions = t3lib_extMgm::writeCacheFiles($extensions, $cacheFilePrefix);
1012 }
1013 }
1014 }
1015 }
1016
1017 return $extensions;
1018 }
1019
1020 /**
1021 * Returns the section headers for the compiled cache-files.
1022 *
1023 * @param string $key is the extension key
1024 * @param string $file is the filename (only informative for comment)
1025 * @return string
1026 * @internal
1027 */
1028 public static function _makeIncludeHeader($key, $file) {
1029 return '<?php
1030 ###########################
1031 ## EXTENSION: '.$key.'
1032 ## FILE: '.$file.'
1033 ###########################
1034
1035 $_EXTKEY = \''.$key.'\';
1036 $_EXTCONF = $TYPO3_CONF_VARS[\'EXT\'][\'extConf\'][$_EXTKEY];
1037
1038 ?>';
1039 }
1040
1041 /**
1042 * Returns true if both the localconf and tables cache file exists (with $cacheFilePrefix)
1043 * Usage: 2
1044 *
1045 * @param string Prefix of the cache file to check
1046 * @return boolean
1047 * @internal
1048 */
1049 public static function isCacheFilesAvailable($cacheFilePrefix) {
1050 return
1051 @is_file(PATH_typo3conf.$cacheFilePrefix.'_ext_localconf.php') &&
1052 @is_file(PATH_typo3conf.$cacheFilePrefix.'_ext_tables.php');
1053 }
1054
1055 /**
1056 * Returns true if the "localconf.php" file in "typo3conf/" is writable
1057 * Usage: 1
1058 *
1059 * @return boolean
1060 * @internal
1061 */
1062 public static function isLocalconfWritable() {
1063 return @is_writable(PATH_typo3conf) && @is_writable(PATH_typo3conf.'localconf.php');
1064 }
1065
1066 /**
1067 * Returns an error string if typo3conf/ or cache-files with $cacheFilePrefix are NOT writable
1068 * Returns false if no problem.
1069 * Usage: 1
1070 *
1071 * @param string Prefix of the cache file to check
1072 * @return string
1073 * @internal
1074 */
1075 public static function cannotCacheFilesWritable($cacheFilePrefix) {
1076 $error = array();
1077 if (!@is_writable(PATH_typo3conf)) {
1078 $error[] = PATH_typo3conf;
1079 }
1080 if (@is_file(PATH_typo3conf.$cacheFilePrefix.'_ext_localconf.php') &&
1081 !@is_writable(PATH_typo3conf.$cacheFilePrefix.'_ext_localconf.php')) {
1082 $error[] = PATH_typo3conf.$cacheFilePrefix.'_ext_localconf.php';
1083 }
1084 if (@is_file(PATH_typo3conf.$cacheFilePrefix.'_ext_tables.php') &&
1085 !@is_writable(PATH_typo3conf.$cacheFilePrefix.'_ext_tables.php')) {
1086 $error[] = PATH_typo3conf.$cacheFilePrefix.'_ext_tables.php';
1087 }
1088 return implode(', ', $error);
1089 }
1090
1091 /**
1092 * Returns an array with the two cache-files (0=>localconf, 1=>tables) from typo3conf/ if they (both) exist. Otherwise false.
1093 * Evaluation relies on $TYPO3_LOADED_EXT['_CACHEFILE']
1094 * Usage: 2
1095 *
1096 * @return array
1097 * @internal
1098 */
1099 public static function currentCacheFiles() {
1100 global $TYPO3_LOADED_EXT;
1101
1102 if ($TYPO3_LOADED_EXT['_CACHEFILE']) {
1103 if (t3lib_extMgm::isCacheFilesAvailable($TYPO3_LOADED_EXT['_CACHEFILE'])) {
1104 return array(
1105 PATH_typo3conf.$TYPO3_LOADED_EXT['_CACHEFILE'].'_ext_localconf.php',
1106 PATH_typo3conf.$TYPO3_LOADED_EXT['_CACHEFILE'].'_ext_tables.php'
1107 );
1108 }
1109 }
1110 }
1111
1112 /**
1113 * Compiles/Creates the two cache-files in typo3conf/ based on $cacheFilePrefix
1114 * Returns a array with the key "_CACHEFILE" set to the $cacheFilePrefix value
1115 * Usage: 1
1116 *
1117 * @param array Extension information array
1118 * @param string Prefix for the cache files
1119 * @return array
1120 * @internal
1121 */
1122 public static function writeCacheFiles($extensions, $cacheFilePrefix) {
1123 // Making cache files:
1124 $extensions['_CACHEFILE'] = $cacheFilePrefix;
1125 $cFiles = array();
1126 $cFiles['ext_localconf'].='<?php
1127
1128 $TYPO3_LOADED_EXT = unserialize(stripslashes(\''.addslashes(serialize($extensions)).'\'));
1129
1130 ?>';
1131
1132 reset($extensions);
1133 while(list($key, $conf) = each($extensions)) {
1134 if (is_array($conf)) {
1135 if ($conf['ext_localconf.php']) {
1136 $cFiles['ext_localconf'].=t3lib_extMgm::_makeIncludeHeader($key, $conf['ext_localconf.php']);
1137 $cFiles['ext_localconf'].=trim(t3lib_div::getUrl($conf['ext_localconf.php']));
1138 }
1139 if ($conf['ext_tables.php']) {
1140 $cFiles['ext_tables'].=t3lib_extMgm::_makeIncludeHeader($key, $conf['ext_tables.php']);
1141 $cFiles['ext_tables'].=trim(t3lib_div::getUrl($conf['ext_tables.php']));
1142 }
1143 }
1144 }
1145
1146 $cFiles['ext_localconf'] = "<?php\n" . preg_replace('/<\?php|\?>/is', '', $cFiles['ext_localconf']) . "?>\n";
1147 $cFiles['ext_tables'] = "<?php\n" . preg_replace('/<\?php|\?>/is', '', $cFiles['ext_tables']) . "?>\n";
1148
1149 t3lib_div::writeFile(PATH_typo3conf.$cacheFilePrefix.'_ext_localconf.php', $cFiles['ext_localconf']);
1150 t3lib_div::writeFile(PATH_typo3conf.$cacheFilePrefix.'_ext_tables.php', $cFiles['ext_tables']);
1151
1152 $extensions = array();
1153 $extensions['_CACHEFILE'] = $cacheFilePrefix;
1154
1155 return $extensions;
1156 }
1157
1158 /**
1159 * Unlink (delete) cache files
1160 *
1161 * @return integer Number of deleted files.
1162 */
1163 public static function removeCacheFiles() {
1164 $cacheFiles = t3lib_extMgm::currentCacheFiles();
1165 $out = 0;
1166 if (is_array($cacheFiles)) {
1167 reset($cacheFiles);
1168 foreach($cacheFiles as $cfile) {
1169 @unlink($cfile);
1170 clearstatcache();
1171 $out++;
1172 }
1173 }
1174 return $out;
1175 }
1176 }
1177
1178 ?>