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