Post cleanup of topapps, some parts were not removed with Changeset 2908
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_extmgm.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2006 Kasper Skaarhoj (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 * $Id$
31 * Revised for TYPO3 3.6 July/2003 by Kasper Skaarhoj
32 *
33 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
34 */
35 /**
36 * [CLASS/FUNCTION INDEX of SCRIPT]
37 *
38 *
39 *
40 * 114: class t3lib_extMgm
41 *
42 * SECTION: PATHS and other evaluation
43 * 131: function isLoaded($key,$exitOnError=0)
44 * 147: function extPath($key,$script='')
45 * 165: function extRelPath($key)
46 * 182: function siteRelPath($key)
47 * 194: function getCN($key)
48 *
49 * SECTION: Adding BACKEND features
50 * 227: function addTCAcolumns($table,$columnArray,$addTofeInterface=0)
51 * 251: function addToAllTCAtypes($table,$str,$specificTypesList='',$position='')
52 * 309: function allowTableOnStandardPages($table)
53 * 326: function addModule($main,$sub='',$position='',$path='')
54 * 389: function insertModuleFunction($modname,$className,$classPath,$title,$MM_key='function',$WS='')
55 * 408: function addPageTSConfig($content)
56 * 422: function addUserTSConfig($content)
57 * 437: function addLLrefForTCAdescr($tca_descr_key,$file_ref)
58 *
59 * SECTION: Adding SERVICES features
60 * 479: function addService($extKey, $serviceType, $serviceKey, $info)
61 * 547: function findService($serviceType, $serviceSubType='', $excludeServiceKeys=array())
62 * 618: function deactivateService($serviceType, $serviceKey)
63 *
64 * SECTION: Adding FRONTEND features
65 * 657: function addPlugin($itemArray,$type='list_type')
66 * 682: function addPiFlexFormValue($piKeyToMatch,$value)
67 * 702: function addToInsertRecords($table,$content_table='tt_content',$content_field='records')
68 * 733: function addPItoST43($key,$classFile='',$prefix='',$type='list_type',$cached=0)
69 * 808: function addStaticFile($extKey,$path,$title)
70 * 827: function addTypoScriptSetup($content)
71 * 841: function addTypoScriptConstants($content)
72 * 858: function addTypoScript($key,$type,$content,$afterStaticUid=0)
73 *
74 * SECTION: INTERNAL EXTENSION MANAGEMENT:
75 * 921: function typo3_loadExtensions()
76 * 998: function _makeIncludeHeader($key,$file)
77 * 1019: function isCacheFilesAvailable($cacheFilePrefix)
78 * 1032: function isLocalconfWritable()
79 * 1045: function cannotCacheFilesWritable($cacheFilePrefix)
80 * 1069: function currentCacheFiles()
81 * 1092: function writeCacheFiles($extensions,$cacheFilePrefix)
82 * 1130: function removeCacheFiles()
83 *
84 * TOTAL FUNCTIONS: 32
85 * (This index is automatically created/updated by the extension "extdeveval")
86 *
87 */
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104 /**
105 * Extension Management functions
106 *
107 * This class is never instantiated, rather the methods inside is called as functions like
108 * t3lib_extMgm::isLoaded('my_extension');
109 *
110 * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
111 * @package TYPO3
112 * @subpackage t3lib
113 */
114 class t3lib_extMgm {
115
116
117 /**************************************
118 *
119 * PATHS and other evaluation
120 *
121 ***************************************/
122
123 /**
124 * Returns true if the extension with extension key $key is loaded.
125 * Usage: 109
126 *
127 * @param string Extension key to test
128 * @param boolean If $exitOnError is true and the extension is not loaded the function will die with an error message
129 * @return boolean
130 */
131 function isLoaded($key,$exitOnError=0) {
132 global $TYPO3_LOADED_EXT;
133 if ($exitOnError && !isset($TYPO3_LOADED_EXT[$key])) die('Fatal Error: Extension "'.$key.'" was not loaded.');
134 return isset($TYPO3_LOADED_EXT[$key]);
135 }
136
137 /**
138 * Returns the absolute path to the extension with extension key $key
139 * If the extension is not loaded the function will die with an error message
140 * Useful for internal fileoperations
141 * Usage: 136
142 *
143 * @param string Extension key
144 * @param string $script is appended to the output if set.
145 * @return string
146 */
147 function extPath($key,$script='') {
148 global $TYPO3_LOADED_EXT;
149 if (!isset($TYPO3_LOADED_EXT[$key])) {
150 #debug(array(debug_backtrace()));
151 die('TYPO3 Fatal Error: Extension key "'.$key.'" was NOT loaded! (t3lib_extMgm::extPath)');
152 }
153 return PATH_site.$TYPO3_LOADED_EXT[$key]['siteRelPath'].$script;
154 }
155
156 /**
157 * Returns the relative path to the extension as measured from from the TYPO3_mainDir
158 * If the extension is not loaded the function will die with an error message
159 * Useful for images and links from backend
160 * Usage: 54
161 *
162 * @param string Extension key
163 * @return string
164 */
165 function extRelPath($key) {
166 global $TYPO3_LOADED_EXT;
167 if (!isset($TYPO3_LOADED_EXT[$key])) {
168 die('TYPO3 Fatal Error: Extension key "'.$key.'" was NOT loaded! (t3lib_extMgm::extRelPath)');
169 }
170 return $TYPO3_LOADED_EXT[$key]['typo3RelPath'];
171 }
172
173 /**
174 * Returns the relative path to the extension as measured from the PATH_site (frontend)
175 * If the extension is not loaded the function will die with an error message
176 * Useful for images and links from the frontend
177 * Usage: 6
178 *
179 * @param string Extension key
180 * @return string
181 */
182 function siteRelPath($key) {
183 return substr(t3lib_extMgm::extPath($key),strlen(PATH_site));
184 }
185
186 /**
187 * Returns the correct class name prefix for the extension key $key
188 * Usage: 3
189 *
190 * @param string Extension key
191 * @return string
192 * @internal
193 */
194 function getCN($key) {
195 return substr($key,0,5)=='user_' ? 'user_'.str_replace('_','',substr($key,5)) : 'tx_'.str_replace('_','',$key);
196 }
197
198
199
200
201
202
203
204
205
206
207 /**************************************
208 *
209 * Adding BACKEND features
210 * (related to core features)
211 *
212 ***************************************/
213
214 /**
215 * Adding fields to an existing table definition in $TCA
216 * Adds an array with $TCA column-configuration to the $TCA-entry for that table.
217 * 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!
218 * So to have the fields displayed you must also call fx. addToAllTCAtypes or manually add the fields to the types list.
219 * FOR USE IN ext_tables.php FILES
220 * Usage: 4
221 *
222 * @param string $table is the table name of a table already present in $TCA with a columns section
223 * @param array $columnArray is the array with the additional columns (typical some fields an extension wants to add)
224 * @param boolean If $addTofeInterface is true the list of fields are also added to the fe_admin_fieldList.
225 * @return void
226 */
227 function addTCAcolumns($table,$columnArray,$addTofeInterface=0) {
228 global $TCA;
229 t3lib_div::loadTCA($table);
230 if (is_array($columnArray) && is_array($TCA[$table]) && is_array($TCA[$table]['columns'])) {
231 $TCA[$table]['columns'] = array_merge($TCA[$table]['columns'],$columnArray); // Candidate for t3lib_div::array_merge() if integer-keys will some day make trouble...
232 if ($addTofeInterface) $TCA[$table]['feInterface']['fe_admin_fieldList'].=','.implode(',',array_keys($columnArray));
233 }
234 }
235
236 /**
237 * Makes fields visible in the TCEforms, adding them to the end of (all) "types"-configurations
238 *
239 * Adds a string $str (comma list of field names) to all ["types"][xxx]["showitem"] entries for table $table (unless limited by $specificTypesList)
240 * This is needed to have new fields shown automatically in the TCEFORMS of a record from $table.
241 * Typically this function is called after having added new columns (database fields) with the addTCAcolumns function
242 * FOR USE IN ext_tables.php FILES
243 * Usage: 1
244 *
245 * @param string Table name
246 * @param string Field list to add.
247 * @param string List of specific types to add the field list to. (If empty, all type entries are affected)
248 * @param string Insert fields before (default) or after one of this fields (commalist with "before:" or "after:" commands). Example: "before:keywords,--palette--;;4,after:description". Palettes must be passed like in the example no matter how the palette definition looks like in TCA.
249 * @return void
250 */
251 function addToAllTCAtypes($table,$str,$specificTypesList='',$position='') {
252 global $TCA;
253
254 $positionArr=t3lib_div::trimExplode(',',$position,1);
255 $insert=count($position);
256
257 t3lib_div::loadTCA($table);
258 $str = trim($str);
259 if ($str && is_array($TCA[$table]) && is_array($TCA[$table]['types'])) {
260 foreach($TCA[$table]['types'] as $k => $v) {
261 if ($specificTypesList === '' || t3lib_div::inList($specificTypesList,$k)) {
262 if ($insert) {
263 if (count($positionArr)) {
264 $append=true;
265 $showItem = t3lib_div::trimExplode(',',$TCA[$table]['types'][$k]['showitem'],1);
266 foreach($showItem as $key => $fieldInfo) {
267
268 $parts = explode(';',$fieldInfo);
269 $theField = trim($parts[0]);
270 $palette = trim($parts[0]).';;'.trim($parts[2]);
271
272 // insert before: find exact field name or palette with number
273 if (in_array($theField, $positionArr) || in_array($palette, $positionArr) || in_array('before:'.$theField, $positionArr) || in_array('before:'.$palette, $positionArr)) {
274 $showItem[$key]=$str.', '.$fieldInfo;
275 $append=false;
276 break;
277 }
278 // insert after
279 if (in_array('after:'.$theField, $positionArr) || in_array('after:'.$palette, $positionArr)) {
280 $showItem[$key]=$fieldInfo.', '.$str;
281 $append=false;
282 break;
283 }
284 }
285
286 // Not found? Then append.
287 if($append) {
288 $showItem[]=$str;
289 }
290
291 $TCA[$table]['types'][$k]['showitem']=implode(', ', $showItem);
292 }
293 else {
294 $TCA[$table]['types'][$k]['showitem'] .= ', ' . $str;
295 }
296
297 } else {
298 $TCA[$table]['types'][$k]['showitem'].=', ' . $str;
299 }
300 }
301 }
302 }
303 }
304
305
306 /**
307 * Add tablename to default list of allowed tables on pages (in $PAGES_TYPES)
308 * Will add the $table to the list of tables allowed by default on pages as setup by $PAGES_TYPES['default']['allowedTables']
309 * FOR USE IN ext_tables.php FILES
310 * Usage: 11
311 *
312 * @param string Table name
313 * @return void
314 */
315 function allowTableOnStandardPages($table) {
316 global $PAGES_TYPES;
317
318 $PAGES_TYPES['default']['allowedTables'].=','.$table;
319 }
320
321 /**
322 * Adds a module (main or sub) to the backend interface
323 * FOR USE IN ext_tables.php FILES
324 * Usage: 18
325 *
326 * @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.
327 * @param string $sub is the submodule key. If $sub is not set a blank $main module is created.
328 * @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.
329 * @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.
330 * @return void
331 */
332 function addModule($main,$sub='',$position='',$path='') {
333 global $TBE_MODULES;
334
335 if (isset($TBE_MODULES[$main]) && $sub) { // If there is already a main module by this name:
336
337 // Adding the submodule to the correct position:
338 list($place,$modRef)=t3lib_div::trimExplode(':',$position,1);
339 $mods = t3lib_div::trimExplode(',',$TBE_MODULES[$main],1);
340 if (!in_array($sub,$mods)) {
341 switch(strtolower($place)) {
342 case 'after':
343 case 'before':
344 $pointer=0;
345 reset($mods);
346 while(list($k,$m)=each($mods)) {
347 if (!strcmp($m,$modRef)) {
348 $pointer=strtolower($place)=='after'?$k+1:$k;
349 }
350 }
351 array_splice(
352 $mods, // The modules array
353 $pointer, // To insert one position from the end of the list
354 0, // Don't remove any items, just insert
355 $sub // Module to insert
356 );
357 break;
358 default:
359 if (strtolower($place)=='top') {
360 array_unshift($mods,$sub);
361 } else {
362 array_push($mods,$sub);
363 }
364 break;
365 }
366 }
367 // Re-inserting the submodule list:
368 $TBE_MODULES[$main]=implode(',',$mods);
369 } else { // Create new main modules with only one submodule, $sub (or none if $sub is blank)
370 $TBE_MODULES[$main]=$sub;
371 }
372
373 // Adding path:
374 if ($path) {
375 $TBE_MODULES['_PATHS'][$main.($sub?'_'.$sub:'')]=$path;
376 }
377 }
378
379 /**
380 * Adds a module path to TBE_MODULES for used with the module dispatcher, mod.php
381 * Used only for modules that are not placed in the main/sub menu hierarchy by the traditional mechanism of addModule()
382 * Examples for this is context menu functionality (like import/export) which runs as an independent module through mod.php
383 * FOR USE IN ext_tables.php FILES
384 * Example: t3lib_extMgm::addModulePath('xMOD_tximpexp',t3lib_extMgm::extPath($_EXTKEY).'app/');
385 *
386 * @param string $name is the name of the module, refer to conf.php of the module.
387 * @param string $path is the absolute path to the module directory inside of which "index.php" and "conf.php" is found.
388 * @return void
389 */
390 function addModulePath($name,$path) {
391 global $TBE_MODULES;
392
393 $TBE_MODULES['_PATHS'][$name] = $path;
394 }
395
396 /**
397 * Adds a "Function menu module" ('third level module') to an existing function menu for some other backend module
398 * The arguments values are generally determined by which function menu this is supposed to interact with
399 * See Inside TYPO3 for information on how to use this function.
400 * FOR USE IN ext_tables.php FILES
401 * Usage: 26
402 *
403 * @param string Module name
404 * @param string Class name
405 * @param string Class path
406 * @param string Title of module
407 * @param string Menu array key - default is "function"
408 * @param string Workspace conditions. Blank means all workspaces, any other string can be a comma list of "online", "offline" and "custom"
409 * @return void
410 * @see t3lib_SCbase::mergeExternalItems()
411 */
412 function insertModuleFunction($modname,$className,$classPath,$title,$MM_key='function',$WS='') {
413 global $TBE_MODULES_EXT;
414 $TBE_MODULES_EXT[$modname]['MOD_MENU'][$MM_key][$className]=array(
415 'name' => $className,
416 'path' => $classPath,
417 'title' => $title,
418 'ws' => $WS
419 );
420 }
421
422 /**
423 * Adds $content to the default Page TSconfig as set in $TYPO3_CONF_VARS[BE]['defaultPageTSconfig']
424 * Prefixed with a [GLOBAL] line
425 * FOR USE IN ext_tables.php/ext_locallang.php FILES
426 * Usage: 5
427 *
428 * @param string Page TSconfig content
429 * @return void
430 */
431 function addPageTSConfig($content) {
432 global $TYPO3_CONF_VARS;
433 $TYPO3_CONF_VARS['BE']['defaultPageTSconfig'].="\n[GLOBAL]\n".$content;
434 }
435
436 /**
437 * Adds $content to the default User TSconfig as set in $TYPO3_CONF_VARS[BE]['defaultUserTSconfig']
438 * Prefixed with a [GLOBAL] line
439 * FOR USE IN ext_tables.php/ext_locallang.php FILES
440 * Usage: 3
441 *
442 * @param string User TSconfig content
443 * @return void
444 */
445 function addUserTSConfig($content) {
446 global $TYPO3_CONF_VARS;
447 $TYPO3_CONF_VARS['BE']['defaultUserTSconfig'].="\n[GLOBAL]\n".$content;
448 }
449
450 /**
451 * Adds a reference to a locallang file with TCA_DESCR labels
452 * FOR USE IN ext_tables.php FILES
453 * 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.
454 * Usage: 31
455 *
456 * @param string Description key. Typically a database table (like "pages") but for applications can be other strings, but prefixed with "_MOD_")
457 * @param string File reference to locallang file, eg. "EXT:lang/locallang_csh_pages.php" (or ".xml")
458 * @return void
459 */
460 function addLLrefForTCAdescr($tca_descr_key,$file_ref) {
461 global $TCA_DESCR;
462 if ($tca_descr_key) {
463 if (!is_array($TCA_DESCR[$tca_descr_key])) {
464 $TCA_DESCR[$tca_descr_key]=array();
465 }
466 if (!is_array($TCA_DESCR[$tca_descr_key]['refs'])) {
467 $TCA_DESCR[$tca_descr_key]['refs']=array();
468 }
469 $TCA_DESCR[$tca_descr_key]['refs'][]=$file_ref;
470 }
471 }
472
473
474
475
476
477
478
479
480
481
482
483
484 /**************************************
485 *
486 * Adding SERVICES features
487 *
488 * @author René Fritz <r.fritz@colorcube.de>
489 *
490 ***************************************/
491
492 /**
493 * Adds a service to the global services array
494 *
495 * @param string Extension key
496 * @param string Service type, cannot be prefixed "tx_"
497 * @param string Service key, must be prefixed "tx_" or "user_"
498 * @param array Service description array
499 * @return void
500 * @author René Fritz <r.fritz@colorcube.de>
501 */
502 function addService($extKey, $serviceType, $serviceKey, $info) {
503 global $T3_SERVICES,$TYPO3_CONF_VARS;
504
505 // even not available services will be included to make it possible to give the admin a feedback of non-available services.
506 // but maybe it's better to move non-available services to a different array??
507
508 if ($serviceType &&
509 !t3lib_div::isFirstPartOfStr($serviceType, 'tx_') &&
510 (t3lib_div::isFirstPartOfStr($serviceKey, 'tx_') || t3lib_div::isFirstPartOfStr($serviceKey, 'user_')) &&
511 is_array($info)) {
512
513 $info['priority'] = max(0,min(100,$info['priority']));
514
515 $T3_SERVICES[$serviceType][$serviceKey]=$info;
516
517 $T3_SERVICES[$serviceType][$serviceKey]['extKey'] = $extKey;
518 $T3_SERVICES[$serviceType][$serviceKey]['serviceKey'] = $serviceKey;
519 $T3_SERVICES[$serviceType][$serviceKey]['serviceType'] = $serviceType;
520
521
522 // mapping a service key to a service type
523 // all service keys begin with tx_ - service types don't
524 // this way a selection of a special service key as service type is easy
525 $T3_SERVICES[$serviceKey][$serviceKey] = &$T3_SERVICES[$serviceType][$serviceKey];
526
527
528 // change the priority (and other values) from TYPO3_CONF_VARS
529 // $TYPO3_CONF_VARS['T3_SERVICES'][$serviceType][$serviceKey]['priority']
530 // even the activation is possible (a unix service might be possible on windows for some reasons)
531 if (is_array($TYPO3_CONF_VARS['T3_SERVICES'][$serviceType][$serviceKey])) {
532
533 // no check is done here - there might be configuration values only the service type knows about, so we pass everything
534 $T3_SERVICES[$serviceType][$serviceKey] = array_merge ($T3_SERVICES[$serviceType][$serviceKey],$TYPO3_CONF_VARS['T3_SERVICES'][$serviceType][$serviceKey]);
535 }
536
537
538 // OS check
539 // empty $os means 'not limited to one OS', therefore a check is not needed
540 if ($T3_SERVICES[$serviceType][$serviceKey]['available'] && $T3_SERVICES[$serviceType][$serviceKey]['os']!='') {
541
542 // TYPO3_OS is not yet defined
543 $os_type = stristr(PHP_OS,'win')&&!stristr(PHP_OS,'darwin')?'WIN':'UNIX';
544
545 $os = t3lib_div::trimExplode(',',strtoupper($T3_SERVICES[$serviceType][$serviceKey]['os']));
546
547 if (!in_array($os_type,$os)) {
548 t3lib_extMgm::deactivateService($serviceType, $serviceKey);
549 }
550 }
551
552 // convert subtype list to array for quicker access
553 $T3_SERVICES[$serviceType][$serviceKey]['serviceSubTypes'] = array();
554 $serviceSubTypes = t3lib_div::trimExplode(',',$info['subtype']);
555 foreach ($serviceSubTypes as $subtype) {
556 $T3_SERVICES[$serviceType][$serviceKey]['serviceSubTypes'][$subtype] = $subtype;
557 }
558 }
559 }
560
561 /**
562 * Find the available service with highest priority
563 *
564 * @param string Service type
565 * @param string Service sub type
566 * @param mixed Service keys that should be excluded in the search for a service. Array or comma list.
567 * @return mixed Service info array if a service was found, FLASE otherwise
568 * @author René Fritz <r.fritz@colorcube.de>
569 */
570 function findService($serviceType, $serviceSubType='', $excludeServiceKeys=array()) {
571 global $T3_SERVICES, $T3_VAR, $TYPO3_CONF_VARS;
572
573 $serviceKey = FALSE;
574 $serviceInfo = FALSE;
575 $priority = 0;
576 $quality = 0;
577
578 if (!is_array($excludeServiceKeys) ) {
579 $excludeServiceKeys = t3lib_div::trimExplode(',', $excludeServiceKeys, 1);
580 }
581
582 if (is_array($T3_SERVICES[$serviceType])) {
583 foreach($T3_SERVICES[$serviceType] as $key => $info) {
584
585 if (in_array($key, $excludeServiceKeys)) {
586 continue;
587 }
588
589 // select a subtype randomly
590 // usefull to start a service by service key without knowing his subtypes - for testing purposes
591 if ($serviceSubType=='*') {
592 $serviceSubType = key($info['serviceSubTypes']);
593 }
594
595 // this matches empty subtype too
596 if ($info['available'] && ($info['subtype']==$serviceSubType || $info['serviceSubTypes'][$serviceSubType]) && $info['priority']>=$priority ) {
597
598 // has a lower quality than the already found, therefore we skip this service
599 if($info['priority']==$priority && $info['quality']<$quality) {
600 continue;
601 }
602
603 // service depends on external programs - check if they exists
604 if(trim($info['exec'])) {
605 require_once(PATH_t3lib.'class.t3lib_exec.php');
606
607 $executables = t3lib_div::trimExplode(',', $info['exec'],1);
608 foreach($executables as $executable) {
609 if(!t3lib_exec::checkCommand($executable)) {
610 t3lib_extMgm::deactivateService($serviceType, $key);
611 $info['available']=FALSE;
612 break;
613 }
614 }
615 }
616
617 // still available after exec check?
618 if($info['available']) {
619 $serviceKey = $key;
620 $priority = $info['priority'];
621 $quality = $info['quality'];
622 }
623 }
624 }
625 }
626
627 if ($serviceKey) {
628 $serviceInfo = $T3_SERVICES[$serviceType][$serviceKey];
629 }
630 return $serviceInfo;
631 }
632
633 /**
634 * Deactivate a service
635 *
636 * @param string Service type
637 * @param string Service key
638 * @return void
639 * @author René Fritz <r.fritz@colorcube.de>
640 */
641 function deactivateService($serviceType, $serviceKey) {
642 global $T3_SERVICES;
643
644 // ... maybe it's better to move non-available services to a different array??
645 $T3_SERVICES[$serviceType][$serviceKey]['available'] = FALSE;
646 }
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661 /**************************************
662 *
663 * Adding FRONTEND features
664 * (related specifically to "cms" extension)
665 *
666 ***************************************/
667
668 /**
669 * Adds an entry to the list of plugins in content elements of type "Insert plugin"
670 * Takes the $itemArray (label,value[,icon]) and adds to the items-array of $TCA[tt_content] elements with CType "listtype" (or another field if $type points to another fieldname)
671 * 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.
672 * 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
673 * FOR USE IN ext_tables.php FILES
674 * Usage: 13
675 *
676 * @param array Item Array
677 * @param string Type (eg. "list_type") - basically a field from "tt_content" table
678 * @return void
679 */
680 function addPlugin($itemArray,$type='list_type') {
681 global $TCA;
682 t3lib_div::loadTCA('tt_content');
683 if (is_array($TCA['tt_content']['columns']) && is_array($TCA['tt_content']['columns'][$type]['config']['items'])) {
684 reset($TCA['tt_content']['columns'][$type]['config']['items']);
685 while(list($k,$v)=each($TCA['tt_content']['columns'][$type]['config']['items'])) {
686 if (!strcmp($v[1],$itemArray[1])) {
687 $TCA['tt_content']['columns'][$type]['config']['items'][$k]=$itemArray;
688 return;
689 }
690 }
691 $TCA['tt_content']['columns'][$type]['config']['items'][]=$itemArray;
692 }
693 }
694
695 /**
696 * Adds an entry to the "ds" array of the tt_content field "pi_flexform".
697 * This is used by plugins to add a flexform XML reference / content for use when they are selected as plugin or content element.
698 * Usage: 0
699 *
700 * @param string Plugin key as used in the list_type field. Use the asterisk * to match all list_type values.
701 * @param string Either a reference to a flex-form XML file (eg. "FILE:EXT:newloginbox/flexform_ds.xml") or the XML directly.
702 * @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.
703 * @return void
704 * @see addPlugin()
705 */
706 function addPiFlexFormValue($piKeyToMatch, $value, $CTypeToMatch='list') {
707 global $TCA;
708 t3lib_div::loadTCA('tt_content');
709
710 if (is_array($TCA['tt_content']['columns']) && is_array($TCA['tt_content']['columns']['pi_flexform']['config']['ds'])) {
711 $TCA['tt_content']['columns']['pi_flexform']['config']['ds'][$piKeyToMatch.','.$CTypeToMatch] = $value;
712 }
713 }
714
715 /**
716 * Adds the $table tablename to the list of tables allowed to be includes by content element type "Insert records"
717 * By using $content_table and $content_field you can also use the function for other tables.
718 * FOR USE IN ext_tables.php FILES
719 * Usage: 9
720 *
721 * @param string Table name to allow for "insert record"
722 * @param string Table name TO WHICH the $table name is applied. See $content_field as well.
723 * @param string Field name in the database $content_table in which $table is allowed to be added as a reference ("Insert Record")
724 * @return void
725 */
726 function addToInsertRecords($table,$content_table='tt_content',$content_field='records') {
727 global $TCA;
728 t3lib_div::loadTCA($content_table);
729 if (is_array($TCA[$content_table]['columns']) && isset($TCA[$content_table]['columns'][$content_field]['config']['allowed'])) {
730 $TCA[$content_table]['columns'][$content_field]['config']['allowed'].=','.$table;
731 }
732 }
733
734 /**
735 * Add PlugIn to Static Template #43
736 *
737 * 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.
738 * 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"
739 * $type determines the type of frontend plugin:
740 * "list_type" (default) - the good old "Insert plugin" entry
741 * "menu_type" - a "Menu/Sitemap" entry
742 * "splash_layout" - a "Textbox" entry
743 * "CType" - a new content element type
744 * "header_layout" - an additional header type (added to the selection of layout1-5)
745 * "includeLib" - just includes the library for manual use somewhere in TypoScript.
746 * (Remember that your $type definition should correspond to the column/items array in $TCA[tt_content] where you added the selector item for the element! See addPlugin() function)
747 * FOR USE IN ext_locallang.php FILES
748 * Usage: 2
749 *
750 * @param string $key is the extension key
751 * @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.
752 * @param string $prefix is used as a - yes, suffix - of the class name (fx. "_pi1")
753 * @param string $type, see description above
754 * @param boolean If $cached is set as USER content object (cObject) is created - otherwise a USER_INT object is created.
755 * @return void
756 */
757 function addPItoST43($key,$classFile='',$prefix='',$type='list_type',$cached=0) {
758 global $TYPO3_LOADED_EXT;
759 $classFile = $classFile ? $classFile : 'pi/class.tx_'.str_replace('_','',$key).$prefix.'.php';
760 $cN = t3lib_extMgm::getCN($key);
761
762 // General plugin:
763 if ($cached) {
764 $pluginContent = trim('
765 includeLibs.'.$cN.$prefix.' = '.$TYPO3_LOADED_EXT[$key]['siteRelPath'].$classFile.'
766 plugin.'.$cN.$prefix.' = USER
767 plugin.'.$cN.$prefix.' {
768 userFunc = '.$cN.$prefix.'->main
769 }');
770 } else {
771 $pluginContent = trim('
772 plugin.'.$cN.$prefix.' = USER_INT
773 plugin.'.$cN.$prefix.' {
774 includeLibs = '.$TYPO3_LOADED_EXT[$key]['siteRelPath'].$classFile.'
775 userFunc = '.$cN.$prefix.'->main
776 }');
777 }
778 t3lib_extMgm::addTypoScript($key,'setup','
779 # Setting '.$key.' plugin TypoScript
780 '.$pluginContent);
781
782 // After ST43:
783 switch($type) {
784 case 'list_type':
785 $addLine = 'tt_content.list.20.'.$key.$prefix.' = < plugin.'.$cN.$prefix;
786 break;
787 case 'menu_type':
788 $addLine = 'tt_content.menu.20.'.$key.$prefix.' = < plugin.'.$cN.$prefix;
789 break;
790 case 'splash_layout':
791 $addLine = 'tt_content.splash.'.$key.$prefix.' = < plugin.'.$cN.$prefix;
792 break;
793 case 'CType':
794 $addLine = trim('
795 tt_content.'.$key.$prefix.' = COA
796 tt_content.'.$key.$prefix.' {
797 10 = < lib.stdheader
798 20 = < plugin.'.$cN.$prefix.'
799 }
800 ');
801 break;
802 case 'header_layout':
803 $addLine = 'lib.stdheader.10.'.$key.$prefix.' = < plugin.'.$cN.$prefix;
804 break;
805 case 'includeLib':
806 $addLine = 'page.1000 = < plugin.'.$cN.$prefix;
807 break;
808 default:
809 $addLine = '';
810 break;
811 }
812 if ($addLine) {
813 t3lib_extMgm::addTypoScript($key,'setup','
814 # Setting '.$key.' plugin TypoScript
815 '.$addLine.'
816 ',43);
817 }
818 }
819
820 /**
821 * Call this method to add an entry in the static template list found in sys_templates
822 * "static template files" are the modern equalent (provided from extensions) to the traditional records in "static_templates"
823 * FOR USE IN ext_locallang.php FILES
824 * Usage: 3
825 *
826 * @param string $extKey is of course the extension key
827 * @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/
828 * @param string $title is the title in the selector box.
829 * @return void
830 * @see addTypoScript()
831 */
832 function addStaticFile($extKey,$path,$title) {
833 global $TCA;
834 t3lib_div::loadTCA('sys_template');
835 if ($extKey && $path && is_array($TCA['sys_template']['columns'])) {
836 $value = str_replace(',','','EXT:'.$extKey.'/'.$path);
837 $itemArray=array(trim($title.' ('.$extKey.')'),$value);
838 $TCA['sys_template']['columns']['include_static_file']['config']['items'][]=$itemArray;
839 }
840 }
841
842 /**
843 * Adds $content to the default TypoScript setup code as set in $TYPO3_CONF_VARS[FE]['defaultTypoScript_setup']
844 * Prefixed with a [GLOBAL] line
845 * FOR USE IN ext_locallang.php FILES
846 * Usage: 6
847 *
848 * @param string TypoScript Setup string
849 * @return void
850 */
851 function addTypoScriptSetup($content) {
852 global $TYPO3_CONF_VARS;
853 $TYPO3_CONF_VARS['FE']['defaultTypoScript_setup'].="\n[GLOBAL]\n".$content;
854 }
855
856 /**
857 * Adds $content to the default TypoScript constants code as set in $TYPO3_CONF_VARS[FE]['defaultTypoScript_constants']
858 * Prefixed with a [GLOBAL] line
859 * FOR USE IN ext_locallang.php FILES
860 * Usage: 0
861 *
862 * @param string TypoScript Constants string
863 * @return void
864 */
865 function addTypoScriptConstants($content) {
866 global $TYPO3_CONF_VARS;
867 $TYPO3_CONF_VARS['FE']['defaultTypoScript_constants'].="\n[GLOBAL]\n".$content;
868 }
869
870 /**
871 * Adds $content to the default TypoScript code for either setup, constants or editorcfg as set in $TYPO3_CONF_VARS[FE]['defaultTypoScript_*']
872 * (Basically this function can do the same as addTypoScriptSetup and addTypoScriptConstants - just with a little more hazzle, but also with some more options!)
873 * FOR USE IN ext_locallang.php FILES
874 * Usage: 7
875 *
876 * @param string $key is the extension key (informative only).
877 * @param string $type is either "setup", "constants" or "editorcfg" and obviously determines which kind of TypoScript code we are adding.
878 * @param string $content is the TS content, prefixed with a [GLOBAL] line and a comment-header.
879 * @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.
880 * @return void
881 */
882 function addTypoScript($key,$type,$content,$afterStaticUid=0) {
883 global $TYPO3_CONF_VARS;
884
885 if ($type=='setup' || $type=='editorcfg' || $type=='constants') {
886 $content = '
887
888 [GLOBAL]
889 #############################################
890 ## TypoScript added by extension "'.$key.'"
891 #############################################
892
893 '.$content;
894 if ($afterStaticUid) {
895 $TYPO3_CONF_VARS['FE']['defaultTypoScript_'.$type.'.'][$afterStaticUid].=$content;
896 if ($afterStaticUid==43) { // If 'content (default)' is targeted, also add to other 'content rendering templates', eg. css_styled_content
897 $TYPO3_CONF_VARS['FE']['defaultTypoScript_'.$type.'.']['cssstyledcontent/static/'].=$content;
898 }
899 } else {
900 $TYPO3_CONF_VARS['FE']['defaultTypoScript_'.$type].=$content;
901 }
902 }
903 }
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922 /**************************************
923 *
924 * INTERNAL EXTENSION MANAGEMENT:
925 *
926 ***************************************/
927
928 /**
929 * Loading extensions configured in $TYPO3_CONF_VARS['EXT']['extList']
930 *
931 * CACHING ON: ($TYPO3_CONF_VARS['EXT']['extCache'] = 1 or 2)
932 * 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.
933 * If cachefiles are not found they will be generated
934 * CACHING OFF: ($TYPO3_CONF_VARS['EXT']['extCache'] = 0)
935 * 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.
936 * This array will later be set in the global var $TYPO3_LOADED_EXT
937 *
938 * Usages of this function can be seen in config_default.php
939 * Extensions are always detected in the order local - global - system.
940 * Usage: 1
941 *
942 * @return array Extension Array
943 * @internal
944 */
945 function typo3_loadExtensions() {
946 global $TYPO3_CONF_VARS;
947
948 // Full list of extensions includes both required and extList:
949 $rawExtList = $TYPO3_CONF_VARS['EXT']['requiredExt'].','.$TYPO3_CONF_VARS['EXT']['extList'];
950
951 // Empty array as a start.
952 $extensions = array();
953
954 //
955 if ($rawExtList) {
956 // The cached File prefix.
957 $cacheFilePrefix = 'temp_CACHED';
958 // Setting the name for the cache files:
959 if (intval($TYPO3_CONF_VARS['EXT']['extCache'])==1) $cacheFilePrefix.= '_ps'.substr(t3lib_div::shortMD5(PATH_site.'|'.$GLOBALS['TYPO_VERSION']),0,4);
960 if (intval($TYPO3_CONF_VARS['EXT']['extCache'])==2) $cacheFilePrefix.= '_'.t3lib_div::shortMD5($rawExtList);
961
962 // If cache files available, set cache file prefix and return:
963 if ($TYPO3_CONF_VARS['EXT']['extCache'] && t3lib_extMgm::isCacheFilesAvailable($cacheFilePrefix)) {
964 // Return cache file prefix:
965 $extensions['_CACHEFILE'] = $cacheFilePrefix;
966 } else { // ... but if not, configure...
967
968 // Prepare reserved filenames:
969 $files = t3lib_div::trimExplode(',','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',1);
970
971 // Traverse extensions and check their existence:
972 clearstatcache(); // Clear file state cache to make sure we get good results from is_dir()
973 $temp_extensions = array_unique(t3lib_div::trimExplode(',',$rawExtList,1));
974 foreach($temp_extensions as $temp_extKey) {
975 // Check local, global and system locations:
976 if (@is_dir(PATH_typo3conf.'ext/'.$temp_extKey.'/')) {
977 $extensions[$temp_extKey] = array('type'=>'L', 'siteRelPath'=>'typo3conf/ext/'.$temp_extKey.'/', 'typo3RelPath'=>'../typo3conf/ext/'.$temp_extKey.'/');
978 } elseif (@is_dir(PATH_typo3.'ext/'.$temp_extKey.'/')) {
979 $extensions[$temp_extKey] = array('type'=>'G', 'siteRelPath'=>TYPO3_mainDir.'ext/'.$temp_extKey.'/', 'typo3RelPath'=>'ext/'.$temp_extKey.'/');
980 } elseif (@is_dir(PATH_typo3.'sysext/'.$temp_extKey.'/')) {
981 $extensions[$temp_extKey] = array('type'=>'S', 'siteRelPath'=>TYPO3_mainDir.'sysext/'.$temp_extKey.'/', 'typo3RelPath'=>'sysext/'.$temp_extKey.'/');
982 }
983
984 // If extension was found, check for reserved filenames:
985 if (isset($extensions[$temp_extKey])) {
986 foreach($files as $fName) {
987 $temp_filename = PATH_site.$extensions[$temp_extKey]['siteRelPath'].trim($fName);
988 if (is_array($extensions[$temp_extKey]) && @is_file($temp_filename)) {
989 $extensions[$temp_extKey][$fName] = $temp_filename;
990 }
991 }
992 }
993 }
994 unset($extensions['_CACHEFILE']);
995
996 // write cache?
997 if ($TYPO3_CONF_VARS['EXT']['extCache'] &&
998 @is_dir(PATH_typo3.'sysext/') &&
999 @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!
1000 $wrError = t3lib_extMgm::cannotCacheFilesWritable($cacheFilePrefix);
1001 if ($wrError) {
1002 $TYPO3_CONF_VARS['EXT']['extCache']=0;
1003 } else {
1004 // Write cache files:
1005 $extensions = t3lib_extMgm::writeCacheFiles($extensions,$cacheFilePrefix);
1006 }
1007 }
1008 }
1009 }
1010
1011 return $extensions;
1012 }
1013
1014 /**
1015 * Returns the section headers for the compiled cache-files.
1016 *
1017 * @param string $key is the extension key
1018 * @param string $file is the filename (only informative for comment)
1019 * @return string
1020 * @internal
1021 */
1022 function _makeIncludeHeader($key,$file) {
1023 return '<?php
1024 ###########################
1025 ## EXTENSION: '.$key.'
1026 ## FILE: '.$file.'
1027 ###########################
1028
1029 $_EXTKEY = \''.$key.'\';
1030 $_EXTCONF = $TYPO3_CONF_VARS[\'EXT\'][\'extConf\'][$_EXTKEY];
1031
1032 ?>';
1033 }
1034
1035 /**
1036 * Returns true if both the localconf and tables cache file exists (with $cacheFilePrefix)
1037 * Usage: 2
1038 *
1039 * @param string Prefix of the cache file to check
1040 * @return boolean
1041 * @internal
1042 */
1043 function isCacheFilesAvailable($cacheFilePrefix) {
1044 return
1045 @is_file(PATH_typo3conf.$cacheFilePrefix.'_ext_localconf.php') &&
1046 @is_file(PATH_typo3conf.$cacheFilePrefix.'_ext_tables.php');
1047 }
1048
1049 /**
1050 * Returns true if the "localconf.php" file in "typo3conf/" is writable
1051 * Usage: 1
1052 *
1053 * @return boolean
1054 * @internal
1055 */
1056 function isLocalconfWritable() {
1057 return @is_writable(PATH_typo3conf) && @is_writable(PATH_typo3conf.'localconf.php');
1058 }
1059
1060 /**
1061 * Returns an error string if typo3conf/ or cache-files with $cacheFilePrefix are NOT writable
1062 * Returns false if no problem.
1063 * Usage: 1
1064 *
1065 * @param string Prefix of the cache file to check
1066 * @return string
1067 * @internal
1068 */
1069 function cannotCacheFilesWritable($cacheFilePrefix) {
1070 $error=array();
1071 if (!@is_writable(PATH_typo3conf)) {
1072 $error[]=PATH_typo3conf;
1073 }
1074 if (@is_file(PATH_typo3conf.$cacheFilePrefix.'_ext_localconf.php') &&
1075 !@is_writable(PATH_typo3conf.$cacheFilePrefix.'_ext_localconf.php')) {
1076 $error[]=PATH_typo3conf.$cacheFilePrefix.'_ext_localconf.php';
1077 }
1078 if (@is_file(PATH_typo3conf.$cacheFilePrefix.'_ext_tables.php') &&
1079 !@is_writable(PATH_typo3conf.$cacheFilePrefix.'_ext_tables.php')) {
1080 $error[]=PATH_typo3conf.$cacheFilePrefix.'_ext_tables.php';
1081 }
1082 return implode(', ',$error);
1083 }
1084
1085 /**
1086 * Returns an array with the two cache-files (0=>localconf, 1=>tables) from typo3conf/ if they (both) exist. Otherwise false.
1087 * Evaluation relies on $TYPO3_LOADED_EXT['_CACHEFILE']
1088 * Usage: 2
1089 *
1090 * @return array
1091 * @internal
1092 */
1093 function currentCacheFiles() {
1094 global $TYPO3_LOADED_EXT;
1095
1096 if ($TYPO3_LOADED_EXT['_CACHEFILE']) {
1097 if (t3lib_extMgm::isCacheFilesAvailable($TYPO3_LOADED_EXT['_CACHEFILE'])) {
1098 return array(
1099 PATH_typo3conf.$TYPO3_LOADED_EXT['_CACHEFILE'].'_ext_localconf.php',
1100 PATH_typo3conf.$TYPO3_LOADED_EXT['_CACHEFILE'].'_ext_tables.php'
1101 );
1102 }
1103 }
1104 }
1105
1106 /**
1107 * Compiles/Creates the two cache-files in typo3conf/ based on $cacheFilePrefix
1108 * Returns a array with the key "_CACHEFILE" set to the $cacheFilePrefix value
1109 * Usage: 1
1110 *
1111 * @param array Extension information array
1112 * @param string Prefix for the cache files
1113 * @return array
1114 * @internal
1115 */
1116 function writeCacheFiles($extensions,$cacheFilePrefix) {
1117 // Making cache files:
1118 $extensions['_CACHEFILE'] = $cacheFilePrefix;
1119 $cFiles=array();
1120 $cFiles['ext_localconf'].='<?php
1121
1122 $TYPO3_LOADED_EXT = unserialize(stripslashes(\''.addslashes(serialize($extensions)).'\'));
1123
1124 ?>';
1125
1126 reset($extensions);
1127 while(list($key,$conf)=each($extensions)) {
1128 if (is_array($conf)) {
1129 if ($conf['ext_localconf.php']) {
1130 $cFiles['ext_localconf'].=t3lib_extMgm::_makeIncludeHeader($key,$conf['ext_localconf.php']);
1131 $cFiles['ext_localconf'].=trim(t3lib_div::getUrl($conf['ext_localconf.php']));
1132 }
1133 if ($conf['ext_tables.php']) {
1134 $cFiles['ext_tables'].=t3lib_extMgm::_makeIncludeHeader($key,$conf['ext_tables.php']);
1135 $cFiles['ext_tables'].=trim(t3lib_div::getUrl($conf['ext_tables.php']));
1136 }
1137 }
1138 }
1139
1140 $cFiles['ext_localconf'] = "<?php\n" . preg_replace('/<\?php|\?>/is', '', $cFiles['ext_localconf']) . "?>\n";
1141 $cFiles['ext_tables'] = "<?php\n" . preg_replace('/<\?php|\?>/is', '', $cFiles['ext_tables']) . "?>\n";
1142
1143 t3lib_div::writeFile(PATH_typo3conf.$cacheFilePrefix.'_ext_localconf.php',$cFiles['ext_localconf']);
1144 t3lib_div::writeFile(PATH_typo3conf.$cacheFilePrefix.'_ext_tables.php',$cFiles['ext_tables']);
1145
1146 $extensions=array();
1147 $extensions['_CACHEFILE'] = $cacheFilePrefix;
1148
1149 return $extensions;
1150 }
1151
1152 /**
1153 * Unlink (delete) cache files
1154 *
1155 * @return integer Number of deleted files.
1156 */
1157 function removeCacheFiles() {
1158 $cacheFiles = t3lib_extMgm::currentCacheFiles();
1159 $out = 0;
1160 if (is_array($cacheFiles)) {
1161 reset($cacheFiles);
1162 foreach($cacheFiles as $cfile) {
1163 @unlink($cfile);
1164 clearstatcache();
1165 $out++;
1166 }
1167 }
1168 return $out;
1169 }
1170 }
1171
1172 ?>