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