[FEATURE] Speed-up Backend with CardLayout
[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 * @param boolean $addJsAutomatically adds automatically the card for this module the TYPO3 BE - if you use ExtJS you may disable this option
778 * @return void
779 */
780 public static function addModule($main, $sub = '', $position = '', $path = '', $addJsAutomatically = TRUE) {
781 if (isset($GLOBALS['TBE_MODULES'][$main]) && $sub) {
782 // if there is already a main module by this name:
783
784 // Adding the submodule to the correct position:
785 list($place, $modRef) = t3lib_div::trimExplode(':', $position, 1);
786 $mods = t3lib_div::trimExplode(',', $GLOBALS['TBE_MODULES'][$main], 1);
787 if (!in_array($sub, $mods)) {
788 switch (strtolower($place)) {
789 case 'after':
790 case 'before':
791 $pointer = 0;
792 $found = FALSE;
793 foreach ($mods as $k => $m) {
794 if (!strcmp($m, $modRef)) {
795 $pointer = strtolower($place) == 'after' ? $k + 1 : $k;
796 $found = TRUE;
797 }
798 }
799 if ($found) {
800 array_splice(
801 $mods, // The modules array
802 $pointer, // To insert one position from the end of the list
803 0, // Don't remove any items, just insert
804 $sub // Module to insert
805 );
806 } else {
807 // If requested module is not found: Add at the end
808 array_push($mods, $sub);
809 }
810 break;
811 default:
812 if (strtolower($place) == 'top') {
813 array_unshift($mods, $sub);
814 } else {
815 array_push($mods, $sub);
816 }
817 break;
818 }
819 }
820 // Re-inserting the submodule list:
821 $GLOBALS['TBE_MODULES'][$main] = implode(',', $mods);
822 } else { // Create new main modules with only one submodule, $sub (or none if $sub is blank)
823 $GLOBALS['TBE_MODULES'][$main] = $sub;
824 }
825
826 // Adding path:
827 if ($path) {
828 $GLOBALS['TBE_MODULES']['_PATHS'][$main . ($sub ? '_' . $sub : '')] = $path;
829 if ($addJsAutomatically) {
830 $GLOBALS['TBE_MODULES']['_JSINIT'][$main . ($sub ? '_' . $sub : '')] = '
831 TYPO3.Viewport.ContentCards.addContentCard("' . $main . ($sub ? '_' . $sub : '') . '",
832 {
833 xtype: "iframePanel"
834 }
835 );
836 ';
837 }
838 }
839 }
840
841 /**
842 * Registers an Ext.Direct component with access restrictions.
843 *
844 * @param string $endpointName
845 * @param string $callbackClass
846 * @param string $moduleName optional: must be <mainmodule> or <mainmodule>_<submodule>
847 * @param string $accessLevel optional: can be 'admin' or 'user,group'
848 * @return void
849 */
850 public static function registerExtDirectComponent($endpointName, $callbackClass, $moduleName = NULL, $accessLevel = NULL) {
851 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ExtDirect'][$endpointName] = array(
852 'callbackClass' => $callbackClass,
853 'moduleName' => $moduleName,
854 'accessLevel' => $accessLevel,
855 );
856 }
857
858 /**
859 * Adds a module path to $GLOBALS['TBE_MODULES'] for used with the module dispatcher, mod.php
860 * Used only for modules that are not placed in the main/sub menu hierarchy by the traditional mechanism of addModule()
861 * Examples for this is context menu functionality (like import/export) which runs as an independent module through mod.php
862 * FOR USE IN ext_tables.php FILES
863 * Example: t3lib_extMgm::addModulePath('xMOD_tximpexp', t3lib_extMgm::extPath($_EXTKEY).'app/');
864 *
865 * @param string $name is the name of the module, refer to conf.php of the module.
866 * @param string $path is the absolute path to the module directory inside of which "index.php" and "conf.php" is found.
867 * @return void
868 */
869 public static function addModulePath($name, $path) {
870 $GLOBALS['TBE_MODULES']['_PATHS'][$name] = $path;
871 }
872
873 /**
874 * Adds a "Function menu module" ('third level module') to an existing function menu for some other backend module
875 * The arguments values are generally determined by which function menu this is supposed to interact with
876 * See Inside TYPO3 for information on how to use this function.
877 * FOR USE IN ext_tables.php FILES
878 * Usage: 26
879 *
880 * @param string Module name
881 * @param string Class name
882 * @param string Class path
883 * @param string Title of module
884 * @param string Menu array key - default is "function"
885 * @param string Workspace conditions. Blank means all workspaces, any other string can be a comma list of "online", "offline" and "custom"
886 * @return void
887 * @see t3lib_SCbase::mergeExternalItems()
888 */
889 public static function insertModuleFunction($modname, $className, $classPath, $title, $MM_key = 'function', $WS = '') {
890 $GLOBALS['TBE_MODULES_EXT'][$modname]['MOD_MENU'][$MM_key][$className] = array(
891 'name' => $className,
892 'path' => $classPath,
893 'title' => $title,
894 'ws' => $WS
895 );
896 }
897
898 /**
899 * Adds $content to the default Page TSconfig as set in $GLOBALS['TYPO3_CONF_VARS'][BE]['defaultPageTSconfig']
900 * Prefixed with a [GLOBAL] line
901 * FOR USE IN ext_tables.php/ext_localconf.php FILES
902 * Usage: 5
903 *
904 * @param string Page TSconfig content
905 * @return void
906 */
907 public static function addPageTSConfig($content) {
908 $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultPageTSconfig'] .= "\n[GLOBAL]\n" . $content;
909 }
910
911 /**
912 * Adds $content to the default User TSconfig as set in $GLOBALS['TYPO3_CONF_VARS'][BE]['defaultUserTSconfig']
913 * Prefixed with a [GLOBAL] line
914 * FOR USE IN ext_tables.php/ext_localconf.php FILES
915 * Usage: 3
916 *
917 * @param string User TSconfig content
918 * @return void
919 */
920 public static function addUserTSConfig($content) {
921 $GLOBALS['TYPO3_CONF_VARS']['BE']['defaultUserTSconfig'] .= "\n[GLOBAL]\n" . $content;
922 }
923
924 /**
925 * Adds a reference to a locallang file with $GLOBALS['TCA_DESCR'] labels
926 * FOR USE IN ext_tables.php FILES
927 * 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.
928 * Usage: 31
929 *
930 * @param string Description key. Typically a database table (like "pages") but for applications can be other strings, but prefixed with "_MOD_")
931 * @param string File reference to locallang file, eg. "EXT:lang/locallang_csh_pages.php" (or ".xml")
932 * @return void
933 */
934 public static function addLLrefForTCAdescr($tca_descr_key, $file_ref) {
935 if ($tca_descr_key) {
936 if (!is_array($GLOBALS['TCA_DESCR'][$tca_descr_key])) {
937 $GLOBALS['TCA_DESCR'][$tca_descr_key] = array();
938 }
939 if (!is_array($GLOBALS['TCA_DESCR'][$tca_descr_key]['refs'])) {
940 $GLOBALS['TCA_DESCR'][$tca_descr_key]['refs'] = array();
941 }
942 $GLOBALS['TCA_DESCR'][$tca_descr_key]['refs'][] = $file_ref;
943 }
944 }
945
946 /**
947 * Registers a navigation component
948 *
949 * @param string $module
950 * @param string $componentId
951 * @return void
952 */
953 public static function addNavigationComponent($module, $componentId) {
954 $GLOBALS['TBE_MODULES']['_navigationComponents'][$module] = array(
955 'componentId' => $componentId,
956 'extKey' => $GLOBALS['_EXTKEY'],
957 'isCoreComponent' => FALSE,
958 );
959 }
960
961 /**
962 * Registers a core navigation component
963 *
964 * @param string $module
965 * @param string $componentId
966 * @return void
967 */
968 public static function addCoreNavigationComponent($module, $componentId) {
969 self::addNavigationComponent($module, $componentId);
970 $GLOBALS['TBE_MODULES']['_navigationComponents'][$module]['isCoreComponent'] = TRUE;
971 }
972
973
974 /**************************************
975 *
976 * Adding SERVICES features
977 *
978 * @author René Fritz <r.fritz@colorcube.de>
979 *
980 ***************************************/
981
982 /**
983 * Adds a service to the global services array
984 *
985 * @param string Extension key
986 * @param string Service type, must not be prefixed "tx_" or "Tx_"
987 * @param string Service key, must be prefixed "tx_", "Tx_" or "user_"
988 * @param array Service description array
989 * @return void
990 * @author René Fritz <r.fritz@colorcube.de>
991 */
992 public static function addService($extKey, $serviceType, $serviceKey, $info) {
993 // even not available services will be included to make it possible to give the admin a feedback of non-available services.
994 // but maybe it's better to move non-available services to a different array??
995
996 if ($serviceType &&
997 !t3lib_div::hasValidClassPrefix($serviceType) &&
998 t3lib_div::hasValidClassPrefix($serviceKey, array('user_')) &&
999 is_array($info)) {
1000
1001 $info['priority'] = max(0, min(100, $info['priority']));
1002
1003 $GLOBALS['T3_SERVICES'][$serviceType][$serviceKey] = $info;
1004
1005 $GLOBALS['T3_SERVICES'][$serviceType][$serviceKey]['extKey'] = $extKey;
1006 $GLOBALS['T3_SERVICES'][$serviceType][$serviceKey]['serviceKey'] = $serviceKey;
1007 $GLOBALS['T3_SERVICES'][$serviceType][$serviceKey]['serviceType'] = $serviceType;
1008
1009
1010 // mapping a service key to a service type
1011 // all service keys begin with tx_ or Tx_ - service types don't
1012 // this way a selection of a special service key as service type is easy
1013 $GLOBALS['T3_SERVICES'][$serviceKey][$serviceKey] = &$GLOBALS['T3_SERVICES'][$serviceType][$serviceKey];
1014
1015
1016 // change the priority (and other values) from $GLOBALS['TYPO3_CONF_VARS']
1017 // $GLOBALS['TYPO3_CONF_VARS']['T3_SERVICES'][$serviceType][$serviceKey]['priority']
1018 // even the activation is possible (a unix service might be possible on windows for some reasons)
1019 if (is_array($GLOBALS['TYPO3_CONF_VARS']['T3_SERVICES'][$serviceType][$serviceKey])) {
1020
1021 // no check is done here - there might be configuration values only the service type knows about, so
1022 // we pass everything
1023 $GLOBALS['T3_SERVICES'][$serviceType][$serviceKey] = array_merge(
1024 $GLOBALS['T3_SERVICES'][$serviceType][$serviceKey],
1025 $GLOBALS['TYPO3_CONF_VARS']['T3_SERVICES'][$serviceType][$serviceKey]
1026 );
1027 }
1028
1029
1030 // OS check
1031 // empty $os means 'not limited to one OS', therefore a check is not needed
1032 if ($GLOBALS['T3_SERVICES'][$serviceType][$serviceKey]['available']
1033 && $GLOBALS['T3_SERVICES'][$serviceType][$serviceKey]['os'] != '') {
1034
1035 // TYPO3_OS is not yet defined
1036 $os_type = stristr(PHP_OS, 'win') && !stristr(PHP_OS, 'darwin') ? 'WIN' : 'UNIX';
1037
1038 $os = t3lib_div::trimExplode(',', strtoupper($GLOBALS['T3_SERVICES'][$serviceType][$serviceKey]['os']));
1039
1040 if (!in_array($os_type, $os)) {
1041 self::deactivateService($serviceType, $serviceKey);
1042 }
1043 }
1044
1045 // convert subtype list to array for quicker access
1046 $GLOBALS['T3_SERVICES'][$serviceType][$serviceKey]['serviceSubTypes'] = array();
1047 $serviceSubTypes = t3lib_div::trimExplode(',', $info['subtype']);
1048 foreach ($serviceSubTypes as $subtype) {
1049 $GLOBALS['T3_SERVICES'][$serviceType][$serviceKey]['serviceSubTypes'][$subtype] = $subtype;
1050 }
1051 }
1052 }
1053
1054 /**
1055 * Find the available service with highest priority
1056 *
1057 * @param string Service type
1058 * @param string Service sub type
1059 * @param mixed Service keys that should be excluded in the search for a service. Array or comma list.
1060 * @return mixed Service info array if a service was found, FLASE otherwise
1061 * @author René Fritz <r.fritz@colorcube.de>
1062 */
1063 public static function findService($serviceType, $serviceSubType = '', $excludeServiceKeys = array()) {
1064 $serviceKey = FALSE;
1065 $serviceInfo = FALSE;
1066 $priority = 0;
1067 $quality = 0;
1068
1069 if (!is_array($excludeServiceKeys)) {
1070 $excludeServiceKeys = t3lib_div::trimExplode(',', $excludeServiceKeys, 1);
1071 }
1072
1073 if (is_array($GLOBALS['T3_SERVICES'][$serviceType])) {
1074 foreach ($GLOBALS['T3_SERVICES'][$serviceType] as $key => $info) {
1075
1076 if (in_array($key, $excludeServiceKeys)) {
1077 continue;
1078 }
1079
1080 // select a subtype randomly
1081 // usefull to start a service by service key without knowing his subtypes - for testing purposes
1082 if ($serviceSubType == '*') {
1083 $serviceSubType = key($info['serviceSubTypes']);
1084 }
1085
1086 // this matches empty subtype too
1087 if ($info['available'] && ($info['subtype'] == $serviceSubType || $info['serviceSubTypes'][$serviceSubType]) && $info['priority'] >= $priority) {
1088
1089 // has a lower quality than the already found, therefore we skip this service
1090 if ($info['priority'] == $priority && $info['quality'] < $quality) {
1091 continue;
1092 }
1093
1094 // service depends on external programs - check if they exists
1095 if (trim($info['exec'])) {
1096 $executables = t3lib_div::trimExplode(',', $info['exec'], 1);
1097 foreach ($executables as $executable) {
1098 if (!t3lib_exec::checkCommand($executable)) {
1099 self::deactivateService($serviceType, $key);
1100 $info['available'] = FALSE;
1101 break;
1102 }
1103 }
1104 }
1105
1106 // still available after exec check?
1107 if ($info['available']) {
1108 $serviceKey = $key;
1109 $priority = $info['priority'];
1110 $quality = $info['quality'];
1111 }
1112 }
1113 }
1114 }
1115
1116 if ($serviceKey) {
1117 $serviceInfo = $GLOBALS['T3_SERVICES'][$serviceType][$serviceKey];
1118 }
1119 return $serviceInfo;
1120 }
1121
1122 /**
1123 * Deactivate a service
1124 *
1125 * @param string Service type
1126 * @param string Service key
1127 * @return void
1128 * @author René Fritz <r.fritz@colorcube.de>
1129 */
1130 public static function deactivateService($serviceType, $serviceKey) {
1131 // ... maybe it's better to move non-available services to a different array??
1132 $GLOBALS['T3_SERVICES'][$serviceType][$serviceKey]['available'] = FALSE;
1133 }
1134
1135
1136 /**************************************
1137 *
1138 * Adding FRONTEND features
1139 * (related specifically to "cms" extension)
1140 *
1141 ***************************************/
1142
1143 /**
1144 * Adds an entry to the list of plugins in content elements of type "Insert plugin"
1145 * 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)
1146 * 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.
1147 * 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
1148 * FOR USE IN ext_tables.php FILES
1149 * Usage: 13
1150 *
1151 * @param array Item Array
1152 * @param string Type (eg. "list_type") - basically a field from "tt_content" table
1153 * @return void
1154 */
1155 public static function addPlugin($itemArray, $type = 'list_type') {
1156 $_EXTKEY = $GLOBALS['_EXTKEY'];
1157 if ($_EXTKEY && !$itemArray[2]) {
1158 $itemArray[2] = self::extRelPath($_EXTKEY) . 'ext_icon.gif';
1159 }
1160
1161 t3lib_div::loadTCA('tt_content');
1162 if (is_array($GLOBALS['TCA']['tt_content']['columns']) && is_array($GLOBALS['TCA']['tt_content']['columns'][$type]['config']['items'])) {
1163 foreach ($GLOBALS['TCA']['tt_content']['columns'][$type]['config']['items'] as $k => $v) {
1164 if (!strcmp($v[1], $itemArray[1])) {
1165 $GLOBALS['TCA']['tt_content']['columns'][$type]['config']['items'][$k] = $itemArray;
1166 return;
1167 }
1168 }
1169 $GLOBALS['TCA']['tt_content']['columns'][$type]['config']['items'][] = $itemArray;
1170 }
1171 }
1172
1173 /**
1174 * Adds an entry to the "ds" array of the tt_content field "pi_flexform".
1175 * This is used by plugins to add a flexform XML reference / content for use when they are selected as plugin or content element.
1176 * Usage: 0
1177 *
1178 * @param string Plugin key as used in the list_type field. Use the asterisk * to match all list_type values.
1179 * @param string Either a reference to a flex-form XML file (eg. "FILE:EXT:newloginbox/flexform_ds.xml") or the XML directly.
1180 * @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.
1181 * @return void
1182 * @see addPlugin()
1183 */
1184 public static function addPiFlexFormValue($piKeyToMatch, $value, $CTypeToMatch = 'list') {
1185 t3lib_div::loadTCA('tt_content');
1186
1187 if (is_array($GLOBALS['TCA']['tt_content']['columns']) && is_array($GLOBALS['TCA']['tt_content']['columns']['pi_flexform']['config']['ds'])) {
1188 $GLOBALS['TCA']['tt_content']['columns']['pi_flexform']['config']['ds'][$piKeyToMatch . ',' . $CTypeToMatch] = $value;
1189 }
1190 }
1191
1192 /**
1193 * Adds the $table tablename to the list of tables allowed to be includes by content element type "Insert records"
1194 * By using $content_table and $content_field you can also use the function for other tables.
1195 * FOR USE IN ext_tables.php FILES
1196 * Usage: 9
1197 *
1198 * @param string Table name to allow for "insert record"
1199 * @param string Table name TO WHICH the $table name is applied. See $content_field as well.
1200 * @param string Field name in the database $content_table in which $table is allowed to be added as a reference ("Insert Record")
1201 * @return void
1202 */
1203 public static function addToInsertRecords($table, $content_table = 'tt_content', $content_field = 'records') {
1204 t3lib_div::loadTCA($content_table);
1205 if (is_array($GLOBALS['TCA'][$content_table]['columns']) && isset($GLOBALS['TCA'][$content_table]['columns'][$content_field]['config']['allowed'])) {
1206 $GLOBALS['TCA'][$content_table]['columns'][$content_field]['config']['allowed'] .= ',' . $table;
1207 }
1208 }
1209
1210 /**
1211 * Add PlugIn to Static Template #43
1212 *
1213 * 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.
1214 * 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"
1215 * $type determines the type of frontend plugin:
1216 * "list_type" (default) - the good old "Insert plugin" entry
1217 * "menu_type" - a "Menu/Sitemap" entry
1218 * "splash_layout" - a "Textbox" entry
1219 * "CType" - a new content element type
1220 * "header_layout" - an additional header type (added to the selection of layout1-5)
1221 * "includeLib" - just includes the library for manual use somewhere in TypoScript.
1222 * (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)
1223 * FOR USE IN ext_localconf.php FILES
1224 * Usage: 2
1225 *
1226 * @param string $key is the extension key
1227 * @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.
1228 * @param string $prefix is used as a - yes, suffix - of the class name (fx. "_pi1")
1229 * @param string $type, see description above
1230 * @param boolean If $cached is set as USER content object (cObject) is created - otherwise a USER_INT object is created.
1231 * @return void
1232 */
1233 public static function addPItoST43($key, $classFile = '', $prefix = '', $type = 'list_type', $cached = 0) {
1234 $classFile = $classFile ? $classFile : 'pi/class.tx_' . str_replace('_', '', $key) . $prefix . '.php';
1235 $cN = self::getCN($key);
1236
1237 // General plugin:
1238 $pluginContent = trim('
1239 plugin.' . $cN . $prefix . ' = USER' . ($cached ? '' : '_INT') . '
1240 plugin.' . $cN . $prefix . ' {
1241 includeLibs = ' . $GLOBALS['TYPO3_LOADED_EXT'][$key]['siteRelPath'] . $classFile . '
1242 userFunc = ' . $cN . $prefix . '->main
1243 }');
1244 self::addTypoScript($key, 'setup', '
1245 # Setting ' . $key . ' plugin TypoScript
1246 ' . $pluginContent);
1247
1248 // After ST43:
1249 switch ($type) {
1250 case 'list_type':
1251 $addLine = 'tt_content.list.20.' . $key . $prefix . ' = < plugin.' . $cN . $prefix;
1252 break;
1253 case 'menu_type':
1254 $addLine = 'tt_content.menu.20.' . $key . $prefix . ' = < plugin.' . $cN . $prefix;
1255 break;
1256 case 'splash_layout':
1257 $addLine = 'tt_content.splash.' . $key . $prefix . ' = < plugin.' . $cN . $prefix;
1258 break;
1259 case 'CType':
1260 $addLine = trim('
1261 tt_content.' . $key . $prefix . ' = COA
1262 tt_content.' . $key . $prefix . ' {
1263 10 = < lib.stdheader
1264 20 = < plugin.' . $cN . $prefix . '
1265 }
1266 ');
1267 break;
1268 case 'header_layout':
1269 $addLine = 'lib.stdheader.10.' . $key . $prefix . ' = < plugin.' . $cN . $prefix;
1270 break;
1271 case 'includeLib':
1272 $addLine = 'page.1000 = < plugin.' . $cN . $prefix;
1273 break;
1274 default:
1275 $addLine = '';
1276 break;
1277 }
1278 if ($addLine) {
1279 self::addTypoScript($key, 'setup', '
1280 # Setting ' . $key . ' plugin TypoScript
1281 ' . $addLine . '
1282 ', 43);
1283 }
1284 }
1285
1286 /**
1287 * Call this method to add an entry in the static template list found in sys_templates
1288 * "static template files" are the modern equivalent (provided from extensions) to the traditional records in "static_templates"
1289 * FOR USE IN ext_localconf.php FILES
1290 * Usage: 3
1291 *
1292 * @param string $extKey is of course the extension key
1293 * @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/
1294 * @param string $title is the title in the selector box.
1295 * @return void
1296 * @see addTypoScript()
1297 */
1298 public static function addStaticFile($extKey, $path, $title) {
1299 t3lib_div::loadTCA('sys_template');
1300 if ($extKey && $path && is_array($GLOBALS['TCA']['sys_template']['columns'])) {
1301 $value = str_replace(',', '', 'EXT:' . $extKey . '/' . $path);
1302 $itemArray = array(trim($title . ' (' . $extKey . ')'), $value);
1303 $GLOBALS['TCA']['sys_template']['columns']['include_static_file']['config']['items'][] = $itemArray;
1304 }
1305 }
1306
1307 /**
1308 * Adds $content to the default TypoScript setup code as set in $GLOBALS['TYPO3_CONF_VARS'][FE]['defaultTypoScript_setup']
1309 * Prefixed with a [GLOBAL] line
1310 * FOR USE IN ext_localconf.php FILES
1311 * Usage: 6
1312 *
1313 * @param string TypoScript Setup string
1314 * @return void
1315 */
1316 public static function addTypoScriptSetup($content) {
1317 $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_setup'] .= "\n[GLOBAL]\n" . $content;
1318 }
1319
1320 /**
1321 * Adds $content to the default TypoScript constants code as set in $GLOBALS['TYPO3_CONF_VARS'][FE]['defaultTypoScript_constants']
1322 * Prefixed with a [GLOBAL] line
1323 * FOR USE IN ext_localconf.php FILES
1324 * Usage: 0
1325 *
1326 * @param string TypoScript Constants string
1327 * @return void
1328 */
1329 public static function addTypoScriptConstants($content) {
1330 $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_constants'] .= "\n[GLOBAL]\n" . $content;
1331 }
1332
1333 /**
1334 * Adds $content to the default TypoScript code for either setup, constants or editorcfg as set in $GLOBALS['TYPO3_CONF_VARS'][FE]['defaultTypoScript_*']
1335 * (Basically this function can do the same as addTypoScriptSetup and addTypoScriptConstants - just with a little more hazzle, but also with some more options!)
1336 * FOR USE IN ext_localconf.php FILES
1337 * Usage: 7
1338 *
1339 * @param string $key is the extension key (informative only).
1340 * @param string $type is either "setup", "constants" or "editorcfg" and obviously determines which kind of TypoScript code we are adding.
1341 * @param string $content is the TS content, prefixed with a [GLOBAL] line and a comment-header.
1342 * @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.
1343 * @return void
1344 */
1345 public static function addTypoScript($key, $type, $content, $afterStaticUid = 0) {
1346 if ($type == 'setup' || $type == 'editorcfg' || $type == 'constants') {
1347 $content = '
1348
1349 [GLOBAL]
1350 #############################################
1351 ## TypoScript added by extension "' . $key . '"
1352 #############################################
1353
1354 ' . $content;
1355 if ($afterStaticUid) {
1356 $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_' . $type . '.'][$afterStaticUid] .= $content;
1357 // If 'content (default)' is targeted, also add to other 'content rendering templates', eg. css_styled_content
1358 if ($afterStaticUid == 43 && is_array($GLOBALS['TYPO3_CONF_VARS']['FE']['contentRenderingTemplates'])) {
1359 foreach ($GLOBALS['TYPO3_CONF_VARS']['FE']['contentRenderingTemplates'] as $templateName) {
1360 $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_' . $type . '.'][$templateName] .= $content;
1361 }
1362 }
1363 } else {
1364 $GLOBALS['TYPO3_CONF_VARS']['FE']['defaultTypoScript_' . $type] .= $content;
1365 }
1366 }
1367 }
1368
1369
1370 /**************************************
1371 *
1372 * INTERNAL EXTENSION MANAGEMENT:
1373 *
1374 ***************************************/
1375
1376 /**
1377 * Loading extensions configured in $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList']
1378 *
1379 * CACHING ON: ($GLOBALS['TYPO3_CONF_VARS']['EXT']['extCache'] = 1)
1380 * 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.
1381 * If cachefiles are not found they will be generated
1382 * CACHING OFF: ($GLOBALS['TYPO3_CONF_VARS']['EXT']['extCache'] = 0)
1383 * 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.
1384 * This array will later be set in the global var $GLOBALS['TYPO3_LOADED_EXT']
1385 *
1386 * Usages of this function can be seen in config_default.php
1387 * Extensions are always detected in the order local - global - system.
1388 * Usage: 1
1389 *
1390 * @return array Extension Array
1391 * @internal
1392 */
1393 public static function typo3_loadExtensions() {
1394
1395 // Caching behaviour of ext_tables.php and ext_localconf.php files:
1396 $extensionCacheBehaviour = self::getExtensionCacheBehaviour();
1397 // Full list of extensions includes both required and extList:
1398 $rawExtList = self::getEnabledExtensionList();
1399
1400 // Empty array as a start.
1401 $extensions = array();
1402
1403 //
1404 if ($rawExtList) {
1405 // The cached File prefix.
1406 $cacheFilePrefix = self::getCacheFilePrefix();
1407
1408 // If cache files available, set cache file prefix and return:
1409 if ($extensionCacheBehaviour && self::isCacheFilesAvailable($cacheFilePrefix)) {
1410 // Return cache file prefix:
1411 $extensions['_CACHEFILE'] = $cacheFilePrefix;
1412 } else { // ... but if not, configure...
1413
1414 // Prepare reserved filenames:
1415 $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');
1416 // Traverse extensions and check their existence:
1417 clearstatcache(); // Clear file state cache to make sure we get good results from is_dir()
1418 $temp_extensions = array_unique(t3lib_div::trimExplode(',', $rawExtList, 1));
1419 foreach ($temp_extensions as $temp_extKey) {
1420 // Check local, global and system locations:
1421 if (@is_dir(PATH_typo3conf . 'ext/' . $temp_extKey . '/')) {
1422 $extensions[$temp_extKey] = array('type' => 'L', 'siteRelPath' => 'typo3conf/ext/' . $temp_extKey . '/', 'typo3RelPath' => '../typo3conf/ext/' . $temp_extKey . '/');
1423 } elseif (@is_dir(PATH_typo3 . 'ext/' . $temp_extKey . '/')) {
1424 $extensions[$temp_extKey] = array('type' => 'G', 'siteRelPath' => TYPO3_mainDir . 'ext/' . $temp_extKey . '/', 'typo3RelPath' => 'ext/' . $temp_extKey . '/');
1425 } elseif (@is_dir(PATH_typo3 . 'sysext/' . $temp_extKey . '/')) {
1426 $extensions[$temp_extKey] = array('type' => 'S', 'siteRelPath' => TYPO3_mainDir . 'sysext/' . $temp_extKey . '/', 'typo3RelPath' => 'sysext/' . $temp_extKey . '/');
1427 }
1428
1429 // If extension was found, check for reserved filenames:
1430 if (isset($extensions[$temp_extKey])) {
1431 foreach ($files as $fName) {
1432 $temp_filename = PATH_site . $extensions[$temp_extKey]['siteRelPath'] . trim($fName);
1433 if (is_array($extensions[$temp_extKey]) && @is_file($temp_filename)) {
1434 $extensions[$temp_extKey][$fName] = $temp_filename;
1435 }
1436 }
1437 }
1438 }
1439 unset($extensions['_CACHEFILE']);
1440
1441 // write cache?
1442 if ($extensionCacheBehaviour &&
1443 @is_dir(PATH_typo3 . 'sysext/') &&
1444 @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!
1445 $wrError = self::cannotCacheFilesWritable($cacheFilePrefix);
1446 if ($wrError) {
1447 $GLOBALS['TYPO3_CONF_VARS']['EXT']['extCache'] = 0;
1448 } else {
1449 // Write cache files:
1450 $extensions = self::writeCacheFiles($extensions, $cacheFilePrefix);
1451 }
1452 }
1453 }
1454 }
1455
1456 return $extensions;
1457 }
1458
1459 /**
1460 * Returns the section headers for the compiled cache-files.
1461 *
1462 * @param string $key is the extension key
1463 * @param string $file is the filename (only informative for comment)
1464 * @return string
1465 * @internal
1466 */
1467 public static function _makeIncludeHeader($key, $file) {
1468 return '<?php
1469 ###########################
1470 ## EXTENSION: ' . $key . '
1471 ## FILE: ' . $file . '
1472 ###########################
1473
1474 $_EXTKEY = \'' . $key . '\';
1475 $_EXTCONF = $GLOBALS[\'TYPO3_CONF_VARS\'][\'EXT\'][\'extConf\'][$_EXTKEY];
1476
1477 ?>';
1478 }
1479
1480 /**
1481 * Returns TRUE if both the localconf and tables cache file exists (with $cacheFilePrefix)
1482 * Usage: 2
1483 *
1484 * @param string Prefix of the cache file to check
1485 * @return boolean
1486 * @internal
1487 */
1488 public static function isCacheFilesAvailable($cacheFilePrefix) {
1489 return
1490 @is_file(PATH_typo3conf . $cacheFilePrefix . '_ext_localconf.php') &&
1491 @is_file(PATH_typo3conf . $cacheFilePrefix . '_ext_tables.php');
1492 }
1493
1494 /**
1495 * Returns TRUE if the "localconf.php" file in "typo3conf/" is writable
1496 * Usage: 1
1497 *
1498 * @return boolean
1499 * @internal
1500 */
1501 public static function isLocalconfWritable() {
1502 return @is_writable(PATH_typo3conf) && @is_writable(PATH_typo3conf . 'localconf.php');
1503 }
1504
1505 /**
1506 * Returns an error string if typo3conf/ or cache-files with $cacheFilePrefix are NOT writable
1507 * Returns FALSE if no problem.
1508 * Usage: 1
1509 *
1510 * @param string Prefix of the cache file to check
1511 * @return string
1512 * @internal
1513 */
1514 public static function cannotCacheFilesWritable($cacheFilePrefix) {
1515 $error = array();
1516 if (!@is_writable(PATH_typo3conf)) {
1517 $error[] = PATH_typo3conf;
1518 }
1519 if (@is_file(PATH_typo3conf . $cacheFilePrefix . '_ext_localconf.php') &&
1520 !@is_writable(PATH_typo3conf . $cacheFilePrefix . '_ext_localconf.php')) {
1521 $error[] = PATH_typo3conf . $cacheFilePrefix . '_ext_localconf.php';
1522 }
1523 if (@is_file(PATH_typo3conf . $cacheFilePrefix . '_ext_tables.php') &&
1524 !@is_writable(PATH_typo3conf . $cacheFilePrefix . '_ext_tables.php')) {
1525 $error[] = PATH_typo3conf . $cacheFilePrefix . '_ext_tables.php';
1526 }
1527 return implode(', ', $error);
1528 }
1529
1530 /**
1531 * Returns an array with the two cache-files (0=>localconf, 1=>tables) from typo3conf/ if they (both) exist. Otherwise FALSE.
1532 * Evaluation relies on $GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE']
1533 * Usage: 2
1534 *
1535 * @param string $cacheFilePrefix Cache file prefix to be used (optional)
1536 * @return array
1537 * @internal
1538 */
1539 public static function currentCacheFiles($cacheFilePrefix = NULL) {
1540 if (is_null($cacheFilePrefix)) {
1541 $cacheFilePrefix = $GLOBALS['TYPO3_LOADED_EXT']['_CACHEFILE'];
1542 }
1543
1544 if ($cacheFilePrefix) {
1545 $cacheFilePrefixFE = str_replace('temp_CACHED', 'temp_CACHED_FE', $cacheFilePrefix);
1546 $files = array();
1547 if (self::isCacheFilesAvailable($cacheFilePrefix)) {
1548 $files[] = PATH_typo3conf . $cacheFilePrefix . '_ext_localconf.php';
1549 $files[] = PATH_typo3conf . $cacheFilePrefix . '_ext_tables.php';
1550 }
1551 if (self::isCacheFilesAvailable($cacheFilePrefixFE)) {
1552 $files[] = PATH_typo3conf . $cacheFilePrefixFE . '_ext_localconf.php';
1553 $files[] = PATH_typo3conf . $cacheFilePrefixFE . '_ext_tables.php';
1554 }
1555 if (!empty($files)) {
1556 return $files;
1557 }
1558 }
1559 }
1560
1561 /**
1562 * Compiles/Creates the two cache-files in typo3conf/ based on $cacheFilePrefix
1563 * Returns a array with the key "_CACHEFILE" set to the $cacheFilePrefix value
1564 * Usage: 1
1565 *
1566 * @param array Extension information array
1567 * @param string Prefix for the cache files
1568 * @return array
1569 * @internal
1570 */
1571 public static function writeCacheFiles($extensions, $cacheFilePrefix) {
1572 // Making cache files:
1573 $extensions['_CACHEFILE'] = $cacheFilePrefix;
1574 $cFiles = array();
1575 $cFiles['ext_localconf'] .= '<?php
1576
1577 $GLOBALS[\'TYPO3_LOADED_EXT\'] = unserialize(stripslashes(\'' . addslashes(serialize($extensions)) . '\'));
1578
1579 ?>';
1580
1581 foreach ($extensions as $key => $conf) {
1582 if (is_array($conf)) {
1583 if ($conf['ext_localconf.php']) {
1584 $cFiles['ext_localconf'] .= self::_makeIncludeHeader($key, $conf['ext_localconf.php']);
1585 $cFiles['ext_localconf'] .= trim(t3lib_div::getUrl($conf['ext_localconf.php']));
1586 }
1587 if ($conf['ext_tables.php']) {
1588 $cFiles['ext_tables'] .= self::_makeIncludeHeader($key, $conf['ext_tables.php']);
1589 $cFiles['ext_tables'] .= trim(t3lib_div::getUrl($conf['ext_tables.php']));
1590 }
1591 }
1592 }
1593
1594 $cFiles['ext_localconf'] = "<?php\n" . preg_replace('/<\?php|\?>/is', '', $cFiles['ext_localconf']) . "?>\n";
1595 $cFiles['ext_tables'] = "<?php\n" . preg_replace('/<\?php|\?>/is', '', $cFiles['ext_tables']) . "?>\n";
1596
1597 t3lib_div::writeFile(PATH_typo3conf . $cacheFilePrefix . '_ext_localconf.php', $cFiles['ext_localconf']);
1598 t3lib_div::writeFile(PATH_typo3conf . $cacheFilePrefix . '_ext_tables.php', $cFiles['ext_tables']);
1599
1600 $extensions = array();
1601 $extensions['_CACHEFILE'] = $cacheFilePrefix;
1602
1603 return $extensions;
1604 }
1605
1606 /**
1607 * Unlink (delete) cache files
1608 *
1609 * @param string $cacheFilePrefix Cache file prefix to be used (optional)
1610 * @return integer Number of deleted files.
1611 */
1612 public static function removeCacheFiles($cacheFilePrefix = NULL) {
1613 $cacheFiles = self::currentCacheFiles($cacheFilePrefix);
1614
1615 $out = 0;
1616 if (is_array($cacheFiles)) {
1617 foreach ($cacheFiles as $cfile) {
1618 @unlink($cfile);
1619 clearstatcache();
1620 $out++;
1621 }
1622 }
1623 return $out;
1624 }
1625
1626 /**
1627 * Gets the behaviour for caching ext_tables.php and ext_localconf.php files
1628 * (see $GLOBALS['TYPO3_CONF_VARS']['EXT']['extCache'] setting in the install tool).
1629 *
1630 * @param boolean $usePlainValue Whether to use the value as it is without modifications
1631 * @return integer
1632 */
1633 public static function getExtensionCacheBehaviour($usePlainValue = FALSE) {
1634 $extensionCacheBehaviour = intval($GLOBALS['TYPO3_CONF_VARS']['EXT']['extCache']);
1635
1636 // Caching of extensions is disabled when install tool is used:
1637 if (!$usePlainValue && defined('TYPO3_enterInstallScript') && TYPO3_enterInstallScript) {
1638 $extensionCacheBehaviour = 0;
1639 }
1640
1641 return $extensionCacheBehaviour;
1642 }
1643
1644 /**
1645 * Gets the prefix used for the ext_tables.php and ext_localconf.php cached files.
1646 *
1647 * @return string
1648 */
1649 public static function getCacheFilePrefix() {
1650 $extensionCacheBehaviour = self::getExtensionCacheBehaviour(TRUE);
1651
1652 $cacheFileSuffix = (TYPO3_MODE == 'FE' ? '_FE' : '');
1653 $cacheFilePrefix = 'temp_CACHED' . $cacheFileSuffix;
1654
1655 if ($extensionCacheBehaviour) {
1656 $cacheFilePrefix .= '_ps' . substr(t3lib_div::shortMD5(PATH_site . '|' . $GLOBALS['TYPO_VERSION']), 0, 4);
1657 }
1658
1659 return $cacheFilePrefix;
1660 }
1661
1662 /**
1663 * Gets the list of enabled extensions for the accordant context (frontend or backend).
1664 *
1665 * @return string
1666 */
1667 public static function getEnabledExtensionList() {
1668 // Select mode how to load extensions in order to speed up the FE
1669 if (TYPO3_MODE == 'FE') {
1670 if (!($extLoadInContext = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList_FE'])) {
1671 // fall back to standard 'extList' if 'extList_FE' is not (yet) set
1672 $extLoadInContext = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList'];
1673 }
1674 } else {
1675 $extLoadInContext = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extList'];
1676 }
1677
1678 $extensionList = self::getRequiredExtensionList() . ',' . $extLoadInContext;
1679 $ignoredExtensionList = self::getIgnoredExtensionList();
1680
1681 // Remove the extensions to be ignored:
1682 if ($ignoredExtensionList && (defined('TYPO3_enterInstallScript') && TYPO3_enterInstallScript) === FALSE) {
1683 $extensions = array_diff(
1684 explode(',', $extensionList),
1685 explode(',', $ignoredExtensionList)
1686 );
1687 $extensionList = implode(',', $extensions);
1688 }
1689
1690 return $extensionList;
1691 }
1692
1693 /**
1694 * Gets the list of required extensions.
1695 *
1696 * @return string
1697 */
1698 public static function getRequiredExtensionList() {
1699 $requiredExtensionList = t3lib_div::uniqueList(
1700 REQUIRED_EXTENSIONS . ',' . $GLOBALS['TYPO3_CONF_VARS']['EXT']['requiredExt']
1701 );
1702
1703 return $requiredExtensionList;
1704 }
1705
1706 /**
1707 * Gets the list of extensions to be ignored (not to be loaded).
1708 *
1709 * @return string
1710 */
1711 public static function getIgnoredExtensionList() {
1712 $ignoredExtensionList = t3lib_div::uniqueList(
1713 $GLOBALS['TYPO3_CONF_VARS']['EXT']['ignoredExt']
1714 );
1715
1716 return $ignoredExtensionList;
1717 }
1718 }
1719
1720 ?>