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