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