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