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