2 /***************************************************************
5 * (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
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.
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.
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.
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
28 * Contains classes for Content Rendering based on TypoScript Template configuration
31 * Revised for TYPO3 3.6 June/2003 by Kasper Skårhøj
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)
39 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
42 * [CLASS/FUNCTION INDEX of SCRIPT]
46 * 256: class tslib_cObj
47 * 353: function start($data,$table='')
48 * 387: function setParent($data,$currentRecord)
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='__')
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)
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)
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)
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)
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)
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)
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)
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)
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)
199 * 7351: class tslib_frameset
200 * 7361: function make($setup)
201 * 7398: function frameParams($setup, $typeNum)
202 * 7426: function framesetParams($setup)
205 * 7459: class tslib_tableOffset
206 * 7471: function start($content,$offset)
209 * 7549: class tslib_controlTable
210 * 7584: function start($offset,$cMargins)
212 * TOTAL FUNCTIONS: 135
213 * (This index is automatically created/updated by the extension "extdeveval")
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.
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.
228 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
241 * stdWrap functions in their correct order
245 var $stdWrapOrder = array(
246 'stdWrapPreProcess' => 'hook', // this is a placeholder for the first Hook
247 'setContentToCurrent' => 'boolean',
248 'setContentToCurrent.' => 'array',
249 'setCurrent' => 'string',
250 'setCurrent.' => 'array',
254 'field' => 'fieldName',
256 'current' => 'boolean',
257 'current.' => 'array',
258 'cObject' => 'cObject',
259 'cObject.' => 'array',
260 'numRows.' => 'array',
262 'filelist.' => 'array',
263 'preUserFunc' => 'functionName',
264 'stdWrapOverride' => 'hook', // this is a placeholder for the second Hook
265 'override' => 'string',
266 'override.' => 'array',
267 'preIfEmptyListNum' => 'listNum',
268 'preIfEmptyListNum.' => 'array',
269 'ifEmpty' => 'string',
270 'ifEmpty.' => 'array',
271 'ifBlank' => 'string',
272 'ifBlank.' => 'array',
273 'listNum' => 'listNum',
274 'listNum.' => 'array',
277 'stdWrap' => 'stdWrap',
278 'stdWrap.' => 'array',
279 'stdWrapProcess' => 'hook', // this is a placeholder for the third Hook
280 'required' => 'boolean',
281 'required.' => 'array',
283 'fieldRequired' => 'fieldName',
284 'fieldRequired.' => 'array',
285 'csConv' => 'string',
286 'csConv.' => 'array',
287 'parseFunc' => 'objectpath',
288 'parseFunc.' => 'array',
289 'HTMLparser' => 'boolean',
290 'HTMLparser.' => 'array',
292 'prioriCalc' => 'boolean',
293 'prioriCalc.' => 'array',
296 'intval' => 'boolean',
297 'intval.' => 'array',
298 'numberFormat.' => 'array',
299 'date' => 'dateconf',
301 'strftime' => 'strftimeconf',
302 'strftime.' => 'array',
307 'bytes' => 'boolean',
309 'substring' => 'parameters',
310 'substring.' => 'array',
311 'removeBadHTML' => 'boolean',
312 'removeBadHTML.' => 'array',
313 'cropHTML' => 'crop',
314 'cropHTML.' => 'array',
315 'stripHtml' => 'boolean',
316 'stripHtml.' => 'array',
319 'rawUrlEncode' => 'boolean',
320 'rawUrlEncode.' => 'array',
321 'htmlSpecialChars' => 'boolean',
322 'htmlSpecialChars.' => 'array',
323 'doubleBrTag' => 'string',
324 'doubleBrTag.' => 'array',
329 'encapsLines.' => 'array',
330 'keywords' => 'boolean',
331 'keywords.' => 'array',
332 'innerWrap' => 'wrap',
333 'innerWrap.' => 'array',
334 'innerWrap2' => 'wrap',
335 'innerWrap2.' => 'array',
337 'fontTag.' => 'array',
338 'addParams.' => 'array',
339 'textStyle.' => 'array',
340 'tableStyle.' => 'array',
341 'filelink.' => 'array',
342 'preCObject' => 'cObject',
343 'preCObject.' => 'array',
344 'postCObject' => 'cObject',
345 'postCObject.' => 'array',
346 'wrapAlign' => 'align',
347 'wrapAlign.' => 'array',
348 'typolink.' => 'array',
349 'TCAselectItem.' => 'array',
352 'spaceBefore' => 'int',
353 'spaceBefore.' => 'array',
354 'spaceAfter' => 'int',
355 'spaceAfter.' => 'array',
358 'noTrimWrap' => 'wrap',
359 'noTrimWrap.' => 'array',
362 'dataWrap' => 'dataWrap',
363 'dataWrap.' => 'array',
364 'prepend' => 'cObject',
365 'prepend.' => 'array',
366 'append' => 'cObject',
367 'append.' => 'array',
370 'outerWrap' => 'wrap',
371 'outerWrap.' => 'array',
372 'insertData' => 'boolean',
373 'insertData.' => 'array',
374 'offsetWrap' => 'space',
375 'offsetWrap.' => 'array',
376 'postUserFunc' => 'functionName',
377 'postUserFuncInt' => 'functionName',
378 'prefixComment' => 'string',
379 'prefixComment.' => 'array',
380 'editIcons' => 'string',
381 'editIcons.' => 'array',
382 'editPanel' => 'boolean',
383 'editPanel.' => 'array',
384 'stdWrapPostProcess' => 'hook', // this is a placeholder for the last Hook
385 'debug' => 'boolean',
387 'debugFunc' => 'boolean',
388 'debugFunc.' => 'array',
389 'debugData' => 'boolean',
390 'debugData.' => 'array'
394 * Holds ImageMagick parameters and extensions used for compression
399 * 1= Dont change! (removes all parameters for the image_object!!)
403 var $image_compression = array(
405 'params' => '', 'ext' => 'gif'
408 'params' => '-colors 128', 'ext' => 'gif'
411 'params' => '-colors 64', 'ext' => 'gif'
414 'params' => '-colors 32', 'ext' => 'gif'
417 'params' => '-colors 16', 'ext' => 'gif'
420 'params' => '-colors 8', 'ext' => 'gif'
424 'params' => '-quality 100', 'ext' => 'jpg'
427 'params' => '-quality 90', 'ext' => 'jpg'
430 'params' => '-quality 80', 'ext' => 'jpg'
433 'params' => '-quality 70', 'ext' => 'jpg'
436 'params' => '-quality 60', 'ext' => 'jpg'
439 'params' => '-quality 50', 'ext' => 'jpg'
442 'params' => '-quality 40', 'ext' => 'jpg'
445 'params' => '-quality 30', 'ext' => 'jpg'
448 'params' => '-quality 20', 'ext' => 'jpg'
452 'params' => '-colors 256', 'ext' => 'png'
455 'params' => '-colors 128', 'ext' => 'png'
458 'params' => '-colors 64', 'ext' => 'png'
461 'params' => '-colors 32', 'ext' => 'png'
464 'params' => '-colors 16', 'ext' => 'png'
467 'params' => '-colors 8', 'ext' => 'png'
470 'params' => '', 'ext' => 'png'
475 * ImageMagick parameters for image effects
479 var $image_effects = array(
483 10 => '-colorspace GRAY',
492 * Loaded with the current data-record.
494 * If the instance of this class is used to render records from the database those records are found in this array.
495 * The function stdWrap has TypoScript properties that fetch field-data from this array.
499 protected $table = '';
500 var $oldData = array(); // Used for backup...
501 var $alternativeData = ''; // If this is set with an array before stdWrap, it's used instead of $this->data in the data-property in stdWrap
502 var $parameters = array(); // Used by the parseFunc function and is loaded with tag-parameters when parsing tags.
503 var $currentValKey = 'currentValue_kidjls9dksoje';
504 var $currentRecord = ''; // This is set to the [table]:[uid] of the record delivered in the $data-array, if the cObjects CONTENT or RECORD is in operation. Note that $GLOBALS['TSFE']->currentRecord is set to an equal value but always indicating the latest record rendered.
505 var $currentRecordTotal = 0; // Set in cObj->RECORDS and cObj->CONTENT to the current number of records selected in a query.
506 var $currentRecordNumber = 0; // Incremented in cObj->RECORDS and cObj->CONTENT before each record rendering.
507 var $parentRecordNumber = 0; // Incremented in parent cObj->RECORDS and cObj->CONTENT before each record rendering.
508 var $parentRecord = array(); // If the tslib_cObj was started from CONTENT, RECORD or SEARCHRESULT cObject's this array has two keys, 'data' and 'currentRecord' which indicates the record and data for the parent cObj.
509 var $regObj; // This may be set as a reference to the calling object of eg. cObjGetSingle. Anyway, just use it as you like. It's used in productsLib.inc for example.
513 var $INT_include = 0; // Is set to 1 if the instance of this cObj is executed from a PHP_SCRIPT_INT -include script (see pagegen, bottom of document)
514 var $checkPid_cache = array(); // This is used by checkPid, that checks if pages are accessible. The $checkPid_cache['page_uid'] is set TRUE or FALSE upon this check featuring a caching function for the next request.
515 var $checkPid_badDoktypeList = '255';
516 var $lastTypoLinkUrl = ''; // This will be set by typoLink() to the url of the most recent link created.
517 var $lastTypoLinkTarget = ''; // DO. link target.
518 var $lastTypoLinkLD = array();
519 var $substMarkerCache = array(); // Caching substituteMarkerArrayCached function
520 var $recordRegister = array(); // array that registers rendered content elements (or any table) to make sure they are not rendered recursively!
521 var $cObjHookObjectsArr = array(); // Containig hooks for userdefined cObjects
522 protected $stdWrapHookObjects = array(); // Containing hook objects for stdWrap
523 protected $getImgResourceHookObjects; // Containing hook objects for getImgResource
526 * @var array with members of tslib_content_abstract
528 protected $contentObjects = array();
531 * Set to TRUE by doConvertToUserIntObject() if USER object wants to become USER_INT
533 public $doConvertToUserIntObject = FALSE;
536 * Indicates current object type. Can hold one of OBJECTTYPE_ constants or FALSE.
537 * The value is set and reset inside USER() function. Any time outside of
538 * USER() it is FALSE.
540 protected $userObjectType = FALSE;
543 * Indicates that object type is USER.
545 * @see tslib_cObjh::$userObjectType
547 const OBJECTTYPE_USER_INT
= 1;
550 * Indicates that object type is USER.
552 * @see tslib_cObjh::$userObjectType
554 const OBJECTTYPE_USER
= 2;
558 * Well, it has to be called manually since it is not a real constructor function.
559 * So after making an instance of the class, call this function and pass to it a database record and the tablename from where the record is from. That will then become the "current" record loaded into memory and accessed by the .fields property found in eg. stdWrap.
561 * @param array $data the record data that is rendered.
562 * @param string $table the table that the data record is from.
565 function start($data, $table = '') {
566 global $TYPO3_CONF_VARS;
568 $this->table
= $table;
569 $this->currentRecord
= $table ?
$table . ':' . $this->data
['uid'] : '';
570 $this->parameters
= array();
571 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClass'])) {
572 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClass'] as $classArr) {
573 $this->cObjHookObjectsArr
[$classArr[0]] = t3lib_div
::getUserObj($classArr[1]);
577 $this->stdWrapHookObjects
= array();
578 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['stdWrap'])) {
579 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['stdWrap'] as $classData) {
580 $hookObject = t3lib_div
::getUserObj($classData);
582 if (!($hookObject instanceof tslib_content_stdWrapHook
)) {
583 throw new UnexpectedValueException(
584 $classData . ' must implement interface tslib_content_stdWrapHook',
589 $this->stdWrapHookObjects
[] = $hookObject;
593 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['postInit'])) {
594 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['postInit'] as $classData) {
595 $postInitializationProcessor = t3lib_div
::getUserObj($classData);
597 if (!($postInitializationProcessor instanceof tslib_content_PostInitHook
)) {
598 throw new UnexpectedValueException(
599 $classData . ' must implement interface tslib_content_PostInitHook',
604 $postInitializationProcessor->postProcessContentObjectInitialization($this);
612 * Resets the references to the TypoScript Content Object implementation
613 * objects of tslib_content_*. Otherwise they would still point to the
614 * original tslib_cObj instance's tslib_content_* instances, they in return
615 * would back-reference to the original tslib_cObj instance instead of the
616 * newly cloned tslib_cObj instance.
618 * @see http://bugs.typo3.org/view.php?id=16568
620 public function __clone() {
621 $this->contentObjects
= array();
625 * Gets the 'getImgResource' hook objects.
626 * The first call initializes the accordant objects.
628 * @return array The 'getImgResource' hook objects (if any)
630 protected function getGetImgResourceHookObjects() {
631 if (!isset($this->getImgResourceHookObjects
)) {
632 $this->getImgResourceHookObjects
= array();
634 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['getImgResource'])) {
635 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['getImgResource'] as $classData) {
636 $hookObject = t3lib_div
::getUserObj($classData);
638 if (!($hookObject instanceof tslib_cObj_getImgResourceHook
)) {
639 throw new UnexpectedValueException(
640 '$hookObject must implement interface tslib_cObj_getImgResourceHook',
645 $this->getImgResourceHookObjects
[] = $hookObject;
650 return $this->getImgResourceHookObjects
;
654 * Sets the internal variable parentRecord with information about current record.
655 * If the tslib_cObj was started from CONTENT, RECORD or SEARCHRESULT cObject's this array has two keys, 'data' and 'currentRecord' which indicates the record and data for the parent cObj.
657 * @param array $data: The record array
658 * @param string $currentRecord: This is set to the [table]:[uid] of the record delivered in the $data-array, if the cObjects CONTENT or RECORD is in operation. Note that $GLOBALS['TSFE']->currentRecord is set to an equal value but always indicating the latest record rendered.
662 function setParent($data, $currentRecord) {
663 $this->parentRecord
= array(
665 'currentRecord' => $currentRecord
671 /***********************************************
675 ***********************************************/
678 * Returns the "current" value.
679 * The "current" value is just an internal variable that can be used by functions to pass a single value on to another function later in the TypoScript processing.
680 * It's like "load accumulator" in the good old C64 days... basically a "register" you can use as you like.
681 * The TSref will tell if functions are setting this value before calling some other object so that you know if it holds any special information.
683 * @return mixed The "current" value
685 function getCurrentVal() {
686 return $this->data
[$this->currentValKey
];
690 * Sets the "current" value.
692 * @param mixed The variable that you want to set as "current"
694 * @see getCurrentVal()
696 function setCurrentVal($value) {
697 $this->data
[$this->currentValKey
] = $value;
701 * Rendering of a "numerical array" of cObjects from TypoScript
702 * Will call ->cObjGetSingle() for each cObject found and accumulate the output.
704 * @param array $setup: array with cObjects as values.
705 * @param string $addKey: A prefix for the debugging information
706 * @return string Rendered output from the cObjects in the array.
707 * @see cObjGetSingle()
709 function cObjGet($setup, $addKey = '') {
710 if (is_array($setup)) {
711 $sKeyArray = t3lib_TStemplate
::sortedKeyList($setup);
713 foreach ($sKeyArray as $theKey) {
714 $theValue = $setup[$theKey];
715 if (intval($theKey) && !strstr($theKey, '.')) {
716 $conf = $setup[$theKey . '.'];
717 $content .= $this->cObjGetSingle($theValue, $conf, $addKey . $theKey); // Get the contentObject
725 * Renders a content object
727 * @param string The content object name, eg. "TEXT" or "USER" or "IMAGE"
728 * @param array The array with TypoScript properties for the content object
729 * @param string A string label used for the internal debugging tracking.
730 * @return string cObject output
732 function cObjGetSingle($name, $conf, $TSkey = '__') {
733 global $TYPO3_CONF_VARS;
736 // Checking that the function is not called eternally. This is done by interrupting at a depth of 100
737 $GLOBALS['TSFE']->cObjectDepthCounter
--;
738 if ($GLOBALS['TSFE']->cObjectDepthCounter
> 0) {
740 if ($GLOBALS['TT']->LR
)
741 $GLOBALS['TT']->push($TSkey, $name);
743 // Checking if the COBJ is a reference to another object. (eg. name of 'blabla.blabla = < styles.something')
744 if (substr($name, 0, 1) == '<') {
745 $key = trim(substr($name, 1));
746 $cF = t3lib_div
::makeInstance('t3lib_TSparser');
747 // $name and $conf is loaded with the referenced values.
749 list ($name, $conf) = $cF->getVal($key, $GLOBALS['TSFE']->tmpl
->setup
);
750 if (is_array($old_conf) && count($old_conf)) {
751 $conf = $this->joinTSarrays($conf, $old_conf);
753 // Getting the cObject
754 $GLOBALS['TT']->incStackPointer();
755 $content .= $this->cObjGetSingle($name, $conf, $key);
756 $GLOBALS['TT']->decStackPointer();
760 // Application defined cObjects
761 foreach ($this->cObjHookObjectsArr
as $cObjName => $hookObj) {
762 if (($name === $cObjName) && method_exists($hookObj, 'cObjGetSingleExt')) {
763 $content .= $hookObj->cObjGetSingleExt($name, $conf, $TSkey, $this);
768 $contentObject = $this->getContentObject($name);
769 if ($contentObject) {
770 $content .= $contentObject->render($conf);
772 // call hook functions for extra processing
773 if ($name && is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClassDefault'])) {
774 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClassDefault'] as $classData) {
775 $hookObject = t3lib_div
::getUserObj($classData);
777 if (!($hookObject instanceof tslib_content_cObjGetSingleHook
)) {
778 throw new UnexpectedValueException(
779 '$hookObject must implement interface tslib_content_cObjGetSingleHook',
783 /* @var $hookObject tslib_content_cObjGetSingleHook */
784 $content .= $hookObject->getSingleContentObject($name, (array) $conf, $TSkey, $this);
787 // log error in AdminPanel
788 $warning = sprintf('Content Object "%s" does not exist', $name);
789 $GLOBALS['TT']->setTSlogMessage($warning, 2);
794 if ($GLOBALS['TT']->LR
)
795 $GLOBALS['TT']->pull($content);
797 // Increasing on exit...
798 $GLOBALS['TSFE']->cObjectDepthCounter++
;
803 * Returns a new content object of type $name.
805 * @param string $name
806 * @return tslib_content_abstract
808 public function getContentObject($name) {
809 $classMapping = array(
813 'CLEARGIF' => 'ClearGif',
814 'COBJ_ARRAY' => 'ContentObjectArray',
815 'COA' => 'ContentObjectArray',
816 'COA_INT' => 'ContentObjectArrayInternal',
818 'USER_INT' => 'UserInternal',
821 'IMG_RESOURCE' => 'ImageResource',
822 'IMGTEXT' => 'ImageText',
823 'CONTENT' => 'Content',
824 'RECORDS' => 'Records',
825 'HMENU' => 'HierarchicalMenu',
826 'CTABLE' => 'ContentTable',
827 'OTABLE' => 'OffsetTable',
828 'COLUMNS' => 'Columns',
829 'HRULER' => 'HorizontalRuler',
830 'CASEFUNC' => 'Case',
831 'LOAD_REGISTER' => 'LoadRegister',
832 'RESTORE_REGISTER' => 'RestoreRegister',
834 'SEARCHRESULT' => 'SearchResult',
835 'PHP_SCRIPT' => 'PhpScript',
836 'PHP_SCRIPT_INT' => 'PhpScriptInternal',
837 'PHP_SCRIPT_EXT' => 'PhpScriptExternal',
838 'TEMPLATE' => 'Template',
839 'FLUIDTEMPLATE' => 'FluidTemplate',
840 'MULTIMEDIA' => 'Multimedia',
842 'SWFOBJECT' => 'ShockwaveFlashObject',
843 'QTOBJECT' => 'QuicktimeObject',
844 'SVG' => 'ScalableVectorGraphics',
845 'EDITPANEL' => 'EditPanel',
847 $name = $classMapping[$name];
849 if (!array_key_exists($name, $this->contentObjects
)) {
851 $this->contentObjects
[$name] = t3lib_div
::makeInstance('tslib_content_' . $name, $this);
852 } catch (ReflectionException
$e) {
853 $this->contentObjects
[$name] = NULL;
856 return $this->contentObjects
[$name];
860 /********************************************
862 * Functions rendering content objects (cObjects)
864 ********************************************/
867 * Rendering the cObject, HTML
869 * @param array array of TypoScript properties
870 * @return string Output
872 function HTML($conf) {
873 return $this->getContentObject('HTML')->render($conf);
877 * Rendering the cObject, TEXT
879 * @param array array of TypoScript properties
880 * @return string Output
882 function TEXT($conf) {
883 return $this->getContentObject('TEXT')->render($conf);
887 * Rendering the cObject, CLEARGIF
889 * @param array array of TypoScript properties
890 * @return string Output
892 function CLEARGIF($conf) {
893 return $this->getContentObject('CLEARGIF')->render($conf);
897 * Rendering the cObject, COBJ_ARRAY / COA and COBJ_ARRAY_INT
899 * @param array array of TypoScript properties
900 * @param string If "INT" then the cObject is a "COBJ_ARRAY_INT" (non-cached), otherwise just "COBJ_ARRAY" (cached)
901 * @return string Output
903 function COBJ_ARRAY($conf, $ext = '') {
904 if ($ext === 'INT') {
905 return $this->getContentObject('COA_INT')->render($conf);
907 return $this->getContentObject('COA')->render($conf);
912 * Rendering the cObject, USER and USER_INT
914 * @param array array of TypoScript properties
915 * @param string If "INT" then the cObject is a "USER_INT" (non-cached), otherwise just "USER" (cached)
916 * @return string Output
918 function USER($conf, $ext = '') {
919 if ($ext === 'INT') {
920 return $this->getContentObject('USER_INT')->render($conf);
922 return $this->getContentObject('USER')->render($conf);
927 * Retrieves a type of object called as USER or USER_INT. Object can detect their
928 * type by using this call. It returns OBJECTTYPE_USER_INT or OBJECTTYPE_USER depending on the
929 * current object execution. In all other cases it will return FALSE to indicate
930 * a call out of context.
932 * @return mixed One of OBJECTTYPE_ class constants or FALSE
934 public function getUserObjectType() {
935 return $this->userObjectType
;
939 * Sets the user object type
941 * @param mixed $userObjectType
944 public function setUserObjectType($userObjectType) {
945 $this->userObjectType
= $userObjectType;
949 * Requests the current USER object to be converted to USER_INT.
953 public function convertToUserIntObject() {
954 if ($this->userObjectType
!== self
::OBJECTTYPE_USER
) {
955 $GLOBALS['TT']->setTSlogMessage('tslib_cObj::convertToUserIntObject() ' . 'is called in the wrong context or for the wrong object type', 2);
957 $this->doConvertToUserIntObject
= TRUE;
962 * Rendering the cObject, FILE
964 * @param array array of TypoScript properties
965 * @return string Output
967 function FILE($conf) {
968 return $this->getContentObject('FILE')->render($conf);
972 * Rendering the cObject, IMAGE
974 * @param array array of TypoScript properties
975 * @return string Output
978 function IMAGE($conf) {
979 return $this->getContentObject('IMAGE')->render($conf);
983 * Rendering the cObject, IMG_RESOURCE
985 * @param array array of TypoScript properties
986 * @return string Output
987 * @see getImgResource()
989 function IMG_RESOURCE($conf) {
990 return $this->getContentObject('IMG_RESOURCE')->render($conf);
994 * Rendering the cObject, IMGTEXT
996 * @param array array of TypoScript properties
997 * @return string Output
999 function IMGTEXT($conf) {
1000 return $this->getContentObject('IMGTEXT')->render($conf);
1004 * Rendering the cObject, CONTENT
1006 * @param array array of TypoScript properties
1007 * @return string Output
1009 function CONTENT($conf) {
1010 return $this->getContentObject('CONTENT')->render($conf);
1014 * Rendering the cObject, RECORDS
1016 * @param array array of TypoScript properties
1017 * @return string Output
1019 function RECORDS($conf) {
1020 return $this->getContentObject('RECORDS')->render($conf);
1024 * Rendering the cObject, HMENU
1026 * @param array array of TypoScript properties
1027 * @return string Output
1029 function HMENU($conf) {
1030 return $this->getContentObject('HMENU')->render($conf);
1034 * Rendering the cObject, CTABLE
1036 * @param array array of TypoScript properties
1037 * @return string Output
1039 function CTABLE($conf) {
1040 return $this->getContentObject('CTABLE')->render($conf);
1044 * Rendering the cObject, OTABLE
1046 * @param array array of TypoScript properties
1047 * @return string Output
1049 function OTABLE($conf) {
1050 return $this->getContentObject('OTABLE')->render($conf);
1054 * Rendering the cObject, COLUMNS
1056 * @param array array of TypoScript properties
1057 * @return string Output
1059 function COLUMNS($conf) {
1060 return $this->getContentObject('COLUMNS')->render($conf);
1064 * Rendering the cObject, HRULER
1066 * @param array array of TypoScript properties
1067 * @return string Output
1069 function HRULER($conf) {
1070 return $this->getContentObject('HRULER')->render($conf);
1074 * Rendering the cObject, CASE
1076 * @param array array of TypoScript properties
1077 * @return string Output
1079 function CASEFUNC($conf) {
1080 return $this->getContentObject('CASE')->render($conf);
1084 * Rendering the cObject, LOAD_REGISTER and RESTORE_REGISTER
1085 * NOTICE: This cObject does NOT return any content since it just sets internal data based on the TypoScript properties.
1087 * @param array array of TypoScript properties
1088 * @param string If "RESTORE_REGISTER" then the cObject rendered is "RESTORE_REGISTER", otherwise "LOAD_REGISTER"
1089 * @return string Empty string (the cObject only sets internal data!)
1091 function LOAD_REGISTER($conf, $name) {
1092 if ($name === 'RESTORE_REGISTER') {
1093 return $this->getContentObject('RESTORE_REGISTER')->render($conf);
1095 return $this->getContentObject('LOAD_REGISTER')->render($conf);
1100 * Rendering the cObject, FORM
1102 * @param array array of TypoScript properties
1103 * @param array Alternative formdata overriding whatever comes from TypoScript
1104 * @return string Output
1106 function FORM($conf, $formData = '') {
1107 return $this->getContentObject('FORM')->render($conf, $formData);
1111 * Rendering the cObject, SEARCHRESULT
1113 * @param array array of TypoScript properties
1114 * @return string Output
1116 function SEARCHRESULT($conf) {
1117 return $this->getContentObject('SEARCHRESULT')->render($conf);
1121 * Rendering the cObject, PHP_SCRIPT, PHP_SCRIPT_INT and PHP_SCRIPT_EXT
1123 * @param array array of TypoScript properties
1124 * @param string If "INT", then rendering "PHP_SCRIPT_INT"; If "EXT", then rendering "PHP_SCRIPT_EXT"; Default is rendering "PHP_SCRIPT" (cached)
1125 * @return string Output
1127 function PHP_SCRIPT($conf, $ext = '') {
1128 if ($ext === 'INT' ||
$ext === 'EXT') {
1129 return $this->getContentObject('PHP_SCRIPT_INT')->render($conf);
1131 return $this->getContentObject('PHP_SCRIPT')->render($conf);
1136 * Rendering the cObject, TEMPLATE
1138 * @param array array of TypoScript properties
1139 * @return string Output
1140 * @see substituteMarkerArrayCached()
1142 function TEMPLATE($conf) {
1143 return $this->getContentObject('TEMPLATE')->render($conf);
1147 * Rendering the cObject, FLUIDTEMPLATE
1149 * @param array array of TypoScript properties
1150 * @return string the HTML output
1151 * @author Steffen Ritter <info@steffen-ritter.net>
1152 * @author Benjamin Mack <benni@typo3.org>
1154 protected function FLUIDTEMPLATE(array $conf) {
1155 return $this->getContentObject('FLUIDTEMPLATE')->render($conf);
1159 * Rendering the cObject, MULTIMEDIA
1161 * @param array array of TypoScript properties
1162 * @return string Output
1164 function MULTIMEDIA($conf) {
1165 return $this->getContentObject('MULTIMEDIA')->render($conf);
1169 * Rendering the cObject, MEDIA
1171 * @param array array of TypoScript properties
1172 * @return string Output
1174 public function MEDIA($conf) {
1175 return $this->getContentObject('MEDIA')->render($conf);
1179 * Rendering the cObject, SWFOBJECT
1181 * @param array array of TypoScript properties
1182 * @return string Output
1184 public function SWFOBJECT($conf) {
1185 return $this->getContentObject('SWFOBJECT')->render($conf);
1189 * Rendering the cObject, QTOBJECT
1191 * @param array array of TypoScript properties
1192 * @return string Output
1194 public function QTOBJECT($conf) {
1195 return $this->getContentObject('QTOBJECT')->render($conf);
1199 * Rendering the cObject, SVG
1201 * @param array array of TypoScript properties
1202 * @return string Output
1204 public function SVG($conf) {
1205 return $this->getContentObject('SVG')->render($conf);
1208 /************************************
1210 * Various helper functions for content objects:
1212 ************************************/
1216 * Converts a given config in Flexform to a conf-array
1217 * @param string Flexform data
1218 * @param array array to write the data into, by reference
1219 * @param boolean is set if called recursive. Don't call function with this parameter, it's used inside the function only
1223 public function readFlexformIntoConf($flexData, &$conf, $recursive = FALSE) {
1224 if ($recursive === FALSE) {
1225 $flexData = t3lib_div
::xml2array($flexData, 'T3');
1228 if (is_array($flexData)) {
1229 if (isset($flexData['data']['sDEF']['lDEF'])) {
1230 $flexData = $flexData['data']['sDEF']['lDEF'];
1233 foreach ($flexData as $key => $value) {
1234 if (is_array($value['el']) && count($value['el']) > 0) {
1235 foreach ($value['el'] as $ekey => $element) {
1236 if (isset($element['vDEF'])) {
1237 $conf[$ekey] = $element['vDEF'];
1239 if (is_array($element)) {
1240 $this->readFlexformIntoConf($element, $conf[$key][key($element)][$ekey], TRUE);
1242 $this->readFlexformIntoConf($element, $conf[$key][$ekey], TRUE);
1247 $this->readFlexformIntoConf($value['el'], $conf[$key], TRUE);
1249 if ($value['vDEF']) {
1250 $conf[$key] = $value['vDEF'];
1258 * Returns all parents of the given PID (Page UID) list
1260 * @param string A list of page Content-Element PIDs (Page UIDs) / stdWrap
1261 * @param array stdWrap array for the list
1262 * @return string A list of PIDs
1265 function getSlidePids($pidList, $pidConf) {
1266 $pidList = isset($pidConf)
1267 ?
trim($this->stdWrap($pidList, $pidConf))
1269 if (!strcmp($pidList, '')) {
1272 if (trim($pidList)) {
1273 $listArr = t3lib_div
::intExplode(',', str_replace('this', $GLOBALS['TSFE']->contentPid
, $pidList));
1274 $listArr = $this->checkPidArray($listArr);
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'];
1285 return implode(',', $pidList);
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.
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.
1298 function getFieldDefaultValue($noValueInsert, $fieldName, $defaultVal) {
1299 if (!$GLOBALS['TSFE']->no_cache ||
(!isset($_POST[$fieldName]) && !isset($_GET[$fieldName])) ||
$noValueInsert) {
1302 return t3lib_div
::_GP($fieldName);
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().
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.
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...
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(
1330 'use IMAGE.altText instead - src: ' . $info[3] . ' - original image: ' . $info['origFile']
1332 if (!strlen($conf['altText']) && !is_array($conf['altText.'])) {
1333 $conf['altText'] = $conf['alttext'];
1334 $conf['altText.'] = $conf['alttext.'];
1338 $altParam = $this->getAltParam($conf);
1339 if($conf['params'] && !isset($conf['params.'])) {
1340 $params = ' ' . $conf['params'];
1342 $params = isset($conf['params.'])
1343 ?
' ' . $this->stdWrap($conf['params'], $conf['params.'])
1346 $theValue = '<img src="' . htmlspecialchars($GLOBALS['TSFE']->absRefPrefix
.
1347 t3lib_div
::rawUrlEncodeFP($info[3])) . '" width="' . $info[0] . '" height="' . $info[1] . '"' .
1348 $this->getBorderAttr(' border="' . intval($conf['border']) . '"') .
1350 ($altParam) . ' />';
1351 $linkWrap = isset($conf['linkWrap.'])
1352 ?
$this->stdWrap($conf['linkWrap'], $conf['linkWrap.'])
1353 : $conf['linkWrap'];
1355 $theValue = $this->linkWrap($theValue, $linkWrap);
1356 } elseif ($conf['imageLinkWrap']) {
1357 $theValue = $this->imageLinkWrap($theValue, $info['origFile'], $conf['imageLinkWrap.']);
1359 $wrap = isset($conf['wrap.'])
1360 ?
$this->stdWrap($conf['wrap'], $conf['wrap.'])
1363 $theValue = $this->wrap($theValue, $conf['wrap']);
1370 * Returns the 'border' attribute for an <img> tag only if the doctype is not xhtml_strict, xhtml_11, xhtml_2 or html5
1371 * or if the config parameter 'disableImgBorderAttr' is not set.
1373 * @param string the border attribute
1374 * @return string the border attribute
1376 function getBorderAttr($borderAttr) {
1377 if (! t3lib_div
::inList('xhtml_strict,xhtml_11,xhtml_2', $GLOBALS['TSFE']->xhtmlDoctype
) &&
1378 $GLOBALS['TSFE']->config
['config']['doctype'] != 'html5' &&
1379 ! $GLOBALS['TSFE']->config
['config']['disableImgBorderAttr']) {
1385 * Wraps the input string in link-tags that opens the image in a new window.
1387 * @param string String to wrap, probably an <img> tag
1388 * @param string The original image file
1389 * @param array TypoScript properties for the "imageLinkWrap" function
1390 * @return string The input string, $string, wrapped as configured.
1393 function imageLinkWrap($string, $imageFile, $conf) {
1397 $enable = isset($conf['enable.'])
1398 ?
$this->stdWrap($conf['enable'], $conf['enable.'])
1401 $content = $this->typolink($string, $conf['typolink.']);
1402 if(isset($conf['file.'])) {
1403 $imageFile = $this->stdWrap($imageFile, $conf['file.']);
1407 if ($content == $string && @is_file
($imageFile)) {
1408 $parameterNames = array('width', 'height', 'effects', 'alternativeTempPath', 'bodyTag', 'title', 'wrap');
1409 $parameters = array();
1411 $sample = isset($conf['sample.'])
1412 ?
$this->stdWrap($conf['sample'], $conf['sample.'])
1415 $parameters['sample'] = 1;
1418 foreach ($parameterNames as $parameterName) {
1419 if(isset($conf[$parameterName.'.'])) {
1420 $conf[$parameterName] = $this->stdWrap($conf[$parameterName], $conf[$parameterName.'.']);
1422 if (isset($conf[$parameterName]) && $conf[$parameterName]) {
1423 $parameters[$parameterName] = $conf[$parameterName];
1427 $parametersEncoded = base64_encode(serialize($parameters));
1429 $md5_value = t3lib_div
::hmac(
1432 array($imageFile, $parametersEncoded)
1436 $params = '&md5=' . $md5_value;
1437 foreach (str_split($parametersEncoded, 64) as $index => $chunk) {
1438 $params .= '¶meters[' . $index . ']=' . rawurlencode($chunk);
1441 $url = $GLOBALS['TSFE']->absRefPrefix
. 'index.php?eID=tx_cms_showpic&file=' . rawurlencode($imageFile) . $params;
1443 $directImageLink = isset($conf['directImageLink.'])
1444 ?
$this->stdWrap($conf['directImageLink'], $conf['directImageLink.'])
1445 : $conf['directImageLink'];
1446 if ($directImageLink) {
1447 $imgResourceConf = array(
1448 'file' => $imageFile,
1451 $url = $this->IMG_RESOURCE($imgResourceConf);
1453 // if no imagemagick / gm is available
1458 // Create TARGET-attribute only if the right doctype is used
1459 if (!t3lib_div
::inList('xhtml_strict,xhtml_11,xhtml_2', $GLOBALS['TSFE']->xhtmlDoctype
)) {
1460 $target = isset($conf['target.'])
1461 ?
$this->stdWrap($conf['target'], $conf['target.'])
1464 $target = sprintf(' target="%s"', $target);
1466 $target = ' target="thePicture"';
1471 $conf['JSwindow'] = isset($conf['JSwindow.'])
1472 ?
$this->stdWrap($conf['JSwindow'], $conf['JSwindow.'])
1473 : $conf['JSwindow'];
1474 if ($conf['JSwindow']) {
1475 if ($conf['JSwindow.']['altUrl'] ||
$conf['JSwindow.']['altUrl.']) {
1476 $altUrl = isset($conf['JSwindow.']['altUrl.'])
1477 ?
$this->stdWrap($conf['JSwindow.']['altUrl'], $conf['JSwindow.']['altUrl.'])
1478 : $conf['JSwindow.']['altUrl'];
1481 ($conf['JSwindow.']['altUrl_noDefaultParams'] ?
'' : '?file=' .
1482 rawurlencode($imageFile) . $params);
1485 $gifCreator = t3lib_div
::makeInstance('tslib_gifbuilder');
1486 $gifCreator->init();
1487 $gifCreator->mayScaleUp
= 0;
1489 $dims = $gifCreator->getImageScale($gifCreator->getImageDimensions($imageFile), $conf['width'], $conf['height'], '');
1490 $JSwindowExpand = isset($conf['JSwindow.']['expand.'])
1491 ?
$this->stdWrap($conf['JSwindow.']['expand'], $conf['JSwindow.']['expand.'])
1492 : $conf['JSwindow.']['expand'];
1493 $offset = t3lib_div
::intExplode(',', $JSwindowExpand . ',');
1495 $newWindow = isset($conf['JSwindow.']['newWindow.'])
1496 ?
$this->stdWrap($conf['JSwindow.']['newWindow'], $conf['JSwindow.']['newWindow.'])
1497 : $conf['JSwindow.']['newWindow'];
1498 $a1 = '<a href="' . htmlspecialchars($url) . '" onclick="' .
1499 htmlspecialchars('openPic(\'' . $GLOBALS['TSFE']->baseUrlWrap($url) . '\',\'' .
1500 ($newWindow ?
md5($url) : 'thePicture') . '\',\'width=' .
1501 ($dims[0] +
$offset[0]) . ',height=' . ($dims[1] +
$offset[1]) .
1502 ',status=0,menubar=0\'); return false;') . '"' .
1503 $target . $GLOBALS['TSFE']->ATagParams
. '>';
1505 $GLOBALS['TSFE']->setJS('openPic');
1507 $conf['linkParams.']['parameter'] = $url;
1508 $string = $this->typoLink($string, $conf['linkParams.']);
1511 if(isset($conf['stdWrap.'])) {
1512 $string = $this->stdWrap($string, $conf['stdWrap.']);
1515 $content = $a1 . $string . $a2;
1523 * Returns content of a file. If it's an image the content of the file is not returned but rather an image tag is.
1525 * @param string The filename, being a TypoScript resource data type
1526 * @param string Additional parameters (attributes). Default is empty alt and title tags.
1527 * @return string If jpg,gif,jpeg,png: returns image_tag with picture in. If html,txt: returns content string
1530 function fileResource($fName, $addParams = 'alt="" title=""') {
1531 $incFile = $GLOBALS['TSFE']->tmpl
->getFileName($fName);
1533 $fileinfo = t3lib_div
::split_fileref($incFile);
1534 if (t3lib_div
::inList('jpg,gif,jpeg,png', $fileinfo['fileext'])) {
1535 $imgFile = $incFile;
1536 $imgInfo = @getImageSize
($imgFile);
1537 return '<img src="' . $GLOBALS['TSFE']->absRefPrefix
. $imgFile .
1538 '" width="' . $imgInfo[0] . '" height="' . $imgInfo[1] . '"' .
1539 $this->getBorderAttr(' border="0"') . ' ' . $addParams . ' />';
1540 } elseif (filesize($incFile) < 1024 * 1024) {
1541 return $GLOBALS['TSFE']->tmpl
->fileContent($incFile);
1547 * Sets the SYS_LASTCHANGED timestamp if input timestamp is larger than current value.
1548 * The SYS_LASTCHANGED timestamp can be used by various caching/indexing applications to determine if the page has new content.
1549 * Therefore you should call this function with the last-changed timestamp of any element you display.
1551 * @param integer Unix timestamp (number of seconds since 1970)
1553 * @see tslib_fe::setSysLastChanged()
1555 function lastChanged($tstamp) {
1556 $tstamp = intval($tstamp);
1557 if ($tstamp > intval($GLOBALS['TSFE']->register
['SYS_LASTCHANGED'])) {
1558 $GLOBALS['TSFE']->register
['SYS_LASTCHANGED'] = $tstamp;
1563 * Wraps the input string by the $wrap value and implements the "linkWrap" data type as well.
1564 * The "linkWrap" data type means that this function will find any integer encapsulated in {} (curly braces) in the first wrap part and substitute it with the corresponding page uid from the rootline where the found integer is pointing to the key in the rootline. See link below.
1566 * @param string Input string
1567 * @param string A string where the first two parts separated by "|" (vertical line) will be wrapped around the input string
1568 * @return string Wrapped output string
1569 * @see wrap(), cImage(), FILE()
1571 function linkWrap($content, $wrap) {
1572 $wrapArr = explode('|', $wrap);
1573 if (preg_match('/\{([0-9]*)\}/', $wrapArr[0], $reg)) {
1574 if ($uid = $GLOBALS['TSFE']->tmpl
->rootLine
[$reg[1]]['uid']) {
1575 $wrapArr[0] = str_replace($reg[0], $uid, $wrapArr[0]);
1578 return trim($wrapArr[0]) . $content . trim($wrapArr[1]);
1582 * An abstraction method which creates an alt or title parameter for an HTML img, applet, area or input element and the FILE content element.
1583 * From the $conf array it implements the properties "altText", "titleText" and "longdescURL"
1585 * @param array TypoScript configuration properties
1586 * @param boolean If set, the longdesc attribute will be generated - must only be used for img elements!
1587 * @return string Parameter string containing alt and title parameters (if any)
1588 * @see IMGTEXT(), FILE(), FORM(), cImage(), filelink()
1590 function getAltParam($conf, $longDesc = TRUE) {
1591 $altText = isset($conf['altText.'])
1592 ?
trim($this->stdWrap($conf['altText'], $conf['altText.']))
1593 : trim($conf['altText']);
1594 $titleText = isset($conf['titleText.'])
1595 ?
trim($this->stdWrap($conf['titleText'], $conf['titleText.']))
1596 : trim($conf['titleText']);
1597 $longDesc = isset($conf['longdescURL.'])
1598 ?
trim($this->stdWrap($conf['longdescURL'], $conf['longdescURL.']))
1599 : trim($conf['longdescURL']);
1602 $altParam = ' alt="' . htmlspecialchars($altText) . '"';
1605 $emptyTitleHandling = 'useAlt';
1606 $emptyTitleHandling = isset($conf['emptyTitleHandling.'])
1607 ?
$this->stdWrap($conf['emptyTitleHandling'], $conf['emptyTitleHandling.'])
1608 : $conf['emptyTitleHandling'];
1609 // choices: 'keepEmpty' | 'useAlt' | 'removeAttr'
1610 if ($titleText ||
$emptyTitleHandling == 'keepEmpty') {
1611 $altParam .= ' title="' . htmlspecialchars($titleText) . '"';
1612 } elseif (!$titleText && $emptyTitleHandling == 'useAlt') {
1613 $altParam .= ' title="' . htmlspecialchars($altText) . '"';
1618 $altParam .= ' longdesc="' . htmlspecialchars(strip_tags($longDesc)) . '"';
1625 * Removes forbidden characters and spaces from name/id attributes in the form tag and formfields
1627 * @param string Input string
1628 * @return string the cleaned string
1631 function cleanFormName($name) {
1632 // turn data[x][y] into data:x:y:
1633 $name = preg_replace('/\[|\]\[?/', ':', trim($name));
1634 // remove illegal chars like _
1635 return preg_replace('#[^:a-zA-Z0-9]#', '', $name);
1639 * An abstraction method to add parameters to an A tag.
1640 * Uses the ATagParams property.
1642 * @param array TypoScript configuration properties
1643 * @param boolean If set, will add the global config.ATagParams to the link
1644 * @return string String containing the parameters to the A tag (if non empty, with a leading space)
1645 * @see IMGTEXT(), filelink(), makelinks(), typolink()
1647 function getATagParams($conf, $addGlobal = 1) {
1649 if ($conf['ATagParams.']) {
1650 $aTagParams = ' ' . $this->stdWrap($conf['ATagParams'], $conf['ATagParams.']);
1651 } elseif ($conf['ATagParams']) {
1652 $aTagParams = ' ' . $conf['ATagParams'];
1655 $aTagParams = ' ' . trim($GLOBALS['TSFE']->ATagParams
. $aTagParams);
1661 * All extension links should ask this function for additional properties to their tags.
1662 * Designed to add for instance an "onclick" property for site tracking systems.
1664 * @param string URL of the website
1665 * @return string the additional tag properties
1667 function extLinkATagParams($URL, $TYPE) {
1670 if ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['extLinkATagParamsHandler']) {
1671 $extLinkATagParamsHandler = t3lib_div
::getUserObj(
1672 $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['extLinkATagParamsHandler']
1675 if (method_exists($extLinkATagParamsHandler, 'main')) {
1676 $out .= trim($extLinkATagParamsHandler->main($URL, $TYPE, $this));
1680 return trim($out) ?
' ' . trim($out) : '';
1685 /***********************************************
1687 * HTML template processing functions
1689 ***********************************************/
1692 * Returns a subpart from the input content stream.
1693 * A subpart is a part of the input stream which is encapsulated in a
1694 * string matching the input string, $marker. If this string is found
1695 * inside of HTML comment tags the start/end points of the content block
1696 * returned will be that right outside that comment block.
1697 * Example: The contennt string is
1698 * "Hello <!--###sub1### begin--> World. How are <!--###sub1### end--> you?"
1699 * If $marker is "###sub1###" then the content returned is
1700 * " World. How are ". The input content string could just as well have
1701 * been "Hello ###sub1### World. How are ###sub1### you?" and the result
1703 * Wrapper for t3lib_parsehtml::getSubpart which behaves identical
1705 * @param string The content stream, typically HTML template content.
1706 * @param string The marker string, typically on the form "###[the marker string]###"
1707 * @return string The subpart found, if found.
1708 * @see substituteSubpart(), t3lib_parsehtml::getSubpart()
1710 public function getSubpart($content, $marker) {
1711 return t3lib_parsehtml
::getSubpart($content, $marker);
1715 * Substitute subpart in input template stream.
1716 * This function substitutes a subpart in $content with the content of
1718 * Wrapper for t3lib_parsehtml::substituteSubpart which behaves identical
1720 * @param string The content stream, typically HTML template content.
1721 * @param string The marker string, typically on the form "###[the marker string]###"
1722 * @param mixed The content to insert instead of the subpart found. If a string, then just plain substitution happens (includes removing the HTML comments of the subpart if found). If $subpartContent happens to be an array, it's [0] and [1] elements are wrapped around the EXISTING content of the subpart (fetched by getSubpart()) thereby not removing the original content.
1723 * @param boolean If $recursive is set, the function calls itself with the content set to the remaining part of the content after the second marker. This means that proceding subparts are ALSO substituted!
1724 * @return string The processed HTML content string.
1725 * @see getSubpart(), t3lib_parsehtml::substituteSubpart()
1727 public function substituteSubpart($content, $marker, $subpartContent, $recursive = 1) {
1728 return t3lib_parsehtml
::substituteSubpart($content, $marker, $subpartContent, $recursive);
1732 * Substitues multiple subparts at once
1734 * @param string The content stream, typically HTML template content.
1735 * @param array The array of key/value pairs being subpart/content values used in the substitution. For each element in this array the function will substitute a subpart in the content stream with the content.
1736 * @return string The processed HTML content string.
1738 public function substituteSubpartArray($content, array $subpartsContent) {
1739 return t3lib_parsehtml
::substituteSubpartArray($content, $subpartsContent);
1743 * Substitutes a marker string in the input content
1744 * (by a simple str_replace())
1746 * @param string The content stream, typically HTML template content.
1747 * @param string The marker string, typically on the form "###[the marker string]###"
1748 * @param mixed The content to insert instead of the marker string found.
1749 * @return string The processed HTML content string.
1750 * @see substituteSubpart()
1752 public function substituteMarker($content, $marker, $markContent) {
1753 return t3lib_parsehtml
::substituteMarker($content, $marker, $markContent);
1757 * Multi substitution function with caching.
1759 * This function should be a one-stop substitution function for working
1760 * with HTML-template. It does not substitute by str_replace but by
1761 * splitting. This secures that the value inserted does not themselves
1762 * contain markers or subparts.
1764 * Note that the "caching" won't cache the content of the substition,
1765 * but only the splitting of the template in various parts. So if you
1766 * want only one cache-entry per template, make sure you always pass the
1767 * exact same set of marker/subpart keys. Else you will be flooding the
1768 * users cache table.
1770 * This function takes three kinds of substitutions in one:
1771 * $markContentArray is a regular marker-array where the 'keys' are
1772 * substituted in $content with their values
1774 * $subpartContentArray works exactly like markContentArray only is whole
1775 * subparts substituted and not only a single marker.
1777 * $wrappedSubpartContentArray is an array of arrays with 0/1 keys where
1778 * the subparts pointed to by the main key is wrapped with the 0/1 value
1781 * @param string The content stream, typically HTML template content.
1782 * @param array Regular marker-array where the 'keys' are substituted in $content with their values
1783 * @param array Exactly like markContentArray only is whole subparts substituted and not only a single marker.
1784 * @param array An array of arrays with 0/1 keys where the subparts pointed to by the main key is wrapped with the 0/1 value alternating.
1785 * @return string The output content stream
1786 * @see substituteSubpart(), substituteMarker(), substituteMarkerInObject(), TEMPLATE()
1788 public function substituteMarkerArrayCached($content, array $markContentArray = NULL, array $subpartContentArray = NULL, array $wrappedSubpartContentArray = NULL) {
1789 $GLOBALS['TT']->push('substituteMarkerArrayCached');
1791 // If not arrays then set them
1792 if (is_null($markContentArray))
1793 $markContentArray = array(); // Plain markers
1794 if (is_null($subpartContentArray))
1795 $subpartContentArray = array(); // Subparts being directly substituted
1796 if (is_null($wrappedSubpartContentArray))
1797 $wrappedSubpartContentArray = array(); // Subparts being wrapped
1798 // Finding keys and check hash:
1799 $sPkeys = array_keys($subpartContentArray);
1800 $wPkeys = array_keys($wrappedSubpartContentArray);
1801 $aKeys = array_merge(array_keys($markContentArray), $sPkeys, $wPkeys);
1802 if (!count($aKeys)) {
1803 $GLOBALS['TT']->pull();
1807 $storeKey = md5('substituteMarkerArrayCached_storeKey:' . serialize(array(
1810 if ($this->substMarkerCache
[$storeKey]) {
1811 $storeArr = $this->substMarkerCache
[$storeKey];
1812 $GLOBALS['TT']->setTSlogMessage('Cached', 0);
1814 $storeArrDat = $GLOBALS['TSFE']->sys_page
->getHash($storeKey);
1815 if (!isset($storeArrDat)) {
1816 // Initialize storeArr
1817 $storeArr = array();
1819 // Finding subparts and substituting them with the subpart as a marker
1820 foreach ($sPkeys as $sPK) {
1821 $content = $this->substituteSubpart($content, $sPK, $sPK);
1824 // Finding subparts and wrapping them with markers
1825 foreach ($wPkeys as $wPK) {
1826 $content = $this->substituteSubpart($content, $wPK, array(
1831 // traverse keys and quote them for reg ex.
1832 foreach ($aKeys as $tK => $tV) {
1833 $aKeys[$tK] = preg_quote($tV, '/');
1835 $regex = '/' . implode('|', $aKeys) . '/';
1837 $storeArr['c'] = preg_split($regex, $content);
1838 preg_match_all($regex, $content, $keyList);
1839 $storeArr['k'] = $keyList[0];
1841 $this->substMarkerCache
[$storeKey] = $storeArr;
1843 // Storing the cached data:
1844 $GLOBALS['TSFE']->sys_page
->storeHash($storeKey, serialize($storeArr), 'substMarkArrayCached');
1846 $GLOBALS['TT']->setTSlogMessage('Parsing', 0);
1849 $storeArr = unserialize($storeArrDat);
1851 $this->substMarkerCache
[$storeKey] = $storeArr;
1852 $GLOBALS['TT']->setTSlogMessage('Cached from DB', 0);
1856 // Substitution/Merging:
1857 // Merging content types together, resetting
1858 $valueArr = array_merge($markContentArray, $subpartContentArray, $wrappedSubpartContentArray);
1860 $wSCA_reg = array();
1862 // traversing the keyList array and merging the static and dynamic content
1863 foreach ($storeArr['k'] as $n => $keyN) {
1864 $content .= $storeArr['c'][$n];
1865 if (!is_array($valueArr[$keyN])) {
1866 $content .= $valueArr[$keyN];
1868 $content .= $valueArr[$keyN][(intval($wSCA_reg[$keyN]) %
2)];
1872 $content .= $storeArr['c'][count($storeArr['k'])];
1874 $GLOBALS['TT']->pull();
1879 * Traverses the input $markContentArray array and for each key the marker
1880 * by the same name (possibly wrapped and in upper case) will be
1881 * substituted with the keys value in the array.
1883 * This is very useful if you have a data-record to substitute in some
1884 * content. In particular when you use the $wrap and $uppercase values to
1885 * pre-process the markers. Eg. a key name like "myfield" could effectively
1886 * be represented by the marker "###MYFIELD###" if the wrap value
1887 * was "###|###" and the $uppercase boolean TRUE.
1889 * @param string The content stream, typically HTML template content.
1890 * @param array The array of key/value pairs being marker/content values used in the substitution. For each element in this array the function will substitute a marker in the content stream with the content.
1891 * @param string A wrap value - [part 1] | [part 2] - for the markers before substitution
1892 * @param boolean If set, all marker string substitution is done with upper-case markers.
1893 * @param boolean If set, all unused marker are deleted.
1894 * @return string The processed output stream
1895 * @see substituteMarker(), substituteMarkerInObject(), TEMPLATE()
1897 public function substituteMarkerArray($content, array $markContentArray, $wrap = '', $uppercase = FALSE, $deleteUnused = FALSE) {
1898 return t3lib_parsehtml
::substituteMarkerArray($content, $markContentArray, $wrap, $uppercase, $deleteUnused);
1902 * Substitute marker array in an array of values
1904 * @param mixed If string, then it just calls substituteMarkerArray. If array(and even multi-dim) then for each key/value pair the marker array will be substituted (by calling this function recursively)
1905 * @param array The array of key/value pairs being marker/content values used in the substitution. For each element in this array the function will substitute a marker in the content string/array values.
1906 * @return mixed The processed input variable.
1907 * @see substituteMarker()
1909 public function substituteMarkerInObject(&$tree, array $markContentArray) {
1910 if (is_array($tree)) {
1911 foreach ($tree as $key => $value) {
1912 $this->substituteMarkerInObject($tree[$key], $markContentArray);
1915 $tree = $this->substituteMarkerArray($tree, $markContentArray);
1922 * Adds elements to the input $markContentArray based on the values from
1923 * the fields from $fieldList found in $row
1925 * @param array array with key/values being marker-strings/substitution values.
1926 * @param array An array with keys found in the $fieldList (typically a record) which values should be moved to the $markContentArray
1927 * @param string A list of fields from the $row array to add to the $markContentArray array. If empty all fields from $row will be added (unless they are integers)
1928 * @param boolean If set, all values added to $markContentArray will be nl2br()'ed
1929 * @param string Prefix string to the fieldname before it is added as a key in the $markContentArray. Notice that the keys added to the $markContentArray always start and end with "###"
1930 * @param boolean If set, all values are passed through htmlspecialchars() - RECOMMENDED to avoid most obvious XSS and maintain XHTML compliance.
1931 * @return array The modified $markContentArray
1933 public function fillInMarkerArray(array $markContentArray, array $row, $fieldList = '', $nl2br = TRUE, $prefix = 'FIELD_', $HSC = FALSE) {
1935 $fArr = t3lib_div
::trimExplode(',', $fieldList, 1);
1936 foreach ($fArr as $field) {
1937 $markContentArray['###' . $prefix . $field . '###'] = $nl2br ?
nl2br($row[$field]) : $row[$field];
1940 if (is_array($row)) {
1941 foreach ($row as $field => $value) {
1942 if (!t3lib_div
::testInt($field)) {
1944 $value = htmlspecialchars($value);
1947 $markContentArray['###' . $prefix . $field . '###'] = $nl2br ?
nl2br($value) : $value;
1953 return $markContentArray;
1956 /***********************************************
1958 * "stdWrap" + sub functions
1960 ***********************************************/
1963 * The "stdWrap" function. This is the implementation of what is known as "stdWrap properties" in TypoScript.
1964 * Basically "stdWrap" performs some processing of a value based on properties in the input $conf array(holding the TypoScript "stdWrap properties")
1965 * See the link below for a complete list of properties and what they do. The order of the table with properties found in TSref (the link) follows the actual order of implementation in this function.
1967 * If $this->alternativeData is an array it's used instead of the $this->data array in ->getData
1969 * @param string Input value undergoing processing in this function. Possibly substituted by other values fetched from another source.
1970 * @param array TypoScript "stdWrap properties".
1971 * @return string The processed input value
1973 public function stdWrap($content = '', $conf = array()) {
1974 if (count($this->stdWrapHookObjects
)) {
1975 foreach ($this->stdWrapHookObjects
as $hookObject) {
1976 if (is_callable(array($hookObject, 'stdWrapPreProcess'))) {
1977 $conf['stdWrapPreProcess'] = 1;
1980 if (is_callable(array($hookObject, 'stdWrapOverride'))) {
1981 $conf['stdWrapOverride'] = 1;
1984 if (is_callable(array($hookObject, 'stdWrapProcess'))) {
1985 $conf['stdWrapProcess'] = 1;
1988 if (is_callable(array($hookObject, 'stdWrapPostProcess'))) {
1989 $conf['stdWrapPostProcess'] = 1;
1994 if (is_array($conf) && count($conf)) {
1995 // check, which of the available stdWrap functions is needed for the current conf Array
1996 // and keep only those but still in the same order
1997 $sortedConf = array_intersect_key($this->stdWrapOrder
, $conf);
1998 // functions types that should not make use of nested stdWrap function calls to avoid conflicts with internal TypoScript used by these functions
1999 $stdWrapDisabledFunctionTypes = 'cObject,functionName,stdWrap';
2000 // additional Array to check whether a function has already been executed
2001 $isExecuted = array();
2002 // additional switch to make sure 'required', 'if' and 'fieldRequired'
2003 // will still stop rendering immediately in case they return false
2005 $this->stdWrapRecursionLevel++
;
2006 $this->stopRendering
[$this->stdWrapRecursionLevel
] = false;
2008 // execute each funtion in the predefined order
2009 foreach ($sortedConf as $stdWrapName => $functionType) {
2010 // eliminate the second key of a pair 'key'|'key.' to make sure functions get called only once and check if rendering has been stopped
2011 if (!$isExecuted[$stdWrapName] &&
2012 !$this->stopRendering
[$this->stdWrapRecursionLevel
]) {
2013 $functionName = rtrim($stdWrapName, '.');
2014 $functionProperties = $functionName . '.';
2015 // if there is any code one the next level, check if it contains "official" stdWrap functions
2016 // if yes, execute them first - will make each function stdWrap aware
2017 // so additional stdWrap calls within the functions can be removed, since the result will be the same
2018 // exception: the recursive stdWrap function and cObject will still be using their own stdWrap call, since it modifies the content and not a property
2019 if (count($conf[$functionProperties]) &&
2020 !t3lib_div
::inList($stdWrapDisabledFunctionTypes, $functionType)) {
2021 if (array_intersect_key($this->stdWrapOrder
, $conf[$functionProperties])) {
2022 $conf[$functionName] = $this->stdWrap($conf[$functionName], $conf[$functionProperties]);
2025 // get just that part of $conf that is needed for the particular function
2026 $singleConf = array(
2027 $functionName => $conf[$functionName],
2028 $functionProperties => $conf[$functionProperties]
2031 // in this special case 'spaceBefore' and 'spaceAfter' need additional stuff from 'space.''
2032 if ($functionName == 'spaceBefore' ||
$functionName == 'spaceAfter') {
2033 $singleConf['space.'] = $conf['space.'];
2036 // hand over the whole $conf array to the stdWrapHookObjects
2037 if ($functionType === 'hook') {
2038 $singleConf = $conf;
2040 // check if key is still containing something, since it might have been changed by next level stdWrap before
2041 if ((isset($conf[$functionName]) ||
$conf[$functionProperties]) &&
2042 !($functionType == 'boolean' && !$conf[$functionName])) {
2043 //add both keys - with and without the dot - to the set of executed functions
2044 $isExecuted[$functionName] = true;
2045 $isExecuted[$functionProperties] = true;
2046 // call the function with the prefix stdWrap_ to make sure nobody can execute functions just by adding their name to the TS Array
2047 $functionName = 'stdWrap_' . $functionName;
2048 $content = $this->$functionName(
2052 // for booleans we have to mark the function as executed in any case, even if it has been 0, '' or false to avoid a second call based on the functionProperties, which would always be true
2053 } elseif($functionType == 'boolean' && !$conf[$functionName]) {
2054 $isExecuted[$functionName] = TRUE;
2055 $isExecuted[$functionProperties] = TRUE;
2060 unset($this->stopRendering
[$this->stdWrapRecursionLevel
]);
2061 $this->stdWrapRecursionLevel
--;
2068 * stdWrap pre process hook
2069 * can be used by extensions authors to modify the behaviour of stdWrap functions to their needs
2070 * this hook will execute functions before any other stdWrap function can modify anything
2072 * @param string Input value undergoing processing in these functions.
2073 * @param array All stdWrap properties, not just the ones for a particular function.
2074 * @return string The processed input value
2076 public function stdWrap_stdWrapPreProcess($content = '', $conf = array()) {
2077 foreach ($this->stdWrapHookObjects
as $hookObject) {
2078 $content = $hookObject->stdWrapPreProcess($content, $conf, $this);
2084 * setContentToCurrent
2085 * actually it just does the contrary: Sets the value of 'current' based on current content
2087 * @param string Input value undergoing processing in this function.
2088 * @param array stdWrap properties for setContentToCurrent.
2089 * @return string The processed input value
2091 public function stdWrap_setContentToCurrent($content = '', $conf = array()) {
2092 $this->data
[$this->currentValKey
] = $content;
2098 * Sets the value of 'current' based on the outcome of stdWrap operations
2100 * @param string Input value undergoing processing in this function.
2101 * @param array stdWrap properties for setCurrent.
2102 * @return string The processed input value
2104 public function stdWrap_setCurrent($content = '', $conf = array()) {
2105 $this->data
[$this->currentValKey
] = $conf['setCurrent'];
2111 * Translates content based on the language currently used by the FE
2113 * @param string Input value undergoing processing in this function.
2114 * @param array stdWrap properties for lang.
2115 * @return string The processed input value
2117 public function stdWrap_lang($content = '', $conf = array()) {
2118 if (isset($conf['lang.']) && $GLOBALS['TSFE']->config
['config']['language'] && isset($conf['lang.'][$GLOBALS['TSFE']->config
['config']['language']])) {
2119 $content = $conf['lang.'][$GLOBALS['TSFE']->config
['config']['language']];
2126 * Gets content from different sources based on getText functions, makes use of alternativeData, when set
2128 * @param string Input value undergoing processing in this function.
2129 * @param array stdWrap properties for data.
2130 * @return string The processed input value
2132 public function stdWrap_data($content = '', $conf = array()) {
2133 $content = $this->getData($conf['data'], is_array($this->alternativeData
) ?
$this->alternativeData
: $this->data
);
2134 $this->alternativeData
= ''; // This must be unset directly after
2140 * Gets content from a DB field
2142 * @param string Input value undergoing processing in this function.
2143 * @param array stdWrap properties for field.
2144 * @return string The processed input value
2146 public function stdWrap_field($content = '', $conf = array()) {
2147 $content = $this->getFieldVal($conf['field']);
2153 * Gets content that has been perviously set as 'current'
2154 * Can be set via setContentToCurrent or setCurrent or will be set automatically i.e. inside the split function
2156 * @param string Input value undergoing processing in this function.
2157 * @param array stdWrap properties for current.
2158 * @return string The processed input value
2160 public function stdWrap_current($content = '', $conf = array()) {
2161 $content = $this->data
[$this->currentValKey
];
2167 * Will replace the content with the value of a any official TypoScript cObject
2168 * like TEXT, COA, HMENU
2170 * @param string Input value undergoing processing in this function.
2171 * @param array stdWrap properties for cObject.
2172 * @return string The processed input value
2174 public function stdWrap_cObject($content = '', $conf = array()) {
2175 $content = $this->cObjGetSingle($conf['cObject'], $conf['cObject.'], '/stdWrap/.cObject');
2181 * Counts the number of returned records of a DB operation
2182 * makes use of select internally
2184 * @param string Input value undergoing processing in this function.
2185 * @param array stdWrap properties for numRows.
2186 * @return string The processed input value
2188 public function stdWrap_numRows($content = '', $conf = array()) {
2189 $content = $this->numRows($conf['numRows.']);
2195 * Will create a list of files based on some additional parameters
2197 * @param string Input value undergoing processing in this function.
2198 * @param array stdWrap properties for filelist.
2199 * @return string The processed input value
2201 public function stdWrap_filelist($content = '', $conf = array()) {
2202 $content = $this->filelist($conf['filelist']);
2208 * Will execute a user public function before the content will be modified by any other stdWrap function
2210 * @param string Input value undergoing processing in this function.
2211 * @param array stdWrap properties for preUserFunc.
2212 * @return string The processed input value
2214 public function stdWrap_preUserFunc($content = '', $conf = array()) {
2215 $content = $this->callUserFunction($conf['preUserFunc'], $conf['preUserFunc.'], $content);
2220 * stdWrap override hook
2221 * can be used by extensions authors to modify the behaviour of stdWrap functions to their needs
2222 * this hook will execute functions on existing content but still before the content gets modified or replaced
2224 * @param string Input value undergoing processing in these functions.
2225 * @param array All stdWrap properties, not just the ones for a particular function.
2226 * @return string The processed input value
2228 public function stdWrap_stdWrapOverride($content = '', $conf = array()) {
2229 foreach ($this->stdWrapHookObjects
as $hookObject) {
2230 $content = $hookObject->stdWrapOverride($content, $conf, $this);
2237 * Will override the current value of content with its own value'
2239 * @param string Input value undergoing processing in this function.
2240 * @param array stdWrap properties for override.
2241 * @return string The processed input value
2243 public function stdWrap_override($content = '', $conf = array()) {
2244 if (trim($conf['override'])) {
2245 $content = $conf['override'];
2252 * Gets a value off a CSV list before the following ifEmpty check
2253 * Makes sure that the result of ifEmpty will be true in case the CSV does not contain a value at the position given by preIfEmptyListNum
2255 * @param string Input value undergoing processing in this function.
2256 * @param array stdWrap properties for preIfEmptyListNum.
2257 * @return string The processed input value
2259 public function stdWrap_preIfEmptyListNum($content = '', $conf = array()) {
2260 $content = $this->listNum($content, $conf['preIfEmptyListNum'], $conf['preIfEmptyListNum.']['splitChar']);
2266 * Will set content to a replacement value in case the trimmed value of content returns false
2267 * 0 (zero) will be replaced as well
2269 * @param string Input value undergoing processing in this function.
2270 * @param array stdWrap properties for ifEmpty.
2271 * @return string The processed input value
2273 public function stdWrap_ifEmpty($content = '', $conf = array()) {
2274 if (!trim($content)) {
2275 $content = $conf['ifEmpty'];
2282 * Will set content to a replacement value in case the trimmed value of content has no length
2283 * 0 (zero) will not be replaced
2285 * @param string Input value undergoing processing in this function.
2286 * @param array stdWrap properties for ifBlank.
2287 * @return string The processed input value
2289 public function stdWrap_ifBlank($content = '', $conf = array()) {
2290 if (!strlen(trim($content))) {
2291 $content = $conf['ifBlank'];
2298 * Gets a value off a CSV list after ifEmpty check
2299 * Might return an empty value in case the CSV does not contain a value at the position given by listNum
2300 * Use preIfEmptyListNum to avoid that behaviour
2302 * @param string Input value undergoing processing in this function.
2303 * @param array stdWrap properties for listNum.
2304 * @return string The processed input value
2306 public function stdWrap_listNum($content = '', $conf = array()) {
2307 $content = $this->listNum($content, $conf['listNum'], $conf['listNum.']['splitChar']);
2313 * Cuts off any whitespace at the beginning and the end of the content
2315 * @param string Input value undergoing processing in this function.
2316 * @param array stdWrap properties for trim.
2317 * @return string The processed input value
2319 public function stdWrap_trim($content = '', $conf = array()) {
2320 $content = trim($content);
2326 * A recursive call of the stdWrap function set
2327 * This enables the user to execute stdWrap functions in another than the predefined order
2328 * It modifies the content, not the property
2329 * while the new feature of chained stdWrap functions modifies the property and not the content
2331 * @param string Input value undergoing processing in this function.
2332 * @param array stdWrap properties for stdWrap.
2333 * @return string The processed input value
2335 public function stdWrap_stdWrap($content = '', $conf = array()) {
2336 $content = $this->stdWrap($content, $conf['stdWrap.']);
2341 * stdWrap process hook
2342 * can be used by extensions authors to modify the behaviour of stdWrap functions to their needs
2343 * this hook executes functions directly after the recursive stdWrap function call but still before the content gets modified
2345 * @param string Input value undergoing processing in these functions.
2346 * @param array All stdWrap properties, not just the ones for a particular function.
2347 * @return string The processed input value
2349 public function stdWrap_stdWrapProcess($content = '', $conf = array()) {
2350 foreach ($this->stdWrapHookObjects
as $hookObject) {
2351 $content = $hookObject->stdWrapProcess($content, $conf, $this);
2358 * Will immediately stop rendering and return an empty value
2359 * when there is no content at this point
2361 * @param string Input value undergoing processing in this function.
2362 * @param array stdWrap properties for required.
2363 * @return string The processed input value
2365 public function stdWrap_required($content = '', $conf = array()) {
2366 if ((string) $content == '') {
2368 $this->stopRendering
[$this->stdWrapRecursionLevel
] = TRUE;
2375 * Will immediately stop rendering and return an empty value
2376 * when the result of the checks returns false
2378 * @param string Input value undergoing processing in this function.
2379 * @param array stdWrap properties for if.
2380 * @return string The processed input value
2382 public function stdWrap_if($content = '', $conf = array()) {
2383 if (!$this->checkIf($conf['if.'])) {
2385 $this->stopRendering
[$this->stdWrapRecursionLevel
] = TRUE;
2392 * Will immediately stop rendering and return an empty value
2393 * when there is no content in the field given by fieldRequired
2395 * @param string Input value undergoing processing in this function.
2396 * @param array stdWrap properties for fieldRequired.
2397 * @return string The processed input value
2399 public function stdWrap_fieldRequired($content = '', $conf = array()) {
2400 if (!trim($this->data
[$conf['fieldRequired']])) {
2402 $this->stopRendering
[$this->stdWrapRecursionLevel
] = TRUE;
2409 * Will convert the current chracter set of the content to the one given in csConv
2411 * @param string Input value undergoing processing in this function.
2412 * @param array stdWrap properties for csConv.
2413 * @return string The processed input value
2415 public function stdWrap_csConv($content = '', $conf = array()) {
2416 $content = $GLOBALS['TSFE']->csConv($content, $conf['csConv']);
2422 * Will parse the content based on functions given as stdWrap properties
2423 * Heavily used together with RTE based content
2425 * @param string Input value undergoing processing in this function.
2426 * @param array stdWrap properties for parseFunc.
2427 * @return string The processed input value
2429 public function stdWrap_parseFunc($content = '', $conf = array()) {
2430 $content = $this->parseFunc($content, $conf['parseFunc.'], $conf['parseFunc']);
2436 * Will parse HTML content based on functions given as stdWrap properties
2437 * Heavily used together with RTE based content
2439 * @param string Input value undergoing processing in this function.
2440 * @param array stdWrap properties for HTMLparser.
2441 * @return string The processed input value
2443 public function stdWrap_HTMLparser($content = '', $conf = array()) {
2444 if (is_array($conf['HTMLparser.'])) {
2445 $content = $this->HTMLparser_TSbridge($content, $conf['HTMLparser.']);
2452 * Will split the content by a given token and treat the results separately
2453 * Automatically fills 'current' with a single result
2455 * @param string Input value undergoing processing in this function.
2456 * @param array stdWrap properties for split.
2457 * @return string The processed input value
2459 public function stdWrap_split($content = '', $conf = array()) {
2460 $content = $this->splitObj($content, $conf['split.']);
2466 * Will use the content as a mathematical term and calculate the result
2467 * Can be set to 1 to just get a calculated value or 'intval' to get the integer of the result
2469 * @param string Input value undergoing processing in this function.
2470 * @param array stdWrap properties for prioriCalc.
2471 * @return string The processed input value
2473 public function stdWrap_prioriCalc($content = '', $conf = array()) {
2474 $content = t3lib_div
::calcParenthesis($content);
2475 if ($conf['prioriCalc'] == 'intval')
2476 $content = intval($content);
2482 * Will return a character based on its position within the current character set
2484 * @param string Input value undergoing processing in this function.
2485 * @param array stdWrap properties for char.
2486 * @return string The processed input value
2488 public function stdWrap_char($content = '', $conf = array()) {
2489 $content = chr(intval($conf['char']));
2495 * Will return an integer value of the current content
2497 * @param string Input value undergoing processing in this function.
2498 * @param array stdWrap properties for intval.
2499 * @return string The processed input value
2501 public function stdWrap_intval($content = '', $conf = array()) {
2502 $content = intval($content);
2508 * Will return a formatted number based on configuration given as stdWrap properties
2510 * @param string Input value undergoing processing in this function.
2511 * @param array stdWrap properties for numberFormat.
2512 * @return string The processed input value
2514 public function stdWrap_numberFormat($content = '', $conf = array()) {
2515 $content = $this->numberFormat($content, $conf['numberFormat.']);
2521 * Will return a formatted date based on configuration given according to PHP date/gmdate properties
2522 * Will return gmdate when the property GMT returns true
2524 * @param string Input value undergoing processing in this function.
2525 * @param array stdWrap properties for date.
2526 * @return string The processed input value
2528 public function stdWrap_date($content = '', $conf = array()) {
2529 $content = ($conf['date.']['GMT'] ?
gmdate($conf['date'], $content) : date($conf['date'], $content));
2535 * Will return a formatted date based on configuration given according to PHP strftime/gmstrftime properties
2536 * Will return gmstrftime when the property GMT returns true
2538 * @param string Input value undergoing processing in this function.
2539 * @param array stdWrap properties for strftime.
2540 * @return string The processed input value
2542 public function stdWrap_strftime($content = '', $conf = array()) {
2543 $content = ($conf['strftime.']['GMT'] ?
gmstrftime($conf['strftime'], $content) : strftime($conf['strftime'], $content));
2544 $tmp_charset = $conf['strftime.']['charset'] ?
$conf['strftime.']['charset'] : $GLOBALS['TSFE']->localeCharset
;
2546 $content = $GLOBALS['TSFE']->csConv($content, $tmp_charset);
2553 * Will return the age of a given timestamp based on configuration given by stdWrap properties
2555 * @param string Input value undergoing processing in this function.
2556 * @param array stdWrap properties for age.
2557 * @return string The processed input value
2559 public function stdWrap_age($content = '', $conf = array()) {
2560 $content = $this->calcAge($GLOBALS['EXEC_TIME'] - $content, $conf['age']);
2566 * Will transform the content to be upper or lower case only
2567 * Leaves HTML tags untouched
2569 * @param string Input value undergoing processing in this function.
2570 * @param array stdWrap properties for case.
2571 * @return string The processed input value
2573 public function stdWrap_case($content = '', $conf = array()) {
2574 $content = $this->HTMLcaseshift($content, $conf['case']);
2580 * Will return the size of a given number in Bytes *
2582 * @param string Input value undergoing processing in this function.
2583 * @param array stdWrap properties for bytes.
2584 * @return string The processed input value
2586 public function stdWrap_bytes($content = '', $conf = array()) {
2587 $content = t3lib_div
::formatSize($content, $conf['bytes.']['labels']);
2593 * Will return a substring based on position information given by stdWrap properties
2595 * @param string Input value undergoing processing in this function.
2596 * @param array stdWrap properties for substring.
2597 * @return string The processed input value
2599 public function stdWrap_substring($content = '', $conf = array()) {
2600 $content = $this->substring($content, $conf['substring']);
2606 * Removes HTML tags based on stdWrap properties
2608 * @param string Input value undergoing processing in this function.
2609 * @param array stdWrap properties for removeBadHTML.
2610 * @return string The processed input value
2612 public function stdWrap_removeBadHTML($content = '', $conf = array()) {
2613 $content = $this->removeBadHTML($content, $conf['removeBadHTML.']);
2619 * Crops content to a given size while leaving HTML tags untouched
2621 * @param string Input value undergoing processing in this function.
2622 * @param array stdWrap properties for cropHTML.
2623 * @return string The processed input value
2625 public function stdWrap_cropHTML($content = '', $conf = array()) {
2626 $content = $this->cropHTML($content, $conf['cropHTML']);
2632 * Copmletely removes HTML tags from content
2634 * @param string Input value undergoing processing in this function.
2635 * @param array stdWrap properties for stripHtml.
2636 * @return string The processed input value
2638 public function stdWrap_stripHtml($content = '', $conf = array()) {
2639 $content = strip_tags($content);
2645 * Crops content to a given size without caring abhout HTML tags
2647 * @param string Input value undergoing processing in this function.
2648 * @param array stdWrap properties for crop.
2649 * @return string The processed input value
2651 public function stdWrap_crop($content = '', $conf = array()) {
2652 $content = $this->crop($content, $conf['crop']);
2658 * Encodes content to be used within URLs
2660 * @param string Input value undergoing processing in this function.
2661 * @param array stdWrap properties for rawUrlEncode.
2662 * @return string The processed input value
2664 public function stdWrap_rawUrlEncode($content = '', $conf = array()) {
2665 $content = rawurlencode($content);
2671 * Transforms HTML tags to readable text by replacing special characters with their HTML entity
2672 * When preserveEntities returns true, existing entities will be left untouched
2674 * @param string Input value undergoing processing in this function.
2675 * @param array stdWrap properties for htmlSpecalChars.
2676 * @return string The processed input value
2678 public function stdWrap_htmlSpecialChars($content = '', $conf = array()) {
2679 $content = htmlSpecialChars($content);
2680 if ($conf['htmlSpecialChars.']['preserveEntities'])
2681 $content = t3lib_div
::deHSCentities($content);
2687 * Searches for double line breaks and replaces them with the given value
2689 * @param string Input value undergoing processing in this function.
2690 * @param array stdWrap properties for doubleBrTag.
2691 * @return string The processed input value
2693 public function stdWrap_doubleBrTag($content = '', $conf = array()) {
2694 $content = preg_replace("/\r?\n[\t ]*\r?\n/", $conf['doubleBrTag'], $content);
2700 * Searches for single line breaks and replaces them with a <br /> tag
2702 * @param string Input value undergoing processing in this function.
2703 * @param array stdWrap properties for br.
2704 * @return string The processed input value
2706 public function stdWrap_br($content = '', $conf = array()) {
2707 $content = nl2br($content);
2713 * Searches for single line feeds and replaces them with the given value
2715 * @param string Input value undergoing processing in this function.
2716 * @param array stdWrap properties for brTag.
2717 * @return string The processed input value
2719 public function stdWrap_brTag($content = '', $conf = array()) {
2720 $content = str_replace(LF
, $conf['brTag'], $content);
2726 * Modifies text blocks by searching for lines which are not surrounded by HTML tags yet
2727 * and wrapping them with values given by stdWrap properties
2729 * @param string Input value undergoing processing in this function.
2730 * @param array stdWrap properties for erncapsLines.
2731 * @return string The processed input value
2733 public function stdWrap_encapsLines($content = '', $conf = array()) {
2734 $content = $this->encaps_lineSplit($content, $conf['encapsLines.']);
2740 * Transforms content into a CSV list to be used i.e. as keywords within a meta tag
2742 * @param string Input value undergoing processing in this function.
2743 * @param array stdWrap properties for keywords.
2744 * @return string The processed input value
2746 public function stdWrap_keywords($content = '', $conf = array()) {
2747 $content = $this->keywords($content);
2753 * First of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
2756 * @param string Input value undergoing processing in this function.
2757 * @param array stdWrap properties for innerWrap.
2758 * @return string The processed input value
2760 public function stdWrap_innerWrap($content = '', $conf = array()) {
2761 $content = $this->wrap($content, $conf['innerWrap']);
2767 * Second of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
2770 * @param string Input value undergoing processing in this function.
2771 * @param array stdWrap properties for innerWrap2.
2772 * @return string The processed input value
2774 public function stdWrap_innerWrap2($content = '', $conf = array()) {
2775 $content = $this->wrap($content, $conf['innerWrap2']);
2781 * A wrap formerly used to apply font tags to format the content
2782 * Still used by lib.stdheader although real font tags are not state of the art anymore
2785 * @param string Input value undergoing processing in this function.
2786 * @param array stdWrap properties for fontTag.
2787 * @return string The processed input value
2789 public function stdWrap_fontTag($content = '', $conf = array()) {
2790 $content = $this->wrap($content, $conf['fontTag']);
2796 * Adds tag attributes to any content that is a tag
2798 * @param string Input value undergoing processing in this function.
2799 * @param array stdWrap properties for addParams.
2800 * @return string The processed input value
2802 public function stdWrap_addParams($content = '', $conf = array()) {
2803 $content = $this->addParams($content, $conf['addParams.']);
2809 * Wraps content in font tags
2812 * @param string Input value undergoing processing in this function.
2813 * @param array stdWrap properties for textStyle.
2814 * @return string The processed input value
2816 public function stdWrap_textStyle($content = '', $conf = array()) {
2817 $content = $this->textStyle($content, $conf['textStyle.']);
2823 * Wraps content with table tags
2826 * @param string Input value undergoing processing in this function.
2827 * @param array stdWrap properties for tableStyle.
2828 * @return string The processed input value
2830 public function stdWrap_tableStyle($content = '', $conf = array()) {
2831 $content = $this->tableStyle($content, $conf['tableStyle.']);
2837 * Used to make lists of links to files
2840 * @param string Input value undergoing processing in this function.
2841 * @param array stdWrap properties for filelink.
2842 * @return string The processed input value
2844 public function stdWrap_filelink($content = '', $conf = array()) {
2845 $content = $this->filelink($content, $conf['filelink.']);
2851 * A content object that is prepended to the current content but between the innerWraps and the rest of the wraps
2853 * @param string Input value undergoing processing in this function.
2854 * @param array stdWrap properties for preCObject.
2855 * @return string The processed input value
2857 public function stdWrap_preCObject($content = '', $conf = array()) {
2858 $content = $this->cObjGetSingle($conf['preCObject'], $conf['preCObject.'], '/stdWrap/.preCObject') . $content;
2864 * A content object that is appended to the current content but between the innerWraps and the rest of the wraps
2866 * @param string Input value undergoing processing in this function.
2867 * @param array stdWrap properties for postCObject.
2868 * @return string The processed input value
2870 public function stdWrap_postCObject($content = '', $conf = array()) {
2871 $content .= $this->cObjGetSingle($conf['postCObject'], $conf['postCObject.'], '/stdWrap/.postCObject');
2877 * Wraps content with a div container having the style attribute text-align set to the given value
2880 * @param string Input value undergoing processing in this function.
2881 * @param array stdWrap properties for wrapAlign.
2882 * @return string The processed input value
2884 public function stdWrap_wrapAlign($content = '', $conf = array()) {
2885 $wrapAlign = trim($conf['wrapAlign']);
2887 $content = $this->wrap($content, '<div style="text-align:' . $wrapAlign . ';">|</div>');
2894 * Wraps the content with a link tag
2895 * URLs and other attributes are created automatically by the values given in the stdWrap properties
2898 * @param string Input value undergoing processing in this function.
2899 * @param array stdWrap properties for typolink.
2900 * @return string The processed input value
2902 public function stdWrap_typolink($content = '', $conf = array()) {
2903 $content = $this->typolink($content, $conf['typolink.']);
2909 * Returns a list of options available for a given field in the DB which has to be of the type select
2911 * @param string Input value undergoing processing in this function.
2912 * @param array stdWrap properties for TCAselectItem.
2913 * @return string The processed input value
2915 public function stdWrap_TCAselectItem($content = '', $conf = array()) {
2916 if (is_array($conf['TCAselectItem.'])) {
2917 $content = $this->TCAlookup($content, $conf['TCAselectItem.']);
2924 * Will add space before the current content
2925 * By default this is done with a clear.gif but it can be done with CSS margins by setting the property space.useDiv to true
2927 * @param string Input value undergoing processing in this function.
2928 * @param array stdWrap properties for spaceBefore and space.
2929 * @return string The processed input value
2931 public function stdWrap_spaceBefore($content = '', $conf = array()) {
2932 $content = $this->wrapSpace($content, trim($conf['spaceBefore']) . '|', $conf['space.']);
2938 * Will add space after the current content
2939 * By default this is done with a clear.gif but it can be done with CSS margins by setting the property space.useDiv to true
2941 * @param string Input value undergoing processing in this function.
2942 * @param array stdWrap properties for spaceAfter and space.
2943 * @return string The processed input value
2945 public function stdWrap_spaceAfter($content = '', $conf = array()) {
2946 $content = $this->wrapSpace($content, '|' . trim($conf['spaceAfter']), $conf['space.']);
2952 * Will add space before or after the current content
2953 * By default this is done with a clear.gif but it can be done with CSS margins by setting the property space.useDiv to true
2956 * @param string Input value undergoing processing in this function.
2957 * @param array stdWrap properties for space.
2958 * @return string The processed input value
2960 public function stdWrap_space($content = '', $conf = array()) {
2961 $content = $this->wrapSpace($content, trim($conf['space']), $conf['space.']);
2967 * This is the "mother" of all wraps
2968 * Third of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
2969 * Basically it will put additional content before and after the current content using a split character as a placeholder for the current content
2970 * The default split character is | but it can be replaced with other characters by the property splitChar
2971 * Any other wrap that does not have own splitChar settings will be using the default split char though
2973 * @param string Input value undergoing processing in this function.
2974 * @param array stdWrap properties for wrap.
2975 * @return string The processed input value
2977 public function stdWrap_wrap($content = '', $conf = array()) {
2978 $content = $this->wrap($content, $conf['wrap'], ($conf['wrap.']['splitChar'] ?
$conf['wrap.']['splitChar'] : '|'));
2984 * Fourth of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
2985 * The major difference to any other wrap is, that this one can make use of whitespace without trimming *
2987 * @param string Input value undergoing processing in this function.
2988 * @param array stdWrap properties for noTrimWrap.
2989 * @return string The processed input value
2991 public function stdWrap_noTrimWrap($content = '', $conf = array()) {
2992 $content = $this->noTrimWrap($content, $conf['noTrimWrap']);
2998 * Fifth of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
2999 * The default split character is | but it can be replaced with other characters by the property splitChar
3001 * @param string Input value undergoing processing in this function.
3002 * @param array stdWrap properties for wrap2.
3003 * @return string The processed input value
3005 public function stdWrap_wrap2($content = '', $conf = array()) {
3006 $content = $this->wrap($content, $conf['wrap2'], ($conf['wrap2.']['splitChar'] ?
$conf['wrap2.']['splitChar'] : '|'));
3012 * Sixth of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
3013 * Can fetch additional content the same way data does (i.e. {field:whatever}) and apply it to the wrap before that is applied to the content
3015 * @param string Input value undergoing processing in this function.
3016 * @param array stdWrap properties for dataWrap.
3017 * @return string The processed input value
3019 public function stdWrap_dataWrap($content = '', $conf = array()) {
3020 $content = $this->dataWrap($content, $conf['dataWrap']);
3026 * A content object that will be prepended to the current content after most of the wraps have already been applied
3028 * @param string Input value undergoing processing in this function.
3029 * @param array stdWrap properties for prepend.
3030 * @return string The processed input value
3032 public function stdWrap_prepend($content = '', $conf = array()) {
3033 $content = $this->cObjGetSingle($conf['prepend'], $conf['prepend.'], '/stdWrap/.prepend') . $content;
3039 * A content object that will be appended to the current content after most of the wraps have already been applied
3041 * @param string Input value undergoing processing in this function.
3042 * @param array stdWrap properties for append.
3043 * @return string The processed input value
3045 public function stdWrap_append($content = '', $conf = array()) {
3046 $content .= $this->cObjGetSingle($conf['append'], $conf['append.'], '/stdWrap/.append');
3052 * Seventh of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
3053 * The default split character is | but it can be replaced with other characters by the property splitChar
3055 * @param string Input value undergoing processing in this function.
3056 * @param array stdWrap properties for wrap3.
3057 * @return string The processed input value
3059 public function stdWrap_wrap3($content = '', $conf = array()) {
3060 $content = $this->wrap($content, $conf['wrap3'], ($conf['wrap3.']['splitChar'] ?
$conf['wrap3.']['splitChar'] : '|'));
3066 * Eighth of a set of different wraps which will be applied in a certain order before or after other functions that modify the content
3068 * @param string Input value undergoing processing in this function.
3069 * @param array stdWrap properties for outerWrap.
3070 * @return string The processed input value
3072 public function stdWrap_outerWrap($content = '', $conf = array()) {
3073 $content = $this->wrap($content, $conf['outerWrap']);
3079 * Can fetch additional content the same way data does and replaces any occurence of {field:whatever} with this content
3081 * @param string Input value undergoing processing in this function.
3082 * @param array stdWrap properties for insertData.
3083 * @return string The processed input value
3085 public function stdWrap_insertData($content = '', $conf = array()) {
3086 $content = $this->insertData($content);
3092 * Creates a so called offset table around the content
3093 * Still here for historical reasons even not used too much nowadays
3095 * @param string Input value undergoing processing in this function.
3096 * @param array stdWrap properties for offsetWrap.
3097 * @return string The processed input value
3099 public function stdWrap_offsetWrap($content = '', $conf = array()) {
3100 $controlTable = t3lib_div
::makeInstance('tslib_tableOffset');
3101 if ($conf['offsetWrap.']['tableParams'] ||
$conf['offsetWrap.']['tableParams.']) {
3102 $controlTable->tableParams
= isset($conf['offsetWrap.']['tableParams.'])
3103 ?
$this->stdWrap($conf['offsetWrap.']['tableParams'], $conf['offsetWrap.']['tableParams.'])
3104 : $conf['offsetWrap.']['tableParams'];
3106 if ($conf['offsetWrap.']['tdParams'] ||
$conf['offsetWrap.']['tdParams.']) {
3107 $controlTable->tdParams
= ' ' . (isset($conf['offsetWrap.']['tdParams.'])
3108 ?
$this->stdWrap($conf['offsetWrap.']['tdParams'], $conf['offsetWrap.']['tdParams.'])
3109 : $conf['offsetWrap.']['tdParams']);
3111 $content = $controlTable->start($content, $conf['offsetWrap']);
3112 if ($conf['offsetWrap.']['stdWrap.']) {
3113 $content = $this->stdWrap($content, $conf['offsetWrap.']['stdWrap.']);
3120 * Will execute a user function after the content has been modified by any other stdWrap function
3122 * @param string Input value undergoing processing in this function.
3123 * @param array stdWrap properties for postUserFunc.
3124 * @return string The processed input value
3126 public function stdWrap_postUserFunc($content = '', $conf = array()) {
3127 $content = $this->callUserFunction($conf['postUserFunc'], $conf['postUserFunc.'], $content);