[TASK] Cleanup foreach() by using references
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_extmgm.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2011 Kasper Skårhøj (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 * Revised for TYPO3 3.6 July/2003 by Kasper Skårhøj
31 *
32 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
33 */
34 /**
35 * [CLASS/FUNCTION INDEX of SCRIPT]
36 *
37 *
38 *
39 * 114: class t3lib_extMgm
40 *
41 * SECTION: PATHS and other evaluation
42 * 131: function isLoaded($key,$exitOnError = 0)
43 * 147: function extPath($key,$script='')
44 * 165: function extRelPath($key)
45 * 182: function siteRelPath($key)
46 * 194: function getCN($key)
47 *
48 * SECTION: Adding BACKEND features
49 * 227: function addTCAcolumns($table,$columnArray,$addTofeInterface=0)
50 * 251: function addToAllTCAtypes($table,$str,$specificTypesList='',$position='')
51 * 309: function allowTableOnStandardPages($table)
52 * 326: function addModule($main,$sub='',$position='',$path='')
53 * 389: function insertModuleFunction($modname,$className,$classPath,$title,$MM_key='function',$WS='')
54 * 408: function addPageTSConfig($content)
55 * 422: function addUserTSConfig($content)
56 * 437: function addLLrefForTCAdescr($tca_descr_key,$file_ref)
57 *
58 * SECTION: Adding SERVICES features
59 * 479: function addService($extKey, $serviceType, $serviceKey, $info)
60 * 547: function findService($serviceType, $serviceSubType='', $excludeServiceKeys=array())
61 * 618: function deactivateService($serviceType, $serviceKey)
62 *
63 * SECTION: Adding FRONTEND features
64 * 657: function addPlugin($itemArray,$type='list_type')
65 * 682: function addPiFlexFormValue($piKeyToMatch,$value)
66 * 702: function addToInsertRecords($table,$content_table='tt_content',$content_field='records')
67 * 733: function addPItoST43($key,$classFile='',$prefix='',$type='list_type',$cached=0)
68 * 808: function addStaticFile($extKey,$path,$title)
69 * 827: function addTypoScriptSetup($content)
70 * 841: function addTypoScriptConstants($content)
71 * 858: function addTypoScript($key,$type,$content,$afterStaticUid=0)
72 *
73 * SECTION: INTERNAL EXTENSION MANAGEMENT:
74 * 921: function typo3_loadExtensions()
75 * 998: function _makeIncludeHeader($key,$file)
76 * 1019: function isCacheFilesAvailable($cacheFilePrefix)
77 * 1032: function isLocalconfWritable()
78 * 1045: function cannotCacheFilesWritable($cacheFilePrefix)
79 * 1069: function currentCacheFiles()
80 * 1092: function writeCacheFiles($extensions,$cacheFilePrefix)
81 * 1130: function removeCacheFiles()
82 *
83 * TOTAL FUNCTIONS: 32
84 * (This index is automatically created/updated by the extension "extdeveval")
85 *
86 */
87
88
89 /**
90 * Extension Management functions
91 *
92 * This class is never instantiated, rather the methods inside is called as functions like
93 * t3lib_extMgm::isLoaded('my_extension');
94 *
95 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
96 * @package TYPO3
97 * @subpackage t3lib
98 */
99 final class t3lib_extMgm {
100 protected static $extensionKeyMap;
101
102
103 /**************************************
104 *
105 * PATHS and other evaluation
106 *
107 ***************************************/
108
109 /**
110 * Returns TRUE if the extension with extension key $key is loaded.
111 * Usage: 109
112 *
113 * @param string Extension key to test
114 * @param boolean If $exitOnError is TRUE and the extension is not loaded the function will die with an error message
115 * @return boolean
116 */
117 public static function isLoaded($key, $exitOnError = 0) {
118 global $TYPO3_LOADED_EXT;
119 if ($exitOnError && !isset($TYPO3_LOADED_EXT[$key])) {
120 throw new BadFunctionCallException(
121 'TYPO3 Fatal Error: Extension "' . $key . '" was not loaded!',
122 1270853910
123 );
124 }
125 return isset($TYPO3_LOADED_EXT[$key]);
126 }
127
128 /**
129 * Returns the absolute path to the extension with extension key $key
130 * If the extension is not loaded the function will die with an error message
131 * Useful for internal fileoperations
132 * Usage: 136
133 *
134 * @param string Extension key
135 * @param string $script is appended to the output if set.
136 * @return string
137 */
138 public static function extPath($key, $script = '') {
139 global $TYPO3_LOADED_EXT;
140 if (!isset($TYPO3_LOADED_EXT[$key])) {
141 throw new BadFunctionCallException(
142 'TYPO3 Fatal Error: Extension key "' . $key . '" was NOT loaded!',
143 1270853878
144 );
145 }
146 return PATH_site . $TYPO3_LOADED_EXT[$key]['siteRelPath'] . $script;
147 }
148
149 /**
150 * Returns the relative path to the extension as measured from from the TYPO3_mainDir
151 * If the extension is not loaded the function will die with an error message
152 * Useful for images and links from backend
153 * Usage: 54
154 *
155 * @param string Extension key
156 * @return string
157 */
158 public static function extRelPath($key) {
159 global $TYPO3_LOADED_EXT;
160 if (!isset($TYPO3_LOADED_EXT[$key])) {
161 throw new BadFunctionCallException(
162 'TYPO3 Fatal Error: Extension key "' . $key . '" was NOT loaded!',
163 1270853879
164 );
165 }
166 return $TYPO3_LOADED_EXT[$key]['typo3RelPath'];
167 }
168
169 /**
170 * Returns the relative path to the extension as measured from the PATH_site (frontend)
171 * If the extension is not loaded the function will die with an error message
172 * Useful for images and links from the frontend
173 * Usage: 6
174 *
175 * @param string Extension key
176 * @return string
177 */
178 public static function siteRelPath($key) {
179 return substr(self::extPath($key), strlen(PATH_site));
180 }
181
182 /**
183 * Returns the correct class name prefix for the extension key $key
184 * Usage: 3
185 *
186 * @param string Extension key
187 * @return string
188 * @internal
189 */
190 public static function getCN($key) {
191 return substr($key, 0, 5) == 'user_' ? 'user_' . str_replace('_', '', substr($key, 5)) : 'tx_' . str_replace('_', '', $key);
192 }
193
194 /**
195 * Returns the real extension key like 'tt_news' from an extension prefix like 'tx_ttnews'.
196 *
197 * @param string $prefix: The extension prefix (e.g. 'tx_ttnews')
198 * @return mixed Real extension key (string) or FALSE (boolean) if something went wrong
199 */
200 public static function getExtensionKeyByPrefix($prefix) {
201 $result = FALSE;
202 // Build map of short keys referencing to real keys:
203 if (!isset(self::$extensionKeyMap)) {
204 self::$extensionKeyMap = array();
205 foreach (array_keys($GLOBALS['TYPO3_LOADED_EXT']) as $extensionKey) {
206 $shortKey = str_replace('_', '', $extensionKey);
207 self::$extensionKeyMap[$shortKey] = $extensionKey;
208 }
209 }
210 // Lookup by the given short key:
211 $parts = explode('_', $prefix);
212 if (isset(self::$extensionKeyMap[$parts[1]])) {
213 $result = self::$extensionKeyMap[$parts[1]];
214 }
215 return $result;
216 }
217
218 /**
219 * Clears the extension key map.
220 *
221 * @return void
222 */
223 public static function clearExtensionKeyMap() {
224 self::$extensionKeyMap = NULL;
225 }
226
227 /**
228 * Retrieves the version of an installed extension.
229 * If the extension is not installed, this function returns an empty string.
230 *
231 * @param string $key the key of the extension to look up, must not be empty
232 * @return string the extension version as a string in the format "x.y.z",
233 * will be an empty string if the extension is not loaded
234 */
235 public static function getExtensionVersion($key) {
236 if (!is_string($key) || empty($key)) {
237 throw new InvalidArgumentException('Extension key must be a non-empty string.', 1294586096);
238 }
239 if (!self::isLoaded($key)) {
240 return '';
241 }
242
243 $EM_CONF = array();
244 $_EXTKEY = $key;
245 include(self::extPath($key) . 'ext_emconf.php');
246
247 return $EM_CONF[$key]['version'];
248 }
249
250
251 /**************************************
252 *
253 * Adding BACKEND features
254 * (related to core features)
255 *
256 ***************************************/
257
258 /**
259 * Adding fields to an existing table definition in $GLOBALS['TCA']
260 * Adds an array with $GLOBALS['TCA'] column-configuration to the $GLOBALS['TCA']-entry for that table.
261 * 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!
262 * So to have the fields displayed you must also call fx. addToAllTCAtypes or manually add the fields to the types list.
263 * FOR USE IN ext_tables.php FILES
264 * Usage: 4
265 *
266 * @param string $table is the table name of a table already present in $GLOBALS['TCA'] with a columns section
267 * @param array $columnArray is the array with the additional columns (typical some fields an extension wants to add)
268 * @param boolean If $addTofeInterface is TRUE the list of fields are also added to the fe_admin_fieldList.
269 * @return void
270 */
271 public static function addTCAcolumns($table, $columnArray, $addTofeInterface = 0) {
272 t3lib_div::loadTCA($table);
273 if (is_array($columnArray) && is_array($GLOBALS['TCA'][$table]) && is_array($GLOBALS['TCA'][$table]['columns'])) {
274 // Candidate for t3lib_div::array_merge() if integer-keys will some day make trouble...
275 $GLOBALS['TCA'][$table]['columns'] = array_merge($GLOBALS['TCA'][$table]['columns'], $columnArray);
276 if ($addTofeInterface) {
277 $GLOBALS['TCA'][$table]['feInterface']['fe_admin_fieldList'] .= ',' . implode(',', array_keys($columnArray));
278 }
279 }
280 }
281
282 /**
283 * Makes fields visible in the TCEforms, adding them to the end of (all) "types"-configurations
284 *
285 * Adds a string $str (comma list of field names) to all ["types"][xxx]["showitem"] entries for table $table (unless limited by $specificTypesList)
286 * This is needed to have new fields shown automatically in the TCEFORMS of a record from $table.
287 * Typically this function is called after having added new columns (database fields) with the addTCAcolumns function
288 * FOR USE IN ext_tables.php FILES
289 * Usage: 1
290 *
291 * @param string Table name
292 * @param string Field list to add.
293 * @param string List of specific types to add the field list to. (If empty, all type entries are affected)
294 * @param string Insert fields before (default) or after one
295 * of this fields (commalist with "before:", "after:" or "replace:" commands).
296 * Example: "before:keywords,--palette--;;4,after:description".
297 * Palettes must be passed like in the example no matter how the palette definition looks like in TCA.
298 * It will add the list of new fields before or after a palette or replace the field inside the palette,
299 * when the field given in $position is found inside a palette used by the type.
300 * @return void
301 */
302 public static function addToAllTCAtypes($table, $str, $specificTypesList = '', $position = '') {
303 t3lib_div::loadTCA($table);
304 $str = trim($str);
305 $palettesChanged = array();
306 if ($str && is_array($GLOBALS['TCA'][$table]) && is_array($GLOBALS['TCA'][$table]['types'])) {
307 foreach ($GLOBALS['TCA'][$table]['types'] as $type => &$typeDetails) {
308 if ($specificTypesList === '' || t3lib_div::inList($specificTypesList, $type)) {
309 $fieldExists = FALSE;
310 if ($position != '' && is_array($GLOBALS['TCA'][$table]['palettes'])) {
311 $positionArray = t3lib_div::trimExplode(':', $position);
312 if ($positionArray[0] == 'replace') {
313 foreach ($GLOBALS['TCA'][$table]['palettes'] as $palette => $paletteDetails) {
314 if (preg_match('/\b' . $palette . '\b/', $typeDetails['showitem']) > 0
315 && preg_match('/\b' . $positionArray[1] . '\b/', $paletteDetails['showitem']) > 0) {
316 self::addFieldsToPalette($table, $palette, $str, $position);
317 // save that palette in case other types use it
318 $palettesChanged[] = $palette;
319 $fieldExists = TRUE;
320 } elseif (in_array($palette, $palettesChanged)) {
321 $fieldExists = TRUE;
322 }
323 }
324 } else {
325 if (strpos($typeDetails['showitem'], $str) !== FALSE) {
326 $fieldExists = TRUE;
327 } else {
328 foreach ($GLOBALS['TCA'][$table]['palettes'] as $palette => $paletteDetails) {
329 if (preg_match('/\b' . $palette . '\b/', $typeDetails['showitem']) > 0
330 && preg_match('/\b' . $positionArray[1] . '\b/', $paletteDetails['showitem']) > 0) {
331 $position = $positionArray[0] . ':--palette--;;' . $palette;
332 }
333 }
334 }
335 }
336 } else {
337 if (strpos($typeDetails['showitem'], $str) !== FALSE) {
338 $fieldExists = TRUE;
339 } elseif (is_array($GLOBALS['TCA'][$table]['palettes'])) {
340 foreach ($GLOBALS['TCA'][$table]['palettes'] as $palette => $paletteDetails) {
341 if (preg_match('/\b' . $palette . '\b/', $typeDetails['showitem']) > 0
342 && strpos($paletteDetails['showitem'], $str) !== FALSE) {
343 $fieldExists = TRUE;
344 }
345 }
346 }
347 }
348 if ($fieldExists === FALSE) {
349 $typeDetails['showitem'] = self::executePositionedStringInsertion(
350 $typeDetails['showitem'],
351 $str,
352 $position
353 );
354 }
355 }
356 }
357 unset($typeDetails);
358 }
359 }
360
361 /**
362 * Adds new fields to all palettes of an existing field.
363 * If the field does not have a palette yet, it's created automatically and
364 * gets called "generatedFor-$field".
365 *
366 * @param string $table: Name of the table
367 * @param string $field: Name of the field that has the palette to be extended
368 * @param string $addFields: List of fields to be added to the palette
369 * @param string $insertionPosition: Insert fields before (default) or after one
370 * of this fields (commalist with "before:", "after:" or "replace:" commands).
371 * Example: "before:keywords,--palette--;;4,after:description".
372 * Palettes must be passed like in the example no matter how the
373 * palette definition looks like in TCA.
374 * @return void
375 */
376 public static function addFieldsToAllPalettesOfField($table, $field, $addFields, $insertionPosition = '') {
377 $generatedPalette = '';
378 $processedPalettes = array();
379 t3lib_div::loadTCA($table);
380
381 if (isset($GLOBALS['TCA'][$table]['columns'][$field])) {
382 $types =& $GLOBALS['TCA'][$table]['types'];
383 if (is_array($types)) {
384 // Iterate through all types and search for the field that defines the palette to be extended:
385 foreach (array_keys($types) as $type) {
386 $items = self::explodeItemList($types[$type]['showitem']);
387 if (isset($items[$field])) {
388 // If the field already has a palette, extend it:
389 if ($items[$field]['details']['palette']) {
390 $palette = $items[$field]['details']['palette'];
391 if (!isset($processedPalettes[$palette])) {
392 self::addFieldsToPalette($table, $palette, $addFields, $insertionPosition);
393 $processedPalettes[$palette] = TRUE;
394 }
395 // If there's not palette yet, create one:
396 } else {
397 if ($generatedPalette) {
398 $palette = $generatedPalette;
399 } else {
400 $palette = $generatedPalette = 'generatedFor-' . $field;
401 self::addFieldsToPalette($table, $palette, $addFields, $insertionPosition);
402 }
403 $items[$field]['details']['palette'] = $palette;
404 $types[$type]['showitem'] = self::generateItemList($items);
405 }
406 }
407 }
408 }
409 }
410 }
411
412 /**
413 * Adds new fields to a palette.
414 * If the palette does not exist yet, it's created automatically.
415 *
416 * @param string $table: Name of the table
417 * @param string $palette: Name of the palette to be extended
418 * @param string $addFields: List of fields to be added to the palette
419 * @param string $insertionPosition: Insert fields before (default) or after one
420 * of this fields (commalist with "before:", "after:" or "replace:" commands).
421 * Example: "before:keywords,--palette--;;4,after:description".
422 * Palettes must be passed like in the example no matter how the
423 * palette definition looks like in TCA.
424 * @return void
425 */
426 public static function addFieldsToPalette($table, $palette, $addFields, $insertionPosition = '') {
427 t3lib_div::loadTCA($table);
428
429 if (isset($GLOBALS['TCA'][$table])) {
430 $paletteData =& $GLOBALS['TCA'][$table]['palettes'][$palette];
431 // If palette already exists, merge the data:
432 if (is_array($paletteData)) {
433 $paletteData['showitem'] = self::executePositionedStringInsertion(
434 $paletteData['showitem'],
435 $addFields,
436 $insertionPosition
437 );
438 // If it's a new palette, just set the data:
439 } else {
440 $paletteData['showitem'] = self::removeDuplicatesForInsertion($addFields);
441 }
442 }
443 }
444
445 /**
446 * Add an item to a select field item list.
447 *
448 * Warning: Do not use this method for radio or check types, especially not
449 * with $relativeToField and $relativePosition parameters. This would shift
450 * existing database data 'off by one'.
451 *
452 * As an example, this can be used to add an item to tt_content CType select
453 * drop-down after the existing 'mailform' field with these parameters:
454 * - $table = 'tt_content'
455 * - $field = 'CType'
456 * - $item = array(
457 * 'LLL:EXT:cms/locallang_ttc.xml:CType.I.10',
458 * 'login',
459 * 'i/tt_content_login.gif',
460 * ),
461 * - $relativeToField = mailform
462 * - $relativePosition = after
463 *
464 * @throws InvalidArgumentException If given paramenters are not of correct
465 * type or out of bounds
466 * @throws RuntimeException If reference to related position fields can not
467 * be found or if select field is not defined
468 *
469 * @param string $table Name of TCA table
470 * @param string $field Name of TCA field
471 * @param array $item New item to add
472 * @param string $relativeToField Add item relative to existing field
473 * @param string $relativePosition Valid keywords: 'before', 'after'
474 * or 'replace' to relativeToField field
475 */
476 public static function addTcaSelectItem($table, $field, array $item, $relativeToField = '', $relativePosition = '') {
477 if (!is_string($table)) {
478 throw new InvalidArgumentException(
479 'Given table is of type "' . gettype($table) . '" but a string is expected.',
480 1303236963
481 );
482 }
483 if (!is_string($field)) {
484 throw new InvalidArgumentException(
485 'Given field is of type "' . gettype($field) . '" but a string is expected.',
486 1303236964
487 );
488 }
489 if (!is_string($relativeToField)) {
490 throw new InvalidArgumentException(
491 'Given relative field is of type "' . gettype($relativeToField) . '" but a string is expected.',
492 1303236965
493 );
494 }
495 if (!is_string($relativePosition)) {
496 throw new InvalidArgumentException(
497 'Given relative position is of type "' . gettype($relativePosition) . '" but a string is expected.',
498 1303236966
499 );
500 }
501 if ($relativePosition !== '' && $relativePosition !== 'before' && $relativePosition !== 'after' && $relativePosition !== 'replace') {
502 throw new InvalidArgumentException(
503 'Relative position must be either empty or one of "before", "after", "replace".',
504 1303236967
505 );
506 }
507
508 t3lib_div::loadTCA($table);
509
510 if (!is_array($GLOBALS['TCA'][$table]['columns'][$field]['config']['items'])) {
511 throw new RuntimeException(
512 'Given select field item list was not found.',
513 1303237468
514 );
515 }
516
517 // Make sure item keys are integers
518 $GLOBALS['TCA'][$table]['columns'][$field]['config']['items'] = array_values($GLOBALS['TCA'][$table]['columns'][$field]['config']['items']);
519
520 if (strlen($relativePosition) > 0) {
521 // Insert at specified position
522 $matchedPosition = t3lib_utility_Array::filterByValueRecursive(
523 $relativeToField,
524 $GLOBALS['TCA'][$table]['columns'][$field]['config']['items']
525 );
526 if (count($matchedPosition) > 0) {
527 $relativeItemKey = key($matchedPosition);
528 if ($relativePosition === 'replace') {
529 $GLOBALS['TCA'][$table]['columns'][$field]['config']['items'][$relativeItemKey] = $item;
530 } else {
531 if ($relativePosition === 'before') {
532 $offset = $relativeItemKey;
533 } else {
534 $offset = $relativeItemKey + 1;
535 }
536 array_splice($GLOBALS['TCA'][$table]['columns'][$field]['config']['items'], $offset, 0, array(0 => $item));
537 }
538 } else {
539 // Insert at new item at the end of the array if relative position was not found
540 $GLOBALS['TCA'][$table]['columns'][$field]['config']['items'][] = $item;
541 }
542 } else {
543 // Insert at new item at the end of the array
544 $GLOBALS['TCA'][$table]['columns'][$field]['config']['items'][] = $item;
545 }
546 }
547
548 /**
549 * Adds a list of new fields to the TYPO3 USER SETTINGS configuration "showitem" list, the array with
550 * the new fields itself needs to be added additionally to show up in the user setup, like
551 * $GLOBALS['TYPO3_USER_SETTINGS']['columns'] += $tempColumns
552 *
553 * @param string $addFields: List of fields to be added to the user settings
554 * @param string $insertionPosition: Insert fields before (default) or after one
555 * of this fields (commalist with "before:", "after:" or "replace:" commands).
556 * Example: "before:password,after:email".
557 * @return void
558 */
559 public function addFieldsToUserSettings($addFields, $insertionPosition = '') {
560 $GLOBALS['TYPO3_USER_SETTINGS']['showitem'] = self::executePositionedStringInsertion(
561 $GLOBALS['TYPO3_USER_SETTINGS']['showitem'],
562 $addFields,
563 $insertionPosition
564 );
565 }
566
567 /**
568 * Inserts as list of data into an existing list.
569 * The insertion position can be defined accordant before of after existing list items.
570 *
571 * @param string $list: The list of items to be extended
572 * @param string $insertionList: The list of items to inserted
573 * @param string $insertionPosition: Insert fields before (default) or after one
574 * of this fields (commalist with "before:" or "after:" commands).
575 * Example: "before:keywords,--palette--;;4,after:description".
576 * Palettes must be passed like in the example no matter how the
577 * palette definition looks like in TCA.
578 * @return string The extended list
579 */
580 protected static function executePositionedStringInsertion($list, $insertionList, $insertionPosition = '') {
581 $list = trim($list);
582 $insertionList = self::removeDuplicatesForInsertion($insertionList, $list);
583
584 if ($insertionList) {
585 // Append data to the end (default):
586 if ($insertionPosition === '') {
587 $list .= ($list ? ', ' : '') . $insertionList;
588 // Insert data before or after insertion points:
589 } else {
590 $positions = t3lib_div::trimExplode(',', $insertionPosition, TRUE);
591 $items = self::explodeItemList($list);
592 $isInserted = FALSE;
593 // Iterate through all fields an check whether it's possible to inserte there:
594 foreach ($items as $item => &$itemDetails) {
595 $needles = self::getInsertionNeedles($item, $itemDetails['details']);
596 // Insert data before:
597 foreach ($needles['before'] as $needle) {
598 if (in_array($needle, $positions)) {
599 $itemDetails['rawData'] = $insertionList . ', ' . $itemDetails['rawData'];
600 $isInserted = TRUE;
601 break;
602 }
603 }
604 // Insert data after:
605 foreach ($needles['after'] as $needle) {
606 if (in_array($needle, $positions)) {
607 $itemDetails['rawData'] .= ', ' . $insertionList;
608 $isInserted = TRUE;
609 break;
610 }
611 }
612 // Replace with data:
613 foreach ($needles['replace'] as $needle) {
614 if (in_array($needle, $positions)) {
615 $itemDetails['rawData'] = $insertionList;
616 $isInserted = TRUE;
617 break;
618 }
619 }
620 // Break if insertion was already done:
621 if ($isInserted) {
622 break;
623 }
624 }
625 // If insertion point could not be determined, append the data:
626 if (!$isInserted) {
627 $list .= ($list ? ', ' : '') . $insertionList;
628 // If data was correctly inserted before or after existing items, recreate the list:
629 } else {
630 $list = self::generateItemList($items, TRUE);
631 }
632 }
633 }
634
635 return $list;
636 }
637
638 /**
639 * Compares an existing list of items and a list of items to be inserted
640 * and returns a duplicate-free variant of that insertion list.
641 *
642 * Example:
643 * + list: 'field_a, field_b;;;;2-2-2, field_c;;;;3-3-3'
644 * + insertion: 'field_b, field_d, field_c;;;4-4-4'
645 * -> new insertion: 'field_d'
646 *
647 * @param string $insertionList: The list of items to inserted
648 * @param string $list: The list of items to be extended (default: '')
649 * @return string Duplicate-free list of items to be inserted
650 */
651 protected static function removeDuplicatesForInsertion($insertionList, $list = '') {
652 $pattern = '/(^|,)\s*\b([^;,]+)\b[^,]*/';
653 $listItems = array();
654
655 if ($list && preg_match_all($pattern, $list, $listMatches)) {
656 $listItems = $listMatches[2];
657 }
658
659 if ($insertionList && preg_match_all($pattern, $insertionList, $insertionListMatches)) {
660 $insertionItems = array();
661 $insertionDuplicates = FALSE;
662
663 foreach ($insertionListMatches[2] as $insertionIndex => $insertionItem) {
664 if (!isset($insertionItems[$insertionItem]) && !in_array($insertionItem, $listItems)) {
665 $insertionItems[$insertionItem] = TRUE;
666 } else {
667 unset($insertionListMatches[0][$insertionIndex]);
668 $insertionDuplicates = TRUE;
669 }
670 }
671
672 if ($insertionDuplicates) {
673 $insertionList = implode('', $insertionListMatches[0]);
674 }
675 }
676
677 return $insertionList;
678 }
679
680 /**
681 * Generates search needles that are used for inserting fields/items into an existing list.
682 *
683 * @see executePositionedStringInsertion
684 * @param string $item: The name of the field/item
685 * @param array $itemDetails: Additional details of the field/item like e.g. palette information
686 * (this array gets created by the function explodeItemList())
687 * @return array The needled to be used for inserting content before or after existing fields/items
688 */
689 protected static function getInsertionNeedles($item, array $itemDetails) {
690 if (strstr($item, '--')) {
691 // If $item is a separator (--div--) or palette (--palette--) then it may have been appended by a unique number. This must be stripped away here.
692 $item = preg_replace('/[0-9]+$/', '', $item);
693 }
694
695 $needles = array(
696 'before' => array($item, 'before:' . $item),
697 'after' => array('after:' . $item),
698 'replace' => array('replace:' . $item),
699 );
700
701 if ($itemDetails['palette']) {
702 $palette = $item . ';;' . $itemDetails['palette'];
703 $needles['before'][] = $palette;
704 $needles['before'][] = 'before:' . $palette;
705 $needles['after'][] = 'after:' . $palette;
706 $needles['replace'][] = 'replace:' . $palette;
707 }
708
709 return $needles;
710 }
711
712 /**
713 * Generates an array of fields/items with additional information such as e.g. the name of the palette.
714 *
715 * @param string $itemList: List of fields/items to be splitted up
716 * (this mostly reflects the data in $GLOBALS['TCA'][<table>]['types'][<type>]['showitem'])
717 * @return array An array with the names of the fields/items as keys and additional information
718 */
719 protected static function explodeItemList($itemList) {
720 $items = array();
721 $itemParts = t3lib_div::trimExplode(',', $itemList, TRUE);
722
723 foreach ($itemParts as $itemPart) {
724 $itemDetails = t3lib_div::trimExplode(';', $itemPart, FALSE, 5);
725 $key = $itemDetails[0];
726 if (strstr($key, '--')) {
727 // If $key is a separator (--div--) or palette (--palette--) then it will be appended by a unique number. This must be removed again when using this value!
728 $key .= count($items);
729 }
730
731 if (!isset($items[$key])) {
732 $items[$key] = array(
733 'rawData' => $itemPart,
734 'details' => array(
735 'field' => $itemDetails[0],
736 'label' => $itemDetails[1],
737 'palette' => $itemDetails[2],
738 'special' => $itemDetails[3],
739 'styles' => $itemDetails[4],
740 ),
741 );
742 }
743 }
744
745 return $items;
746 }
747
748 /**
749 * Generates a list of fields/items out of an array provided by the function getFieldsOfFieldList().
750 *
751 * @see explodeItemList
752 * @param array $items: The array of fields/items with optional additional information
753 * @param boolean $useRawData: Use raw data instead of building by using the details (default: FALSE)
754 * @return string The list of fields/items which gets used for $GLOBALS['TCA'][<table>]['types'][<type>]['showitem']
755 * or $GLOBALS['TCA'][<table>]['palettes'][<palette>]['showitem'] in most cases
756 */
757 protected static function generateItemList(array $items, $useRawData = FALSE) {
758 $itemParts = array();
759
760 foreach ($items as $item => $itemDetails) {
761 if (strstr($item, '--')) {
762 // If $item is a separator (--div--) or palette (--palette--) then it may have been appended by a unique number. This must be stripped away here.
763 $item = preg_replace('/[0-9]+$/', '', $item);
764 }
765
766 if ($useRawData) {
767 $itemParts[] = $itemDetails['rawData'];
768 } else {
769 $itemParts[] = (count($itemDetails['details']) > 1 ? implode(';', $itemDetails['details']) : $item);
770 }
771 }
772
773 return implode(', ', $itemParts);
774 }
775
776 /**
777 * Add tablename to default list of allowed tables on pages (in $PAGES_TYPES)
778 * Will add the $table to the list of tables allowed by default on pages as setup by $PAGES_TYPES['default']['allowedTables']
779 * FOR USE IN ext_tables.php FILES
780 * Usage: 11
781 *
782 * @param string Table name
783 * @return void
784 */
785 public static function allowTableOnStandardPages($table) {
786 $GLOBALS['PAGES_TYPES']['default']['allowedTables'] .= ',' . $table;
787 }
788
789 /**
790 * Adds a module (main or sub) to the backend interface
791 * FOR USE IN ext_tables.php FILES
792 * Usage: 18
793 *
794 * @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.
795 * @param string $sub is the submodule key. If $sub is not set a blank $main module is created.
796 * @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.
797 * @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.
798 * @return void
799 */
800 public static function addModule($main, $sub = '', $position = '', $path = '') {
801 if (isset($GLOBALS['TBE_MODULES'][$main]) && $sub) {
802 // if there is already a main module by this name:
803
804 // Adding the submodule to the correct position:
805 list($place, $modRef) = t3lib_div::trimExplode(':', $position, 1);
806 $mods = t3lib_div::trimExplode(',', $GLOBALS['TBE_MODULES'][$main], 1);
807 if (!in_array($sub, $mods)) {
808 switch (strtolower($place)) {
809 case 'after':
810 case 'before':
811 $pointer = 0;
812 $found = FALSE;
813 foreach ($mods as $k => $m) {
814 if (!strcmp($m, $modRef)) {
815 $pointer = strtolower($place) == 'after' ? $k + 1 : $k;
816 $found = TRUE;
817 }
818 }
819 if ($found) {
820 array_splice(
821 $mods, // The modules array
822 $pointer, // To insert one position from the end of the list
823 0, // Don't remove any items, just insert
824 $sub // Module to insert
825 );
826 } else {
827 // If requested module is not found: Add at the end
828 array_push($mods, $sub);
829 }
830 break;
831 default:
832 if (strtolower($place) == 'top') {
833 array_unshift($mods, $sub);
834 } else {
835 array_push($mods, $sub);
836 }
837 break;
838 }
839 }
840 // Re-inserting the submodule list:
841 $GLOBALS['TBE_MODULES'][$main] = implode(',', $mods);
842 } else { // Create new main modules with only one submodule, $sub (or none if $sub is blank)
843 $GLOBALS['TBE_MODULES'][$main] = $sub;
844 }
845
846 // Adding path:
847 if ($path) {
848 $GLOBALS['TBE_MODULES']['_PATHS'][$main . ($sub ? '_' . $sub : '')] = $path;
849 }
850 }
851
852 /**
853 * Adds a module path to $GLOBALS['TBE_MODULES'] for used with the module dispatcher, mod.php
854 * Used only for modules that are not placed in the main/sub menu hierarchy by the traditional mechanism of addModule()
855 * Examples for this is context menu functionality (like import/export) which runs as an independent module through mod.php
856 * FOR USE IN ext_tables.php FILES
857 * Example: t3lib_extMgm::addModulePath('xMOD_tximpexp', t3lib_extMgm::extPath($_EXTKEY).'app/');
858 *
859 * @param string $name is the name of the module, refer to conf.php of the module.
860 * @param string $path is the absolute path to the module directory inside of which "index.php" and "conf.php" is found.
861 * @return void
862 */
863 public static function addModulePath($name, $path) {
864 $GLOBALS['TBE_MODULES']['_PATHS'][$name] = $path;
865 }
866
867 /**
868 * Adds a "Function menu module" ('third level module') to an existing function menu for some other backend module
869 * The arguments values are generally determined by which function menu this is supposed to interact with
870 * See Inside TYPO3 for information on how to use this function.
871 * FOR USE IN ext_tables.php FILES
872 * Usage: 26
873 *
874 * @param string Module name
875 * @param string Class name
876 * @param string Class path
877 * @param string Title of module
878 * @param string Menu array key - default is "function"
879 * @param string Workspace conditions. Blank means all workspaces, any other string can be a comma list of "online", "offline" and "custom"
880 * @return void
881 * @see t3lib_SCbase::mergeExternalItems()
882 */
883 public static function insertModuleFunction($modname, $className, $classPath, $title, $MM_key = 'function', $WS = '') {
884 $GLOBALS['TBE_MODULES_EXT'][$modname]['MOD_MENU'][$MM_key][$className] = array(
885 'name' => $className,
886 'path' => $classPath,
887 'title' => $title,
888 'ws' => $WS
889 );
890 }
891
892 /**
893 * Adds $content to the default Page TSconfig as set in $GLOBALS['TYPO3_CONF_VARS'][BE]['defaultPageTSconfig']
894 * Prefixed with a [GLOBAL] line
895 * FOR USE IN ext_tables.php/ext_localconf.php FILES
896 * Usage: 5
897 *
898 * @param string Page TSconfig content
899 * @return void
900 */
901 public static function addPageTSConfig($content) {
902 $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig'] .= "\n[GLOBAL]\n" . $content;
903 }
904
905 /**
906 * Adds $content to the default User TSconfig as set in $GLOBALS['TYPO3_CONF_VARS'][BE]['defaultUserTSconfig']
907 * Prefixed with a [GLOBAL] line
908 * FOR USE IN ext_tables.php/ext_localconf.php FILES
909 * Usage: 3
910 *
911 * @param string User TSconfig content
912 * @return void
913 */
914 public static function addUserTSConfig($content) {
915 $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultUserTSconfig'] .= "\n[GLOBAL]\n" . $content;
916 }
917
918 /**
919 * Adds a reference to a locallang file with $GLOBALS['TCA_DESCR'] labels
920 * FOR USE IN ext_tables.php FILES
921 * 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.
922 * Usage: 31
923 *
924 * @param string Description key. Typically a database table (like "pages") but for applications can be other strings, but prefixed with "_MOD_")
925 * @param string File reference to locallang file, eg. "EXT:lang/locallang_csh_pages.php" (or ".xml")
926 * @return void
927 */
928 public static function addLLrefForTCAdescr($tca_descr_key, $file_ref) {
929 if ($tca_descr_key) {
930 if (!is_array($GLOBALS['TCA_DESCR'][$tca_descr_key])) {
931 $GLOBALS['TCA_DESCR'][$tca_descr_key] = array();
932 }
933 if (!is_array($GLOBALS['TCA_DESCR'][$tca_descr_key]['refs'])) {
934 $GLOBALS['TCA_DESCR'][$tca_descr_key]['refs'] = array();
935 }
936 $GLOBALS['TCA_DESCR'][$tca_descr_key]['refs'][] = $file_ref;
937 }
938 }
939
940 /**
941 * Registers a navigation component
942 *
943 * @param string $module
944 * @param string $componentId
945 * @return void
946 */
947 public static function addNavigationComponent($module, $componentId) {
948 $GLOBALS['TBE_MODULES']['_navigationComponents'][$module] = array(
949 'componentId' => $componentId,
950 'extKey' => $GLOBALS['_EXTKEY'],
951 'isCoreComponent' => FALSE,
952 );
953 }
954
955 /**
956 * Registers a core navigation component
957 *
958 * @param string $module
959 * @param string $componentId
960 * @return void
961 */
962 public static function addCoreNavigationComponent($module, $componentId) {
963 self::addNavigationComponent($module, $componentId);
964 $GLOBALS['TBE_MODULES']['_navigationComponents'][$module]['isCoreComponent'] = TRUE;
965 }
966
967
968 /**************************************
969 *
970 * Adding SERVICES features
971 *
972 * @author René Fritz <r.fritz@colorcube.de>
973 *
974 ***************************************/
975
976 /**
977 * Adds a service to the global services array
978 *
979 * @param string Extension key
980 * @param string Service type, must not be prefixed "tx_" or "Tx_"
981 * @param string Service key, must be prefixed "tx_", "Tx_" or "user_"
982 * @param array Service description array
983 * @return void
984 * @author René Fritz <r.fritz@colorcube.de>
985 */
986 public static function addService($extKey, $serviceType, $serviceKey, $info) {
987 // even not available services will be included to make it possible to give the admin a feedback of non-available services.
988 // but maybe it's better to move non-available services to a different array??
989
990 if ($serviceType &&
991 !t3lib_div::hasValidClassPrefix($serviceType) &&
992 t3lib_div::hasValidClassPrefix($serviceKey, array('user_')) &&
993 is_array($info)) {
994
995 $info['priority'] = max(0, min(100, $info['priority']));
996
997 $GLOBALS['T3_SERVICES'][$serviceType][$serviceKey] = $info;
998
999 $GLOBALS['T3_SERVICES'][$serviceType][$serviceKey]['extKey'] = $extKey;
1000 $GLOBALS['T3_SERVICES'][$serviceType][$serviceKey]['serviceKey'] = $serviceKey;
1001 $GLOBALS['T3_SERVICES'][$serviceType][$serviceKey]['serviceType'] = $serviceType;
1002
1003
1004 // mapping a service key to a service type
1005 // all service keys begin with tx_ or Tx_ - service types don't
1006 // this way a selection of a special service key as service type is easy
1007 $GLOBALS['T3_SERVICES'][$serviceKey][$serviceKey] = &$GLOBALS['T3_SERVICES'][$serviceType][$serviceKey];
1008
1009
1010 // change the priority (and other values) from $GLOBALS['TYPO3_CONF_VARS']
1011 // $GLOBALS['TYPO3_CONF_VARS']['T3_SERVICES'][$serviceType][$serviceKey]['priority']
1012 // even the activation is possible (a unix service might be possible on windows for some reasons)
1013 if (is_array($GLOBALS['TYPO3_CONF_VARS']['T3_SERVICES'][$serviceType][$serviceKey])) {
1014
1015 // no check is done here - there might be configuration values only the service type knows about, so
1016 // we pass everything
1017 $GLOBALS['T3_SERVICES'][$serviceType][$serviceKey] = array_merge(
1018 $GLOBALS['T3_SERVICES'][$serviceType][$serviceKey],
1019 $GLOBALS['TYPO3_CONF_VARS']['T3_SERVICES'][$serviceType][$serviceKey]
1020 );
1021 }
1022
1023
1024 // OS check
1025 // empty $os means 'not limited to one OS', therefore a check is not needed
1026 if ($GLOBALS['T3_SERVICES'][$serviceType][$serviceKey]['available']
1027 && $GLOBALS['T3_SERVICES'][$serviceType][$serviceKey]['os'] != '') {
1028
1029 // TYPO3_OS is not yet defined
1030 $os_type = stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin') ? 'WIN' : 'UNIX';
1031
1032 $os = t3lib_div::trimExplode(',', strtoupper($GLOBALS['T3_SERVICES'][$serviceType][$serviceKey]['os']));
1033
1034 if (!in_array($os_type, $os)) {
1035 self::deactivateService($serviceType, $serviceKey);
1036 }
1037 }
1038
1039 // convert subtype list to array for quicker access
1040 $GLOBALS['T3_SERVICES'][$serviceType][$serviceKey]['serviceSubTypes'] = array();
1041 $serviceSubTypes = t3lib_div::trimExplode(',', $info['subtype']);
1042 foreach ($serviceSubTypes as $subtype) {
1043 $GLOBALS['T3_SERVICES'][$serviceType][$serviceKey]['serviceSubTypes'][$subtype] = $subtype;
1044 }
1045 }
1046 }
1047
1048 /**
1049 * Find the available service with highest priority
1050 *
1051 * @param string Service type
1052 * @param string Service sub type
1053 * @param mixed Service keys that should be excluded in the search for a service. Array or comma list.
1054 * @return mixed Service info array if a service was found, FLASE otherwise
1055 * @author René Fritz <r.fritz@colorcube.de>
1056 */
1057 public static function findService($serviceType, $serviceSubType = '', $excludeServiceKeys = array()) {
1058 $serviceKey = FALSE;
1059 $serviceInfo = FALSE;
1060 $priority = 0;
1061 $quality = 0;
1062
1063 if (!is_array($excludeServiceKeys)) {
1064 $excludeServiceKeys = t3lib_div::trimExplode(',', $excludeServiceKeys, 1);
1065 }
1066
1067 if (is_array($GLOBALS['T3_SERVICES'][$serviceType])) {
1068 foreach ($GLOBALS['T3_SERVICES'][$serviceType] as $key => $info) {
1069
1070 if (in_array($key, $excludeServiceKeys)) {
1071 continue;
1072 }
1073
1074 // select a subtype randomly
1075 // usefull to start a service by service key without knowing his subtypes - for testing purposes
1076 if ($serviceSubType == '*') {
1077 $serviceSubType = key($info['serviceSubTypes']);
1078 }
1079
1080 // this matches empty subtype too
1081 if ($info['available'] && ($info['subtype'] == $serviceSubType || $info['serviceSubTypes'][$serviceSubType]) && $info['priority'] >= $priority) {
1082
1083 // has a lower quality than the already found, therefore we skip this service
1084 if ($info['priority'] == $priority && $info['quality'] < $quality) {
1085 continue;
1086 }
1087
1088 // service depends on external programs - check if they exists
1089 if (trim($info['exec'])) {
1090 $executables = t3lib_div::trimExplode(',', $info['exec'], 1);
1091 foreach ($executables as $executable) {
1092 if (!t3lib_exec::checkCommand($executable)) {
1093 self::deactivateService($serviceType, $key);
1094 $info['available'] = FALSE;
1095 break;
1096 }
1097 }
1098 }
1099
1100 // still available after exec check?
1101 if ($info['available']) {
1102 $serviceKey = $key;
1103 $priority = $info['priority'];
1104 $quality = $info['quality'];
1105 }
1106 }
1107 }
1108 }
1109
1110 if ($serviceKey) {
1111 $serviceInfo = $GLOBALS['T3_SERVICES'][$serviceType][$serviceKey];
1112 }
1113 return $serviceInfo;
1114 }
1115
1116 /**
1117 * Deactivate a service
1118 *
1119 * @param string Service type
1120 * @param string Service key
1121 * @return void
1122 * @author René Fritz <r.fritz@colorcube.de>
1123 */
1124 public static function deactivateService($serviceType, $serviceKey) {
1125 // ... maybe it's better to move non-available services to a different array??
1126 $GLOBALS['T3_SERVICES'][$serviceType][$serviceKey]['available'] = FALSE;
1127 }
1128
1129
1130 /**************************************
1131 *
1132 * Adding FRONTEND features
1133 * (related specifically to "cms" extension)
1134 *
1135 ***************************************/
1136
1137 /**
1138 * Adds an entry to the list of plugins in content elements of type "Insert plugin"
1139 * Takes the $itemArray (label, value[,icon]) and adds to the items-array of $GLOBALS['TCA'][tt_content] elements with CType "listtype" (or another field if $type points to another fieldname)
1140 * 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.
1141 * 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
1142 * FOR USE IN ext_tables.php FILES
1143 * Usage: 13
1144 *
1145 * @param array Item Array
1146 * @param string Type (eg. "list_type") - basically a field from "tt_content" table
1147 * @return void
1148 */
1149 public static function addPlugin($itemArray, $type = 'list_type') {
1150 $_EXTKEY = $GLOBALS['_EXTKEY'];
1151 if ($_EXTKEY && !$itemArray[2]) {
1152 $itemArray[2] = self::extRelPath($_EXTKEY) . 'ext_icon.gif';
1153 }
1154
1155 t3lib_div::loadTCA('tt_content');
1156 if (is_array($GLOBALS['TCA']['tt_content']['columns']) && is_array($GLOBALS['TCA']['tt_content']['columns'][$type]['config']['items'])) {
1157 foreach ($GLOBALS['TCA']['tt_content']['columns'][$type]['config']['items'] as $k => $v) {
1158 if (!strcmp($v[1], $itemArray[1])) {
1159 $GLOBALS['TCA']['tt_content']['columns'][$type]['config']['items'][$k] = $itemArray;
1160 return;
1161 }
1162 }
1163 $GLOBALS['TCA']['tt_content']['columns'][$type]['config']['items'][] = $itemArray;
1164 }
1165 }
1166
1167 /**
1168 * Adds an entry to the "ds" array of the tt_content field "pi_flexform".
1169 * This is used by plugins to add a flexform XML reference / content for use when they are selected as plugin or content element.
1170 * Usage: 0
1171 *
1172 * @param string Plugin key as used in the list_type field. Use the asterisk * to match all list_type values.
1173 * @param string Either a reference to a flex-form XML file (eg. "FILE:EXT:newloginbox/flexform_ds.xml") or the XML directly.
1174 * @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.
1175 * @return void
1176 * @see addPlugin()
1177 */
1178 public static function addPiFlexFormValue($piKeyToMatch, $value, $CTypeToMatch = 'list') {
1179 t3lib_div::loadTCA('tt_content');
1180
1181 if (is_array($GLOBALS['TCA']['tt_content']['columns']) && is_array($GLOBALS['TCA']['tt_content']['columns']['pi_flexform']['config']['ds'])) {
1182 $GLOBALS['TCA']['tt_content']['columns']['pi_flexform']['config']['ds'][$piKeyToMatch . ',' . $CTypeToMatch] = $value;
1183 }
1184 }
1185
1186 /**
1187 * Adds the $table tablename to the list of tables allowed to be includes by content element type "Insert records"
1188 * By using $content_table and $content_field you can also use the function for other tables.
1189 * FOR USE IN ext_tables.php FILES
1190 * Usage: 9
1191 *
1192 * @param string Table name to allow for "insert record"
1193 * @param string Table name TO WHICH the $table name is applied. See $content_field as well.
1194 * @param string Field name in the database $content_table in which $table is allowed to be added as a reference ("Insert Record")
1195 * @return void
1196 */
1197 public static function addToInsertRecords($table, $content_table = 'tt_content', $content_field = 'records') {
1198 t3lib_div::loadTCA($content_table);
1199 if (is_array($GLOBALS['TCA'][$content_table]['columns']) && isset($GLOBALS['TCA'][$content_table]['columns'][$content_field]['config']['allowed'])) {
1200 $GLOBALS['TCA'][$content_table]['columns'][$content_field]['config']['allowed'] .= ',' . $table;
1201 }
1202 }
1203
1204 /**
1205 * Add PlugIn to Static Template #43
1206 *
1207 * 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.
1208 * 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"
1209 * $type determines the type of frontend plugin:
1210 * "list_type" (default) - the good old "Insert plugin" entry
1211 * "menu_type" - a "Menu/Sitemap" entry
1212 * "splash_layout" - a "Textbox" entry
1213 * "CType" - a new content element type
1214 * "header_layout" - an additional header type (added to the selection of layout1-5)
1215 * "includeLib" - just includes the library for manual use somewhere in TypoScript.
1216 * (Remember that your $type definition should correspond to the column/items array in $GLOBALS['TCA'][tt_content] where you added the selector item for the element! See addPlugin() function)
1217 * FOR USE IN ext_localconf.php FILES
1218 * Usage: 2
1219 *
1220 * @param string $key is the extension key
1221 * @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.
1222 * @param string $prefix is used as a - yes, suffix - of the class name (fx. "_pi1")
1223 * @param string $type, see description above
1224 * @param boolean If $cached is set as USER content object (cObject) is created - otherwise a USER_INT object is created.
1225 * @return void
1226 */
1227 public static function addPItoST43($key, $classFile = '', $prefix = '', $type = 'list_type', $cached = 0) {
1228 $classFile = $classFile ? $classFile : 'pi/class.tx_' . str_replace('_', '', $key) . $prefix . '.php';
1229 $cN = self::getCN($key);
1230
1231 // General plugin:
1232 $pluginContent = trim('
1233 plugin.' . $cN . $prefix . ' = USER' . ($cached ? '' : '_INT') . '
1234 plugin.' . $cN . $prefix . ' {
1235 includeLibs = ' . $GLOBALS['TYPO3_LOADED_EXT'][$key]['siteRelPath'] . $classFile . '
1236 userFunc = ' . $cN . $prefix . '->main
1237 }');
1238 self::addTypoScript($key, 'setup', '
1239 # Setting ' . $key . ' plugin TypoScript
1240 ' . $pluginContent);
1241
1242 // After ST43:
1243 switch ($type) {
1244 case 'list_type':
1245 $addLine = 'tt_content.list.20.' . $key . $prefix . ' = < plugin.' . $cN . $prefix;
1246 break;
1247 case 'menu_type':
1248 $addLine = 'tt_content.menu.20.' . $key . $prefix . ' = < plugin.' . $cN . $prefix;
1249 break;
1250 case 'splash_layout':
1251 $addLine = 'tt_content.splash.' . $key . $prefix . ' = < plugin.' . $cN . $prefix;
1252 break;
1253 case 'CType':
1254 $addLine = trim('
1255 tt_content.' . $key . $prefix . ' = COA
1256 tt_content.' . $key . $prefix . ' {
1257 10 = < lib.stdheader
1258 20 = < plugin.' . $cN . $prefix . '
1259 }
1260 ');
1261 break;
1262 case 'header_layout':
1263 $addLine = 'lib.stdheader.10.' . $key . $prefix . ' = < plugin.' . $cN . $prefix;
1264 break;
1265 case 'includeLib':
1266 $addLine = 'page.1000 = < plugin.' . $cN . $prefix;
1267 break;
1268 default:
1269 $addLine = '';
1270 break;
1271 }
1272 if ($addLine) {
1273 self::addTypoScript($key, 'setup', '
1274 # Setting ' . $key . ' plugin TypoScript
1275 ' . $addLine . '
1276 ', 43);
1277 }
1278 }
1279
1280 /**
1281 * Call this method to add an entry in the static template list found in sys_templates
1282 * "static template files" are the modern equivalent (provided from extensions) to the traditional records in "static_templates"
1283 * FOR USE IN ext_localconf.php FILES
1284 * Usage: 3
1285 *
1286 * @param string $extKey is of course the extension key
1287 * @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/
1288 * @param string $title is the title in the selector box.
1289 * @return void
1290 * @see addTypoScript()
1291 */
1292 public static function addStaticFile($extKey, $path, $title) {
1293 t3lib_div::loadTCA('sys_template');
1294 if ($extKey && $path && is_array($GLOBALS['TCA']['sys_template']['columns'])) {
1295 $value = str_replace(',', '', 'EXT:' . $extKey . '/' . $path);
1296 $itemArray = array(trim($title . ' (' . $extKey . ')'), $value);
1297 $GLOBALS['TCA']['sys_template']['columns']['include_static_file']['config']['items'][] = $itemArray;
1298 }
1299 }
1300
1301 /**
1302 * Adds $content to the default TypoScript setup code as set in $GLOBALS['TYPO3_CONF_VARS'][FE]['defaultTypoScript_setup']
1303 * Prefixed with a [GLOBAL] line
1304 * FOR USE IN ext_localconf.php FILES
1305 * Usage: 6
1306 *
1307 * @param string TypoScript Setup string
1308 * @return void
1309 */
1310 public static function addTypoScriptSetup($content) {
1311 $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup'] .= "\n[GLOBAL]\n" . $content;
1312 }
1313
1314 /**
1315 * Adds $content to the default TypoScript constants code as set in $GLOBALS['TYPO3_CONF_VARS'][FE]['defaultTypoScript_constants']
1316 * Prefixed with a [GLOBAL] line
1317 * FOR USE IN ext_localconf.php FILES
1318 * Usage: 0
1319 *
1320 * @param string TypoScript Constants string
1321 * @return void
1322 */
1323 public static function addTypoScriptConstants($content) {
1324 $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_constants'] .= "\n[GLOBAL]\n" . $content;
1325 }
1326
1327 /**
1328 * Adds $content to the default TypoScript code for either setup, constants or editorcfg as set in $GLOBALS['TYPO3_CONF_VARS'][FE]['defaultTypoScript_*']
1329 * (Basically this function can do the same as addTypoScriptSetup and addTypoScriptConstants - just with a little more hazzle, but also with some more options!)
1330 * FOR USE IN ext_localconf.php FILES
1331 * Usage: 7
1332 *
1333 * @param string $key is the extension key (informative only).
1334 * @param string $type is either "setup", "constants" or "editorcfg" and obviously determines which kind of TypoScript code we are adding.
1335 * @param string $content is the TS content, prefixed with a [GLOBAL] line and a comment-header.
1336 * @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.
1337 * @return void
1338 */
1339 public static function addTypoScript($key, $type, $content, $afterStaticUid = 0) {
1340 if ($type == 'setup' || $type == 'editorcfg' || $type == 'constants') {
1341 $content = '
1342
1343 [GLOBAL]
1344 #############################################
1345 ## TypoScript added by extension "' . $key . '"
1346 #############################################
1347
1348 ' . $content;
1349 if ($afterStaticUid) {
1350 $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_' . $type . '.'][$afterStaticUid] .= $content;
1351 // If 'content (default)' is targeted, also add to other 'content rendering templates', eg. css_styled_content
1352 if ($afterStaticUid == 43 && is_array($GLOBALS['TYPO3_CONF_VARS']['FE']['contentRenderingTemplates'])) {
1353 foreach ($GLOBALS['TYPO3_CONF_VARS']['FE']['contentRenderingTemplates'] as $templateName) {
1354 $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_' . $type . '.'][$templateName] .= $content;
1355 }
1356 }
1357 } else {
1358 $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_' . $type] .= $content;
1359 }
1360 }
1361 }
1362
1363
1364 /**************************************
1365 *
1366 * INTERNAL EXTENSION MANAGEMENT:
1367 *
1368 ***************************************/
1369
1370 /**
1371 * Loading extensions configured in $TYPO3_CONF_VARS['EXT']['extList']
1372 *
1373 * CACHING ON: ($TYPO3_CONF_VARS['EXT']['extCache'] = 1 or 2)
1374 * 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.
1375 * If cachefiles are not found they will be generated
1376 * CACHING OFF: ($TYPO3_CONF_VARS['EXT']['extCache'] = 0)
1377 * 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.
1378 * This array will later be set in the global var $TYPO3_LOADED_EXT
1379 *
1380 * Usages of this function can be seen in config_default.php
1381 * Extensions are always detected in the order local - global - system.
1382 * Usage: 1
1383 *
1384 * @return array Extension Array
1385 * @internal
1386 */
1387 public static function typo3_loadExtensions() {
1388 global $TYPO3_CONF_VARS;
1389
1390 // Caching behaviour of ext_tables.php and ext_localconf.php files:
1391 $extensionCacheBehaviour = self::getExtensionCacheBehaviour();
1392 // Full list of extensions includes both required and extList:
1393 $rawExtList = self::getEnabledExtensionList();
1394
1395 // Empty array as a start.
1396 $extensions = array();
1397
1398 //
1399 if ($rawExtList) {
1400 // The cached File prefix.
1401 $cacheFilePrefix = self::getCacheFilePrefix();
1402
1403 // If cache files available, set cache file prefix and return:
1404 if ($extensionCacheBehaviour && self::isCacheFilesAvailable($cacheFilePrefix)) {
1405 // Return cache file prefix:
1406 $extensions['_CACHEFILE'] = $cacheFilePrefix;
1407 } else { // ... but if not, configure...
1408
1409 // Prepare reserved filenames:
1410 $files = array('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');
1411 // Traverse extensions and check their existence:
1412 clearstatcache(); // Clear file state cache to make sure we get good results from is_dir()
1413 $temp_extensions = array_unique(t3lib_div::trimExplode(',', $rawExtList, 1));
1414 foreach ($temp_extensions as $temp_extKey) {
1415 // Check local, global and system locations:
1416 if (@is_dir(PATH_typo3conf . 'ext/' . $temp_extKey . '/')) {
1417 $extensions[$temp_extKey] = array('type' => 'L', 'siteRelPath' => 'typo3conf/ext/' . $temp_extKey . '/', 'typo3RelPath' => '../typo3conf/ext/' . $temp_extKey . '/');
1418 } elseif (@is_dir(PATH_typo3 . 'ext/' . $temp_extKey . '/')) {
1419 $extensions[$temp_extKey] = array('type' => 'G', 'siteRelPath' => TYPO3_mainDir . 'ext/' . $temp_extKey . '/', 'typo3RelPath' => 'ext/' . $temp_extKey . '/');
1420 } elseif (@is_dir(PATH_typo3 . 'sysext/' . $temp_extKey . '/')) {
1421 $extensions[$temp_extKey] = array('type' => 'S', 'siteRelPath' => TYPO3_mainDir . 'sysext/' . $temp_extKey . '/', 'typo3RelPath' => 'sysext/' . $temp_extKey . '/');
1422 }
1423
1424 // If extension was found, check for reserved filenames:
1425 if (isset($extensions[$temp_extKey])) {
1426 foreach ($files as $fName) {
1427 $temp_filename = PATH_site . $extensions[$temp_extKey]['siteRelPath'] . trim($fName);
1428 if (is_array($extensions[$temp_extKey]) && @is_file($temp_filename)) {
1429 $extensions[$temp_extKey][$fName] = $temp_filename;
1430 }
1431 }
1432 }
1433 }
1434 unset($extensions['_CACHEFILE']);
1435
1436 // write cache?
1437 if ($extensionCacheBehaviour &&
1438 @is_dir(PATH_typo3 . 'sysext/') &&
1439 @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!
1440 $wrError = self::cannotCacheFilesWritable($cacheFilePrefix);
1441 if ($wrError) {
1442 $TYPO3_CONF_VARS['EXT']['extCache'] = 0;
1443 } else {
1444 // Write cache files:
1445 $extensions = self::writeCacheFiles($extensions, $cacheFilePrefix);
1446 }
1447 }
1448 }
1449 }
1450
1451 return $extensions;
1452 }
1453
1454 /**
1455 * Returns the section headers for the compiled cache-files.
1456 *
1457 * @param string $key is the extension key
1458 * @param string $file is the filename (only informative for comment)
1459 * @return string
1460 * @internal
1461 */
1462 public static function _makeIncludeHeader($key, $file) {
1463 return '<?php
1464 ###########################
1465 ## EXTENSION: ' . $key . '
1466 ## FILE: ' . $file . '
1467 ###########################
1468
1469 $_EXTKEY = \'' . $key . '\';
1470 $_EXTCONF = $TYPO3_CONF_VARS[\'EXT\'][\'extConf\'][$_EXTKEY];
1471
1472 ?>';
1473 }
1474
1475 /**
1476 * Returns TRUE if both the localconf and tables cache file exists (with $cacheFilePrefix)
1477 * Usage: 2
1478 *
1479 * @param string Prefix of the cache file to check
1480 * @return boolean
1481 * @internal
1482 */
1483 public static function isCacheFilesAvailable($cacheFilePrefix) {
1484 return
1485 @is_file(PATH_typo3conf . $cacheFilePrefix . '_ext_localconf.php') &&
1486 @is_file(PATH_typo3conf . $cacheFilePrefix . '_ext_tables.php');
1487 }
1488
1489 /**
1490 * Returns TRUE if the "localconf.php" file in "typo3conf/" is writable
1491 * Usage: 1
1492 *
1493 * @return boolean
1494 * @internal
1495 */
1496 public static function isLocalconfWritable() {
1497 return @is_writable(PATH_typo3conf) && @is_writable(PATH_typo3conf . 'localconf.php');
1498 }
1499
1500 /**
1501 * Returns an error string if typo3conf/ or cache-files with $cacheFilePrefix are NOT writable
1502 * Returns FALSE if no problem.
1503 * Usage: 1
1504 *
1505 * @param string Prefix of the cache file to check
1506 * @return string
1507 * @internal
1508 */
1509 public static function cannotCacheFilesWritable($cacheFilePrefix) {
1510 $error = array();
1511 if (!@is_writable(PATH_typo3conf)) {
1512 $error[] = PATH_typo3conf;
1513 }
1514 if (@is_file(PATH_typo3conf . $cacheFilePrefix . '_ext_localconf.php') &&
1515 !@is_writable(PATH_typo3conf . $cacheFilePrefix . '_ext_localconf.php')) {
1516 $error[] = PATH_typo3conf . $cacheFilePrefix . '_ext_localconf.php';
1517 }
1518 if (@is_file(PATH_typo3conf . $cacheFilePrefix . '_ext_tables.php') &&
1519 !@is_writable(PATH_typo3conf . $cacheFilePrefix . '_ext_tables.php')) {
1520 $error[] = PATH_typo3conf . $cacheFilePrefix . '_ext_tables.php';
1521 }
1522 return implode(', ', $error);
1523 }
1524
1525 /**
1526 * Returns an array with the two cache-files (0=>localconf, 1=>tables) from typo3conf/ if they (both) exist. Otherwise FALSE.
1527 * Evaluation relies on $TYPO3_LOADED_EXT['_CACHEFILE']
1528 * Usage: 2
1529 *
1530 * @param string $cacheFilePrefix Cache file prefix to be used (optional)
1531 * @return array
1532 * @internal
1533 */
1534 public static function currentCacheFiles($cacheFilePrefix = NULL) {
1535 if (is_null($cacheFilePrefix)) {
1536 $cacheFilePrefix = $GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE'];
1537 }
1538
1539 if ($cacheFilePrefix) {
1540 $cacheFilePrefixFE = str_replace('temp_CACHED', 'temp_CACHED_FE', $cacheFilePrefix);
1541 $files = array();
1542 if (self::isCacheFilesAvailable($cacheFilePrefix)) {
1543 $files[] = PATH_typo3conf . $cacheFilePrefix . '_ext_localconf.php';
1544 $files[] = PATH_typo3conf . $cacheFilePrefix . '_ext_tables.php';
1545 }
1546 if (self::isCacheFilesAvailable($cacheFilePrefixFE)) {
1547 $files[] = PATH_typo3conf . $cacheFilePrefixFE . '_ext_localconf.php';
1548 $files[] = PATH_typo3conf . $cacheFilePrefixFE . '_ext_tables.php';
1549 }
1550 if (!empty($files)) {
1551 return $files;
1552 }
1553 }
1554 }
1555
1556 /**
1557 * Compiles/Creates the two cache-files in typo3conf/ based on $cacheFilePrefix
1558 * Returns a array with the key "_CACHEFILE" set to the $cacheFilePrefix value
1559 * Usage: 1
1560 *
1561 * @param array Extension information array
1562 * @param string Prefix for the cache files
1563 * @return array
1564 * @internal
1565 */
1566 public static function writeCacheFiles($extensions, $cacheFilePrefix) {
1567 // Making cache files:
1568 $extensions['_CACHEFILE'] = $cacheFilePrefix;
1569 $cFiles = array();
1570 $cFiles['ext_localconf'] .= '<?php
1571
1572 $TYPO3_LOADED_EXT = unserialize(stripslashes(\'' . addslashes(serialize($extensions)) . '\'));
1573
1574 ?>';
1575
1576 foreach ($extensions as $key => $conf) {
1577 if (is_array($conf)) {
1578 if ($conf['ext_localconf.php']) {
1579 $cFiles['ext_localconf'] .= self::_makeIncludeHeader($key, $conf['ext_localconf.php']);
1580 $cFiles['ext_localconf'] .= trim(t3lib_div::getUrl($conf['ext_localconf.php']));
1581 }
1582 if ($conf['ext_tables.php']) {
1583 $cFiles['ext_tables'] .= self::_makeIncludeHeader($key, $conf['ext_tables.php']);
1584 $cFiles['ext_tables'] .= trim(t3lib_div::getUrl($conf['ext_tables.php']));
1585 }
1586 }
1587 }
1588
1589 $cFiles['ext_localconf'] = "<?php\n" . preg_replace('/<\?php|\?>/is', '', $cFiles['ext_localconf']) . "?>\n";
1590 $cFiles['ext_tables'] = "<?php\n" . preg_replace('/<\?php|\?>/is', '', $cFiles['ext_tables']) . "?>\n";
1591
1592 t3lib_div::writeFile(PATH_typo3conf . $cacheFilePrefix . '_ext_localconf.php', $cFiles['ext_localconf']);
1593 t3lib_div::writeFile(PATH_typo3conf . $cacheFilePrefix . '_ext_tables.php', $cFiles['ext_tables']);
1594
1595 $extensions = array();
1596 $extensions['_CACHEFILE'] = $cacheFilePrefix;
1597
1598 return $extensions;
1599 }
1600
1601 /**
1602 * Unlink (delete) cache files
1603 *
1604 * @param string $cacheFilePrefix Cache file prefix to be used (optional)
1605 * @return integer Number of deleted files.
1606 */
1607 public static function removeCacheFiles($cacheFilePrefix = NULL) {
1608 $cacheFiles = self::currentCacheFiles($cacheFilePrefix);
1609
1610 $out = 0;
1611 if (is_array($cacheFiles)) {
1612 reset($cacheFiles);
1613 foreach ($cacheFiles as $cfile) {
1614 @unlink($cfile);
1615 clearstatcache();
1616 $out++;
1617 }
1618 }
1619 return $out;
1620 }
1621
1622 /**
1623 * Gets the behaviour for caching ext_tables.php and ext_localconf.php files
1624 * (see $TYPO3_CONF_VARS['EXT']['extCache'] setting in the install tool).
1625 *
1626 * @param boolean $usePlainValue Whether to use the value as it is without modifications
1627 * @return integer
1628 */
1629 public static function getExtensionCacheBehaviour($usePlainValue = FALSE) {
1630 $extensionCacheBehaviour = intval($GLOBALS['TYPO3_CONF_VARS']['EXT']['extCache']);
1631
1632 // Caching of extensions is disabled when install tool is used:
1633 if (!$usePlainValue && defined('TYPO3_enterInstallScript') && TYPO3_enterInstallScript) {
1634 $extensionCacheBehaviour = 0;
1635 }
1636
1637 return $extensionCacheBehaviour;
1638 }
1639
1640 /**
1641 * Gets the prefix used for the ext_tables.php and ext_localconf.php cached files.
1642 *
1643 * @return string
1644 */
1645 public static function getCacheFilePrefix() {
1646 $extensionCacheBehaviour = self::getExtensionCacheBehaviour(TRUE);
1647
1648 $cacheFileSuffix = (TYPO3_MODE == 'FE' ? '_FE' : '');
1649 $cacheFilePrefix = 'temp_CACHED' . $cacheFileSuffix;
1650
1651 if ($extensionCacheBehaviour == 1) {
1652 $cacheFilePrefix .= '_ps' . substr(t3lib_div::shortMD5(PATH_site . '|' . $GLOBALS['TYPO_VERSION']), 0, 4);
1653 } elseif ($extensionCacheBehaviour == 2) {
1654 $cacheFilePrefix .= '_' . t3lib_div::shortMD5(self::getEnabledExtensionList());
1655 }
1656
1657 return $cacheFilePrefix;
1658 }
1659
1660 /**
1661 * Gets the list of enabled extensions for the accordant context (frontend or backend).
1662 *
1663 * @return string
1664 */
1665 public static function getEnabledExtensionList() {
1666 // Select mode how to load extensions in order to speed up the FE
1667 if (TYPO3_MODE == 'FE') {
1668 if (!($extLoadInContext = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList_FE'])) {
1669 // fall back to standard 'extList' if 'extList_FE' is not (yet) set
1670 $extLoadInContext = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList'];
1671 }
1672 } else {
1673 $extLoadInContext = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList'];
1674 }
1675
1676 $extensionList = self::getRequiredExtensionList() . ',' . $extLoadInContext;
1677 $ignoredExtensionList = self::getIgnoredExtensionList();
1678
1679 // Remove the extensions to be ignored:
1680 if ($ignoredExtensionList && (defined('TYPO3_enterInstallScript') && TYPO3_enterInstallScript) === FALSE) {
1681 $extensions = array_diff(
1682 explode(',', $extensionList),
1683 explode(',', $ignoredExtensionList)
1684 );
1685 $extensionList = implode(',', $extensions);
1686 }
1687
1688 return $extensionList;
1689 }
1690
1691 /**
1692 * Gets the list of required extensions.
1693 *
1694 * @return string
1695 */
1696 public static function getRequiredExtensionList() {
1697 $requiredExtensionList = t3lib_div::uniqueList(
1698 REQUIRED_EXTENSIONS . ',' . $GLOBALS['TYPO3_CONF_VARS']['EXT']['requiredExt']
1699 );
1700
1701 return $requiredExtensionList;
1702 }
1703
1704 /**
1705 * Gets the list of extensions to be ignored (not to be loaded).
1706 *
1707 * @return string
1708 */
1709 public static function getIgnoredExtensionList() {
1710 $ignoredExtensionList = t3lib_div::uniqueList(
1711 $GLOBALS['TYPO3_CONF_VARS']['EXT']['ignoredExt']
1712 );
1713
1714 return $ignoredExtensionList;
1715 }
1716 }
1717
1718 ?>