[BUGFIX] FAL broke rendering of image with RECORDS cObj
[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 ;
1876 if (is_callable(array($hookObject, 'stdWrapOverride'))) {
1877 $conf['stdWrapOverride'] = 1;
1878 }
1879 ;
1880 if (is_callable(array($hookObject, 'stdWrapProcess'))) {
1881 $conf['stdWrapProcess'] = 1;
1882 }
1883 ;
1884 if (is_callable(array($hookObject, 'stdWrapPostProcess'))) {
1885 $conf['stdWrapPostProcess'] = 1;
1886 }
1887 ;
1888 }
1889 }
1890
1891 if (is_array($conf) && count($conf)) {
1892
1893 // cache handling
1894 if (is_array($conf['cache.'])) {
1895 $conf['cache.']['key'] = $this->stdWrap($conf['cache.']['key'], $conf['cache.']['key.']);
1896 $conf['cache.']['tags'] = $this->stdWrap($conf['cache.']['tags'], $conf['cache.']['tags.']);
1897 $conf['cache.']['lifetime'] = $this->stdWrap($conf['cache.']['lifetime'], $conf['cache.']['lifetime.']);
1898
1899 $conf['cacheRead'] = 1;
1900 $conf['cacheStore'] = 1;
1901 }
1902
1903 // check, which of the available stdWrap functions is needed for the current conf Array
1904 // and keep only those but still in the same order
1905 $sortedConf = array_intersect_key($this->stdWrapOrder, $conf);
1906 // functions types that should not make use of nested stdWrap function calls to avoid conflicts with internal TypoScript used by these functions
1907 $stdWrapDisabledFunctionTypes = 'cObject,functionName,stdWrap';
1908 // additional Array to check whether a function has already been executed
1909 $isExecuted = array();
1910 // additional switch to make sure 'required', 'if' and 'fieldRequired'
1911 // will still stop rendering immediately in case they return FALSE
1912
1913 $this->stdWrapRecursionLevel++;
1914 $this->stopRendering[$this->stdWrapRecursionLevel] = FALSE;
1915
1916 // execute each function in the predefined order
1917 foreach ($sortedConf as $stdWrapName => $functionType) {
1918 // eliminate the second key of a pair 'key'|'key.' to make sure functions get called only once and check if rendering has been stopped
1919 if (!$isExecuted[$stdWrapName] &&
1920 !$this->stopRendering[$this->stdWrapRecursionLevel]) {
1921 $functionName = rtrim($stdWrapName, '.');
1922 $functionProperties = $functionName . '.';
1923 // if there is any code one the next level, check if it contains "official" stdWrap functions
1924 // if yes, execute them first - will make each function stdWrap aware
1925 // so additional stdWrap calls within the functions can be removed, since the result will be the same
1926 // exception: the recursive stdWrap function and cObject will still be using their own stdWrap call, since it modifies the content and not a property
1927 if (count($conf[$functionProperties]) &&
1928 !t3lib_div::inList($stdWrapDisabledFunctionTypes, $functionType)) {
1929 if (array_intersect_key($this->stdWrapOrder, $conf[$functionProperties])) {
1930 $conf[$functionName] = $this->stdWrap($conf[$functionName], $conf[$functionProperties]);
1931 }
1932 }
1933 // get just that part of $conf that is needed for the particular function
1934 $singleConf = array(
1935 $functionName => $conf[$functionName],
1936 $functionProperties => $conf[$functionProperties]
1937 );
1938
1939 // in this special case 'spaceBefore' and 'spaceAfter' need additional stuff from 'space.''
1940 if ($functionName == 'spaceBefore' || $functionName == 'spaceAfter') {
1941 $singleConf['space.'] = $conf['space.'];
1942 }
1943
1944 // hand over the whole $conf array to the stdWrapHookObjects
1945 if ($functionType === 'hook') {
1946 $singleConf = $conf;
1947 }
1948 // check if key is still containing something, since it might have been changed by next level stdWrap before
1949 if ((isset($conf[$functionName]) || $conf[$functionProperties]) &&
1950 !($functionType == 'boolean' && !$conf[$functionName])) {
1951 //add both keys - with and without the dot - to the set of executed functions
1952 $isExecuted[$functionName] = TRUE;
1953 $isExecuted[$functionProperties] = TRUE;
1954 // call the function with the prefix stdWrap_ to make sure nobody can execute functions just by adding their name to the TS Array
1955 $functionName = 'stdWrap_' . $functionName;
1956 $content = $this->$functionName(
1957 $content,
1958 $singleConf
1959 );
1960 // 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
1961 } elseif($functionType == 'boolean' && !$conf[$functionName]) {
1962 $isExecuted[$functionName] = TRUE;
1963 $isExecuted[$functionProperties] = TRUE;
1964 }
1965 }
1966 }
1967
1968 unset($this->stopRendering[$this->stdWrapRecursionLevel]);
1969 $this->stdWrapRecursionLevel--;
1970
1971 }
1972 return $content;
1973 }
1974
1975 /**
1976 * stdWrap pre process hook
1977 * can be used by extensions authors to modify the behaviour of stdWrap functions to their needs
1978 * this hook will execute functions before any other stdWrap function can modify anything
1979 *
1980 * @param string Input value undergoing processing in these functions.
1981 * @param array All stdWrap properties, not just the ones for a particular function.
1982 * @return string The processed input value
1983 */
1984 public function stdWrap_stdWrapPreProcess($content = '', $conf = array()) {
1985 foreach ($this->stdWrapHookObjects as $hookObject) {
1986 $content = $hookObject->stdWrapPreProcess($content, $conf, $this);
1987 }
1988 return $content;
1989 }
1990
1991 /**
1992 * Check if content was cached before (depending on the given cache key)
1993 *
1994 * @param string Input value undergoing processing in these functions.
1995 * @param array All stdWrap properties, not just the ones for a particular function.
1996 * @return string The processed input value
1997 */
1998 public function stdWrap_cacheRead($content = '', $conf = array()) {
1999 if (!empty($conf['cache.']['key'])) {
2000 $cacheFrontend = $GLOBALS['typo3CacheManager']->getCache('cache_hash'); /* @var $cacheFrontend t3lib_cache_frontend_VariableFrontend */
2001 if ($cacheFrontend && $cacheFrontend->has($conf['cache.']['key'])) {
2002 $content = $cacheFrontend->get($conf['cache.']['key']);
2003 $this->stopRendering[$this->stdWrapRecursionLevel] = TRUE;
2004 }
2005 }
2006 return $content;
2007 }
2008
2009 /**
2010 * setContentToCurrent
2011 * actually it just does the contrary: Sets the value of 'current' based on current content
2012 *
2013 * @param string Input value undergoing processing in this function.
2014 * @param array stdWrap properties for setContentToCurrent.
2015 * @return string The processed input value
2016 */
2017 public function stdWrap_setContentToCurrent($content = '', $conf = array()) {
2018 $this->data[$this->currentValKey] = $content;
2019 return $content;
2020 }
2021
2022 /**
2023 * setCurrent
2024 * Sets the value of 'current' based on the outcome of stdWrap operations
2025 *
2026 * @param string Input value undergoing processing in this function.
2027 * @param array stdWrap properties for setCurrent.
2028 * @return string The processed input value
2029 */
2030 public function stdWrap_setCurrent($content = '', $conf = array()) {
2031 $this->data[$this->currentValKey] = $conf['setCurrent'];
2032 return $content;
2033 }
2034
2035 /**
2036 * lang
2037 * Translates content based on the language currently used by the FE
2038 *
2039 * @param string Input value undergoing processing in this function.
2040 * @param array stdWrap properties for lang.
2041 * @return string The processed input value
2042 */
2043 public function stdWrap_lang($content = '', $conf = array()) {
2044 if (isset($conf['lang.']) && $GLOBALS['TSFE']->config['config']['language'] && isset($conf['lang.'][$GLOBALS['TSFE']->config['config']['language']])) {
2045 $content = $conf['lang.'][$GLOBALS['TSFE']->config['config']['language']];
2046 }
2047 return $content;
2048 }
2049
2050 /**
2051 * data
2052 * Gets content from different sources based on getText functions, makes use of alternativeData, when set
2053 *
2054 * @param string Input value undergoing processing in this function.
2055 * @param array stdWrap properties for data.
2056 * @return string The processed input value
2057 */
2058 public function stdWrap_data($content = '', $conf = array()) {
2059 $content = $this->getData($conf['data'], is_array($this->alternativeData) ? $this->alternativeData : $this->data);
2060 $this->alternativeData = ''; // This must be unset directly after
2061 return $content;
2062 }
2063
2064 /**
2065 * field
2066 * Gets content from a DB field
2067 *
2068 * @param string Input value undergoing processing in this function.
2069 * @param array stdWrap properties for field.
2070 * @return string The processed input value
2071 */
2072 public function stdWrap_field($content = '', $conf = array()) {
2073 $content = $this->getFieldVal($conf['field']);
2074 return $content;
2075 }
2076
2077 /**
2078 * current
2079 * Gets content that has been perviously set as 'current'
2080 * Can be set via setContentToCurrent or setCurrent or will be set automatically i.e. inside the split function
2081 *
2082 * @param string Input value undergoing processing in this function.
2083 * @param array stdWrap properties for current.
2084 * @return string The processed input value
2085 */
2086 public function stdWrap_current($content = '', $conf = array()) {
2087 $content = $this->data[$this->currentValKey];
2088 return $content;
2089 }
2090
2091 /**
2092 * cObject
2093 * Will replace the content with the value of a any official TypoScript cObject
2094 * like TEXT, COA, HMENU
2095 *
2096 * @param string Input value undergoing processing in this function.
2097 * @param array stdWrap properties for cObject.
2098 * @return string The processed input value
2099 */
2100 public function stdWrap_cObject($content = '', $conf = array()) {
2101 $content = $this->cObjGetSingle($conf['cObject'], $conf['cObject.'], '/stdWrap/.cObject');
2102 return $content;
2103 }
2104
2105 /**
2106 * numRows
2107 * Counts the number of returned records of a DB operation
2108 * makes use of select internally
2109 *
2110 * @param string Input value undergoing processing in this function.
2111 * @param array stdWrap properties for numRows.
2112 * @return string The processed input value
2113 */
2114 public function stdWrap_numRows($content = '', $conf = array()) {
2115 $content = $this->numRows($conf['numRows.']);
2116 return $content;
2117 }
2118
2119 /**
2120 * filelist
2121 * Will create a list of files based on some additional parameters
2122 *
2123 * @param string Input value undergoing processing in this function.
2124 * @param array stdWrap properties for filelist.
2125 * @return string The processed input value
2126 */
2127 public function stdWrap_filelist($content = '', $conf = array()) {
2128 $content = $this->filelist($conf['filelist']);
2129 return $content;
2130 }
2131
2132 /**
2133 * preUserFunc
2134 * Will execute a user public function before the content will be modified by any other stdWrap function
2135 *
2136 * @param string Input value undergoing processing in this function.
2137 * @param array stdWrap properties for preUserFunc.
2138 * @return string The processed input value
2139 */
2140 public function stdWrap_preUserFunc($content = '', $conf = array()) {
2141 $content = $this->callUserFunction($conf['preUserFunc'], $conf['preUserFunc.'], $content);
2142 return $content;
2143 }
2144
2145 /**
2146 * stdWrap override hook
2147 * can be used by extensions authors to modify the behaviour of stdWrap functions to their needs
2148 * this hook will execute functions on existing content but still before the content gets modified or replaced
2149 *
2150 * @param string Input value undergoing processing in these functions.
2151 * @param array All stdWrap properties, not just the ones for a particular function.
2152 * @return string The processed input value
2153 */
2154 public function stdWrap_stdWrapOverride($content = '', $conf = array()) {
2155 foreach ($this->stdWrapHookObjects as $hookObject) {
2156 $content = $hookObject->stdWrapOverride($content, $conf, $this);
2157 }
2158 return $content;
2159 }
2160
2161 /**
2162 * override
2163 * Will override the current value of content with its own value'
2164 *
2165 * @param string Input value undergoing processing in this function.
2166 * @param array stdWrap properties for override.
2167 * @return string The processed input value
2168 */
2169 public function stdWrap_override($content = '', $conf = array()) {
2170 if (trim($conf['override'])) {
2171 $content = $conf['override'];
2172 }
2173 return $content;
2174 }
2175
2176 /**
2177 * preIfEmptyListNum
2178 * Gets a value off a CSV list before the following ifEmpty check
2179 * 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
2180 *
2181 * @param string Input value undergoing processing in this function.
2182 * @param array stdWrap properties for preIfEmptyListNum.
2183 * @return string The processed input value
2184 */
2185 public function stdWrap_preIfEmptyListNum($content = '', $conf = array()) {
2186 $content = $this->listNum($content, $conf['preIfEmptyListNum'], $conf['preIfEmptyListNum.']['splitChar']);
2187 return $content;
2188 }
2189
2190 /**
2191 * ifEmpty
2192 * Will set content to a replacement value in case the trimmed value of content returns FALSE
2193 * 0 (zero) will be replaced as well
2194 *
2195 * @param string Input value undergoing processing in this function.
2196 * @param array stdWrap properties for ifEmpty.
2197 * @return string The processed input value
2198 */
2199 public function stdWrap_ifEmpty($content = '', $conf = array()) {
2200 if (!trim($content)) {
2201 $content = $conf['ifEmpty'];
2202 }
2203 return $content;
2204 }
2205
2206 /**
2207 * ifBlank
2208 * Will set content to a replacement value in case the trimmed value of content has no length
2209 * 0 (zero) will not be replaced
2210 *
2211 * @param string Input value undergoing processing in this function.
2212 * @param array stdWrap properties for ifBlank.
2213 * @return string The processed input value
2214 */
2215 public function stdWrap_ifBlank($content = '', $conf = array()) {
2216 if (!strlen(trim($content))) {
2217 $content = $conf['ifBlank'];
2218 }
2219 return $content;
2220 }
2221
2222 /**
2223 * listNum
2224 * Gets a value off a CSV list after ifEmpty check
2225 * Might return an empty value in case the CSV does not contain a value at the position given by listNum
2226 * Use preIfEmptyListNum to avoid that behaviour
2227 *
2228 * @param string Input value undergoing processing in this function.
2229 * @param array stdWrap properties for listNum.
2230 * @return string The processed input value
2231 */
2232 public function stdWrap_listNum($content = '', $conf = array()) {
2233 $content = $this->listNum($content, $conf['listNum'], $conf['listNum.']['splitChar']);
2234 return $content;
2235 }
2236
2237 /**
2238 * trim
2239 * Cuts off any whitespace at the beginning and the end of the content
2240 *
2241 * @param string Input value undergoing processing in this function.
2242 * @param array stdWrap properties for trim.
2243 * @return string The processed input value
2244 */
2245 public function stdWrap_trim($content = '', $conf = array()) {
2246 $content = trim($content);
2247 return $content;
2248 }
2249
2250 /**
2251 * stdWrap
2252 * A recursive call of the stdWrap function set
2253 * This enables the user to execute stdWrap functions in another than the predefined order
2254 * It modifies the content, not the property
2255 * while the new feature of chained stdWrap functions modifies the property and not the content
2256 *
2257 * @param string Input value undergoing processing in this function.
2258 * @param array stdWrap properties for stdWrap.
2259 * @return string The processed input value
2260 */
2261 public function stdWrap_stdWrap($content = '', $conf = array()) {
2262 $content = $this->stdWrap($content, $conf['stdWrap.']);
2263 return $content;
2264 }
2265
2266 /**
2267 * stdWrap process hook
2268 * can be used by extensions authors to modify the behaviour of stdWrap functions to their needs
2269 * this hook executes functions directly after the recursive stdWrap function call but still before the content gets modified
2270 *
2271 * @param string Input value undergoing processing in these functions.
2272 * @param array All stdWrap properties, not just the ones for a particular function.
2273 * @return string The processed input value
2274 */
2275 public function stdWrap_stdWrapProcess($content = '', $conf = array()) {
2276 foreach ($this->stdWrapHookObjects as $hookObject) {
2277 $content = $hookObject->stdWrapProcess($content, $conf, $this);
2278 }
2279 return $content;
2280 }
2281
2282 /**
2283 * required
2284 * Will immediately stop rendering and return an empty value
2285 * when there is no content at this point
2286 *
2287 * @param string Input value undergoing processing in this function.
2288 * @param array stdWrap properties for required.
2289 * @return string The processed input value
2290 */
2291 public function stdWrap_required($content = '', $conf = array()) {
2292 if ((string) $content == '') {
2293 $content = '';
2294 $this->stopRendering[$this->stdWrapRecursionLevel] = TRUE;
2295 }
2296 return $content;
2297 }
2298
2299 /**
2300 * if
2301 * Will immediately stop rendering and return an empty value
2302 * when the result of the checks returns FALSE
2303 *
2304 * @param string Input value undergoing processing in this function.
2305 * @param array stdWrap properties for if.
2306 * @return string The processed input value
2307 */
2308 public function stdWrap_if($content = '', $conf = array()) {
2309 if (!$this->checkIf($conf['if.'])) {
2310 $content = '';
2311 $this->stopRendering[$this->stdWrapRecursionLevel] = TRUE;
2312 }
2313 return $content;
2314 }
2315
2316 /**
2317 * fieldRequired
2318 * Will immediately stop rendering and return an empty value
2319 * when there is no content in the field given by fieldRequired
2320 *
2321 * @param string Input value undergoing processing in this function.
2322 * @param array stdWrap properties for fieldRequired.
2323 * @return string The processed input value
2324 */
2325 public function stdWrap_fieldRequired($content = '', $conf = array()) {
2326 if (!trim($this->data[$conf['fieldRequired']])) {
2327 $content = '';
2328 $this->stopRendering[$this->stdWrapRecursionLevel] = TRUE;
2329 }
2330 return $content;
2331 }
2332
2333 /**
2334 * csConv
2335 * Will convert the current chracter set of the content to the one given in csConv
2336 *
2337 * @param string Input value undergoing processing in this function.
2338 * @param array stdWrap properties for csConv.
2339 * @return string The processed input value
2340 */
2341 public function stdWrap_csConv($content = '', $conf = array()) {
2342 $content = $GLOBALS['TSFE']->csConv($content, $conf['csConv']);
2343 return $content;
2344 }
2345
2346 /**
2347 * parseFunc
2348 * Will parse the content based on functions given as stdWrap properties
2349 * Heavily used together with RTE based content
2350 *
2351 * @param string Input value undergoing processing in this function.
2352 * @param array stdWrap properties for parseFunc.
2353 * @return string The processed input value
2354 */
2355 public function stdWrap_parseFunc($content = '', $conf = array()) {
2356 $content = $this->parseFunc($content, $conf['parseFunc.'], $conf['parseFunc']);
2357 return $content;
2358 }
2359
2360 /**
2361 * HTMLparser
2362 * Will parse HTML content based on functions given as stdWrap properties
2363 * Heavily used together with RTE based content
2364 *
2365 * @param string Input value undergoing processing in this function.
2366 * @param array stdWrap properties for HTMLparser.
2367 * @return string The processed input value
2368 */
2369 public function stdWrap_HTMLparser($content = '', $conf = array()) {
2370 if (is_array($conf['HTMLparser.'])) {
2371 $content = $this->HTMLparser_TSbridge($content, $conf['HTMLparser.']);
2372 }
2373 return $content;
2374 }
2375
2376 /**
2377 * split
2378 * Will split the content by a given token and treat the results separately
2379 * Automatically fills 'current' with a single result
2380 *
2381 * @param string Input value undergoing processing in this function.
2382 * @param array stdWrap properties for split.
2383 * @return string The processed input value
2384 */
2385 public function stdWrap_split($content = '', $conf = array()) {
2386 $content = $this->splitObj($content, $conf['split.']);
2387 return $content;
2388 }
2389
2390 /**
2391 * replacement
2392 * Will execute replacements on the content (optionally with preg-regex)
2393 *
2394 * @param string Input value undergoing processing in this function.
2395 * @param array stdWrap properties for replacement.
2396 * @return string The processed input value
2397 */
2398 public function stdWrap_replacement($content = '', $conf = array()) {
2399 $content = $this->replacement($content, $conf['replacement.']);
2400 return $content;
2401 }
2402
2403 /**
2404 * prioriCalc
2405 * Will use the content as a mathematical term and calculate the result
2406 * Can be set to 1 to just get a calculated value or 'intval' to get the integer of the result
2407 *
2408 * @param string Input value undergoing processing in this function.
2409 * @param array stdWrap properties for prioriCalc.
2410 * @return string The processed input value
2411 */
2412 public function stdWrap_prioriCalc($content = '', $conf = array()) {
2413 $content = t3lib_utility_Math::calculateWithParentheses($content);
2414 if ($conf['prioriCalc'] == 'intval')
2415 $content = intval($content);
2416 return $content;
2417 }
2418
2419 /**
2420 * char
2421 * Will return a character based on its position within the current character set
2422 *
2423 * @param string Input value undergoing processing in this function.
2424 * @param array stdWrap properties for char.
2425 * @return string The processed input value
2426 */
2427 public function stdWrap_char($content = '', $conf = array()) {
2428 $content = chr(intval($conf['char']));
2429 return $content;
2430 }
2431
2432 /**
2433 * intval
2434 * Will return an integer value of the current content
2435 *
2436 * @param string Input value undergoing processing in this function.
2437 * @param array stdWrap properties for intval.
2438 * @return string The processed input value
2439 */
2440 public function stdWrap_intval($content = '', $conf = array()) {
2441 $content = intval($content);
2442 return $content;
2443 }
2444
2445 /**
2446 * Will return a hashed value of the current content
2447 *
2448 * @param string Input value undergoing processing in this function.
2449 * @param array stdWrap properties for hash.
2450 * @return string The processed input value
2451 * @link http://php.net/manual/de/function.hash-algos.php for a list of supported hash algorithms
2452 */
2453 public function stdWrap_hash($content = '', array $conf = array()) {
2454 $algorithm = isset($conf['hash.'])
2455 ? $this->stdWrap($conf['hash'], $conf['hash.'])
2456 : $conf['hash'];
2457 if (function_exists('hash') && in_array($algorithm, hash_algos())) {
2458 $content = hash($algorithm, $content);
2459 } else {
2460 // non-existing hashing algorithm
2461 $content = '';
2462 }
2463 return $content;
2464 }
2465
2466 /**
2467 * stdWrap_round will return a rounded number with ceil(), floor() or round(), defaults to round()
2468 * Only the english number format is supported . (dot) as decimal point
2469 *
2470 * @param string Input value undergoing processing in this function.
2471 * @param array stdWrap properties for round.
2472 * @return string The processed input value
2473 */
2474 public function stdWrap_round($content = '', $conf = array()){
2475 $content = $this->round($content, $conf['round.']);
2476 return $content;
2477 }
2478
2479 /**
2480 * numberFormat
2481 * Will return a formatted number based on configuration given as stdWrap properties
2482 *
2483 * @param string Input value undergoing processing in this function.
2484 * @param array stdWrap properties for numberFormat.
2485 * @return string The processed input value
2486 */
2487 public function stdWrap_numberFormat($content = '', $conf = array()) {
2488 $content = $this->numberFormat($content, $conf['numberFormat.']);
2489 return $content;
2490 }
2491
2492 /**
2493 * expandList
2494 * Will return a formatted number based on configuration given as stdWrap properties
2495 *
2496 * @param string Input value undergoing processing in this function.
2497 * @param array stdWrap properties for expandList.
2498 * @return string The processed input value
2499 */
2500 public function stdWrap_expandList($content = '', $conf = array()) {
2501 $content = t3lib_div::expandList($content);
2502 return $content;
2503 }
2504
2505 /**
2506 * date
2507 * Will return a formatted date based on configuration given according to PHP date/gmdate properties
2508 * Will return gmdate when the property GMT returns TRUE
2509 *
2510 * @param string $content Input value undergoing processing in this function.
2511 * @param array $conf stdWrap properties for date.
2512 * @return string The processed input value
2513 */
2514 public function stdWrap_date($content = '', $conf = array()) {
2515 // check for zero length string to mimic default case of date/gmdate.
2516 $content = $content == '' ? $GLOBALS['EXEC_TIME'] : intval($content);
2517 $content = ($conf['date.']['GMT'] ? gmdate($conf['date'], $content) : date($conf['date'], $content));
2518 return $content;
2519 }
2520
2521 /**
2522 * strftime
2523 * Will return a formatted date based on configuration given according to PHP strftime/gmstrftime properties
2524 * Will return gmstrftime when the property GMT returns TRUE
2525 *
2526 * @param string Input value undergoing processing in this function.
2527 * @param array stdWrap properties for strftime.
2528 * @return string The processed input value
2529 */
2530 public function stdWrap_strftime($content = '', $conf = array()) {
2531 $content = ($conf['strftime.']['GMT'] ? gmstrftime($conf['strftime'], $content) : strftime($conf['strftime'], $content));
2532 $tmp_charset = $conf['strftime.']['charset'] ? $conf['strftime.']['charset'] : $GLOBALS['TSFE']->localeCharset;
2533 if ($tmp_charset) {
2534 $content = $GLOBALS['TSFE']->csConv($content, $tmp_charset);
2535 }
2536 return $content;
2537 }
2538
2539 /**
2540 * age
2541 * Will return the age of a given timestamp based on configuration given by stdWrap properties
2542 *
2543 * @param string Input value undergoing processing in this function.
2544 * @param array stdWrap properties for age.
2545 * @return string The processed input value
2546 */
2547 public function stdWrap_age($content = '', $conf = array()) {
2548 $content = $this->calcAge($GLOBALS['EXEC_TIME'] - $content, $conf['age']);
2549 return $content;
2550 }
2551
2552 /**
2553 * case
2554 * Will transform the content to be upper or lower case only
2555 * Leaves HTML tags untouched
2556 *
2557 * @param string Input value undergoing processing in this function.
2558 * @param array stdWrap properties for case.
2559 * @return string The processed input value
2560 */
2561 public function stdWrap_case($content = '', $conf = array()) {
2562 $content = $this->HTMLcaseshift($content, $conf['case']);
2563 return $content;
2564 }
2565
2566 /**
2567 * bytes
2568 * Will return the size of a given number in Bytes *
2569 *
2570 * @param string Input value undergoing processing in this function.
2571 * @param array stdWrap properties for bytes.
2572 * @return string The processed input value
2573 */
2574 public function stdWrap_bytes($content = '', $conf = array()) {
2575 $content = t3lib_div::formatSize($content, $conf['bytes.']['labels']);
2576 return $content;
2577 }
2578
2579 /**
2580 * substring
2581 * Will return a substring based on position information given by stdWrap properties
2582 *
2583 * @param string Input value undergoing processing in this function.
2584 * @param array stdWrap properties for substring.
2585 * @return string The processed input value
2586 */
2587 public function stdWrap_substring($content = '', $conf = array()) {
2588 $content = $this->substring($content, $conf['substring']);
2589 return $content;
2590 }
2591
2592 /**
2593 * removeBadHTML
2594 * Removes HTML tags based on stdWrap properties
2595 *
2596 * @param string Input value undergoing processing in this function.
2597 * @param array stdWrap properties for removeBadHTML.
2598 * @return string The processed input value
2599 */
2600 public function stdWrap_removeBadHTML($content = '', $conf = array()) {
2601 $content = $this->removeBadHTML($content, $conf['removeBadHTML.']);
2602 return $content;
2603 }
2604
2605 /**
2606 * cropHTML
2607 * Crops content to a given size while leaving HTML tags untouched
2608 *
2609 * @param string Input value undergoing processing in this function.
2610 * @param array stdWrap properties for cropHTML.
2611 * @return string The processed input value
2612 */
2613 public function stdWrap_cropHTML($content = '', $conf = array()) {
2614 $content = $this->cropHTML($content, $conf['cropHTML']);
2615 return $content;
2616 }
2617
2618 /**
2619 * stripHtml
2620 * Copmletely removes HTML tags from content
2621 *
2622 * @param string Input value undergoing processing in this function.
2623 * @param array stdWrap properties for stripHtml.
2624 * @return string The processed input value
2625 */
2626 public function stdWrap_stripHtml($content = '', $conf = array()) {
2627 $content = strip_tags($content);
2628 return $content;
2629 }
2630
2631 /**
2632 * cropHTML
2633 * Crops content to a given size without caring abhout HTML tags
2634 *
2635 * @param string Input value undergoing processing in this function.
2636 * @param array stdWrap properties for crop.
2637 * @return string The processed input value
2638 */
2639 public function stdWrap_crop($content = '', $conf = array()) {
2640 $content = $this->crop($content, $conf['crop']);
2641 return $content;
2642 }
2643
2644 /**
2645 * rawUrlEncode
2646 * Encodes content to be used within URLs
2647 *
2648 * @param string Input value undergoing processing in this function.
2649 * @param array stdWrap properties for rawUrlEncode.
2650 * @return string The processed input value
2651 */
2652 public function stdWrap_rawUrlEncode($content = '', $conf = array()) {
2653 $content = rawurlencode($content);
2654 return $content;
2655 }
2656
2657 /**
2658 * htmlSpecialChars
2659 * Transforms HTML tags to readable text by replacing special characters with their HTML entity
2660 * When preserveEntities returns TRUE, existing entities will be left untouched
2661 *
2662 * @param string Input value undergoing processing in this function.
2663 * @param array stdWrap properties for htmlSpecalChars.
2664 * @return string The processed input value
2665 */
2666 public function stdWrap_htmlSpecialChars($content = '', $conf = array()) {
2667 $content = htmlSpecialChars($content);
2668 if ($conf['htmlSpecialChars.']['preserveEntities'])
2669 $content = t3lib_div::deHSCentities($content);
2670 return $content;
2671 }
2672
2673 /**
2674 * doubleBrTag
2675 * Searches for double line breaks and replaces them with the given value
2676 *
2677 * @param string Input value undergoing processing in this function.
2678 * @param array stdWrap properties for doubleBrTag.
2679 * @return string The processed input value
2680 */
2681 public function stdWrap_doubleBrTag($content = '', $conf = array()) {
2682 $content = preg_replace("/\r?\n[\t ]*\r?\n/", $conf['doubleBrTag'], $content);
2683 return $content;
2684 }
2685
2686 /**
2687 * br
2688 * Searches for single line breaks and replaces them with a <br />/<br> tag
2689 * according to the doctype
2690 *
2691 * @param string Input value undergoing processing in this function.
2692 * @param array stdWrap properties for br.
2693 * @return string The processed input value
2694 */
2695 public function stdWrap_br($content = '', $conf = array()) {
2696 $content = nl2br($content, !empty($GLOBALS['TSFE']->xhtmlDoctype));
2697 return $content;
2698 }
2699
2700 /**
2701 * brTag
2702 * Searches for single line feeds and replaces them with the given value
2703 *
2704 * @param string Input value undergoing processing in this function.
2705 * @param array stdWrap properties for brTag.
2706 * @return string The processed input value
2707 */
2708 public function stdWrap_brTag($content = '', $conf = array()) {
2709 $content = str_replace(LF, $conf['brTag'], $content);
2710 return $content;
2711 }
2712
2713 /**
2714 * encapsLines
2715 * Modifies text blocks by searching for lines which are not surrounded by HTML tags yet
2716 * and wrapping them with values given by stdWrap properties
2717 *
2718 * @param string Input value undergoing processing in this function.
2719 * @param array stdWrap properties for erncapsLines.
2720 * @return string The processed input value
2721 */
2722 public function stdWrap_encapsLines($content = '', $conf = array()) {
2723 $content = $this->encaps_lineSplit($content, $conf['encapsLines.']);
2724 return $content;
2725 }
2726
2727 /**
2728 * keywords
2729 * Transforms content into a CSV list to be used i.e. as keywords within a meta tag
2730 *
2731 * @param string Input value undergoing processing in this function.
2732 * @param array stdWrap properties for keywords.
2733 * @return string The processed input value
2734 */
2735 public function stdWrap_keywords($content = '', $conf = array()) {
2736 $content = $this->keywords($content);
2737 return $content;
2738 }
2739
2740 /**
2741 * innerWrap
2742 * First of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
2743 * See wrap
2744 *
2745 * @param string Input value undergoing processing in this function.
2746 * @param array stdWrap properties for innerWrap.
2747 * @return string The processed input value
2748 */
2749 public function stdWrap_innerWrap($content = '', $conf = array()) {
2750 $content = $this->wrap($content, $conf['innerWrap']);
2751 return $content;
2752 }
2753
2754 /**
2755 * innerWrap2
2756 * Second of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
2757 * See wrap
2758 *
2759 * @param string Input value undergoing processing in this function.
2760 * @param array stdWrap properties for innerWrap2.
2761 * @return string The processed input value
2762 */
2763 public function stdWrap_innerWrap2($content = '', $conf = array()) {
2764 $content = $this->wrap($content, $conf['innerWrap2']);
2765 return $content;
2766 }
2767
2768 /**
2769 * fontTag
2770 * A wrap formerly used to apply font tags to format the content
2771 * Still used by lib.stdheader although real font tags are not state of the art anymore
2772 * See wrap
2773 *
2774 * @param string Input value undergoing processing in this function.
2775 * @param array stdWrap properties for fontTag.
2776 * @return string The processed input value
2777 */
2778 public function stdWrap_fontTag($content = '', $conf = array()) {
2779 $content = $this->wrap($content, $conf['fontTag']);
2780 return $content;
2781 }
2782
2783 /**
2784 * addParams
2785 * Adds tag attributes to any content that is a tag
2786 *
2787 * @param string Input value undergoing processing in this function.
2788 * @param array stdWrap properties for addParams.
2789 * @return string The processed input value
2790 */
2791 public function stdWrap_addParams($content = '', $conf = array()) {
2792 $content = $this->addParams($content, $conf['addParams.']);
2793 return $content;
2794 }
2795
2796 /**
2797 * textStyle
2798 * Wraps content in font tags
2799 * See wrap
2800 *
2801 * @param string Input value undergoing processing in this function.
2802 * @param array stdWrap properties for textStyle.
2803 * @return string The processed input value
2804 */
2805 public function stdWrap_textStyle($content = '', $conf = array()) {
2806 $content = $this->textStyle($content, $conf['textStyle.']);
2807 return $content;
2808 }
2809
2810 /**
2811 * tableStyle
2812 * Wraps content with table tags
2813 * See wrap
2814 *
2815 * @param string Input value undergoing processing in this function.
2816 * @param array stdWrap properties for tableStyle.
2817 * @return string The processed input value
2818 */
2819 public function stdWrap_tableStyle($content = '', $conf = array()) {
2820 $content = $this->tableStyle($content, $conf['tableStyle.']);
2821 return $content;
2822 }
2823
2824 /**
2825 * filelink
2826 * Used to make lists of links to files
2827 * See wrap
2828 *
2829 * @param string Input value undergoing processing in this function.
2830 * @param array stdWrap properties for filelink.
2831 * @return string The processed input value
2832 */
2833 public function stdWrap_filelink($content = '', $conf = array()) {
2834 $content = $this->filelink($content, $conf['filelink.']);
2835 return $content;
2836 }
2837
2838 /**
2839 * preCObject
2840 * A content object that is prepended to the current content but between the innerWraps and the rest of the wraps
2841 *
2842 * @param string Input value undergoing processing in this function.
2843 * @param array stdWrap properties for preCObject.
2844 * @return string The processed input value
2845 */
2846 public function stdWrap_preCObject($content = '', $conf = array()) {
2847 $content = $this->cObjGetSingle($conf['preCObject'], $conf['preCObject.'], '/stdWrap/.preCObject') . $content;
2848 return $content;
2849 }
2850
2851 /**
2852 * postCObject
2853 * A content object that is appended to the current content but between the innerWraps and the rest of the wraps
2854 *
2855 * @param string Input value undergoing processing in this function.
2856 * @param array stdWrap properties for postCObject.
2857 * @return string The processed input value
2858 */
2859 public function stdWrap_postCObject($content = '', $conf = array()) {
2860 $content .= $this->cObjGetSingle($conf['postCObject'], $conf['postCObject.'], '/stdWrap/.postCObject');
2861 return $content;
2862 }
2863
2864 /**
2865 * wrapAlign
2866 * Wraps content with a div container having the style attribute text-align set to the given value
2867 * See wrap
2868 *
2869 * @param string Input value undergoing processing in this function.
2870 * @param array stdWrap properties for wrapAlign.
2871 * @return string The processed input value
2872 */
2873 public function stdWrap_wrapAlign($content = '', $conf = array()) {
2874 $wrapAlign = trim($conf['wrapAlign']);
2875 if ($wrapAlign) {
2876 $content = $this->wrap($content, '<div style="text-align:' . $wrapAlign . ';">|</div>');
2877 }
2878 return $content;
2879 }
2880
2881 /**
2882 * typolink
2883 * Wraps the content with a link tag
2884 * URLs and other attributes are created automatically by the values given in the stdWrap properties
2885 * See wrap
2886 *
2887 * @param string Input value undergoing processing in this function.
2888 * @param array stdWrap properties for typolink.
2889 * @return string The processed input value
2890 */
2891 public function stdWrap_typolink($content = '', $conf = array()) {
2892 $content = $this->typolink($content, $conf['typolink.']);
2893 return $content;
2894 }
2895
2896 /**
2897 * TCAselectItem
2898 * Returns a list of options available for a given field in the DB which has to be of the type select
2899 *
2900 * @param string Input value undergoing processing in this function.
2901 * @param array stdWrap properties for TCAselectItem.
2902 * @return string The processed input value
2903 */
2904 public function stdWrap_TCAselectItem($content = '', $conf = array()) {
2905 if (is_array($conf['TCAselectItem.'])) {
2906 $content = $this->TCAlookup($content, $conf['TCAselectItem.']);
2907 }
2908 return $content;
2909 }
2910
2911 /**
2912 * spaceBefore
2913 * Will add space before the current content
2914 * 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
2915 *
2916 * @param string Input value undergoing processing in this function.
2917 * @param array stdWrap properties for spaceBefore and space.
2918 * @return string The processed input value
2919 */
2920 public function stdWrap_spaceBefore($content = '', $conf = array()) {
2921 $content = $this->wrapSpace($content, trim($conf['spaceBefore']) . '|', $conf['space.']);
2922 return $content;
2923 }
2924
2925 /**
2926 * spaceAfter
2927 * Will add space after the current content
2928 * 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
2929 *
2930 * @param string Input value undergoing processing in this function.
2931 * @param array stdWrap properties for spaceAfter and space.
2932 * @return string The processed input value
2933 */
2934 public function stdWrap_spaceAfter($content = '', $conf = array()) {
2935 $content = $this->wrapSpace($content, '|' . trim($conf['spaceAfter']), $conf['space.']);
2936 return $content;
2937 }
2938
2939 /**
2940 * space
2941 * Will add space before or after the current content
2942 * 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
2943 * See wrap
2944 *
2945 * @param string Input value undergoing processing in this function.
2946 * @param array stdWrap properties for space.
2947 * @return string The processed input value
2948 */
2949 public function stdWrap_space($content = '', $conf = array()) {
2950 $content = $this->wrapSpace($content, trim($conf['space']), $conf['space.']);
2951 return $content;
2952 }
2953
2954 /**
2955 * wrap
2956 * This is the "mother" of all wraps
2957 * Third of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
2958 * Basically it will put additional content before and after the current content using a split character as a placeholder for the current content
2959 * The default split character is | but it can be replaced with other characters by the property splitChar
2960 * Any other wrap that does not have own splitChar settings will be using the default split char though
2961 *
2962 * @param string Input value undergoing processing in this function.
2963 * @param array stdWrap properties for wrap.
2964 * @return string The processed input value
2965 */
2966 public function stdWrap_wrap($content = '', $conf = array()) {
2967 $content = $this->wrap($content, $conf['wrap'], ($conf['wrap.']['splitChar'] ? $conf['wrap.']['splitChar'] : '|'));
2968 return $content;
2969 }
2970
2971 /**
2972 * noTrimWrap
2973 * Fourth of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
2974 * The major difference to any other wrap is, that this one can make use of whitespace without trimming *
2975 *
2976 * @param string Input value undergoing processing in this function.
2977 * @param array stdWrap properties for noTrimWrap.
2978 * @return string The processed input value
2979 */
2980 public function stdWrap_noTrimWrap($content = '', $conf = array()) {
2981 $content = $this->noTrimWrap($content, $conf['noTrimWrap']);
2982 return $content;
2983 }
2984
2985 /**
2986 * wrap2
2987 * Fifth of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
2988 * The default split character is | but it can be replaced with other characters by the property splitChar
2989 *
2990 * @param string Input value undergoing processing in this function.
2991 * @param array stdWrap properties for wrap2.
2992 * @return string The processed input value
2993 */
2994 public function stdWrap_wrap2($content = '', $conf = array()) {
2995 $content = $this->wrap($content, $conf['wrap2'], ($conf['wrap2.']['splitChar'] ? $conf['wrap2.']['splitChar'] : '|'));
2996 return $content;
2997 }
2998
2999 /**
3000 * dataWrap
3001 * Sixth of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
3002 * 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
3003 *
3004 * @param string Input value undergoing processing in this function.
3005 * @param array stdWrap properties for dataWrap.
3006 * @return string The processed input value
3007 */
3008 public function stdWrap_dataWrap($content = '', $conf = array()) {
3009 $content = $this->dataWrap($content, $conf['dataWrap']);
3010 return $content;
3011 }
3012
3013 /**
3014 * prepend
3015 * A content object that will be prepended to the current content after most of the wraps have already been applied
3016 *
3017 * @param string Input value undergoing processing in this function.
3018 * @param array stdWrap properties for prepend.
3019 * @return string The processed input value
3020 */
3021 public function stdWrap_prepend($content = '', $conf = array()) {
3022 $content = $this->cObjGetSingle($conf['prepend'], $conf['prepend.'], '/stdWrap/.prepend') . $content;
3023 return $content;
3024 }
3025
3026 /**
3027 * append
3028 * A content object that will be appended to the current content after most of the wraps have already been applied
3029 *
3030 * @param string Input value undergoing processing in this function.
3031 * @param array stdWrap properties for append.
3032 * @return string The processed input value
3033 */
3034 public function stdWrap_append($content = '', $conf = array()) {
3035 $content .= $this->cObjGetSingle($conf['append'], $conf['append.'], '/stdWrap/.append');
3036 return $content;
3037 }
3038
3039 /**
3040 * wrap3
3041 * Seventh of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
3042 * The default split character is | but it can be replaced with other characters by the property splitChar
3043 *
3044 * @param string Input value undergoing processing in this function.
3045 * @param array stdWrap properties for wrap3.
3046 * @return string The processed input value
3047 */
3048 public function stdWrap_wrap3($content = '', $conf = array()) {
3049 $content = $this->wrap($content, $conf['wrap3'], ($conf['wrap3.']['splitChar'] ? $conf['wrap3.']['splitChar'] : '|'));
3050 return $content;
3051 }
3052
3053 /**
3054 * orderedStdWrap
3055 * Calls stdWrap for each entry in the provided array
3056 *
3057 * @param string Input value undergoing processing in this function.
3058 * @param array stdWrap properties for orderedStdWrap.
3059 * @return string The processed input value
3060 */
3061 public function stdWrap_orderedStdWrap($content = '', $conf = array()) {
3062 $sortedKeysArray = t3lib_TStemplate::sortedKeyList($conf['orderedStdWrap.'], TRUE);
3063 foreach ($sortedKeysArray as $key) {
3064 $content = $this->stdWrap($content, $conf['orderedStdWrap.'][$key . '.']);
3065 }
3066 return $content;
3067 }
3068 /**
3069 * outerWrap
3070 * Eighth of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
3071 *
3072 * @param string Input value undergoing processing in this function.
3073 * @param array stdWrap properties for outerWrap.
3074 * @return string The processed input value
3075 */
3076 public function stdWrap_outerWrap($content = '', $conf = array()) {
3077 $content = $this->wrap($content, $conf['outerWrap']);
3078 return $content;
3079 }
3080
3081 /**
3082 * insertData
3083 * Can fetch additional content the same way data does and replaces any occurence of {field:whatever} with this content
3084 *
3085 * @param string Input value undergoing processing in this function.
3086 * @param array stdWrap properties for insertData.
3087 * @return string The processed input value
3088 */
3089 public function stdWrap_insertData($content = '', $conf = array()) {
3090 $content = $this->insertData($content);
3091 return $content;
3092 }
3093
3094 /**
3095 * offsetWrap
3096 * Creates a so called offset table around the content
3097 * Still here for historical reasons even not used too much nowadays
3098 *
3099 * @param string Input value undergoing processing in this function.
3100 * @param array stdWrap properties for offsetWrap.
3101 * @return string The processed input value
3102 */