[TASK] self:: is not used for local static member reference
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / tslib / class.tslib_content.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 * This class contains all main TypoScript features.
30 * This includes the rendering of TypoScript content objects (cObjects).
31 * Is the backbone of TypoScript Template rendering.
32 *
33 * There are lots of functions you can use from your include-scripts.
34 * The class "tslib_cObj" is normally instantiated and referred to as "cObj".
35 * When you call your own PHP-code typically through a USER or USER_INT cObject then it is this class that instantiates the object and calls the main method. Before it does so it will set (if you are using classes) a reference to itself in the internal variable "cObj" of the object. Thus you can access all functions and data from this class by $this->cObj->... from within you classes written to be USER or USER_INT content objects.
36 *
37 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
38 * @package TYPO3
39 * @subpackage tslib
40 */
41 class tslib_cObj {
42
43 var $align = array(
44 'center',
45 'right',
46 'left'
47 );
48
49 /**
50 * stdWrap functions in their correct order
51 *
52 * @see stdWrap()
53 */
54 var $stdWrapOrder = array(
55 'stdWrapPreProcess' => 'hook', // this is a placeholder for the first Hook
56 'cacheRead' => 'hook', // this is a placeholder for checking if the content is available in cache
57 'setContentToCurrent' => 'boolean',
58 'setContentToCurrent.' => 'array',
59 'setCurrent' => 'string',
60 'setCurrent.' => 'array',
61 'lang.' => 'array',
62 'data' => 'getText',
63 'data.' => 'array',
64 'field' => 'fieldName',
65 'field.' => 'array',
66 'current' => 'boolean',
67 'current.' => 'array',
68 'cObject' => 'cObject',
69 'cObject.' => 'array',
70 'numRows.' => 'array',
71 'filelist' => 'dir',
72 'filelist.' => 'array',
73 'preUserFunc' => 'functionName',
74 'stdWrapOverride' => 'hook', // this is a placeholder for the second Hook
75 'override' => 'string',
76 'override.' => 'array',
77 'preIfEmptyListNum' => 'listNum',
78 'preIfEmptyListNum.' => 'array',
79 'ifEmpty' => 'string',
80 'ifEmpty.' => 'array',
81 'ifBlank' => 'string',
82 'ifBlank.' => 'array',
83 'listNum' => 'listNum',
84 'listNum.' => 'array',
85 'trim' => 'boolean',
86 'trim.' => 'array',
87 'stdWrap' => 'stdWrap',
88 'stdWrap.' => 'array',
89 'stdWrapProcess' => 'hook', // this is a placeholder for the third Hook
90 'required' => 'boolean',
91 'required.' => 'array',
92 'if.' => 'array',
93 'fieldRequired' => 'fieldName',
94 'fieldRequired.' => 'array',
95 'csConv' => 'string',
96 'csConv.' => 'array',
97 'parseFunc' => 'objectpath',
98 'parseFunc.' => 'array',
99 'HTMLparser' => 'boolean',
100 'HTMLparser.' => 'array',
101 'split.' => 'array',
102 'replacement.' => 'array',
103 'prioriCalc' => 'boolean',
104 'prioriCalc.' => 'array',
105 'char' => 'integer',
106 'char.' => 'array',
107 'intval' => 'boolean',
108 'intval.' => 'array',
109 'hash' => 'string',
110 'hash.' => 'array',
111 'round' => 'boolean',
112 'round.' => 'array',
113 'numberFormat.' => 'array',
114 'expandList' => 'boolean',
115 'expandList.' => 'array',
116 'date' => 'dateconf',
117 'date.' => 'array',
118 'strftime' => 'strftimeconf',
119 'strftime.' => 'array',
120 'age' => 'boolean',
121 'age.' => 'array',
122 'case' => 'case',
123 'case.' => 'array',
124 'bytes' => 'boolean',
125 'bytes.' => 'array',
126 'substring' => 'parameters',
127 'substring.' => 'array',
128 'removeBadHTML' => 'boolean',
129 'removeBadHTML.' => 'array',
130 'cropHTML' => 'crop',
131 'cropHTML.' => 'array',
132 'stripHtml' => 'boolean',
133 'stripHtml.' => 'array',
134 'crop' => 'crop',
135 'crop.' => 'array',
136 'rawUrlEncode' => 'boolean',
137 'rawUrlEncode.' => 'array',
138 'htmlSpecialChars' => 'boolean',
139 'htmlSpecialChars.' => 'array',
140 'doubleBrTag' => 'string',
141 'doubleBrTag.' => 'array',
142 'br' => 'boolean',
143 'br.' => 'array',
144 'brTag' => 'string',
145 'brTag.' => 'array',
146 'encapsLines.' => 'array',
147 'keywords' => 'boolean',
148 'keywords.' => 'array',
149 'innerWrap' => 'wrap',
150 'innerWrap.' => 'array',
151 'innerWrap2' => 'wrap',
152 'innerWrap2.' => 'array',
153 'fontTag' => 'wrap',
154 'fontTag.' => 'array',
155 'addParams.' => 'array',
156 'textStyle.' => 'array',
157 'tableStyle.' => 'array',
158 'filelink.' => 'array',
159 'preCObject' => 'cObject',
160 'preCObject.' => 'array',
161 'postCObject' => 'cObject',
162 'postCObject.' => 'array',
163 'wrapAlign' => 'align',
164 'wrapAlign.' => 'array',
165 'typolink.' => 'array',
166 'TCAselectItem.' => 'array',
167 'space' => 'space',
168 'space.' => 'array',
169 'spaceBefore' => 'int',
170 'spaceBefore.' => 'array',
171 'spaceAfter' => 'int',
172 'spaceAfter.' => 'array',
173 'wrap' => 'wrap',
174 'wrap.' => 'array',
175 'noTrimWrap' => 'wrap',
176 'noTrimWrap.' => 'array',
177 'wrap2' => 'wrap',
178 'wrap2.' => 'array',
179 'dataWrap' => 'dataWrap',
180 'dataWrap.' => 'array',
181 'prepend' => 'cObject',
182 'prepend.' => 'array',
183 'append' => 'cObject',
184 'append.' => 'array',
185 'wrap3' => 'wrap',
186 'wrap3.' => 'array',
187 'orderedStdWrap' => 'stdWrap',
188 'orderedStdWrap.' => 'array',
189 'outerWrap' => 'wrap',
190 'outerWrap.' => 'array',
191 'insertData' => 'boolean',
192 'insertData.' => 'array',
193 'offsetWrap' => 'space',
194 'offsetWrap.' => 'array',
195 'postUserFunc' => 'functionName',
196 'postUserFuncInt' => 'functionName',
197 'prefixComment' => 'string',
198 'prefixComment.' => 'array',
199 'editIcons' => 'string',
200 'editIcons.' => 'array',
201 'editPanel' => 'boolean',
202 'editPanel.' => 'array',
203 'cacheStore' => 'hook', // this is a placeholder for storing the content in cache
204 'stdWrapPostProcess' => 'hook', // this is a placeholder for the last Hook
205 'debug' => 'boolean',
206 'debug.' => 'array',
207 'debugFunc' => 'boolean',
208 'debugFunc.' => 'array',
209 'debugData' => 'boolean',
210 'debugData.' => 'array'
211 );
212
213 /**
214 * Holds ImageMagick parameters and extensions used for compression
215 *
216 * @see IMGTEXT()
217 *
218 * 0= Default
219 * 1= Dont change! (removes all parameters for the image_object!!)
220 * 1x = GIFs
221 * 2x = JPGs
222 */
223 var $image_compression = array(
224 10 => array(
225 'params' => '', 'ext' => 'gif'
226 ),
227 11 => array(
228 'params' => '-colors 128', 'ext' => 'gif'
229 ),
230 12 => array(
231 'params' => '-colors 64', 'ext' => 'gif'
232 ),
233 13 => array(
234 'params' => '-colors 32', 'ext' => 'gif'
235 ),
236 14 => array(
237 'params' => '-colors 16', 'ext' => 'gif'
238 ),
239 15 => array(
240 'params' => '-colors 8', 'ext' => 'gif'
241 ),
242
243 20 => array(
244 'params' => '-quality 100', 'ext' => 'jpg'
245 ),
246 21 => array(
247 'params' => '-quality 90', 'ext' => 'jpg'
248 ),
249 22 => array(
250 'params' => '-quality 80', 'ext' => 'jpg'
251 ),
252 23 => array(
253 'params' => '-quality 70', 'ext' => 'jpg'
254 ),
255 24 => array(
256 'params' => '-quality 60', 'ext' => 'jpg'
257 ),
258 25 => array(
259 'params' => '-quality 50', 'ext' => 'jpg'
260 ),
261 26 => array(
262 'params' => '-quality 40', 'ext' => 'jpg'
263 ),
264 27 => array(
265 'params' => '-quality 30', 'ext' => 'jpg'
266 ),
267 28 => array(
268 'params' => '-quality 20', 'ext' => 'jpg'
269 ),
270
271 30 => array(
272 'params' => '-colors 256', 'ext' => 'png'
273 ),
274 31 => array(
275 'params' => '-colors 128', 'ext' => 'png'
276 ),
277 32 => array(
278 'params' => '-colors 64', 'ext' => 'png'
279 ),
280 33 => array(
281 'params' => '-colors 32', 'ext' => 'png'
282 ),
283 34 => array(
284 'params' => '-colors 16', 'ext' => 'png'
285 ),
286 35 => array(
287 'params' => '-colors 8', 'ext' => 'png'
288 ),
289 39 => array(
290 'params' => '', 'ext' => 'png'
291 ),
292 );
293
294 /**
295 * ImageMagick parameters for image effects
296 *
297 * @see IMGTEXT()
298 */
299 var $image_effects = array(
300 1 => '-rotate 90',
301 2 => '-rotate 270',
302 3 => '-rotate 180',
303 10 => '-colorspace GRAY',
304 11 => '-sharpen 70',
305 20 => '-normalize',
306 23 => '-contrast',
307 25 => '-gamma 1.3',
308 26 => '-gamma 0.8'
309 );
310
311 /**
312 * Loaded with the current data-record.
313 *
314 * If the instance of this class is used to render records from the database those records are found in this array.
315 * The function stdWrap has TypoScript properties that fetch field-data from this array.
316 * @see init()
317 */
318 var $data = array();
319 protected $table = '';
320 var $oldData = array(); // Used for backup...
321 var $alternativeData = ''; // If this is set with an array before stdWrap, it's used instead of $this->data in the data-property in stdWrap
322 var $parameters = array(); // Used by the parseFunc function and is loaded with tag-parameters when parsing tags.
323 var $currentValKey = 'currentValue_kidjls9dksoje';
324 var $currentRecord = ''; // This is set to the [table]:[uid] of the record delivered in the $data-array, if the cObjects CONTENT or RECORD is in operation. Note that $GLOBALS['TSFE']->currentRecord is set to an equal value but always indicating the latest record rendered.
325 var $currentRecordTotal = 0; // Set in cObj->RECORDS and cObj->CONTENT to the current number of records selected in a query.
326 var $currentRecordNumber = 0; // Incremented in cObj->RECORDS and cObj->CONTENT before each record rendering.
327 var $parentRecordNumber = 0; // Incremented in parent cObj->RECORDS and cObj->CONTENT before each record rendering.
328 var $parentRecord = array(); // If the tslib_cObj was started from CONTENT, RECORD or SEARCHRESULT cObject's this array has two keys, 'data' and 'currentRecord' which indicates the record and data for the parent cObj.
329 var $regObj; // This may be set as a reference to the calling object of eg. cObjGetSingle. Anyway, just use it as you like. It's used in productsLib.inc for example.
330
331
332 // internal
333 var $INT_include = 0; // Is set to 1 if the instance of this cObj is executed from a *_INT plugin (see pagegen, bottom of document)
334 var $checkPid_cache = array(); // This is used by checkPid, that checks if pages are accessible. The $checkPid_cache['page_uid'] is set TRUE or FALSE upon this check featuring a caching function for the next request.
335 var $checkPid_badDoktypeList = '255';
336 var $lastTypoLinkUrl = ''; // This will be set by typoLink() to the url of the most recent link created.
337 var $lastTypoLinkTarget = ''; // DO. link target.
338 var $lastTypoLinkLD = array();
339 var $substMarkerCache = array(); // Caching substituteMarkerArrayCached function
340 var $recordRegister = array(); // array that registers rendered content elements (or any table) to make sure they are not rendered recursively!
341 var $cObjHookObjectsArr = array(); // Containig hooks for userdefined cObjects
342 protected $stdWrapHookObjects = array(); // Containing hook objects for stdWrap
343 protected $getImgResourceHookObjects; // Containing hook objects for getImgResource
344
345 /**
346 * @var array with members of tslib_content_abstract
347 */
348 protected $contentObjects = array();
349
350 /**
351 * @var t3lib_file_File Current file objects (during iterations over files)
352 */
353 protected $currentFile = NULL;
354
355 /**
356 * Set to TRUE by doConvertToUserIntObject() if USER object wants to become USER_INT
357 */
358 public $doConvertToUserIntObject = FALSE;
359
360 /**
361 * Indicates current object type. Can hold one of OBJECTTYPE_ constants or FALSE.
362 * The value is set and reset inside USER() function. Any time outside of
363 * USER() it is FALSE.
364 */
365 protected $userObjectType = FALSE;
366
367 /**
368 * Indicates that object type is USER.
369 *
370 * @see tslib_cObjh::$userObjectType
371 */
372 const OBJECTTYPE_USER_INT = 1;
373
374 /**
375 * Indicates that object type is USER.
376 *
377 * @see tslib_cObjh::$userObjectType
378 */
379 const OBJECTTYPE_USER = 2;
380
381 /**
382 * Class constructor.
383 * Well, it has to be called manually since it is not a real constructor function.
384 * So after making an instance of the class, call this function and pass to it a database record and the tablename from where the record is from. That will then become the "current" record loaded into memory and accessed by the .fields property found in eg. stdWrap.
385 *
386 * @param array $data the record data that is rendered.
387 * @param string $table the table that the data record is from.
388 * @return void
389 */
390 function start($data, $table = '') {
391 global $TYPO3_CONF_VARS;
392 t3lib_file_Service_BackwardsCompatibility_TslibContentAdapterService::modifyDBRow($data, $table);
393 $this->data = $data;
394 $this->table = $table;
395 $this->currentRecord = $table ? $table . ':' . $this->data['uid'] : '';
396 $this->parameters = array();
397 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClass'])) {
398 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClass'] as $classArr) {
399 $this->cObjHookObjectsArr[$classArr[0]] = t3lib_div::getUserObj($classArr[1]);
400 }
401 }
402
403 $this->stdWrapHookObjects = array();
404 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['stdWrap'])) {
405 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['stdWrap'] as $classData) {
406 $hookObject = t3lib_div::getUserObj($classData);
407
408 if (!($hookObject instanceof tslib_content_stdWrapHook)) {
409 throw new UnexpectedValueException(
410 $classData . ' must implement interface tslib_content_stdWrapHook',
411 1195043965
412 );
413 }
414
415 $this->stdWrapHookObjects[] = $hookObject;
416 }
417 }
418
419 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['postInit'])) {
420 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['postInit'] as $classData) {
421 $postInitializationProcessor = t3lib_div::getUserObj($classData);
422
423 if (!($postInitializationProcessor instanceof tslib_content_PostInitHook)) {
424 throw new UnexpectedValueException(
425 $classData . ' must implement interface tslib_content_PostInitHook',
426 1274563549
427 );
428 }
429
430 $postInitializationProcessor->postProcessContentObjectInitialization($this);
431 }
432 }
433 }
434
435 /**
436 * Returns the current table
437 *
438 * @return string
439 */
440 public function getCurrentTable() {
441 return $this->table;
442 }
443
444 /**
445 * Clone helper.
446 *
447 * Resets the references to the TypoScript Content Object implementation
448 * objects of tslib_content_*. Otherwise they would still point to the
449 * original tslib_cObj instance's tslib_content_* instances, they in return
450 * would back-reference to the original tslib_cObj instance instead of the
451 * newly cloned tslib_cObj instance.
452 *
453 * @see http://bugs.typo3.org/view.php?id=16568
454 */
455 public function __clone() {
456 $this->contentObjects = array();
457 }
458
459 /**
460 * Gets the 'getImgResource' hook objects.
461 * The first call initializes the accordant objects.
462 *
463 * @return array The 'getImgResource' hook objects (if any)
464 */
465 protected function getGetImgResourceHookObjects() {
466 if (!isset($this->getImgResourceHookObjects)) {
467 $this->getImgResourceHookObjects = array();
468
469 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['getImgResource'])) {
470 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['getImgResource'] as $classData) {
471 $hookObject = t3lib_div::getUserObj($classData);
472
473 if (!($hookObject instanceof tslib_cObj_getImgResourceHook)) {
474 throw new UnexpectedValueException(
475 '$hookObject must implement interface tslib_cObj_getImgResourceHook',
476 1218636383
477 );
478 }
479
480 $this->getImgResourceHookObjects[] = $hookObject;
481 }
482 }
483 }
484
485 return $this->getImgResourceHookObjects;
486 }
487
488 /**
489 * Sets the internal variable parentRecord with information about current record.
490 * If the tslib_cObj was started from CONTENT, RECORD or SEARCHRESULT cObject's this array has two keys, 'data' and 'currentRecord' which indicates the record and data for the parent cObj.
491 *
492 * @param array $data: The record array
493 * @param string $currentRecord: This is set to the [table]:[uid] of the record delivered in the $data-array, if the cObjects CONTENT or RECORD is in operation. Note that $GLOBALS['TSFE']->currentRecord is set to an equal value but always indicating the latest record rendered.
494 * @return void
495 * @access private
496 */
497 function setParent($data, $currentRecord) {
498 $this->parentRecord = array(
499 'data' => $data,
500 'currentRecord' => $currentRecord
501 );
502 }
503
504
505
506 /***********************************************
507 *
508 * CONTENT_OBJ:
509 *
510 ***********************************************/
511
512 /**
513 * Returns the "current" value.
514 * The "current" value is just an internal variable that can be used by functions to pass a single value on to another function later in the TypoScript processing.
515 * It's like "load accumulator" in the good old C64 days... basically a "register" you can use as you like.
516 * The TSref will tell if functions are setting this value before calling some other object so that you know if it holds any special information.
517 *
518 * @return mixed The "current" value
519 */
520 function getCurrentVal() {
521 return $this->data[$this->currentValKey];
522 }
523
524 /**
525 * Sets the "current" value.
526 *
527 * @param mixed The variable that you want to set as "current"
528 * @return void
529 * @see getCurrentVal()
530 */
531 function setCurrentVal($value) {
532 $this->data[$this->currentValKey] = $value;
533 }
534
535 /**
536 * Rendering of a "numerical array" of cObjects from TypoScript
537 * Will call ->cObjGetSingle() for each cObject found and accumulate the output.
538 *
539 * @param array $setup: array with cObjects as values.
540 * @param string $addKey: A prefix for the debugging information
541 * @return string Rendered output from the cObjects in the array.
542 * @see cObjGetSingle()
543 */
544 function cObjGet($setup, $addKey = '') {
545 if (is_array($setup)) {
546 $sKeyArray = t3lib_TStemplate::sortedKeyList($setup);
547 $content = '';
548 foreach ($sKeyArray as $theKey) {
549 $theValue = $setup[$theKey];
550 if (intval($theKey) && !strstr($theKey, '.')) {
551 $conf = $setup[$theKey . '.'];
552 $content .= $this->cObjGetSingle($theValue, $conf, $addKey . $theKey); // Get the contentObject
553 }
554 }
555 return $content;
556 }
557 }
558
559 /**
560 * Renders a content object
561 *
562 * @param string The content object name, eg. "TEXT" or "USER" or "IMAGE"
563 * @param array The array with TypoScript properties for the content object
564 * @param string A string label used for the internal debugging tracking.
565 * @return string cObject output
566 */
567 function cObjGetSingle($name, $conf, $TSkey = '__') {
568 global $TYPO3_CONF_VARS;
569
570 $content = '';
571 // Checking that the function is not called eternally. This is done by interrupting at a depth of 100
572 $GLOBALS['TSFE']->cObjectDepthCounter--;
573 if ($GLOBALS['TSFE']->cObjectDepthCounter > 0) {
574 $name = trim($name);
575 if ($GLOBALS['TT']->LR)
576 $GLOBALS['TT']->push($TSkey, $name);
577
578 // Checking if the COBJ is a reference to another object. (eg. name of 'blabla.blabla = < styles.something')
579 if (substr($name, 0, 1) == '<') {
580 $key = trim(substr($name, 1));
581 $cF = t3lib_div::makeInstance('t3lib_TSparser');
582 // $name and $conf is loaded with the referenced values.
583 $old_conf = $conf;
584 list ($name, $conf) = $cF->getVal($key, $GLOBALS['TSFE']->tmpl->setup);
585 if (is_array($old_conf) && count($old_conf)) {
586 $conf = $this->joinTSarrays($conf, $old_conf);
587 }
588 // Getting the cObject
589 $GLOBALS['TT']->incStackPointer();
590 $content .= $this->cObjGetSingle($name, $conf, $key);
591 $GLOBALS['TT']->decStackPointer();
592 } else {
593
594 $hooked = FALSE;
595 // Application defined cObjects
596 foreach ($this->cObjHookObjectsArr as $cObjName => $hookObj) {
597 if (($name === $cObjName) && method_exists($hookObj, 'cObjGetSingleExt')) {
598 $content .= $hookObj->cObjGetSingleExt($name, $conf, $TSkey, $this);
599 $hooked = TRUE;
600 }
601 }
602 if (!$hooked) {
603 $contentObject = $this->getContentObject($name);
604 if ($contentObject) {
605 $content .= $contentObject->render($conf);
606 } else {
607 // call hook functions for extra processing
608 if ($name && is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClassDefault'])) {
609 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClassDefault'] as $classData) {
610 $hookObject = t3lib_div::getUserObj($classData);
611
612 if (!($hookObject instanceof tslib_content_cObjGetSingleHook)) {
613 throw new UnexpectedValueException(
614 '$hookObject must implement interface tslib_content_cObjGetSingleHook',
615 1195043731
616 );
617 }
618 /* @var $hookObject tslib_content_cObjGetSingleHook */
619 $content .= $hookObject->getSingleContentObject($name, (array) $conf, $TSkey, $this);
620 }
621 } else {
622 // log error in AdminPanel
623 $warning = sprintf('Content Object "%s" does not exist', $name);
624 $GLOBALS['TT']->setTSlogMessage($warning, 2);
625 }
626 }
627 }
628 }
629 if ($GLOBALS['TT']->LR)
630 $GLOBALS['TT']->pull($content);
631 }
632 // Increasing on exit...
633 $GLOBALS['TSFE']->cObjectDepthCounter++;
634 return $content;
635 }
636
637 /**
638 * Returns a new content object of type $name.
639 *
640 * @param string $name
641 * @return tslib_content_abstract
642 */
643 public function getContentObject($name) {
644 $classMapping = array(
645 'TEXT' => 'Text',
646 'CASE' => 'Case',
647 'CLEARGIF' => 'ClearGif',
648 'COBJ_ARRAY' => 'ContentObjectArray',
649 'COA' => 'ContentObjectArray',
650 'COA_INT' => 'ContentObjectArrayInternal',
651 'USER' => 'User',
652 'USER_INT' => 'UserInternal',
653 'FILE' => 'File',
654 'FILES' => 'Files',
655 'IMAGE' => 'Image',
656 'IMG_RESOURCE' => 'ImageResource',
657 'IMGTEXT' => 'ImageText',
658 'CONTENT' => 'Content',
659 'RECORDS' => 'Records',
660 'HMENU' => 'HierarchicalMenu',
661 'CTABLE' => 'ContentTable',
662 'OTABLE' => 'OffsetTable',
663 'COLUMNS' => 'Columns',
664 'HRULER' => 'HorizontalRuler',
665 'CASEFUNC' => 'Case',
666 'LOAD_REGISTER' => 'LoadRegister',
667 'RESTORE_REGISTER' => 'RestoreRegister',
668 'FORM' => 'Form',
669 'SEARCHRESULT' => 'SearchResult',
670 'TEMPLATE' => 'Template',
671 'FLUIDTEMPLATE' => 'FluidTemplate',
672 'MULTIMEDIA' => 'Multimedia',
673 'MEDIA' => 'Media',
674 'SWFOBJECT' => 'ShockwaveFlashObject',
675 'FLOWPLAYER' => 'FlowPlayer',
676 'QTOBJECT' => 'QuicktimeObject',
677 'SVG' => 'ScalableVectorGraphics',
678 'EDITPANEL' => 'EditPanel',
679 );
680 $name = $classMapping[$name];
681
682 if (!array_key_exists($name, $this->contentObjects)) {
683 try {
684 $this->contentObjects[$name] = t3lib_div::makeInstance('tslib_content_' . $name, $this);
685 } catch (ReflectionException $e) {
686 $this->contentObjects[$name] = NULL;
687 }
688 }
689 return $this->contentObjects[$name];
690 }
691
692
693 /********************************************
694 *
695 * Functions rendering content objects (cObjects)
696 *
697 ********************************************/
698
699 /**
700 * Rendering the cObject, HTML
701 *
702 * @param array array of TypoScript properties
703 * @return string Output
704 * @deprecated since 6.0, will be removed in two versions
705 */
706 function HTML($conf) {
707 t3lib_div::logDeprecatedFunction();
708 return '';
709 }
710
711 /**
712 * Rendering the cObject, FLOWPLAYER
713 *
714 * @param array $conf array of TypoScript properties
715 * @return string Output
716 */
717 function FLOWPLAYER($conf) {
718 return $this->getContentObject('FLOWPLAYER')->render($conf);
719 }
720
721
722 /**
723 * Rendering the cObject, TEXT
724 *
725 * @param array array of TypoScript properties
726 * @return string Output
727 */
728 function TEXT($conf) {
729 return $this->getContentObject('TEXT')->render($conf);
730 }
731
732 /**
733 * Rendering the cObject, CLEARGIF
734 *
735 * @param array array of TypoScript properties
736 * @return string Output
737 */
738 function CLEARGIF($conf) {
739 return $this->getContentObject('CLEARGIF')->render($conf);
740 }
741
742 /**
743 * Rendering the cObject, COBJ_ARRAY / COA and COBJ_ARRAY_INT
744 *
745 * @param array array of TypoScript properties
746 * @param string If "INT" then the cObject is a "COBJ_ARRAY_INT" (non-cached), otherwise just "COBJ_ARRAY" (cached)
747 * @return string Output
748 */
749 function COBJ_ARRAY($conf, $ext = '') {
750 if ($ext === 'INT') {
751 return $this->getContentObject('COA_INT')->render($conf);
752 } else {
753 return $this->getContentObject('COA')->render($conf);
754 }
755 }
756
757 /**
758 * Rendering the cObject, USER and USER_INT
759 *
760 * @param array array of TypoScript properties
761 * @param string If "INT" then the cObject is a "USER_INT" (non-cached), otherwise just "USER" (cached)
762 * @return string Output
763 */
764 function USER($conf, $ext = '') {
765 if ($ext === 'INT') {
766 return $this->getContentObject('USER_INT')->render($conf);
767 } else {
768 return $this->getContentObject('USER')->render($conf);
769 }
770 }
771
772 /**
773 * Retrieves a type of object called as USER or USER_INT. Object can detect their
774 * type by using this call. It returns OBJECTTYPE_USER_INT or OBJECTTYPE_USER depending on the
775 * current object execution. In all other cases it will return FALSE to indicate
776 * a call out of context.
777 *
778 * @return mixed One of OBJECTTYPE_ class constants or FALSE
779 */
780 public function getUserObjectType() {
781 return $this->userObjectType;
782 }
783
784 /**
785 * Sets the user object type
786 *
787 * @param mixed $userObjectType
788 * @return void
789 */
790 public function setUserObjectType($userObjectType) {
791 $this->userObjectType = $userObjectType;
792 }
793
794 /**
795 * Requests the current USER object to be converted to USER_INT.
796 *
797 * @return void
798 */
799 public function convertToUserIntObject() {
800 if ($this->userObjectType !== self::OBJECTTYPE_USER) {
801 $GLOBALS['TT']->setTSlogMessage('tslib_cObj::convertToUserIntObject() ' . 'is called in the wrong context or for the wrong object type', 2);
802 } else {
803 $this->doConvertToUserIntObject = TRUE;
804 }
805 }
806
807 /**
808 * Rendering the cObject, FILE
809 *
810 * @param array array of TypoScript properties
811 * @return string Output
812 */
813 function FILE($conf) {
814 return $this->getContentObject('FILE')->render($conf);
815 }
816
817 /**
818 * Rendering the cObject, FILES
819 *
820 * @param array array of TypoScript properties
821 * @return string Output
822 */
823 function FILES($conf) {
824 return $this->getContentObject('FILES')->render($conf);
825 }
826
827 /**
828 * Rendering the cObject, IMAGE
829 *
830 * @param array array of TypoScript properties
831 * @return string Output
832 * @see cImage()
833 */
834 function IMAGE($conf) {
835 return $this->getContentObject('IMAGE')->render($conf);
836 }
837
838 /**
839 * Rendering the cObject, IMG_RESOURCE
840 *
841 * @param array array of TypoScript properties
842 * @return string Output
843 * @see getImgResource()
844 */
845 function IMG_RESOURCE($conf) {
846 return $this->getContentObject('IMG_RESOURCE')->render($conf);
847 }
848
849 /**
850 * Rendering the cObject, IMGTEXT
851 *
852 * @param array array of TypoScript properties
853 * @return string Output
854 */
855 function IMGTEXT($conf) {
856 return $this->getContentObject('IMGTEXT')->render($conf);
857 }
858
859 /**
860 * Rendering the cObject, CONTENT
861 *
862 * @param array array of TypoScript properties
863 * @return string Output
864 */
865 function CONTENT($conf) {
866 return $this->getContentObject('CONTENT')->render($conf);
867 }
868
869 /**
870 * Rendering the cObject, RECORDS
871 *
872 * @param array array of TypoScript properties
873 * @return string Output
874 */
875 function RECORDS($conf) {
876 return $this->getContentObject('RECORDS')->render($conf);
877 }
878
879 /**
880 * Rendering the cObject, HMENU
881 *
882 * @param array array of TypoScript properties
883 * @return string Output
884 */
885 function HMENU($conf) {
886 return $this->getContentObject('HMENU')->render($conf);
887 }
888
889 /**
890 * Rendering the cObject, CTABLE
891 *
892 * @param array array of TypoScript properties
893 * @return string Output
894 */
895 function CTABLE($conf) {
896 return $this->getContentObject('CTABLE')->render($conf);
897 }
898
899 /**
900 * Rendering the cObject, OTABLE
901 *
902 * @param array array of TypoScript properties
903 * @return string Output
904 */
905 function OTABLE($conf) {
906 return $this->getContentObject('OTABLE')->render($conf);
907 }
908
909 /**
910 * Rendering the cObject, COLUMNS
911 *
912 * @param array array of TypoScript properties
913 * @return string Output
914 */
915 function COLUMNS($conf) {
916 return $this->getContentObject('COLUMNS')->render($conf);
917 }
918
919 /**
920 * Rendering the cObject, HRULER
921 *
922 * @param array array of TypoScript properties
923 * @return string Output
924 */
925 function HRULER($conf) {
926 return $this->getContentObject('HRULER')->render($conf);
927 }
928
929 /**
930 * Rendering the cObject, CASE
931 *
932 * @param array array of TypoScript properties
933 * @return string Output
934 */
935 function CASEFUNC($conf) {
936 return $this->getContentObject('CASE')->render($conf);
937 }
938
939 /**
940 * Rendering the cObject, LOAD_REGISTER and RESTORE_REGISTER
941 * NOTICE: This cObject does NOT return any content since it just sets internal data based on the TypoScript properties.
942 *
943 * @param array array of TypoScript properties
944 * @param string If "RESTORE_REGISTER" then the cObject rendered is "RESTORE_REGISTER", otherwise "LOAD_REGISTER"
945 * @return string Empty string (the cObject only sets internal data!)
946 */
947 function LOAD_REGISTER($conf, $name) {
948 if ($name === 'RESTORE_REGISTER') {
949 return $this->getContentObject('RESTORE_REGISTER')->render($conf);
950 } else {
951 return $this->getContentObject('LOAD_REGISTER')->render($conf);
952 }
953 }
954
955 /**
956 * Rendering the cObject, FORM
957 *
958 * @param array array of TypoScript properties
959 * @param array Alternative formdata overriding whatever comes from TypoScript
960 * @return string Output
961 */
962 function FORM($conf, $formData = '') {
963 return $this->getContentObject('FORM')->render($conf, $formData);
964 }
965
966 /**
967 * Rendering the cObject, SEARCHRESULT
968 *
969 * @param array array of TypoScript properties
970 * @return string Output
971 */
972 function SEARCHRESULT($conf) {
973 return $this->getContentObject('SEARCHRESULT')->render($conf);
974 }
975
976 /**
977 * Rendering the cObject, PHP_SCRIPT, PHP_SCRIPT_INT and PHP_SCRIPT_EXT
978 *
979 * @param array array of TypoScript properties
980 * @param string If "INT", then rendering "PHP_SCRIPT_INT"; If "EXT", then rendering "PHP_SCRIPT_EXT"; Default is rendering "PHP_SCRIPT" (cached)
981 * @return string Output
982 * @deprecated and unused since 6.0, will be removed two versions later
983 */
984 function PHP_SCRIPT($conf, $ext = '') {
985 t3lib_div::logDeprecatedFunction();
986 return '';
987 }
988
989 /**
990 * Rendering the cObject, TEMPLATE
991 *
992 * @param array array of TypoScript properties
993 * @return string Output
994 * @see substituteMarkerArrayCached()
995 */
996 function TEMPLATE($conf) {
997 return $this->getContentObject('TEMPLATE')->render($conf);
998 }
999
1000 /**
1001 * Rendering the cObject, FLUIDTEMPLATE
1002 *
1003 * @param array array of TypoScript properties
1004 * @return string the HTML output
1005 * @author Steffen Ritter <info@steffen-ritter.net>
1006 * @author Benjamin Mack <benni@typo3.org>
1007 */
1008 protected function FLUIDTEMPLATE(array $conf) {
1009 return $this->getContentObject('FLUIDTEMPLATE')->render($conf);
1010 }
1011
1012 /**
1013 * Rendering the cObject, MULTIMEDIA
1014 *
1015 * @param array array of TypoScript properties
1016 * @return string Output
1017 */
1018 function MULTIMEDIA($conf) {
1019 return $this->getContentObject('MULTIMEDIA')->render($conf);
1020 }
1021
1022 /**
1023 * Rendering the cObject, MEDIA
1024 *
1025 * @param array array of TypoScript properties
1026 * @return string Output
1027 */
1028 public function MEDIA($conf) {
1029 return $this->getContentObject('MEDIA')->render($conf);
1030 }
1031
1032 /**
1033 * Rendering the cObject, SWFOBJECT
1034 *
1035 * @param array array of TypoScript properties
1036 * @return string Output
1037 */
1038 public function SWFOBJECT($conf) {
1039 return $this->getContentObject('SWFOBJECT')->render($conf);
1040 }
1041
1042 /**
1043 * Rendering the cObject, QTOBJECT
1044 *
1045 * @param array array of TypoScript properties
1046 * @return string Output
1047 */
1048 public function QTOBJECT($conf) {
1049 return $this->getContentObject('QTOBJECT')->render($conf);
1050 }
1051
1052 /**
1053 * Rendering the cObject, SVG
1054 *
1055 * @param array array of TypoScript properties
1056 * @return string Output
1057 */
1058 public function SVG($conf) {
1059 return $this->getContentObject('SVG')->render($conf);
1060 }
1061
1062 /************************************
1063 *
1064 * Various helper functions for content objects:
1065 *
1066 ************************************/
1067
1068
1069 /**
1070 * Converts a given config in Flexform to a conf-array
1071 * @param string Flexform data
1072 * @param array array to write the data into, by reference
1073 * @param boolean is set if called recursive. Don't call function with this parameter, it's used inside the function only
1074 * @access public
1075 *
1076 */
1077 public function readFlexformIntoConf($flexData, &$conf, $recursive = FALSE) {
1078 if ($recursive === FALSE) {
1079 $flexData = t3lib_div::xml2array($flexData, 'T3');
1080 }
1081
1082 if (is_array($flexData)) {
1083 if (isset($flexData['data']['sDEF']['lDEF'])) {
1084 $flexData = $flexData['data']['sDEF']['lDEF'];
1085 }
1086
1087 foreach ($flexData as $key => $value) {
1088 if (is_array($value['el']) && count($value['el']) > 0) {
1089 foreach ($value['el'] as $ekey => $element) {
1090 if (isset($element['vDEF'])) {
1091 $conf[$ekey] = $element['vDEF'];
1092 } else {
1093 if (is_array($element)) {
1094 $this->readFlexformIntoConf($element, $conf[$key][key($element)][$ekey], TRUE);
1095 } else {
1096 $this->readFlexformIntoConf($element, $conf[$key][$ekey], TRUE);
1097 }
1098 }
1099 }
1100 } else {
1101 $this->readFlexformIntoConf($value['el'], $conf[$key], TRUE);
1102 }
1103 if ($value['vDEF']) {
1104 $conf[$key] = $value['vDEF'];
1105 }
1106 }
1107 }
1108 }
1109
1110
1111 /**
1112 * Returns all parents of the given PID (Page UID) list
1113 *
1114 * @param string A list of page Content-Element PIDs (Page UIDs) / stdWrap
1115 * @param array stdWrap array for the list
1116 * @return string A list of PIDs
1117 * @access private
1118 */
1119 function getSlidePids($pidList, $pidConf) {
1120 $pidList = isset($pidConf)
1121 ? trim($this->stdWrap($pidList, $pidConf))
1122 : trim($pidList);
1123 if (!strcmp($pidList, '')) {
1124 $pidList = 'this';
1125 }
1126 if (trim($pidList)) {
1127 $listArr = t3lib_div::intExplode(',', str_replace('this', $GLOBALS['TSFE']->contentPid, $pidList));
1128 $listArr = $this->checkPidArray($listArr);
1129 }
1130 $pidList = array();
1131 if (is_array($listArr) && count($listArr)) {
1132 foreach ($listArr as $uid) {
1133 $page = $GLOBALS['TSFE']->sys_page->getPage($uid);
1134 if (!$page['is_siteroot']) {
1135 $pidList[] = $page['pid'];
1136 }
1137 }
1138 }
1139 return implode(',', $pidList);
1140 }
1141
1142 /**
1143 * Returns a default value for a form field in the FORM cObject.
1144 * Page CANNOT be cached because that would include the inserted value for the current user.
1145 *
1146 * @param boolean If noValueInsert OR if the no_cache flag for this page is NOT set, the original default value is returned.
1147 * @param string $fieldName: The POST var name to get default value for
1148 * @param string $defaultVal: The current default value
1149 * @return string The default value, either from INPUT var or the current default, based on whether caching is enabled or not.
1150 * @access private
1151 */
1152 function getFieldDefaultValue($noValueInsert, $fieldName, $defaultVal) {
1153 if (!$GLOBALS['TSFE']->no_cache || (!isset($_POST[$fieldName]) && !isset($_GET[$fieldName])) || $noValueInsert) {
1154 return $defaultVal;
1155 } else {
1156 return t3lib_div::_GP($fieldName);
1157 }
1158 }
1159
1160 /**
1161 * Returns a <img> tag with the image file defined by $file and processed according to the properties in the TypoScript array.
1162 * Mostly this function is a sub-function to the IMAGE function which renders the IMAGE cObject in TypoScript.
1163 * This function is called by "$this->cImage($conf['file'], $conf);" from IMAGE().
1164 *
1165 * @param string File TypoScript resource
1166 * @param array TypoScript configuration properties
1167 * @return string <img> tag, (possibly wrapped in links and other HTML) if any image found.
1168 * @access private
1169 * @see IMAGE()
1170 */
1171 function cImage($file, $conf) {
1172 $info = $this->getImgResource($file, $conf['file.']);
1173 $GLOBALS['TSFE']->lastImageInfo = $info;
1174 if (is_array($info)) {
1175 $info[3] = t3lib_div::png_to_gif_by_imagemagick($info[3]);
1176 $GLOBALS['TSFE']->imagesOnPage[] = $info[3]; // This array is used to collect the image-refs on the page...
1177
1178
1179 $altParam = $this->getAltParam($conf);
1180 if($conf['params'] && !isset($conf['params.'])) {
1181 $params = ' ' . $conf['params'];
1182 } else {
1183 $params = isset($conf['params.'])
1184 ? ' ' . $this->stdWrap($conf['params'], $conf['params.'])
1185 : '';
1186 }
1187 $theValue = '<img src="' . htmlspecialchars($GLOBALS['TSFE']->absRefPrefix .
1188 t3lib_div::rawUrlEncodeFP($info[3])) . '" width="' . $info[0] . '" height="' . $info[1] . '"' .
1189 $this->getBorderAttr(' border="' . intval($conf['border']) . '"') .
1190 $params .
1191 ($altParam) .
1192 (!empty($GLOBALS['TSFE']->xhtmlDoctype) ? ' /' : '') .
1193 '>';
1194 $linkWrap = isset($conf['linkWrap.'])
1195 ? $this->stdWrap($conf['linkWrap'], $conf['linkWrap.'])
1196 : $conf['linkWrap'];
1197 if ($linkWrap) {
1198 $theValue = $this->linkWrap($theValue, $linkWrap);
1199 } elseif ($conf['imageLinkWrap']) {
1200 $theValue = $this->imageLinkWrap($theValue, $info['origFile'], $conf['imageLinkWrap.']);
1201 }
1202 $wrap = isset($conf['wrap.'])
1203 ? $this->stdWrap($conf['wrap'], $conf['wrap.'])
1204 : $conf['wrap'];
1205 if($wrap) {
1206 $theValue = $this->wrap($theValue, $conf['wrap']);
1207 }
1208 return $theValue;
1209 }
1210 }
1211
1212 /**
1213 * Returns the 'border' attribute for an <img> tag only if the doctype is not xhtml_strict, xhtml_11, xhtml_2 or html5
1214 * or if the config parameter 'disableImgBorderAttr' is not set.
1215 *
1216 * @param string the border attribute
1217 * @return string the border attribute
1218 */
1219 function getBorderAttr($borderAttr) {
1220 if (! t3lib_div::inList('xhtml_strict,xhtml_11,xhtml_2', $GLOBALS['TSFE']->xhtmlDoctype) &&
1221 $GLOBALS['TSFE']->config['config']['doctype'] != 'html5' &&
1222 ! $GLOBALS['TSFE']->config['config']['disableImgBorderAttr']) {
1223 return $borderAttr;
1224 }
1225 }
1226
1227 /**
1228 * Wraps the input string in link-tags that opens the image in a new window.
1229 *
1230 * @param string String to wrap, probably an <img> tag
1231 * @param string The original image file
1232 * @param array TypoScript properties for the "imageLinkWrap" function
1233 * @return string The input string, $string, wrapped as configured.
1234 * @see cImage()
1235 */
1236 function imageLinkWrap($string, $imageFile, $conf) {
1237 $a1 = '';
1238 $a2 = '';
1239 $content = $string;
1240 $enable = isset($conf['enable.'])
1241 ? $this->stdWrap($conf['enable'], $conf['enable.'])
1242 : $conf['enable'];
1243 if ($enable) {
1244 $content = $this->typolink($string, $conf['typolink.']);
1245 if(isset($conf['file.'])) {
1246 $imageFile = $this->stdWrap($imageFile, $conf['file.']);
1247 }
1248
1249 // imageFileLink:
1250 if ($content == $string && @is_file($imageFile)) {
1251 $parameterNames = array('width', 'height', 'effects', 'alternativeTempPath', 'bodyTag', 'title', 'wrap');
1252 $parameters = array();
1253
1254 $sample = isset($conf['sample.'])
1255 ? $this->stdWrap($conf['sample'], $conf['sample.'])
1256 : $conf['sample'];
1257 if ($sample) {
1258 $parameters['sample'] = 1;
1259 }
1260
1261 foreach ($parameterNames as $parameterName) {
1262 if(isset($conf[$parameterName.'.'])) {
1263 $conf[$parameterName] = $this->stdWrap($conf[$parameterName], $conf[$parameterName.'.']);
1264 }
1265 if (isset($conf[$parameterName]) && $conf[$parameterName]) {
1266 $parameters[$parameterName] = $conf[$parameterName];
1267 }
1268 }
1269
1270 $parametersEncoded = base64_encode(serialize($parameters));
1271
1272 $md5_value = t3lib_div::hmac(
1273 implode(
1274 '|',
1275 array($imageFile, $parametersEncoded)
1276 )
1277 );
1278
1279 $params = '&md5=' . $md5_value;
1280 foreach (str_split($parametersEncoded, 64) as $index => $chunk) {
1281 $params .= '&parameters' . rawurlencode('[') . $index . rawurlencode(']') . '=' . rawurlencode($chunk);
1282 }
1283
1284 $url = $GLOBALS['TSFE']->absRefPrefix . 'index.php?eID=tx_cms_showpic&file=' . rawurlencode($imageFile) . $params;
1285
1286 $directImageLink = isset($conf['directImageLink.'])
1287 ? $this->stdWrap($conf['directImageLink'], $conf['directImageLink.'])
1288 : $conf['directImageLink'];
1289 if ($directImageLink) {
1290 $imgResourceConf = array(
1291 'file' => $imageFile,
1292 'file.' => $conf
1293 );
1294 $url = $this->IMG_RESOURCE($imgResourceConf);
1295 if (!$url) {
1296 // if no imagemagick / gm is available
1297 $url = $imageFile;
1298 }
1299 }
1300
1301 // Create TARGET-attribute only if the right doctype is used
1302 if (!t3lib_div::inList('xhtml_strict,xhtml_11,xhtml_2', $GLOBALS['TSFE']->xhtmlDoctype)) {
1303 $target = isset($conf['target.'])
1304 ? $this->stdWrap($conf['target'], $conf['target.'])
1305 : $conf['target'];
1306 if ($target) {
1307 $target = sprintf(' target="%s"', $target);
1308 } else {
1309 $target = ' target="thePicture"';
1310 }
1311 } else {
1312 $target = '';
1313 }
1314 $conf['JSwindow'] = isset($conf['JSwindow.'])
1315 ? $this->stdWrap($conf['JSwindow'], $conf['JSwindow.'])
1316 : $conf['JSwindow'];
1317 if ($conf['JSwindow']) {
1318 if ($conf['JSwindow.']['altUrl'] || $conf['JSwindow.']['altUrl.']) {
1319 $altUrl = isset($conf['JSwindow.']['altUrl.'])
1320 ? $this->stdWrap($conf['JSwindow.']['altUrl'], $conf['JSwindow.']['altUrl.'])
1321 : $conf['JSwindow.']['altUrl'];
1322 if ($altUrl) {
1323 $url = $altUrl .
1324 ($conf['JSwindow.']['altUrl_noDefaultParams'] ? '' : '?file=' .
1325 rawurlencode($imageFile) . $params);
1326 }
1327 }
1328 $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
1329 $gifCreator->init();
1330 $gifCreator->mayScaleUp = 0;
1331
1332 $dims = $gifCreator->getImageScale($gifCreator->getImageDimensions($imageFile), $conf['width'], $conf['height'], '');
1333 $JSwindowExpand = isset($conf['JSwindow.']['expand.'])
1334 ? $this->stdWrap($conf['JSwindow.']['expand'], $conf['JSwindow.']['expand.'])
1335 : $conf['JSwindow.']['expand'];
1336 $offset = t3lib_div::intExplode(',', $JSwindowExpand . ',');
1337
1338 $newWindow = isset($conf['JSwindow.']['newWindow.'])
1339 ? $this->stdWrap($conf['JSwindow.']['newWindow'], $conf['JSwindow.']['newWindow.'])
1340 : $conf['JSwindow.']['newWindow'];
1341 $a1 = '<a href="' . htmlspecialchars($url) . '" onclick="' .
1342 htmlspecialchars('openPic(\'' . $GLOBALS['TSFE']->baseUrlWrap($url) . '\',\'' .
1343 ($newWindow ? md5($url) : 'thePicture') . '\',\'width=' .
1344 ($dims[0] + $offset[0]) . ',height=' . ($dims[1] + $offset[1]) .
1345 ',status=0,menubar=0\'); return false;') . '"' .
1346 $target . $GLOBALS['TSFE']->ATagParams . '>';
1347 $a2 = '</a>';
1348 $GLOBALS['TSFE']->setJS('openPic');
1349 } else {
1350 $conf['linkParams.']['parameter'] = $url;
1351 $string = $this->typoLink($string, $conf['linkParams.']);
1352 }
1353
1354 if(isset($conf['stdWrap.'])) {
1355 $string = $this->stdWrap($string, $conf['stdWrap.']);
1356 }
1357
1358 $content = $a1 . $string . $a2;
1359 }
1360 }
1361
1362 return $content;
1363 }
1364
1365 /**
1366 * Returns content of a file. If it's an image the content of the file is not returned but rather an image tag is.
1367 *
1368 * @param string The filename, being a TypoScript resource data type
1369 * @param string Additional parameters (attributes). Default is empty alt and title tags.
1370 * @return string If jpg,gif,jpeg,png: returns image_tag with picture in. If html,txt: returns content string
1371 * @see FILE()
1372 */
1373 function fileResource($fName, $addParams = 'alt="" title=""') {
1374 $incFile = $GLOBALS['TSFE']->tmpl->getFileName($fName);
1375 if ($incFile) {
1376 $fileinfo = t3lib_div::split_fileref($incFile);
1377 if (t3lib_div::inList('jpg,gif,jpeg,png', $fileinfo['fileext'])) {
1378 $imgFile = $incFile;
1379 $imgInfo = @getImageSize($imgFile);
1380 return '<img src="' . $GLOBALS['TSFE']->absRefPrefix . $imgFile .
1381 '" width="' . $imgInfo[0] . '" height="' . $imgInfo[1] . '"' .
1382 $this->getBorderAttr(' border="0"') . ' ' . $addParams . ' />';
1383 } elseif (filesize($incFile) < 1024 * 1024) {
1384 return $GLOBALS['TSFE']->tmpl->fileContent($incFile);
1385 }
1386 }
1387 }
1388
1389 /**
1390 * Sets the SYS_LASTCHANGED timestamp if input timestamp is larger than current value.
1391 * The SYS_LASTCHANGED timestamp can be used by various caching/indexing applications to determine if the page has new content.
1392 * Therefore you should call this function with the last-changed timestamp of any element you display.
1393 *
1394 * @param integer Unix timestamp (number of seconds since 1970)
1395 * @return void
1396 * @see tslib_fe::setSysLastChanged()
1397 */
1398 function lastChanged($tstamp) {
1399 $tstamp = intval($tstamp);
1400 if ($tstamp > intval($GLOBALS['TSFE']->register['SYS_LASTCHANGED'])) {
1401 $GLOBALS['TSFE']->register['SYS_LASTCHANGED'] = $tstamp;
1402 }
1403 }
1404
1405 /**
1406 * Wraps the input string by the $wrap value and implements the "linkWrap" data type as well.
1407 * The "linkWrap" data type means that this function will find any integer encapsulated in {} (curly braces) in the first wrap part and substitute it with the corresponding page uid from the rootline where the found integer is pointing to the key in the rootline. See link below.
1408 *
1409 * @param string Input string
1410 * @param string A string where the first two parts separated by "|" (vertical line) will be wrapped around the input string
1411 * @return string Wrapped output string
1412 * @see wrap(), cImage(), FILE()
1413 */
1414 function linkWrap($content, $wrap) {
1415 $wrapArr = explode('|', $wrap);
1416 if (preg_match('/\{([0-9]*)\}/', $wrapArr[0], $reg)) {
1417 if ($uid = $GLOBALS['TSFE']->tmpl->rootLine[$reg[1]]['uid']) {
1418 $wrapArr[0] = str_replace($reg[0], $uid, $wrapArr[0]);
1419 }
1420 }
1421 return trim($wrapArr[0]) . $content . trim($wrapArr[1]);
1422 }
1423
1424 /**
1425 * An abstraction method which creates an alt or title parameter for an HTML img, applet, area or input element and the FILE content element.
1426 * From the $conf array it implements the properties "altText", "titleText" and "longdescURL"
1427 *
1428 * @param array TypoScript configuration properties
1429 * @param boolean If set, the longdesc attribute will be generated - must only be used for img elements!
1430 * @return string Parameter string containing alt and title parameters (if any)
1431 * @see IMGTEXT(), FILE(), FORM(), cImage(), filelink()
1432 */
1433 function getAltParam($conf, $longDesc = TRUE) {
1434 $altText = isset($conf['altText.'])
1435 ? trim($this->stdWrap($conf['altText'], $conf['altText.']))
1436 : trim($conf['altText']);
1437 $titleText = isset($conf['titleText.'])
1438 ? trim($this->stdWrap($conf['titleText'], $conf['titleText.']))
1439 : trim($conf['titleText']);
1440 if (isset($conf['longdescURL.']) && $GLOBALS['TSFE']->config['config']['doctype'] != 'html5') {
1441 $longDesc = $this->typoLink_URL($conf['longdescURL.']);
1442 } else {
1443 $longDesc = trim($conf['longdescURL']);
1444 }
1445
1446 // "alt":
1447 $altParam = ' alt="' . htmlspecialchars($altText) . '"';
1448
1449 // "title":
1450 $emptyTitleHandling = 'useAlt';
1451 $emptyTitleHandling = isset($conf['emptyTitleHandling.'])
1452 ? $this->stdWrap($conf['emptyTitleHandling'], $conf['emptyTitleHandling.'])
1453 : $conf['emptyTitleHandling'];
1454 // choices: 'keepEmpty' | 'useAlt' | 'removeAttr'
1455 if ($titleText || $emptyTitleHandling == 'keepEmpty') {
1456 $altParam .= ' title="' . htmlspecialchars($titleText) . '"';
1457 } elseif (!$titleText && $emptyTitleHandling == 'useAlt') {
1458 $altParam .= ' title="' . htmlspecialchars($altText) . '"';
1459 }
1460
1461 // "longDesc" URL
1462 if ($longDesc) {
1463 $altParam .= ' longdesc="' . htmlspecialchars(strip_tags($longDesc)) . '"';
1464 }
1465
1466 return $altParam;
1467 }
1468
1469 /**
1470 * Removes forbidden characters and spaces from name/id attributes in the form tag and formfields
1471 *
1472 * @param string Input string
1473 * @return string the cleaned string
1474 * @see FORM()
1475 */
1476 function cleanFormName($name) {
1477 // turn data[x][y] into data:x:y:
1478 $name = preg_replace('/\[|\]\[?/', ':', trim($name));
1479 // remove illegal chars like _
1480 return preg_replace('#[^:a-zA-Z0-9]#', '', $name);
1481 }
1482
1483 /**
1484 * An abstraction method to add parameters to an A tag.
1485 * Uses the ATagParams property.
1486 *
1487 * @param array TypoScript configuration properties
1488 * @param boolean If set, will add the global config.ATagParams to the link
1489 * @return string String containing the parameters to the A tag (if non empty, with a leading space)
1490 * @see IMGTEXT(), filelink(), makelinks(), typolink()
1491 */
1492 function getATagParams($conf, $addGlobal = 1) {
1493 $aTagParams = '';
1494 if ($conf['ATagParams.']) {
1495 $aTagParams = ' ' . $this->stdWrap($conf['ATagParams'], $conf['ATagParams.']);
1496 } elseif ($conf['ATagParams']) {
1497 $aTagParams = ' ' . $conf['ATagParams'];
1498 }
1499 if ($addGlobal) {
1500 $aTagParams = ' ' . trim($GLOBALS['TSFE']->ATagParams . $aTagParams);
1501 }
1502
1503 // extend params
1504 if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['getATagParamsPostProc']) && is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['getATagParamsPostProc'])) {
1505 $_params = array(
1506 'conf' => &$conf,
1507 'aTagParams' => &$aTagParams
1508 );
1509 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['getATagParamsPostProc'] as $objRef) {
1510 $processor = &t3lib_div::getUserObj($objRef);
1511 $aTagParams = $processor->process( $_params, $this);
1512 }
1513 }
1514
1515 return $aTagParams;
1516 }
1517
1518 /**
1519 * All extension links should ask this function for additional properties to their tags.
1520 * Designed to add for instance an "onclick" property for site tracking systems.
1521 *
1522 * @param string URL of the website
1523 * @return string the additional tag properties
1524 */
1525 function extLinkATagParams($URL, $TYPE) {
1526 $out = '';
1527
1528 if ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['extLinkATagParamsHandler']) {
1529 $extLinkATagParamsHandler = t3lib_div::getUserObj(
1530 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['extLinkATagParamsHandler']
1531 );
1532
1533 if (method_exists($extLinkATagParamsHandler, 'main')) {
1534 $out .= trim($extLinkATagParamsHandler->main($URL, $TYPE, $this));
1535 }
1536 }
1537
1538 return trim($out) ? ' ' . trim($out) : '';
1539 }
1540
1541
1542
1543 /***********************************************
1544 *
1545 * HTML template processing functions
1546 *
1547 ***********************************************/
1548
1549 /**
1550 * Returns a subpart from the input content stream.
1551 * A subpart is a part of the input stream which is encapsulated in a
1552 * string matching the input string, $marker. If this string is found
1553 * inside of HTML comment tags the start/end points of the content block
1554 * returned will be that right outside that comment block.
1555 * Example: The contennt string is
1556 * "Hello <!--###sub1### begin--> World. How are <!--###sub1### end--> you?"
1557 * If $marker is "###sub1###" then the content returned is
1558 * " World. How are ". The input content string could just as well have
1559 * been "Hello ###sub1### World. How are ###sub1### you?" and the result
1560 * would be the same
1561 * Wrapper for t3lib_parsehtml::getSubpart which behaves identical
1562 *
1563 * @param string The content stream, typically HTML template content.
1564 * @param string The marker string, typically on the form "###[the marker string]###"
1565 * @return string The subpart found, if found.
1566 * @see substituteSubpart(), t3lib_parsehtml::getSubpart()
1567 */
1568 public function getSubpart($content, $marker) {
1569 return t3lib_parsehtml::getSubpart($content, $marker);
1570 }
1571
1572 /**
1573 * Substitute subpart in input template stream.
1574 * This function substitutes a subpart in $content with the content of
1575 * $subpartContent.
1576 * Wrapper for t3lib_parsehtml::substituteSubpart which behaves identical
1577 *
1578 * @param string The content stream, typically HTML template content.
1579 * @param string The marker string, typically on the form "###[the marker string]###"
1580 * @param mixed The content to insert instead of the subpart found. If a string, then just plain substitution happens (includes removing the HTML comments of the subpart if found). If $subpartContent happens to be an array, it's [0] and [1] elements are wrapped around the EXISTING content of the subpart (fetched by getSubpart()) thereby not removing the original content.
1581 * @param boolean If $recursive is set, the function calls itself with the content set to the remaining part of the content after the second marker. This means that proceding subparts are ALSO substituted!
1582 * @return string The processed HTML content string.
1583 * @see getSubpart(), t3lib_parsehtml::substituteSubpart()
1584 */
1585 public function substituteSubpart($content, $marker, $subpartContent, $recursive = 1) {
1586 return t3lib_parsehtml::substituteSubpart($content, $marker, $subpartContent, $recursive);
1587 }
1588
1589 /**
1590 * Substitues multiple subparts at once
1591 *
1592 * @param string The content stream, typically HTML template content.
1593 * @param array The array of key/value pairs being subpart/content values used in the substitution. For each element in this array the function will substitute a subpart in the content stream with the content.
1594 * @return string The processed HTML content string.
1595 */
1596 public function substituteSubpartArray($content, array $subpartsContent) {
1597 return t3lib_parsehtml::substituteSubpartArray($content, $subpartsContent);
1598 }
1599
1600 /**
1601 * Substitutes a marker string in the input content
1602 * (by a simple str_replace())
1603 *
1604 * @param string The content stream, typically HTML template content.
1605 * @param string The marker string, typically on the form "###[the marker string]###"
1606 * @param mixed The content to insert instead of the marker string found.
1607 * @return string The processed HTML content string.
1608 * @see substituteSubpart()
1609 */
1610 public function substituteMarker($content, $marker, $markContent) {
1611 return t3lib_parsehtml::substituteMarker($content, $marker, $markContent);
1612 }
1613
1614 /**
1615 * Multi substitution function with caching.
1616 *
1617 * This function should be a one-stop substitution function for working
1618 * with HTML-template. It does not substitute by str_replace but by
1619 * splitting. This secures that the value inserted does not themselves
1620 * contain markers or subparts.
1621 *
1622 * Note that the "caching" won't cache the content of the substition,
1623 * but only the splitting of the template in various parts. So if you
1624 * want only one cache-entry per template, make sure you always pass the
1625 * exact same set of marker/subpart keys. Else you will be flooding the
1626 * users cache table.
1627 *
1628 * This function takes three kinds of substitutions in one:
1629 * $markContentArray is a regular marker-array where the 'keys' are
1630 * substituted in $content with their values
1631 *
1632 * $subpartContentArray works exactly like markContentArray only is whole
1633 * subparts substituted and not only a single marker.
1634 *
1635 * $wrappedSubpartContentArray is an array of arrays with 0/1 keys where
1636 * the subparts pointed to by the main key is wrapped with the 0/1 value
1637 * alternating.
1638 *
1639 * @param string The content stream, typically HTML template content.
1640 * @param array Regular marker-array where the 'keys' are substituted in $content with their values
1641 * @param array Exactly like markContentArray only is whole subparts substituted and not only a single marker.
1642 * @param array An array of arrays with 0/1 keys where the subparts pointed to by the main key is wrapped with the 0/1 value alternating.
1643 * @return string The output content stream
1644 * @see substituteSubpart(), substituteMarker(), substituteMarkerInObject(), TEMPLATE()
1645 */
1646 public function substituteMarkerArrayCached($content, array $markContentArray = NULL, array $subpartContentArray = NULL, array $wrappedSubpartContentArray = NULL) {
1647 $GLOBALS['TT']->push('substituteMarkerArrayCached');
1648
1649 // If not arrays then set them
1650 if (is_null($markContentArray))
1651 $markContentArray = array(); // Plain markers
1652 if (is_null($subpartContentArray))
1653 $subpartContentArray = array(); // Subparts being directly substituted
1654 if (is_null($wrappedSubpartContentArray))
1655 $wrappedSubpartContentArray = array(); // Subparts being wrapped
1656 // Finding keys and check hash:
1657 $sPkeys = array_keys($subpartContentArray);
1658 $wPkeys = array_keys($wrappedSubpartContentArray);
1659 $aKeys = array_merge(array_keys($markContentArray), $sPkeys, $wPkeys);
1660 if (!count($aKeys)) {
1661 $GLOBALS['TT']->pull();
1662 return $content;
1663 }
1664 asort($aKeys);
1665 $storeKey = md5('substituteMarkerArrayCached_storeKey:' . serialize(array(
1666 $content, $aKeys
1667 )));
1668 if ($this->substMarkerCache[$storeKey]) {
1669 $storeArr = $this->substMarkerCache[$storeKey];
1670 $GLOBALS['TT']->setTSlogMessage('Cached', 0);
1671 } else {
1672 $storeArrDat = $GLOBALS['TSFE']->sys_page->getHash($storeKey);
1673 if (!isset($storeArrDat)) {
1674 // Initialize storeArr
1675 $storeArr = array();
1676
1677 // Finding subparts and substituting them with the subpart as a marker
1678 foreach ($sPkeys as $sPK) {
1679 $content = $this->substituteSubpart($content, $sPK, $sPK);
1680 }
1681
1682 // Finding subparts and wrapping them with markers
1683 foreach ($wPkeys as $wPK) {
1684 $content = $this->substituteSubpart($content, $wPK, array(
1685 $wPK, $wPK
1686 ));
1687 }
1688
1689 // traverse keys and quote them for reg ex.
1690 foreach ($aKeys as $tK => $tV) {
1691 $aKeys[$tK] = preg_quote($tV, '/');
1692 }
1693 $regex = '/' . implode('|', $aKeys) . '/';
1694 // Doing regex's
1695 $storeArr['c'] = preg_split($regex, $content);
1696 preg_match_all($regex, $content, $keyList);
1697 $storeArr['k'] = $keyList[0];
1698 // Setting cache:
1699 $this->substMarkerCache[$storeKey] = $storeArr;
1700
1701 // Storing the cached data:
1702 $GLOBALS['TSFE']->sys_page->storeHash($storeKey, serialize($storeArr), 'substMarkArrayCached');
1703
1704 $GLOBALS['TT']->setTSlogMessage('Parsing', 0);
1705 } else {
1706 // Unserializing
1707 $storeArr = unserialize($storeArrDat);
1708 // Setting cache:
1709 $this->substMarkerCache[$storeKey] = $storeArr;
1710 $GLOBALS['TT']->setTSlogMessage('Cached from DB', 0);
1711 }
1712 }
1713
1714 // Substitution/Merging:
1715 // Merging content types together, resetting
1716 $valueArr = array_merge($markContentArray, $subpartContentArray, $wrappedSubpartContentArray);
1717
1718 $wSCA_reg = array();
1719 $content = '';
1720 // traversing the keyList array and merging the static and dynamic content
1721 foreach ($storeArr['k'] as $n => $keyN) {
1722 $content .= $storeArr['c'][$n];
1723 if (!is_array($valueArr[$keyN])) {
1724 $content .= $valueArr[$keyN];
1725 } else {
1726 $content .= $valueArr[$keyN][(intval($wSCA_reg[$keyN]) % 2)];
1727 $wSCA_reg[$keyN]++;
1728 }
1729 }
1730 $content .= $storeArr['c'][count($storeArr['k'])];
1731
1732 $GLOBALS['TT']->pull();
1733 return $content;
1734 }
1735
1736 /**
1737 * Traverses the input $markContentArray array and for each key the marker
1738 * by the same name (possibly wrapped and in upper case) will be
1739 * substituted with the keys value in the array.
1740 *
1741 * This is very useful if you have a data-record to substitute in some
1742 * content. In particular when you use the $wrap and $uppercase values to
1743 * pre-process the markers. Eg. a key name like "myfield" could effectively
1744 * be represented by the marker "###MYFIELD###" if the wrap value
1745 * was "###|###" and the $uppercase boolean TRUE.
1746 *
1747 * @param string The content stream, typically HTML template content.
1748 * @param array The array of key/value pairs being marker/content values used in the substitution. For each element in this array the function will substitute a marker in the content stream with the content.
1749 * @param string A wrap value - [part 1] | [part 2] - for the markers before substitution
1750 * @param boolean If set, all marker string substitution is done with upper-case markers.
1751 * @param boolean If set, all unused marker are deleted.
1752 * @return string The processed output stream
1753 * @see substituteMarker(), substituteMarkerInObject(), TEMPLATE()
1754 */
1755 public function substituteMarkerArray($content, array $markContentArray, $wrap = '', $uppercase = FALSE, $deleteUnused = FALSE) {
1756 return t3lib_parsehtml::substituteMarkerArray($content, $markContentArray, $wrap, $uppercase, $deleteUnused);
1757 }
1758
1759 /**
1760 * Substitute marker array in an array of values
1761 *
1762 * @param mixed If string, then it just calls substituteMarkerArray. If array(and even multi-dim) then for each key/value pair the marker array will be substituted (by calling this function recursively)
1763 * @param array The array of key/value pairs being marker/content values used in the substitution. For each element in this array the function will substitute a marker in the content string/array values.
1764 * @return mixed The processed input variable.
1765 * @see substituteMarker()
1766 */
1767 public function substituteMarkerInObject(&$tree, array $markContentArray) {
1768 if (is_array($tree)) {
1769 foreach ($tree as $key => $value) {
1770 $this->substituteMarkerInObject($tree[$key], $markContentArray);
1771 }
1772 } else {
1773 $tree = $this->substituteMarkerArray($tree, $markContentArray);
1774 }
1775
1776 return $tree;
1777 }
1778
1779 /**
1780 * Replaces all markers and subparts in a template with the content provided in the structured array.
1781 *
1782 * @param $content
1783 * @param array $markersAndSubparts
1784 * @param string $wrap
1785 * @param bool $uppercase
1786 * @param bool $deleteUnused
1787 * @return string
1788 * @see t3lib_parsehtml::substituteMarkerAndSubpartArrayRecursive()
1789 */
1790 public function substituteMarkerAndSubpartArrayRecursive($content, array $markersAndSubparts, $wrap = '', $uppercase = FALSE,
1791 $deleteUnused = FALSE) {
1792 return t3lib_parsehtml::substituteMarkerAndSubpartArrayRecursive(
1793 $content, $markersAndSubparts, $wrap, $uppercase, $deleteUnused
1794 );
1795 }
1796
1797 /**
1798 * Adds elements to the input $markContentArray based on the values from
1799 * the fields from $fieldList found in $row
1800 *
1801 * @param array array with key/values being marker-strings/substitution values.
1802 * @param array An array with keys found in the $fieldList (typically a record) which values should be moved to the $markContentArray
1803 * @param string A list of fields from the $row array to add to the $markContentArray array. If empty all fields from $row will be added (unless they are integers)
1804 * @param boolean If set, all values added to $markContentArray will be nl2br()'ed
1805 * @param string Prefix string to the fieldname before it is added as a key in the $markContentArray. Notice that the keys added to the $markContentArray always start and end with "###"
1806 * @param boolean If set, all values are passed through htmlspecialchars() - RECOMMENDED to avoid most obvious XSS and maintain XHTML compliance.
1807 * @return array The modified $markContentArray
1808 */
1809 public function fillInMarkerArray(array $markContentArray, array $row, $fieldList = '', $nl2br = TRUE, $prefix = 'FIELD_', $HSC = FALSE) {
1810 if ($fieldList) {
1811 $fArr = t3lib_div::trimExplode(',', $fieldList, 1);
1812 foreach ($fArr as $field) {
1813 $markContentArray['###' . $prefix . $field . '###'] =
1814 $nl2br ? nl2br($row[$field], !empty($GLOBALS['TSFE']->xhtmlDoctype)) : $row[$field];
1815 }
1816 } else {
1817 if (is_array($row)) {
1818 foreach ($row as $field => $value) {
1819 if (!t3lib_utility_Math::canBeInterpretedAsInteger($field)) {
1820 if ($HSC) {
1821 $value = htmlspecialchars($value);
1822 }
1823
1824 $markContentArray['###' . $prefix . $field . '###'] =
1825 $nl2br ? nl2br($value, !empty($GLOBALS['TSFE']->xhtmlDoctype)) : $value;
1826 }
1827 }
1828 }
1829 }
1830
1831 return $markContentArray;
1832 }
1833
1834 /**
1835 * Sets the current file object during iterations over files.
1836 *
1837 * @param t3lib_file_File $fileObject The file object.
1838 */
1839 public function setCurrentFile($fileObject) {
1840 $this->currentFile = $fileObject;
1841 }
1842
1843 /**
1844 * Gets the current file object during iterations over files.
1845 *
1846 * @return t3lib_file_File The current file object.
1847 */
1848 public function getCurrentFile() {
1849 return $this->currentFile;
1850 }
1851
1852 /***********************************************
1853 *
1854 * "stdWrap" + sub functions
1855 *
1856 ***********************************************/
1857
1858 /**
1859 * The "stdWrap" function. This is the implementation of what is known as "stdWrap properties" in TypoScript.
1860 * Basically "stdWrap" performs some processing of a value based on properties in the input $conf array(holding the TypoScript "stdWrap properties")
1861 * See the link below for a complete list of properties and what they do. The order of the table with properties found in TSref (the link) follows the actual order of implementation in this function.
1862 *
1863 * If $this->alternativeData is an array it's used instead of the $this->data array in ->getData
1864 *
1865 * @param string Input value undergoing processing in this function. Possibly substituted by other values fetched from another source.
1866 * @param array TypoScript "stdWrap properties".
1867 * @return string The processed input value
1868 */
1869 public function stdWrap($content = '', $conf = array()) {
1870 if (count($this->stdWrapHookObjects)) {
1871 foreach ($this->stdWrapHookObjects as $hookObject) {
1872 if (is_callable(array($hookObject, 'stdWrapPreProcess'))) {
1873 $conf['stdWrapPreProcess'] = 1;
1874 }
1875 if (is_callable(array($hookObject, 'stdWrapOverride'))) {
1876 $conf['stdWrapOverride'] = 1;
1877 }
1878 if (is_callable(array($hookObject, 'stdWrapProcess'))) {
1879 $conf['stdWrapProcess'] = 1;
1880 }
1881 if (is_callable(array($hookObject, 'stdWrapPostProcess'))) {
1882 $conf['stdWrapPostProcess'] = 1;
1883 }
1884 }
1885 }
1886
1887 if (is_array($conf) && count($conf)) {
1888
1889 // cache handling
1890 if (is_array($conf['cache.'])) {
1891 $conf['cache.']['key'] = $this->stdWrap($conf['cache.']['key'], $conf['cache.']['key.']);
1892 $conf['cache.']['tags'] = $this->stdWrap($conf['cache.']['tags'], $conf['cache.']['tags.']);
1893 $conf['cache.']['lifetime'] = $this->stdWrap($conf['cache.']['lifetime'], $conf['cache.']['lifetime.']);
1894
1895 $conf['cacheRead'] = 1;
1896 $conf['cacheStore'] = 1;
1897 }
1898
1899 // check, which of the available stdWrap functions is needed for the current conf Array
1900 // and keep only those but still in the same order
1901 $sortedConf = array_intersect_key($this->stdWrapOrder, $conf);
1902 // functions types that should not make use of nested stdWrap function calls to avoid conflicts with internal TypoScript used by these functions
1903 $stdWrapDisabledFunctionTypes = 'cObject,functionName,stdWrap';
1904 // additional Array to check whether a function has already been executed
1905 $isExecuted = array();
1906 // additional switch to make sure 'required', 'if' and 'fieldRequired'
1907 // will still stop rendering immediately in case they return FALSE
1908
1909 $this->stdWrapRecursionLevel++;
1910 $this->stopRendering[$this->stdWrapRecursionLevel] = FALSE;
1911
1912 // execute each function in the predefined order
1913 foreach ($sortedConf as $stdWrapName => $functionType) {
1914 // eliminate the second key of a pair 'key'|'key.' to make sure functions get called only once and check if rendering has been stopped
1915 if (!$isExecuted[$stdWrapName] &&
1916 !$this->stopRendering[$this->stdWrapRecursionLevel]) {
1917 $functionName = rtrim($stdWrapName, '.');
1918 $functionProperties = $functionName . '.';
1919 // if there is any code one the next level, check if it contains "official" stdWrap functions
1920 // if yes, execute them first - will make each function stdWrap aware
1921 // so additional stdWrap calls within the functions can be removed, since the result will be the same
1922 // exception: the recursive stdWrap function and cObject will still be using their own stdWrap call, since it modifies the content and not a property
1923 if (count($conf[$functionProperties]) &&
1924 !t3lib_div::inList($stdWrapDisabledFunctionTypes, $functionType)) {
1925 if (array_intersect_key($this->stdWrapOrder, $conf[$functionProperties])) {
1926 $conf[$functionName] = $this->stdWrap($conf[$functionName], $conf[$functionProperties]);
1927 }
1928 }
1929 // get just that part of $conf that is needed for the particular function
1930 $singleConf = array(
1931 $functionName => $conf[$functionName],
1932 $functionProperties => $conf[$functionProperties]
1933 );
1934
1935 // in this special case 'spaceBefore' and 'spaceAfter' need additional stuff from 'space.''
1936 if ($functionName == 'spaceBefore' || $functionName == 'spaceAfter') {
1937 $singleConf['space.'] = $conf['space.'];
1938 }
1939
1940 // hand over the whole $conf array to the stdWrapHookObjects
1941 if ($functionType === 'hook') {
1942 $singleConf = $conf;
1943 }
1944 // check if key is still containing something, since it might have been changed by next level stdWrap before
1945 if ((isset($conf[$functionName]) || $conf[$functionProperties]) &&
1946 !($functionType == 'boolean' && !$conf[$functionName])) {
1947 //add both keys - with and without the dot - to the set of executed functions
1948 $isExecuted[$functionName] = TRUE;
1949 $isExecuted[$functionProperties] = TRUE;
1950 // call the function with the prefix stdWrap_ to make sure nobody can execute functions just by adding their name to the TS Array
1951 $functionName = 'stdWrap_' . $functionName;
1952 $content = $this->$functionName(
1953 $content,
1954 $singleConf
1955 );
1956 // for booleans we have to mark the function as executed in any case, even if it has been 0, '' or false to avoid a second call based on the functionProperties, which would always be true
1957 } elseif($functionType == 'boolean' && !$conf[$functionName]) {
1958 $isExecuted[$functionName] = TRUE;
1959 $isExecuted[$functionProperties] = TRUE;
1960 }
1961 }
1962 }
1963
1964 unset($this->stopRendering[$this->stdWrapRecursionLevel]);
1965 $this->stdWrapRecursionLevel--;
1966
1967 }
1968 return $content;
1969 }
1970
1971 /**
1972 * stdWrap pre process hook
1973 * can be used by extensions authors to modify the behaviour of stdWrap functions to their needs
1974 * this hook will execute functions before any other stdWrap function can modify anything
1975 *
1976 * @param string Input value undergoing processing in these functions.
1977 * @param array All stdWrap properties, not just the ones for a particular function.
1978 * @return string The processed input value
1979 */
1980 public function stdWrap_stdWrapPreProcess($content = '', $conf = array()) {
1981 foreach ($this->stdWrapHookObjects as $hookObject) {
1982 $content = $hookObject->stdWrapPreProcess($content, $conf, $this);
1983 }
1984 return $content;
1985 }
1986
1987 /**
1988 * Check if content was cached before (depending on the given cache key)
1989 *
1990 * @param string Input value undergoing processing in these functions.
1991 * @param array All stdWrap properties, not just the ones for a particular function.
1992 * @return string The processed input value
1993 */
1994 public function stdWrap_cacheRead($content = '', $conf = array()) {
1995 if (!empty($conf['cache.']['key'])) {
1996 $cacheFrontend = $GLOBALS['typo3CacheManager']->getCache('cache_hash'); /* @var $cacheFrontend t3lib_cache_frontend_VariableFrontend */
1997 if ($cacheFrontend && $cacheFrontend->has($conf['cache.']['key'])) {
1998 $content = $cacheFrontend->get($conf['cache.']['key']);
1999 $this->stopRendering[$this->stdWrapRecursionLevel] = TRUE;
2000 }
2001 }
2002 return $content;
2003 }
2004
2005 /**
2006 * setContentToCurrent
2007 * actually it just does the contrary: Sets the value of 'current' based on current content
2008 *
2009 * @param string Input value undergoing processing in this function.
2010 * @param array stdWrap properties for setContentToCurrent.
2011 * @return string The processed input value
2012 */
2013 public function stdWrap_setContentToCurrent($content = '', $conf = array()) {
2014 $this->data[$this->currentValKey] = $content;
2015 return $content;
2016 }
2017
2018 /**
2019 * setCurrent
2020 * Sets the value of 'current' based on the outcome of stdWrap operations
2021 *
2022 * @param string Input value undergoing processing in this function.
2023 * @param array stdWrap properties for setCurrent.
2024 * @return string The processed input value
2025 */
2026 public function stdWrap_setCurrent($content = '', $conf = array()) {
2027 $this->data[$this->currentValKey] = $conf['setCurrent'];
2028 return $content;
2029 }
2030
2031 /**
2032 * lang
2033 * Translates content based on the language currently used by the FE
2034 *
2035 * @param string Input value undergoing processing in this function.
2036 * @param array stdWrap properties for lang.
2037 * @return string The processed input value
2038 */
2039 public function stdWrap_lang($content = '', $conf = array()) {
2040 if (isset($conf['lang.']) && $GLOBALS['TSFE']->config['config']['language'] && isset($conf['lang.'][$GLOBALS['TSFE']->config['config']['language']])) {
2041 $content = $conf['lang.'][$GLOBALS['TSFE']->config['config']['language']];
2042 }
2043 return $content;
2044 }
2045
2046 /**
2047 * data
2048 * Gets content from different sources based on getText functions, makes use of alternativeData, when set
2049 *
2050 * @param string Input value undergoing processing in this function.
2051 * @param array stdWrap properties for data.
2052 * @return string The processed input value
2053 */
2054 public function stdWrap_data($content = '', $conf = array()) {
2055 $content = $this->getData($conf['data'], is_array($this->alternativeData) ? $this->alternativeData : $this->data);
2056 $this->alternativeData = ''; // This must be unset directly after
2057 return $content;
2058 }
2059
2060 /**
2061 * field
2062 * Gets content from a DB field
2063 *
2064 * @param string Input value undergoing processing in this function.
2065 * @param array stdWrap properties for field.
2066 * @return string The processed input value
2067 */
2068 public function stdWrap_field($content = '', $conf = array()) {
2069 $content = $this->getFieldVal($conf['field']);
2070 return $content;
2071 }
2072
2073 /**
2074 * current
2075 * Gets content that has been perviously set as 'current'
2076 * Can be set via setContentToCurrent or setCurrent or will be set automatically i.e. inside the split function
2077 *
2078 * @param string Input value undergoing processing in this function.
2079 * @param array stdWrap properties for current.
2080 * @return string The processed input value
2081 */
2082 public function stdWrap_current($content = '', $conf = array()) {
2083 $content = $this->data[$this->currentValKey];
2084 return $content;
2085 }
2086
2087 /**
2088 * cObject
2089 * Will replace the content with the value of a any official TypoScript cObject
2090 * like TEXT, COA, HMENU
2091 *
2092 * @param string Input value undergoing processing in this function.
2093 * @param array stdWrap properties for cObject.
2094 * @return string The processed input value
2095 */
2096 public function stdWrap_cObject($content = '', $conf = array()) {
2097 $content = $this->cObjGetSingle($conf['cObject'], $conf['cObject.'], '/stdWrap/.cObject');
2098 return $content;
2099 }
2100
2101 /**
2102 * numRows
2103 * Counts the number of returned records of a DB operation
2104 * makes use of select internally
2105 *
2106 * @param string Input value undergoing processing in this function.
2107 * @param array stdWrap properties for numRows.
2108 * @return string The processed input value
2109 */
2110 public function stdWrap_numRows($content = '', $conf = array()) {
2111 $content = $this->numRows($conf['numRows.']);
2112 return $content;
2113 }
2114
2115 /**
2116 * filelist
2117 * Will create a list of files based on some additional parameters
2118 *
2119 * @param string Input value undergoing processing in this function.
2120 * @param array stdWrap properties for filelist.
2121 * @return string The processed input value
2122 */
2123 public function stdWrap_filelist($content = '', $conf = array()) {
2124 $content = $this->filelist($conf['filelist']);
2125 return $content;
2126 }
2127
2128 /**
2129 * preUserFunc
2130 * Will execute a user public function before the content will be modified by any other stdWrap function
2131 *
2132 * @param string Input value undergoing processing in this function.
2133 * @param array stdWrap properties for preUserFunc.
2134 * @return string The processed input value
2135 */
2136 public function stdWrap_preUserFunc($content = '', $conf = array()) {
2137 $content = $this->callUserFunction($conf['preUserFunc'], $conf['preUserFunc.'], $content);
2138 return $content;
2139 }
2140
2141 /**
2142 * stdWrap override hook
2143 * can be used by extensions authors to modify the behaviour of stdWrap functions to their needs
2144 * this hook will execute functions on existing content but still before the content gets modified or replaced
2145 *
2146 * @param string Input value undergoing processing in these functions.
2147 * @param array All stdWrap properties, not just the ones for a particular function.
2148 * @return string The processed input value
2149 */
2150 public function stdWrap_stdWrapOverride($content = '', $conf = array()) {
2151 foreach ($this->stdWrapHookObjects as $hookObject) {
2152 $content = $hookObject->stdWrapOverride($content, $conf, $this);
2153 }
2154 return $content;
2155 }
2156
2157 /**
2158 * override
2159 * Will override the current value of content with its own value'
2160 *
2161 * @param string Input value undergoing processing in this function.
2162 * @param array stdWrap properties for override.
2163 * @return string The processed input value
2164 */
2165 public function stdWrap_override($content = '', $conf = array()) {
2166 if (trim($conf['override'])) {
2167 $content = $conf['override'];
2168 }
2169 return $content;
2170 }
2171
2172 /**
2173 * preIfEmptyListNum
2174 * Gets a value off a CSV list before the following ifEmpty check
2175 * Makes sure that the result of ifEmpty will be TRUE in case the CSV does not contain a value at the position given by preIfEmptyListNum
2176 *
2177 * @param string Input value undergoing processing in this function.
2178 * @param array stdWrap properties for preIfEmptyListNum.
2179 * @return string The processed input value
2180 */
2181 public function stdWrap_preIfEmptyListNum($content = '', $conf = array()) {
2182 $content = $this->listNum($content, $conf['preIfEmptyListNum'], $conf['preIfEmptyListNum.']['splitChar']);
2183 return $content;
2184 }
2185
2186 /**
2187 * ifEmpty
2188 * Will set content to a replacement value in case the trimmed value of content returns FALSE
2189 * 0 (zero) will be replaced as well
2190 *
2191 * @param string Input value undergoing processing in this function.
2192 * @param array stdWrap properties for ifEmpty.
2193 * @return string The processed input value
2194 */
2195 public function stdWrap_ifEmpty($content = '', $conf = array()) {
2196 if (!trim($content)) {
2197 $content = $conf['ifEmpty'];
2198 }
2199 return $content;
2200 }
2201
2202 /**
2203 * ifBlank
2204 * Will set content to a replacement value in case the trimmed value of content has no length
2205 * 0 (zero) will not be replaced
2206 *
2207 * @param string Input value undergoing processing in this function.
2208 * @param array stdWrap properties for ifBlank.
2209 * @return string The processed input value
2210 */
2211 public function stdWrap_ifBlank($content = '', $conf = array()) {
2212 if (!strlen(trim($content))) {
2213 $content = $conf['ifBlank'];
2214 }
2215 return $content;
2216 }
2217
2218 /**
2219 * listNum
2220 * Gets a value off a CSV list after ifEmpty check
2221 * Might return an empty value in case the CSV does not contain a value at the position given by listNum
2222 * Use preIfEmptyListNum to avoid that behaviour
2223 *
2224 * @param string Input value undergoing processing in this function.
2225 * @param array stdWrap properties for listNum.
2226 * @return string The processed input value
2227 */
2228 public function stdWrap_listNum($content = '', $conf = array()) {
2229 $content = $this->listNum($content, $conf['listNum'], $conf['listNum.']['splitChar']);
2230 return $content;
2231 }
2232
2233 /**
2234 * trim
2235 * Cuts off any whitespace at the beginning and the end of the content
2236 *
2237 * @param string Input value undergoing processing in this function.
2238 * @param array stdWrap properties for trim.
2239 * @return string The processed input value
2240 */
2241 public function stdWrap_trim($content = '', $conf = array()) {
2242 $content = trim($content);
2243 return $content;
2244 }
2245
2246 /**
2247 * stdWrap
2248 * A recursive call of the stdWrap function set
2249 * This enables the user to execute stdWrap functions in another than the predefined order
2250 * It modifies the content, not the property
2251 * while the new feature of chained stdWrap functions modifies the property and not the content
2252 *
2253 * @param string Input value undergoing processing in this function.
2254 * @param array stdWrap properties for stdWrap.
2255 * @return string The processed input value
2256 */
2257 public function stdWrap_stdWrap($content = '', $conf = array()) {
2258 $content = $this->stdWrap($content, $conf['stdWrap.']);
2259 return $content;
2260 }
2261
2262 /**
2263 * stdWrap process hook
2264 * can be used by extensions authors to modify the behaviour of stdWrap functions to their needs
2265 * this hook executes functions directly after the recursive stdWrap function call but still before the content gets modified
2266 *
2267 * @param string Input value undergoing processing in these functions.
2268 * @param array All stdWrap properties, not just the ones for a particular function.
2269 * @return string The processed input value
2270 */
2271 public function stdWrap_stdWrapProcess($content = '', $conf = array()) {
2272 foreach ($this->stdWrapHookObjects as $hookObject) {
2273 $content = $hookObject->stdWrapProcess($content, $conf, $this);
2274 }
2275 return $content;
2276 }
2277
2278 /**
2279 * required
2280 * Will immediately stop rendering and return an empty value
2281 * when there is no content at this point
2282 *
2283 * @param string Input value undergoing processing in this function.
2284 * @param array stdWrap properties for required.
2285 * @return string The processed input value
2286 */
2287 public function stdWrap_required($content = '', $conf = array()) {
2288 if ((string) $content == '') {
2289 $content = '';
2290 $this->stopRendering[$this->stdWrapRecursionLevel] = TRUE;
2291 }
2292 return $content;
2293 }
2294
2295 /**
2296 * if
2297 * Will immediately stop rendering and return an empty value
2298 * when the result of the checks returns FALSE
2299 *
2300 * @param string Input value undergoing processing in this function.
2301 * @param array stdWrap properties for if.
2302 * @return string The processed input value
2303 */
2304 public function stdWrap_if($content = '', $conf = array()) {
2305 if (!$this->checkIf($conf['if.'])) {
2306 $content = '';
2307 $this->stopRendering[$this->stdWrapRecursionLevel] = TRUE;
2308 }
2309 return $content;
2310 }
2311
2312 /**
2313 * fieldRequired
2314 * Will immediately stop rendering and return an empty value
2315 * when there is no content in the field given by fieldRequired
2316 *
2317 * @param string Input value undergoing processing in this function.
2318 * @param array stdWrap properties for fieldRequired.
2319 * @return string The processed input value
2320 */
2321 public function stdWrap_fieldRequired($content = '', $conf = array()) {
2322 if (!trim($this->data[$conf['fieldRequired']])) {
2323 $content = '';
2324 $this->stopRendering[$this->stdWrapRecursionLevel] = TRUE;
2325 }
2326 return $content;
2327 }
2328
2329 /**
2330 * csConv
2331 * Will convert the current chracter set of the content to the one given in csConv
2332 *
2333 * @param string Input value undergoing processing in this function.
2334 * @param array stdWrap properties for csConv.
2335 * @return string The processed input value
2336 */
2337 public function stdWrap_csConv($content = '', $conf = array()) {
2338 $content = $GLOBALS['TSFE']->csConv($content, $conf['csConv']);
2339 return $content;
2340 }
2341
2342 /**
2343 * parseFunc
2344 * Will parse the content based on functions given as stdWrap properties
2345 * Heavily used together with RTE based content
2346 *
2347 * @param string Input value undergoing processing in this function.
2348 * @param array stdWrap properties for parseFunc.
2349 * @return string The processed input value
2350 */
2351 public function stdWrap_parseFunc($content = '', $conf = array()) {
2352 $content = $this->parseFunc($content, $conf['parseFunc.'], $conf['parseFunc']);
2353 return $content;
2354 }
2355
2356 /**
2357 * HTMLparser
2358 * Will parse HTML content based on functions given as stdWrap properties
2359 * Heavily used together with RTE based content
2360 *
2361 * @param string Input value undergoing processing in this function.
2362 * @param array stdWrap properties for HTMLparser.
2363 * @return string The processed input value
2364 */
2365 public function stdWrap_HTMLparser($content = '', $conf = array()) {
2366 if (is_array($conf['HTMLparser.'])) {
2367 $content = $this->HTMLparser_TSbridge($content, $conf['HTMLparser.']);
2368 }
2369 return $content;
2370 }
2371
2372 /**
2373 * split
2374 * Will split the content by a given token and treat the results separately
2375 * Automatically fills 'current' with a single result
2376 *
2377 * @param string Input value undergoing processing in this function.
2378 * @param array stdWrap properties for split.
2379 * @return string The processed input value
2380 */
2381 public function stdWrap_split($content = '', $conf = array()) {
2382 $content = $this->splitObj($content, $conf['split.']);
2383 return $content;
2384 }
2385
2386 /**
2387 * replacement
2388 * Will execute replacements on the content (optionally with preg-regex)
2389 *
2390 * @param string Input value undergoing processing in this function.
2391 * @param array stdWrap properties for replacement.
2392 * @return string The processed input value
2393 */
2394 public function stdWrap_replacement($content = '', $conf = array()) {
2395 $content = $this->replacement($content, $conf['replacement.']);
2396 return $content;
2397 }
2398
2399 /**
2400 * prioriCalc
2401 * Will use the content as a mathematical term and calculate the result
2402 * Can be set to 1 to just get a calculated value or 'intval' to get the integer of the result
2403 *
2404 * @param string Input value undergoing processing in this function.
2405 * @param array stdWrap properties for prioriCalc.
2406 * @return string The processed input value
2407 */
2408 public function stdWrap_prioriCalc($content = '', $conf = array()) {
2409 $content = t3lib_utility_Math::calculateWithParentheses($content);
2410 if ($conf['prioriCalc'] == 'intval')
2411 $content = intval($content);
2412 return $content;
2413 }
2414
2415 /**
2416 * char
2417 * Will return a character based on its position within the current character set
2418 *
2419 * @param string Input value undergoing processing in this function.
2420 * @param array stdWrap properties for char.
2421 * @return string The processed input value
2422 */
2423 public function stdWrap_char($content = '', $conf = array()) {
2424 $content = chr(intval($conf['char']));
2425 return $content;
2426 }
2427
2428 /**
2429 * intval
2430 * Will return an integer value of the current content
2431 *
2432 * @param string Input value undergoing processing in this function.
2433 * @param array stdWrap properties for intval.
2434 * @return string The processed input value
2435 */
2436 public function stdWrap_intval($content = '', $conf = array()) {
2437 $content = intval($content);
2438 return $content;
2439 }
2440
2441 /**
2442 * Will return a hashed value of the current content
2443 *
2444 * @param string Input value undergoing processing in this function.
2445 * @param array stdWrap properties for hash.
2446 * @return string The processed input value
2447 * @link http://php.net/manual/de/function.hash-algos.php for a list of supported hash algorithms
2448 */
2449 public function stdWrap_hash($content = '', array $conf = array()) {
2450 $algorithm = isset($conf['hash.'])
2451 ? $this->stdWrap($conf['hash'], $conf['hash.'])
2452 : $conf['hash'];
2453 if (function_exists('hash') && in_array($algorithm, hash_algos())) {
2454 $content = hash($algorithm, $content);
2455 } else {
2456 // non-existing hashing algorithm
2457 $content = '';
2458 }
2459 return $content;
2460 }
2461
2462 /**
2463 * stdWrap_round will return a rounded number with ceil(), floor() or round(), defaults to round()
2464 * Only the english number format is supported . (dot) as decimal point
2465 *
2466 * @param string Input value undergoing processing in this function.
2467 * @param array stdWrap properties for round.
2468 * @return string The processed input value
2469 */
2470 public function stdWrap_round($content = '', $conf = array()) {
2471 $content = $this->round($content, $conf['round.']);
2472 return $content;
2473 }
2474
2475 /**
2476 * numberFormat
2477 * Will return a formatted number based on configuration given as stdWrap properties
2478 *
2479 * @param string Input value undergoing processing in this function.
2480 * @param array stdWrap properties for numberFormat.
2481 * @return string The processed input value
2482 */
2483 public function stdWrap_numberFormat($content = '', $conf = array()) {
2484 $content = $this->numberFormat($content, $conf['numberFormat.']);
2485 return $content;
2486 }
2487
2488 /**
2489 * expandList
2490 * Will return a formatted number based on configuration given as stdWrap properties
2491 *
2492 * @param string Input value undergoing processing in this function.
2493 * @param array stdWrap properties for expandList.
2494 * @return string The processed input value
2495 */
2496 public function stdWrap_expandList($content = '', $conf = array()) {
2497 $content = t3lib_div::expandList($content);
2498 return $content;
2499 }
2500
2501 /**
2502 * date
2503 * Will return a formatted date based on configuration given according to PHP date/gmdate properties
2504 * Will return gmdate when the property GMT returns TRUE
2505 *
2506 * @param string $content Input value undergoing processing in this function.
2507 * @param array $conf stdWrap properties for date.
2508 * @return string The processed input value
2509 */
2510 public function stdWrap_date($content = '', $conf = array()) {
2511 // check for zero length string to mimic default case of date/gmdate.
2512 $content = $content == '' ? $GLOBALS['EXEC_TIME'] : intval($content);
2513 $content = ($conf['date.']['GMT'] ? gmdate($conf['date'], $content) : date($conf['date'], $content));
2514 return $content;
2515 }
2516
2517 /**
2518 * strftime
2519 * Will return a formatted date based on configuration given according to PHP strftime/gmstrftime properties
2520 * Will return gmstrftime when the property GMT returns TRUE
2521 *
2522 * @param string Input value undergoing processing in this function.
2523 * @param array stdWrap properties for strftime.
2524 * @return string The processed input value
2525 */
2526 public function stdWrap_strftime($content = '', $conf = array()) {
2527 $content = ($conf['strftime.']['GMT'] ? gmstrftime($conf['strftime'], $content) : strftime($conf['strftime'], $content));
2528 $tmp_charset = $conf['strftime.']['charset'] ? $conf['strftime.']['charset'] : $GLOBALS['TSFE']->localeCharset;
2529 if ($tmp_charset) {
2530 $content = $GLOBALS['TSFE']->csConv($content, $tmp_charset);
2531 }
2532 return $content;
2533 }
2534
2535 /**
2536 * age
2537 * Will return the age of a given timestamp based on configuration given by stdWrap properties
2538 *
2539 * @param string Input value undergoing processing in this function.
2540 * @param array stdWrap properties for age.
2541 * @return string The processed input value
2542 */
2543 public function stdWrap_age($content = '', $conf = array()) {
2544 $content = $this->calcAge($GLOBALS['EXEC_TIME'] - $content, $conf['age']);
2545 return $content;
2546 }
2547
2548 /**
2549 * case
2550 * Will transform the content to be upper or lower case only
2551 * Leaves HTML tags untouched
2552 *
2553 * @param string Input value undergoing processing in this function.
2554 * @param array stdWrap properties for case.
2555 * @return string The processed input value
2556 */
2557 public function stdWrap_case($content = '', $conf = array()) {
2558 $content = $this->HTMLcaseshift($content, $conf['case']);
2559 return $content;
2560 }
2561
2562 /**
2563 * bytes
2564 * Will return the size of a given number in Bytes *
2565 *
2566 * @param string Input value undergoing processing in this function.
2567 * @param array stdWrap properties for bytes.
2568 * @return string The processed input value
2569 */
2570 public function stdWrap_bytes($content = '', $conf = array()) {
2571 $content = t3lib_div::formatSize($content, $conf['bytes.']['labels']);
2572 return $content;
2573 }
2574
2575 /**
2576 * substring
2577 * Will return a substring based on position information given by stdWrap properties
2578 *
2579 * @param string Input value undergoing processing in this function.
2580 * @param array stdWrap properties for substring.
2581 * @return string The processed input value
2582 */
2583 public function stdWrap_substring($content = '', $conf = array()) {
2584 $content = $this->substring($content, $conf['substring']);
2585 return $content;
2586 }
2587
2588 /**
2589 * removeBadHTML
2590 * Removes HTML tags based on stdWrap properties
2591 *
2592 * @param string Input value undergoing processing in this function.
2593 * @param array stdWrap properties for removeBadHTML.
2594 * @return string The processed input value
2595 */
2596 public function stdWrap_removeBadHTML($content = '', $conf = array()) {
2597 $content = $this->removeBadHTML($content, $conf['removeBadHTML.']);
2598 return $content;
2599 }
2600
2601 /**
2602 * cropHTML
2603 * Crops content to a given size while leaving HTML tags untouched
2604 *
2605 * @param string Input value undergoing processing in this function.
2606 * @param array stdWrap properties for cropHTML.
2607 * @return string The processed input value
2608 */
2609 public function stdWrap_cropHTML($content = '', $conf = array()) {
2610 $content = $this->cropHTML($content, $conf['cropHTML']);
2611 return $content;
2612 }
2613
2614 /**
2615 * stripHtml
2616 * Copmletely removes HTML tags from content
2617 *
2618 * @param string Input value undergoing processing in this function.
2619 * @param array stdWrap properties for stripHtml.
2620 * @return string The processed input value
2621 */
2622 public function stdWrap_stripHtml($content = '', $conf = array()) {
2623 $content = strip_tags($content);
2624 return $content;
2625 }
2626
2627 /**
2628 * cropHTML
2629 * Crops content to a given size without caring abhout HTML tags
2630 *
2631 * @param string Input value undergoing processing in this function.
2632 * @param array stdWrap properties for crop.
2633 * @return string The processed input value
2634 */
2635 public function stdWrap_crop($content = '', $conf = array()) {
2636 $content = $this->crop($content, $conf['crop']);
2637 return $content;
2638 }
2639
2640 /**
2641 * rawUrlEncode
2642 * Encodes content to be used within URLs
2643 *
2644 * @param string Input value undergoing processing in this function.
2645 * @param array stdWrap properties for rawUrlEncode.
2646 * @return string The processed input value
2647 */
2648 public function stdWrap_rawUrlEncode($content = '', $conf = array()) {
2649 $content = rawurlencode($content);
2650 return $content;
2651 }
2652
2653 /**
2654 * htmlSpecialChars
2655 * Transforms HTML tags to readable text by replacing special characters with their HTML entity
2656 * When preserveEntities returns TRUE, existing entities will be left untouched
2657 *
2658 * @param string Input value undergoing processing in this function.
2659 * @param array stdWrap properties for htmlSpecalChars.
2660 * @return string The processed input value
2661 */
2662 public function stdWrap_htmlSpecialChars($content = '', $conf = array()) {
2663 $content = htmlSpecialChars($content);
2664 if ($conf['htmlSpecialChars.']['preserveEntities'])
2665 $content = t3lib_div::deHSCentities($content);
2666 return $content;
2667 }
2668
2669 /**
2670 * doubleBrTag
2671 * Searches for double line breaks and replaces them with the given value
2672 *
2673 * @param string Input value undergoing processing in this function.
2674 * @param array stdWrap properties for doubleBrTag.
2675 * @return string The processed input value
2676 */
2677 public function stdWrap_doubleBrTag($content = '', $conf = array()) {
2678 $content = preg_replace("/\r?\n[\t ]*\r?\n/", $conf['doubleBrTag'], $content);
2679 return $content;
2680 }
2681
2682 /**
2683 * br
2684 * Searches for single line breaks and replaces them with a <br />/<br> tag
2685 * according to the doctype
2686 *
2687 * @param string Input value undergoing processing in this function.
2688 * @param array stdWrap properties for br.
2689 * @return string The processed input value
2690 */
2691 public function stdWrap_br($content = '', $conf = array()) {
2692 $content = nl2br($content, !empty($GLOBALS['TSFE']->xhtmlDoctype));
2693 return $content;
2694 }
2695
2696 /**
2697 * brTag
2698 * Searches for single line feeds and replaces them with the given value
2699 *
2700 * @param string Input value undergoing processing in this function.
2701 * @param array stdWrap properties for brTag.
2702 * @return string The processed input value
2703 */
2704 public function stdWrap_brTag($content = '', $conf = array()) {
2705 $content = str_replace(LF, $conf['brTag'], $content);
2706 return $content;
2707 }
2708
2709 /**
2710 * encapsLines
2711 * Modifies text blocks by searching for lines which are not surrounded by HTML tags yet
2712 * and wrapping them with values given by stdWrap properties
2713 *
2714 * @param string Input value undergoing processing in this function.
2715 * @param array stdWrap properties for erncapsLines.
2716 * @return string The processed input value
2717 */
2718 public function stdWrap_encapsLines($content = '', $conf = array()) {
2719 $content = $this->encaps_lineSplit($content, $conf['encapsLines.']);
2720 return $content;
2721 }
2722
2723 /**
2724 * keywords
2725 * Transforms content into a CSV list to be used i.e. as keywords within a meta tag
2726 *
2727 * @param string Input value undergoing processing in this function.
2728 * @param array stdWrap properties for keywords.
2729 * @return string The processed input value
2730 */
2731 public function stdWrap_keywords($content = '', $conf = array()) {
2732 $content = $this->keywords($content);
2733 return $content;
2734 }
2735
2736 /**
2737 * innerWrap
2738 * First of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
2739 * See wrap
2740 *
2741 * @param string Input value undergoing processing in this function.
2742 * @param array stdWrap properties for innerWrap.
2743 * @return string The processed input value
2744 */
2745 public function stdWrap_innerWrap($content = '', $conf = array()) {
2746 $content = $this->wrap($content, $conf['innerWrap']);
2747 return $content;
2748 }
2749
2750 /**
2751 * innerWrap2
2752 * Second of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
2753 * See wrap
2754 *
2755 * @param string Input value undergoing processing in this function.
2756 * @param array stdWrap properties for innerWrap2.
2757 * @return string The processed input value
2758 */
2759 public function stdWrap_innerWrap2($content = '', $conf = array()) {
2760 $content = $this->wrap($content, $conf['innerWrap2']);
2761 return $content;
2762 }
2763
2764 /**
2765 * fontTag
2766 * A wrap formerly used to apply font tags to format the content
2767 * Still used by lib.stdheader although real font tags are not state of the art anymore
2768 * See wrap
2769 *
2770 * @param string Input value undergoing processing in this function.
2771 * @param array stdWrap properties for fontTag.
2772 * @return string The processed input value
2773 */
2774 public function stdWrap_fontTag($content = '', $conf = array()) {
2775 $content = $this->wrap($content, $conf['fontTag']);
2776 return $content;
2777 }
2778
2779 /**
2780 * addParams
2781 * Adds tag attributes to any content that is a tag
2782 *
2783 * @param string Input value undergoing processing in this function.
2784 * @param array stdWrap properties for addParams.
2785 * @return string The processed input value
2786 */
2787 public function stdWrap_addParams($content = '', $conf = array()) {
2788 $content = $this->addParams($content, $conf['addParams.']);
2789 return $content;
2790 }
2791
2792 /**
2793 * textStyle
2794 * Wraps content in font tags
2795 * See wrap
2796 *
2797 * @param string Input value undergoing processing in this function.
2798 * @param array stdWrap properties for textStyle.
2799 * @return string The processed input value
2800 */
2801 public function stdWrap_textStyle($content = '', $conf = array()) {
2802 $content = $this->textStyle($content, $conf['textStyle.']);
2803 return $content;
2804 }
2805
2806 /**
2807 * tableStyle
2808 * Wraps content with table tags
2809 * See wrap
2810 *
2811 * @param string Input value undergoing processing in this function.
2812 * @param array stdWrap properties for tableStyle.
2813 * @return string The processed input value
2814 */
2815 public function stdWrap_tableStyle($content = '', $conf = array()) {
2816 $content = $this->tableStyle($content, $conf['tableStyle.']);
2817 return $content;
2818 }
2819
2820 /**
2821 * filelink
2822 * Used to make lists of links to files
2823 * See wrap
2824 *
2825 * @param string Input value undergoing processing in this function.
2826 * @param array stdWrap properties for filelink.
2827 * @return string The processed input value
2828 */
2829 public function stdWrap_filelink($content = '', $conf = array()) {
2830 $content = $this->filelink($content, $conf['filelink.']);
2831 return $content;
2832 }
2833
2834 /**
2835 * preCObject
2836 * A content object that is prepended to the current content but between the innerWraps and the rest of the wraps
2837 *
2838 * @param string Input value undergoing processing in this function.
2839 * @param array stdWrap properties for preCObject.
2840 * @return string The processed input value
2841 */
2842 public function stdWrap_preCObject($content = '', $conf = array()) {
2843 $content = $this->cObjGetSingle($conf['preCObject'], $conf['preCObject.'], '/stdWrap/.preCObject') . $content;
2844 return $content;
2845 }
2846
2847 /**
2848 * postCObject
2849 * A content object that is appended to the current content but between the innerWraps and the rest of the wraps
2850 *
2851 * @param string Input value undergoing processing in this function.
2852 * @param array stdWrap properties for postCObject.
2853 * @return string The processed input value
2854 */
2855 public function stdWrap_postCObject($content = '', $conf = array()) {
2856 $content .= $this->cObjGetSingle($conf['postCObject'], $conf['postCObject.'], '/stdWrap/.postCObject');
2857 return $content;
2858 }
2859
2860 /**
2861 * wrapAlign
2862 * Wraps content with a div container having the style attribute text-align set to the given value
2863 * See wrap
2864 *
2865 * @param string Input value undergoing processing in this function.
2866 * @param array stdWrap properties for wrapAlign.
2867 * @return string The processed input value
2868 */
2869 public function stdWrap_wrapAlign($content = '', $conf = array()) {
2870 $wrapAlign = trim($conf['wrapAlign']);
2871 if ($wrapAlign) {
2872 $content = $this->wrap($content, '<div style="text-align:' . $wrapAlign . ';">|</div>');
2873 }
2874 return $content;
2875 }
2876
2877 /**
2878 * typolink
2879 * Wraps the content with a link tag
2880 * URLs and other attributes are created automatically by the values given in the stdWrap properties
2881 * See wrap
2882 *
2883 * @param string Input value undergoing processing in this function.
2884 * @param array stdWrap properties for typolink.
2885 * @return string The processed input value
2886 */
2887 public function stdWrap_typolink($content = '', $conf = array()) {
2888 $content = $this->typolink($content, $conf['typolink.']);
2889 return $content;
2890 }
2891
2892 /**
2893 * TCAselectItem
2894 * Returns a list of options available for a given field in the DB which has to be of the type select
2895 *
2896 * @param string Input value undergoing processing in this function.
2897 * @param array stdWrap properties for TCAselectItem.
2898 * @return string The processed input value
2899 */
2900 public function stdWrap_TCAselectItem($content = '', $conf = array()) {
2901 if (is_array($conf['TCAselectItem.'])) {
2902 $content = $this->TCAlookup($content, $conf['TCAselectItem.']);
2903 }
2904 return $content;
2905 }
2906
2907 /**
2908 * spaceBefore
2909 * Will add space before the current content
2910 * By default this is done with a clear.gif but it can be done with CSS margins by setting the property space.useDiv to TRUE
2911 *
2912 * @param string Input value undergoing processing in this function.
2913 * @param array stdWrap properties for spaceBefore and space.
2914 * @return string The processed input value
2915 */
2916 public function stdWrap_spaceBefore($content = '', $conf = array()) {
2917 $content = $this->wrapSpace($content, trim($conf['spaceBefore']) . '|', $conf['space.']);
2918 return $content;
2919 }
2920
2921 /**
2922 * spaceAfter
2923 * Will add space after the current content
2924 * By default this is done with a clear.gif but it can be done with CSS margins by setting the property space.useDiv to TRUE
2925 *
2926 * @param string Input value undergoing processing in this function.
2927 * @param array stdWrap properties for spaceAfter and space.
2928 * @return string The processed input value
2929 */
2930 public function stdWrap_spaceAfter($content = '', $conf = array()) {
2931 $content = $this->wrapSpace($content, '|' . trim($conf['spaceAfter']), $conf['space.']);
2932 return $content;
2933 }
2934
2935 /**
2936 * space
2937 * Will add space before or after the current content
2938 * By default this is done with a clear.gif but it can be done with CSS margins by setting the property space.useDiv to TRUE
2939 * See wrap
2940 *
2941 * @param string Input value undergoing processing in this function.
2942 * @param array stdWrap properties for space.
2943 * @return string The processed input value
2944 */
2945 public function stdWrap_space($content = '', $conf = array()) {
2946 $content = $this->wrapSpace($content, trim($conf['space']), $conf['space.']);
2947 return $content;
2948 }
2949
2950 /**
2951 * wrap
2952 * This is the "mother" of all wraps
2953 * Third of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
2954 * Basically it will put additional content before and after the current content using a split character as a placeholder for the current content
2955 * The default split character is | but it can be replaced with other characters by the property splitChar
2956 * Any other wrap that does not have own splitChar settings will be using the default split char though
2957 *
2958 * @param string Input value undergoing processing in this function.
2959 * @param array stdWrap properties for wrap.
2960 * @return string The processed input value
2961 */
2962 public function stdWrap_wrap($content = '', $conf = array()) {
2963 $content = $this->wrap($content, $conf['wrap'], ($conf['wrap.']['splitChar'] ? $conf['wrap.']['splitChar'] : '|'));
2964 return $content;
2965 }
2966
2967 /**
2968 * noTrimWrap
2969 * Fourth of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
2970 * The major difference to any other wrap is, that this one can make use of whitespace without trimming *
2971 *
2972 * @param string Input value undergoing processing in this function.
2973 * @param array stdWrap properties for noTrimWrap.
2974 * @return string The processed input value
2975 */
2976 public function stdWrap_noTrimWrap($content = '', $conf = array()) {
2977 $content = $this->noTrimWrap($content, $conf['noTrimWrap']);
2978 return $content;
2979 }
2980
2981 /**
2982 * wrap2
2983 * Fifth of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
2984 * The default split character is | but it can be replaced with other characters by the property splitChar
2985 *
2986 * @param string Input value undergoing processing in this function.
2987 * @param array stdWrap properties for wrap2.
2988 * @return string The processed input value
2989 */
2990 public function stdWrap_wrap2($content = '', $conf = array()) {
2991 $content = $this->wrap($content, $conf['wrap2'], ($conf['wrap2.']['splitChar'] ? $conf['wrap2.']['splitChar'] : '|'));
2992 return $content;
2993 }
2994
2995 /**
2996 * dataWrap
2997 * Sixth of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
2998 * Can fetch additional content the same way data does (i.e. {field:whatever}) and apply it to the wrap before that is applied to the content
2999 *
3000 * @param string Input value undergoing processing in this function.
3001 * @param array stdWrap properties for dataWrap.
3002 * @return string The processed input value
3003 */
3004 public function stdWrap_dataWrap($content = '', $conf = array()) {
3005 $content = $this->dataWrap($content, $conf['dataWrap']);
3006 return $content;
3007 }
3008
3009 /**
3010 * prepend
3011 * A content object that will be prepended to the current content after most of the wraps have already been applied
3012 *
3013 * @param string Input value undergoing processing in this function.
3014 * @param array stdWrap properties for prepend.
3015 * @return string The processed input value
3016 */
3017 public function stdWrap_prepend($content = '', $conf = array()) {
3018 $content = $this->cObjGetSingle($conf['prepend'], $conf['prepend.'], '/stdWrap/.prepend') . $content;
3019 return $content;
3020 }
3021
3022 /**
3023 * append
3024 * A content object that will be appended to the current content after most of the wraps have already been applied
3025 *
3026 * @param string Input value undergoing processing in this function.
3027 * @param array stdWrap properties for append.
3028 * @return string The processed input value
3029 */
3030 public function stdWrap_append($content = '', $conf = array()) {
3031 $content .= $this->cObjGetSingle($conf['append'], $conf['append.'], '/stdWrap/.append');
3032 return $content;
3033 }
3034
3035 /**
3036 * wrap3
3037 * Seventh of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
3038 * The default split character is | but it can be replaced with other characters by the property splitChar
3039 *
3040 * @param string Input value undergoing processing in this function.
3041 * @param array stdWrap properties for wrap3.
3042 * @return string The processed input value
3043 */
3044 public function stdWrap_wrap3($content = '', $conf = array()) {
3045 $content = $this->wrap($content, $conf['wrap3'], ($conf['wrap3.']['splitChar'] ? $conf['wrap3.']['splitChar'] : '|'));
3046 return $content;
3047 }
3048
3049 /**
3050 * orderedStdWrap
3051 * Calls stdWrap for each entry in the provided array
3052 *
3053 * @param string Input value undergoing processing in this function.
3054 * @param array stdWrap properties for orderedStdWrap.
3055 * @return string The processed input value
3056 */
3057 public function stdWrap_orderedStdWrap($content = '', $conf = array()) {
3058 $sortedKeysArray = t3lib_TStemplate::sortedKeyList($conf['orderedStdWrap.'], TRUE);
3059 foreach ($sortedKeysArray as $key) {
3060 $content = $this->stdWrap($content, $conf['orderedStdWrap.'][$key . '.']);
3061 }
3062 return $content;
3063 }
3064 /**
3065 * outerWrap
3066 * Eighth of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
3067 *
3068 * @param string Input value undergoing processing in this function.
3069 * @param array stdWrap properties for outerWrap.
3070 * @return string The processed input value
3071 */
3072 public function stdWrap_outerWrap($content = '', $conf = array()) {
3073 $content = $this->wrap($content, $conf['outerWrap']);
3074 return $content;
3075 }
3076
3077 /**
3078 * insertData
3079 * Can fetch additional content the same way data does and replaces any occurence of {field:whatever} with this content
3080 *
3081 * @param string Input value undergoing processing in this function.
3082 * @param array stdWrap properties for insertData.
3083 * @return string The processed input value
3084 */
3085 public function stdWrap_insertData($content = '', $conf = array()) {
3086 $content = $this->insertData($content);
3087 return $content;
3088 }
3089
3090 /**
3091 * offsetWrap
3092 * Creates a so called offset table around the content
3093 * Still here for historical reasons even not used too much nowadays
3094 *
3095 * @param string Input value undergoing processing in this function.
3096 * @param array stdWrap properties for offsetWrap.
3097 * @return string The processed input value
3098 */
3099 public function stdWrap_offsetWrap($content = '', $conf = array()) {
3100 $controlTable = t3lib_div::makeInstance('tslib_tableOffset');
3101 if ($conf['offsetWrap.']['tableParams'] || $conf['offsetWrap.']['tableParams.']) {
3102 $controlTable->tableParams = isset($conf['offsetWrap.']['tableParams.'])
3103 ? $this->stdWrap($conf['offsetWrap.']['tableParams'], $conf['offsetWrap.']['tableParams.'])
3104 : $conf['offsetWrap.']['tableParams'];
3105 }
3106 if ($conf['offsetWrap.']['tdParams'] || $conf['offsetWrap.']['tdParams.']) {
3107 $controlTable->tdParams = ' ' . (isset($conf['offsetWrap.']['tdParams.'])
3108 ? $this->stdWrap($conf['offsetWrap.']['tdParams'], $conf['offsetWrap.']['tdParams.'])
3109 : $conf['offsetWrap.']['tdParams']);
3110 }
3111 $content = $controlTable->start($content, $conf['offsetWrap']);
3112 if ($conf['offsetWrap.']['stdWrap.']) {
3113 $content = $this->stdWrap($content, $conf['offsetWrap.']['stdWrap.']);
3114 }
3115 return $content;
3116 }
3117
3118 /**
3119 * postUserFunc
3120 * Will execute a user function after the content has been modified by any other stdWrap function
3121 *
3122 * @param string Input value undergoing processing in this function.
3123 * @param array stdWrap properties for postUserFunc.
3124 * @return string The processed input value
3125 */
3126 public function stdWrap_postUserFunc($content = '', $conf = array()) {
3127 $content = $this->callUserFunction($conf['postUserFunc'], $conf['postUserFunc.'], $content);
3128 return $content;
3129 }
3130
3131 /**
3132 * postUserFuncInt