Fixed bug #15928: Replace the current if-construct of stdWrap with real functions...
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / tslib / class.tslib_content.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2010 Kasper Skårhøj (kasperYYYY@typo3.com)
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 * A copy is found in the textfile GPL.txt and important notices to the license
17 * from the author is found in LICENSE.txt distributed with these scripts.
18 *
19 *
20 * This script is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
24 *
25 * This copyright notice MUST APPEAR in all copies of the script!
26 ***************************************************************/
27 /**
28 * Contains classes for Content Rendering based on TypoScript Template configuration
29 *
30 * $Id$
31 * Revised for TYPO3 3.6 June/2003 by Kasper Skårhøj
32 * XHTML compliant
33 *
34 * class tslib_cObj : All main TypoScript features, rendering of content objects (cObjects). This class is the backbone of TypoScript Template rendering.
35 * class tslib_controlTable : Makes a table CTABLE (TS cObject)
36 * class tslib_tableOffset : Makes a table-offset (TS)
37 * class tslib_frameset : Generates framesets (TS)
38 *
39 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
40 */
41 /**
42 * [CLASS/FUNCTION INDEX of SCRIPT]
43 *
44 *
45 *
46 * 256: class tslib_cObj
47 * 353: function start($data,$table='')
48 * 387: function setParent($data,$currentRecord)
49 *
50 * SECTION: CONTENT_OBJ:
51 * 412: function getCurrentVal()
52 * 423: function setCurrentVal($value)
53 * 436: function cObjGet($setup,$addKey='')
54 * 460: function cObjGetSingle($name,$conf,$TSkey='__')
55 *
56 * SECTION: Functions rendering content objects (cObjects)
57 * 629: function HTML($conf)
58 * 640: function TEXT($conf)
59 * 651: function CLEARGIF($conf)
60 * 670: function COBJ_ARRAY($conf,$ext='')
61 * 706: function USER($conf,$ext='')
62 * 733: function FILE($conf)
63 * 749: function IMAGE($conf)
64 * 768: function IMG_RESOURCE($conf)
65 * 780: function IMGTEXT($conf)
66 * 1203: function CONTENT($conf)
67 * 1290: function RECORDS($conf)
68 * 1370: function HMENU($conf)
69 * 1402: function CTABLE ($conf)
70 * 1440: function OTABLE ($conf)
71 * 1455: function COLUMNS ($conf)
72 * 1534: function HRULER ($conf)
73 * 1559: function CASEFUNC ($conf)
74 * 1584: function LOAD_REGISTER($conf,$name)
75 * 1624: function FORM($conf,$formData='')
76 * 2145: function SEARCHRESULT($conf)
77 * 2311: function PHP_SCRIPT($conf,$ext='')
78 * 2354: function TEMPLATE($conf)
79 * 2505: function MULTIMEDIA($conf)
80 *
81 * SECTION: Various helper functions for content objects:
82 * 2592: function getSlidePids($pidList, $pidConf)
83 * 2623: function getFieldDefaultValue($noValueInsert, $fieldName, $defaultVal)
84 * 2641: function cImage($file,$conf)
85 * 2669: function getBorderAttr($borderAttr)
86 * 2685: function imageLinkWrap($string,$imageFile,$conf)
87 * 2765: function fileResource($fName, $addParams='alt="" title=""')
88 * 2788: function lastChanged($tstamp)
89 * 2805: function linkWrap($content,$wrap)
90 * 2824: function getAltParam($conf, $longDesc=TRUE)
91 * 2859: function cleanFormName($name)
92 * 2875: function getATagParams($conf, $addGlobal=1)
93 *
94 * SECTION: HTML template processing functions
95 * 2922: function getSubpart($content, $marker)
96 * 2938: function substituteSubpart($content,$marker,$subpartContent,$recursive=1)
97 * 2951: function substituteMarker($content,$marker,$markContent)
98 * 2971: function substituteMarkerArrayCached($content,$markContentArray=array(),$subpartContentArray=array(),$wrappedSubpartContentArray=array())
99 * 3069: function substituteMarkerArray($content,$markContentArray,$wrap='',$uppercase=0)
100 * 3081: function substituteMarkerInObject(&$tree, $markContentArray)
101 * 3104: function fillInMarkerArray($markContentArray, $row, $fieldList='', $nl2br=TRUE, $prefix='FIELD_', $HSC=FALSE)
102 *
103 * SECTION: "stdWrap" + sub functions
104 * 3167: function stdWrap($content,$conf)
105 * 3364: function numRows($conf)
106 * 3388: function listNum($content,$listNum,$char)
107 * 3408: function checkIf($conf)
108 * 3471: function filelist($data)
109 * 3553: function clean_directory($theDir)
110 * 3571: function HTMLparser_TSbridge($theValue, $conf)
111 * 3585: function dataWrap($content,$wrap)
112 * 3598: function insertData($str)
113 * 3628: function prefixComment($str,$conf,$content)
114 * 3652: function substring($content,$options)
115 * 3670: function crop($content,$options)
116 * 3702: function removeBadHTML($text, $conf)
117 * 3746: function textStyle($theValue, $conf)
118 * 3813: function tableStyle($theValue, $conf)
119 * 3854: function addParams($content,$conf)
120 * 3895: function filelink($theValue, $conf)
121 * 3966: function locDataJU($jumpUrl,$conf)
122 * 3997: function calc($val)
123 * 4026: function calcIntExplode($delim, $string)
124 * 4046: function splitObj($value, $conf)
125 * 4108: function parseFunc($theValue, $conf, $ref='')
126 * 4218: function _parseFunc ($theValue, $conf)
127 * 4424: function encaps_lineSplit($theValue, $conf)
128 * 4507: function http_makelinks($data,$conf)
129 * 4574: function mailto_makelinks($data,$conf)
130 * 4617: function getImgResource($file,$fileArray)
131 *
132 * SECTION: Data retrieval etc.
133 * 4810: function getFieldVal($field)
134 * 4830: function getData($string,$fieldArray)
135 * 4975: function rootLineValue($key,$field,$slideBack=0,$altRootLine='')
136 * 4997: function getGlobal($var, $source=NULL)
137 * 5033: function getKey($key,$arr)
138 * 5056: function TCAlookup($inputValue,$conf)
139 *
140 * SECTION: Link functions (typolink)
141 * 5116: function typoLink($linktxt, $conf)
142 * 5481: function typoLink_URL($conf)
143 * 5499: function getTypoLink($label,$params,$urlParameters=array(),$target='')
144 * 5526: function getTypoLink_URL($params,$urlParameters=array(),$target='')
145 * 5538: function typolinkWrap($conf)
146 * 5551: function currentPageUrl($urlParameters=array(),$id=0)
147 * 5564: function getClosestMPvalueForPage($pageId, $raw=FALSE)
148 * 5619: function getMailTo($mailAddress,$linktxt,$initP='?')
149 * 5658: function getQueryArguments($conf,$overruleQueryArgs=array(),$forceArgs=FALSE)
150 *
151 * SECTION: Miscellaneous functions, stand alone
152 * 5754: function wrap($content,$wrap,$char='|')
153 * 5770: function noTrimWrap($content,$wrap)
154 * 5784: function wrapSpace($content, $wrap)
155 * 5810: function callUserFunction($funcName,$conf,$content)
156 * 5851: function processParams($params)
157 * 5869: function keywords($content)
158 * 5886: function caseshift($theValue, $case)
159 * 5911: function HTMLcaseshift($theValue, $case)
160 * 5940: function bytes($sizeInBytes,$labels)
161 * 5951: function calcAge($seconds,$labels)
162 * 5983: function sendNotifyEmail($msg, $recipients, $cc, $email_from, $email_fromName='', $replyTo='')
163 * 6010: function URLqMark($url,$params)
164 * 6026: function checkEmail($email)
165 * 6038: function clearTSProperties($TSArr,$propList)
166 * 6057: function mergeTSRef($confArr,$prop)
167 * 6080: function joinTSarrays($conf,$old_conf)
168 * 6103: function gifBuilderTextBox($gifbuilderConf, $conf, $text)
169 * 6159: function linebreaks($string,$chars,$maxLines=0)
170 * 6190: function getUpdateJS($dataArray, $formName, $arrPrefix, $fieldList)
171 *
172 * SECTION: Database functions, making of queries
173 * 6260: function DBgetDelete($table, $uid, $doExec=FALSE)
174 * 6292: function DBgetUpdate($table, $uid, $dataArr, $fieldList, $doExec=FALSE)
175 * 6334: function DBgetInsert($table, $pid, $dataArr, $fieldList, $doExec=FALSE)
176 * 6371: function DBmayFEUserEdit($table,$row, $feUserRow, $allowedGroups='',$feEditSelf=0)
177 * 6411: function DBmayFEUserEditSelect($table,$feUserRow,$allowedGroups='',$feEditSelf=0)
178 * 6451: function enableFields($table,$show_hidden=0)
179 * 6475: function getTreeList($id,$depth,$begin=0,$dontCheckEnableFields=FALSE,$addSelectFields='',$moreWhereClauses='', $prevId_array=array(), $recursionLevel=0)
180 * 6583: function whereSelectFromList($field,$value)
181 * 6601: function exec_mm_query($select,$local_table,$mm_table,$foreign_table,$whereClause='',$groupBy='',$orderBy='',$limit='')
182 * 6628: function exec_mm_query_uidList($select,$local_table_uidlist,$mm_table,$foreign_table='',$whereClause='',$groupBy='',$orderBy='',$limit='')
183 * 6649: function searchWhere($sw,$searchFieldList,$searchTable='')
184 * 6685: function exec_getQuery($table, $conf)
185 * 6703: function getQuery($table, $conf, $returnQueryArray=FALSE)
186 * 6783: function getWhere($table,$conf, $returnQueryArray=FALSE)
187 * 6878: function checkPidArray($listArr)
188 * 6902: function checkPid($uid)
189 *
190 * SECTION: Frontend editing functions
191 * 6959: function editPanel($content, $conf, $currentRecord='', $dataArr=array())
192 * 7146: function editIcons($content,$params, $conf=array(), $currentRecord='', $dataArr=array(),$addUrlParamStr='')
193 * 7228: function editPanelLinkWrap($string,$formName,$cmd,$currentRecord='',$confirm='',$nPid='')
194 * 7270: function editPanelLinkWrap_doWrap($string,$url,$currentRecord)
195 * 7298: function editPanelPreviewBorder($table,$row,$content,$thick,$conf=array())
196 * 7320: function isDisabled($table,$row)
197 *
198 *
199 * 7351: class tslib_frameset
200 * 7361: function make($setup)
201 * 7398: function frameParams($setup, $typeNum)
202 * 7426: function framesetParams($setup)
203 *
204 *
205 * 7459: class tslib_tableOffset
206 * 7471: function start($content,$offset)
207 *
208 *
209 * 7549: class tslib_controlTable
210 * 7584: function start($offset,$cMargins)
211 *
212 * TOTAL FUNCTIONS: 135
213 * (This index is automatically created/updated by the extension "extdeveval")
214 *
215 */
216
217
218
219 /**
220 * This class contains all main TypoScript features.
221 * This includes the rendering of TypoScript content objects (cObjects).
222 * Is the backbone of TypoScript Template rendering.
223 *
224 * There are lots of functions you can use from your include-scripts.
225 * The class "tslib_cObj" is normally instantiated and referred to as "cObj".
226 * When you call your own PHP-code typically through a USER or USER_INT cObject then it is this class that instantiates the object and calls the main method. Before it does so it will set (if you are using classes) a reference to itself in the internal variable "cObj" of the object. Thus you can access all functions and data from this class by $this->cObj->... from within you classes written to be USER or USER_INT content objects.
227 *
228 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
229 * @package TYPO3
230 * @subpackage tslib
231 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&cHash=4ad9d7acb4
232 */
233 class tslib_cObj {
234 var $align = array(
235 'center', 'right', 'left'
236 );
237
238 /**
239 * stdWrap functions in their correct order
240 *
241 * @see stdWrap()
242 */
243 var $stdWrapOrder = array(
244 'stdWrapPreProcess' => 1, // this is a placeholder for the first Hook
245 'setContentToCurrent' => 1,
246 'setContentToCurrent.' => 1,
247 'setCurrent' => 1,
248 'setCurrent.' => 1,
249 'lang' => 1,
250 'lang.' => 1,
251 'data' => 1,
252 'data.' => 1,
253 'field' => 1,
254 'field.' => 1,
255 'current' => 1,
256 'current.' => 1,
257 'cObject' => 1,
258 'cObject.' => 1,
259 'numRows' => 1,
260 'numRows.' => 1,
261 'filelist' => 1,
262 'filelist.' => 1,
263 'preUserFunc' => 1,
264 'preUserFunc.' => 1,
265 'stdWrapOverride' => 1, // this is a placeholder for the second Hook
266 'override' => 1,
267 'override.' => 1,
268 'preIfEmptyListNum' => 1,
269 'preIfEmptyListNum.' => 1,
270 'ifEmpty' => 1,
271 'ifEmpty.' => 1,
272 'ifBlank' => 1,
273 'ifBlank.' => 1,
274 'listNum' => 1,
275 'listNum.' => 1,
276 'trim' => 1,
277 'trim.' => 1,
278 'stdWrap' => 1,
279 'stdWrap.' => 1,
280 'stdWrapProcess' => 1, // this is a placeholder for the third Hook
281 'required' => 1,
282 'required.' => 1,
283 'if' => 1,
284 'if.' => 1,
285 'fieldRequired' => 1,
286 'fieldRequired.' => 1,
287 'csConv' => 1,
288 'csConv.' => 1,
289 'parseFunc' => 1,
290 'parseFunc.' => 1,
291 'HTMLparser' => 1,
292 'HTMLparser.' => 1,
293 'split' => 1,
294 'split.' => 1,
295 'prioriCalc' => 1,
296 'prioriCalc.' => 1,
297 'char' => 1,
298 'char.' => 1,
299 'intval' => 1,
300 'intval.' => 1,
301 'numberFormat' => 1,
302 'numberFormat.' => 1,
303 'date' => 1,
304 'date.' => 1,
305 'strftime' => 1,
306 'strftime.' => 1,
307 'age' => 1,
308 'age.' => 1,
309 'case' => 1,
310 'case.' => 1,
311 'bytes' => 1,
312 'bytes.' => 1,
313 'substring' => 1,
314 'substring.' => 1,
315 'removeBadHTML' => 1,
316 'removeBadHTML.' => 1,
317 'cropHTML' => 1,
318 'cropHTML.' => 1,
319 'stripHtml' => 1,
320 'stripHtml.' => 1,
321 'crop' => 1,
322 'crop.' => 1,
323 'rawUrlEncode' => 1,
324 'rawUrlEncode.' => 1,
325 'htmlSpecialChars' => 1,
326 'htmlSpecialChars.' => 1,
327 'doubleBrTag' => 1,
328 'doubleBrTag.' => 1,
329 'br' => 1,
330 'br.' => 1,
331 'brTag' => 1,
332 'brTag.' => 1,
333 'encapsLines' => 1,
334 'encapsLines.' => 1,
335 'keywords' => 1,
336 'keywords.' => 1,
337 'innerWrap' => 1,
338 'innerWrap.' => 1,
339 'innerWrap2' => 1,
340 'innerWrap2.' => 1,
341 'fontTag' => 1,
342 'fontTag.' => 1,
343 'addParams' => 1,
344 'addParams.' => 1,
345 'textStyle' => 1,
346 'textStyle.' => 1,
347 'tableStyle' => 1,
348 'tableStyle.' => 1,
349 'filelink' => 1,
350 'filelink.' => 1,
351 'preCObject' => 1,
352 'preCObject.' => 1,
353 'postCObject' => 1,
354 'postCObject.' => 1,
355 'wrapAlign' => 1,
356 'wrapAlign.' => 1,
357 'typolink' => 1,
358 'typolink.' => 1,
359 'TCAselectItem' => 1,
360 'TCAselectItem.' => 1,
361 'space' => 1,
362 'space.' => 1,
363 'spaceBefore' => 1,
364 'spaceBefore.' => 1,
365 'spaceAfter' => 1,
366 'spaceAfter.' => 1,
367 'wrap' => 1,
368 'wrap.' => 1,
369 'noTrimWrap' => 1,
370 'noTrimWrap.' => 1,
371 'wrap2' => 1,
372 'wrap2.' => 1,
373 'dataWrap' => 1,
374 'dataWrap.' => 1,
375 'prepend' => 1,
376 'prepend.' => 1,
377 'append' => 1,
378 'append.' => 1,
379 'wrap3' => 1,
380 'wrap3.' => 1,
381 'outerWrap' => 1,
382 'outerWrap.' => 1,
383 'insertData' => 1,
384 'insertData.' => 1,
385 'offsetWrap' => 1,
386 'offsetWrap.' => 1,
387 'postUserFunc' => 1,
388 'postUserFunc.' => 1,
389 'postUserFuncInt' => 1,
390 'postUserFuncInt.' => 1,
391 'prefixComment' => 1,
392 'prefixComment.' => 1,
393 'editIcons' => 1,
394 'editIcons.' => 1,
395 'editPanel' => 1,
396 'editPanel.' => 1,
397 'stdWrapPostProcess' => 1, // this is a placeholder for the last Hook
398 'debug' => 1,
399 'debug.' => 1,
400 'debugFunc' => 1,
401 'debugFunc.' => 1,
402 'debugData' => 1,
403 'debugData.' => 1
404 );
405
406 /**
407 * Holds ImageMagick parameters and extensions used for compression
408 *
409 * @see IMGTEXT()
410 *
411 * 0= Default
412 * 1= Dont change! (removes all parameters for the image_object!!)
413 * 1x = GIFs
414 * 2x = JPGs
415 */
416 var $image_compression = array(
417 10 => array(
418 'params' => '', 'ext' => 'gif'
419 ),
420 11 => array(
421 'params' => '-colors 128', 'ext' => 'gif'
422 ),
423 12 => array(
424 'params' => '-colors 64', 'ext' => 'gif'
425 ),
426 13 => array(
427 'params' => '-colors 32', 'ext' => 'gif'
428 ),
429 14 => array(
430 'params' => '-colors 16', 'ext' => 'gif'
431 ),
432 15 => array(
433 'params' => '-colors 8', 'ext' => 'gif'
434 ),
435
436 20 => array(
437 'params' => '-quality 100', 'ext' => 'jpg'
438 ),
439 21 => array(
440 'params' => '-quality 90', 'ext' => 'jpg'
441 ),
442 22 => array(
443 'params' => '-quality 80', 'ext' => 'jpg'
444 ),
445 23 => array(
446 'params' => '-quality 70', 'ext' => 'jpg'
447 ),
448 24 => array(
449 'params' => '-quality 60', 'ext' => 'jpg'
450 ),
451 25 => array(
452 'params' => '-quality 50', 'ext' => 'jpg'
453 ),
454 26 => array(
455 'params' => '-quality 40', 'ext' => 'jpg'
456 ),
457 27 => array(
458 'params' => '-quality 30', 'ext' => 'jpg'
459 ),
460 28 => array(
461 'params' => '-quality 20', 'ext' => 'jpg'
462 ),
463
464 30 => array(
465 'params' => '-colors 256', 'ext' => 'png'
466 ),
467 31 => array(
468 'params' => '-colors 128', 'ext' => 'png'
469 ),
470 32 => array(
471 'params' => '-colors 64', 'ext' => 'png'
472 ),
473 33 => array(
474 'params' => '-colors 32', 'ext' => 'png'
475 ),
476 34 => array(
477 'params' => '-colors 16', 'ext' => 'png'
478 ),
479 35 => array(
480 'params' => '-colors 8', 'ext' => 'png'
481 ),
482 39 => array(
483 'params' => '', 'ext' => 'png'
484 ),
485 );
486
487 /**
488 * ImageMagick parameters for image effects
489 *
490 * @see IMGTEXT()
491 */
492 var $image_effects = array(
493 1 => '-rotate 90',
494 2 => '-rotate 270',
495 3 => '-rotate 180',
496 10 => '-colorspace GRAY',
497 11 => '-sharpen 70',
498 20 => '-normalize',
499 23 => '-contrast',
500 25 => '-gamma 1.3',
501 26 => '-gamma 0.8'
502 );
503
504 /**
505 * Loaded with the current data-record.
506 *
507 * If the instance of this class is used to render records from the database those records are found in this array.
508 * The function stdWrap has TypoScript properties that fetch field-data from this array.
509 * @see init()
510 */
511 var $data = array();
512 protected $table = '';
513 var $oldData = array(); // Used for backup...
514 var $alternativeData = ''; // If this is set with an array before stdWrap, it's used instead of $this->data in the data-property in stdWrap
515 var $parameters = array(); // Used by the parseFunc function and is loaded with tag-parameters when parsing tags.
516 var $currentValKey = 'currentValue_kidjls9dksoje';
517 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.
518 var $currentRecordTotal = 0; // Set in cObj->RECORDS and cObj->CONTENT to the current number of records selected in a query.
519 var $currentRecordNumber = 0; // Incremented in cObj->RECORDS and cObj->CONTENT before each record rendering.
520 var $parentRecordNumber = 0; // Incremented in parent cObj->RECORDS and cObj->CONTENT before each record rendering.
521 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.
522 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.
523
524
525 // internal
526 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)
527 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.
528 var $checkPid_badDoktypeList = '255';
529 var $lastTypoLinkUrl = ''; // This will be set by typoLink() to the url of the most recent link created.
530 var $lastTypoLinkTarget = ''; // DO. link target.
531 var $lastTypoLinkLD = array();
532 var $substMarkerCache = array(); // Caching substituteMarkerArrayCached function
533 var $recordRegister = array(); // array that registers rendered content elements (or any table) to make sure they are not rendered recursively!
534 var $cObjHookObjectsArr = array(); // Containig hooks for userdefined cObjects
535 protected $stdWrapHookObjects = array(); // Containing hook objects for stdWrap
536 protected $getImgResourceHookObjects; // Containing hook objects for getImgResource
537
538
539 /**
540 * Set to TRUE by doConvertToUserIntObject() if USER object wants to become USER_INT
541 */
542 protected $doConvertToUserIntObject = FALSE;
543
544 /**
545 * Indicates current object type. Can hold one of OBJECTTYPE_ constants or FALSE.
546 * The value is set and reset inside USER() function. Any time outside of
547 * USER() it is FALSE.
548 */
549 protected $userObjectType = FALSE;
550
551 /**
552 * Indicates that object type is USER.
553 *
554 * @see tslib_cObjh::$userObjectType
555 */
556 const OBJECTTYPE_USER_INT = 1;
557
558 /**
559 * Indicates that object type is USER.
560 *
561 * @see tslib_cObjh::$userObjectType
562 */
563 const OBJECTTYPE_USER = 2;
564
565 /**
566 * Class constructor.
567 * Well, it has to be called manually since it is not a real constructor function.
568 * 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.
569 *
570 * @param array $data the record data that is rendered.
571 * @param string $table the table that the data record is from.
572 * @return void
573 */
574 function start($data, $table = '') {
575 global $TYPO3_CONF_VARS;
576 $this->data = $data;
577 $this->table = $table;
578 $this->currentRecord = $table ? $table . ':' . $this->data['uid'] : '';
579 $this->parameters = array();
580 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClass'])) {
581 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClass'] as $classArr) {
582 $this->cObjHookObjectsArr[$classArr[0]] = t3lib_div::getUserObj($classArr[1]);
583 }
584 }
585
586 $this->stdWrapHookObjects = array();
587 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['stdWrap'])) {
588 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['stdWrap'] as $classData) {
589 $hookObject = t3lib_div::getUserObj($classData);
590
591 if (!($hookObject instanceof tslib_content_stdWrapHook)) {
592 throw new UnexpectedValueException(
593 '$hookObject must implement interface tslib_content_stdWrapHook',
594 1195043965
595 );
596 }
597
598 $this->stdWrapHookObjects[] = $hookObject;
599 }
600 }
601
602 if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['postInit'])) {
603 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['postInit'] as $classData) {
604 $postInitializationProcessor = t3lib_div::getUserObj($classData);
605
606 if (!($postInitializationProcessor instanceof tslib_content_PostInitHook)) {
607 throw new UnexpectedValueException(
608 '$postInitializationProcessor must implement interface tslib_content_PostInitHook',
609 1274563549
610 );
611 }
612
613 $postInitializationProcessor->postProcessContentObjectInitialization($this);
614 }
615 }
616 }
617
618 /**
619 * Gets the 'getImgResource' hook objects.
620 * The first call initializes the accordant objects.
621 *
622 * @return array The 'getImgResource' hook objects (if any)
623 */
624 protected function getGetImgResourceHookObjects() {
625 if (!isset($this->getImgResourceHookObjects)) {
626 $this->getImgResourceHookObjects = array();
627
628 if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['getImgResource'])) {
629 foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['getImgResource'] as $classData) {
630 $hookObject = t3lib_div::getUserObj($classData);
631
632 if (!($hookObject instanceof tslib_cObj_getImgResourceHook)) {
633 throw new UnexpectedValueException(
634 '$hookObject must implement interface tslib_cObj_getImgResourceHook',
635 1218636383
636 );
637 }
638
639 $this->getImgResourceHookObjects[] = $hookObject;
640 }
641 }
642 }
643
644 return $this->getImgResourceHookObjects;
645 }
646
647 /**
648 * Sets the internal variable parentRecord with information about current record.
649 * 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.
650 *
651 * @param array $data: The record array
652 * @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.
653 * @return void
654 * @access private
655 */
656 function setParent($data, $currentRecord) {
657 $this->parentRecord = array(
658 'data' => $data,
659 'currentRecord' => $currentRecord
660 );
661 }
662
663
664
665 /***********************************************
666 *
667 * CONTENT_OBJ:
668 *
669 ***********************************************/
670
671 /**
672 * Returns the "current" value.
673 * 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.
674 * It's like "load accumulator" in the good old C64 days... basically a "register" you can use as you like.
675 * 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.
676 *
677 * @return mixed The "current" value
678 */
679 function getCurrentVal() {
680 return $this->data[$this->currentValKey];
681 }
682
683 /**
684 * Sets the "current" value.
685 *
686 * @param mixed The variable that you want to set as "current"
687 * @return void
688 * @see getCurrentVal()
689 */
690 function setCurrentVal($value) {
691 $this->data[$this->currentValKey] = $value;
692 }
693
694 /**
695 * Rendering of a "numerical array" of cObjects from TypoScript
696 * Will call ->cObjGetSingle() for each cObject found and accumulate the output.
697 *
698 * @param array $setup: array with cObjects as values.
699 * @param string $addKey: A prefix for the debugging information
700 * @return string Rendered output from the cObjects in the array.
701 * @see cObjGetSingle()
702 */
703 function cObjGet($setup, $addKey = '') {
704 if (is_array($setup)) {
705 $sKeyArray = t3lib_TStemplate::sortedKeyList($setup);
706 $content = '';
707 foreach ($sKeyArray as $theKey) {
708 $theValue = $setup[$theKey];
709 if (intval($theKey) && !strstr($theKey, '.')) {
710 $conf = $setup[$theKey . '.'];
711 $content .= $this->cObjGetSingle($theValue, $conf, $addKey . $theKey); // Get the contentObject
712 }
713 }
714 return $content;
715 }
716 }
717
718 /**
719 * Renders a content object
720 *
721 * @param string The content object name, eg. "TEXT" or "USER" or "IMAGE"
722 * @param array The array with TypoScript properties for the content object
723 * @param string A string label used for the internal debugging tracking.
724 * @return string cObject output
725 * @example http://typo3.org/doc.0.html?&encryptionKey=&tx_extrepmgm_pi1[extUid]=267&tx_extrepmgm_pi1[tocEl]=153&cHash=7e74f4d331
726 */
727 function cObjGetSingle($name, $conf, $TSkey = '__') {
728 global $TYPO3_CONF_VARS;
729
730 $content = '';
731 // Checking that the function is not called eternally. This is done by interrupting at a depth of 100
732 $GLOBALS['TSFE']->cObjectDepthCounter--;
733 if ($GLOBALS['TSFE']->cObjectDepthCounter > 0) {
734 $name = trim($name);
735 if ($GLOBALS['TT']->LR)
736 $GLOBALS['TT']->push($TSkey, $name);
737
738 // Checking if the COBJ is a reference to another object. (eg. name of 'blabla.blabla = < styles.something')
739 if (substr($name, 0, 1) == '<') {
740 $key = trim(substr($name, 1));
741 $cF = t3lib_div::makeInstance('t3lib_TSparser');
742 // $name and $conf is loaded with the referenced values.
743 $old_conf = $conf;
744 list ($name, $conf) = $cF->getVal($key, $GLOBALS['TSFE']->tmpl->setup);
745 if (is_array($old_conf) && count($old_conf)) {
746 $conf = $this->joinTSarrays($conf, $old_conf);
747 }
748 // Getting the cObject
749 $GLOBALS['TT']->incStackPointer();
750 $content .= $this->cObjGetSingle($name, $conf, $key);
751 $GLOBALS['TT']->decStackPointer();
752 } else {
753
754 $hooked = FALSE;
755 // Application defined cObjects
756 foreach ($this->cObjHookObjectsArr as $cObjName => $hookObj) {
757 if (($name === $cObjName) && method_exists($hookObj, 'cObjGetSingleExt')) {
758 $content .= $hookObj->cObjGetSingleExt($name, $conf, $TSkey, $this);
759 $hooked = TRUE;
760 }
761 }
762 if (!$hooked) {
763 // Traditional Content Object branching:
764 switch ($name) {
765 case 'COBJ_ARRAY' :
766 case 'COA' :
767 $content .= $this->COBJ_ARRAY($conf);
768 break;
769 case 'COA_INT' :
770 $content .= $this->COBJ_ARRAY($conf, 'INT');
771 break;
772 case 'HTML' :
773 $content .= $this->HTML($conf);
774 break;
775 case 'TEXT' :
776 $content .= $this->TEXT($conf);
777 break;
778 case 'CLEARGIF' :
779 $content .= $this->CLEARGIF($conf);
780 break;
781 case 'FILE' :
782 $content .= $this->FILE($conf);
783 break;
784 case 'IMAGE' :
785 $content .= $this->IMAGE($conf);
786 break;
787 case 'IMG_RESOURCE' :
788 $content .= $this->IMG_RESOURCE($conf);
789 break;
790 case 'IMGTEXT' :
791 $content .= $this->IMGTEXT($conf);
792 break;
793 case 'CONTENT' :
794 $content .= $this->CONTENT($conf);
795 break;
796 case 'RECORDS' :
797 $content .= $this->RECORDS($conf);
798 break;
799 case 'HMENU' :
800 $content .= $this->HMENU($conf);
801 break;
802 case 'CTABLE' :
803 $content .= $this->CTABLE($conf);
804 break;
805 case 'OTABLE' :
806 $content .= $this->OTABLE($conf);
807 break;
808 case 'COLUMNS' :
809 $content .= $this->COLUMNS($conf);
810 break;
811 case 'HRULER' :
812 $content .= $this->HRULER($conf);
813 break;
814 case 'CASE' :
815 $content .= $this->CASEFUNC($conf);
816 break;
817 case 'LOAD_REGISTER' :
818 case 'RESTORE_REGISTER' :
819 $this->LOAD_REGISTER($conf, $name);
820 break;
821 case 'FORM' :
822 $content .= $this->FORM($conf);
823 break;
824 case 'SEARCHRESULT' :
825 $content .= $this->SEARCHRESULT($conf);
826 break;
827 case 'PHP_SCRIPT' :
828 $content .= $this->PHP_SCRIPT($conf);
829 break;
830 case 'PHP_SCRIPT_EXT' :
831 $content .= $this->PHP_SCRIPT($conf, 'EXT');
832 break;
833 case 'PHP_SCRIPT_INT' :
834 $content .= $this->PHP_SCRIPT($conf, 'INT');
835 break;
836 case 'USER' :
837 $content .= $this->USER($conf);
838 break;
839 case 'USER_INT' :
840 $content .= $this->USER($conf, 'INT');
841 break;
842 case 'TEMPLATE' :
843 $content .= $this->TEMPLATE($conf);
844 break;
845 case 'EDITPANEL' :
846 if ($GLOBALS['TSFE']->beUserLogin) {
847 $content .= $this->editPanel($content, $conf);
848 }
849 break;
850 case 'MULTIMEDIA' :
851 $content .= $this->MULTIMEDIA($conf);
852 break;
853 case 'MEDIA' :
854 $content .= $this->MEDIA($conf);
855 break;
856 case 'SWFOBJECT' :
857 $content .= $this->SWFOBJECT($conf);
858 break;
859 case 'QTOBJECT' :
860 $content .= $this->QTOBJECT($conf);
861 break;
862 case 'SVG' :
863 $content .= $this->SVG($conf);
864 break;
865 default :
866 // call hook functions for extra processing
867 if ($name && is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClassDefault'])) {
868 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClassDefault'] as $classData) {
869 $hookObject = t3lib_div::getUserObj($classData);
870
871 if (!($hookObject instanceof tslib_content_cObjGetSingleHook)) {
872 throw new UnexpectedValueException(
873 '$hookObject must implement interface tslib_content_cObjGetSingleHook',
874 1195043731
875 );
876 }
877 /* @var $hookObject tslib_content_cObjGetSingleHook */
878 $content .= $hookObject->getSingleContentObject($name, (array) $conf, $TSkey, $this);
879 }
880 }
881 break;
882 }
883 }
884 }
885 if ($GLOBALS['TT']->LR)
886 $GLOBALS['TT']->pull($content);
887 }
888 // Increasing on exit...
889 $GLOBALS['TSFE']->cObjectDepthCounter++;
890 return $content;
891 }
892
893
894
895 /********************************************
896 *
897 * Functions rendering content objects (cObjects)
898 *
899 ********************************************/
900
901 /**
902 * Rendering the cObject, HTML
903 *
904 * @param array array of TypoScript properties
905 * @return string Output
906 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=349&cHash=d3fd0c70b4
907 */
908 function HTML($conf) {
909 return $this->stdWrap($conf['value'], $conf['value.']);
910 }
911
912 /**
913 * Rendering the cObject, TEXT
914 *
915 * @param array array of TypoScript properties
916 * @return string Output
917 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=350&cHash=b49de28f83
918 */
919 function TEXT($conf) {
920 return $this->stdWrap($conf['value'], $conf);
921 }
922
923 /**
924 * Rendering the cObject, CLEARGIF
925 *
926 * @param array array of TypoScript properties
927 * @return string Output
928 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=355&cHash=70c0f19915
929 */
930 function CLEARGIF($conf) {
931 $w = $this->stdWrap($conf['width'], $conf['width.']);
932 $h = $this->stdWrap($conf['height'], $conf['height.']);
933 $w = $w ? $w : 1;
934 $h = $h ? $h : 1;
935 $wrap = $conf['wrap'] ? $conf['wrap'] : '|<br />';
936 $theValue = $this->wrap(
937 '<img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' . $w . '" height="' . $h . '"' .
938 $this->getBorderAttr(' border="0"') . ' alt="" title="" />',
939 $wrap
940 );
941
942 return $this->stdWrap($theValue, $conf['stdWrap.']);
943 }
944
945 /**
946 * Rendering the cObject, COBJ_ARRAY / COA and COBJ_ARRAY_INT
947 *
948 * @param array array of TypoScript properties
949 * @param string If "INT" then the cObject is a "COBJ_ARRAY_INT" (non-cached), otherwise just "COBJ_ARRAY" (cached)
950 * @return string Output
951 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=351&cHash=a09db0329c
952 */
953 function COBJ_ARRAY($conf, $ext = '') {
954
955 if (is_array($conf)) {
956 $content = '';
957 switch ($ext) {
958 case 'INT' :
959 $substKey = $ext . '_SCRIPT.' . $GLOBALS['TSFE']->uniqueHash();
960 $content .= '<!--' . $substKey . '-->';
961 $GLOBALS['TSFE']->config[$ext . 'incScript'][$substKey] = array(
962 'file' => $conf['includeLibs'],
963 'conf' => $conf,
964 'cObj' => serialize($this),
965 'type' => 'COA'
966 );
967 break;
968 default :
969 if ($this->checkIf($conf['if.'])) {
970 $this->includeLibs($conf);
971 $content = $this->cObjGet($conf);
972 if ($conf['wrap']) {
973 $content = $this->wrap($content, $conf['wrap']);
974 }
975 if ($conf['stdWrap.']) {
976 $content = $this->stdWrap($content, $conf['stdWrap.']);
977 }
978 }
979 break;
980 }
981 return $content;
982 } else {
983 $GLOBALS['TT']->setTSlogMessage('No elements in this content object array(COBJ_ARRAY, COA, COA_INT).', 2);
984 }
985 }
986
987 /**
988 * Rendering the cObject, USER and USER_INT
989 *
990 * @param array array of TypoScript properties
991 * @param string If "INT" then the cObject is a "USER_INT" (non-cached), otherwise just "USER" (cached)
992 * @return string Output
993 * @link http://typo3.org/documentation/document-library/references/doc_core_tsref/4.1.0/view/8/22/
994 */
995 function USER($conf, $ext = '') {
996 $content = '';
997 switch ($ext) {
998 case 'INT' :
999 $this->userObjectType = self::OBJECTTYPE_USER_INT;
1000 $substKey = $ext . '_SCRIPT.' . $GLOBALS['TSFE']->uniqueHash();
1001 $content .= '<!--' . $substKey . '-->';
1002 $GLOBALS['TSFE']->config[$ext . 'incScript'][$substKey] = array(
1003 'file' => $conf['includeLibs'],
1004 'conf' => $conf,
1005 'cObj' => serialize($this),
1006 'type' => 'FUNC'
1007 );
1008 break;
1009 default :
1010 if ($this->userObjectType === FALSE) {
1011 // Come here only if we are not called from $TSFE->INTincScript_process()!
1012 $this->userObjectType = self::OBJECTTYPE_USER;
1013 }
1014 $this->includeLibs($conf);
1015 $tempContent = $this->callUserFunction($conf['userFunc'], $conf, '');
1016 if ($this->doConvertToUserIntObject) {
1017 $this->doConvertToUserIntObject = FALSE;
1018 $content = $this->USER($conf, 'INT');
1019 } else {
1020 $content .= $tempContent;
1021 }
1022 break;
1023 }
1024 $this->userObjectType = FALSE;
1025 return $content;
1026 }
1027
1028 /**
1029 * Retrieves a type of object called as USER or USER_INT. Object can detect their
1030 * type by using this call. It returns OBJECTTYPE_USER_INT or OBJECTTYPE_USER depending on the
1031 * current object execution. In all other cases it will return FALSE to indicate
1032 * a call out of context.
1033 *
1034 * @return mixed One of OBJECTTYPE_ class constants or FALSE
1035 */
1036 public function getUserObjectType() {
1037 return $this->userObjectType;
1038 }
1039
1040 /**
1041 * Requests the current USER object to be converted to USER_INT.
1042 *
1043 * @return void
1044 */
1045 public function convertToUserIntObject() {
1046 if ($this->userObjectType !== self::OBJECTTYPE_USER) {
1047 $GLOBALS['TT']->setTSlogMessage('tslib_cObj::convertToUserIntObject() ' . 'is called in the wrong context or for the wrong object type', 2);
1048 } else {
1049 $this->doConvertToUserIntObject = TRUE;
1050 }
1051 }
1052
1053 /**
1054 * Rendering the cObject, FILE
1055 *
1056 * @param array array of TypoScript properties
1057 * @return string Output
1058 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=352&cHash=379c60f8bc
1059 */
1060 function FILE($conf) {
1061 $theValue = $this->fileResource($this->stdWrap($conf['file'], $conf['file.']), trim($this->getAltParam($conf, FALSE)));
1062 if ($conf['linkWrap']) {
1063 $theValue = $this->linkWrap($theValue, $conf['linkWrap']);
1064 }
1065 return $this->wrap($theValue, $conf['wrap']);
1066 }
1067
1068 /**
1069 * Rendering the cObject, IMAGE
1070 *
1071 * @param array array of TypoScript properties
1072 * @return string Output
1073 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=353&cHash=440681ea56
1074 * @see cImage()
1075 */
1076 function IMAGE($conf) {
1077 $content = '';
1078 if ($this->checkIf($conf['if.'])) {
1079 $theValue = $this->cImage($conf['file'], $conf);
1080 if ($conf['stdWrap.']) {
1081 $theValue = $this->stdWrap($theValue, $conf['stdWrap.']);
1082 }
1083 return $theValue;
1084 }
1085 }
1086
1087 /**
1088 * Rendering the cObject, IMG_RESOURCE
1089 *
1090 * @param array array of TypoScript properties
1091 * @return string Output
1092 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=354&cHash=46f9299706
1093 * @see getImgResource()
1094 */
1095 function IMG_RESOURCE($conf) {
1096 $GLOBALS['TSFE']->lastImgResourceInfo = $this->getImgResource($conf['file'], $conf['file.']);
1097 return $this->stdWrap($GLOBALS['TSFE']->lastImgResourceInfo[3], $conf['stdWrap.']);
1098 }
1099
1100 /**
1101 * Rendering the cObject, IMGTEXT
1102 *
1103 * @param array array of TypoScript properties
1104 * @return string Output
1105 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=363&cHash=cf2969bce1
1106 */
1107 function IMGTEXT($conf) {
1108 $content = '';
1109 if (is_array($conf['text.'])) {
1110 $content .= $this->stdWrap($this->cObjGet($conf['text.'], 'text.'), $conf['text.']); // this gets the surrounding content
1111 }
1112 $imgList = trim($this->stdWrap($conf['imgList'], $conf['imgList.'])); // gets images
1113 if ($imgList) {
1114 $imgs = t3lib_div::trimExplode(',', $imgList);
1115 $imgStart = intval($this->stdWrap($conf['imgStart'], $conf['imgStart.']));
1116
1117 $imgCount = count($imgs) - $imgStart;
1118
1119 $imgMax = intval($this->stdWrap($conf['imgMax'], $conf['imgMax.']));
1120 if ($imgMax) {
1121 $imgCount = t3lib_div::intInRange($imgCount, 0, $imgMax); // reduces the number of images.
1122 }
1123
1124 $imgPath = $this->stdWrap($conf['imgPath'], $conf['imgPath.']);
1125
1126 // initialisation
1127 $caption = '';
1128 $captionArray = array();
1129 if (!$conf['captionSplit'] && !$conf['imageTextSplit'] && is_array($conf['caption.'])) {
1130 $caption = $this->stdWrap($this->cObjGet($conf['caption.'], 'caption.'), $conf['caption.']); // global caption, no splitting
1131 }
1132 if ($conf['captionSplit'] && $conf['captionSplit.']['cObject']) {
1133 $legacyCaptionSplit = 1;
1134 $capSplit = $this->stdWrap($conf['captionSplit.']['token'], $conf['captionSplit.']['token.']);
1135 if (!$capSplit) {
1136 $capSplit = LF;
1137 }
1138 $captionArray = explode($capSplit, $this->cObjGetSingle(
1139 $conf['captionSplit.']['cObject'],
1140 $conf['captionSplit.']['cObject.'],
1141 'captionSplit.cObject')
1142 );
1143 foreach ($captionArray as $ca_key => $ca_val) {
1144 $captionArray[$ca_key] = $this->stdWrap(trim($captionArray[$ca_key]), $conf['captionSplit.']['stdWrap.']);
1145 }
1146 }
1147
1148 $tablecode = '';
1149 $position = $this->stdWrap($conf['textPos'], $conf['textPos.']);
1150
1151 $tmppos = $position & 7;
1152 $contentPosition = $position & 24;
1153 $align = $this->align[$tmppos];
1154 $cap = ($caption) ? 1 : 0;
1155 $txtMarg = intval($this->stdWrap($conf['textMargin'], $conf['textMargin.']));
1156 if (!$conf['textMargin_outOfText'] && $contentPosition < 16) {
1157 $txtMarg = 0;
1158 }
1159
1160 $cols = intval($this->stdWrap($conf['cols'], $conf['cols.']));
1161 $rows = intval($this->stdWrap($conf['rows'], $conf['rows.']));
1162 $colspacing = intval($this->stdWrap($conf['colSpace'], $conf['colSpace.']));
1163 $rowspacing = intval($this->stdWrap($conf['rowSpace'], $conf['rowSpace.']));
1164
1165 $border = intval($this->stdWrap($conf['border'], $conf['border.'])) ? 1 : 0;
1166 $borderColor = $this->stdWrap($conf['borderCol'], $conf['borderCol.']);
1167 $borderThickness = intval($this->stdWrap($conf['borderThick'], $conf['borderThick.']));
1168
1169 $borderColor = $borderColor ? $borderColor : 'black';
1170 $borderThickness = $borderThickness ? $borderThickness : 1;
1171
1172 $caption_align = $this->stdWrap($conf['captionAlign'], $conf['captionAlign.']);
1173 if (!$caption_align) {
1174 $caption_align = $align;
1175 }
1176 // generate cols
1177 $colCount = ($cols > 1) ? $cols : 1;
1178 if ($colCount > $imgCount) {
1179 $colCount = $imgCount;
1180 }
1181 $rowCount = ($colCount > 1) ? ceil($imgCount / $colCount) : $imgCount;
1182 // generate rows
1183 if ($rows > 1) {
1184 $rowCount = $rows;
1185 if ($rowCount > $imgCount) {
1186 $rowCount = $imgCount;
1187 }
1188 $colCount = ($rowCount > 1) ? ceil($imgCount / $rowCount) : $imgCount;
1189 }
1190
1191 // max Width
1192 $colRelations = trim($this->stdWrap($conf['colRelations'], $conf['colRelations.']));
1193 $maxW = intval($this->stdWrap($conf['maxW'], $conf['maxW.']));
1194
1195 $maxWInText = intval($this->stdWrap($conf['maxWInText'], $conf['maxWInText.']));
1196 if (!$maxWInText) { // If maxWInText is not set, it's calculated to the 50 % of the max...
1197 $maxWInText = round($maxW / 2);
1198 }
1199
1200 if ($maxWInText && $contentPosition >= 16) { // inText
1201 $maxW = $maxWInText;
1202 }
1203
1204 if ($maxW && $colCount > 0) { // If there is a max width and if colCount is greater than column
1205 $maxW = ceil(($maxW - $colspacing * ($colCount - 1) - $colCount * $border * $borderThickness * 2) / $colCount);
1206 }
1207 // create the relation between rows
1208 $colMaxW = array();
1209 if ($colRelations) {
1210 $rel_parts = explode(':', $colRelations);
1211 $rel_total = 0;
1212 for ($a = 0; $a < $colCount; $a++) {
1213 $rel_parts[$a] = intval($rel_parts[$a]);
1214 $rel_total += $rel_parts[$a];
1215 }
1216 if ($rel_total) {
1217 for ($a = 0; $a < $colCount; $a++) {
1218 $colMaxW[$a] = round(($maxW * $colCount) / $rel_total * $rel_parts[$a]);
1219 }
1220 if (min($colMaxW) <= 0 || max($rel_parts) / min($rel_parts) > 10) { // The difference in size between the largest and smalles must be within a factor of ten.
1221 $colMaxW = array();
1222 }
1223 }
1224 }
1225 $image_compression = intval($this->stdWrap($conf['image_compression'], $conf['image_compression.']));
1226 $image_effects = intval($this->stdWrap($conf['image_effects'], $conf['image_effects.']));
1227 $image_frames = intval($this->stdWrap($conf['image_frames.']['key'], $conf['image_frames.']['key.']));
1228
1229 // fetches pictures
1230 $splitArr = array();
1231 $splitArr['imgObjNum'] = $conf['imgObjNum'];
1232 $splitArr = $GLOBALS['TSFE']->tmpl->splitConfArray($splitArr, $imgCount);
1233
1234 // EqualHeight
1235 $equalHeight = intval($this->stdWrap($conf['equalH'], $conf['equalH.']));
1236 if ($equalHeight) { // Initiate gifbuilder object in order to get dimensions AND calculate the imageWidth's
1237 $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
1238 $gifCreator->init();
1239 $relations = array();
1240 $relations_cols = array();
1241 $totalMaxW = $maxW * $colCount;
1242 for ($a = 0; $a < $imgCount; $a++) {
1243 $imgKey = $a + $imgStart;
1244 $imgInfo = $gifCreator->getImageDimensions($imgPath . $imgs[$imgKey]);
1245 $relations[$a] = $imgInfo[1] / $equalHeight; // relationship between the original height and the wished height
1246 if ($relations[$a]) { // if relations is zero, then the addition of this value is omitted as the image is not expected to display because of some error.
1247 $relations_cols[floor($a / $colCount)] += $imgInfo[0] / $relations[$a]; // counts the total width of the row with the new height taken into consideration.
1248 }
1249 }
1250 }
1251
1252 $imageRowsFinalWidths = array(); // contains the width of every image row
1253 $imageRowsMaxHeights = array();
1254 $imgsTag = array();
1255 $origImages = array();
1256 for ($a = 0; $a < $imgCount; $a++) {
1257 $GLOBALS['TSFE']->register['IMAGE_NUM'] = $a;
1258 $GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = $a;
1259
1260 $imgKey = $a + $imgStart;
1261 $totalImagePath = $imgPath . $imgs[$imgKey];
1262 $this->data[$this->currentValKey] = $totalImagePath;
1263 $imgObjNum = intval($splitArr[$a]['imgObjNum']);
1264 $imgConf = $conf[$imgObjNum . '.'];
1265
1266 if ($equalHeight) {
1267 $scale = 1;
1268 if ($totalMaxW) {
1269 $rowTotalMaxW = $relations_cols[floor($a / $colCount)];
1270 if ($rowTotalMaxW > $totalMaxW) {
1271 $scale = $rowTotalMaxW / $totalMaxW;
1272 }
1273 }
1274 // transfer info to the imageObject. Please note, that
1275 $imgConf['file.']['height'] = round($equalHeight / $scale);
1276
1277 unset(
1278 $imgConf['file.']['width'],
1279 $imgConf['file.']['maxW'],
1280 $imgConf['file.']['maxH'],
1281 $imgConf['file.']['minW'],
1282 $imgConf['file.']['minH'],
1283 $imgConf['file.']['width.'],
1284 $imgConf['file.']['maxW.'],
1285 $imgConf['file.']['maxH.'],
1286 $imgConf['file.']['minW.'],
1287 $imgConf['file.']['minH.']
1288 );
1289 $maxW = 0; // setting this to zero, so that it doesn't disturb
1290 }
1291
1292 if ($maxW) {
1293 if (count($colMaxW)) {
1294 $imgConf['file.']['maxW'] = $colMaxW[($a % $colCount)];
1295 } else {
1296 $imgConf['file.']['maxW'] = $maxW;
1297 }
1298 }
1299
1300 // Image Object supplied:
1301 if (is_array($imgConf)) {
1302 if ($this->image_effects[$image_effects]) {
1303 $imgConf['file.']['params'] .= ' ' . $this->image_effects[$image_effects];
1304 }
1305 if ($image_frames) {
1306 if (is_array($conf['image_frames.'][$image_frames . '.'])) {
1307 $imgConf['file.']['m.'] = $conf['image_frames.'][$image_frames . '.'];
1308 }
1309 }
1310 if ($image_compression && $imgConf['file'] != 'GIFBUILDER') {
1311 if ($image_compression == 1) {
1312 $tempImport = $imgConf['file.']['import'];
1313 $tempImport_dot = $imgConf['file.']['import.'];
1314 unset($imgConf['file.']);
1315 $imgConf['file.']['import'] = $tempImport;
1316 $imgConf['file.']['import.'] = $tempImport_dot;
1317 } elseif (isset($this->image_compression[$image_compression])) {
1318 $imgConf['file.']['params'] .= ' ' . $this->image_compression[$image_compression]['params'];
1319 $imgConf['file.']['ext'] = $this->image_compression[$image_compression]['ext'];
1320 unset($imgConf['file.']['ext.']);
1321 }
1322 }
1323
1324 // "alt", "title" and "longdesc" attributes:
1325 if (!strlen($imgConf['altText']) && !is_array($imgConf['altText.'])) {
1326 $imgConf['altText'] = $conf['altText'];
1327 $imgConf['altText.'] = $conf['altText.'];
1328 }
1329 if (!strlen($imgConf['titleText']) && !is_array($imgConf['titleText.'])) {
1330 $imgConf['titleText'] = $conf['titleText'];
1331 $imgConf['titleText.'] = $conf['titleText.'];
1332 }
1333 if (!strlen($imgConf['longdescURL']) && !is_array($imgConf['longdescURL.'])) {
1334 $imgConf['longdescURL'] = $conf['longdescURL'];
1335 $imgConf['longdescURL.'] = $conf['longdescURL.'];
1336 }
1337 } else {
1338 $imgConf = array(
1339 'altText' => $conf['altText'],
1340 'titleText' => $conf['titleText'],
1341 'longdescURL' => $conf['longdescURL'],
1342 'file' => $totalImagePath
1343 );
1344 }
1345
1346 $imgsTag[$imgKey] = $this->IMAGE($imgConf);
1347
1348 // Store the original filepath
1349 $origImages[$imgKey] = $GLOBALS['TSFE']->lastImageInfo;
1350
1351 $imageRowsFinalWidths[floor($a / $colCount)] += $GLOBALS['TSFE']->lastImageInfo[0];
1352 if ($GLOBALS['TSFE']->lastImageInfo[1] > $imageRowsMaxHeights[floor($a / $colCount)]) {
1353 $imageRowsMaxHeights[floor($a / $colCount)] = $GLOBALS['TSFE']->lastImageInfo[1];
1354 }
1355 }
1356 // calculating the tableWidth:
1357 // TableWidth problems: It creates problems if the pictures are NOT as wide as the tableWidth.
1358 $tableWidth = max($imageRowsFinalWidths) + $colspacing * ($colCount - 1) + $colCount * $border * $borderThickness * 2;
1359
1360 // make table for pictures
1361 $index = $imgIndex = $imgStart;
1362
1363 $noRows = $this->stdWrap($conf['noRows'], $conf['noRows.']);
1364 $noCols = $this->stdWrap($conf['noCols'], $conf['noCols.']);
1365 if ($noRows) {
1366 $noCols = 0;
1367 } // noRows overrides noCols. They cannot exist at the same time.
1368 if ($equalHeight) {
1369 $noCols = 1;
1370 $noRows = 0;
1371 }
1372
1373 $rowCount_temp = 1;
1374 $colCount_temp = $colCount;
1375 if ($noRows) {
1376 $rowCount_temp = $rowCount;
1377 $rowCount = 1;
1378 }
1379 if ($noCols) {
1380 $colCount = 1;
1381 }
1382 // col- and rowspans calculated
1383 $colspan = (($colspacing) ? $colCount * 2 - 1 : $colCount);
1384 $rowspan = (($rowspacing) ? $rowCount * 2 - 1 : $rowCount) + $cap;
1385
1386
1387 // Edit icons:
1388 $editIconsHTML = $conf['editIcons'] && $GLOBALS['TSFE']->beUserLogin
1389 ? $this->editIcons('', $conf['editIcons'], $conf['editIcons.'])
1390 : '';
1391
1392 // strech out table:
1393 $tablecode = '';
1394 $flag = 0;
1395 if ($conf['noStretchAndMarginCells'] != 1) {
1396 $tablecode .= '<tr>';
1397 if ($txtMarg && $align == 'right') { // If right aligned, the textborder is added on the right side
1398 $tablecode .= '<td rowspan="' . ($rowspan + 1) . '" valign="top"><img src="' .
1399 $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' . $txtMarg . '" height="1" alt="" title="" />' .
1400 ($editIconsHTML ? '<br />' . $editIconsHTML : '') . '</td>';
1401 $editIconsHTML = '';
1402 $flag = 1;
1403 }
1404 $tablecode .= '<td colspan="' . $colspan . '"><img src="' .
1405 $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' . $tableWidth . '" height="1" alt="" /></td>';
1406 if ($txtMarg && $align == 'left') { // If left aligned, the textborder is added on the left side
1407 $tablecode .= '<td rowspan="' . ($rowspan + 1) . '" valign="top"><img src="' .
1408 $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' . $txtMarg . '" height="1" alt="" title="" />' .
1409 ($editIconsHTML ? '<br />' . $editIconsHTML : '') . '</td>';
1410 $editIconsHTML = '';
1411 $flag = 1;
1412 }
1413 if ($flag) {
1414 $tableWidth += $txtMarg + 1;
1415 }
1416 $tablecode .= '</tr>';
1417 }
1418
1419 // draw table
1420 for ($c = 0; $c < $rowCount; $c++) { // Looping through rows. If 'noRows' is set, this is '1 time', but $rowCount_temp will hold the actual number of rows!
1421 if ($c && $rowspacing) { // If this is NOT the first time in the loop AND if space is required, a row-spacer is added. In case of "noRows" rowspacing is done further down.
1422 $tablecode .= '<tr><td colspan="' . $colspan . '"><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="1" height="' . $rowspacing . '"' . $this->getBorderAttr(' border="0"') . ' alt="" title="" /></td></tr>';
1423 }
1424 $tablecode .= '<tr>'; // starting row
1425 for ($b = 0; $b < $colCount_temp; $b++) { // Looping through the columns
1426 if ($b && $colspacing) { // If this is NOT the first iteration AND if column space is required. In case of "noCols", the space is done without a separate cell.
1427 if (!$noCols) {
1428 $tablecode .= '<td><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' .
1429 $colspacing . '" height="1"' . $this->getBorderAttr(' border="0"') . ' alt="" title="" /></td>';
1430 } else {
1431 $colSpacer = '<img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' .
1432 ($border ? $colspacing - 6 : $colspacing) . '" height="' .
1433 ($imageRowsMaxHeights[$c] + ($border ? $borderThickness * 2 : 0)) . '"' .
1434 $this->getBorderAttr(' border="0"') . ' align="' .
1435 ($border ? 'left' : 'top') . '" alt="" title="" />';
1436 $colSpacer = '<td valign="top">' . $colSpacer . '</td>'; // added 160301, needed for the new "noCols"-table...
1437 $tablecode .= $colSpacer;
1438 }
1439 }
1440 if (!$noCols || ($noCols && !$b)) {
1441 $tablecode .= '<td valign="top">'; // starting the cell. If "noCols" this cell will hold all images in the row, otherwise only a single image.
1442 if ($noCols) {
1443 $tablecode .= '<table width="' . $imageRowsFinalWidths[$c] . '" border="0" cellpadding="0" cellspacing="0"><tr>';
1444 } // In case of "noCols" we must set the table-tag that surrounds the images in the row.
1445 }
1446 for ($a = 0; $a < $rowCount_temp; $a++) { // Looping through the rows IF "noRows" is set. "noRows" means that the rows of images is not rendered by physical table rows but images are all in one column and spaced apart with clear-gifs. This loop is only one time if "noRows" is not set.
1447 $GLOBALS['TSFE']->register['IMAGE_NUM'] = $imgIndex; // register previous imgIndex
1448 $imgIndex = $index + $a * $colCount_temp;
1449 $GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = $imgIndex;
1450 if ($imgsTag[$imgIndex]) {
1451 if ($rowspacing && $noRows && $a) { // Puts distance between the images IF "noRows" is set and this is the first iteration of the loop
1452 $tablecode .= '<img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="1" height="' .
1453 $rowspacing . '" alt="" title="" /><br />';
1454 }
1455 if ($legacyCaptionSplit) {
1456 $thisCaption = $captionArray[$imgIndex];
1457 } else if ($conf['captionSplit'] || $conf['imageTextSplit']) {
1458 $thisCaption = $this->stdWrap($this->cObjGet($conf['caption.'], 'caption.'), $conf['caption.']);
1459 }
1460 $imageHTML = $imgsTag[$imgIndex] . '<br />';
1461 $Talign = (!trim($thisCaption) && !$noRows) ? ' align="left"' : ''; // this is necessary if the tablerows are supposed to space properly together! "noRows" is excluded because else the images "layer" together.
1462 if ($border) {
1463 $imageHTML = '<table border="0" cellpadding="' . $borderThickness . '" cellspacing="0" bgcolor="' .
1464 $borderColor . '"' . $Talign . '><tr><td>' . $imageHTML . '</td></tr></table>';
1465 }
1466 $imageHTML .= $editIconsHTML;
1467 $editIconsHTML = '';
1468 $imageHTML .= $thisCaption; // Adds caption.
1469 if ($noCols) {
1470 $imageHTML = '<td valign="top">' . $imageHTML . '</td>';
1471 } // If noCols, put in table cell.
1472 $tablecode .= $imageHTML;
1473 }
1474 }
1475 $index++;
1476 if (!$noCols || ($noCols && $b + 1 == $colCount_temp)) {
1477 if ($noCols) {
1478 $tablecode .= '</tr></table>';
1479 } // In case of "noCols" we must finish the table that surrounds the images in the row.
1480 $tablecode .= '</td>'; // Ending the cell. In case of "noCols" the cell holds all pictures!
1481 }
1482 }
1483 $tablecode .= '</tr>'; // ending row
1484 }
1485 if ($c) {
1486 switch ($contentPosition) {
1487 case '0' : // above
1488 case '8' : // below
1489 switch ($align) { // These settings are needed for Firefox
1490 case 'center' :
1491 $table_align = 'margin-left: auto; margin-right: auto';
1492 break;
1493 case 'right' :
1494 $table_align = 'margin-left: auto; margin-right: 0px';
1495 break;
1496 default : // Most of all: left
1497 $table_align = 'margin-left: 0px; margin-right: auto';
1498 }
1499 $table_align = 'style="' . $table_align . '"';
1500 break;
1501 case '16' : // in text
1502 $table_align = 'align="' . $align . '"';
1503 break;
1504 default :
1505 $table_align = '';
1506 }
1507
1508 // Table-tag is inserted
1509 $tablecode = '<table' . ($tableWidth ? ' width="' . $tableWidth . '"' : '') . ' border="0" cellspacing="0" cellpadding="0" ' . $table_align . ' class="imgtext-table">' . $tablecode;
1510 if ($editIconsHTML) { // IF this value is not long since reset.
1511 $tablecode .= '<tr><td colspan="' . $colspan . '">' . $editIconsHTML . '</td></tr>';
1512 $editIconsHTML = '';
1513 }
1514 if ($cap) {
1515 $tablecode .= '<tr><td colspan="' . $colspan . '" align="' . $caption_align . '">' . $caption . '</td></tr>';
1516 }
1517 $tablecode .= '</table>';
1518 if ($conf['tableStdWrap.']) {
1519 $tablecode = $this->stdWrap($tablecode, $conf['tableStdWrap.']);
1520 }
1521 }
1522
1523 $spaceBelowAbove = intval($this->stdWrap($conf['spaceBelowAbove'], $conf['spaceBelowAbove.']));
1524 switch ($contentPosition) {
1525 case '0' : // above
1526 $output = '<div style="text-align:' . $align . ';">' . $tablecode . '</div>' .
1527 $this->wrapSpace($content, $spaceBelowAbove . '|0');
1528 break;
1529 case '8' : // below
1530 $output = $this->wrapSpace($content, '0|' . $spaceBelowAbove) .
1531 '<div style="text-align:' . $align . ';">' . $tablecode . '</div>';
1532 break;
1533 case '16' : // in text
1534 $output = $tablecode . $content;
1535 break;
1536 case '24' : // in text, no wrap
1537 $theResult = '';
1538 $theResult .= '<table border="0" cellspacing="0" cellpadding="0" class="imgtext-nowrap"><tr>';
1539 if ($align == 'right') {
1540 $theResult .= '<td valign="top">' . $content . '</td><td valign="top">' . $tablecode . '</td>';
1541 } else {
1542 $theResult .= '<td valign="top">' . $tablecode . '</td><td valign="top">' . $content . '</td>';
1543 }
1544 $theResult .= '</tr></table>';
1545 $output = $theResult;
1546 break;
1547 }
1548 } else {
1549 $output = $content;
1550 }
1551
1552 if ($conf['stdWrap.']) {
1553 $output = $this->stdWrap($output, $conf['stdWrap.']);
1554 }
1555
1556 return $output;
1557 }
1558
1559 /**
1560 * Rendering the cObject, CONTENT
1561 *
1562 * @param array array of TypoScript properties
1563 * @return string Output
1564 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=356&cHash=9f3b5c6ba2
1565 */
1566 function CONTENT($conf) {
1567 $theValue = '';
1568
1569 $originalRec = $GLOBALS['TSFE']->currentRecord;
1570 if ($originalRec) { // If the currentRecord is set, we register, that this record has invoked this function. It's should not be allowed to do this again then!!
1571 $GLOBALS['TSFE']->recordRegister[$originalRec]++;
1572 }
1573
1574 $conf['table'] = trim($this->stdWrap($conf['table'], $conf['table.']));
1575 if ($conf['table'] == 'pages' || substr($conf['table'], 0, 3) == 'tt_' || substr($conf['table'], 0, 3) == 'fe_' || substr($conf['table'], 0, 3) == 'tx_' || substr($conf['table'], 0, 4) == 'ttx_' || substr($conf['table'], 0, 5) == 'user_' || substr($conf['table'], 0, 7) == 'static_') {
1576
1577 $renderObjName = $conf['renderObj'] ? $conf['renderObj'] : '<' . $conf['table'];
1578 $renderObjKey = $conf['renderObj'] ? 'renderObj' : '';
1579 $renderObjConf = $conf['renderObj.'];
1580
1581 $slide = intval($conf['slide']) ? intval($conf['slide']) : 0;
1582 $slideCollect = intval($conf['slide.']['collect']) ? intval($conf['slide.']['collect']) : 0;
1583 $slideCollectReverse = intval($conf['slide.']['collectReverse']) ? TRUE : FALSE;
1584 $slideCollectFuzzy = $slideCollect ? (intval($conf['slide.']['collectFuzzy']) ? TRUE : FALSE) : TRUE;
1585 $again = FALSE;
1586
1587 do {
1588 $res = $this->exec_getQuery($conf['table'], $conf['select.']);
1589 if ($error = $GLOBALS['TYPO3_DB']->sql_error()) {
1590 $GLOBALS['TT']->setTSlogMessage($error, 3);
1591 } else {
1592 $this->currentRecordTotal = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
1593 $GLOBALS['TT']->setTSlogMessage('NUMROWS: ' . $GLOBALS['TYPO3_DB']->sql_num_rows($res));
1594 $cObj = t3lib_div::makeInstance('tslib_cObj');
1595 $cObj->setParent($this->data, $this->currentRecord);
1596 $this->currentRecordNumber = 0;
1597 $cobjValue = '';
1598 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1599
1600 // Versioning preview:
1601 $GLOBALS['TSFE']->sys_page->versionOL($conf['table'], $row, TRUE);
1602
1603 // Language overlay:
1604 if (is_array($row) && $GLOBALS['TSFE']->sys_language_contentOL) {
1605 $row = $GLOBALS['TSFE']->sys_page->getRecordOverlay($conf['table'], $row, $GLOBALS['TSFE']->sys_language_content, $GLOBALS['TSFE']->sys_language_contentOL);
1606 }
1607
1608 if (is_array($row)) { // Might be unset in the sys_language_contentOL
1609 if (!$GLOBALS['TSFE']->recordRegister[$conf['table'] . ':' . $row['uid']]) {
1610 $this->currentRecordNumber++;
1611 $cObj->parentRecordNumber = $this->currentRecordNumber;
1612 $GLOBALS['TSFE']->currentRecord = $conf['table'] . ':' . $row['uid'];
1613 $this->lastChanged($row['tstamp']);
1614 $cObj->start($row, $conf['table']);
1615 $tmpValue = $cObj->cObjGetSingle($renderObjName, $renderObjConf, $renderObjKey);
1616 $cobjValue .= $tmpValue;
1617 }
1618 }
1619 }
1620 $GLOBALS['TYPO3_DB']->sql_free_result($res);
1621 }
1622 if ($slideCollectReverse) {
1623 $theValue = $cobjValue . $theValue;
1624 } else {
1625 $theValue .= $cobjValue;
1626 }
1627 if ($slideCollect > 0) {
1628 $slideCollect--;
1629 }
1630 if ($slide) {
1631 if ($slide > 0) {
1632 $slide--;
1633 }
1634 $conf['select.']['pidInList'] = $this->getSlidePids($conf['select.']['pidInList'], $conf['select.']['pidInList.']);
1635 $again = strlen($conf['select.']['pidInList']) ? TRUE : FALSE;
1636 }
1637 } while ($again && (($slide && !strlen($tmpValue) && $slideCollectFuzzy) || ($slide && $slideCollect)));
1638 }
1639
1640 $theValue = $this->wrap($theValue, $conf['wrap']);
1641 if ($conf['stdWrap.'])
1642 $theValue = $this->stdWrap($theValue, $conf['stdWrap.']);
1643
1644 $GLOBALS['TSFE']->currentRecord = $originalRec; // Restore
1645 return $theValue;
1646 }
1647
1648 /**
1649 * Rendering the cObject, RECORDS
1650 *
1651 * @param array array of TypoScript properties
1652 * @return string Output
1653 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=357&cHash=303e959472
1654 */
1655 function RECORDS($conf) {
1656 $theValue = '';
1657
1658 $originalRec = $GLOBALS['TSFE']->currentRecord;
1659 if ($originalRec) { // If the currentRecord is set, we register, that this record has invoked this function. It's should not be allowed to do this again then!!
1660 $GLOBALS['TSFE']->recordRegister[$originalRec]++;
1661 }
1662
1663 $conf['source'] = $this->stdWrap($conf['source'], $conf['source.']);
1664 if ($conf['tables'] && $conf['source']) {
1665 $allowedTables = $conf['tables'];
1666 if (is_array($conf['conf.'])) {
1667 foreach ($conf['conf.'] as $k => $v) {
1668 if (substr($k, -1) != '.')
1669 $allowedTables .= ',' . $k;
1670 }
1671 }
1672
1673 $loadDB = t3lib_div::makeInstance('FE_loadDBGroup');
1674 $loadDB->start($conf['source'], $allowedTables);
1675 foreach ($loadDB->tableArray as $table => $v) {
1676 if (is_array($GLOBALS['TCA'][$table])) {
1677 $loadDB->additionalWhere[$table] = $this->enableFields($table);
1678 }
1679 }
1680 $loadDB->getFromDB();
1681
1682 reset($loadDB->itemArray);
1683 $data = $loadDB->results;
1684
1685 $cObj = t3lib_div::makeInstance('tslib_cObj');
1686 $cObj->setParent($this->data, $this->currentRecord);
1687 $this->currentRecordNumber = 0;
1688 $this->currentRecordTotal = count($loadDB->itemArray);
1689 foreach ($loadDB->itemArray as $val) {
1690 $row = $data[$val['table']][$val['id']];
1691
1692 // Versioning preview:
1693 $GLOBALS['TSFE']->sys_page->versionOL($val['table'], $row);
1694
1695 // Language overlay:
1696 if (is_array($row) && $GLOBALS['TSFE']->sys_language_contentOL) {
1697 $row = $GLOBALS['TSFE']->sys_page->getRecordOverlay(
1698 $val['table'],
1699 $row,
1700 $GLOBALS['TSFE']->sys_language_content,
1701 $GLOBALS['TSFE']->sys_language_contentOL
1702 );
1703 }
1704
1705 if (is_array($row)) { // Might be unset in the content overlay things...
1706 if (!$conf['dontCheckPid']) {
1707 $row = $this->checkPid($row['pid']) ? $row : '';
1708 }
1709 if ($row && !$GLOBALS['TSFE']->recordRegister[$val['table'] . ':' . $val['id']]) {
1710 $renderObjName = $conf['conf.'][$val['table']] ? $conf['conf.'][$val['table']] : '<' . $val['table'];
1711 $renderObjKey = $conf['conf.'][$val['table']] ? 'conf.' . $val['table'] : '';
1712 $renderObjConf = $conf['conf.'][$val['table'] . '.'];
1713 $this->currentRecordNumber++;
1714 $cObj->parentRecordNumber = $this->currentRecordNumber;
1715 $GLOBALS['TSFE']->currentRecord = $val['table'] . ':' . $val['id'];
1716 $this->lastChanged($row['tstamp']);
1717 $cObj->start($row, $val['table']);
1718 $tmpValue = $cObj->cObjGetSingle($renderObjName, $renderObjConf, $renderObjKey);
1719 $theValue .= $tmpValue;
1720 }
1721 }
1722 }
1723 }
1724 if ($conf['wrap'])
1725 $theValue = $this->wrap($theValue, $conf['wrap']);
1726 if ($conf['stdWrap.'])
1727 $theValue = $this->stdWrap($theValue, $conf['stdWrap.']);
1728
1729 $GLOBALS['TSFE']->currentRecord = $originalRec; // Restore
1730 return $theValue;
1731 }
1732
1733 /**
1734 * Rendering the cObject, HMENU
1735 *
1736 * @param array array of TypoScript properties
1737 * @return string Output
1738 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=358&cHash=5400c1c06a
1739 */
1740 function HMENU($conf) {
1741 $content = '';
1742 if ($this->checkIf($conf['if.'])) {
1743 $cls = strtolower($conf[1]);
1744 if (t3lib_div::inList($GLOBALS['TSFE']->tmpl->menuclasses, $cls)) {
1745 if ($conf['special.']['value.']) {
1746 $conf['special.']['value'] = $this->stdWrap($conf['special.']['value'], $conf['special.']['value.']);
1747 }
1748 $GLOBALS['TSFE']->register['count_HMENU']++;
1749 $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ'] = 0;
1750 $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'] = array();
1751 $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMparentId'] = array();
1752
1753 $menu = t3lib_div::makeInstance('tslib_' . $cls);
1754 $menu->parent_cObj = $this;
1755 $menu->start($GLOBALS['TSFE']->tmpl, $GLOBALS['TSFE']->sys_page, '', $conf, 1);
1756 $menu->makeMenu();
1757 $content .= $menu->writeMenu();
1758 }
1759 if ($conf['wrap'])
1760 $content = $this->wrap($content, $conf['wrap']);
1761 if ($conf['stdWrap.'])
1762 $content = $this->stdWrap($content, $conf['stdWrap.']);
1763 }
1764 return $content;
1765 }
1766
1767 /**
1768 * Rendering the cObject, CTABLE
1769 *
1770 * @param array array of TypoScript properties
1771 * @return string Output
1772 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=359&cHash=2e0065b4e7
1773 */
1774 function CTABLE($conf) {
1775 $controlTable = t3lib_div::makeInstance('tslib_controlTable');
1776 if ($conf['tableParams']) {
1777 $controlTable->tableParams = $conf['tableParams'];
1778 }
1779 // loads the pagecontent
1780 $controlTable->contentW = $conf['cWidth'];
1781 // loads the menues if any
1782 if (is_array($conf['c.'])) {
1783 $controlTable->content = $this->cObjGet($conf['c.'], 'c.');
1784 $controlTable->contentTDparams = isset($conf['c.']['TDParams']) ? $conf['c.']['TDParams'] : 'valign="top"';
1785 }
1786 if (is_array($conf['lm.'])) {
1787 $controlTable->lm = $this->cObjGet($conf['lm.'], 'lm.');
1788 $controlTable->lmTDparams = isset($conf['lm.']['TDParams']) ? $conf['lm.']['TDParams'] : 'valign="top"';
1789 }
1790 if (is_array($conf['tm.'])) {
1791 $controlTable->tm = $this->cObjGet($conf['tm.'], 'tm.');
1792 $controlTable->tmTDparams = isset($conf['tm.']['TDParams']) ? $conf['tm.']['TDParams'] : 'valign="top"';
1793 }
1794 if (is_array($conf['rm.'])) {
1795 $controlTable->rm = $this->cObjGet($conf['rm.'], 'rm.');
1796 $controlTable->rmTDparams = isset($conf['rm.']['TDParams']) ? $conf['rm.']['TDParams'] : 'valign="top"';
1797 }
1798 if (is_array($conf['bm.'])) {
1799 $controlTable->bm = $this->cObjGet($conf['bm.'], 'bm.');
1800 $controlTable->bmTDparams = isset($conf['bm.']['TDParams']) ? $conf['bm.']['TDParams'] : 'valign="top"';
1801 }
1802 return $controlTable->start($conf['offset'], $conf['cMargins']);
1803 }
1804
1805 /**
1806 * Rendering the cObject, OTABLE
1807 *
1808 * @param array array of TypoScript properties
1809 * @return string Output
1810 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=360&cHash=02c9552d38
1811 */
1812 function OTABLE($conf) {
1813 $controlTable = t3lib_div::makeInstance('tslib_tableOffset');
1814 if ($conf['tableParams']) {
1815 $controlTable->tableParams = $conf['tableParams'];
1816 }
1817 return $controlTable->start($this->cObjGet($conf), $conf['offset']);
1818 }
1819
1820 /**
1821 * Rendering the cObject, COLUMNS
1822 *
1823 * @param array array of TypoScript properties
1824 * @return string Output
1825 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=361&cHash=7e4e228cad
1826 */
1827 function COLUMNS($conf) {
1828 $content = '';
1829 if (is_array($conf) && $this->checkIf($conf['if.'])) {
1830 $tdRowCount = 0;
1831 $tableParams = $conf['tableParams'] ? ' ' . $conf['tableParams'] : ' border="0" cellspacing="0" cellpadding="0"';
1832 $TDparams = $conf['TDparams'] ? ' ' . $conf['TDparams'] : ' valign="top"';
1833 $rows = t3lib_div::intInRange($conf['rows'], 2, 20);
1834 $totalWidth = intval($conf['totalWidth']);
1835 $columnWidth = 0;
1836
1837 $totalGapWidth = 0;
1838 $gapData = array(
1839 'gapWidth' => $this->stdWrap($conf['gapWidth'], $conf['gapWidth.']),
1840 'gapBgCol' => $this->stdWrap($conf['gapBgCol'], $conf['gapBgCol.']),
1841 'gapLineThickness' => $this->stdWrap($conf['gapLineThickness'], $conf['gapLineThickness.']),
1842 'gapLineCol' => $this->stdWrap($conf['gapLineCol'], $conf['gapLineCol.']),
1843 );
1844 $gapData = $GLOBALS['TSFE']->tmpl->splitConfArray($gapData, $rows - 1);
1845 foreach ($gapData as $val) {
1846 $totalGapWidth += intval($val['gapWidth']);
1847 }
1848
1849 if ($totalWidth) {
1850 $columnWidth = ceil(($totalWidth - $totalGapWidth) / $rows);
1851 $TDparams .= ' width="' . $columnWidth . '"';
1852 $tableParams .= ' width="' . $totalWidth . '"';
1853 } else {
1854 $TDparams .= ' width="' . floor(100 / $rows) . '%"';
1855 $tableParams .= ' width="100%"';
1856 }
1857
1858 for ($a = 1; $a <= $rows; $a++) {
1859 $tdRowCount++;
1860 $content .= '<td' . $TDparams . '>';
1861 $content .= $this->cObjGetSingle($conf[$a], $conf[$a . '.'], $a);
1862 $content .= '</td>';
1863 if ($a < $rows) {
1864 $gapConf = $gapData[($a - 1)];
1865 $gapWidth = intval($gapConf['gapWidth']);
1866 if ($gapWidth) {
1867 $tdPar = $gapConf['gapBgCol'] ? ' bgcolor="' . $gapConf['gapBgCol'] . '"' : '';
1868 $gapLine = intval($gapConf['gapLineThickness']);
1869 if ($gapLine) {
1870 $gapSurround = t3lib_div::intInRange(($gapWidth - $gapLine) / 2, 1, 1000);
1871 // right gap
1872 $content .= '<td' . $tdPar . '><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' .
1873 $gapSurround . '" height="1" alt="" title="" /></td>';
1874 $tdRowCount++;
1875 // line:
1876 $GtdPar = $gapConf['gapLineCol'] ? ' bgcolor="' . $gapConf['gapLineCol'] . '"' : ' bgcolor="black"';
1877 $content .= '<td' . $GtdPar . '><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' .
1878 $gapLine . '" height="1" alt="" title="" /></td>';
1879 $tdRowCount++;
1880 // left gap
1881 $content .= '<td' . $tdPar . '><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' .
1882 $gapSurround . '" height="1" alt="" title="" /></td>';
1883 $tdRowCount++;
1884 } else {
1885 $content .= '<td' . $tdPar . '><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' .
1886 $gapWidth . '" height="1" alt="" title="" /></td>';
1887 $tdRowCount++;
1888 }
1889 }
1890 }
1891 }
1892 $content = '<tr>' . $content . '</tr>';
1893 $content = '<table' . $tableParams . '>' . $content . '</table>';
1894 $content .= $this->cObjGetSingle($conf['after'], $conf['after.'], 'after');
1895 if ($conf['stdWrap.']) {
1896 $content = $this->stdWrap($content, $conf['stdWrap.']);
1897 }
1898 }
1899 return $content;
1900 }
1901
1902 /**
1903 * Rendering the cObject, HRULER
1904 *
1905 * @param array array of TypoScript properties
1906 * @return string Output
1907 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=362&cHash=2a462aa084
1908 */
1909 function HRULER($conf) {
1910 $lineThickness = t3lib_div::intInRange($this->stdWrap($conf['lineThickness'], $conf['lineThickness.']), 1, 50);
1911 $lineColor = $conf['lineColor'] ? $conf['lineColor'] : 'black';
1912 $spaceBefore = intval($conf['spaceLeft']);
1913 $spaceAfter = intval($conf['spaceRight']);
1914 $tableWidth = $conf['tableWidth'] ? $conf['tableWidth'] : '99%';
1915 $content = '';
1916
1917 $content .= '<table border="0" cellspacing="0" cellpadding="0" width="' . htmlspecialchars($tableWidth) . '" summary=""><tr>';
1918 if ($spaceBefore) {
1919 $content .= '<td width="1"><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' .
1920 $spaceBefore . '" height="1" alt="" title="" /></td>';
1921 }
1922 $content .= '<td bgcolor="' . $lineColor . '"><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="1" height="' .
1923 $lineThickness . '" alt="" title="" /></td>';
1924 if ($spaceAfter) {
1925 $content .= '<td width="1"><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' .
1926 $spaceAfter . '" height="1" alt="" title="" /></td>';
1927 }
1928 $content .= '</tr></table>';
1929
1930 $content = $this->stdWrap($content, $conf['stdWrap.']);
1931 return $content;
1932 }
1933
1934 /**
1935 * Rendering the cObject, CASE
1936 *
1937 * @param array array of TypoScript properties
1938 * @return string Output
1939 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=364&cHash=cffedd09e3
1940 */
1941 function CASEFUNC($conf) {
1942 $content = '';
1943 if ($this->checkIf($conf['if.'])) {
1944 if ($conf['setCurrent'] || $conf['setCurrent.']) {
1945 $this->data[$this->currentValKey] = $this->stdWrap($conf['setCurrent'], $conf['setCurrent.']);
1946 }
1947 $key = $this->stdWrap($conf['key'], $conf['key.']);
1948 $key = strlen($conf[$key]) ? $key : 'default';
1949 $name = $conf[$key];
1950 $theValue = $this->cObjGetSingle($name, $conf[$key . '.'], $key);
1951 if ($conf['stdWrap.']) {
1952 $theValue = $this->stdWrap($theValue, $conf['stdWrap.']);
1953 }
1954 return $theValue;
1955 }
1956 }
1957
1958 /**
1959 * Rendering the cObject, LOAD_REGISTER and RESTORE_REGISTER
1960 * NOTICE: This cObject does NOT return any content since it just sets internal data based on the TypoScript properties.
1961 *
1962 * @param array array of TypoScript properties
1963 * @param string If "RESTORE_REGISTER" then the cObject rendered is "RESTORE_REGISTER", otherwise "LOAD_REGISTER"
1964 * @return string Empty string (the cObject only sets internal data!)
1965 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=365&cHash=4935524e2e
1966 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=366&cHash=4f9485e8cc
1967 */
1968 function LOAD_REGISTER($conf, $name) {
1969 if ($name == 'RESTORE_REGISTER') {
1970 $GLOBALS['TSFE']->register = array_pop($GLOBALS['TSFE']->registerStack);
1971 } else {
1972 array_push($GLOBALS['TSFE']->registerStack, $GLOBALS['TSFE']->register);
1973 if (is_array($conf)) {
1974 foreach ($conf as $theKey => $theValue) {
1975 if (!strstr($theKey, '.') || !isset($conf[substr($theKey, 0, -1)])) { // Only if 1) the property is set but not the value itself, 2) the value and/or any property
1976 if (strstr($theKey, '.')) {
1977 $theKey = substr($theKey, 0, -1);
1978 }
1979 $GLOBALS['TSFE']->register[$theKey] = $this->stdWrap($conf[$theKey], $conf[$theKey . '.']);
1980 }
1981 }
1982 }
1983 }
1984 return '';
1985 }
1986
1987 /**
1988 * Rendering the cObject, FORM
1989 *
1990 * Note on $formData:
1991 * In the optional $formData array each entry represents a line in the ordinary setup.
1992 * In those entries each entry (0,1,2...) represents a space normally divided by the '|' line.
1993 *
1994 * $formData [] = array('Name:', 'name=input, 25 ', 'Default value....');
1995 * $formData [] = array('Email:', 'email=input, 25 ', 'Default value for email....');
1996 *
1997 * - corresponds to the $conf['data'] value being :
1998 * Name:|name=input, 25 |Default value....||Email:|email=input, 25 |Default value for email....
1999 *
2000 * If $formData is an array the value of $conf['data'] is ignored.
2001 *
2002 * @param array array of TypoScript properties
2003 * @param array Alternative formdata overriding whatever comes from TypoScript
2004 * @return string Output
2005 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=367&cHash=bbc518d930
2006 */
2007 function FORM($conf, $formData = '') {
2008 $content = '';
2009 if (is_array($formData)) {
2010 $dataArr = $formData;
2011 } else {
2012 $data = $this->stdWrap($conf['data'], $conf['data.']);
2013 // Clearing dataArr
2014 $dataArr = array();
2015 // Getting the original config
2016 if (trim($data)) {
2017 $data = str_replace(LF, '||', $data);
2018 $dataArr = explode('||', $data);
2019 }
2020 // Adding the new dataArray config form:
2021 if (is_array($conf['dataArray.'])) { // dataArray is supplied
2022 $sKeyArray = t3lib_TStemplate::sortedKeyList($conf['dataArray.'], TRUE);
2023 foreach ($sKeyArray as $theKey) {
2024 $dAA = $conf['dataArray.'][$theKey . '.'];
2025 if (is_array($dAA)) {
2026 $temp = array();
2027 list ($temp[0]) = explode('|', $dAA['label.'] ? $this->stdWrap($dAA['label'], $dAA['label.']) : $dAA['label']);
2028 list ($temp[1]) = explode('|', $dAA['type']);
2029 if ($dAA['required']) {
2030 $temp[1] = '*' . $temp[1];
2031 }
2032 list ($temp[2]) = explode('|', $dAA['value.'] ? $this->stdWrap($dAA['value'], $dAA['value.']) : $dAA['value']);
2033 // If value array is set, then implode those values.
2034 if (is_array($dAA['valueArray.'])) {
2035 $temp_accum = array();
2036 foreach ($dAA['valueArray.'] as $dAKey_vA => $dAA_vA) {
2037 if (is_array($dAA_vA) && !strcmp(intval($dAKey_vA) . '.', $dAKey_vA)) {
2038 $temp_vA = array();
2039 list ($temp_vA[0]) = explode('=', $dAA_vA['label.'] ? $this->stdWrap($dAA_vA['label'], $dAA_vA['label.']) : $dAA_vA['label']);
2040 if ($dAA_vA['selected']) {
2041 $temp_vA[0] = '*' . $temp_vA[0];
2042 }
2043 list ($temp_vA[1]) = explode(',', $dAA_vA['value']);
2044 }
2045 $temp_accum[] = implode('=', $temp_vA);
2046 }
2047 $temp[2] = implode(',', $temp_accum);
2048 }
2049 list ($temp[3]) = explode('|', $dAA['specialEval.'] ? $this->stdWrap($dAA['specialEval'], $dAA['specialEval.']) : $dAA['specialEval']);
2050
2051 // adding the form entry to the dataArray
2052 $dataArr[] = implode('|', $temp);
2053 }
2054 }
2055 }
2056 }
2057
2058 $attachmentCounter = '';
2059 $hiddenfields = '';
2060 $fieldlist = array();
2061 $propertyOverride = array();
2062 $fieldname_hashArray = array();
2063 $cc = 0;
2064
2065 $xhtmlStrict = t3lib_div::inList('xhtml_strict,xhtml_11,xhtml_2', $GLOBALS['TSFE']->xhtmlDoctype);
2066 // Formname
2067 if ($conf['formName']) {
2068 $formname = $this->cleanFormName($conf['formName']);
2069 } else {
2070 $formname = $GLOBALS['TSFE']->uniqueHash();
2071 $formname = 'a' . $formname; // form name has to start with a letter to reach XHTML compliance
2072 }
2073
2074 if (isset($conf['fieldPrefix'])) {
2075 if ($conf['fieldPrefix']) {
2076 $prefix = $this->cleanFormName($conf['fieldPrefix']);
2077 } else {
2078 $prefix = '';
2079 }
2080 } else {
2081 $prefix = $formname;
2082 }
2083
2084 foreach ($dataArr as $val) {
2085
2086 $cc++;
2087 $confData = array();
2088 if (is_array($formData)) {
2089 $parts = $val;
2090 $val = 1; // TRUE...
2091 } else {
2092 $val = trim($val);
2093 $parts = explode('|', $val);
2094 }
2095 if ($val && strcspn($val, '#/')) {
2096 // label:
2097 $confData['label'] = trim($parts[0]);
2098 // field:
2099 $fParts = explode(',', $parts[1]);
2100 $fParts[0] = trim($fParts[0]);
2101 if (substr($fParts[0], 0, 1) == '*') {
2102 $confData['required'] = 1;
2103 $fParts[0] = substr($fParts[0], 1);
2104 }
2105 $typeParts = explode('=', $fParts[0]);
2106 $confData['type'] = trim(strtolower(end($typeParts)));
2107 if (count($typeParts) == 1) {
2108 $confData['fieldname'] = $this->cleanFormName($parts[0]);
2109 if (strtolower(preg_replace('/[^[:alnum:]]/', '', $confData['fieldname'])) == 'email') {
2110 $confData['fieldname'] = 'email';
2111 }
2112 // Duplicate fieldnames resolved
2113 if (isset($fieldname_hashArray[md5($confData['fieldname'])])) {
2114 $confData['fieldname'] .= '_' . $cc;
2115 }
2116 $fieldname_hashArray[md5($confData['fieldname'])] = $confData['fieldname'];
2117 // Attachment names...
2118 if ($confData['type'] == 'file') {
2119 $confData['fieldname'] = 'attachment' . $attachmentCounter;
2120 $attachmentCounter = intval($attachmentCounter) + 1;
2121 }
2122 } else {
2123 $confData['fieldname'] = str_replace(' ', '_', trim($typeParts[0]));
2124 }
2125 $fieldCode = '';
2126
2127 if ($conf['wrapFieldName']) {
2128 $confData['fieldname'] = $this->wrap($confData['fieldname'], $conf['wrapFieldName']);
2129 }
2130
2131 // Set field name as current:
2132 $this->setCurrentVal($confData['fieldname']);
2133
2134 // Additional parameters
2135 if (trim($confData['type'])) {
2136 $addParams = trim($conf['params']);
2137 if (is_array($conf['params.']) && isset($conf['params.'][$confData['type']])) {
2138 $addParams = trim($conf['params.'][$confData['type']]);
2139 }
2140 if (strcmp('', $addParams)) {
2141 $addParams = ' ' . $addParams;
2142 }
2143 } else
2144 $addParams = '';
2145
2146 if ($conf['dontMd5FieldNames']) {
2147 $fName = $confData['fieldname'];
2148 } else {
2149 $fName = md5($confData['fieldname']);
2150 }
2151
2152 // Accessibility: Set id = fieldname attribute:
2153 if ($conf['accessibility'] || $xhtmlStrict) {
2154 $elementIdAttribute = ' id="' . $prefix . $fName . '"';
2155 } else {
2156 $elementIdAttribute = '';
2157 }
2158
2159 // Create form field based on configuration/type:
2160 switch ($confData['type']) {
2161 case 'textarea' :
2162 $cols = trim($fParts[1]) ? intval($fParts[1]) : 20;
2163 $compWidth = doubleval($conf['compensateFieldWidth']
2164 ? $conf['compensateFieldWidth']
2165 : $GLOBALS['TSFE']->compensateFieldWidth
2166 );
2167 $compWidth = $compWidth ? $compWidth : 1;
2168 $cols = t3lib_div::intInRange($cols * $compWidth, 1, 120);
2169
2170 $rows = trim($fParts[2]) ? t3lib_div::intInRange($fParts[2], 1, 30) : 5;
2171 $wrap = trim($fParts[3]);
2172 if ($conf['noWrapAttr'] || $wrap === 'disabled') {
2173 $wrap = '';
2174 } else {
2175 $wrap = $wrap ? ' wrap="' . $wrap . '"' : ' wrap="virtual"';
2176 }
2177 $default = $this->getFieldDefaultValue(
2178 $conf['noValueInsert'],
2179 $confData['fieldname'],
2180 str_replace('\n', LF, trim($parts[2]))
2181 );
2182 $fieldCode = sprintf(
2183 '<textarea name="%s"%s cols="%s" rows="%s"%s%s>%s</textarea>',
2184 $confData['fieldname'],
2185 $elementIdAttribute,
2186 $cols,
2187 $rows,
2188 $wrap,
2189 $addParams,
2190 t3lib_div::formatForTextarea($default)
2191 );
2192 break;
2193 case 'input' :
2194 case 'password' :
2195 $size = trim($fParts[1]) ? intval($fParts[1]) : 20;
2196 $compWidth = doubleval($conf['compensateFieldWidth']
2197 ? $conf['compensateFieldWidth']
2198 : $GLOBALS['TSFE']->compensateFieldWidth
2199 );
2200 $compWidth = $compWidth ? $compWidth : 1;
2201 $size = t3lib_div::intInRange($size * $compWidth, 1, 120);
2202 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], trim($parts[2]));
2203
2204 if ($confData['type'] == 'password') {
2205 $default = '';
2206 }
2207
2208 $max = trim($fParts[2]) ? ' maxlength="' . t3lib_div::intInRange($fParts[2], 1, 1000) . '"' : "";
2209 $theType = $confData['type'] == 'input' ? 'text' : 'password';
2210
2211 $fieldCode = sprintf(
2212 '<input type="%s" name="%s"%s size="%s"%s value="%s"%s />',
2213 $theType,
2214 $confData['fieldname'],
2215 $elementIdAttribute,
2216 $size,
2217 $max,
2218 htmlspecialchars($default),
2219 $addParams
2220 );
2221
2222 break;
2223 case 'file' :
2224 $size = trim($fParts[1]) ? t3lib_div::intInRange($fParts[1], 1, 60) : 20;
2225 $fieldCode = sprintf(
2226 '<input type="file" name="%s"%s size="%s"%s />',
2227 $confData['fieldname'],
2228 $elementIdAttribute,
2229 $size,
2230 $addParams
2231 );
2232 break;
2233 case 'check' :
2234 // alternative default value:
2235 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], trim($parts[2]));
2236 $checked = $default ? ' checked="checked"' : '';
2237 $fieldCode = sprintf(
2238 '<input type="checkbox" value="%s" name="%s"%s%s%s />',
2239 1,
2240 $confData['fieldname'],
2241 $elementIdAttribute,
2242 $checked,
2243 $addParams
2244 );
2245 break;
2246 case 'select' :
2247 $option = '';
2248 $valueParts = explode(',', $parts[2]);
2249 // size
2250 if (strtolower(trim($fParts[1])) == 'auto') {
2251 $fParts[1] = count($valueParts);
2252 } // Auto size set here. Max 20
2253 $size = trim($fParts[1]) ? t3lib_div::intInRange($fParts[1], 1, 20) : 1;
2254 // multiple
2255 $multiple = strtolower(trim($fParts[2])) == 'm' ? ' multiple="multiple"' : '';
2256
2257 $items = array(); // Where the items will be
2258 $defaults = array(); //RTF
2259 $pCount = count($valueParts);
2260 for ($a = 0; $a < $pCount; $a++) {
2261 $valueParts[$a] = trim($valueParts[$a]);
2262 if (substr($valueParts[$a], 0, 1) == '*') { // Finding default value
2263 $sel = 'selected';
2264 $valueParts[$a] = substr($valueParts[$a], 1);
2265 } else
2266 $sel = '';
2267 // Get value/label
2268 $subParts = explode('=', $valueParts[$a]);
2269 $subParts[1] = (isset($subParts[1]) ? trim($subParts[1]) : trim($subParts[0])); // Sets the value
2270 $items[] = $subParts; // Adds the value/label pair to the items-array
2271 if ($sel) {
2272 $defaults[] = $subParts[1];
2273 } // Sets the default value if value/label pair is marked as default.
2274 }
2275 // alternative default value:
2276 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], $defaults);
2277 if (!is_array($default)) {
2278 $defaults = array();
2279 $defaults[] = $default;
2280 } else {
2281 $defaults = $default;
2282 }
2283 // Create the select-box:
2284 $iCount = count($items);
2285 for ($a = 0; $a < $iCount; $a++) {
2286 $option .= '<option value="' . $items[$a][1] . '"' . (in_array($items[$a][1], $defaults) ? ' selected="selected"' : '') . '>' . trim($items[$a][0]) . '</option>'; //RTF
2287 }
2288
2289 if ($multiple) {
2290 // The fieldname must be prepended '[]' if multiple select. And the reason why it's prepended is, because the required-field list later must also have [] prepended.
2291 $confData['fieldname'] .= '[]';
2292 }
2293 $fieldCode = sprintf(
2294 '<select name="%s"%s size="%s"%s%s>%s</select>',
2295 $confData['fieldname'],
2296 $elementIdAttribute,
2297 $size,
2298 $multiple,
2299 $addParams,
2300 $option
2301 ); //RTF
2302 break;
2303 case 'radio' :
2304 $option = '';
2305
2306 $valueParts = explode(',', $parts[2]);
2307 $items = array(); // Where the items will be
2308 $default = '';
2309 $pCount = count($valueParts);
2310 for ($a = 0; $a < $pCount; $a++) {
2311 $valueParts[$a] = trim($valueParts[$a]);
2312 if (substr($valueParts[$a], 0, 1) == '*') {
2313 $sel = 'checked';
2314 $valueParts[$a] = substr($valueParts[$a], 1);
2315 } else
2316 $sel = '';
2317 // Get value/label
2318 $subParts = explode('=', $valueParts[$a]);
2319 $subParts[1] = (isset($subParts[1]) ? trim($subParts[1]) : trim($subParts[0])); // Sets the value
2320 $items[] = $subParts; // Adds the value/label pair to the items-array
2321 if ($sel) {
2322 $default = $subParts[1];
2323 } // Sets the default value if value/label pair is marked as default.
2324 }
2325 // alternative default value:
2326 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], $default);
2327 // Create the select-box:
2328 $iCount = count($items);
2329 for ($a = 0; $a < $iCount; $a++) {
2330 $radioId = $prefix . $fName . $this->cleanFormName($items[$a][0]);
2331 if ($conf['accessibility']) {
2332 $radioLabelIdAttribute = ' id="' . $radioId . '"';
2333 } else {
2334 $radioLabelIdAttribute = '';
2335 }
2336 $option .= '<input type="radio" name="' . $confData['fieldname'] . '"' .
2337 $radioLabelIdAttribute . ' value="' . $items[$a][1] . '"' .
2338 (!strcmp($items[$a][1], $default) ? ' checked="checked"' : '') .
2339 $addParams . ' />';
2340 if ($conf['accessibility']) {
2341 $option .= '<label for="' . $radioId . '">' .
2342 $this->stdWrap(trim($items[$a][0]), $conf['radioWrap.']) .
2343 '</label>';
2344 } else {
2345 $option .= $this->stdWrap(trim($items[$a][0]), $conf['radioWrap.']);
2346 }
2347 }
2348
2349 if ($conf['accessibility']) {
2350 $accessibilityWrap = $conf['radioWrap.']['accessibilityWrap'];
2351
2352 $search = array(
2353 '###RADIO_FIELD_ID###', '###RADIO_GROUP_LABEL###'
2354 );
2355 $replace = array(
2356 $elementIdAttribute, $confData['label']
2357 );
2358 $accessibilityWrap = str_replace($search, $replace, $accessibilityWrap);
2359
2360 $option = $this->wrap($option, $accessibilityWrap);
2361 }
2362
2363 $fieldCode = $option;
2364 break;
2365 case 'hidden' :
2366 $value = trim($parts[2]);
2367
2368 // If this form includes an auto responder message, include a HMAC checksum field
2369 // in order to verify potential abuse of this feature.
2370 if (strlen($value) && t3lib_div::inList($confData['fieldname'], 'auto_respond_msg')) {
2371 $hmacChecksum = t3lib_div::hmac($value);
2372 $hiddenfields .= sprintf(
2373 '<input type="hidden" name="auto_respond_checksum" id="%sauto_respond_checksum" value="%s" />',
2374 $prefix,
2375 $hmacChecksum
2376 );
2377 }
2378
2379 if (strlen($value) && t3lib_div::inList('recipient_copy,recipient',
2380 $confData['fieldname']) && $GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail']) {
2381 break;
2382 }
2383 if (strlen($value) && t3lib_div::inList('recipient_copy,recipient', $confData['fieldname'])) {
2384 $value = $GLOBALS['TSFE']->codeString($value);
2385 }
2386 $hiddenfields .= sprintf(
2387 '<input type="hidden" name="%s"%s value="%s" />',
2388 $confData['fieldname'],
2389 $elementIdAttribute,
2390 htmlspecialchars($value)
2391 );
2392 break;
2393 case 'property' :
2394 if (t3lib_div::inList('type,locationData,goodMess,badMess,emailMess', $confData['fieldname'])) {
2395 $value = trim($parts[2]);
2396 $propertyOverride[$confData['fieldname']] = $value;
2397 $conf[$confData['fieldname']] = $value;
2398 }
2399 break;
2400 case 'submit' :
2401 $value = trim($parts[2]);
2402 if ($conf['image.']) {
2403 $this->data[$this->currentValKey] = $value;
2404 $image = $this->IMG_RESOURCE($conf['image.']);
2405 $params = $conf['image.']['params'] ? ' ' . $conf['image.']['params'] : '';
2406 $params .= $this->getAltParam($conf['image.'], FALSE);
2407 $params .= $addParams;
2408 } else {
2409 $image = '';
2410 }
2411 if ($image) {
2412 $fieldCode = sprintf(
2413 '<input type="image" name="%s"%s src="%s"%s />',
2414 $confData['fieldname'],
2415 $elementIdAttribute,
2416 $image,
2417 $params
2418 );
2419 } else {
2420 $fieldCode = sprintf(
2421 '<input type="submit" name="%s"%s value="%s"%s />',
2422 $confData['fieldname'],
2423 $elementIdAttribute,
2424 t3lib_div::deHSCentities(htmlspecialchars($value)),
2425 $addParams
2426 );
2427 }
2428 break;
2429 case 'reset' :
2430 $value = trim($parts[2]);
2431 $fieldCode = sprintf(
2432 '<input type="reset" name="%s"%s value="%s"%s />',
2433 $confData['fieldname'],
2434 $elementIdAttribute,
2435 t3lib_div::deHSCentities(htmlspecialchars($value)),
2436 $addParams
2437 );
2438 break;
2439 case 'label' :
2440 $fieldCode = nl2br(htmlspecialchars(trim($parts[2])));
2441 break;
2442 default :
2443 $confData['type'] = 'comment';
2444 $fieldCode = trim($parts[2]) . '&nbsp;';
2445 break;
2446 }
2447 if ($fieldCode) {
2448
2449 // Checking for special evaluation modes:
2450 if (t3lib_div::inList('textarea,input,password', $confData['type']) && strlen(trim($parts[3]))) {
2451 $modeParameters = t3lib_div::trimExplode(':', $parts[3]);
2452 } else {
2453 $modeParameters = array();
2454 }
2455
2456 // Adding evaluation based on settings:
2457 switch ((string) $modeParameters[0]) {
2458 case 'EREG' :
2459 $fieldlist[] = '_EREG';
2460 $fieldlist[] = $modeParameters[1];
2461 $fieldlist[] = $modeParameters[2];
2462 $fieldlist[] = $confData['fieldname'];
2463 $fieldlist[] = $confData['label'];
2464 $confData['required'] = 1; // Setting this so "required" layout is used.
2465 break;
2466 case 'EMAIL' :
2467 $fieldlist[] = '_EMAIL';
2468 $fieldlist[] = $confData['fieldname'];
2469 $fieldlist[] = $confData['label'];
2470 $confData['required'] = 1; // Setting this so "required" layout is used.
2471 break;
2472 default :
2473 if ($confData['required']) {
2474 $fieldlist[] = $confData['fieldname'];
2475 $fieldlist[] = $confData['label'];
2476 }
2477 break;
2478 }
2479
2480 // Field:
2481 $fieldLabel = $confData['label'];
2482 if ($conf['accessibility'] && trim($fieldLabel) && !preg_match('/^(label|hidden|comment)$/', $confData['type'])) {
2483 $fieldLabel = '<label for="' . $prefix . $fName . '">' . $fieldLabel . '</label>';
2484 }
2485
2486 // Getting template code:
2487 $fieldCode = $this->stdWrap($fieldCode, $conf['fieldWrap.']);
2488 $labelCode = $this->stdWrap($fieldLabel, $conf['labelWrap.']);
2489 $commentCode = $this->stdWrap($confData['label'], $conf['commentWrap.']); // RTF
2490 $result = $conf['layout'];
2491 if ($conf['REQ'] && $confData['required']) {
2492 if (is_array($conf['REQ.']['fieldWrap.']))
2493 $fieldCode = $this->stdWrap($fieldCode, $conf['REQ.']['fieldWrap.']);
2494 if (is_array($conf['REQ.']['labelWrap.']))
2495 $labelCode = $this->stdWrap($fieldLabel, $conf['REQ.']['labelWrap.']);
2496 if ($conf['REQ.']['layout']) {
2497 $result = $conf['REQ.']['layout'];
2498 }
2499 }
2500 if ($confData['type'] == 'comment' && $conf['COMMENT.']['layout']) {
2501 $result = $conf['COMMENT.']['layout'];
2502 }
2503 if ($confData['type'] == 'check' && $conf['CHECK.']['layout']) {
2504 $result = $conf['CHECK.']['layout'];
2505 }
2506 if ($confData['type'] == 'radio' && $conf['RADIO.']['layout']) {
2507 $result = $conf['RADIO.']['layout'];
2508 }
2509 if ($confData['type'] == 'label' && $conf['LABEL.']['layout']) {
2510 $result = $conf['LABEL.']['layout'];
2511 }
2512 $result = str_replace('###FIELD###', $fieldCode, $result);
2513 $result = str_replace('###LABEL###', $labelCode, $result);
2514 $result = str_replace('###COMMENT###', $commentCode, $result); //RTF
2515 $content .= $result;
2516 }
2517 }
2518 }
2519 if ($conf['stdWrap.']) {
2520 $content = $this->stdWrap($content, $conf['stdWrap.']);
2521 }
2522
2523
2524 // redirect (external: where to go afterwards. internal: where to submit to)
2525 $theRedirect = $this->stdWrap($conf['redirect'], $conf['redirect.']); // redirect should be set to the page to redirect to after an external script has been used. If internal scripts is used, and if no 'type' is set that dictates otherwise, redirect is used as the url to jump to as long as it's an integer (page)
2526 $page = $GLOBALS['TSFE']->page;
2527 if (!$theRedirect) { // Internal: Just submit to current page
2528 $LD = $GLOBALS['TSFE']->tmpl->linkData(
2529 $page,
2530 $conf['target'],
2531 $conf['no_cache'],
2532 'index.php',
2533 '',
2534 $this->getClosestMPvalueForPage($page['uid'])
2535 );
2536 } elseif (t3lib_div::testInt($theRedirect)) { // Internal: Submit to page with ID $theRedirect
2537 $page = $GLOBALS['TSFE']->sys_page->getPage_noCheck($theRedirect);
2538 $LD = $GLOBALS['TSFE']->tmpl->linkData(
2539 $page,
2540 $conf['target'],
2541 $conf['no_cache'],
2542 'index.php',
2543 '',
2544 $this->getClosestMPvalueForPage($page['uid'])
2545 );
2546 } else { // External URL, redirect-hidden field is rendered!
2547 $LD = $GLOBALS['TSFE']->tmpl->linkData(
2548 $page,
2549 $conf['target'],
2550 $conf['no_cache'],
2551 '',
2552 '',
2553 $this->getClosestMPvalueForPage($page['uid'])
2554 );
2555 $LD['totalURL'] = $theRedirect;
2556 $hiddenfields .= '<input type="hidden" name="redirect" value="' . htmlspecialchars($LD['totalURL']) . '" />'; // 18-09-00 added
2557 }
2558
2559 // Formtype (where to submit to!):
2560 $formtype = $propertyOverride['type'] ? $propertyOverride['type'] : $this->stdWrap($conf['type'], $conf['type.']);
2561 if (t3lib_div::testInt($formtype)) { // Submit to a specific page
2562 $page = $GLOBALS['TSFE']->sys_page->getPage_noCheck($formtype);
2563 $LD_A = $GLOBALS['TSFE']->tmpl->linkData(
2564 $page,
2565 $conf['target'],
2566 $conf['no_cache'],
2567 '',
2568 '',
2569 $this->getClosestMPvalueForPage($page['uid'])
2570 );
2571 $action = $LD_A['totalURL'];
2572 } elseif ($formtype) { // Submit to external script
2573 $LD_A = $LD;
2574 $action = $formtype;
2575 } elseif (t3lib_div::testInt($theRedirect)) {
2576 $LD_A = $LD;
2577 $action = $LD_A['totalURL'];
2578 } else { // Submit to "nothing" - which is current page
2579 $LD_A = $GLOBALS['TSFE']->tmpl->linkData(
2580 $GLOBALS['TSFE']->page,
2581 $conf['target'],
2582 $conf['no_cache'],
2583 '',
2584 '',
2585 $this->getClosestMPvalueForPage($page['uid'])
2586 );
2587 $action = $LD_A['totalURL'];
2588 }
2589
2590 // Recipient:
2591 $theEmail = $this->stdWrap($conf['recipient'], $conf['recipient.']);
2592 if ($theEmail && !$GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail']) {
2593 $theEmail = $GLOBALS['TSFE']->codeString($theEmail);
2594 $hiddenfields .= '<input type="hidden" name="recipient" value="' . htmlspecialchars($theEmail) . '" />';
2595 }
2596
2597 // location data:
2598 if ($conf['locationData']) {
2599 if ($conf['locationData'] == 'HTTP_POST_VARS' && isset($_POST['locationData'])) {
2600 $locationData = t3lib_div::_POST('locationData');
2601 } else {
2602 // locationData is [hte page id]:[tablename]:[uid of record]. Indicates on which page the record (from tablename with uid) is shown. Used to check access.
2603 $locationData = $GLOBALS['TSFE']->id . ':' . $this->currentRecord;
2604 }
2605 $hiddenfields .= '<input type="hidden" name="locationData" value="' . htmlspecialchars($locationData) . '" />';
2606 }
2607
2608 // hidden fields:
2609 if (is_array($conf['hiddenFields.'])) {
2610 foreach ($conf['hiddenFields.'] as $hF_key => $hF_conf) {
2611 if (substr($hF_key, -1) != '.') {
2612 $hF_value = $this->cObjGetSingle($hF_conf, $conf['hiddenFields.'][$hF_key . '.'], 'hiddenfields');
2613 if (strlen($hF_value) && t3lib_div::inList('recipient_copy,recipient', $hF_key)) {
2614 if ($GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail']) {
2615 continue;
2616 }
2617 $hF_value = $GLOBALS['TSFE']->codeString($hF_value);
2618 }
2619 $hiddenfields .= '<input type="hidden" name="' . $hF_key . '" value="' . htmlspecialchars($hF_value) . '" />';
2620 }
2621 }
2622 }
2623
2624 // Wrap all hidden fields in a div tag (see http://bugs.typo3.org/view.php?id=678)
2625 $hiddenfields = '<div style="display:none;">' . $hiddenfields . '</div>';
2626
2627 if ($conf['REQ']) {
2628 $validateForm = ' onsubmit="return validateForm(\'' . $formname . '\',\'' . implode(',', $fieldlist)
2629 . '\',' . t3lib_div::quoteJSvalue($conf['goodMess']) . ',' .
2630 t3lib_div::quoteJSvalue($conf['badMess']) . ',' .
2631 t3lib_div::quoteJSvalue($conf['emailMess']) . ')"';
2632 $GLOBALS['TSFE']->additionalHeaderData['JSFormValidate'] = '<script type="text/javascript" src="' .
2633 t3lib_div::createVersionNumberedFilename($GLOBALS['TSFE']->absRefPrefix .
2634 't3lib/jsfunc.validateform.js') . '"></script>';
2635 } else {
2636 $validateForm = '';
2637 }
2638
2639 // Create form tag:
2640 $theTarget = ($theRedirect ? $LD['target'] : $LD_A['target']);
2641 $content = array(
2642 '<form' . ' action="' . htmlspecialchars($action) . '"' . ' id="' .
2643 $formname . '"' . ($xhtmlStrict ? '' : ' name="' . $formname . '"') .
2644 ' enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '"' .
2645 ' method="' . ($conf['method'] ? $conf['method'] : 'post') . '"' .
2646 ($theTarget ? ' target="' . $theTarget . '"' : '') .
2647 $validateForm . '>', $hiddenfields . $content,
2648 '</form>'
2649 );
2650
2651 if ($conf['arrayReturnMode']) {
2652 $content['validateForm'] = $validateForm;
2653 $content['formname'] = $formname;
2654 return $content;
2655 } else {
2656 return implode('', $content);
2657 }
2658 }
2659
2660 /**
2661 * Rendering the cObject, SEARCHRESULT
2662 *
2663 * @param array array of TypoScript properties
2664 * @return string Output
2665 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=368&cHash=d00731cd7b
2666 */
2667 function SEARCHRESULT($conf) {
2668 if (t3lib_div::_GP('sword') && t3lib_div::_GP('scols')) {
2669 $search = t3lib_div::makeInstance('tslib_search');
2670 $search->register_and_explode_search_string(t3lib_div::_GP('sword'));
2671 $search->register_tables_and_columns(t3lib_div::_GP('scols'), $conf['allowedCols']);
2672 // depth
2673 $depth = 100;
2674 // the startId is found
2675 $theStartId = 0;
2676 if (t3lib_div::testInt(t3lib_div::_GP('stype'))) {
2677 $temp_theStartId = t3lib_div::_GP('stype');
2678 $rootLine = $GLOBALS['TSFE']->sys_page->getRootLine($temp_theStartId);
2679 // The page MUST have a rootline with the Level0-page of the current site inside!!
2680 foreach ($rootLine as $val) {
2681 if ($val['uid'] == $GLOBALS['TSFE']->tmpl->rootLine[0]['uid']) {
2682 $theStartId = $temp_theStartId;
2683 }
2684 }
2685 } else if (t3lib_div::_GP('stype')) {
2686 if (substr(t3lib_div::_GP('stype'), 0, 1) == 'L') {
2687 $pointer = intval(substr(t3lib_div::_GP('stype'), 1));
2688 $theRootLine = $GLOBALS['TSFE']->tmpl->rootLine;
2689 // location Data:
2690 $locDat_arr = explode(':', t3lib_div::_POST('locationData'));
2691 $pId = intval($locDat_arr[0]);
2692 if ($pId) {
2693 $altRootLine = $GLOBALS['TSFE']->sys_page->getRootLine($pId);
2694 ksort($altRootLine);
2695 if (count($altRootLine)) {
2696 // check if the rootline has the real Level0 in it!!
2697 $hitRoot = 0;
2698 $theNewRoot = array();
2699 foreach ($altRootLine as $val) {
2700 if ($hitRoot || $val['uid'] == $GLOBALS['TSFE']->tmpl->rootLine[0]['uid']) {
2701 $hitRoot = 1;
2702 $theNewRoot[] = $val;
2703 }
2704 }
2705 if ($hitRoot) {
2706 $theRootLine = $theNewRoot; // Override the real rootline if any thing
2707 }
2708 }
2709 }
2710 $key = $this->getKey($pointer, $theRootLine);
2711 $theStartId = $theRootLine[$key]['uid'];
2712 }
2713 }
2714 if (!$theStartId) {
2715 // If not set, we use current page
2716 $theStartId = $GLOBALS['TSFE']->id;
2717