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