Fixed bug #17507: Extension using stdWrap hooks are broken due to stdWrap refactoring...
[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);
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 $conf['scriptSuffix'] = $ext;
1130 return $this->getContentObject('PHP_SCRIPT_INT')->render($conf);
1131 } else {
1132 return $this->getContentObject('PHP_SCRIPT')->render($conf);
1133 }
1134 }
1135
1136 /**
1137 * Rendering the cObject, TEMPLATE
1138 *
1139 * @param array array of TypoScript properties
1140 * @return string Output
1141 * @see substituteMarkerArrayCached()
1142 */
1143 function TEMPLATE($conf) {
1144 return $this->getContentObject('TEMPLATE')->render($conf);
1145 }
1146
1147 /**
1148 * Rendering the cObject, FLUIDTEMPLATE
1149 *
1150 * @param array array of TypoScript properties
1151 * @return string the HTML output
1152 * @author Steffen Ritter <info@steffen-ritter.net>
1153 * @author Benjamin Mack <benni@typo3.org>
1154 */
1155 protected function FLUIDTEMPLATE(array $conf) {
1156 return $this->getContentObject('FLUIDTEMPLATE')->render($conf);
1157 }
1158
1159 /**
1160 * Rendering the cObject, MULTIMEDIA
1161 *
1162 * @param array array of TypoScript properties
1163 * @return string Output
1164 */
1165 function MULTIMEDIA($conf) {
1166 return $this->getContentObject('MULTIMEDIA')->render($conf);
1167 }
1168
1169 /**
1170 * Rendering the cObject, MEDIA
1171 *
1172 * @param array array of TypoScript properties
1173 * @return string Output
1174 */
1175 public function MEDIA($conf) {
1176 return $this->getContentObject('MEDIA')->render($conf);
1177 }
1178
1179 /**
1180 * Rendering the cObject, SWFOBJECT
1181 *
1182 * @param array array of TypoScript properties
1183 * @return string Output
1184 */
1185 public function SWFOBJECT($conf) {
1186 return $this->getContentObject('SWFOBJECT')->render($conf);
1187 }
1188
1189 /**
1190 * Rendering the cObject, QTOBJECT
1191 *
1192 * @param array array of TypoScript properties
1193 * @return string Output
1194 */
1195 public function QTOBJECT($conf) {
1196 return $this->getContentObject('QTOBJECT')->render($conf);
1197 }
1198
1199 /**
1200 * Rendering the cObject, SVG
1201 *
1202 * @param array array of TypoScript properties
1203 * @return string Output
1204 */
1205 public function SVG($conf) {
1206 return $this->getContentObject('SVG')->render($conf);
1207 }
1208
1209 /************************************
1210 *
1211 * Various helper functions for content objects:
1212 *
1213 ************************************/
1214
1215
1216 /**
1217 * Converts a given config in Flexform to a conf-array
1218 * @param string Flexform data
1219 * @param array array to write the data into, by reference
1220 * @param boolean is set if called recursive. Don't call function with this parameter, it's used inside the function only
1221 * @access public
1222 *
1223 */
1224 public function readFlexformIntoConf($flexData, &$conf, $recursive = FALSE) {
1225 if ($recursive === FALSE) {
1226 $flexData = t3lib_div::xml2array($flexData, 'T3');
1227 }
1228
1229 if (is_array($flexData)) {
1230 if (isset($flexData['data']['sDEF']['lDEF'])) {
1231 $flexData = $flexData['data']['sDEF']['lDEF'];
1232 }
1233
1234 foreach ($flexData as $key => $value) {
1235 if (is_array($value['el']) && count($value['el']) > 0) {
1236 foreach ($value['el'] as $ekey => $element) {
1237 if (isset($element['vDEF'])) {
1238 $conf[$ekey] = $element['vDEF'];
1239 } else {
1240 if (is_array($element)) {
1241 $this->readFlexformIntoConf($element, $conf[$key][key($element)][$ekey], TRUE);
1242 } else {
1243 $this->readFlexformIntoConf($element, $conf[$key][$ekey], TRUE);
1244 }
1245 }
1246 }
1247 } else {
1248 $this->readFlexformIntoConf($value['el'], $conf[$key], TRUE);
1249 }
1250 if ($value['vDEF']) {
1251 $conf[$key] = $value['vDEF'];
1252 }
1253 }
1254 }
1255 }
1256
1257
1258 /**
1259 * Returns all parents of the given PID (Page UID) list
1260 *
1261 * @param string A list of page Content-Element PIDs (Page UIDs) / stdWrap
1262 * @param array stdWrap array for the list
1263 * @return string A list of PIDs
1264 * @access private
1265 */
1266 function getSlidePids($pidList, $pidConf) {
1267 $pidList = isset($pidConf)
1268 ? trim($this->stdWrap($pidList, $pidConf))
1269 : trim($pidList);
1270 if (!strcmp($pidList, '')) {
1271 $pidList = 'this';
1272 }
1273 if (trim($pidList)) {
1274 $listArr = t3lib_div::intExplode(',', str_replace('this', $GLOBALS['TSFE']->contentPid, $pidList));
1275 $listArr = $this->checkPidArray($listArr);
1276 }
1277 $pidList = array();
1278 if (is_array($listArr) && count($listArr)) {
1279 foreach ($listArr as $uid) {
1280 $page = $GLOBALS['TSFE']->sys_page->getPage($uid);
1281 if (!$page['is_siteroot']) {
1282 $pidList[] = $page['pid'];
1283 }
1284 }
1285 }
1286 return implode(',', $pidList);
1287 }
1288
1289 /**
1290 * Returns a default value for a form field in the FORM cObject.
1291 * Page CANNOT be cached because that would include the inserted value for the current user.
1292 *
1293 * @param boolean If noValueInsert OR if the no_cache flag for this page is NOT set, the original default value is returned.
1294 * @param string $fieldName: The POST var name to get default value for
1295 * @param string $defaultVal: The current default value
1296 * @return string The default value, either from INPUT var or the current default, based on whether caching is enabled or not.
1297 * @access private
1298 */
1299 function getFieldDefaultValue($noValueInsert, $fieldName, $defaultVal) {
1300 if (!$GLOBALS['TSFE']->no_cache || (!isset($_POST[$fieldName]) && !isset($_GET[$fieldName])) || $noValueInsert) {
1301 return $defaultVal;
1302 } else {
1303 return t3lib_div::_GP($fieldName);
1304 }
1305 }
1306
1307 /**
1308 * Returns a <img> tag with the image file defined by $file and processed according to the properties in the TypoScript array.
1309 * Mostly this function is a sub-function to the IMAGE function which renders the IMAGE cObject in TypoScript.
1310 * This function is called by "$this->cImage($conf['file'],$conf);" from IMAGE().
1311 *
1312 * @param string File TypoScript resource
1313 * @param array TypoScript configuration properties
1314 * @return string <img> tag, (possibly wrapped in links and other HTML) if any image found.
1315 * @access private
1316 * @see IMAGE()
1317 */
1318 function cImage($file, $conf) {
1319 $info = $this->getImgResource($file, $conf['file.']);
1320 $GLOBALS['TSFE']->lastImageInfo = $info;
1321 if (is_array($info)) {
1322 $info[3] = t3lib_div::png_to_gif_by_imagemagick($info[3]);
1323 $GLOBALS['TSFE']->imagesOnPage[] = $info[3]; // This array is used to collect the image-refs on the page...
1324
1325
1326 // Backwards compatibility if altText is not set and alttext is set
1327 // @deprecated since TYPO3 4.3, will be removed in TYPO3 4.6
1328 if (strlen($conf['alttext']) || is_array($conf['alttext.'])) {
1329 $GLOBALS['TSFE']->logDeprecatedTyposcript(
1330 'IMAGE.alttext',
1331 'use IMAGE.altText instead - src: ' . $info[3] . ' - original image: ' . $info['origFile']
1332 );
1333 if (!strlen($conf['altText']) && !is_array($conf['altText.'])) {
1334 $conf['altText'] = $conf['alttext'];
1335 $conf['altText.'] = $conf['alttext.'];
1336 }
1337 }
1338
1339 $altParam = $this->getAltParam($conf);
1340 if($conf['params'] && !isset($conf['params.'])) {
1341 $params = ' ' . $conf['params'];
1342 } else {
1343 $params = isset($conf['params.'])
1344 ? ' ' . $this->stdWrap($conf['params'], $conf['params.'])
1345 : '';
1346 }
1347 $theValue = '<img src="' . htmlspecialchars($GLOBALS['TSFE']->absRefPrefix .
1348 t3lib_div::rawUrlEncodeFP($info[3])) . '" width="' . $info[0] . '" height="' . $info[1] . '"' .
1349 $this->getBorderAttr(' border="' . intval($conf['border']) . '"') .
1350 $params .
1351 ($altParam) . ' />';
1352 $linkWrap = isset($conf['linkWrap.'])
1353 ? $this->stdWrap($conf['linkWrap'], $conf['linkWrap.'])
1354 : $conf['linkWrap'];
1355 if ($linkWrap) {
1356 $theValue = $this->linkWrap($theValue, $linkWrap);
1357 } elseif ($conf['imageLinkWrap']) {
1358 $theValue = $this->imageLinkWrap($theValue, $info['origFile'], $conf['imageLinkWrap.']);
1359 }
1360 $wrap = isset($conf['wrap.'])
1361 ? $this->stdWrap($conf['wrap'], $conf['wrap.'])
1362 : $conf['wrap'];
1363 if($wrap) {
1364 $theValue = $this->wrap($theValue, $conf['wrap']);
1365 }
1366 return $theValue;
1367 }
1368 }
1369
1370 /**
1371 * Returns the 'border' attribute for an <img> tag only if the doctype is not xhtml_strict, xhtml_11, xhtml_2 or html5
1372 * or if the config parameter 'disableImgBorderAttr' is not set.
1373 *
1374 * @param string the border attribute
1375 * @return string the border attribute
1376 */
1377 function getBorderAttr($borderAttr) {
1378 if (! t3lib_div::inList('xhtml_strict,xhtml_11,xhtml_2', $GLOBALS['TSFE']->xhtmlDoctype) &&
1379 $GLOBALS['TSFE']->config['config']['doctype'] != 'html5' &&
1380 ! $GLOBALS['TSFE']->config['config']['disableImgBorderAttr']) {
1381 return $borderAttr;
1382 }
1383 }
1384
1385 /**
1386 * Wraps the input string in link-tags that opens the image in a new window.
1387 *
1388 * @param string String to wrap, probably an <img> tag
1389 * @param string The original image file
1390 * @param array TypoScript properties for the "imageLinkWrap" function
1391 * @return string The input string, $string, wrapped as configured.
1392 * @see cImage()
1393 */
1394 function imageLinkWrap($string, $imageFile, $conf) {
1395 $a1 = '';
1396 $a2 = '';
1397 $content = $string;
1398 $enable = isset($conf['enable.'])
1399 ? $this->stdWrap($conf['enable'], $conf['enable.'])
1400 : $conf['enable'];
1401 if ($enable) {
1402 $content = $this->typolink($string, $conf['typolink.']);
1403 if(isset($conf['file.'])) {
1404 $imageFile = $this->stdWrap($imageFile, $conf['file.']);
1405 }
1406
1407 // imageFileLink:
1408 if ($content == $string && @is_file($imageFile)) {
1409 $parameterNames = array('width', 'height', 'effects', 'alternativeTempPath', 'bodyTag', 'title', 'wrap');
1410 $parameters = array();
1411
1412 $sample = isset($conf['sample.'])
1413 ? $this->stdWrap($conf['sample'], $conf['sample.'])
1414 : $conf['sample'];
1415 if ($sample) {
1416 $parameters['sample'] = 1;
1417 }
1418
1419 foreach ($parameterNames as $parameterName) {
1420 if(isset($conf[$parameterName.'.'])) {
1421 $conf[$parameterName] = $this->stdWrap($conf[$parameterName], $conf[$parameterName.'.']);
1422 }
1423 if (isset($conf[$parameterName]) && $conf[$parameterName]) {
1424 $parameters[$parameterName] = $conf[$parameterName];
1425 }
1426 }
1427
1428 $parametersEncoded = base64_encode(serialize($parameters));
1429
1430 $md5_value = t3lib_div::hmac(
1431 implode(
1432 '|',
1433 array($imageFile, $parametersEncoded)
1434 )
1435 );
1436
1437 $params = '&md5=' . $md5_value;
1438 foreach (str_split($parametersEncoded, 64) as $index => $chunk) {
1439 $params .= '&parameters[' . $index . ']=' . rawurlencode($chunk);
1440 }
1441
1442 $url = $GLOBALS['TSFE']->absRefPrefix . 'index.php?eID=tx_cms_showpic&file=' . rawurlencode($imageFile) . $params;
1443
1444 $directImageLink = isset($conf['directImageLink.'])
1445 ? $this->stdWrap($conf['directImageLink'], $conf['directImageLink.'])
1446 : $conf['directImageLink'];
1447 if ($directImageLink) {
1448 $imgResourceConf = array(
1449 'file' => $imageFile,
1450 'file.' => $conf
1451 );
1452 $url = $this->IMG_RESOURCE($imgResourceConf);
1453 if (!$url) {
1454 // if no imagemagick / gm is available
1455 $url = $imageFile;
1456 }
1457 }
1458
1459 // Create TARGET-attribute only if the right doctype is used
1460 if (!t3lib_div::inList('xhtml_strict,xhtml_11,xhtml_2', $GLOBALS['TSFE']->xhtmlDoctype)) {
1461 $target = isset($conf['target.'])
1462 ? $this-stdWrap($conf['target'], $conf['target.'])
1463 : $conf['target'];
1464 if(!$target) {
1465 $target = sprintf(' target="%s"', $target);
1466 } else {
1467 $target = ' target="thePicture"';
1468 }
1469 } else {
1470 $target = '';
1471 }
1472 $conf['JSwindow'] = isset($conf['JSwindow.'])
1473 ? $this->stdWrap($conf['JSwindow'], $conf['JSwindow.'])
1474 : $conf['JSwindow'];
1475 if ($conf['JSwindow']) {
1476 if ($conf['JSwindow.']['altUrl'] || $conf['JSwindow.']['altUrl.']) {
1477 $altUrl = isset($conf['JSwindow.']['altUrl.'])
1478 ? $this->stdWrap($conf['JSwindow.']['altUrl'], $conf['JSwindow.']['altUrl.'])
1479 : $conf['JSwindow.']['altUrl'];
1480 if ($altUrl) {
1481 $url = $altUrl .
1482 ($conf['JSwindow.']['altUrl_noDefaultParams'] ? '' : '?file=' .
1483 rawurlencode($imageFile) . $params);
1484 }
1485 }
1486 $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
1487 $gifCreator->init();
1488 $gifCreator->mayScaleUp = 0;
1489
1490 $dims = $gifCreator->getImageScale($gifCreator->getImageDimensions($imageFile), $conf['width'], $conf['height'], '');
1491 $JSwindowExpand = isset($conf['JSwindow.']['expand.'])
1492 ? $this->stdWrap($conf['JSwindow.']['expand'], $conf['JSwindow.']['expand.'])
1493 : $conf['JSwindow.']['expand'];
1494 $offset = t3lib_div::intExplode(',', $JSwindowExpand . ',');
1495
1496 $newWindow = isset($conf['JSwindow.']['newWindow.'])
1497 ? $this->stdWrap($conf['JSwindow.']['newWindow'], $conf['JSwindow.']['newWindow.'])
1498 : $conf['JSwindow.']['newWindow'];
1499 $a1 = '<a href="' . htmlspecialchars($url) . '" onclick="' .
1500 htmlspecialchars('openPic(\'' . $GLOBALS['TSFE']->baseUrlWrap($url) . '\',\'' .
1501 ($newWindow ? md5($url) : 'thePicture') . '\',\'width=' .
1502 ($dims[0] + $offset[0]) . ',height=' . ($dims[1] + $offset[1]) .
1503 ',status=0,menubar=0\'); return false;') . '"' .
1504 $target . $GLOBALS['TSFE']->ATagParams . '>';
1505 $a2 = '</a>';
1506 $GLOBALS['TSFE']->setJS('openPic');
1507 } else {
1508 $conf['linkParams.']['parameter'] = $url;
1509 $string = $this->typoLink($string, $conf['linkParams.']);
1510 }
1511
1512 if(isset($conf['stdWrap.'])) {
1513 $string = $this->stdWrap($string, $conf['stdWrap.']);
1514 }
1515
1516 $content = $a1 . $string . $a2;
1517 }
1518 }
1519
1520 return $content;
1521 }
1522
1523 /**
1524 * Returns content of a file. If it's an image the content of the file is not returned but rather an image tag is.
1525 *
1526 * @param string The filename, being a TypoScript resource data type
1527 * @param string Additional parameters (attributes). Default is empty alt and title tags.
1528 * @return string If jpg,gif,jpeg,png: returns image_tag with picture in. If html,txt: returns content string
1529 * @see FILE()
1530 */
1531 function fileResource($fName, $addParams = 'alt="" title=""') {
1532 $incFile = $GLOBALS['TSFE']->tmpl->getFileName($fName);
1533 if ($incFile) {
1534 $fileinfo = t3lib_div::split_fileref($incFile);
1535 if (t3lib_div::inList('jpg,gif,jpeg,png', $fileinfo['fileext'])) {
1536 $imgFile = $incFile;
1537 $imgInfo = @getImageSize($imgFile);
1538 return '<img src="' . $GLOBALS['TSFE']->absRefPrefix . $imgFile .
1539 '" width="' . $imgInfo[0] . '" height="' . $imgInfo[1] . '"' .
1540 $this->getBorderAttr(' border="0"') . ' ' . $addParams . ' />';
1541 } elseif (filesize($incFile) < 1024 * 1024) {
1542 return $GLOBALS['TSFE']->tmpl->fileContent($incFile);
1543 }
1544 }
1545 }
1546
1547 /**
1548 * Sets the SYS_LASTCHANGED timestamp if input timestamp is larger than current value.
1549 * The SYS_LASTCHANGED timestamp can be used by various caching/indexing applications to determine if the page has new content.
1550 * Therefore you should call this function with the last-changed timestamp of any element you display.
1551 *
1552 * @param integer Unix timestamp (number of seconds since 1970)
1553 * @return void
1554 * @see tslib_fe::setSysLastChanged()
1555 */
1556 function lastChanged($tstamp) {
1557 $tstamp = intval($tstamp);
1558 if ($tstamp > intval($GLOBALS['TSFE']->register['SYS_LASTCHANGED'])) {
1559 $GLOBALS['TSFE']->register['SYS_LASTCHANGED'] = $tstamp;
1560 }
1561 }
1562
1563 /**
1564 * Wraps the input string by the $wrap value and implements the "linkWrap" data type as well.
1565 * 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.
1566 *
1567 * @param string Input string
1568 * @param string A string where the first two parts separated by "|" (vertical line) will be wrapped around the input string
1569 * @return string Wrapped output string
1570 * @see wrap(), cImage(), FILE()
1571 */
1572 function linkWrap($content, $wrap) {
1573 $wrapArr = explode('|', $wrap);
1574 if (preg_match('/\{([0-9]*)\}/', $wrapArr[0], $reg)) {
1575 if ($uid = $GLOBALS['TSFE']->tmpl->rootLine[$reg[1]]['uid']) {
1576 $wrapArr[0] = str_replace($reg[0], $uid, $wrapArr[0]);
1577 }
1578 }
1579 return trim($wrapArr[0]) . $content . trim($wrapArr[1]);
1580 }
1581
1582 /**
1583 * An abstraction method which creates an alt or title parameter for an HTML img, applet, area or input element and the FILE content element.
1584 * From the $conf array it implements the properties "altText", "titleText" and "longdescURL"
1585 *
1586 * @param array TypoScript configuration properties
1587 * @param boolean If set, the longdesc attribute will be generated - must only be used for img elements!
1588 * @return string Parameter string containing alt and title parameters (if any)
1589 * @see IMGTEXT(), FILE(), FORM(), cImage(), filelink()
1590 */
1591 function getAltParam($conf, $longDesc = TRUE) {
1592 $altText = isset($conf['altText.'])
1593 ? trim($this->stdWrap($conf['altText'], $conf['altText.']))
1594 : trim($conf['altText']);
1595 $titleText = isset($conf['titleText.'])
1596 ? trim($this->stdWrap($conf['titleText'], $conf['titleText.']))
1597 : trim($conf['titleText']);
1598 $longDesc = isset($conf['longdescURL.'])
1599 ? trim($this->stdWrap($conf['longdescURL'], $conf['longdescURL.']))
1600 : trim($conf['longdescURL']);
1601
1602 // "alt":
1603 $altParam = ' alt="' . htmlspecialchars($altText) . '"';
1604
1605 // "title":
1606 $emptyTitleHandling = 'useAlt';
1607 $emptyTitleHandling = isset($conf['emptyTitleHandling.'])
1608 ? $this->stdWrap($conf['emptyTitleHandling'], $conf['emptyTitleHandling.'])
1609 : $conf['emptyTitleHandling'];
1610 // choices: 'keepEmpty' | 'useAlt' | 'removeAttr'
1611 if ($titleText || $emptyTitleHandling == 'keepEmpty') {
1612 $altParam .= ' title="' . htmlspecialchars($titleText) . '"';
1613 } elseif (!$titleText && $emptyTitleHandling == 'useAlt') {
1614 $altParam .= ' title="' . htmlspecialchars($altText) . '"';
1615 }
1616
1617 // "longDesc" URL
1618 if ($longDesc) {
1619 $altParam .= ' longdesc="' . htmlspecialchars(strip_tags($longDesc)) . '"';
1620 }
1621
1622 return $altParam;
1623 }
1624
1625 /**
1626 * Removes forbidden characters and spaces from name/id attributes in the form tag and formfields
1627 *
1628 * @param string Input string
1629 * @return string the cleaned string
1630 * @see FORM()
1631 */
1632 function cleanFormName($name) {
1633 // turn data[x][y] into data:x:y:
1634 $name = preg_replace('/\[|\]\[?/', ':', trim($name));
1635 // remove illegal chars like _
1636 return preg_replace('#[^:a-zA-Z0-9]#', '', $name);
1637 }
1638
1639 /**
1640 * An abstraction method to add parameters to an A tag.
1641 * Uses the ATagParams property.
1642 *
1643 * @param array TypoScript configuration properties
1644 * @param boolean If set, will add the global config.ATagParams to the link
1645 * @return string String containing the parameters to the A tag (if non empty, with a leading space)
1646 * @see IMGTEXT(), filelink(), makelinks(), typolink()
1647 */
1648 function getATagParams($conf, $addGlobal = 1) {
1649 $aTagParams = '';
1650 if ($conf['ATagParams.']) {
1651 $aTagParams = ' ' . $this->stdWrap($conf['ATagParams'], $conf['ATagParams.']);
1652 } elseif ($conf['ATagParams']) {
1653 $aTagParams = ' ' . $conf['ATagParams'];
1654 }
1655 if ($addGlobal) {
1656 $aTagParams = ' ' . trim($GLOBALS['TSFE']->ATagParams . $aTagParams);
1657 }
1658 return $aTagParams;
1659 }
1660
1661 /**
1662 * All extension links should ask this function for additional properties to their tags.
1663 * Designed to add for instance an "onclick" property for site tracking systems.
1664 *
1665 * @param string URL of the website
1666 * @return string the additional tag properties
1667 */
1668 function extLinkATagParams($URL, $TYPE) {
1669 $out = '';
1670
1671 if ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['extLinkATagParamsHandler']) {
1672 $extLinkATagParamsHandler = t3lib_div::getUserObj(
1673 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['extLinkATagParamsHandler']
1674 );
1675
1676 if (method_exists($extLinkATagParamsHandler, 'main')) {
1677 $out .= trim($extLinkATagParamsHandler->main($URL, $TYPE, $this));
1678 }
1679 }
1680
1681 return trim($out) ? ' ' . trim($out) : '';
1682 }
1683
1684
1685
1686 /***********************************************
1687 *
1688 * HTML template processing functions
1689 *
1690 ***********************************************/
1691
1692 /**
1693 * Returns a subpart from the input content stream.
1694 * A subpart is a part of the input stream which is encapsulated in a
1695 * string matching the input string, $marker. If this string is found
1696 * inside of HTML comment tags the start/end points of the content block
1697 * returned will be that right outside that comment block.
1698 * Example: The contennt string is
1699 * "Hello <!--###sub1### begin--> World. How are <!--###sub1### end--> you?"
1700 * If $marker is "###sub1###" then the content returned is
1701 * " World. How are ". The input content string could just as well have
1702 * been "Hello ###sub1### World. How are ###sub1### you?" and the result
1703 * would be the same
1704 * Wrapper for t3lib_parsehtml::getSubpart which behaves identical
1705 *
1706 * @param string The content stream, typically HTML template content.
1707 * @param string The marker string, typically on the form "###[the marker string]###"
1708 * @return string The subpart found, if found.
1709 * @see substituteSubpart(), t3lib_parsehtml::getSubpart()
1710 */
1711 public function getSubpart($content, $marker) {
1712 return t3lib_parsehtml::getSubpart($content, $marker);
1713 }
1714
1715 /**
1716 * Substitute subpart in input template stream.
1717 * This function substitutes a subpart in $content with the content of
1718 * $subpartContent.
1719 * Wrapper for t3lib_parsehtml::substituteSubpart which behaves identical
1720 *
1721 * @param string The content stream, typically HTML template content.
1722 * @param string The marker string, typically on the form "###[the marker string]###"
1723 * @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.
1724 * @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!
1725 * @return string The processed HTML content string.
1726 * @see getSubpart(), t3lib_parsehtml::substituteSubpart()
1727 */
1728 public function substituteSubpart($content, $marker, $subpartContent, $recursive = 1) {
1729 return t3lib_parsehtml::substituteSubpart($content, $marker, $subpartContent, $recursive);
1730 }
1731
1732 /**
1733 * Substitues multiple subparts at once
1734 *
1735 * @param string The content stream, typically HTML template content.
1736 * @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.
1737 * @return string The processed HTML content string.
1738 */
1739 public function substituteSubpartArray($content, array $subpartsContent) {
1740 return t3lib_parsehtml::substituteSubpartArray($content, $subpartsContent);
1741 }
1742
1743 /**
1744 * Substitutes a marker string in the input content
1745 * (by a simple str_replace())
1746 *
1747 * @param string The content stream, typically HTML template content.
1748 * @param string The marker string, typically on the form "###[the marker string]###"
1749 * @param mixed The content to insert instead of the marker string found.
1750 * @return string The processed HTML content string.
1751 * @see substituteSubpart()
1752 */
1753 public function substituteMarker($content, $marker, $markContent) {
1754 return t3lib_parsehtml::substituteMarker($content, $marker, $markContent);
1755 }
1756
1757 /**
1758 * Multi substitution function with caching.
1759 *
1760 * This function should be a one-stop substitution function for working
1761 * with HTML-template. It does not substitute by str_replace but by
1762 * splitting. This secures that the value inserted does not themselves
1763 * contain markers or subparts.
1764 *
1765 * Note that the "caching" won't cache the content of the substition,
1766 * but only the splitting of the template in various parts. So if you
1767 * want only one cache-entry per template, make sure you always pass the
1768 * exact same set of marker/subpart keys. Else you will be flooding the
1769 * users cache table.
1770 *
1771 * This function takes three kinds of substitutions in one:
1772 * $markContentArray is a regular marker-array where the 'keys' are
1773 * substituted in $content with their values
1774 *
1775 * $subpartContentArray works exactly like markContentArray only is whole
1776 * subparts substituted and not only a single marker.
1777 *
1778 * $wrappedSubpartContentArray is an array of arrays with 0/1 keys where
1779 * the subparts pointed to by the main key is wrapped with the 0/1 value
1780 * alternating.
1781 *
1782 * @param string The content stream, typically HTML template content.
1783 * @param array Regular marker-array where the 'keys' are substituted in $content with their values
1784 * @param array Exactly like markContentArray only is whole subparts substituted and not only a single marker.
1785 * @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.
1786 * @return string The output content stream
1787 * @see substituteSubpart(), substituteMarker(), substituteMarkerInObject(), TEMPLATE()
1788 */
1789 public function substituteMarkerArrayCached($content, array $markContentArray = NULL, array $subpartContentArray = NULL, array $wrappedSubpartContentArray = NULL) {
1790 $GLOBALS['TT']->push('substituteMarkerArrayCached');
1791
1792 // If not arrays then set them
1793 if (is_null($markContentArray))
1794 $markContentArray = array(); // Plain markers
1795 if (is_null($subpartContentArray))
1796 $subpartContentArray = array(); // Subparts being directly substituted
1797 if (is_null($wrappedSubpartContentArray))
1798 $wrappedSubpartContentArray = array(); // Subparts being wrapped
1799 // Finding keys and check hash:
1800 $sPkeys = array_keys($subpartContentArray);
1801 $wPkeys = array_keys($wrappedSubpartContentArray);
1802 $aKeys = array_merge(array_keys($markContentArray), $sPkeys, $wPkeys);
1803 if (!count($aKeys)) {
1804 $GLOBALS['TT']->pull();
1805 return $content;
1806 }
1807 asort($aKeys);
1808 $storeKey = md5('substituteMarkerArrayCached_storeKey:' . serialize(array(
1809 $content, $aKeys
1810 )));
1811 if ($this->substMarkerCache[$storeKey]) {
1812 $storeArr = $this->substMarkerCache[$storeKey];
1813 $GLOBALS['TT']->setTSlogMessage('Cached', 0);
1814 } else {
1815 $storeArrDat = $GLOBALS['TSFE']->sys_page->getHash($storeKey);
1816 if (!isset($storeArrDat)) {
1817 // Initialize storeArr
1818 $storeArr = array();
1819
1820 // Finding subparts and substituting them with the subpart as a marker
1821 foreach ($sPkeys as $sPK) {
1822 $content = $this->substituteSubpart($content, $sPK, $sPK);
1823 }
1824
1825 // Finding subparts and wrapping them with markers
1826 foreach ($wPkeys as $wPK) {
1827 $content = $this->substituteSubpart($content, $wPK, array(
1828 $wPK, $wPK
1829 ));
1830 }
1831
1832 // traverse keys and quote them for reg ex.
1833 foreach ($aKeys as $tK => $tV) {
1834 $aKeys[$tK] = preg_quote($tV, '/');
1835 }
1836 $regex = '/' . implode('|', $aKeys) . '/';
1837 // Doing regex's
1838 $storeArr['c'] = preg_split($regex, $content);
1839 preg_match_all($regex, $content, $keyList);
1840 $storeArr['k'] = $keyList[0];
1841 // Setting cache:
1842 $this->substMarkerCache[$storeKey] = $storeArr;
1843
1844 // Storing the cached data:
1845 $GLOBALS['TSFE']->sys_page->storeHash($storeKey, serialize($storeArr), 'substMarkArrayCached');
1846
1847 $GLOBALS['TT']->setTSlogMessage('Parsing', 0);
1848 } else {
1849 // Unserializing
1850 $storeArr = unserialize($storeArrDat);
1851 // Setting cache:
1852 $this->substMarkerCache[$storeKey] = $storeArr;
1853 $GLOBALS['TT']->setTSlogMessage('Cached from DB', 0);
1854 }
1855 }
1856
1857 // Substitution/Merging:
1858 // Merging content types together, resetting
1859 $valueArr = array_merge($markContentArray, $subpartContentArray, $wrappedSubpartContentArray);
1860
1861 $wSCA_reg = array();
1862 $content = '';
1863 // traversing the keyList array and merging the static and dynamic content
1864 foreach ($storeArr['k'] as $n => $keyN) {
1865 $content .= $storeArr['c'][$n];
1866 if (!is_array($valueArr[$keyN])) {
1867 $content .= $valueArr[$keyN];
1868 } else {
1869 $content .= $valueArr[$keyN][(intval($wSCA_reg[$keyN]) % 2)];
1870 $wSCA_reg[$keyN]++;
1871 }
1872 }
1873 $content .= $storeArr['c'][count($storeArr['k'])];
1874
1875 $GLOBALS['TT']->pull();
1876 return $content;
1877 }
1878
1879 /**
1880 * Traverses the input $markContentArray array and for each key the marker
1881 * by the same name (possibly wrapped and in upper case) will be
1882 * substituted with the keys value in the array.
1883 *
1884 * This is very useful if you have a data-record to substitute in some
1885 * content. In particular when you use the $wrap and $uppercase values to
1886 * pre-process the markers. Eg. a key name like "myfield" could effectively
1887 * be represented by the marker "###MYFIELD###" if the wrap value
1888 * was "###|###" and the $uppercase boolean TRUE.
1889 *
1890 * @param string The content stream, typically HTML template content.
1891 * @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.
1892 * @param string A wrap value - [part 1] | [part 2] - for the markers before substitution
1893 * @param boolean If set, all marker string substitution is done with upper-case markers.
1894 * @param boolean If set, all unused marker are deleted.
1895 * @return string The processed output stream
1896 * @see substituteMarker(), substituteMarkerInObject(), TEMPLATE()
1897 */
1898 public function substituteMarkerArray($content, array $markContentArray, $wrap = '', $uppercase = FALSE, $deleteUnused = FALSE) {
1899 return t3lib_parsehtml::substituteMarkerArray($content, $markContentArray, $wrap, $uppercase, $deleteUnused);
1900 }
1901
1902 /**
1903 * Substitute marker array in an array of values
1904 *
1905 * @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)
1906 * @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.
1907 * @return mixed The processed input variable.
1908 * @see substituteMarker()
1909 */
1910 public function substituteMarkerInObject(&$tree, array $markContentArray) {
1911 if (is_array($tree)) {
1912 foreach ($tree as $key => $value) {
1913 $this->substituteMarkerInObject($tree[$key], $markContentArray);
1914 }
1915 } else {
1916 $tree = $this->substituteMarkerArray($tree, $markContentArray);
1917 }
1918
1919 return $tree;
1920 }
1921
1922 /**
1923 * Adds elements to the input $markContentArray based on the values from
1924 * the fields from $fieldList found in $row
1925 *
1926 * @param array array with key/values being marker-strings/substitution values.
1927 * @param array An array with keys found in the $fieldList (typically a record) which values should be moved to the $markContentArray
1928 * @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)
1929 * @param boolean If set, all values added to $markContentArray will be nl2br()'ed
1930 * @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 "###"
1931 * @param boolean If set, all values are passed through htmlspecialchars() - RECOMMENDED to avoid most obvious XSS and maintain XHTML compliance.
1932 * @return array The modified $markContentArray
1933 */
1934 public function fillInMarkerArray(array $markContentArray, array $row, $fieldList = '', $nl2br = TRUE, $prefix = 'FIELD_', $HSC = FALSE) {
1935 if ($fieldList) {
1936 $fArr = t3lib_div::trimExplode(',', $fieldList, 1);
1937 foreach ($fArr as $field) {
1938 $markContentArray['###' . $prefix . $field . '###'] = $nl2br ? nl2br($row[$field]) : $row[$field];
1939 }
1940 } else {
1941 if (is_array($row)) {
1942 foreach ($row as $field => $value) {
1943 if (!t3lib_div::testInt($field)) {
1944 if ($HSC) {
1945 $value = htmlspecialchars($value);
1946 }
1947
1948 $markContentArray['###' . $prefix . $field . '###'] = $nl2br ? nl2br($value) : $value;
1949 }
1950 }
1951 }
1952 }
1953
1954 return $markContentArray;
1955 }
1956
1957 /***********************************************
1958 *
1959 * "stdWrap" + sub functions
1960 *
1961 ***********************************************/
1962
1963 /**
1964 * The "stdWrap" function. This is the implementation of what is known as "stdWrap properties" in TypoScript.
1965 * Basically "stdWrap" performs some processing of a value based on properties in the input $conf array(holding the TypoScript "stdWrap properties")
1966 * 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.
1967 *
1968 * If $this->alternativeData is an array it's used instead of the $this->data array in ->getData
1969 *
1970 * @param string Input value undergoing processing in this function. Possibly substituted by other values fetched from another source.
1971 * @param array TypoScript "stdWrap properties".
1972 * @return string The processed input value
1973 */
1974 public function stdWrap($content = '', $conf = array()) {
1975 if (count($this->stdWrapHookObjects)) {
1976 foreach ($this->stdWrapHookObjects as $hookObject) {
1977 if (is_callable(array($hookObject, 'stdWrapPreProcess'))) {
1978 $conf['stdWrapPreProcess'] = 1;
1979 }
1980 ;
1981 if (is_callable(array($hookObject, 'stdWrapOverride'))) {
1982 $conf['stdWrapOverride'] = 1;
1983 }
1984 ;
1985 if (is_callable(array($hookObject, 'stdWrapProcess'))) {
1986 $conf['stdWrapProcess'] = 1;
1987 }
1988 ;
1989 if (is_callable(array($hookObject, 'stdWrapPostProcess'))) {
1990 $conf['stdWrapPostProcess'] = 1;
1991 }
1992 ;
1993 }
1994 }
1995 if (is_array($conf) && count($conf)) {
1996 // check, which of the available stdWrap functions is needed for the current conf Array
1997 // and keep only those but still in the same order
1998 $sortedConf = array_intersect_key($this->stdWrapOrder, $conf);
1999 // functions types that should not make use of nested stdWrap function calls to avoid conflicts with internal TypoScript used by these functions
2000 $stdWrapDisabledFunctionTypes = 'cObject,functionName,stdWrap';
2001 // additional Array to check whether a function has already been executed
2002 $isExecuted = array();
2003 // additional switch to make sure 'required', 'if' and 'fieldRequired'
2004 // will still stop rendering immediately in case they return false
2005
2006 $this->stdWrapRecursionLevel++;
2007 $this->stopRendering[$this->stdWrapRecursionLevel] = false;
2008
2009 // execute each funtion in the predefined order
2010 foreach ($sortedConf as $stdWrapName => $functionType) {
2011 // eliminate the second key of a pair 'key'|'key.' to make sure functions get called only once and check if rendering has been stopped
2012 if (!$isExecuted[$stdWrapName] &&
2013 !$this->stopRendering[$this->stdWrapRecursionLevel]) {
2014 $functionName = rtrim($stdWrapName, '.');
2015 $functionProperties = $functionName . '.';
2016 // if there is any code one the next level, check if it contains "official" stdWrap functions
2017 // if yes, execute them first - will make each function stdWrap aware
2018 // so additional stdWrap calls within the functions can be removed, since the result will be the same
2019 // exception: the recursive stdWrap function and cObject will still be using their own stdWrap call, since it modifies the content and not a property
2020 if (count($conf[$functionProperties]) &&
2021 !t3lib_div::inList($stdWrapDisabledFunctionTypes, $functionType)) {
2022 if (array_intersect_key($this->stdWrapOrder, $conf[$functionProperties])) {
2023 $conf[$functionName] = $this->stdWrap($conf[$functionName], $conf[$functionProperties]);
2024 }
2025 }
2026 // get just that part of $conf that is needed for the particular function
2027 $singleConf = array(
2028 $functionName => $conf[$functionName],
2029 $functionProperties => $conf[$functionProperties]
2030 );
2031
2032 // in this special case 'spaceBefore' and 'spaceAfter' need additional stuff from 'space.''
2033 if ($functionName == 'spaceBefore' || $functionName == 'spaceAfter') {
2034 $singleConf['space.'] = $conf['space.'];
2035 }
2036
2037 // hand over the whole $conf array to the stdWrapHookObjects
2038 if ($functionType === 'hook') {
2039 $singleConf = $conf;
2040 }
2041 // check if key is still containing something, since it might have been changed by next level stdWrap before
2042 if ((isset($conf[$functionName]) || $conf[$functionProperties]) &&
2043 !($functionType == 'boolean' && $conf[$functionName] === '0')) {
2044 //add both keys - with and without the dot - to the set of executed functions
2045 $isExecuted[$functionName] = true;
2046 $isExecuted[$functionProperties] = true;
2047 // call the function with the prefix stdWrap_ to make sure nobody can execute functions just by adding their name to the TS Array
2048 $functionName = 'stdWrap_' . $functionName;
2049 $content = $this->$functionName(
2050 $content,
2051 $singleConf
2052 );
2053 }
2054 }
2055 }
2056
2057 unset($this->stopRendering[$this->stdWrapRecursionLevel]);
2058 $this->stdWrapRecursionLevel--;
2059
2060 }
2061 return $content;
2062 }
2063
2064 /**
2065 * stdWrap pre process hook
2066 * can be used by extensions authors to modify the behaviour of stdWrap functions to their needs
2067 * this hook will execute functions before any other stdWrap function can modify anything
2068 *
2069 * @param string Input value undergoing processing in these functions.
2070 * @param array All stdWrap properties, not just the ones for a particular function.
2071 * @return string The processed input value
2072 */
2073 public function stdWrap_stdWrapPreProcess($content = '', $conf = array()) {
2074 foreach ($this->stdWrapHookObjects as $hookObject) {
2075 $content = $hookObject->stdWrapPreProcess($content, $conf, $this);
2076 }
2077 return $content;
2078 }
2079
2080 /**
2081 * setContentToCurrent
2082 * actually it just does the contrary: Sets the value of 'current' based on current content
2083 *
2084 * @param string Input value undergoing processing in this function.
2085 * @param array stdWrap properties for setContentToCurrent.
2086 * @return string The processed input value
2087 */
2088 public function stdWrap_setContentToCurrent($content = '', $conf = array()) {
2089 $this->data[$this->currentValKey] = $content;
2090 return $content;
2091 }
2092
2093 /**
2094 * setCurrent
2095 * Sets the value of 'current' based on the outcome of stdWrap operations
2096 *
2097 * @param string Input value undergoing processing in this function.
2098 * @param array stdWrap properties for setCurrent.
2099 * @return string The processed input value
2100 */
2101 public function stdWrap_setCurrent($content = '', $conf = array()) {
2102 $this->data[$this->currentValKey] = $conf['setCurrent'];
2103 return $content;
2104 }
2105
2106 /**
2107 * lang
2108 * Translates content based on the language currently used by the FE
2109 *
2110 * @param string Input value undergoing processing in this function.
2111 * @param array stdWrap properties for lang.
2112 * @return string The processed input value
2113 */
2114 public function stdWrap_lang($content = '', $conf = array()) {
2115 if (isset($conf['lang.']) && $GLOBALS['TSFE']->config['config']['language'] && isset($conf['lang.'][$GLOBALS['TSFE']->config['config']['language']])) {
2116 $content = $conf['lang.'][$GLOBALS['TSFE']->config['config']['language']];
2117 }
2118 return $content;
2119 }
2120
2121 /**
2122 * data
2123 * Gets content from different sources based on getText functions, makes use of alternativeData, when set
2124 *
2125 * @param string Input value undergoing processing in this function.
2126 * @param array stdWrap properties for data.
2127 * @return string The processed input value
2128 */
2129 public function stdWrap_data($content = '', $conf = array()) {
2130 $content = $this->getData($conf['data'], is_array($this->alternativeData) ? $this->alternativeData : $this->data);
2131 $this->alternativeData = ''; // This must be unset directly after
2132 return $content;
2133 }
2134
2135 /**
2136 * field
2137 * Gets content from a DB field
2138 *
2139 * @param string Input value undergoing processing in this function.
2140 * @param array stdWrap properties for field.
2141 * @return string The processed input value
2142 */
2143 public function stdWrap_field($content = '', $conf = array()) {
2144 $content = $this->getFieldVal($conf['field']);
2145 return $content;
2146 }
2147
2148 /**
2149 * current
2150 * Gets content that has been perviously set as 'current'
2151 * Can be set via setContentToCurrent or setCurrent or will be set automatically i.e. inside the split function
2152 *
2153 * @param string Input value undergoing processing in this function.
2154 * @param array stdWrap properties for current.
2155 * @return string The processed input value
2156 */
2157 public function stdWrap_current($content = '', $conf = array()) {
2158 $content = $this->data[$this->currentValKey];
2159 return $content;
2160 }
2161
2162 /**
2163 * cObject
2164 * Will replace the content with the value of a any official TypoScript cObject
2165 * like TEXT, COA, HMENU
2166 *
2167 * @param string Input value undergoing processing in this function.
2168 * @param array stdWrap properties for cObject.
2169 * @return string The processed input value
2170 */
2171 public function stdWrap_cObject($content = '', $conf = array()) {
2172 $content = $this->cObjGetSingle($conf['cObject'], $conf['cObject.'], '/stdWrap/.cObject');
2173 return $content;
2174 }
2175
2176 /**
2177 * numRows
2178 * Counts the number of returned records of a DB operation
2179 * makes use of select internally
2180 *
2181 * @param string Input value undergoing processing in this function.
2182 * @param array stdWrap properties for numRows.
2183 * @return string The processed input value
2184 */
2185 public function stdWrap_numRows($content = '', $conf = array()) {
2186 $content = $this->numRows($conf['numRows.']);
2187 return $content;
2188 }
2189
2190 /**
2191 * filelist
2192 * Will create a list of files based on some additional parameters
2193 *
2194 * @param string Input value undergoing processing in this function.
2195 * @param array stdWrap properties for filelist.
2196 * @return string The processed input value
2197 */
2198 public function stdWrap_filelist($content = '', $conf = array()) {
2199 $content = $this->filelist($conf['filelist']);
2200 return $content;
2201 }
2202
2203 /**
2204 * preUserFunc
2205 * Will execute a user public function before the content will be modified by any other stdWrap function
2206 *
2207 * @param string Input value undergoing processing in this function.
2208 * @param array stdWrap properties for preUserFunc.
2209 * @return string The processed input value
2210 */
2211 public function stdWrap_preUserFunc($content = '', $conf = array()) {
2212 $content = $this->callUserFunction($conf['preUserFunc'], $conf['preUserFunc.'], $content);
2213 return $content;
2214 }
2215
2216 /**
2217 * stdWrap override hook
2218 * can be used by extensions authors to modify the behaviour of stdWrap functions to their needs
2219 * this hook will execute functions on existing content but still before the content gets modified or replaced
2220 *
2221 * @param string Input value undergoing processing in these functions.
2222 * @param array All stdWrap properties, not just the ones for a particular function.
2223 * @return string The processed input value
2224 */
2225 public function stdWrap_stdWrapOverride($content = '', $conf = array()) {
2226 foreach ($this->stdWrapHookObjects as $hookObject) {
2227 $content = $hookObject->stdWrapOverride($content, $conf, $this);
2228 }
2229 return $content;
2230 }
2231
2232 /**
2233 * override
2234 * Will override the current value of content with its own value'
2235 *
2236 * @param string Input value undergoing processing in this function.
2237 * @param array stdWrap properties for override.
2238 * @return string The processed input value
2239 */
2240 public function stdWrap_override($content = '', $conf = array()) {
2241 if (trim($conf['override'])) {
2242 $content = $conf['override'];
2243 }
2244 return $content;
2245 }
2246
2247 /**
2248 * preIfEmptyListNum
2249 * Gets a value off a CSV list before the following ifEmpty check
2250 * 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
2251 *
2252 * @param string Input value undergoing processing in this function.
2253 * @param array stdWrap properties for preIfEmptyListNum.
2254 * @return string The processed input value
2255 */
2256 public function stdWrap_preIfEmptyListNum($content = '', $conf = array()) {
2257 $content = $this->listNum($content, $conf['preIfEmptyListNum'], $conf['preIfEmptyListNum.']['splitChar']);
2258 return $content;
2259 }
2260
2261 /**
2262 * ifEmpty
2263 * Will set content to a replacement value in case the trimmed value of content returns false
2264 * 0 (zero) will be replaced as well
2265 *
2266 * @param string Input value undergoing processing in this function.
2267 * @param array stdWrap properties for ifEmpty.
2268 * @return string The processed input value
2269 */
2270 public function stdWrap_ifEmpty($content = '', $conf = array()) {
2271 if (!trim($content)) {
2272 $content = $conf['ifEmpty'];
2273 }
2274 return $content;
2275 }
2276
2277 /**
2278 * ifBlank
2279 * Will set content to a replacement value in case the trimmed value of content has no length
2280 * 0 (zero) will not be replaced
2281 *
2282 * @param string Input value undergoing processing in this function.
2283 * @param array stdWrap properties for ifBlank.
2284 * @return string The processed input value
2285 */
2286 public function stdWrap_ifBlank($content = '', $conf = array()) {
2287 if (!strlen(trim($content))) {
2288 $content = $conf['ifBlank'];
2289 }
2290 return $content;
2291 }
2292
2293 /**
2294 * listNum
2295 * Gets a value off a CSV list after ifEmpty check
2296 * Might return an empty value in case the CSV does not contain a value at the position given by listNum
2297 * Use preIfEmptyListNum to avoid that behaviour
2298 *
2299 * @param string Input value undergoing processing in this function.
2300 * @param array stdWrap properties for listNum.
2301 * @return string The processed input value
2302 */
2303 public function stdWrap_listNum($content = '', $conf = array()) {
2304 $content = $this->listNum($content, $conf['listNum'], $conf['listNum.']['splitChar']);
2305 return $content;
2306 }
2307
2308 /**
2309 * trim
2310 * Cuts off any whitespace at the beginning and the end of the content
2311 *
2312 * @param string Input value undergoing processing in this function.
2313 * @param array stdWrap properties for trim.
2314 * @return string The processed input value
2315 */
2316 public function stdWrap_trim($content = '', $conf = array()) {
2317 $content = trim($content);
2318 return $content;
2319 }
2320
2321 /**
2322 * stdWrap
2323 * A recursive call of the stdWrap function set
2324 * This enables the user to execute stdWrap functions in another than the predefined order
2325 * It modifies the content, not the property
2326 * while the new feature of chained stdWrap functions modifies the property and not the content
2327 *
2328 * @param string Input value undergoing processing in this function.
2329 * @param array stdWrap properties for stdWrap.
2330 * @return string The processed input value
2331 */
2332 public function stdWrap_stdWrap($content = '', $conf = array()) {
2333 $content = $this->stdWrap($content, $conf['stdWrap.']);
2334 return $content;
2335 }
2336
2337 /**
2338 * stdWrap process hook
2339 * can be used by extensions authors to modify the behaviour of stdWrap functions to their needs
2340 * this hook executes functions directly after the recursive stdWrap function call but still before the content gets modified
2341 *
2342 * @param string Input value undergoing processing in these functions.
2343 * @param array All stdWrap properties, not just the ones for a particular function.
2344 * @return string The processed input value
2345 */
2346 public function stdWrap_stdWrapProcess($content = '', $conf = array()) {
2347 foreach ($this->stdWrapHookObjects as $hookObject) {
2348 $content = $hookObject->stdWrapProcess($content, $conf, $this);
2349 }
2350 return $content;
2351 }
2352
2353 /**
2354 * required
2355 * Will immediately stop rendering and return an empty value
2356 * when there is no content at this point
2357 *
2358 * @param string Input value undergoing processing in this function.
2359 * @param array stdWrap properties for required.
2360 * @return string The processed input value
2361 */
2362 public function stdWrap_required($content = '', $conf = array()) {
2363 if ((string) $content == '') {
2364 $content = '';
2365 $this->stopRendering[$this->stdWrapRecursionLevel] = TRUE;
2366 }
2367 return $content;
2368 }
2369
2370 /**
2371 * if
2372 * Will immediately stop rendering and return an empty value
2373 * when the result of the checks returns false
2374 *
2375 * @param string Input value undergoing processing in this function.
2376 * @param array stdWrap properties for if.
2377 * @return string The processed input value
2378 */
2379 public function stdWrap_if($content = '', $conf = array()) {
2380 if (!$this->checkIf($conf['if.'])) {
2381 $content = '';
2382 $this->stopRendering[$this->stdWrapRecursionLevel] = TRUE;
2383 }
2384 return $content;
2385 }
2386
2387 /**
2388 * fieldRequired
2389 * Will immediately stop rendering and return an empty value
2390 * when there is no content in the field given by fieldRequired
2391 *
2392 * @param string Input value undergoing processing in this function.
2393 * @param array stdWrap properties for fieldRequired.
2394 * @return string The processed input value
2395 */
2396 public function stdWrap_fieldRequired($content = '', $conf = array()) {
2397 if (!trim($this->data[$conf['fieldRequired']])) {
2398 $content = '';
2399 $this->stopRendering[$this->stdWrapRecursionLevel] = TRUE;
2400 }
2401 return $content;
2402 }
2403
2404 /**
2405 * csConv
2406 * Will convert the current chracter set of the content to the one given in csConv
2407 *
2408 * @param string Input value undergoing processing in this function.
2409 * @param array stdWrap properties for csConv.
2410 * @return string The processed input value
2411 */
2412 public function stdWrap_csConv($content = '', $conf = array()) {
2413 $content = $GLOBALS['TSFE']->csConv($content, $conf['csConv']);
2414 return $content;
2415 }
2416
2417 /**
2418 * parseFunc
2419 * Will parse the content based on functions given as stdWrap properties
2420 * Heavily used together with RTE based content
2421 *
2422 * @param string Input value undergoing processing in this function.
2423 * @param array stdWrap properties for parseFunc.
2424 * @return string The processed input value
2425 */
2426 public function stdWrap_parseFunc($content = '', $conf = array()) {
2427 $content = $this->parseFunc($content, $conf['parseFunc.'], $conf['parseFunc']);
2428 return $content;
2429 }
2430
2431 /**
2432 * HTMLparser
2433 * Will parse HTML content based on functions given as stdWrap properties
2434 * Heavily used together with RTE based content
2435 *
2436 * @param string Input value undergoing processing in this function.
2437 * @param array stdWrap properties for HTMLparser.
2438 * @return string The processed input value
2439 */
2440 public function stdWrap_HTMLparser($content = '', $conf = array()) {
2441 if (is_array($conf['HTMLparser.'])) {
2442 $content = $this->HTMLparser_TSbridge($content, $conf['HTMLparser.']);
2443 }
2444 return $content;
2445 }
2446
2447 /**
2448 * split
2449 * Will split the content by a given token and treat the results separately
2450 * Automatically fills 'current' with a single result
2451 *
2452 * @param string Input value undergoing processing in this function.
2453 * @param array stdWrap properties for split.
2454 * @return string The processed input value
2455 */
2456 public function stdWrap_split($content = '', $conf = array()) {
2457 $content = $this->splitObj($content, $conf['split.']);
2458 return $content;
2459 }
2460
2461 /**
2462 * prioriCalc
2463 * Will use the content as a mathematical term and calculate the result
2464 * Can be set to 1 to just get a calculated value or 'intval' to get the integer of the result
2465 *
2466 * @param string Input value undergoing processing in this function.
2467 * @param array stdWrap properties for prioriCalc.
2468 * @return string The processed input value
2469 */
2470 public function stdWrap_prioriCalc($content = '', $conf = array()) {
2471 $content = t3lib_div::calcParenthesis($content);
2472 if ($conf['prioriCalc'] == 'intval')
2473 $content = intval($content);
2474 return $content;
2475 }
2476
2477 /**
2478 * char
2479 * Will return a character based on its position within the current character set
2480 *
2481 * @param string Input value undergoing processing in this function.
2482 * @param array stdWrap properties for char.
2483 * @return string The processed input value
2484 */
2485 public function stdWrap_char($content = '', $conf = array()) {
2486 $content = chr(intval($conf['char']));
2487 return $content;
2488 }
2489
2490 /**
2491 * intval
2492 * Will return an integer value of the current content
2493 *
2494 * @param string Input value undergoing processing in this function.
2495 * @param array stdWrap properties for intval.
2496 * @return string The processed input value
2497 */
2498 public function stdWrap_intval($content = '', $conf = array()) {
2499 $content = intval($content);
2500 return $content;
2501 }
2502
2503 /**
2504 * numberFormat
2505 * Will return a formatted number based on configuration given as stdWrap properties
2506 *
2507 * @param string Input value undergoing processing in this function.
2508 * @param array stdWrap properties for numberFormat.
2509 * @return string The processed input value
2510 */
2511 public function stdWrap_numberFormat($content = '', $conf = array()) {
2512 $content = $this->numberFormat($content, $conf['numberFormat.']);
2513 return $content;
2514 }
2515
2516 /**
2517 * date
2518 * Will return a formatted date based on configuration given according to PHP date/gmdate properties
2519 * Will return gmdate when the property GMT returns true
2520 *
2521 * @param string Input value undergoing processing in this function.
2522 * @param array stdWrap properties for date.
2523 * @return string The processed input value
2524 */
2525 public function stdWrap_date($content = '', $conf = array()) {
2526 $content = ($conf['date.']['GMT'] ? gmdate($conf['date'], $content) : date($conf['date'], $content));
2527 return $content;
2528 }
2529
2530 /**
2531 * strftime
2532 * Will return a formatted date based on configuration given according to PHP strftime/gmstrftime properties
2533 * Will return gmstrftime when the property GMT returns true
2534 *
2535 * @param string Input value undergoing processing in this function.
2536 * @param array stdWrap properties for strftime.
2537 * @return string The processed input value
2538 */
2539 public function stdWrap_strftime($content = '', $conf = array()) {
2540 $content = ($conf['strftime.']['GMT'] ? gmstrftime($conf['strftime'], $content) : strftime($conf['strftime'], $content));
2541 $tmp_charset = $conf['strftime.']['charset'] ? $conf['strftime.']['charset'] : $GLOBALS['TSFE']->localeCharset;
2542 if ($tmp_charset) {
2543 $content = $GLOBALS['TSFE']->csConv($content, $tmp_charset);
2544 }
2545 return $content;
2546 }
2547
2548 /**
2549 * age
2550 * Will return the age of a given timestamp based on configuration given by stdWrap properties
2551 *
2552 * @param string Input value undergoing processing in this function.
2553 * @param array stdWrap properties for age.
2554 * @return string The processed input value
2555 */
2556 public function stdWrap_age($content = '', $conf = array()) {
2557 $content = $this->calcAge($GLOBALS['EXEC_TIME'] - $content, $conf['age']);
2558 return $content;
2559 }
2560
2561 /**
2562 * case
2563 * Will transform the content to be upper or lower case only
2564 * Leaves HTML tags untouched
2565 *
2566 * @param string Input value undergoing processing in this function.
2567 * @param array stdWrap properties for case.
2568 * @return string The processed input value
2569 */
2570 public function stdWrap_case($content = '', $conf = array()) {
2571 $content = $this->HTMLcaseshift($content, $conf['case']);
2572 return $content;
2573 }
2574
2575 /**
2576 * bytes
2577 * Will return the size of a given number in Bytes *
2578 *
2579 * @param string Input value undergoing processing in this function.
2580 * @param array stdWrap properties for bytes.
2581 * @return string The processed input value
2582 */
2583 public function stdWrap_bytes($content = '', $conf = array()) {
2584 $content = t3lib_div::formatSize($content, $conf['bytes.']['labels']);
2585 return $content;
2586 }
2587
2588 /**
2589 * substring
2590 * Will return a substring based on position information given by stdWrap properties
2591 *
2592 * @param string Input value undergoing processing in this function.
2593 * @param array stdWrap properties for substring.
2594 * @return string The processed input value
2595 */
2596 public function stdWrap_substring($content = '', $conf = array()) {
2597 $content = $this->substring($content, $conf['substring']);
2598 return $content;
2599 }
2600
2601 /**
2602 * removeBadHTML
2603 * Removes HTML tags based on stdWrap properties
2604 *
2605 * @param string Input value undergoing processing in this function.
2606 * @param array stdWrap properties for removeBadHTML.
2607 * @return string The processed input value
2608 */
2609 public function stdWrap_removeBadHTML($content = '', $conf = array()) {
2610 $content = $this->removeBadHTML($content, $conf['removeBadHTML.']);
2611 return $content;
2612 }
2613
2614 /**
2615 * cropHTML
2616 * Crops content to a given size while leaving HTML tags untouched
2617 *
2618 * @param string Input value undergoing processing in this function.
2619 * @param array stdWrap properties for cropHTML.
2620 * @return string The processed input value
2621 */
2622 public function stdWrap_cropHTML($content = '', $conf = array()) {
2623 $content = $this->cropHTML($content, $conf['cropHTML']);
2624 return $content;
2625 }
2626
2627 /**
2628 * stripHtml
2629 * Copmletely removes HTML tags from content
2630 *
2631 * @param string Input value undergoing processing in this function.
2632 * @param array stdWrap properties for stripHtml.
2633 * @return string The processed input value
2634 */
2635 public function stdWrap_stripHtml($content = '', $conf = array()) {
2636 $content = strip_tags($content);
2637 return $content;
2638 }
2639
2640 /**
2641 * cropHTML
2642 * Crops content to a given size without caring abhout HTML tags
2643 *
2644 * @param string Input value undergoing processing in this function.
2645 * @param array stdWrap properties for crop.
2646 * @return string The processed input value
2647 */
2648 public function stdWrap_crop($content = '', $conf = array()) {
2649 $content = $this->crop($content, $conf['crop']);
2650 return $content;
2651 }
2652
2653 /**
2654 * rawUrlEncode
2655 * Encodes content to be used within URLs
2656 *
2657 * @param string Input value undergoing processing in this function.
2658 * @param array stdWrap properties for rawUrlEncode.
2659 * @return string The processed input value
2660 */
2661 public function stdWrap_rawUrlEncode($content = '', $conf = array()) {
2662 $content = rawurlencode($content);
2663 return $content;
2664 }
2665
2666 /**
2667 * htmlSpecialChars
2668 * Transforms HTML tags to readable text by replacing special characters with their HTML entity
2669 * When preserveEntities returns true, existing entities will be left untouched
2670 *
2671 * @param string Input value undergoing processing in this function.
2672 * @param array stdWrap properties for htmlSpecalChars.
2673 * @return string The processed input value
2674 */
2675 public function stdWrap_htmlSpecialChars($content = '', $conf = array()) {
2676 $content = htmlSpecialChars($content);
2677 if ($conf['htmlSpecialChars.']['preserveEntities'])
2678 $content = t3lib_div::deHSCentities($content);
2679 return $content;
2680 }
2681
2682 /**
2683 * doubleBrTag
2684 * Searches for double line breaks and replaces them with the given value
2685 *
2686 * @param string Input value undergoing processing in this function.
2687 * @param array stdWrap properties for doubleBrTag.
2688 * @return string The processed input value
2689 */
2690 public function stdWrap_doubleBrTag($content = '', $conf = array()) {
2691 $content = preg_replace("/\r?\n[\t ]*\r?\n/", $conf['doubleBrTag'], $content);
2692 return $content;
2693 }
2694
2695 /**
2696 * br
2697 * Searches for single line breaks and replaces them with a <br /> tag
2698 *
2699 * @param string Input value undergoing processing in this function.
2700 * @param array stdWrap properties for br.
2701 * @return string The processed input value
2702 */
2703 public function stdWrap_br($content = '', $conf = array()) {
2704 $content = nl2br($content);
2705 return $content;
2706 }
2707
2708 /**
2709 * brTag
2710 * Searches for single line feeds and replaces them with the given value
2711 *
2712 * @param string Input value undergoing processing in this function.
2713 * @param array stdWrap properties for brTag.
2714 * @return string The processed input value
2715 */
2716 public function stdWrap_brTag($content = '', $conf = array()) {
2717 $content = str_replace(LF, $conf['brTag'], $content);
2718 return $content;
2719 }
2720
2721 /**
2722 * encapsLines
2723 * Modifies text blocks by searching for lines which are not surrounded by HTML tags yet
2724 * and wrapping them with values given by stdWrap properties
2725 *
2726 * @param string Input value undergoing processing in this function.
2727 * @param array stdWrap properties for erncapsLines.
2728 * @return string The processed input value
2729 */
2730 public function stdWrap_encapsLines($content = '', $conf = array()) {
2731 $content = $this->encaps_lineSplit($content, $conf['encapsLines.']);
2732 return $content;
2733 }
2734
2735 /**
2736 * keywords
2737 * Transforms content into a CSV list to be used i.e. as keywords within a meta tag
2738 *
2739 * @param string Input value undergoing processing in this function.
2740 * @param array stdWrap properties for keywords.
2741 * @return string The processed input value
2742 */
2743 public function stdWrap_keywords($content = '', $conf = array()) {
2744 $content = $this->keywords($content);
2745 return $content;
2746 }
2747
2748 /**
2749 * innerWrap
2750 * First of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
2751 * See wrap
2752 *
2753 * @param string Input value undergoing processing in this function.
2754 * @param array stdWrap properties for innerWrap.
2755 * @return string The processed input value
2756 */
2757 public function stdWrap_innerWrap($content = '', $conf = array()) {
2758 $content = $this->wrap($content, $conf['innerWrap']);
2759 return $content;
2760 }
2761
2762 /**
2763 * innerWrap2
2764 * Second of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
2765 * See wrap
2766 *
2767 * @param string Input value undergoing processing in this function.
2768 * @param array stdWrap properties for innerWrap2.
2769 * @return string The processed input value
2770 */
2771 public function stdWrap_innerWrap2($content = '', $conf = array()) {
2772 $content = $this->wrap($content, $conf['innerWrap2']);
2773 return $content;
2774 }
2775
2776 /**
2777 * fontTag
2778 * A wrap formerly used to apply font tags to format the content
2779 * Still used by lib.stdheader although real font tags are not state of the art anymore
2780 * See wrap
2781 *
2782 * @param string Input value undergoing processing in this function.
2783 * @param array stdWrap properties for fontTag.
2784 * @return string The processed input value
2785 */
2786 public function stdWrap_fontTag($content = '', $conf = array()) {
2787 $content = $this->wrap($content, $conf['fontTag']);
2788 return $content;
2789 }
2790
2791 /**
2792 * addParams
2793 * Adds tag attributes to any content that is a tag
2794 *
2795 * @param string Input value undergoing processing in this function.
2796 * @param array stdWrap properties for addParams.
2797 * @return string The processed input value
2798 */
2799 public function stdWrap_addParams($content = '', $conf = array()) {
2800 $content = $this->addParams($content, $conf['addParams.']);
2801 return $content;
2802 }
2803
2804 /**
2805 * textStyle
2806 * Wraps content in font tags
2807 * See wrap
2808 *
2809 * @param string Input value undergoing processing in this function.
2810 * @param array stdWrap properties for textStyle.
2811 * @return string The processed input value
2812 */
2813 public function stdWrap_textStyle($content = '', $conf = array()) {
2814 $content = $this->textStyle($content, $conf['textStyle.']);
2815 return $content;
2816 }
2817
2818 /**
2819 * tableStyle
2820 * Wraps content with table tags
2821 * See wrap
2822 *
2823 * @param string Input value undergoing processing in this function.
2824 * @param array stdWrap properties for tableStyle.
2825 * @return string The processed input value
2826 */
2827 public function stdWrap_tableStyle($content = '', $conf = array()) {
2828 $content = $this->tableStyle($content, $conf['tableStyle.']);
2829 return $content;
2830 }
2831
2832 /**
2833 * filelink
2834 * Used to make lists of links to files
2835 * See wrap
2836 *
2837 * @param string Input value undergoing processing in this function.
2838 * @param array stdWrap properties for filelink.
2839 * @return string The processed input value
2840 */
2841 public function stdWrap_filelink($content = '', $conf = array()) {
2842 $content = $this->filelink($content, $conf['filelink.']);
2843 return $content;
2844 }
2845
2846 /**
2847 * preCObject
2848 * A content object that is prepended to the current content but between the innerWraps and the rest of the wraps
2849 *
2850 * @param string Input value undergoing processing in this function.
2851 * @param array stdWrap properties for preCObject.
2852 * @return string The processed input value
2853 */
2854 public function stdWrap_preCObject($content = '', $conf = array()) {
2855 $content = $this->cObjGetSingle($conf['preCObject'], $conf['preCObject.'], '/stdWrap/.preCObject') . $content;
2856 return $content;
2857 }
2858
2859 /**
2860 * postCObject
2861 * A content object that is appended to the current content but between the innerWraps and the rest of the wraps
2862 *
2863 * @param string Input value undergoing processing in this function.
2864 * @param array stdWrap properties for postCObject.
2865 * @return string The processed input value
2866 */
2867 public function stdWrap_postCObject($content = '', $conf = array()) {
2868 $content .= $this->cObjGetSingle($conf['postCObject'], $conf['postCObject.'], '/stdWrap/.postCObject');
2869 return $content;
2870 }
2871
2872 /**
2873 * wrapAlign
2874 * Wraps content with a div container having the style attribute text-align set to the given value
2875 * See wrap
2876 *
2877 * @param string Input value undergoing processing in this function.
2878 * @param array stdWrap properties for wrapAlign.
2879 * @return string The processed input value
2880 */
2881 public function stdWrap_wrapAlign($content = '', $conf = array()) {
2882 $wrapAlign = trim($conf['wrapAlign']);
2883 if ($wrapAlign) {
2884 $content = $this->wrap($content, '<div style="text-align:' . $wrapAlign . ';">|</div>');
2885 }
2886 return $content;
2887 }
2888
2889 /**
2890 * typolink
2891 * Wraps the content with a link tag
2892 * URLs and other attributes are created automatically by the values given in the stdWrap properties
2893 * See wrap
2894 *
2895 * @param string Input value undergoing processing in this function.
2896 * @param array stdWrap properties for typolink.
2897 * @return string The processed input value
2898 */
2899 public function stdWrap_typolink($content = '', $conf = array()) {
2900 $content = $this->typolink($content, $conf['typolink.']);
2901 return $content;
2902 }
2903
2904 /**
2905 * TCAselectItem
2906 * Returns a list of options available for a given field in the DB which has to be of the type select
2907 *
2908 * @param string Input value undergoing processing in this function.
2909 * @param array stdWrap properties for TCAselectItem.
2910 * @return string The processed input value
2911 */
2912 public function stdWrap_TCAselectItem($content = '', $conf = array()) {
2913 if (is_array($conf['TCAselectItem.'])) {
2914 $content = $this->TCAlookup($content, $conf['TCAselectItem.']);
2915 }
2916 return $content;
2917 }
2918
2919 /**
2920 * spaceBefore
2921 * Will add space before the current content
2922 * 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
2923 *
2924 * @param string Input value undergoing processing in this function.
2925 * @param array stdWrap properties for spaceBefore and space.
2926 * @return string The processed input value
2927 */
2928 public function stdWrap_spaceBefore($content = '', $conf = array()) {
2929 $content = $this->wrapSpace($content, trim($conf['spaceBefore']) . '|', $conf['space.']);
2930 return $content;
2931 }
2932
2933 /**
2934 * spaceAfter
2935 * Will add space after the current content
2936 * 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
2937 *
2938 * @param string Input value undergoing processing in this function.
2939 * @param array stdWrap properties for spaceAfter and space.
2940 * @return string The processed input value
2941 */
2942 public function stdWrap_spaceAfter($content = '', $conf = array()) {
2943 $content = $this->wrapSpace($content, '|' . trim($conf['spaceAfter']), $conf['space.']);
2944 return $content;
2945 }
2946
2947 /**
2948 * space
2949 * Will add space before or after the current content
2950 * 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
2951 * See wrap
2952 *
2953 * @param string Input value undergoing processing in this function.
2954 * @param array stdWrap properties for space.
2955 * @return string The processed input value
2956 */
2957 public function stdWrap_space($content = '', $conf = array()) {
2958 $content = $this->wrapSpace($content, trim($conf['space']), $conf['space.']);
2959 return $content;
2960 }
2961
2962 /**
2963 * wrap
2964 * This is the "mother" of all wraps
2965 * Third of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
2966 * Basically it will put additional content before and after the current content using a split character as a placeholder for the current content
2967 * The default split character is | but it can be replaced with other characters by the property splitChar
2968 * Any other wrap that does not have own splitChar settings will be using the default split char though
2969 *
2970 * @param string Input value undergoing processing in this function.
2971 * @param array stdWrap properties for wrap.
2972 * @return string The processed input value
2973 */
2974 public function stdWrap_wrap($content = '', $conf = array()) {
2975 $content = $this->wrap($content, $conf['wrap'], ($conf['wrap.']['splitChar'] ? $conf['wrap.']['splitChar'] : '|'));
2976 return $content;
2977 }
2978
2979 /**
2980 * noTrimWrap
2981 * Fourth of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
2982 * The major difference to any other wrap is, that this one can make use of whitespace without trimming *
2983 *
2984 * @param string Input value undergoing processing in this function.
2985 * @param array stdWrap properties for noTrimWrap.
2986 * @return string The processed input value
2987 */
2988 public function stdWrap_noTrimWrap($content = '', $conf = array()) {
2989 $content = $this->noTrimWrap($content, $conf['noTrimWrap']);
2990 return $content;
2991 }
2992
2993 /**
2994 * wrap2
2995 * Fifth of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
2996 * The default split character is | but it can be replaced with other characters by the property splitChar
2997 *
2998 * @param string Input value undergoing processing in this function.
2999 * @param array stdWrap properties for wrap2.
3000 * @return string The processed input value
3001 */
3002 public function stdWrap_wrap2($content = '', $conf = array()) {
3003 $content = $this->wrap($content, $conf['wrap2'], ($conf['wrap2.']['splitChar'] ? $conf['wrap2.']['splitChar'] : '|'));
3004 return $content;
3005 }
3006
3007 /**
3008 * dataWrap
3009 * Sixth of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
3010 * 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
3011 *
3012 * @param string Input value undergoing processing in this function.
3013 * @param array stdWrap properties for dataWrap.
3014 * @return string The processed input value
3015 */
3016 public function stdWrap_dataWrap($content = '', $conf = array()) {
3017 $content = $this->dataWrap($content, $conf['dataWrap']);
3018 return $content;
3019 }
3020
3021 /**
3022 * prepend
3023 * A content object that will be prepended to the current content after most of the wraps have already been applied
3024 *
3025 * @param string Input value undergoing processing in this function.
3026 * @param array stdWrap properties for prepend.
3027 * @return string The processed input value
3028 */
3029 public function stdWrap_prepend($content = '', $conf = array()) {
3030 $content = $this->cObjGetSingle($conf['prepend'], $conf['prepend.'], '/stdWrap/.prepend') . $content;
3031 return $content;
3032 }
3033
3034 /**
3035 * append
3036 * A content object that will be appended to the current content after most of the wraps have already been applied
3037 *
3038 * @param string Input value undergoing processing in this function.
3039 * @param array stdWrap properties for append.
3040 * @return string The processed input value
3041 */
3042 public function stdWrap_append($content = '', $conf = array()) {
3043 $content .= $this->cObjGetSingle($conf['append'], $conf['append.'], '/stdWrap/.append');
3044 return $content;
3045 }
3046
3047 /**
3048 * wrap3
3049 * Seventh of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
3050 * The default split character is | but it can be replaced with other characters by the property splitChar
3051 *
3052 * @param string Input value undergoing processing in this function.
3053 * @param array stdWrap properties for wrap3.
3054 * @return string The processed input value
3055 */
3056 public function stdWrap_wrap3($content = '', $conf = array()) {
3057 $content = $this->wrap($content, $conf['wrap3'], ($conf['wrap3.']['splitChar'] ? $conf['wrap3.']['splitChar'] : '|'));
3058 return $content;
3059 }
3060
3061 /**
3062 * outerWrap
3063 * Eighth of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
3064 *
3065 * @param string Input value undergoing processing in this function.
3066 * @param array stdWrap properties for outerWrap.
3067 * @return string The processed input value
3068 */
3069 public function stdWrap_outerWrap($content = '', $conf = array()) {
3070 $content = $this->wrap($content, $conf['outerWrap']);
3071 return $content;
3072 }
3073
3074 /**
3075 * inserData
3076 * Can fetch additional content the same way data does and replaces any occurence of {field:whatever} with this content
3077 *
3078 * @param string Input value undergoing processing in this function.
3079 * @param array stdWrap properties for insertData.
3080 * @return string The processed input value
3081 */
3082 public function stdWrap_insertData($content = '', $conf = array()) {
3083 $content = $this->insertData($content);
3084 return $content;
3085 }
3086
3087 /**
3088 * offsetWrap
3089 * Creates a so called offset table around the content
3090 * Still here for historical reasons even not used too much nowadays
3091 *
3092 * @param string Input value undergoing processing in this function.
3093 * @param array stdWrap properties for offsetWrap.
3094 * @return string The processed input value
3095 */
3096 public function stdWrap_offsetWrap($content = '', $conf = array()) {
3097 $controlTable = t3lib_div::makeInstance('tslib_tableOffset');
3098 if ($conf['offsetWrap.']['tableParams'] || $conf['offsetWrap.']['tableParams.']) {
3099 $controlTable->tableParams = isset($conf['offsetWrap.']['tableParams.'])
3100 ? $this->stdWrap($conf['offsetWrap.']['tableParams'], $conf['offsetWrap.']['tableParams.'])
3101 : $conf['offsetWrap.']['tableParams'];
3102 }
3103 if ($conf['offsetWrap.']['tdParams'] || $conf['offsetWrap.']['tdParams.']) {
3104 $controlTable->tdParams = ' ' . isset($conf['offsetWrap.']['tdParams.'])
3105 ? $this->stdWrap($conf['offsetWrap.']['tdParams'], $conf['offsetWrap.']['tdParams.'])
3106 : $conf['offsetWrap.']['tdParams'];
3107 }
3108 $content = $controlTable->start($content, $conf['offsetWrap']);
3109 if ($conf['offsetWrap.']['stdWrap.']) {
3110 $content = $this->stdWrap($content, $conf['offsetWrap.']['stdWrap.']);
3111 }
3112 return $content;
3113 }
3114
3115 /**
3116 * postUserFunc
3117 * Will execute a user function after the content has been modified by any other stdWrap function
3118 *
3119 * @param string Input value undergoing processing in this function.
3120 * @param array stdWrap properties for postUserFunc.
3121 * @return string The processed input value
3122 */
3123 public function stdWrap_postUserFunc($content = '', $conf = array()) {
3124 $content = $this->callUserFunction($conf['postUserFunc'], $conf['postUserFunc.'], $content);
3125 return $content;
3126 }
3127
3128 /**
3129 * postUserFuncInt
3130 * Will execute a user function after the content has been created and each time it is fetched from Cache
3131 * The result of this function itself will not be cached
3132 *
3133 * @param string Input value undergoing processing in this function.
3134 * @param array stdWrap properties for postUserFuncInt.
3135 * @return string The processed input value
3136 */
3137 public function stdWrap_postUserFuncInt($content = '', $conf = array()) {
3138 $substKey = 'INT_SCRIPT.' . $GLOBALS['TSFE']->uniqueHash();
3139 $GLOBALS['TSFE']->config['INTincScript'][$substKey] = array(
3140 'content' => $content, 'postUserFunc' => $conf['postUserFuncInt'], 'conf' => $conf['postUserFuncInt.'], 'type' => 'POSTUSERFUNC', 'cObj' => serialize($this)
3141 );
3142 $content = '<!--' . $substKey . '-->';
3143 return $content;
3144 }
3145
3146 /**
3147 * prefixComment
3148 * Will add HTML comments to the content to make it easier to identify certain content elements within the HTML output later on
3149 *
3150 * @param string Input value undergoing processing in this function.
3151 * @param array stdWrap properties for prefixComment.
3152 * @return string The processed input value
3153 */
3154 public function stdWrap_prefixComment($content = '', $conf = array()) {
3155 if (!$GLOBALS['TSFE']->config['config']['disablePrefixComment']) {
3156 $content = $this->prefixComment($conf['prefixComment'], $conf['prefixComment.'], $content);
3157 }
3158 return $content;
3159 }
3160
3161 /**
3162 * editIcons
3163 * Will render icons for frontend editing as long as there is a BE user logged in
3164 *
3165 * @param string Input value undergoing processing in this function.
3166 * @param array stdWrap properties for editIcons.