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