Added feature #16008: A new TypoScript cObject: FLUIDTEMPLATE
[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 'FLUIDTEMPLATE':
846 $content .= $this->FLUIDTEMPLATE($conf);
847 break;
848 case 'EDITPANEL' :
849 if ($GLOBALS['TSFE']->beUserLogin) {
850 $content .= $this->editPanel($content, $conf);
851 }
852 break;
853 case 'MULTIMEDIA' :
854 $content .= $this->MULTIMEDIA($conf);
855 break;
856 case 'MEDIA' :
857 $content .= $this->MEDIA($conf);
858 break;
859 case 'SWFOBJECT' :
860 $content .= $this->SWFOBJECT($conf);
861 break;
862 case 'QTOBJECT' :
863 $content .= $this->QTOBJECT($conf);
864 break;
865 case 'SVG' :
866 $content .= $this->SVG($conf);
867 break;
868 default :
869 // call hook functions for extra processing
870 if ($name && is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClassDefault'])) {
871 foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClassDefault'] as $classData) {
872 $hookObject = t3lib_div::getUserObj($classData);
873
874 if (!($hookObject instanceof tslib_content_cObjGetSingleHook)) {
875 throw new UnexpectedValueException(
876 '$hookObject must implement interface tslib_content_cObjGetSingleHook',
877 1195043731
878 );
879 }
880 /* @var $hookObject tslib_content_cObjGetSingleHook */
881 $content .= $hookObject->getSingleContentObject($name, (array) $conf, $TSkey, $this);
882 }
883 }
884 break;
885 }
886 }
887 }
888 if ($GLOBALS['TT']->LR)
889 $GLOBALS['TT']->pull($content);
890 }
891 // Increasing on exit...
892 $GLOBALS['TSFE']->cObjectDepthCounter++;
893 return $content;
894 }
895
896
897
898 /********************************************
899 *
900 * Functions rendering content objects (cObjects)
901 *
902 ********************************************/
903
904 /**
905 * Rendering the cObject, HTML
906 *
907 * @param array array of TypoScript properties
908 * @return string Output
909 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=349&cHash=d3fd0c70b4
910 */
911 function HTML($conf) {
912 return $this->stdWrap($conf['value'], $conf['value.']);
913 }
914
915 /**
916 * Rendering the cObject, TEXT
917 *
918 * @param array array of TypoScript properties
919 * @return string Output
920 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=350&cHash=b49de28f83
921 */
922 function TEXT($conf) {
923 return $this->stdWrap($conf['value'], $conf);
924 }
925
926 /**
927 * Rendering the cObject, CLEARGIF
928 *
929 * @param array array of TypoScript properties
930 * @return string Output
931 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=355&cHash=70c0f19915
932 */
933 function CLEARGIF($conf) {
934 $w = $this->stdWrap($conf['width'], $conf['width.']);
935 $h = $this->stdWrap($conf['height'], $conf['height.']);
936 $w = $w ? $w : 1;
937 $h = $h ? $h : 1;
938 $wrap = $conf['wrap'] ? $conf['wrap'] : '|<br />';
939 $theValue = $this->wrap(
940 '<img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' . $w . '" height="' . $h . '"' .
941 $this->getBorderAttr(' border="0"') . ' alt="" title="" />',
942 $wrap
943 );
944
945 return $this->stdWrap($theValue, $conf['stdWrap.']);
946 }
947
948 /**
949 * Rendering the cObject, COBJ_ARRAY / COA and COBJ_ARRAY_INT
950 *
951 * @param array array of TypoScript properties
952 * @param string If "INT" then the cObject is a "COBJ_ARRAY_INT" (non-cached), otherwise just "COBJ_ARRAY" (cached)
953 * @return string Output
954 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=351&cHash=a09db0329c
955 */
956 function COBJ_ARRAY($conf, $ext = '') {
957
958 if (is_array($conf)) {
959 $content = '';
960 switch ($ext) {
961 case 'INT' :
962 $substKey = $ext . '_SCRIPT.' . $GLOBALS['TSFE']->uniqueHash();
963 $content .= '<!--' . $substKey . '-->';
964 $GLOBALS['TSFE']->config[$ext . 'incScript'][$substKey] = array(
965 'file' => $conf['includeLibs'],
966 'conf' => $conf,
967 'cObj' => serialize($this),
968 'type' => 'COA'
969 );
970 break;
971 default :
972 if ($this->checkIf($conf['if.'])) {
973 $this->includeLibs($conf);
974 $content = $this->cObjGet($conf);
975 if ($conf['wrap']) {
976 $content = $this->wrap($content, $conf['wrap']);
977 }
978 if ($conf['stdWrap.']) {
979 $content = $this->stdWrap($content, $conf['stdWrap.']);
980 }
981 }
982 break;
983 }
984 return $content;
985 } else {
986 $GLOBALS['TT']->setTSlogMessage('No elements in this content object array(COBJ_ARRAY, COA, COA_INT).', 2);
987 }
988 }
989
990 /**
991 * Rendering the cObject, USER and USER_INT
992 *
993 * @param array array of TypoScript properties
994 * @param string If "INT" then the cObject is a "USER_INT" (non-cached), otherwise just "USER" (cached)
995 * @return string Output
996 * @link http://typo3.org/documentation/document-library/references/doc_core_tsref/4.1.0/view/8/22/
997 */
998 function USER($conf, $ext = '') {
999 $content = '';
1000 switch ($ext) {
1001 case 'INT' :
1002 $this->userObjectType = self::OBJECTTYPE_USER_INT;
1003 $substKey = $ext . '_SCRIPT.' . $GLOBALS['TSFE']->uniqueHash();
1004 $content .= '<!--' . $substKey . '-->';
1005 $GLOBALS['TSFE']->config[$ext . 'incScript'][$substKey] = array(
1006 'file' => $conf['includeLibs'],
1007 'conf' => $conf,
1008 'cObj' => serialize($this),
1009 'type' => 'FUNC'
1010 );
1011 break;
1012 default :
1013 if ($this->userObjectType === FALSE) {
1014 // Come here only if we are not called from $TSFE->INTincScript_process()!
1015 $this->userObjectType = self::OBJECTTYPE_USER;
1016 }
1017 $this->includeLibs($conf);
1018 $tempContent = $this->callUserFunction($conf['userFunc'], $conf, '');
1019 if ($this->doConvertToUserIntObject) {
1020 $this->doConvertToUserIntObject = FALSE;
1021 $content = $this->USER($conf, 'INT');
1022 } else {
1023 $content .= $tempContent;
1024 }
1025 break;
1026 }
1027 $this->userObjectType = FALSE;
1028 return $content;
1029 }
1030
1031 /**
1032 * Retrieves a type of object called as USER or USER_INT. Object can detect their
1033 * type by using this call. It returns OBJECTTYPE_USER_INT or OBJECTTYPE_USER depending on the
1034 * current object execution. In all other cases it will return FALSE to indicate
1035 * a call out of context.
1036 *
1037 * @return mixed One of OBJECTTYPE_ class constants or FALSE
1038 */
1039 public function getUserObjectType() {
1040 return $this->userObjectType;
1041 }
1042
1043 /**
1044 * Requests the current USER object to be converted to USER_INT.
1045 *
1046 * @return void
1047 */
1048 public function convertToUserIntObject() {
1049 if ($this->userObjectType !== self::OBJECTTYPE_USER) {
1050 $GLOBALS['TT']->setTSlogMessage('tslib_cObj::convertToUserIntObject() ' . 'is called in the wrong context or for the wrong object type', 2);
1051 } else {
1052 $this->doConvertToUserIntObject = TRUE;
1053 }
1054 }
1055
1056 /**
1057 * Rendering the cObject, FILE
1058 *
1059 * @param array array of TypoScript properties
1060 * @return string Output
1061 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=352&cHash=379c60f8bc
1062 */
1063 function FILE($conf) {
1064 $theValue = $this->fileResource($this->stdWrap($conf['file'], $conf['file.']), trim($this->getAltParam($conf, FALSE)));
1065 if ($conf['linkWrap']) {
1066 $theValue = $this->linkWrap($theValue, $conf['linkWrap']);
1067 }
1068 return $this->wrap($theValue, $conf['wrap']);
1069 }
1070
1071 /**
1072 * Rendering the cObject, IMAGE
1073 *
1074 * @param array array of TypoScript properties
1075 * @return string Output
1076 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=353&cHash=440681ea56
1077 * @see cImage()
1078 */
1079 function IMAGE($conf) {
1080 $content = '';
1081 if ($this->checkIf($conf['if.'])) {
1082 $theValue = $this->cImage($conf['file'], $conf);
1083 if ($conf['stdWrap.']) {
1084 $theValue = $this->stdWrap($theValue, $conf['stdWrap.']);
1085 }
1086 return $theValue;
1087 }
1088 }
1089
1090 /**
1091 * Rendering the cObject, IMG_RESOURCE
1092 *
1093 * @param array array of TypoScript properties
1094 * @return string Output
1095 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=354&cHash=46f9299706
1096 * @see getImgResource()
1097 */
1098 function IMG_RESOURCE($conf) {
1099 $GLOBALS['TSFE']->lastImgResourceInfo = $this->getImgResource($conf['file'], $conf['file.']);
1100 return $this->stdWrap($GLOBALS['TSFE']->lastImgResourceInfo[3], $conf['stdWrap.']);
1101 }
1102
1103 /**
1104 * Rendering the cObject, IMGTEXT
1105 *
1106 * @param array array of TypoScript properties
1107 * @return string Output
1108 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=363&cHash=cf2969bce1
1109 */
1110 function IMGTEXT($conf) {
1111 $content = '';
1112 if (is_array($conf['text.'])) {
1113 $content .= $this->stdWrap($this->cObjGet($conf['text.'], 'text.'), $conf['text.']); // this gets the surrounding content
1114 }
1115 $imgList = trim($this->stdWrap($conf['imgList'], $conf['imgList.'])); // gets images
1116 if ($imgList) {
1117 $imgs = t3lib_div::trimExplode(',', $imgList);
1118 $imgStart = intval($this->stdWrap($conf['imgStart'], $conf['imgStart.']));
1119
1120 $imgCount = count($imgs) - $imgStart;
1121
1122 $imgMax = intval($this->stdWrap($conf['imgMax'], $conf['imgMax.']));
1123 if ($imgMax) {
1124 $imgCount = t3lib_div::intInRange($imgCount, 0, $imgMax); // reduces the number of images.
1125 }
1126
1127 $imgPath = $this->stdWrap($conf['imgPath'], $conf['imgPath.']);
1128
1129 // initialisation
1130 $caption = '';
1131 $captionArray = array();
1132 if (!$conf['captionSplit'] && !$conf['imageTextSplit'] && is_array($conf['caption.'])) {
1133 $caption = $this->stdWrap($this->cObjGet($conf['caption.'], 'caption.'), $conf['caption.']); // global caption, no splitting
1134 }
1135 if ($conf['captionSplit'] && $conf['captionSplit.']['cObject']) {
1136 $legacyCaptionSplit = 1;
1137 $capSplit = $this->stdWrap($conf['captionSplit.']['token'], $conf['captionSplit.']['token.']);
1138 if (!$capSplit) {
1139 $capSplit = LF;
1140 }
1141 $captionArray = explode($capSplit, $this->cObjGetSingle(
1142 $conf['captionSplit.']['cObject'],
1143 $conf['captionSplit.']['cObject.'],
1144 'captionSplit.cObject')
1145 );
1146 foreach ($captionArray as $ca_key => $ca_val) {
1147 $captionArray[$ca_key] = $this->stdWrap(trim($captionArray[$ca_key]), $conf['captionSplit.']['stdWrap.']);
1148 }
1149 }
1150
1151 $tablecode = '';
1152 $position = $this->stdWrap($conf['textPos'], $conf['textPos.']);
1153
1154 $tmppos = $position & 7;
1155 $contentPosition = $position & 24;
1156 $align = $this->align[$tmppos];
1157 $cap = ($caption) ? 1 : 0;
1158 $txtMarg = intval($this->stdWrap($conf['textMargin'], $conf['textMargin.']));
1159 if (!$conf['textMargin_outOfText'] && $contentPosition < 16) {
1160 $txtMarg = 0;
1161 }
1162
1163 $cols = intval($this->stdWrap($conf['cols'], $conf['cols.']));
1164 $rows = intval($this->stdWrap($conf['rows'], $conf['rows.']));
1165 $colspacing = intval($this->stdWrap($conf['colSpace'], $conf['colSpace.']));
1166 $rowspacing = intval($this->stdWrap($conf['rowSpace'], $conf['rowSpace.']));
1167
1168 $border = intval($this->stdWrap($conf['border'], $conf['border.'])) ? 1 : 0;
1169 $borderColor = $this->stdWrap($conf['borderCol'], $conf['borderCol.']);
1170 $borderThickness = intval($this->stdWrap($conf['borderThick'], $conf['borderThick.']));
1171
1172 $borderColor = $borderColor ? $borderColor : 'black';
1173 $borderThickness = $borderThickness ? $borderThickness : 1;
1174
1175 $caption_align = $this->stdWrap($conf['captionAlign'], $conf['captionAlign.']);
1176 if (!$caption_align) {
1177 $caption_align = $align;
1178 }
1179 // generate cols
1180 $colCount = ($cols > 1) ? $cols : 1;
1181 if ($colCount > $imgCount) {
1182 $colCount = $imgCount;
1183 }
1184 $rowCount = ($colCount > 1) ? ceil($imgCount / $colCount) : $imgCount;
1185 // generate rows
1186 if ($rows > 1) {
1187 $rowCount = $rows;
1188 if ($rowCount > $imgCount) {
1189 $rowCount = $imgCount;
1190 }
1191 $colCount = ($rowCount > 1) ? ceil($imgCount / $rowCount) : $imgCount;
1192 }
1193
1194 // max Width
1195 $colRelations = trim($this->stdWrap($conf['colRelations'], $conf['colRelations.']));
1196 $maxW = intval($this->stdWrap($conf['maxW'], $conf['maxW.']));
1197
1198 $maxWInText = intval($this->stdWrap($conf['maxWInText'], $conf['maxWInText.']));
1199 if (!$maxWInText) { // If maxWInText is not set, it's calculated to the 50 % of the max...
1200 $maxWInText = round($maxW / 2);
1201 }
1202
1203 if ($maxWInText && $contentPosition >= 16) { // inText
1204 $maxW = $maxWInText;
1205 }
1206
1207 if ($maxW && $colCount > 0) { // If there is a max width and if colCount is greater than column
1208 $maxW = ceil(($maxW - $colspacing * ($colCount - 1) - $colCount * $border * $borderThickness * 2) / $colCount);
1209 }
1210 // create the relation between rows
1211 $colMaxW = array();
1212 if ($colRelations) {
1213 $rel_parts = explode(':', $colRelations);
1214 $rel_total = 0;
1215 for ($a = 0; $a < $colCount; $a++) {
1216 $rel_parts[$a] = intval($rel_parts[$a]);
1217 $rel_total += $rel_parts[$a];
1218 }
1219 if ($rel_total) {
1220 for ($a = 0; $a < $colCount; $a++) {
1221 $colMaxW[$a] = round(($maxW * $colCount) / $rel_total * $rel_parts[$a]);
1222 }
1223 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.
1224 $colMaxW = array();
1225 }
1226 }
1227 }
1228 $image_compression = intval($this->stdWrap($conf['image_compression'], $conf['image_compression.']));
1229 $image_effects = intval($this->stdWrap($conf['image_effects'], $conf['image_effects.']));
1230 $image_frames = intval($this->stdWrap($conf['image_frames.']['key'], $conf['image_frames.']['key.']));
1231
1232 // fetches pictures
1233 $splitArr = array();
1234 $splitArr['imgObjNum'] = $conf['imgObjNum'];
1235 $splitArr = $GLOBALS['TSFE']->tmpl->splitConfArray($splitArr, $imgCount);
1236
1237 // EqualHeight
1238 $equalHeight = intval($this->stdWrap($conf['equalH'], $conf['equalH.']));
1239 if ($equalHeight) { // Initiate gifbuilder object in order to get dimensions AND calculate the imageWidth's
1240 $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
1241 $gifCreator->init();
1242 $relations = array();
1243 $relations_cols = array();
1244 $totalMaxW = $maxW * $colCount;
1245 for ($a = 0; $a < $imgCount; $a++) {
1246 $imgKey = $a + $imgStart;
1247 $imgInfo = $gifCreator->getImageDimensions($imgPath . $imgs[$imgKey]);
1248 $relations[$a] = $imgInfo[1] / $equalHeight; // relationship between the original height and the wished height
1249 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.
1250 $relations_cols[floor($a / $colCount)] += $imgInfo[0] / $relations[$a]; // counts the total width of the row with the new height taken into consideration.
1251 }
1252 }
1253 }
1254
1255 $imageRowsFinalWidths = array(); // contains the width of every image row
1256 $imageRowsMaxHeights = array();
1257 $imgsTag = array();
1258 $origImages = array();
1259 for ($a = 0; $a < $imgCount; $a++) {
1260 $GLOBALS['TSFE']->register['IMAGE_NUM'] = $a;
1261 $GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = $a;
1262
1263 $imgKey = $a + $imgStart;
1264 $totalImagePath = $imgPath . $imgs[$imgKey];
1265 $this->data[$this->currentValKey] = $totalImagePath;
1266 $imgObjNum = intval($splitArr[$a]['imgObjNum']);
1267 $imgConf = $conf[$imgObjNum . '.'];
1268
1269 if ($equalHeight) {
1270 $scale = 1;
1271 if ($totalMaxW) {
1272 $rowTotalMaxW = $relations_cols[floor($a / $colCount)];
1273 if ($rowTotalMaxW > $totalMaxW) {
1274 $scale = $rowTotalMaxW / $totalMaxW;
1275 }
1276 }
1277 // transfer info to the imageObject. Please note, that
1278 $imgConf['file.']['height'] = round($equalHeight / $scale);
1279
1280 unset(
1281 $imgConf['file.']['width'],
1282 $imgConf['file.']['maxW'],
1283 $imgConf['file.']['maxH'],
1284 $imgConf['file.']['minW'],
1285 $imgConf['file.']['minH'],
1286 $imgConf['file.']['width.'],
1287 $imgConf['file.']['maxW.'],
1288 $imgConf['file.']['maxH.'],
1289 $imgConf['file.']['minW.'],
1290 $imgConf['file.']['minH.']
1291 );
1292 $maxW = 0; // setting this to zero, so that it doesn't disturb
1293 }
1294
1295 if ($maxW) {
1296 if (count($colMaxW)) {
1297 $imgConf['file.']['maxW'] = $colMaxW[($a % $colCount)];
1298 } else {
1299 $imgConf['file.']['maxW'] = $maxW;
1300 }
1301 }
1302
1303 // Image Object supplied:
1304 if (is_array($imgConf)) {
1305 if ($this->image_effects[$image_effects]) {
1306 $imgConf['file.']['params'] .= ' ' . $this->image_effects[$image_effects];
1307 }
1308 if ($image_frames) {
1309 if (is_array($conf['image_frames.'][$image_frames . '.'])) {
1310 $imgConf['file.']['m.'] = $conf['image_frames.'][$image_frames . '.'];
1311 }
1312 }
1313 if ($image_compression && $imgConf['file'] != 'GIFBUILDER') {
1314 if ($image_compression == 1) {
1315 $tempImport = $imgConf['file.']['import'];
1316 $tempImport_dot = $imgConf['file.']['import.'];
1317 unset($imgConf['file.']);
1318 $imgConf['file.']['import'] = $tempImport;
1319 $imgConf['file.']['import.'] = $tempImport_dot;
1320 } elseif (isset($this->image_compression[$image_compression])) {
1321 $imgConf['file.']['params'] .= ' ' . $this->image_compression[$image_compression]['params'];
1322 $imgConf['file.']['ext'] = $this->image_compression[$image_compression]['ext'];
1323 unset($imgConf['file.']['ext.']);
1324 }
1325 }
1326
1327 // "alt", "title" and "longdesc" attributes:
1328 if (!strlen($imgConf['altText']) && !is_array($imgConf['altText.'])) {
1329 $imgConf['altText'] = $conf['altText'];
1330 $imgConf['altText.'] = $conf['altText.'];
1331 }
1332 if (!strlen($imgConf['titleText']) && !is_array($imgConf['titleText.'])) {
1333 $imgConf['titleText'] = $conf['titleText'];
1334 $imgConf['titleText.'] = $conf['titleText.'];
1335 }
1336 if (!strlen($imgConf['longdescURL']) && !is_array($imgConf['longdescURL.'])) {
1337 $imgConf['longdescURL'] = $conf['longdescURL'];
1338 $imgConf['longdescURL.'] = $conf['longdescURL.'];
1339 }
1340 } else {
1341 $imgConf = array(
1342 'altText' => $conf['altText'],
1343 'titleText' => $conf['titleText'],
1344 'longdescURL' => $conf['longdescURL'],
1345 'file' => $totalImagePath
1346 );
1347 }
1348
1349 $imgsTag[$imgKey] = $this->IMAGE($imgConf);
1350
1351 // Store the original filepath
1352 $origImages[$imgKey] = $GLOBALS['TSFE']->lastImageInfo;
1353
1354 $imageRowsFinalWidths[floor($a / $colCount)] += $GLOBALS['TSFE']->lastImageInfo[0];
1355 if ($GLOBALS['TSFE']->lastImageInfo[1] > $imageRowsMaxHeights[floor($a / $colCount)]) {
1356 $imageRowsMaxHeights[floor($a / $colCount)] = $GLOBALS['TSFE']->lastImageInfo[1];
1357 }
1358 }
1359 // calculating the tableWidth:
1360 // TableWidth problems: It creates problems if the pictures are NOT as wide as the tableWidth.
1361 $tableWidth = max($imageRowsFinalWidths) + $colspacing * ($colCount - 1) + $colCount * $border * $borderThickness * 2;
1362
1363 // make table for pictures
1364 $index = $imgIndex = $imgStart;
1365
1366 $noRows = $this->stdWrap($conf['noRows'], $conf['noRows.']);
1367 $noCols = $this->stdWrap($conf['noCols'], $conf['noCols.']);
1368 if ($noRows) {
1369 $noCols = 0;
1370 } // noRows overrides noCols. They cannot exist at the same time.
1371 if ($equalHeight) {
1372 $noCols = 1;
1373 $noRows = 0;
1374 }
1375
1376 $rowCount_temp = 1;
1377 $colCount_temp = $colCount;
1378 if ($noRows) {
1379 $rowCount_temp = $rowCount;
1380 $rowCount = 1;
1381 }
1382 if ($noCols) {
1383 $colCount = 1;
1384 }
1385 // col- and rowspans calculated
1386 $colspan = (($colspacing) ? $colCount * 2 - 1 : $colCount);
1387 $rowspan = (($rowspacing) ? $rowCount * 2 - 1 : $rowCount) + $cap;
1388
1389
1390 // Edit icons:
1391 $editIconsHTML = $conf['editIcons'] && $GLOBALS['TSFE']->beUserLogin
1392 ? $this->editIcons('', $conf['editIcons'], $conf['editIcons.'])
1393 : '';
1394
1395 // strech out table:
1396 $tablecode = '';
1397 $flag = 0;
1398 if ($conf['noStretchAndMarginCells'] != 1) {
1399 $tablecode .= '<tr>';
1400 if ($txtMarg && $align == 'right') { // If right aligned, the textborder is added on the right side
1401 $tablecode .= '<td rowspan="' . ($rowspan + 1) . '" valign="top"><img src="' .
1402 $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' . $txtMarg . '" height="1" alt="" title="" />' .
1403 ($editIconsHTML ? '<br />' . $editIconsHTML : '') . '</td>';
1404 $editIconsHTML = '';
1405 $flag = 1;
1406 }
1407 $tablecode .= '<td colspan="' . $colspan . '"><img src="' .
1408 $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' . $tableWidth . '" height="1" alt="" /></td>';
1409 if ($txtMarg && $align == 'left') { // If left aligned, the textborder is added on the left side
1410 $tablecode .= '<td rowspan="' . ($rowspan + 1) . '" valign="top"><img src="' .
1411 $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' . $txtMarg . '" height="1" alt="" title="" />' .
1412 ($editIconsHTML ? '<br />' . $editIconsHTML : '') . '</td>';
1413 $editIconsHTML = '';
1414 $flag = 1;
1415 }
1416 if ($flag) {
1417 $tableWidth += $txtMarg + 1;
1418 }
1419 $tablecode .= '</tr>';
1420 }
1421
1422 // draw table
1423 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!
1424 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.
1425 $tablecode .= '<tr><td colspan="' . $colspan . '"><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="1" height="' . $rowspacing . '"' . $this->getBorderAttr(' border="0"') . ' alt="" title="" /></td></tr>';
1426 }
1427 $tablecode .= '<tr>'; // starting row
1428 for ($b = 0; $b < $colCount_temp; $b++) { // Looping through the columns
1429 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.
1430 if (!$noCols) {
1431 $tablecode .= '<td><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' .
1432 $colspacing . '" height="1"' . $this->getBorderAttr(' border="0"') . ' alt="" title="" /></td>';
1433 } else {
1434 $colSpacer = '<img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' .
1435 ($border ? $colspacing - 6 : $colspacing) . '" height="' .
1436 ($imageRowsMaxHeights[$c] + ($border ? $borderThickness * 2 : 0)) . '"' .
1437 $this->getBorderAttr(' border="0"') . ' align="' .
1438 ($border ? 'left' : 'top') . '" alt="" title="" />';
1439 $colSpacer = '<td valign="top">' . $colSpacer . '</td>'; // added 160301, needed for the new "noCols"-table...
1440 $tablecode .= $colSpacer;
1441 }
1442 }
1443 if (!$noCols || ($noCols && !$b)) {
1444 $tablecode .= '<td valign="top">'; // starting the cell. If "noCols" this cell will hold all images in the row, otherwise only a single image.
1445 if ($noCols) {
1446 $tablecode .= '<table width="' . $imageRowsFinalWidths[$c] . '" border="0" cellpadding="0" cellspacing="0"><tr>';
1447 } // In case of "noCols" we must set the table-tag that surrounds the images in the row.
1448 }
1449 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.
1450 $GLOBALS['TSFE']->register['IMAGE_NUM'] = $imgIndex; // register previous imgIndex
1451 $imgIndex = $index + $a * $colCount_temp;
1452 $GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = $imgIndex;
1453 if ($imgsTag[$imgIndex]) {
1454 if ($rowspacing && $noRows && $a) { // Puts distance between the images IF "noRows" is set and this is the first iteration of the loop
1455 $tablecode .= '<img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="1" height="' .
1456 $rowspacing . '" alt="" title="" /><br />';
1457 }
1458 if ($legacyCaptionSplit) {
1459 $thisCaption = $captionArray[$imgIndex];
1460 } else if ($conf['captionSplit'] || $conf['imageTextSplit']) {
1461 $thisCaption = $this->stdWrap($this->cObjGet($conf['caption.'], 'caption.'), $conf['caption.']);
1462 }
1463 $imageHTML = $imgsTag[$imgIndex] . '<br />';
1464 $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.
1465 if ($border) {
1466 $imageHTML = '<table border="0" cellpadding="' . $borderThickness . '" cellspacing="0" bgcolor="' .
1467 $borderColor . '"' . $Talign . '><tr><td>' . $imageHTML . '</td></tr></table>';
1468 }
1469 $imageHTML .= $editIconsHTML;
1470 $editIconsHTML = '';
1471 $imageHTML .= $thisCaption; // Adds caption.
1472 if ($noCols) {
1473 $imageHTML = '<td valign="top">' . $imageHTML . '</td>';
1474 } // If noCols, put in table cell.
1475 $tablecode .= $imageHTML;
1476 }
1477 }
1478 $index++;
1479 if (!$noCols || ($noCols && $b + 1 == $colCount_temp)) {
1480 if ($noCols) {
1481 $tablecode .= '</tr></table>';
1482 } // In case of "noCols" we must finish the table that surrounds the images in the row.
1483 $tablecode .= '</td>'; // Ending the cell. In case of "noCols" the cell holds all pictures!
1484 }
1485 }
1486 $tablecode .= '</tr>'; // ending row
1487 }
1488 if ($c) {
1489 switch ($contentPosition) {
1490 case '0' : // above
1491 case '8' : // below
1492 switch ($align) { // These settings are needed for Firefox
1493 case 'center' :
1494 $table_align = 'margin-left: auto; margin-right: auto';
1495 break;
1496 case 'right' :
1497 $table_align = 'margin-left: auto; margin-right: 0px';
1498 break;
1499 default : // Most of all: left
1500 $table_align = 'margin-left: 0px; margin-right: auto';
1501 }
1502 $table_align = 'style="' . $table_align . '"';
1503 break;
1504 case '16' : // in text
1505 $table_align = 'align="' . $align . '"';
1506 break;
1507 default :
1508 $table_align = '';
1509 }
1510
1511 // Table-tag is inserted
1512 $tablecode = '<table' . ($tableWidth ? ' width="' . $tableWidth . '"' : '') . ' border="0" cellspacing="0" cellpadding="0" ' . $table_align . ' class="imgtext-table">' . $tablecode;
1513 if ($editIconsHTML) { // IF this value is not long since reset.
1514 $tablecode .= '<tr><td colspan="' . $colspan . '">' . $editIconsHTML . '</td></tr>';
1515 $editIconsHTML = '';
1516 }
1517 if ($cap) {
1518 $tablecode .= '<tr><td colspan="' . $colspan . '" align="' . $caption_align . '">' . $caption . '</td></tr>';
1519 }
1520 $tablecode .= '</table>';
1521 if ($conf['tableStdWrap.']) {
1522 $tablecode = $this->stdWrap($tablecode, $conf['tableStdWrap.']);
1523 }
1524 }
1525
1526 $spaceBelowAbove = intval($this->stdWrap($conf['spaceBelowAbove'], $conf['spaceBelowAbove.']));
1527 switch ($contentPosition) {
1528 case '0' : // above
1529 $output = '<div style="text-align:' . $align . ';">' . $tablecode . '</div>' .
1530 $this->wrapSpace($content, $spaceBelowAbove . '|0');
1531 break;
1532 case '8' : // below
1533 $output = $this->wrapSpace($content, '0|' . $spaceBelowAbove) .
1534 '<div style="text-align:' . $align . ';">' . $tablecode . '</div>';
1535 break;
1536 case '16' : // in text
1537 $output = $tablecode . $content;
1538 break;
1539 case '24' : // in text, no wrap
1540 $theResult = '';
1541 $theResult .= '<table border="0" cellspacing="0" cellpadding="0" class="imgtext-nowrap"><tr>';
1542 if ($align == 'right') {
1543 $theResult .= '<td valign="top">' . $content . '</td><td valign="top">' . $tablecode . '</td>';
1544 } else {
1545 $theResult .= '<td valign="top">' . $tablecode . '</td><td valign="top">' . $content . '</td>';
1546 }
1547 $theResult .= '</tr></table>';
1548 $output = $theResult;
1549 break;
1550 }
1551 } else {
1552 $output = $content;
1553 }
1554
1555 if ($conf['stdWrap.']) {
1556 $output = $this->stdWrap($output, $conf['stdWrap.']);
1557 }
1558
1559 return $output;
1560 }
1561
1562 /**
1563 * Rendering the cObject, CONTENT
1564 *
1565 * @param array array of TypoScript properties
1566 * @return string Output
1567 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=356&cHash=9f3b5c6ba2
1568 */
1569 function CONTENT($conf) {
1570 $theValue = '';
1571
1572 $originalRec = $GLOBALS['TSFE']->currentRecord;
1573 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!!
1574 $GLOBALS['TSFE']->recordRegister[$originalRec]++;
1575 }
1576
1577 $conf['table'] = trim($this->stdWrap($conf['table'], $conf['table.']));
1578 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_') {
1579
1580 $renderObjName = $conf['renderObj'] ? $conf['renderObj'] : '<' . $conf['table'];
1581 $renderObjKey = $conf['renderObj'] ? 'renderObj' : '';
1582 $renderObjConf = $conf['renderObj.'];
1583
1584 $slide = intval($conf['slide']) ? intval($conf['slide']) : 0;
1585 $slideCollect = intval($conf['slide.']['collect']) ? intval($conf['slide.']['collect']) : 0;
1586 $slideCollectReverse = intval($conf['slide.']['collectReverse']) ? TRUE : FALSE;
1587 $slideCollectFuzzy = $slideCollect ? (intval($conf['slide.']['collectFuzzy']) ? TRUE : FALSE) : TRUE;
1588 $again = FALSE;
1589
1590 do {
1591 $res = $this->exec_getQuery($conf['table'], $conf['select.']);
1592 if ($error = $GLOBALS['TYPO3_DB']->sql_error()) {
1593 $GLOBALS['TT']->setTSlogMessage($error, 3);
1594 } else {
1595 $this->currentRecordTotal = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
1596 $GLOBALS['TT']->setTSlogMessage('NUMROWS: ' . $GLOBALS['TYPO3_DB']->sql_num_rows($res));
1597 $cObj = t3lib_div::makeInstance('tslib_cObj');
1598 $cObj->setParent($this->data, $this->currentRecord);
1599 $this->currentRecordNumber = 0;
1600 $cobjValue = '';
1601 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1602
1603 // Versioning preview:
1604 $GLOBALS['TSFE']->sys_page->versionOL($conf['table'], $row, TRUE);
1605
1606 // Language overlay:
1607 if (is_array($row) && $GLOBALS['TSFE']->sys_language_contentOL) {
1608 $row = $GLOBALS['TSFE']->sys_page->getRecordOverlay($conf['table'], $row, $GLOBALS['TSFE']->sys_language_content, $GLOBALS['TSFE']->sys_language_contentOL);
1609 }
1610
1611 if (is_array($row)) { // Might be unset in the sys_language_contentOL
1612 if (!$GLOBALS['TSFE']->recordRegister[$conf['table'] . ':' . $row['uid']]) {
1613 $this->currentRecordNumber++;
1614 $cObj->parentRecordNumber = $this->currentRecordNumber;
1615 $GLOBALS['TSFE']->currentRecord = $conf['table'] . ':' . $row['uid'];
1616 $this->lastChanged($row['tstamp']);
1617 $cObj->start($row, $conf['table']);
1618 $tmpValue = $cObj->cObjGetSingle($renderObjName, $renderObjConf, $renderObjKey);
1619 $cobjValue .= $tmpValue;
1620 }
1621 }
1622 }
1623 $GLOBALS['TYPO3_DB']->sql_free_result($res);
1624 }
1625 if ($slideCollectReverse) {
1626 $theValue = $cobjValue . $theValue;
1627 } else {
1628 $theValue .= $cobjValue;
1629 }
1630 if ($slideCollect > 0) {
1631 $slideCollect--;
1632 }
1633 if ($slide) {
1634 if ($slide > 0) {
1635 $slide--;
1636 }
1637 $conf['select.']['pidInList'] = $this->getSlidePids($conf['select.']['pidInList'], $conf['select.']['pidInList.']);
1638 $again = strlen($conf['select.']['pidInList']) ? TRUE : FALSE;
1639 }
1640 } while ($again && (($slide && !strlen($tmpValue) && $slideCollectFuzzy) || ($slide && $slideCollect)));
1641 }
1642
1643 $theValue = $this->wrap($theValue, $conf['wrap']);
1644 if ($conf['stdWrap.'])
1645 $theValue = $this->stdWrap($theValue, $conf['stdWrap.']);
1646
1647 $GLOBALS['TSFE']->currentRecord = $originalRec; // Restore
1648 return $theValue;
1649 }
1650
1651 /**
1652 * Rendering the cObject, RECORDS
1653 *
1654 * @param array array of TypoScript properties
1655 * @return string Output
1656 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=357&cHash=303e959472
1657 */
1658 function RECORDS($conf) {
1659 $theValue = '';
1660
1661 $originalRec = $GLOBALS['TSFE']->currentRecord;
1662 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!!
1663 $GLOBALS['TSFE']->recordRegister[$originalRec]++;
1664 }
1665
1666 $conf['source'] = $this->stdWrap($conf['source'], $conf['source.']);
1667 if ($conf['tables'] && $conf['source']) {
1668 $allowedTables = $conf['tables'];
1669 if (is_array($conf['conf.'])) {
1670 foreach ($conf['conf.'] as $k => $v) {
1671 if (substr($k, -1) != '.')
1672 $allowedTables .= ',' . $k;
1673 }
1674 }
1675
1676 $loadDB = t3lib_div::makeInstance('FE_loadDBGroup');
1677 $loadDB->start($conf['source'], $allowedTables);
1678 foreach ($loadDB->tableArray as $table => $v) {
1679 if (is_array($GLOBALS['TCA'][$table])) {
1680 $loadDB->additionalWhere[$table] = $this->enableFields($table);
1681 }
1682 }
1683 $loadDB->getFromDB();
1684
1685 reset($loadDB->itemArray);
1686 $data = $loadDB->results;
1687
1688 $cObj = t3lib_div::makeInstance('tslib_cObj');
1689 $cObj->setParent($this->data, $this->currentRecord);
1690 $this->currentRecordNumber = 0;
1691 $this->currentRecordTotal = count($loadDB->itemArray);
1692 foreach ($loadDB->itemArray as $val) {
1693 $row = $data[$val['table']][$val['id']];
1694
1695 // Versioning preview:
1696 $GLOBALS['TSFE']->sys_page->versionOL($val['table'], $row);
1697
1698 // Language overlay:
1699 if (is_array($row) && $GLOBALS['TSFE']->sys_language_contentOL) {
1700 $row = $GLOBALS['TSFE']->sys_page->getRecordOverlay(
1701 $val['table'],
1702 $row,
1703 $GLOBALS['TSFE']->sys_language_content,
1704 $GLOBALS['TSFE']->sys_language_contentOL
1705 );
1706 }
1707
1708 if (is_array($row)) { // Might be unset in the content overlay things...
1709 if (!$conf['dontCheckPid']) {
1710 $row = $this->checkPid($row['pid']) ? $row : '';
1711 }
1712 if ($row && !$GLOBALS['TSFE']->recordRegister[$val['table'] . ':' . $val['id']]) {
1713 $renderObjName = $conf['conf.'][$val['table']] ? $conf['conf.'][$val['table']] : '<' . $val['table'];
1714 $renderObjKey = $conf['conf.'][$val['table']] ? 'conf.' . $val['table'] : '';
1715 $renderObjConf = $conf['conf.'][$val['table'] . '.'];
1716 $this->currentRecordNumber++;
1717 $cObj->parentRecordNumber = $this->currentRecordNumber;
1718 $GLOBALS['TSFE']->currentRecord = $val['table'] . ':' . $val['id'];
1719 $this->lastChanged($row['tstamp']);
1720 $cObj->start($row, $val['table']);
1721 $tmpValue = $cObj->cObjGetSingle($renderObjName, $renderObjConf, $renderObjKey);
1722 $theValue .= $tmpValue;
1723 }
1724 }
1725 }
1726 }
1727 if ($conf['wrap'])
1728 $theValue = $this->wrap($theValue, $conf['wrap']);
1729 if ($conf['stdWrap.'])
1730 $theValue = $this->stdWrap($theValue, $conf['stdWrap.']);
1731
1732 $GLOBALS['TSFE']->currentRecord = $originalRec; // Restore
1733 return $theValue;
1734 }
1735
1736 /**
1737 * Rendering the cObject, HMENU
1738 *
1739 * @param array array of TypoScript properties
1740 * @return string Output
1741 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=358&cHash=5400c1c06a
1742 */
1743 function HMENU($conf) {
1744 $content = '';
1745 if ($this->checkIf($conf['if.'])) {
1746 $cls = strtolower($conf[1]);
1747 if (t3lib_div::inList($GLOBALS['TSFE']->tmpl->menuclasses, $cls)) {
1748 if ($conf['special.']['value.']) {
1749 $conf['special.']['value'] = $this->stdWrap($conf['special.']['value'], $conf['special.']['value.']);
1750 }
1751 $GLOBALS['TSFE']->register['count_HMENU']++;
1752 $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ'] = 0;
1753 $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'] = array();
1754 $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMparentId'] = array();
1755
1756 $menu = t3lib_div::makeInstance('tslib_' . $cls);
1757 $menu->parent_cObj = $this;
1758 $menu->start($GLOBALS['TSFE']->tmpl, $GLOBALS['TSFE']->sys_page, '', $conf, 1);
1759 $menu->makeMenu();
1760 $content .= $menu->writeMenu();
1761 }
1762 if ($conf['wrap'])
1763 $content = $this->wrap($content, $conf['wrap']);
1764 if ($conf['stdWrap.'])
1765 $content = $this->stdWrap($content, $conf['stdWrap.']);
1766 }
1767 return $content;
1768 }
1769
1770 /**
1771 * Rendering the cObject, CTABLE
1772 *
1773 * @param array array of TypoScript properties
1774 * @return string Output
1775 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=359&cHash=2e0065b4e7
1776 */
1777 function CTABLE($conf) {
1778 $controlTable = t3lib_div::makeInstance('tslib_controlTable');
1779 if ($conf['tableParams']) {
1780 $controlTable->tableParams = $conf['tableParams'];
1781 }
1782 // loads the pagecontent
1783 $controlTable->contentW = $conf['cWidth'];
1784 // loads the menues if any
1785 if (is_array($conf['c.'])) {
1786 $controlTable->content = $this->cObjGet($conf['c.'], 'c.');
1787 $controlTable->contentTDparams = isset($conf['c.']['TDParams']) ? $conf['c.']['TDParams'] : 'valign="top"';
1788 }
1789 if (is_array($conf['lm.'])) {
1790 $controlTable->lm = $this->cObjGet($conf['lm.'], 'lm.');
1791 $controlTable->lmTDparams = isset($conf['lm.']['TDParams']) ? $conf['lm.']['TDParams'] : 'valign="top"';
1792 }
1793 if (is_array($conf['tm.'])) {
1794 $controlTable->tm = $this->cObjGet($conf['tm.'], 'tm.');
1795 $controlTable->tmTDparams = isset($conf['tm.']['TDParams']) ? $conf['tm.']['TDParams'] : 'valign="top"';
1796 }
1797 if (is_array($conf['rm.'])) {
1798 $controlTable->rm = $this->cObjGet($conf['rm.'], 'rm.');
1799 $controlTable->rmTDparams = isset($conf['rm.']['TDParams']) ? $conf['rm.']['TDParams'] : 'valign="top"';
1800 }
1801 if (is_array($conf['bm.'])) {
1802 $controlTable->bm = $this->cObjGet($conf['bm.'], 'bm.');
1803 $controlTable->bmTDparams = isset($conf['bm.']['TDParams']) ? $conf['bm.']['TDParams'] : 'valign="top"';
1804 }
1805 return $controlTable->start($conf['offset'], $conf['cMargins']);
1806 }
1807
1808 /**
1809 * Rendering the cObject, OTABLE
1810 *
1811 * @param array array of TypoScript properties
1812 * @return string Output
1813 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=360&cHash=02c9552d38
1814 */
1815 function OTABLE($conf) {
1816 $controlTable = t3lib_div::makeInstance('tslib_tableOffset');
1817 if ($conf['tableParams']) {
1818 $controlTable->tableParams = $conf['tableParams'];
1819 }
1820 return $controlTable->start($this->cObjGet($conf), $conf['offset']);
1821 }
1822
1823 /**
1824 * Rendering the cObject, COLUMNS
1825 *
1826 * @param array array of TypoScript properties
1827 * @return string Output
1828 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=361&cHash=7e4e228cad
1829 */
1830 function COLUMNS($conf) {
1831 $content = '';
1832 if (is_array($conf) && $this->checkIf($conf['if.'])) {
1833 $tdRowCount = 0;
1834 $tableParams = $conf['tableParams'] ? ' ' . $conf['tableParams'] : ' border="0" cellspacing="0" cellpadding="0"';
1835 $TDparams = $conf['TDparams'] ? ' ' . $conf['TDparams'] : ' valign="top"';
1836 $rows = t3lib_div::intInRange($conf['rows'], 2, 20);
1837 $totalWidth = intval($conf['totalWidth']);
1838 $columnWidth = 0;
1839
1840 $totalGapWidth = 0;
1841 $gapData = array(
1842 'gapWidth' => $this->stdWrap($conf['gapWidth'], $conf['gapWidth.']),
1843 'gapBgCol' => $this->stdWrap($conf['gapBgCol'], $conf['gapBgCol.']),
1844 'gapLineThickness' => $this->stdWrap($conf['gapLineThickness'], $conf['gapLineThickness.']),
1845 'gapLineCol' => $this->stdWrap($conf['gapLineCol'], $conf['gapLineCol.']),
1846 );
1847 $gapData = $GLOBALS['TSFE']->tmpl->splitConfArray($gapData, $rows - 1);
1848 foreach ($gapData as $val) {
1849 $totalGapWidth += intval($val['gapWidth']);
1850 }
1851
1852 if ($totalWidth) {
1853 $columnWidth = ceil(($totalWidth - $totalGapWidth) / $rows);
1854 $TDparams .= ' width="' . $columnWidth . '"';
1855 $tableParams .= ' width="' . $totalWidth . '"';
1856 } else {
1857 $TDparams .= ' width="' . floor(100 / $rows) . '%"';
1858 $tableParams .= ' width="100%"';
1859 }
1860
1861 for ($a = 1; $a <= $rows; $a++) {
1862 $tdRowCount++;
1863 $content .= '<td' . $TDparams . '>';
1864 $content .= $this->cObjGetSingle($conf[$a], $conf[$a . '.'], $a);
1865 $content .= '</td>';
1866 if ($a < $rows) {
1867 $gapConf = $gapData[($a - 1)];
1868 $gapWidth = intval($gapConf['gapWidth']);
1869 if ($gapWidth) {
1870 $tdPar = $gapConf['gapBgCol'] ? ' bgcolor="' . $gapConf['gapBgCol'] . '"' : '';
1871 $gapLine = intval($gapConf['gapLineThickness']);
1872 if ($gapLine) {
1873 $gapSurround = t3lib_div::intInRange(($gapWidth - $gapLine) / 2, 1, 1000);
1874 // right gap
1875 $content .= '<td' . $tdPar . '><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' .
1876 $gapSurround . '" height="1" alt="" title="" /></td>';
1877 $tdRowCount++;
1878 // line:
1879 $GtdPar = $gapConf['gapLineCol'] ? ' bgcolor="' . $gapConf['gapLineCol'] . '"' : ' bgcolor="black"';
1880 $content .= '<td' . $GtdPar . '><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' .
1881 $gapLine . '" height="1" alt="" title="" /></td>';
1882 $tdRowCount++;
1883 // left gap
1884 $content .= '<td' . $tdPar . '><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' .
1885 $gapSurround . '" height="1" alt="" title="" /></td>';
1886 $tdRowCount++;
1887 } else {
1888 $content .= '<td' . $tdPar . '><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' .
1889 $gapWidth . '" height="1" alt="" title="" /></td>';
1890 $tdRowCount++;
1891 }
1892 }
1893 }
1894 }
1895 $content = '<tr>' . $content . '</tr>';
1896 $content = '<table' . $tableParams . '>' . $content . '</table>';
1897 $content .= $this->cObjGetSingle($conf['after'], $conf['after.'], 'after');
1898 if ($conf['stdWrap.']) {
1899 $content = $this->stdWrap($content, $conf['stdWrap.']);
1900 }
1901 }
1902 return $content;
1903 }
1904
1905 /**
1906 * Rendering the cObject, HRULER
1907 *
1908 * @param array array of TypoScript properties
1909 * @return string Output
1910 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=362&cHash=2a462aa084
1911 */
1912 function HRULER($conf) {
1913 $lineThickness = t3lib_div::intInRange($this->stdWrap($conf['lineThickness'], $conf['lineThickness.']), 1, 50);
1914 $lineColor = $conf['lineColor'] ? $conf['lineColor'] : 'black';
1915 $spaceBefore = intval($conf['spaceLeft']);
1916 $spaceAfter = intval($conf['spaceRight']);
1917 $tableWidth = $conf['tableWidth'] ? $conf['tableWidth'] : '99%';
1918 $content = '';
1919
1920 $content .= '<table border="0" cellspacing="0" cellpadding="0" width="' . htmlspecialchars($tableWidth) . '" summary=""><tr>';
1921 if ($spaceBefore) {
1922 $content .= '<td width="1"><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' .
1923 $spaceBefore . '" height="1" alt="" title="" /></td>';
1924 }
1925 $content .= '<td bgcolor="' . $lineColor . '"><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="1" height="' .
1926 $lineThickness . '" alt="" title="" /></td>';
1927 if ($spaceAfter) {
1928 $content .= '<td width="1"><img src="' . $GLOBALS['TSFE']->absRefPrefix . 'clear.gif" width="' .
1929 $spaceAfter . '" height="1" alt="" title="" /></td>';
1930 }
1931 $content .= '</tr></table>';
1932
1933 $content = $this->stdWrap($content, $conf['stdWrap.']);
1934 return $content;
1935 }
1936
1937 /**
1938 * Rendering the cObject, CASE
1939 *
1940 * @param array array of TypoScript properties
1941 * @return string Output
1942 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=364&cHash=cffedd09e3
1943 */
1944 function CASEFUNC($conf) {
1945 $content = '';
1946 if ($this->checkIf($conf['if.'])) {
1947 if ($conf['setCurrent'] || $conf['setCurrent.']) {
1948 $this->data[$this->currentValKey] = $this->stdWrap($conf['setCurrent'], $conf['setCurrent.']);
1949 }
1950 $key = $this->stdWrap($conf['key'], $conf['key.']);
1951 $key = strlen($conf[$key]) ? $key : 'default';
1952 $name = $conf[$key];
1953 $theValue = $this->cObjGetSingle($name, $conf[$key . '.'], $key);
1954 if ($conf['stdWrap.']) {
1955 $theValue = $this->stdWrap($theValue, $conf['stdWrap.']);
1956 }
1957 return $theValue;
1958 }
1959 }
1960
1961 /**
1962 * Rendering the cObject, LOAD_REGISTER and RESTORE_REGISTER
1963 * NOTICE: This cObject does NOT return any content since it just sets internal data based on the TypoScript properties.
1964 *
1965 * @param array array of TypoScript properties
1966 * @param string If "RESTORE_REGISTER" then the cObject rendered is "RESTORE_REGISTER", otherwise "LOAD_REGISTER"
1967 * @return string Empty string (the cObject only sets internal data!)
1968 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=365&cHash=4935524e2e
1969 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=366&cHash=4f9485e8cc
1970 */
1971 function LOAD_REGISTER($conf, $name) {
1972 if ($name == 'RESTORE_REGISTER') {
1973 $GLOBALS['TSFE']->register = array_pop($GLOBALS['TSFE']->registerStack);
1974 } else {
1975 array_push($GLOBALS['TSFE']->registerStack, $GLOBALS['TSFE']->register);
1976 if (is_array($conf)) {
1977 foreach ($conf as $theKey => $theValue) {
1978 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
1979 if (strstr($theKey, '.')) {
1980 $theKey = substr($theKey, 0, -1);
1981 }
1982 $GLOBALS['TSFE']->register[$theKey] = $this->stdWrap($conf[$theKey], $conf[$theKey . '.']);
1983 }
1984 }
1985 }
1986 }
1987 return '';
1988 }
1989
1990 /**
1991 * Rendering the cObject, FORM
1992 *
1993 * Note on $formData:
1994 * In the optional $formData array each entry represents a line in the ordinary setup.
1995 * In those entries each entry (0,1,2...) represents a space normally divided by the '|' line.
1996 *
1997 * $formData [] = array('Name:', 'name=input, 25 ', 'Default value....');
1998 * $formData [] = array('Email:', 'email=input, 25 ', 'Default value for email....');
1999 *
2000 * - corresponds to the $conf['data'] value being :
2001 * Name:|name=input, 25 |Default value....||Email:|email=input, 25 |Default value for email....
2002 *
2003 * If $formData is an array the value of $conf['data'] is ignored.
2004 *
2005 * @param array array of TypoScript properties
2006 * @param array Alternative formdata overriding whatever comes from TypoScript
2007 * @return string Output
2008 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=367&cHash=bbc518d930
2009 */
2010 function FORM($conf, $formData = '') {
2011 $content = '';
2012 if (is_array($formData)) {
2013 $dataArr = $formData;
2014 } else {
2015 $data = $this->stdWrap($conf['data'], $conf['data.']);
2016 // Clearing dataArr
2017 $dataArr = array();
2018 // Getting the original config
2019 if (trim($data)) {
2020 $data = str_replace(LF, '||', $data);
2021 $dataArr = explode('||', $data);
2022 }
2023 // Adding the new dataArray config form:
2024 if (is_array($conf['dataArray.'])) { // dataArray is supplied
2025 $sKeyArray = t3lib_TStemplate::sortedKeyList($conf['dataArray.'], TRUE);
2026 foreach ($sKeyArray as $theKey) {
2027 $dAA = $conf['dataArray.'][$theKey . '.'];
2028 if (is_array($dAA)) {
2029 $temp = array();
2030 list ($temp[0]) = explode('|', $dAA['label.'] ? $this->stdWrap($dAA['label'], $dAA['label.']) : $dAA['label']);
2031 list ($temp[1]) = explode('|', $dAA['type']);
2032 if ($dAA['required']) {
2033 $temp[1] = '*' . $temp[1];
2034 }
2035 list ($temp[2]) = explode('|', $dAA['value.'] ? $this->stdWrap($dAA['value'], $dAA['value.']) : $dAA['value']);
2036 // If value array is set, then implode those values.
2037 if (is_array($dAA['valueArray.'])) {
2038 $temp_accum = array();
2039 foreach ($dAA['valueArray.'] as $dAKey_vA => $dAA_vA) {
2040 if (is_array($dAA_vA) && !strcmp(intval($dAKey_vA) . '.', $dAKey_vA)) {
2041 $temp_vA = array();
2042 list ($temp_vA[0]) = explode('=', $dAA_vA['label.'] ? $this->stdWrap($dAA_vA['label'], $dAA_vA['label.']) : $dAA_vA['label']);
2043 if ($dAA_vA['selected']) {
2044 $temp_vA[0] = '*' . $temp_vA[0];
2045 }
2046 list ($temp_vA[1]) = explode(',', $dAA_vA['value']);
2047 }
2048 $temp_accum[] = implode('=', $temp_vA);
2049 }
2050 $temp[2] = implode(',', $temp_accum);
2051 }
2052 list ($temp[3]) = explode('|', $dAA['specialEval.'] ? $this->stdWrap($dAA['specialEval'], $dAA['specialEval.']) : $dAA['specialEval']);
2053
2054 // adding the form entry to the dataArray
2055 $dataArr[] = implode('|', $temp);
2056 }
2057 }
2058 }
2059 }
2060
2061 $attachmentCounter = '';
2062 $hiddenfields = '';
2063 $fieldlist = array();
2064 $propertyOverride = array();
2065 $fieldname_hashArray = array();
2066 $cc = 0;
2067
2068 $xhtmlStrict = t3lib_div::inList('xhtml_strict,xhtml_11,xhtml_2', $GLOBALS['TSFE']->xhtmlDoctype);
2069 // Formname
2070 if ($conf['formName']) {
2071 $formname = $this->cleanFormName($conf['formName']);
2072 } else {
2073 $formname = $GLOBALS['TSFE']->uniqueHash();
2074 $formname = 'a' . $formname; // form name has to start with a letter to reach XHTML compliance
2075 }
2076
2077 if (isset($conf['fieldPrefix'])) {
2078 if ($conf['fieldPrefix']) {
2079 $prefix = $this->cleanFormName($conf['fieldPrefix']);
2080 } else {
2081 $prefix = '';
2082 }
2083 } else {
2084 $prefix = $formname;
2085 }
2086
2087 foreach ($dataArr as $val) {
2088
2089 $cc++;
2090 $confData = array();
2091 if (is_array($formData)) {
2092 $parts = $val;
2093 $val = 1; // TRUE...
2094 } else {
2095 $val = trim($val);
2096 $parts = explode('|', $val);
2097 }
2098 if ($val && strcspn($val, '#/')) {
2099 // label:
2100 $confData['label'] = trim($parts[0]);
2101 // field:
2102 $fParts = explode(',', $parts[1]);
2103 $fParts[0] = trim($fParts[0]);
2104 if (substr($fParts[0], 0, 1) == '*') {
2105 $confData['required'] = 1;
2106 $fParts[0] = substr($fParts[0], 1);
2107 }
2108 $typeParts = explode('=', $fParts[0]);
2109 $confData['type'] = trim(strtolower(end($typeParts)));
2110 if (count($typeParts) == 1) {
2111 $confData['fieldname'] = $this->cleanFormName($parts[0]);
2112 if (strtolower(preg_replace('/[^[:alnum:]]/', '', $confData['fieldname'])) == 'email') {
2113 $confData['fieldname'] = 'email';
2114 }
2115 // Duplicate fieldnames resolved
2116 if (isset($fieldname_hashArray[md5($confData['fieldname'])])) {
2117 $confData['fieldname'] .= '_' . $cc;
2118 }
2119 $fieldname_hashArray[md5($confData['fieldname'])] = $confData['fieldname'];
2120 // Attachment names...
2121 if ($confData['type'] == 'file') {
2122 $confData['fieldname'] = 'attachment' . $attachmentCounter;
2123 $attachmentCounter = intval($attachmentCounter) + 1;
2124 }
2125 } else {
2126 $confData['fieldname'] = str_replace(' ', '_', trim($typeParts[0]));
2127 }
2128 $fieldCode = '';
2129
2130 if ($conf['wrapFieldName']) {
2131 $confData['fieldname'] = $this->wrap($confData['fieldname'], $conf['wrapFieldName']);
2132 }
2133
2134 // Set field name as current:
2135 $this->setCurrentVal($confData['fieldname']);
2136
2137 // Additional parameters
2138 if (trim($confData['type'])) {
2139 $addParams = trim($conf['params']);
2140 if (is_array($conf['params.']) && isset($conf['params.'][$confData['type']])) {
2141 $addParams = trim($conf['params.'][$confData['type']]);
2142 }
2143 if (strcmp('', $addParams)) {
2144 $addParams = ' ' . $addParams;
2145 }
2146 } else
2147 $addParams = '';
2148
2149 if ($conf['dontMd5FieldNames']) {
2150 $fName = $confData['fieldname'];
2151 } else {
2152 $fName = md5($confData['fieldname']);
2153 }
2154
2155 // Accessibility: Set id = fieldname attribute:
2156 if ($conf['accessibility'] || $xhtmlStrict) {
2157 $elementIdAttribute = ' id="' . $prefix . $fName . '"';
2158 } else {
2159 $elementIdAttribute = '';
2160 }
2161
2162 // Create form field based on configuration/type:
2163 switch ($confData['type']) {
2164 case 'textarea' :
2165 $cols = trim($fParts[1]) ? intval($fParts[1]) : 20;
2166 $compWidth = doubleval($conf['compensateFieldWidth']
2167 ? $conf['compensateFieldWidth']
2168 : $GLOBALS['TSFE']->compensateFieldWidth
2169 );
2170 $compWidth = $compWidth ? $compWidth : 1;
2171 $cols = t3lib_div::intInRange($cols * $compWidth, 1, 120);
2172
2173 $rows = trim($fParts[2]) ? t3lib_div::intInRange($fParts[2], 1, 30) : 5;
2174 $wrap = trim($fParts[3]);
2175 if ($conf['noWrapAttr'] || $wrap === 'disabled') {
2176 $wrap = '';
2177 } else {
2178 $wrap = $wrap ? ' wrap="' . $wrap . '"' : ' wrap="virtual"';
2179 }
2180 $default = $this->getFieldDefaultValue(
2181 $conf['noValueInsert'],
2182 $confData['fieldname'],
2183 str_replace('\n', LF, trim($parts[2]))
2184 );
2185 $fieldCode = sprintf(
2186 '<textarea name="%s"%s cols="%s" rows="%s"%s%s>%s</textarea>',
2187 $confData['fieldname'],
2188 $elementIdAttribute,
2189 $cols,
2190 $rows,
2191 $wrap,
2192 $addParams,
2193 t3lib_div::formatForTextarea($default)
2194 );
2195 break;
2196 case 'input' :
2197 case 'password' :
2198 $size = trim($fParts[1]) ? intval($fParts[1]) : 20;
2199 $compWidth = doubleval($conf['compensateFieldWidth']
2200 ? $conf['compensateFieldWidth']
2201 : $GLOBALS['TSFE']->compensateFieldWidth
2202 );
2203 $compWidth = $compWidth ? $compWidth : 1;
2204 $size = t3lib_div::intInRange($size * $compWidth, 1, 120);
2205 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], trim($parts[2]));
2206
2207 if ($confData['type'] == 'password') {
2208 $default = '';
2209 }
2210
2211 $max = trim($fParts[2]) ? ' maxlength="' . t3lib_div::intInRange($fParts[2], 1, 1000) . '"' : "";
2212 $theType = $confData['type'] == 'input' ? 'text' : 'password';
2213
2214 $fieldCode = sprintf(
2215 '<input type="%s" name="%s"%s size="%s"%s value="%s"%s />',
2216 $theType,
2217 $confData['fieldname'],
2218 $elementIdAttribute,
2219 $size,
2220 $max,
2221 htmlspecialchars($default),
2222 $addParams
2223 );
2224
2225 break;
2226 case 'file' :
2227 $size = trim($fParts[1]) ? t3lib_div::intInRange($fParts[1], 1, 60) : 20;
2228 $fieldCode = sprintf(
2229 '<input type="file" name="%s"%s size="%s"%s />',
2230 $confData['fieldname'],
2231 $elementIdAttribute,
2232 $size,
2233 $addParams
2234 );
2235 break;
2236 case 'check' :
2237 // alternative default value:
2238 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], trim($parts[2]));
2239 $checked = $default ? ' checked="checked"' : '';
2240 $fieldCode = sprintf(
2241 '<input type="checkbox" value="%s" name="%s"%s%s%s />',
2242 1,
2243 $confData['fieldname'],
2244 $elementIdAttribute,
2245 $checked,
2246 $addParams
2247 );
2248 break;
2249 case 'select' :
2250 $option = '';
2251 $valueParts = explode(',', $parts[2]);
2252 // size
2253 if (strtolower(trim($fParts[1])) == 'auto') {
2254 $fParts[1] = count($valueParts);
2255 } // Auto size set here. Max 20
2256 $size = trim($fParts[1]) ? t3lib_div::intInRange($fParts[1], 1, 20) : 1;
2257 // multiple
2258 $multiple = strtolower(trim($fParts[2])) == 'm' ? ' multiple="multiple"' : '';
2259
2260 $items = array(); // Where the items will be
2261 $defaults = array(); //RTF
2262 $pCount = count($valueParts);
2263 for ($a = 0; $a < $pCount; $a++) {
2264 $valueParts[$a] = trim($valueParts[$a]);
2265 if (substr($valueParts[$a], 0, 1) == '*') { // Finding default value
2266 $sel = 'selected';
2267 $valueParts[$a] = substr($valueParts[$a], 1);
2268 } else
2269 $sel = '';
2270 // Get value/label
2271 $subParts = explode('=', $valueParts[$a]);
2272 $subParts[1] = (isset($subParts[1]) ? trim($subParts[1]) : trim($subParts[0])); // Sets the value
2273 $items[] = $subParts; // Adds the value/label pair to the items-array
2274 if ($sel) {
2275 $defaults[] = $subParts[1];
2276 } // Sets the default value if value/label pair is marked as default.
2277 }
2278 // alternative default value:
2279 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], $defaults);
2280 if (!is_array($default)) {
2281 $defaults = array();
2282 $defaults[] = $default;
2283 } else {
2284 $defaults = $default;
2285 }
2286 // Create the select-box:
2287 $iCount = count($items);
2288 for ($a = 0; $a < $iCount; $a++) {
2289 $option .= '<option value="' . $items[$a][1] . '"' . (in_array($items[$a][1], $defaults) ? ' selected="selected"' : '') . '>' . trim($items[$a][0]) . '</option>'; //RTF
2290 }
2291
2292 if ($multiple) {
2293 // 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.
2294 $confData['fieldname'] .= '[]';
2295 }
2296 $fieldCode = sprintf(
2297 '<select name="%s"%s size="%s"%s%s>%s</select>',
2298 $confData['fieldname'],
2299 $elementIdAttribute,
2300 $size,
2301 $multiple,
2302 $addParams,
2303 $option
2304 ); //RTF
2305 break;
2306 case 'radio' :
2307 $option = '';
2308
2309 $valueParts = explode(',', $parts[2]);
2310 $items = array(); // Where the items will be
2311 $default = '';
2312 $pCount = count($valueParts);
2313 for ($a = 0; $a < $pCount; $a++) {
2314 $valueParts[$a] = trim($valueParts[$a]);
2315 if (substr($valueParts[$a], 0, 1) == '*') {
2316 $sel = 'checked';
2317 $valueParts[$a] = substr($valueParts[$a], 1);
2318 } else
2319 $sel = '';
2320 // Get value/label
2321 $subParts = explode('=', $valueParts[$a]);
2322 $subParts[1] = (isset($subParts[1]) ? trim($subParts[1]) : trim($subParts[0])); // Sets the value
2323 $items[] = $subParts; // Adds the value/label pair to the items-array
2324 if ($sel) {
2325 $default = $subParts[1];
2326 } // Sets the default value if value/label pair is marked as default.
2327 }
2328 // alternative default value:
2329 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], $default);
2330 // Create the select-box:
2331 $iCount = count($items);
2332 for ($a = 0; $a < $iCount; $a++) {
2333 $radioId = $prefix . $fName . $this->cleanFormName($items[$a][0]);
2334 if ($conf['accessibility']) {
2335 $radioLabelIdAttribute = ' id="' . $radioId . '"';
2336 } else {
2337 $radioLabelIdAttribute = '';
2338 }
2339 $option .= '<input type="radio" name="' . $confData['fieldname'] . '"' .
2340 $radioLabelIdAttribute . ' value="' . $items[$a][1] . '"' .
2341 (!strcmp($items[$a][1], $default) ? ' checked="checked"' : '') .
2342 $addParams . ' />';
2343 if ($conf['accessibility']) {
2344 $option .= '<label for="' . $radioId . '">' .
2345 $this->stdWrap(trim($items[$a][0]), $conf['radioWrap.']) .
2346 '</label>';
2347 } else {
2348 $option .= $this->stdWrap(trim($items[$a][0]), $conf['radioWrap.']);
2349 }
2350 }
2351
2352 if ($conf['accessibility']) {
2353 $accessibilityWrap = $conf['radioWrap.']['accessibilityWrap'];
2354
2355 $search = array(
2356 '###RADIO_FIELD_ID###', '###RADIO_GROUP_LABEL###'
2357 );
2358 $replace = array(
2359 $elementIdAttribute, $confData['label']
2360 );
2361 $accessibilityWrap = str_replace($search, $replace, $accessibilityWrap);
2362
2363 $option = $this->wrap($option, $accessibilityWrap);
2364 }
2365
2366 $fieldCode = $option;
2367 break;
2368 case 'hidden' :
2369 $value = trim($parts[2]);
2370
2371 // If this form includes an auto responder message, include a HMAC checksum field
2372 // in order to verify potential abuse of this feature.
2373 if (strlen($value) && t3lib_div::inList($confData['fieldname'], 'auto_respond_msg')) {
2374 $hmacChecksum = t3lib_div::hmac($value);
2375 $hiddenfields .= sprintf(
2376 '<input type="hidden" name="auto_respond_checksum" id="%sauto_respond_checksum" value="%s" />',
2377 $prefix,
2378 $hmacChecksum
2379 );
2380 }
2381
2382 if (strlen($value) && t3lib_div::inList('recipient_copy,recipient',
2383 $confData['fieldname']) && $GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail']) {
2384 break;
2385 }
2386 if (strlen($value) && t3lib_div::inList('recipient_copy,recipient', $confData['fieldname'])) {
2387 $value = $GLOBALS['TSFE']->codeString($value);
2388 }
2389 $hiddenfields .= sprintf(
2390 '<input type="hidden" name="%s"%s value="%s" />',
2391 $confData['fieldname'],
2392 $elementIdAttribute,
2393 htmlspecialchars($value)
2394 );
2395 break;
2396 case 'property' :
2397 if (t3lib_div::inList('type,locationData,goodMess,badMess,emailMess', $confData['fieldname'])) {
2398 $value = trim($parts[2]);
2399 $propertyOverride[$confData['fieldname']] = $value;
2400 $conf[$confData['fieldname']] = $value;
2401 }
2402 break;
2403 case 'submit' :
2404 $value = trim($parts[2]);
2405 if ($conf['image.']) {
2406 $this->data[$this->currentValKey] = $value;
2407 $image = $this->IMG_RESOURCE($conf['image.']);
2408 $params = $conf['image.']['params'] ? ' ' . $conf['image.']['params'] : '';
2409 $params .= $this->getAltParam($conf['image.'], FALSE);
2410 $params .= $addParams;
2411 } else {
2412 $image = '';
2413 }
2414 if ($image) {
2415 $fieldCode = sprintf(
2416 '<input type="image" name="%s"%s src="%s"%s />',
2417 $confData['fieldname'],
2418 $elementIdAttribute,
2419 $image,
2420 $params
2421 );
2422 } else {
2423 $fieldCode = sprintf(
2424 '<input type="submit" name="%s"%s value="%s"%s />',
2425 $confData['fieldname'],
2426 $elementIdAttribute,
2427 t3lib_div::deHSCentities(htmlspecialchars($value)),
2428 $addParams
2429 );
2430 }
2431 break;
2432 case 'reset' :
2433 $value = trim($parts[2]);
2434 $fieldCode = sprintf(
2435 '<input type="reset" name="%s"%s value="%s"%s />',
2436 $confData['fieldname'],
2437 $elementIdAttribute,
2438 t3lib_div::deHSCentities(htmlspecialchars($value)),
2439 $addParams
2440 );
2441 break;
2442 case 'label' :
2443 $fieldCode = nl2br(htmlspecialchars(trim($parts[2])));
2444 break;
2445 default :
2446 $confData['type'] = 'comment';
2447 $fieldCode = trim($parts[2]) . '&nbsp;';
2448 break;
2449 }
2450 if ($fieldCode) {
2451
2452 // Checking for special evaluation modes:
2453 if (t3lib_div::inList('textarea,input,password', $confData['type']) && strlen(trim($parts[3]))) {
2454 $modeParameters = t3lib_div::trimExplode(':', $parts[3]);
2455 } else {
2456 $modeParameters = array();
2457 }
2458
2459 // Adding evaluation based on settings:
2460 switch ((string) $modeParameters[0]) {
2461 case 'EREG' :
2462 $fieldlist[] = '_EREG';
2463 $fieldlist[] = $modeParameters[1];
2464 $fieldlist[] = $modeParameters[2];
2465 $fieldlist[] = $confData['fieldname'];
2466 $fieldlist[] = $confData['label'];
2467 $confData['required'] = 1; // Setting this so "required" layout is used.
2468 break;
2469 case 'EMAIL' :
2470 $fieldlist[] = '_EMAIL';
2471 $fieldlist[] = $confData['fieldname'];
2472 $fieldlist[] = $confData['label'];
2473 $confData['required'] = 1; // Setting this so "required" layout is used.
2474 break;
2475 default :
2476 if ($confData['required']) {
2477 $fieldlist[] = $confData['fieldname'];
2478 $fieldlist[] = $confData['label'];
2479 }
2480 break;
2481 }
2482
2483 // Field:
2484 $fieldLabel = $confData['label'];
2485 if ($conf['accessibility'] && trim($fieldLabel) && !preg_match('/^(label|hidden|comment)$/', $confData['type'])) {
2486 $fieldLabel = '<label for="' . $prefix . $fName . '">' . $fieldLabel . '</label>';
2487 }
2488
2489 // Getting template code:
2490 $fieldCode = $this->stdWrap($fieldCode, $conf['fieldWrap.']);
2491 $labelCode = $this->stdWrap($fieldLabel, $conf['labelWrap.']);
2492 $commentCode = $this->stdWrap($confData['label'], $conf['commentWrap.']); // RTF
2493 $result = $conf['layout'];
2494 if ($conf['REQ'] && $confData['required']) {
2495 if (is_array($conf['REQ.']['fieldWrap.']))
2496 $fieldCode = $this->stdWrap($fieldCode, $conf['REQ.']['fieldWrap.']);
2497 if (is_array($conf['REQ.']['labelWrap.']))
2498 $labelCode = $this->stdWrap($fieldLabel, $conf['REQ.']['labelWrap.']);
2499 if ($conf['REQ.']['layout']) {
2500 $result = $conf['REQ.']['layout'];
2501 }
2502 }
2503 if ($confData['type'] == 'comment' && $conf['COMMENT.']['layout']) {
2504 $result = $conf['COMMENT.']['layout'];
2505 }
2506 if ($confData['type'] == 'check' && $conf['CHECK.']['layout']) {
2507 $result = $conf['CHECK.']['layout'];
2508 }
2509 if ($confData['type'] == 'radio' && $conf['RADIO.']['layout']) {
2510 $result = $conf['RADIO.']['layout'];
2511 }
2512 if ($confData['type'] == 'label' && $conf['LABEL.']['layout']) {
2513 $result = $conf['LABEL.']['layout'];
2514 }
2515 $result = str_replace('###FIELD###', $fieldCode, $result);
2516 $result = str_replace('###LABEL###', $labelCode, $result);
2517 $result = str_replace('###COMMENT###', $commentCode, $result); //RTF
2518 $content .= $result;
2519 }
2520 }
2521 }
2522 if ($conf['stdWrap.']) {
2523 $content = $this->stdWrap($content, $conf['stdWrap.']);
2524 }
2525
2526
2527 // redirect (external: where to go afterwards. internal: where to submit to)
2528 $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)
2529 $page = $GLOBALS['TSFE']->page;
2530 if (!$theRedirect) { // Internal: Just submit to current page
2531 $LD = $GLOBALS['TSFE']->tmpl->linkData(
2532 $page,
2533 $conf['target'],
2534 $conf['no_cache'],
2535 'index.php',
2536 '',
2537 $this->getClosestMPvalueForPage($page['uid'])
2538 );
2539 } elseif (t3lib_div::testInt($theRedirect)) { // Internal: Submit to page with ID $theRedirect
2540 $page = $GLOBALS['TSFE']->sys_page->getPage_noCheck($theRedirect);
2541 $LD = $GLOBALS['TSFE']->tmpl->linkData(
2542 $page,
2543 $conf['target'],
2544 $conf['no_cache'],
2545 'index.php',
2546 '',
2547 $this->getClosestMPvalueForPage($page['uid'])
2548 );
2549 } else { // External URL, redirect-hidden field is rendered!
2550 $LD = $GLOBALS['TSFE']->tmpl->linkData(
2551 $page,
2552 $conf['target'],
2553 $conf['no_cache'],
2554 '',
2555 '',
2556 $this->getClosestMPvalueForPage($page['uid'])
2557 );
2558 $LD['totalURL'] = $theRedirect;
2559 $hiddenfields .= '<input type="hidden" name="redirect" value="' . htmlspecialchars($LD['totalURL']) . '" />'; // 18-09-00 added
2560 }
2561
2562 // Formtype (where to submit to!):
2563 $formtype = $propertyOverride['type'] ? $propertyOverride['type'] : $this->stdWrap($conf['type'], $conf['type.']);
2564 if (t3lib_div::testInt($formtype)) { // Submit to a specific page
2565 $page = $GLOBALS['TSFE']->sys_page->getPage_noCheck($formtype);
2566 $LD_A = $GLOBALS['TSFE']->tmpl->linkData(
2567 $page,
2568 $conf['target'],
2569 $conf['no_cache'],
2570 '',
2571 '',
2572 $this->getClosestMPvalueForPage($page['uid'])
2573 );
2574 $action = $LD_A['totalURL'];
2575 } elseif ($formtype) { // Submit to external script
2576 $LD_A = $LD;
2577 $action = $formtype;
2578 } elseif (t3lib_div::testInt($theRedirect)) {
2579 $LD_A = $LD;
2580 $action = $LD_A['totalURL'];
2581 } else { // Submit to "nothing" - which is current page
2582 $LD_A = $GLOBALS['TSFE']->tmpl->linkData(
2583 $GLOBALS['TSFE']->page,
2584 $conf['target'],
2585 $conf['no_cache'],
2586 '',
2587 '',
2588 $this->getClosestMPvalueForPage($page['uid'])
2589 );
2590 $action = $LD_A['totalURL'];
2591 }
2592
2593 // Recipient:
2594 $theEmail = $this->stdWrap($conf['recipient'], $conf['recipient.']);
2595 if ($theEmail && !$GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail']) {
2596 $theEmail = $GLOBALS['TSFE']->codeString($theEmail);
2597 $hiddenfields .= '<input type="hidden" name="recipient" value="' . htmlspecialchars($theEmail) . '" />';
2598 }
2599
2600 // location data:
2601 if ($conf['locationData']) {
2602 if ($conf['locationData'] == 'HTTP_POST_VARS' && isset($_POST['locationData'])) {
2603 $locationData = t3lib_div::_POST('locationData');
2604 } else {
2605 // 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.
2606 $locationData = $GLOBALS['TSFE']->id . ':' . $this->currentRecord;
2607 }
2608 $hiddenfields .= '<input type="hidden" name="locationData" value="' . htmlspecialchars($locationData) . '" />';
2609 }
2610
2611 // hidden fields:
2612 if (is_array($conf['hiddenFields.'])) {
2613 foreach ($conf['hiddenFields.'] as $hF_key => $hF_conf) {
2614 if (substr($hF_key, -1) != '.') {
2615 $hF_value = $this->cObjGetSingle($hF_conf, $conf['hiddenFields.'][$hF_key . '.'], 'hiddenfields');
2616 if (strlen($hF_value) && t3lib_div::inList('recipient_copy,recipient', $hF_key)) {
2617 if ($GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail']) {
2618 continue;
2619 }
2620 $hF_value = $GLOBALS['TSFE']->codeString($hF_value);
2621 }
2622 $hiddenfields .= '<input type="hidden" name="' . $hF_key . '" value="' . htmlspecialchars($hF_value) . '" />';
2623 }
2624 }
2625 }
2626
2627 // Wrap all hidden fields in a div tag (see http://bugs.typo3.org/view.php?id=678)
2628 $hiddenfields = '<div style="display:none;">' . $hiddenfields . '</div>';
2629
2630 if ($conf['REQ']) {
2631 $validateForm = ' onsubmit="return validateForm(\'' . $formname . '\',\'' . implode(',', $fieldlist)
2632 . '\',' . t3lib_div::quoteJSvalue($conf['goodMess']) . ',' .
2633 t3lib_div::quoteJSvalue($conf['badMess']) . ',' .
2634 t3lib_div::quoteJSvalue($conf['emailMess']) . ')"';
2635 $GLOBALS['TSFE']->additionalHeaderData['JSFormValidate'] = '<script type="text/javascript" src="' .
2636 t3lib_div::createVersionNumberedFilename($GLOBALS['TSFE']->absRefPrefix .
2637 't3lib/jsfunc.validateform.js') . '"></script>';
2638 } else {
2639 $validateForm = '';
2640 }
2641
2642 // Create form tag:
2643 $theTarget = ($theRedirect ? $LD['target'] : $LD_A['target']);
2644 $content = array(
2645 '<form' . ' action="' . htmlspecialchars($action) . '"' . ' id="' .
2646 $formname . '"' . ($xhtmlStrict ? '' : ' name="' . $formname . '"') .
2647 ' enctype="' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'] . '"' .
2648 ' method="' . ($conf['method'] ? $conf['method'] : 'post') . '"' .
2649 ($theTarget ? ' target="' . $theTarget . '"' : '') .
2650 $validateForm . '>', $hiddenfields . $content,
2651 '</form>'
2652 );
2653
2654 if ($conf['arrayReturnMode']) {
2655 $content['validateForm'] = $validateForm;
2656 $content['formname'] = $formname;
2657 return $content;
2658 } else {
2659 return implode('', $content);
2660 }
2661 }
2662
2663 /**
2664 * Rendering the cObject, SEARCHRESULT
2665 *
2666 * @param array array of TypoScript properties
2667 * @return string Output
2668 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=368&cHash=d00731cd7b
2669 */
2670 function SEARCHRESULT($conf) {
2671 if (t3lib_div::_GP('sword') && t3lib_div::_GP('scols')) {
2672 $search = t3lib_div::makeInstance('tslib_search');
2673 $search->register_and_explode_search_string(t3lib_div::_GP('sword'));
2674 $search->register_tables_and_columns(t3lib_div::_GP('scols'), $conf['allowedCols']);
2675 // depth
2676 $depth = 100;
2677 // the startId is found
2678 $theStartId = 0;
2679 if (t3lib_div::testInt(t3lib_div::_GP('stype'))) {
2680 $temp_theStartId = t3lib_div::_GP('stype');
2681 $rootLine = $GLOBALS['TSFE']->sys_page->getRootLine($temp_theStartId);
2682 // The page MUST have a rootline with the Level0-page of the current site inside!!
2683 foreach ($rootLine as $val) {
2684 if ($val['uid'] == $GLOBALS['TSFE']->tmpl->rootLine[0]['uid']) {
2685 $theStartId = $temp_theStartId;
2686 }
2687 }
2688 } else if (t3lib_div::_GP('stype')) {
2689 if (substr(t3lib_div::_GP('stype'), 0, 1) == 'L') {
2690 $pointer = intval(substr(t3lib_div::_GP('stype'), 1));
2691 $theRootLine = $GLOBALS['TSFE']->tmpl->rootLine;
2692 // location Data:
2693 $locDat_arr = explode(':', t3lib_div::_POST('locationData'));
2694 $pId = intval($locDat_arr[0]);
2695 if ($pId) {
2696 $altRootLine = $GLOBALS['TSFE']->sys_page->getRootLine($pId);
2697 ksort($altRootLine);
2698 if (count($altRootLine)) {
2699 // check if the rootline has the real Level0 in it!!
2700 $hitRoot = 0;
2701 $theNewRoot = array();
2702 foreach ($altRootLine as $val) {
2703 if ($hitRoot || $val['uid'] == $GLOBALS['TSFE']->tmpl->rootLine[0]['uid']) {
2704 $hitRoot = 1;
2705 $theNewRoot[] = $val;
2706 }
2707 }
2708 if ($hitRoot) {
2709 $theRootLine = $theNewRoot; // Override the real rootline if any thing
2710 }
2711 }
2712 }
2713 $key = $this->getKey($pointer, $theRootLine);
2714 $theStartId = $theRootLine[$key]['uid'];
2715 }
2716 }