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