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