Added support for JavaScript window open in target parameter for typoLink. See next...
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / tslib / class.tslib_content.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2003 Kasper Skårhøj (kasper@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 * Revised for TYPO3 3.6 June/2003 by Kasper Skårhøj
31 * XHTML compliant
32 *
33 * class tslib_cObj : All main TypoScript features, rendering of content objects (cObjects). This class is the backbone of TypoScript Template rendering.
34 * class tslib_controlTable : Makes a table CTABLE (TS cObject)
35 * class tslib_tableOffset : Makes a table-offset (TS)
36 * class tslib_frameset : Generates framesets (TS)
37 *
38 * @author Kasper Skårhøj <kasper@typo3.com>
39 * @package TYPO3
40 * @subpackage tslib
41 */
42 /**
43 * [CLASS/FUNCTION INDEX of SCRIPT]
44 *
45 *
46 *
47 * 243: class tslib_cObj
48 * 340: function start($data,$table='')
49 * 355: function setParent($data,$currentRecord)
50 *
51 * SECTION: CONTENT_OBJ:
52 * 380: function getCurrentVal()
53 * 391: function setCurrentVal($value)
54 * 404: function cObjGet($setup,$addKey='')
55 * 428: function cObjGetSingle($name,$conf,$TSkey='__')
56 *
57 * SECTION: Functions rendering content objects (cObjects)
58 * 567: function HTML($conf)
59 * 578: function TEXT($conf)
60 * 589: function CLEARGIF($conf)
61 * 608: function COBJ_ARRAY($conf,$ext='')
62 * 644: function USER($conf,$ext='')
63 * 671: function FILE($conf)
64 * 687: function IMAGE($conf)
65 * 706: function IMG_RESOURCE($conf)
66 * 718: function IMGTEXT($conf)
67 * 1092: function CONTENT($conf)
68 * 1145: function RECORDS($conf)
69 * 1211: function HMENU($conf)
70 * 1243: function CTABLE ($conf)
71 * 1281: function OTABLE ($conf)
72 * 1296: function COLUMNS ($conf)
73 * 1375: function HRULER ($conf)
74 * 1399: function CASEFUNC ($conf)
75 * 1424: function LOAD_REGISTER($conf,$name)
76 * 1464: function FORM($conf,$formData='')
77 * 1831: function SEARCHRESULT($conf)
78 * 1988: function PHP_SCRIPT($conf,$ext='')
79 * 2031: function TEMPLATE($conf)
80 * 2175: function MULTIMEDIA($conf)
81 *
82 * SECTION: Various helper functions for content objects:
83 * 2259: function netprintApplication_offsiteLinkWrap($str,$imgConf,$conf)
84 * 2300: function getFieldDefaultValue($noValueInsert, $fieldName, $defaultVal)
85 * 2318: function cImage($file,$conf)
86 * 2345: function imageLinkWrap($string,$imageFile,$conf)
87 * 2409: function fileResource($fName)
88 * 2432: function lastChanged($tstamp)
89 * 2449: function linkWrap($content,$wrap)
90 *
91 * SECTION: HTML template processing functions
92 * 2494: function getSubpart($content, $marker)
93 * 2523: function substituteSubpart($content,$marker,$subpartContent,$recursive=1)
94 * 2565: function substituteMarker($content,$marker,$markContent)
95 * 2586: function substituteMarkerArrayCached($content,$markContentArray=array(),$subpartContentArray=array(),$wrappedSubpartContentArray=array())
96 * 2684: function substituteMarkerArray($content,$markContentArray,$wrap='',$uppercase=0)
97 * 2705: function substituteMarkerInObject(&$tree, $markContentArray)
98 * 2727: function fillInMarkerArray($markContentArray, $row, $fieldList='', $nl2br=1, $prefix='FIELD_')
99 *
100 * SECTION: "stdWrap" + sub functions
101 * 2788: function stdWrap($content,$conf)
102 * 2928: function numRows($conf)
103 * 2948: function listNum($content,$listNum,$char)
104 * 2968: function checkIf($conf)
105 * 3031: function filelist($data)
106 * 3110: function clean_directory($theDir)
107 * 3128: function HTMLparser_TSbridge($theValue, $conf)
108 * 3142: function dataWrap($content,$wrap)
109 * 3155: function insertData($str)
110 * 3184: function substring($content,$options)
111 * 3202: function crop($content,$options)
112 * 3228: function textStyle($theValue, $conf)
113 * 3295: function tableStyle($theValue, $conf)
114 * 3336: function addParams($content,$conf)
115 * 3374: function filelink($theValue, $conf)
116 * 3441: function locDataJU($jumpUrl,$conf)
117 * 3472: function calc($val)
118 * 3501: function calcIntExplode($delim, $string)
119 * 3521: function splitObj($value, $conf)
120 * 3576: function parseFunc($theValue, $conf)
121 * 3670: function _parseFunc ($theValue, $conf)
122 * 3872: function encaps_lineSplit($theValue, $conf)
123 * 3955: function http_makelinks($data,$conf)
124 * 4014: function mailto_makelinks($data,$conf)
125 * 4059: function getImgResource($file,$fileArray)
126 *
127 * SECTION: Data retrieval etc.
128 * 4231: function getFieldVal($field)
129 * 4251: function getData($string,$fieldArray)
130 * 4338: function rootLineValue($key,$field,$slideBack=0,$altRootLine='')
131 * 4359: function getGlobal($var)
132 * 4384: function getKey($key,$arr)
133 *
134 * SECTION: Link functions (typolink)
135 * 4439: function typoLink($linktxt, $conf)
136 * 4646: function typoLink_URL($conf)
137 * 4664: function getTypoLink($label,$params,$urlParameters=array(),$target='')
138 * 4694: function getTypoLink_URL($params,$urlParameters=array(),$target='')
139 * 4706: function typolinkWrap($conf)
140 * 4719: function currentPageUrl($urlParameters=array(),$id=0)
141 *
142 * SECTION: Miscellaneous functions, stand alone
143 * 4763: function wrap($content,$wrap,$char='|')
144 * 4779: function noTrimWrap($content,$wrap)
145 * 4793: function wrapSpace($content, $wrap)
146 * 4819: function callUserFunction($funcName,$conf,$content)
147 * 4860: function processParams($params)
148 * 4878: function keywords($content)
149 * 4895: function caseshift($theValue, $case)
150 * 4918: function HTMLcaseshift($theValue, $case)
151 * 4946: function bytes($sizeInBytes)
152 * 4957: function calcAge($seconds,$labels)
153 * 4988: function sendNotifyEmail($msg, $recipients, $cc, $email_from, $email_fromName='', $replyTo='')
154 * 5015: function URLqMark($url,$params)
155 * 5031: function checkEmail($email)
156 * 5043: function clearTSProperties($TSArr,$propList)
157 * 5062: function mergeTSRef($confArr,$prop)
158 * 5085: function joinTSarrays($conf,$old_conf)
159 * 5108: function gifBuilderTextBox($gifbuilderConf, $conf, $text)
160 * 5164: function linebreaks($string,$chars,$maxLines=0)
161 * 5196: function getUpdateJS($dataArray, $formName, $arrPrefix, $fieldList, $stripSlashes=1)
162 *
163 * SECTION: Database functions, making of queries
164 * 5267: function DBgetDelete($table, $uid)
165 * 5293: function DBgetUpdate($table, $uid, $dataArr, $fieldList, $addSlashes=0)
166 * 5329: function DBgetInsert($table, $pid, $dataArr, $fieldList, $addSlashes=0)
167 * 5361: function DBcompileInsert($table,$fp,$vp)
168 * 5377: function DBmayFEUserEdit($table,$row, $feUserRow, $allowedGroups='',$feEditSelf=0)
169 * 5417: function DBmayFEUserEditSelect($table,$feUserRow,$allowedGroups='',$feEditSelf=0)
170 * 5457: function enableFields($table,$show_hidden=0)
171 * 5480: function getTreeList($id,$depth,$begin=0,$dontCheckEnableFields=0,$addSelectFields='',$moreWhereClauses='')
172 * 5514: function whereSelectFromList($field,$value)
173 * 5531: function mm_query($select,$local_table,$mm_table,$foreign_table,$endClause='')
174 * 5550: function mm_query_uidList($select,$local_table_uidlist,$mm_table,$foreign_table='',$endClause='')
175 * 5566: function searchWhere($sw,$searchFieldList,$prefixTableName='')
176 * 5601: function getQuery($table,$conf)
177 * 5659: function getWhere($table,$conf)
178 * 5727: function checkPidArray($listArr)
179 * 5751: function checkPid($uid)
180 *
181 * SECTION: Frontend editing functions
182 * 5808: function editPanel($content, $conf, $currentRecord='', $dataArr=array())
183 * 5961: function editIcons($content,$params, $conf=array(), $currentRecord='', $dataArr=array(),$addUrlParamStr='')
184 * 6019: function editPanelLinkWrap($string,$formName,$cmd,$currentRecord='',$confirm='')
185 * 6057: function editPanelLinkWrap_doWrap($string,$url,$currentRecord)
186 * 6084: function editPanelPreviewBorder($table,$row,$content,$thick)
187 * 6101: function isDisabled($table,$row)
188 *
189 *
190 * 6132: class tslib_frameset
191 * 6142: function make($setup)
192 * 6179: function frameParams($setup, $typeNum)
193 * 6214: function framesetParams($setup)
194 *
195 *
196 * 6247: class tslib_tableOffset
197 * 6259: function start($content,$offset)
198 *
199 *
200 * 6337: class tslib_controlTable
201 * 6372: function start($offset,$cMargins)
202 *
203 * TOTAL FUNCTIONS: 125
204 * (This index is automatically created/updated by the extension "extdeveval")
205 *
206 */
207
208
209 // Includes this class since it is used for parsing HTML
210 require_once (PATH_t3lib."class.t3lib_parsehtml.php");
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229 /**
230 * This class contains all main TypoScript features.
231 * This includes the rendering of TypoScript content objects (cObjects).
232 * Is the backbone of TypoScript Template rendering.
233 *
234 * There are lots of functions you can use from your include-scripts.
235 * The class "tslib_cObj" is normally instantiated and referred to as "cObj".
236 * 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.
237 *
238 * @author Kasper Skårhøj <kasper@typo3.com>
239 * @package TYPO3
240 * @subpackage tslib
241 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&cHash=4ad9d7acb4
242 */
243 class tslib_cObj {
244 var $align = Array ('center', 'right', 'left');
245 var $caseConvStrings = array(
246 'áéúíâêûôîæøåäöü',
247 'ÁÉÚÍÄËÜÖÏÆØÅÄÖÜ'
248 );
249
250 /**
251 * Holds ImageMagick parameters and extensions used for compression
252 *
253 * @see IMGTEXT()
254 *
255 * 0= Default
256 * 1= Dont change! (removes all parameters for the image_object!!)
257 * 1x = GIFs
258 * 2x = JPGs
259 */
260 var $image_compression = Array(
261 10 => Array('params'=>'', 'ext'=>'gif'),
262 11 => Array('params'=>'-colors 128', 'ext'=>'gif'),
263 12 => Array('params'=>'-colors 64', 'ext'=>'gif'),
264 13 => Array('params'=>'-colors 32', 'ext'=>'gif'),
265 14 => Array('params'=>'-colors 16', 'ext'=>'gif'),
266 15 => Array('params'=>'-colors 8', 'ext'=>'gif'),
267
268 30 => Array('params'=>'-colors 256', 'ext'=>'png'),
269 31 => Array('params'=>'-colors 128', 'ext'=>'png'),
270 32 => Array('params'=>'-colors 64', 'ext'=>'png'),
271 33 => Array('params'=>'-colors 32', 'ext'=>'png'),
272 34 => Array('params'=>'-colors 16', 'ext'=>'png'),
273 35 => Array('params'=>'-colors 8', 'ext'=>'png'),
274 39 => Array('params'=>'', 'ext'=>'png'),
275
276 20 => Array('params'=>'-quality 100', 'ext'=>'jpg'),
277 21 => Array('params'=>'-quality 90', 'ext'=>'jpg'),
278 22 => Array('params'=>'-quality 80', 'ext'=>'jpg'),
279 23 => Array('params'=>'-quality 70', 'ext'=>'jpg'),
280 24 => Array('params'=>'-quality 60', 'ext'=>'jpg'),
281 25 => Array('params'=>'-quality 50', 'ext'=>'jpg'),
282 26 => Array('params'=>'-quality 40', 'ext'=>'jpg'),
283 27 => Array('params'=>'-quality 30', 'ext'=>'jpg'),
284 28 => Array('params'=>'-quality 20', 'ext'=>'jpg')
285 );
286
287 /**
288 * ImageMagick parameters for image effects
289 *
290 * @see IMGTEXT()
291 */
292 var $image_effects = Array(
293 1 => '-rotate 90',
294 2 => '-rotate 270',
295 3 => '-rotate 180',
296 10 => '-colorspace GRAY',
297 11 => '-sharpen 70',
298 20 => '-normalize',
299 23 => '-contrast',
300 25 => '-gamma 1.3',
301 26 => '-gamma 0.8'
302 );
303
304 /**
305 * Loaded with the current data-record.
306 *
307 * If the instance of this class is used to render records from the database those records are found in this array.
308 * The function stdWrap has TypoScript properties that fetch field-data from this array.
309 * @see init()
310 */
311 var $data = Array();
312 var $oldData = Array(); // Used for backup...
313 var $alternativeData =''; // If this is set with an array before stdWrap, it's used instead of $this->data in the data-property in stdWrap
314 var $parameters = Array(); // Used by the parseFunc function and is loaded with tag-parameters when parsing tags.
315 var $currentValKey = 'currentValue_kidjls9dksoje';
316 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.
317 var $currentRecordTotal=0; // Set in cObj->RECORDS and cObj->CONTENT to the current number of records selected in a query.
318 var $currentRecordNumber=0; // Incremented in cObj->RECORDS and cObj->CONTENT before each record rendering.
319 var $parentRecordNumber=0; // Incremented in parent cObj->RECORDS and cObj->CONTENT before each record rendering.
320 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.
321 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.
322
323 // internal
324 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)
325 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.
326 var $checkPid_badDoktypeList = '255';
327 var $lastTypoLinkUrl=''; // This will be set by typoLink() to the url of the most recent link created.
328 var $lastTypoLinkTarget=''; // DO. link target.
329 var $substMarkerCache=array(); // Caching substituteMarkerArrayCached function
330
331 /**
332 * Class constructor.
333 * Well, it has to be called manually since it is not a real constructor function.
334 * 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.
335 *
336 * @param array $data the record data that is rendered.
337 * @param string $table the table that the data record is from.
338 * @return void
339 */
340 function start($data,$table='') {
341 $this->data = $data;
342 $this->currentRecord = $table ? $table.':'.$this->data['uid'] : '';
343 $this->parameters = Array();
344 }
345
346 /**
347 * Sets the internal variable parentRecord with information about current record.
348 * 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.
349 *
350 * @param array $data: The record array
351 * @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.
352 * @return void
353 * @access private
354 */
355 function setParent($data,$currentRecord) {
356 $this->parentRecord=array('data'=>$data, 'currentRecord'=>$currentRecord);
357 }
358
359
360
361
362
363
364
365
366 /***********************************************
367 *
368 * CONTENT_OBJ:
369 *
370 ***********************************************/
371
372 /**
373 * Returns the "current" value.
374 * 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.
375 * It's like "load accumulator" in the good old C64 days... basically a "register" you can use as you like.
376 * 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.
377 *
378 * @return mixed The "current" value
379 */
380 function getCurrentVal() {
381 return $this->data[$this->currentValKey];
382 }
383
384 /**
385 * Sets the "current" value.
386 *
387 * @param mixed The variable that you want to set as "current"
388 * @return void
389 * @see getCurrentVal()
390 */
391 function setCurrentVal($value) {
392 $this->data[$this->currentValKey] = $value;
393 }
394
395 /**
396 * Rendering of a "numerical array" of cObjects from TypoScript
397 * Will call ->cObjGetSingle() for each cObject found and accumulate the output.
398 *
399 * @param array $setup: Array with cObjects as values.
400 * @param string $addKey: A prefix for the debugging information
401 * @return string Rendered output from the cObjects in the array.
402 * @see cObjGetSingle()
403 */
404 function cObjGet($setup,$addKey='') {
405 if (is_array($setup)) {
406 $sKeyArray=t3lib_TStemplate::sortedKeyList($setup);
407 $content ='';
408 foreach($sKeyArray as $theKey) {
409 $theValue=$setup[$theKey];
410 if (intval($theKey) && !strstr($theKey,'.')) {
411 $conf=$setup[$theKey.'.'];
412 $content.=$this->cObjGetSingle($theValue,$conf,$addKey.$theKey); // Get the contentObject
413 }
414 }
415 return $content;
416 }
417 }
418
419 /**
420 * Renders a content object
421 *
422 * @param string The content object name, eg. "TEXT" or "USER" or "IMAGE"
423 * @param array The array with TypoScript properties for the content object
424 * @param string A string label used for the internal debugging tracking.
425 * @return string cObject output
426 * @example http://typo3.org/doc.0.html?&encryptionKey=&tx_extrepmgm_pi1[extUid]=267&tx_extrepmgm_pi1[tocEl]=153&cHash=7e74f4d331
427 */
428 function cObjGetSingle($name,$conf,$TSkey='__') {
429 $content='';
430 // Checking that the function is not called eternally. This is done by interrupting at a depth of 100
431 $GLOBALS['TSFE']->cObjectDepthCounter--;
432 if ($GLOBALS['TSFE']->cObjectDepthCounter>0) {
433 $name = trim($name);
434 if ($GLOBALS['TT']->LR) $GLOBALS['TT']->push($TSkey, $name);
435
436 // Checking if the COBJ is a reference to another object. (eg. name of 'blabla.blabla = < styles.something')
437 if (substr($name,0,1)=='<') {
438 $key = trim(substr($name,1));
439 $cF = t3lib_div::makeInstance('t3lib_TSparser');
440 // $name and $conf is loaded with the referenced values.
441 $old_conf=$conf;
442 list($name, $conf) = $cF->getVal($key,$GLOBALS['TSFE']->tmpl->setup);
443 if (is_array($old_conf) && count($old_conf)) {
444 $conf = $this->joinTSarrays($conf,$old_conf);
445 // debug($conf);
446 }
447 // Getting the cObject
448 $GLOBALS['TT']->incStackPointer();
449 $content.=$this->cObjGetSingle($name,$conf,$key);
450 $GLOBALS['TT']->decStackPointer();
451 } else {
452 switch($name) {
453 case 'COBJ_ARRAY':
454 case 'COA':
455 $content.=$this->COBJ_ARRAY($conf);
456 break;
457 case 'COA_INT':
458 $content.=$this->COBJ_ARRAY($conf,'INT');
459 break;
460 case 'HTML':
461 $content.=$this->HTML($conf);
462 break;
463 case 'TEXT':
464 $content.=$this->TEXT($conf);
465 break;
466 case 'CLEARGIF':
467 $content.=$this->CLEARGIF($conf);
468 break;
469 case 'FILE':
470 $content.=$this->FILE($conf);
471 break;
472 case 'IMAGE':
473 $content.=$this->IMAGE($conf);
474 break;
475 case 'IMG_RESOURCE':
476 $content.=$this->IMG_RESOURCE($conf);
477 break;
478 case 'IMGTEXT':
479 $content.=$this->IMGTEXT($conf);
480 break;
481 case 'CONTENT':
482 $content.=$this->CONTENT($conf);
483 break;
484 case 'RECORDS':
485 $content.=$this->RECORDS($conf);
486 break;
487 case 'HMENU':
488 $content.=$this->HMENU($conf);
489 break;
490 case 'CTABLE':
491 $content.=$this->CTABLE($conf);
492 break;
493 case 'OTABLE':
494 $content.=$this->OTABLE($conf);
495 break;
496 case 'COLUMNS':
497 $content.=$this->COLUMNS($conf);
498 break;
499 case 'HRULER':
500 $content.=$this->HRULER($conf);
501 break;
502 case 'CASE':
503 $content.=$this->CASEFUNC($conf);
504 break;
505 case 'LOAD_REGISTER':
506 case 'RESTORE_REGISTER':
507 $this->LOAD_REGISTER($conf,$name);
508 break;
509 case 'FORM':
510 $content.=$this->FORM($conf);
511 break;
512 case 'SEARCHRESULT':
513 $content.=$this->SEARCHRESULT($conf);
514 break;
515 case 'PHP_SCRIPT':
516 $content.=$this->PHP_SCRIPT($conf);
517 break;
518 case 'PHP_SCRIPT_EXT':
519 $content.=$this->PHP_SCRIPT($conf,'EXT');
520 break;
521 case 'PHP_SCRIPT_INT':
522 $content.=$this->PHP_SCRIPT($conf,'INT');
523 break;
524 case 'USER':
525 $content.=$this->USER($conf);
526 break;
527 case 'USER_INT':
528 $content.=$this->USER($conf,'INT');
529 break;
530 case 'TEMPLATE':
531 $content.=$this->TEMPLATE($conf);
532 break;
533 case 'EDITPANEL':
534 if ($GLOBALS['TSFE']->beUserLogin) {$content.=$this->editPanel($content, $conf);}
535 break;
536 case 'MULTIMEDIA':
537 $content.=$this->MULTIMEDIA($conf);
538 break;
539 }
540 }
541 if ($GLOBALS['TT']->LR) $GLOBALS['TT']->pull($content);
542 }
543 // Increasing on exit...
544 $GLOBALS['TSFE']->cObjectDepthCounter++;
545 return $content;
546 }
547
548
549
550
551
552
553
554 /********************************************
555 *
556 * Functions rendering content objects (cObjects)
557 *
558 ********************************************/
559
560 /**
561 * Rendering the cObject, HTML
562 *
563 * @param array Array of TypoScript properties
564 * @return string Output
565 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=349&cHash=d3fd0c70b4
566 */
567 function HTML($conf) {
568 return $this->stdWrap($conf['value'],$conf['value.']);
569 }
570
571 /**
572 * Rendering the cObject, TEXT
573 *
574 * @param array Array of TypoScript properties
575 * @return string Output
576 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=350&cHash=b49de28f83
577 */
578 function TEXT($conf) {
579 return $this->stdWrap($conf['value'],$conf);
580 }
581
582 /**
583 * Rendering the cObject, CLEARGIF
584 *
585 * @param array Array of TypoScript properties
586 * @return string Output
587 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=355&cHash=70c0f19915
588 */
589 function CLEARGIF($conf) {
590 $w = $this->stdWrap($conf['width'],$conf['width.']);
591 $h = $this->stdWrap($conf['height'],$conf['height.']);
592 $w = $w ? $w : 1;
593 $h = $h ? $h : 1;
594 $wrap = $conf['wrap'] ? $conf['wrap'] : '|<br />';
595 $theValue = $this->wrap('<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$w.'" height="'.$h.'" border="0" alt="" />', $wrap);
596
597 return $this->stdWrap($theValue,$conf['stdWrap.']);
598 }
599
600 /**
601 * Rendering the cObject, COBJ_ARRAY / COA and COBJ_ARRAY_INT
602 *
603 * @param array Array of TypoScript properties
604 * @param string If "INT" then the cObject is a "COBJ_ARRAY_INT" (non-cached), otherwise just "COBJ_ARRAY" (cached)
605 * @return string Output
606 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=351&cHash=a09db0329c
607 */
608 function COBJ_ARRAY($conf,$ext='') {
609 $content='';
610 switch($ext) {
611 case 'INT':
612 $substKey = $ext.'_SCRIPT.'.$GLOBALS['TSFE']->uniqueHash();
613 $content.='<!--'.$substKey.'-->';
614 $GLOBALS['TSFE']->config[$ext.'incScript'][$substKey] = array(
615 'file'=>$incFile,
616 'conf'=>$conf,
617 'cObj'=>serialize($this),
618 'type'=>'COA'
619 );
620 break;
621 default:
622 if ($this->checkIf($conf['if.'])) {
623 $content=$this->cObjGet($conf);
624 if ($conf['wrap']) {
625 $content=$this->wrap($content, $conf['wrap']);
626 }
627 if ($conf['stdWrap.']) {
628 $content=$this->stdWrap($content, $conf['stdWrap.']);
629 }
630 }
631 break;
632 }
633 return $content;
634 }
635
636 /**
637 * Rendering the cObject, USER and USER_INT
638 *
639 * @param array Array of TypoScript properties
640 * @param string If "INT" then the cObject is a "USER_INT" (non-cached), otherwise just "USER" (cached)
641 * @return string Output
642 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=369&cHash=b623aca0a9
643 */
644 function USER($conf,$ext='') {
645 $content='';
646 switch($ext) {
647 case 'INT':
648 $substKey = $ext.'_SCRIPT.'.$GLOBALS['TSFE']->uniqueHash();
649 $content.='<!--'.$substKey.'-->';
650 $GLOBALS['TSFE']->config[$ext.'incScript'][$substKey] = array(
651 'file'=>$incFile,
652 'conf'=>$conf,
653 'cObj'=>serialize($this),
654 'type'=>'FUNC'
655 );
656 break;
657 default:
658 $content.=$this->callUserFunction($conf['userFunc'],$conf,'');
659 break;
660 }
661 return $content;
662 }
663
664 /**
665 * Rendering the cObject, FILE
666 *
667 * @param array Array of TypoScript properties
668 * @return string Output
669 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=352&cHash=379c60f8bc
670 */
671 function FILE($conf) {
672 $theValue = $this->fileResource($this->stdWrap($conf['file'],$conf['file.']));
673 if ($conf['linkWrap']) {
674 $theValue = $this->linkWrap($theValue,$conf['linkWrap']);
675 }
676 return $this->wrap($theValue,$conf['wrap']);
677 }
678
679 /**
680 * Rendering the cObject, IMAGE
681 *
682 * @param array Array of TypoScript properties
683 * @return string Output
684 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=353&cHash=440681ea56
685 * @see cImage()
686 */
687 function IMAGE($conf) {
688 $content='';
689 if ($this->checkIf($conf['if.'])) {
690 $theValue = $this->cImage($conf['file'],$conf);
691 if ($conf['stdWrap.']) {
692 $theValue = $this->stdWrap($theValue,$conf['stdWrap.']);
693 }
694 return $theValue;
695 }
696 }
697
698 /**
699 * Rendering the cObject, IMG_RESOURCE
700 *
701 * @param array Array of TypoScript properties
702 * @return string Output
703 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=354&cHash=46f9299706
704 * @see getImgResource()
705 */
706 function IMG_RESOURCE($conf) {
707 $imgArray = $this->getImgResource($conf['file'],$conf['file.']);
708 return $this->stdWrap($imgArray[3],$conf['stdWrap.']);
709 }
710
711 /**
712 * Rendering the cObject, IMGTEXT
713 *
714 * @param array Array of TypoScript properties
715 * @return string Output
716 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=363&cHash=cf2969bce1
717 */
718 function IMGTEXT($conf) {
719 $content='';
720 if (is_array($conf['text.'])) {
721 $content.= $this->stdWrap($this->cObjGet($conf['text.'],'text.'),$conf['text.']); // this gets the surrounding content
722 }
723 $imgList=trim($this->stdWrap($conf['imgList'],$conf['imgList.'])); // gets images
724 if ($imgList) {
725 $imgs = explode(',',$imgList);
726 $imgStart = intval($this->stdWrap($conf['imgStart'],$conf['imgStart.']));
727
728 $imgCount= count($imgs)-$imgStart;
729
730 $imgMax = intval($this->stdWrap($conf['imgMax'],$conf['imgMax.']));
731 if ($imgMax) {
732 $imgCount = t3lib_div::intInRange($imgCount,0,$conf['imgMax']); // reduces the number of images.
733 }
734
735 $imgPath = $this->stdWrap($conf['imgPath'],$conf['imgPath.']);
736
737 // initialisation
738 $caption='';
739 if (is_array($conf['caption.'])) {
740 $caption= $this->stdWrap($this->cObjGet($conf['caption.'], 'caption.'),$conf['caption.']);
741 }
742 $captionArray=array();
743 if ($conf['captionSplit']) {
744 $capSplit = $this->stdWrap($conf['captionSplit.']['token'],$conf['captionSplit.']['token.']);
745 if (!$capSplit) {$capSplit=chr(10);}
746 $caption2= $this->cObjGetSingle($conf['captionSplit.']['cObject'],$conf['captionSplit.']['cObject.'],'captionSplit.cObject');
747 $captionArray=explode($capSplit,$caption2);
748 while(list($ca_key,$ca_val)=each($captionArray)) {
749 $captionArray[$ca_key] = $this->stdWrap(trim($captionArray[$ca_key]), $conf['captionSplit.']['stdWrap.']);
750 }
751 }
752
753 $tablecode='';
754 $position=$this->stdWrap($conf['textPos'],$conf['textPos.']);
755
756 $tmppos = $position&7;
757 $contentPosition = $position&24;
758 $align = $this->align[$tmppos];
759 $cap = ($caption)?1:0;
760 $txtMarg = intval($this->stdWrap($conf['textMargin'],$conf['textMargin.']));
761 if (!$conf['textMargin_outOfText'] && $contentPosition<16) {
762 $txtMarg=0;
763 }
764
765 $cols = intval($this->stdWrap($conf['cols'],$conf['cols.']));
766 $rows = intval($this->stdWrap($conf['rows'],$conf['rows.']));
767 $colspacing = intval($this->stdWrap($conf['colSpace'],$conf['colSpace.']));
768 $rowspacing = intval($this->stdWrap($conf['rowSpace'],$conf['rowSpace.']));
769
770 $border = intval($this->stdWrap($conf['border'],$conf['border.'])) ? 1:0;
771 $borderColor = $this->stdWrap($conf['borderCol'],$conf['borderCol.']);
772 $borderThickness = intval($this->stdWrap($conf['borderThick'],$conf['borderThick.']));
773
774 $borderColor=$borderColor?$borderColor:'black';
775 $borderThickness=$borderThickness?$borderThickness:1;
776
777 $caption_align = $this->stdWrap($conf['captionAlign'],$conf['captionAlign.']);
778 if (!$caption_align) {
779 $caption_align = $align;
780 }
781 // generate cols
782 $colCount = ($cols > 1) ? $cols : 1;
783 if ($colCount > $imgCount) {$colCount = $imgCount;}
784 $rowCount = ($colCount > 1) ? ceil($imgCount / $colCount) : $imgCount;
785 // generate rows
786 if ($rows>1) {
787 $rowCount = $rows;
788 if ($rowCount > $imgCount) {$rowCount = $imgCount;}
789 $colCount = ($rowCount>1) ? ceil($imgCount / $rowCount) : $imgCount;
790 }
791
792 // max Width
793 $colRelations = trim($this->stdWrap($conf['colRelations'],$conf['colRelations.']));
794 $maxW = intval($this->stdWrap($conf['maxW'],$conf['maxW.']));
795
796 $maxWInText = intval($this->stdWrap($conf['maxWInText'],$conf['maxWInText.']));
797 if (!$maxWInText) { // If maxWInText is not set, it's calculated to the 70 % of the max...
798 $maxWInText = round($maxW/100*50);
799 }
800
801 if ($maxWInText && $contentPosition>=16) { // inText
802 $maxW = $maxWInText;
803 }
804
805 if ($maxW && $colCount > 0) { // If there is a max width and if colCount is greater than column
806 /* debug($border*$borderThickness*2);
807 debug($maxW);
808 debug($colspacing);
809 debug(($maxW-$colspacing*($colCount-1)-$colCount*$border*$borderThickness*2));
810 */
811 $maxW = ceil(($maxW-$colspacing*($colCount-1)-$colCount*$border*$borderThickness*2)/$colCount);
812 }
813 // create the relation between rows
814 $colMaxW = Array();
815 if ($colRelations) {
816 $rel_parts = explode(':',$colRelations);
817 $rel_total = 0;
818 for ($a=0;$a<$colCount;$a++) {
819 $rel_parts[$a] = intval($rel_parts[$a]);
820 $rel_total+= $rel_parts[$a];
821 }
822 if ($rel_total) {
823 for ($a=0;$a<$colCount;$a++) {
824 $colMaxW[$a] = round(($maxW*$colCount)/$rel_total*$rel_parts[$a]);
825 }
826 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.
827 $colMaxW = Array();
828 }
829 }
830 }
831 $image_compression = intval($this->stdWrap($conf['image_compression'],$conf['image_compression.']));
832 $image_effects = intval($this->stdWrap($conf['image_effects'],$conf['image_effects.']));
833 $image_frames = intval($this->stdWrap($conf['image_frames.']['key'],$conf['image_frames.']['key.']));
834
835 // fetches pictures
836 $splitArr=array();
837 $splitArr['imgObjNum']=$conf['imgObjNum'];
838 $splitArr = $GLOBALS['TSFE']->tmpl->splitConfArray($splitArr,$imgCount);
839
840 $alttext = $this->stdWrap($conf['altText'],$conf['altText.']);
841 if ($alttext) {
842 $altP = ' alt="'.htmlspecialchars(strip_tags($alttext)).'"';
843 }
844 // EqualHeight
845 $equalHeight = intval($this->stdWrap($conf['equalH'],$conf['equalH.']));
846 if ($equalHeight) { // Initiate gifbuilder object in order to get dimensions AND calculate the imageWidth's
847 $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
848 $gifCreator->init();
849 $relations = Array();
850 $relations_cols = Array();
851 $totalMaxW = $maxW*$colCount;
852 for($a=0;$a<$imgCount;$a++) {
853 $imgKey = $a+$imgStart;
854 $imgInfo = $gifCreator->getImageDimensions($imgPath.$imgs[$imgKey]);
855 $relations[$a] = $imgInfo[1] / $equalHeight; // relationship between the original height and the wished height
856 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.
857 $relations_cols[floor($a/$colCount)] += $imgInfo[0]/$relations[$a]; // counts the total width of the row with the new height taken into consideration.
858 }
859 }
860 }
861
862 $imageRowsFinalWidths = Array(); // contains the width of every image row
863 $imageRowsMaxHeights = Array();
864 $imgsTag=array();
865 $origImages=array();
866 for($a=0;$a<$imgCount;$a++) {
867 $GLOBALS['TSFE']->register['IMAGE_NUM'] = $a;
868
869 $imgKey = $a+$imgStart;
870 $totalImagePath = $imgPath.$imgs[$imgKey];
871 $this->data[$this->currentValKey] = $totalImagePath;
872 $imgObjNum = intval($splitArr[$a]['imgObjNum']);
873 $imgConf = $conf[$imgObjNum.'.'];
874
875 if ($equalHeight) {
876 $scale = 1;
877 if ($totalMaxW) {
878 $rowTotalMaxW = $relations_cols[floor($a/$colCount)];
879 if ($rowTotalMaxW > $totalMaxW) {
880 $scale = $rowTotalMaxW / $totalMaxW;
881 }
882 }
883 // transfer info to the imageObject. Please note, that
884 $imgConf['file.']['height'] = round($equalHeight/$scale);
885
886 unset($imgConf['file.']['width']);
887 unset($imgConf['file.']['maxW']);
888 unset($imgConf['file.']['maxH']);
889 unset($imgConf['file.']['minW']);
890 unset($imgConf['file.']['minH']);
891 unset($imgConf['file.']['width.']);
892 unset($imgConf['file.']['maxW.']);
893 unset($imgConf['file.']['maxH.']);
894 unset($imgConf['file.']['minW.']);
895 unset($imgConf['file.']['minH.']);
896 $maxW = 0; // setting this to zero, so that it doesn't disturb
897 }
898
899 if ($maxW) {
900 if (count($colMaxW)) {
901 $imgConf['file.']['maxW'] = $colMaxW[($a%$colCount)];
902 } else {
903 $imgConf['file.']['maxW'] = $maxW;
904 }
905 }
906
907 if ($imgConf || $imgConf['file']) {
908 $imgConf['params'].=$altP;
909 if ($this->image_effects[$image_effects]) {
910 $imgConf['file.']['params'].= ' '.$this->image_effects[$image_effects];
911 }
912 if ($image_frames) {
913 if (is_array($conf['image_frames.'][$image_frames.'.'])) {
914 $imgConf['file.']['m.'] = $conf['image_frames.'][$image_frames.'.'];
915 }
916 }
917 if ($image_compression && $imgConf['file']!='GIFBUILDER') {
918 if ($image_compression==1) {
919 $tempImport = $imgConf['file.']['import'];
920 $tempImport_dot = $imgConf['file.']['import.'];
921 unset($imgConf['file.']);
922 $imgConf['file.']['import'] = $tempImport;
923 $imgConf['file.']['import.'] = $tempImport_dot;
924 } elseif (isset($this->image_compression[$image_compression])) {
925 $imgConf['file.']['params'].= ' '.$this->image_compression[$image_compression]['params'];
926 $imgConf['file.']['ext'] = $this->image_compression[$image_compression]['ext'];
927 unset($imgConf['file.']['ext.']);
928 }
929 }
930 $imgsTag[$imgKey] = $this->IMAGE($imgConf);
931 } else {
932 $imgsTag[$imgKey] = $this->IMAGE(Array('params'=>$altP, 'file'=>$totalImagePath)); // currentValKey !!!
933 }
934 // Store the original filepath
935 $origImages[$imgKey]=$GLOBALS['TSFE']->lastImageInfo;
936
937 $imageRowsFinalWidths[floor($a/$colCount)] += $GLOBALS['TSFE']->lastImageInfo[0];
938 if ($GLOBALS['TSFE']->lastImageInfo[1]>$imageRowsMaxHeights[floor($a/$colCount)]) {
939 $imageRowsMaxHeights[floor($a/$colCount)] = $GLOBALS['TSFE']->lastImageInfo[1];
940 }
941 }
942 // calculating the tableWidth:
943 // TableWidth problems: It creates problems if the pictures are NOT as wide as the tableWidth.
944 $tableWidth = max($imageRowsFinalWidths)+ $colspacing*($colCount-1) + $colCount*$border*$borderThickness*2;
945
946 // make table for pictures
947 $index=$imgStart;
948
949 $noRows = $this->stdWrap($conf['noRows'],$conf['noRows.']);
950 $noCols = $this->stdWrap($conf['noCols'],$conf['noCols.']);
951 if ($noRows) {$noCols=0;} // noRows overrides noCols. They cannot exist at the same time.
952 if ($equalHeight) {
953 $noCols=1;
954 $noRows=0;
955 }
956
957 $rowCount_temp=1;
958 $colCount_temp=$colCount;
959 if ($noRows) {
960 $rowCount_temp = $rowCount;
961 $rowCount=1;
962 }
963 if ($noCols) {
964 $colCount=1;
965 }
966 // col- and rowspans calculated
967 $colspan = (($colspacing) ? $colCount*2-1 : $colCount);
968 $rowspan = (($rowspacing) ? $rowCount*2-1 : $rowCount) + $cap;
969
970
971 // Edit icons:
972 $editIconsHTML = $conf['editIcons']&&$GLOBALS['TSFE']->beUserLogin ? $this->editIcons('',$conf['editIcons'],$conf['editIcons.']) : '';
973
974 // strech out table:
975 $tablecode='';
976 $flag=0;
977 if ($conf['noStretchAndMarginCells']!=1) {
978 $tablecode.='<tr>';
979 if ($txtMarg && $align=='right') { // If right aligned, the textborder is added on the right side
980 $tablecode.='<td rowspan="'.($rowspan+1).'" valign="top"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$txtMarg.'" height="1" alt="" />'.($editIconsHTML?'<br />'.$editIconsHTML:'').'</td>';
981 $editIconsHTML='';
982 $flag=1;
983 }
984 $tablecode.='<td colspan="'.$colspan.'"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$tableWidth.'" height="1" alt="" /></td>';
985 if ($txtMarg && $align=='left') { // If left aligned, the textborder is added on the left side
986 $tablecode.='<td rowspan="'.($rowspan+1).'" valign="top"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$txtMarg.'" height="1" alt="" />'.($editIconsHTML?'<br />'.$editIconsHTML:'').'</td>';
987 $editIconsHTML='';
988 $flag=1;
989 }
990 if ($flag) $tableWidth+=$txtMarg+1;
991 // $tableWidth=0;
992 $tablecode.='</tr>';
993 }
994
995 // draw table
996 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!
997 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.
998 $tablecode.='<tr><td colspan="'.$colspan.'"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$rowspacing.'" border="0" alt="" /></td></tr>';
999 }
1000 $tablecode.='<tr>'; // starting row
1001 for ($b=0; $b<$colCount_temp; $b++) { // Looping through the columns
1002 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.
1003 if (!$noCols) {
1004 $tablecode.='<td><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$colspacing.'" height="1" border="0" alt="" /></td>';
1005 } else {
1006 $colSpacer='<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.($border?$colspacing-6:$colspacing).'" height="'.($imageRowsMaxHeights[$c]+($border?$borderThickness*2:0)).'" border="0" align="'.($border?'left':'top').'" alt="" />';
1007 $colSpacer='<td valign="top">'.$colSpacer.'</td>'; // added 160301, needed for the new "noCols"-table...
1008 $tablecode.=$colSpacer;
1009 }
1010 }
1011 if (!$noCols || ($noCols && !$b)) {
1012 $tablecode.='<td valign="top">'; // starting the cell. If "noCols" this cell will hold all images in the row, otherwise only a single image.
1013 if ($noCols) {$tablecode.='<table width="'.$imageRowsFinalWidths[$c].'" border="0" cellpadding="0" cellspacing="0"><tr>';} // In case of "noCols" we must set the table-tag that surrounds the images in the row.
1014 }
1015 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.
1016 $imgIndex = $index+$a*$colCount_temp;
1017 if ($imgsTag[$imgIndex]) {
1018 if ($rowspacing && $noRows && $a) { // Puts distance between the images IF "noRows" is set and this is the first iteration of the loop
1019 $tablecode.= '<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$rowspacing.'" alt="" /><br />';
1020 }
1021
1022 $imageHTML = $imgsTag[$imgIndex].'<br />';
1023 $Talign = (!trim($captionArray[$imgIndex]) && !$noRows && !$conf['netprintApplicationLink']) ? ' align="left"' : ''; // this is necessary if the tablerows are supposed to space properly together! "noRows" is excluded because else the images "layer" together.
1024 if ($border) {$imageHTML='<table border="0" cellpadding="'.$borderThickness.'" cellspacing="0" bgcolor="'.$borderColor.'"'.$Talign.'><tr><td>'.$imageHTML.'</td></tr></table>';} // break-tag added 160301 , ($noRows?'':' align="left"') removed 160301, break tag removed 160301 (later...)
1025 $imageHTML.=$editIconsHTML; $editIconsHTML='';
1026 if ($conf['netprintApplicationLink']) {$imageHTML = $this->netprintApplication_offsiteLinkWrap($imageHTML,$origImages[$imgIndex],$conf['netprintApplicationLink.']);}
1027 $imageHTML.=$captionArray[$imgIndex]; // Adds caption.
1028 if ($noCols) {$imageHTML='<td valign="top">'.$imageHTML.'</td>';} // If noCols, put in table cell.
1029 $tablecode.=$imageHTML;
1030 }
1031 }
1032 $index++;
1033 if (!$noCols || ($noCols && $b+1==$colCount_temp)) {
1034 if ($noCols) {$tablecode.='</tr></table>';} // In case of "noCols" we must finish the table that surrounds the images in the row.
1035 $tablecode.='</td>'; // Ending the cell. In case of "noCols" the cell holds all pictures!
1036 }
1037 }
1038 $tablecode.='</tr>'; // ending row
1039 }
1040 if ($c) {
1041 // Table-tag is inserted
1042 $i=$contentPosition;
1043 $table_align = (($i==16) ? 'align="'.$align.'"' : '');
1044 $tablecode = '<table'.($tableWidth?' width="'.$tableWidth.'"':'').' border="0" cellspacing="0" cellpadding="0" '.$table_align.'>'.$tablecode;
1045 if ($editIconsHTML) { // IF this value is not long since reset.
1046 $tablecode.='<tr><td colspan="'.$colspan.'">'.$editIconsHTML.'</td></tr>';
1047 $editIconsHTML='';
1048 }
1049 if ($cap) {
1050 $tablecode.='<tr><td colspan="'.$colspan.'" align="'.$caption_align.'">'.$caption.'</td></tr>';
1051 }
1052 $tablecode.='</table>';
1053 if ($conf['tableStdWrap.']) {$tablecode=$this->stdWrap($tablecode,$conf['tableStdWrap.']);}
1054 }
1055
1056 $spaceBelowAbove = intval($this->stdWrap($conf['spaceBelowAbove'],$conf['spaceBelowAbove.']));
1057 switch ($contentPosition) {
1058 case '0': // above
1059 $output= '<div align="'.$align.'">'.$tablecode.'</div>'.$this->wrapSpace($content, $spaceBelowAbove.'|0');
1060 break;
1061 case '8': // below
1062 $output= $this->wrapSpace($content, '0|'.$spaceBelowAbove).'<div align="'.$align.'">'.$tablecode.'</div>';
1063 break;
1064 case '16': // in text
1065 $output= $tablecode.$content;
1066 break;
1067 case '24': // in text, no wrap
1068 $theResult = '';
1069 $theResult.= '<table border="0" cellspacing="0" cellpadding="0"><tr>';
1070 if ($align=='right') {
1071 $theResult.= '<td valign="top">'.$content.'</td><td valign="top">'.$tablecode.'</td>';
1072 } else {
1073 $theResult.= '<td valign="top">'.$tablecode.'</td><td valign="top">'.$content.'</td>';
1074 }
1075 $theResult.= '</tr></table>';
1076 $output= $theResult;
1077 break;
1078 }
1079 } else {
1080 $output= $content;
1081 }
1082 return $output;
1083 }
1084
1085 /**
1086 * Rendering the cObject, CONTENT
1087 *
1088 * @param array Array of TypoScript properties
1089 * @return string Output
1090 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=356&cHash=9f3b5c6ba2
1091 */
1092 function CONTENT($conf) {
1093 $theValue='';
1094
1095 $originalRec=$GLOBALS['TSFE']->currentRecord;
1096 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!!
1097 $GLOBALS['TSFE']->recordRegister[md5($originalRec)]++;
1098 }
1099
1100 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_') {
1101
1102 $renderObjName = $conf['renderObj'] ? $conf['renderObj'] : '<'.$conf['table'];
1103 $renderObjKey = $conf['renderObj'] ? 'renderObj' : '';
1104 $renderObjConf = $conf['renderObj.'];
1105
1106 $query = $this->getQuery($conf['table'],$conf['select.']);
1107 $res = @mysql(TYPO3_db,$query);
1108 if ($error = mysql_error()) {
1109 $GLOBALS['TT']->setTSlogMessage($error.': '.$query,3);
1110 } else {
1111 $this->currentRecordTotal = mysql_num_rows($res);
1112 $GLOBALS['TT']->setTSlogMessage($query);
1113 $GLOBALS['TT']->setTSlogMessage('NUMROWS: '.mysql_num_rows($res));
1114 $cObj =t3lib_div::makeInstance('tslib_cObj');
1115 $cObj->setParent($this->data,$this->currentRecord);
1116 $this->currentRecordNumber=0;
1117 while ($row = mysql_fetch_assoc($res)) {
1118 if (!$GLOBALS['TSFE']->recordRegister[md5($val['table'].':'.$val['id'])]) {
1119 $this->currentRecordNumber++;
1120 $cObj->parentRecordNumber=$this->currentRecordNumber;
1121 $GLOBALS['TSFE']->currentRecord=$conf['table'].':'.$row['uid'];
1122 $this->lastChanged($row['tstamp']);
1123 $cObj->start($row,$conf['table']);
1124 if ($GLOBALS['TSFE']->config['config']['insertDmailerBoundaries']) {$theValue.='<!--DMAILER_SECTION_BOUNDARY_'.intval($row['module_sys_dmail_category']).'-->';}
1125 $theValue.=$cObj->cObjGetSingle($renderObjName, $renderObjConf, $renderObjKey);
1126 } else {debug($val['table'].':'.$val['id']);}
1127 }
1128 if ($GLOBALS['TSFE']->config['config']['insertDmailerBoundaries']) {$theValue.='<!--DMAILER_SECTION_BOUNDARY_END-->';}
1129 }
1130 }
1131
1132 $theValue = $this->wrap($theValue,$conf['wrap']);
1133 if ($conf['stdWrap.']) $theValue = $this->stdWrap($theValue,$conf['stdWrap.']);
1134 $GLOBALS['TSFE']->currentRecord=$originalRec;
1135 return $theValue;
1136 }
1137
1138 /**
1139 * Rendering the cObject, RECORDS
1140 *
1141 * @param array Array of TypoScript properties
1142 * @return string Output
1143 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=357&cHash=303e959472
1144 */
1145 function RECORDS($conf) {
1146 $theValue='';
1147
1148 $originalRec=$GLOBALS['TSFE']->currentRecord;
1149 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!!
1150 $GLOBALS['TSFE']->recordRegister[md5($originalRec)]++;
1151 }
1152
1153 $conf['source'] = $this->stdWrap($conf['source'],$conf['source.']);
1154 if ($conf['tables'] && $conf['source']) {
1155 $allowedTables = $conf['tables'];
1156 if (is_array($conf['conf.'])) {
1157 reset($conf['conf.']);
1158 while(list($k)=each($conf['conf.'])) {
1159 if (substr($k,-1)!='.') $allowedTables.=','.$k;
1160 }
1161 }
1162
1163 $loadDB = t3lib_div::makeInstance('FE_loadDBGroup');
1164 $loadDB->start($conf['source'], $allowedTables);
1165 reset($loadDB->tableArray);
1166 while(list($table,)=each($loadDB->tableArray)) {
1167 if (is_array($GLOBALS['TCA'][$table])) {
1168 $loadDB->additionalWhere[$table]=$this->enableFields($table);
1169 }
1170 }
1171 $loadDB->getFromDB();
1172
1173 reset($loadDB->itemArray);
1174 $data = $loadDB->results;
1175
1176 $cObj =t3lib_div::makeInstance('tslib_cObj');
1177 $cObj->setParent($this->data,$this->currentRecord);
1178 $this->currentRecordNumber=0;
1179 $this->currentRecordTotal = count($loadDB->itemArray);
1180 reset($loadDB->itemArray);
1181 while(list(,$val)=each($loadDB->itemArray)) {
1182 $row = $data[$val['table']][$val['id']];
1183 if (!$conf['dontCheckPid']) {
1184 $row = $this->checkPid($row['pid']) ? $row : '';
1185 }
1186 if ($row && !$GLOBALS['TSFE']->recordRegister[md5($val['table'].':'.$val['id'])]) {
1187 $renderObjName = $conf['conf.'][$val['table']] ? $conf['conf.'][$val['table']] : '<'.$val['table'];
1188 $renderObjKey = $conf['conf.'][$val['table']] ? 'conf.'.$val['table'] : '';
1189 $renderObjConf = $conf['conf.'][$val['table'].'.'];
1190 $this->currentRecordNumber++;
1191 $GLOBALS['TSFE']->currentRecord=$val['table'].':'.$val['id'];
1192 $this->lastChanged($row['tstamp']);
1193 $cObj->start($row,$val['table']);
1194 if ($GLOBALS['TSFE']->config['config']['insertDmailerBoundaries']) {$theValue.='<!--DMAILER_SECTION_BOUNDARY_'.intval($row['module_sys_dmail_category']).'-->';}
1195 $theValue.=$cObj->cObjGetSingle($renderObjName, $renderObjConf, $renderObjKey);
1196 if ($GLOBALS['TSFE']->config['config']['insertDmailerBoundaries']) {$theValue.='<!--DMAILER_SECTION_BOUNDARY_END-->';}
1197 }
1198 }
1199 }
1200 $GLOBALS['TSFE']->currentRecord=$originalRec;
1201 return $this->wrap($theValue,$conf['wrap']);
1202 }
1203
1204 /**
1205 * Rendering the cObject, HMENU
1206 *
1207 * @param array Array of TypoScript properties
1208 * @return string Output
1209 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=358&cHash=5400c1c06a
1210 */
1211 function HMENU($conf) {
1212 $content='';
1213 if ($this->checkIf($conf['if.'])) {
1214 $cls=strtolower($conf[1]);
1215 if (t3lib_div::inList($GLOBALS['TSFE']->tmpl->menuclasses,$cls)) {
1216 if ($conf['special.']['value.']) {
1217 $conf['special.']['value'] = $this->stdWrap($conf['special.']['value'],$conf['special.']['value.']);
1218 }
1219 $GLOBALS['TSFE']->register['count_HMENU']++;
1220 $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ']=0;
1221 $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid']=array();
1222 $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMparentId']=array();
1223
1224 $menu = t3lib_div::makeInstance('tslib_'.$cls);
1225 $menu->parent_cObj = $this;
1226 $menu->start($GLOBALS['TSFE']->tmpl,$GLOBALS['TSFE']->sys_page,'',$conf,1);
1227 $menu->makeMenu();
1228 $content.=$menu->writeMenu();
1229 }
1230 if ($conf['wrap']) $content=$this->wrap($content, $conf['wrap']);
1231 if ($conf['stdWrap.']) $content = $this->stdWrap($content, $conf['stdWrap.']);
1232 }
1233 return $content;
1234 }
1235
1236 /**
1237 * Rendering the cObject, CTABLE
1238 *
1239 * @param array Array of TypoScript properties
1240 * @return string Output
1241 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=359&cHash=2e0065b4e7
1242 */
1243 function CTABLE ($conf) {
1244 $controlTable = t3lib_div::makeInstance('tslib_controlTable');
1245 if ($conf['tableParams']) {
1246 $controlTable->tableParams = $conf['tableParams'];
1247 }
1248 // loads the pagecontent
1249 $controlTable->contentW = $conf['cWidth'];
1250 // loads the menues if any
1251 if (is_array($conf['c.'])) {
1252 $controlTable->content = $this->cObjGet($conf['c.'],'c.');
1253 $controlTable->contentTDparams = isset($conf['c.']['TDParams']) ? $conf['c.']['TDParams'] : 'valign="top"';
1254 }
1255 if (is_array($conf['lm.'])) {
1256 $controlTable->lm = $this->cObjGet($conf['lm.'],'lm.');
1257 $controlTable->lmTDparams = isset($conf['lm.']['TDParams']) ? $conf['lm.']['TDParams'] : 'valign="top"';
1258 }
1259 if (is_array($conf['tm.'])) {
1260 $controlTable->tm = $this->cObjGet($conf['tm.'],'tm.');
1261 $controlTable->tmTDparams = isset($conf['tm.']['TDParams']) ? $conf['tm.']['TDParams'] : 'valign="top"';
1262 }
1263 if (is_array($conf['rm.'])) {
1264 $controlTable->rm = $this->cObjGet($conf['rm.'],'rm.');
1265 $controlTable->rmTDparams = isset($conf['rm.']['TDParams']) ? $conf['rm.']['TDParams'] : 'valign="top"';
1266 }
1267 if (is_array($conf['bm.'])) {
1268 $controlTable->bm = $this->cObjGet($conf['bm.'],'bm.');
1269 $controlTable->bmTDparams = isset($conf['bm.']['TDParams']) ? $conf['bm.']['TDParams'] : 'valign="top"';
1270 }
1271 return $controlTable->start($conf['offset'],$conf['cMargins']);
1272 }
1273
1274 /**
1275 * Rendering the cObject, OTABLE
1276 *
1277 * @param array Array of TypoScript properties
1278 * @return string Output
1279 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=360&cHash=02c9552d38
1280 */
1281 function OTABLE ($conf) {
1282 $controlTable = t3lib_div::makeInstance('tslib_tableOffset');
1283 if ($conf['tableParams']) {
1284 $controlTable->tableParams = $conf['tableParams'];
1285 }
1286 return $controlTable->start($this->cObjGet($conf),$conf['offset']);
1287 }
1288
1289 /**
1290 * Rendering the cObject, COLUMNS
1291 *
1292 * @param array Array of TypoScript properties
1293 * @return string Output
1294 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=361&cHash=7e4e228cad
1295 */
1296 function COLUMNS ($conf) {
1297 $content='';
1298 if (is_array($conf) && $this->checkIf($conf['if.'])) {
1299 $tdRowCount=0;
1300 $tableParams = $conf['tableParams'] ? ' '.$conf['tableParams'] : ' border="0" cellspacing="0" cellpadding="0"';
1301 $TDparams = $conf['TDparams'] ? ' '.$conf['TDparams']:' valign="top"';
1302 $rows = t3lib_div::intInRange($conf['rows'],2,20);
1303 $totalWidth = intval($conf['totalWidth']);
1304 $columnWidth=0;
1305
1306 $totalGapWidth=0;
1307 $gapData = Array(
1308 'gapWidth' => $this->stdWrap($conf['gapWidth'],$conf['gapWidth.']),
1309 'gapBgCol' => $this->stdWrap($conf['gapBgCol'],$conf['gapBgCol.']),
1310 'gapLineThickness' => $this->stdWrap($conf['gapLineThickness'],$conf['gapLineThickness.']),
1311 'gapLineCol' => $this->stdWrap($conf['gapLineCol'],$conf['gapLineCol.'])
1312 );
1313 $gapData = $GLOBALS['TSFE']->tmpl->splitConfArray($gapData,$rows-1);
1314 reset($gapData);
1315 while(list(,$val)=each($gapData)) {
1316 $totalGapWidth+=intval($val['gapWidth']);
1317 }
1318
1319 if ($totalWidth) {
1320 $columnWidth = ceil(($totalWidth-$totalGapWidth)/$rows);
1321 $TDparams.=' width="'.$columnWidth.'"';
1322 $tableParams.=' width="'.$totalWidth.'"';
1323 } else {
1324 $TDparams.=' width="'.floor(100/$rows).'%"';
1325 $tableParams.=' width="100%"';
1326 }
1327
1328 for ($a=1;$a<=$rows;$a++) {
1329 $tdRowCount++;
1330 $content.='<td'.$TDparams.'>';
1331 $content.=$this->cObjGetSingle($conf[$a],$conf[$a.'.'], $a);
1332 $content.='</td>';
1333 if ($a < $rows) {
1334 $gapConf = $gapData[($a-1)];
1335 $gapWidth = intval($gapConf['gapWidth']);
1336 if ($gapWidth) {
1337 $tdPar = $gapConf['gapBgCol'] ? ' bgcolor="'.$gapConf['gapBgCol'].'"' : '';
1338 $gapLine = intval($gapConf['gapLineThickness']);
1339 if ($gapLine) {
1340 $gapSurround = t3lib_div::intInRange(($gapWidth-$gapLine)/2, 1, 1000);
1341 // right gap
1342 $content.='<td'.$tdPar.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$gapSurround.'" height="1" alt="" /></td>';
1343 $tdRowCount++;
1344 // line:
1345 $GtdPar = $gapConf['gapLineCol'] ? ' bgcolor="'.$gapConf['gapLineCol'].'"' : ' bgcolor="black"';
1346 $content.='<td'.$GtdPar.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$gapLine.'" height="1" alt="" /></td>';
1347 $tdRowCount++;
1348 // left gap
1349 $content.='<td'.$tdPar.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$gapSurround.'" height="1" alt="" /></td>';
1350 $tdRowCount++;
1351 } else {
1352 $content.='<td'.$tdPar.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$gapWidth.'" height="1" alt="" /></td>';
1353 $tdRowCount++;
1354 }
1355 }
1356 }
1357 }
1358 $content='<tr>'.$content.'</tr>';
1359 $content='<table'.$tableParams.'>'.$content.'</table>';
1360 $content.=$this->cObjGetSingle($conf['after'],$conf['after.'], 'after');
1361 if ($conf['stdWrap.']) {
1362 $content = $this->stdWrap($content,$conf['stdWrap.']);
1363 }
1364 }
1365 return $content;
1366 }
1367
1368 /**
1369 * Rendering the cObject, HRULER
1370 *
1371 * @param array Array of TypoScript properties
1372 * @return string Output
1373 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=362&cHash=2a462aa084
1374 */
1375 function HRULER ($conf) {
1376 $lineThickness = t3lib_div::intInRange($this->stdWrap($conf['lineThickness'],$conf['lineThickness.']),1,50);
1377 $lineColor = $conf['lineColor'] ? $conf['lineColor'] : 'black';
1378 $spaceBefore = intval($conf['spaceLeft']);
1379 $spaceAfter = intval($conf['spaceRight']);
1380 $content='';
1381
1382 $content.='<table border="0" cellspacing="0" cellpadding="0" width="99%"><tr>';
1383 if ($spaceBefore) {$content.='<td width="1"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$spaceBefore.'" height="1" alt="" /></td>'; }
1384 $content.='<td bgcolor="'.$lineColor.'"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$lineThickness.'" alt="" /></td>';
1385 if ($spaceAfter) {$content.='<td width="1"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$spaceAfter.'" height="1" alt="" /></td>'; }
1386 $content.='</tr></table>';
1387
1388 $content = $this->stdWrap($content, $conf['stdWrap.']);
1389 return $content;
1390 }
1391
1392 /**
1393 * Rendering the cObject, CASE
1394 *
1395 * @param array Array of TypoScript properties
1396 * @return string Output
1397 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=364&cHash=cffedd09e3
1398 */
1399 function CASEFUNC ($conf){
1400 $content='';
1401 if ($this->checkIf($conf['if.'])) {
1402 if ($conf['setCurrent'] || $conf['setCurrent.']){$this->data[$this->currentValKey] = $this->stdWrap($conf['setCurrent'], $conf['setCurrent.']);}
1403 $key = $this->stdWrap($conf['key'],$conf['key.']);
1404 $key = $conf[$key] ? $key : 'default';
1405 $name = $conf[$key];
1406 $theValue = $this->cObjGetSingle($name,$conf[$key.'.'], $key);
1407 if ($conf['stdWrap.']) {
1408 $theValue = $this->stdWrap($theValue,$conf['stdWrap.']);
1409 }
1410 return $theValue;
1411 }
1412 }
1413
1414 /**
1415 * Rendering the cObject, LOAD_REGISTER and RESTORE_REGISTER
1416 * NOTICE: This cObject does NOT return any content since it just sets internal data based on the TypoScript properties.
1417 *
1418 * @param array Array of TypoScript properties
1419 * @param string If "RESTORE_REGISTER" then the cObject rendered is "RESTORE_REGISTER", otherwise "LOAD_REGISTER"
1420 * @return string Empty string (the cObject only sets internal data!)
1421 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=365&cHash=4935524e2e
1422 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=366&cHash=4f9485e8cc
1423 */
1424 function LOAD_REGISTER($conf,$name) {
1425 if ($name=='RESTORE_REGISTER') {
1426 $GLOBALS['TSFE']->register = array_pop($GLOBALS['TSFE']->registerStack);
1427 } else {
1428 array_push($GLOBALS['TSFE']->registerStack,$GLOBALS['TSFE']->register);
1429 if (is_array($conf)) {
1430 reset($conf);
1431 while(list($theKey,$theValue)=each($conf)) {
1432 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
1433 if (strstr($theKey,'.')) {
1434 $theKey = substr($theKey,0,-1);
1435 }
1436 $GLOBALS['TSFE']->register[$theKey] = $this->stdWrap($conf[$theKey],$conf[$theKey.'.']);
1437 }
1438 }
1439 }
1440 }
1441 return '';
1442 }
1443
1444 /**
1445 * Rendering the cObject, FORM
1446 *
1447 * Note on $formData:
1448 * In the optional $formData array each entry represents a line in the ordinary setup.
1449 * In those entries each entry (0,1,2...) represents a space normally divided by the '|' line.
1450 *
1451 * $formData [] = array('Name:', 'name=input, 25 ', 'Default value....');
1452 * $formData [] = array('Email:', 'email=input, 25 ', 'Default value for email....');
1453 *
1454 * - corresponds to the $conf['data'] value being :
1455 * Name:|name=input, 25 |Default value....||Email:|email=input, 25 |Default value for email....
1456 *
1457 * If $formData is an array the value of $conf['data'] is ignored.
1458 *
1459 * @param array Array of TypoScript properties
1460 * @param array Alternative formdata overriding whatever comes from TypoScript
1461 * @return string Output
1462 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=367&cHash=bbc518d930
1463 */
1464 function FORM($conf,$formData='') {
1465 $content='';
1466 if (is_array($formData)) {
1467 $dataArr = $formData;
1468 } else {
1469 $data=$this->stdWrap($conf['data'],$conf['data.']);
1470 // Clearing dataArr
1471 $dataArr=array();
1472 // Getting the original config
1473 if (trim($data)) {
1474 $data = ereg_replace(chr(10),'||',$data);
1475 $dataArr = explode('||',$data);
1476 }
1477 // Adding the new dataArray config form:
1478 if (is_array($conf['dataArray.'])) { // dataArray is supplied
1479 reset($conf['dataArray.']);
1480 while(list($dAKey,$dAA)=each($conf['dataArray.'])) {
1481 if (is_array($dAA) && !strcmp(intval($dAKey).'.',$dAKey)) {
1482 $temp=array();
1483 list($temp[0])= explode('|',$dAA['label.'] ? $this->stdWrap($dAA['label'],$dAA['label.']) : $dAA['label']);
1484 list($temp[1])= explode('|',$dAA['type']);
1485 if ($dAA['required']) {$temp[1]='*'.$temp[1];}
1486 list($temp[2])= explode('|',$dAA['value.'] ? $this->stdWrap($dAA['value'],$dAA['value.']) : $dAA['value']);
1487 // If value Array is set, then implode those values.
1488 if (is_array($dAA['valueArray.'])) {
1489 reset($dAA['valueArray.']);
1490 $temp_accum = array();
1491 while(list($dAKey_vA,$dAA_vA)=each($dAA['valueArray.'])) {
1492 if (is_array($dAA_vA) && !strcmp(intval($dAKey_vA).'.',$dAKey_vA)) {
1493 $temp_vA=array();
1494 list($temp_vA[0])= explode('=',$dAA_vA['label.'] ? $this->stdWrap($dAA_vA['label'],$dAA_vA['label.']) : $dAA_vA['label']);
1495 if ($dAA_vA['selected']) {$temp_vA[0]='*'.$temp_vA[0];}
1496 list($temp_vA[1])= explode(',',$dAA_vA['value']);
1497 }
1498 $temp_accum[] = implode('=',$temp_vA);
1499 }
1500 $temp[2] = implode(',',$temp_accum);
1501 }
1502 // adding the form entry to the dataArray
1503 $dataArr[] = implode('|',$temp);
1504 }
1505 }
1506 }
1507 }
1508 $attachmentCounter='';
1509 $hiddenfields='';
1510 $fieldlist=Array();
1511 $propertyOverride = Array();
1512 $fieldname_hashArray = Array();
1513 $cc=0;
1514 reset($dataArr);
1515 while(list(,$val)=each($dataArr)) {
1516 $cc++;
1517 $confData=Array();
1518 if (is_array($formData)) {
1519 $parts = $val;
1520 $val=1; // true...
1521 } else {
1522 $val=trim($val);
1523 $parts = explode('|',$val);
1524 }
1525 if ($val && strcspn($val,'#/')) {
1526 // label:
1527 $confData['label'] = trim($parts[0]);
1528 // field:
1529 $fParts = explode(',',$parts[1]);
1530 $fParts[0]=trim($fParts[0]);
1531 if (substr($fParts[0],0,1)=='*') {
1532 $confData['required']=1;
1533 $fParts[0] = substr($fParts[0],1);
1534 }
1535 $typeParts = explode('=',$fParts[0]);
1536 $confData['type'] = trim(strtolower(end($typeParts)));
1537 if (count($typeParts)==1) {
1538 $confData['fieldname'] = substr(ereg_replace('[^a-zA-Z0-9_]','',str_replace(' ','_',trim($parts[0]))),0,30);
1539 if (strtolower(ereg_replace('[^[:alnum:]]','',$confData['fieldname']))=='email') {$confData['fieldname']='email';}
1540 // Duplicate fieldnames resolved
1541 if (isset($fieldname_hashArray[md5($confData['fieldname'])])) {
1542 $confData['fieldname'].='_'.$cc;
1543 }
1544 $fieldname_hashArray[md5($confData['fieldname'])]=$confData['fieldname'];
1545 // Attachment names...
1546 if ($confData['type']=='file') {
1547 $confData['fieldname']='attachment'.$attachmentCounter;
1548 $attachmentCounter=intval($attachmentCounter)+1;
1549 }
1550 } else {
1551 $confData['fieldname'] = str_replace(' ','_',trim($typeParts[0]));
1552 }
1553 $fieldCode='';
1554
1555
1556 if ($conf['wrapFieldName']) {
1557 $confData['fieldname'] = $this->wrap($confData['fieldname'],$conf['wrapFieldName']);
1558 }
1559
1560 // Additional parameters
1561 if (trim($confData['type'])) {
1562 $addParams=trim($conf['params']);
1563 if (is_array($conf['params.']) && isset($conf['params.'][$confData['type']])) {
1564 $addParams=trim($conf['params.'][$confData['type']]);
1565 }
1566 if (strcmp('',$addParams)) $addParams=' '.$addParams;
1567 } else $addParams='';
1568
1569 switch($confData['type']) {
1570 case'textarea':
1571 $cols=trim($fParts[1]) ? intval($fParts[1]) : 20;
1572 $compWidth = doubleval($conf['compensateFieldWidth'] ? $conf['compensateFieldWidth'] : $GLOBALS['TSFE']->compensateFieldWidth);
1573 $compWidth = $compWidth ? $compWidth : 1;
1574 $cols = t3lib_div::intInRange($cols*$compWidth, 1, 120);
1575
1576 $rows=trim($fParts[2]) ? t3lib_div::intInRange($fParts[2],1,30) : 5;
1577 $wrap=trim($fParts[3]) ? ' wrap="'.trim($fParts[3]).'"' : ' wrap="virtual"';
1578 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], trim($parts[2]));
1579 $fieldCode=sprintf('<textarea name="%s" cols="%s" rows="%s"%s'.$addParams.'>%s</textarea>',
1580 $confData['fieldname'], $cols, $rows, $wrap, t3lib_div::formatForTextarea($default));
1581 break;
1582 case'input':
1583 case'password':
1584 $size=trim($fParts[1]) ? intval($fParts[1]) : 20;
1585 $compWidth = doubleval($conf['compensateFieldWidth'] ? $conf['compensateFieldWidth'] : $GLOBALS['TSFE']->compensateFieldWidth);
1586 $compWidth = $compWidth ? $compWidth : 1;
1587 $size = t3lib_div::intInRange($size*$compWidth, 1, 120);
1588 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], trim($parts[2]));
1589 if ($confData['type']=='password') {
1590 $default='';
1591 }
1592
1593 $max=trim($fParts[2]) ? ' maxlength="'.t3lib_div::intInRange($fParts[2],1,1000).'"' : "";
1594 $theType = $confData['type']=='input' ? 'text' : 'password';
1595
1596 $fieldCode=sprintf('<input type="'.$theType.'" name="%s" size="%s"%s value="%s"'.$addParams.' />',
1597 $confData['fieldname'], $size, $max, htmlspecialchars($default));
1598 break;
1599 case'file':
1600 $size=trim($fParts[1]) ? t3lib_div::intInRange($fParts[1],1,60) : 20;
1601 $fieldCode=sprintf('<input type="file" name="%s" size="%s"'.$addParams.' />',
1602 $confData['fieldname'], $size);
1603 break;
1604 case'check':
1605 // alternative default value:
1606 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], trim($parts[2]));
1607 $checked = $default ? ' checked="checked"' : '';
1608 $fieldCode=sprintf('<input type="checkbox" value="%s" name="%s"%s'.$addParams.' />',
1609 1, $confData['fieldname'], $checked);
1610 break;
1611 case'select':
1612 $option='';
1613 $valueParts = explode(',',$parts[2]);
1614 // size
1615 if (strtolower(trim($fParts[1]))=='auto') {$fParts[1]=count($valueParts);} // Auto size set here. Max 20
1616 $size=trim($fParts[1]) ? t3lib_div::intInRange($fParts[1],1,20) : 1;
1617 // multiple
1618 $multiple = strtolower(trim($fParts[2]))=='m' ? ' multiple="multiple"' : '';
1619
1620 $items=array(); // Where the items will be
1621 $defaults=array(); //RTF
1622 for($a=0;$a<count($valueParts);$a++) {
1623 $valueParts[$a]=trim($valueParts[$a]);
1624 if (substr($valueParts[$a],0,1)=='*') { // Finding default value
1625 $sel='selected';
1626 $valueParts[$a] = substr($valueParts[$a],1);
1627 } else $sel='';
1628 // Get value/label
1629 $subParts=explode('=',$valueParts[$a]);
1630 $subParts[1] = (isset($subParts[1])?trim($subParts[1]):trim($subParts[0])); // Sets the value
1631 $items[] = $subParts; // Adds the value/label pair to the items-array
1632 if ($sel) {$defaults[]=$subParts[1];} // Sets the default value if value/label pair is marked as default.
1633 }
1634 // alternative default value:
1635 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], $defaults);
1636 if (!is_array($default)) {
1637 $defaults=array();
1638 $defaults[] = $default;
1639 } else $defaults=$default;
1640 // Create the select-box:
1641 for($a=0;$a<count($items);$a++) {
1642 $option.='<option value="'.$items[$a][1].'"'.(in_array($items[$a][1],$defaults)?' selected="selected"':'').'>'.trim($items[$a][0]).'</option>'; //RTF
1643 }
1644
1645 if ($multiple) $confData['fieldname'].='[]'; // 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.
1646 $fieldCode=sprintf('<select name="%s" size="%s"%s'.$addParams.'>%s</select>',
1647 $confData['fieldname'], $size, $multiple, $option); //RTF
1648 break;
1649 case'radio':
1650 $option='';
1651 $valueParts = explode(',',$parts[2]);
1652 $items=array(); // Where the items will be
1653 $default='';
1654 for($a=0;$a<count($valueParts);$a++) {
1655 $valueParts[$a]=trim($valueParts[$a]);
1656 if (substr($valueParts[$a],0,1)=='*') {
1657 $sel='checked';
1658 $valueParts[$a] = substr($valueParts[$a],1);
1659 } else $sel='';
1660 // Get value/label
1661 $subParts=explode('=',$valueParts[$a]);
1662 $subParts[1] = (isset($subParts[1])?trim($subParts[1]):trim($subParts[0])); // Sets the value
1663 $items[] = $subParts; // Adds the value/label pair to the items-array
1664 if ($sel) {$default=$subParts[1];} // Sets the default value if value/label pair is marked as default.
1665 }
1666 // alternative default value:
1667 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], $default);
1668 // Create the select-box:
1669 for($a=0;$a<count($items);$a++) {
1670 $option.= '<input type="radio" name="'.$confData['fieldname'].'" value="'.$items[$a][1].'"'.(!strcmp($items[$a][1],$default)?' checked="checked"':'').''.$addParams.' />';
1671 $option.= $this->stdWrap(trim($items[$a][0]), $conf['radioWrap.']);
1672 $option.= '<br />';
1673 }
1674 $fieldCode=$option;
1675 break;
1676 case 'hidden':
1677 $value=trim($parts[2]);
1678 $hiddenfields.=sprintf('<input type="hidden" name="%s" value="%s" />',
1679 $confData['fieldname'], $value);
1680 break;
1681 case 'property':
1682 if (t3lib_div::inList('type,locationData,goodMess,badMess',$confData['fieldname'])) {
1683 $value=trim($parts[2]);
1684 $propertyOverride[$confData['fieldname']] = $value;
1685 $conf[$confData['fieldname']] = $value;
1686 }
1687 break;
1688 case 'submit':
1689 $value=trim($parts[2]);
1690 if ($conf['image.']) {
1691 $this->data[$this->currentValKey]=$value;
1692 $image=$this->IMAGE($conf['image.']);
1693 } else $image='';
1694 if($image) {
1695 $fieldCode = str_replace('<img','<input type="image"'.$addParams.' name="'.$confData['fieldname'].'"' ,$image);
1696 } else {
1697 $fieldCode=sprintf('<input type="submit" name="%s" value="%s"'.$addParams.'>',
1698 $confData['fieldname'], htmlspecialchars($value));
1699 }
1700 break;
1701 default:
1702 $confData['type']='comment';
1703 $fieldCode=trim($parts[2]).'&nbsp;';
1704 break;
1705 }
1706 if ($fieldCode) {
1707 $fieldCode = $this->stdWrap($fieldCode, $conf['fieldWrap.']);
1708 $labelCode = $this->stdWrap($confData['label'], $conf['labelWrap.']);
1709 $commentCode = $this->stdWrap($confData['label'], $conf['commentWrap.']); // RTF
1710 $result = $conf['layout'];
1711 if ($conf['REQ'] && $confData['required']) {
1712 if (is_array($conf['REQ.']['fieldWrap.']))
1713 $fieldCode = $this->stdWrap($fieldCode, $conf['REQ.']['fieldWrap.']);
1714 if (is_array($conf['REQ.']['labelWrap.']))
1715 $labelCode = $this->stdWrap($confData['label'], $conf['REQ.']['labelWrap.']);
1716 if ($conf['REQ.']['layout']) {
1717 $result = $conf['REQ.']['layout'];
1718 }
1719 }
1720 if ($confData['type']=='comment' && $conf['COMMENT.']['layout']) {
1721 $result = $conf['COMMENT.']['layout'];
1722 }
1723 if ($confData['type']=='check' && $conf['CHECK.']['layout']) {
1724 $result = $conf['CHECK.']['layout'];
1725 }
1726 if ($confData['type']=='radio' && $conf['RADIO.']['layout']) {
1727 $result = $conf['RADIO.']['layout'];
1728 }
1729 $result = str_replace('###FIELD###',$fieldCode,$result);
1730 $result = str_replace('###LABEL###',$labelCode,$result);
1731 $result = str_replace('###COMMENT###',$commentCode,$result); //RTF
1732 $content.=$result;
1733 // Required:
1734 if ($confData['required'] && $confData['type']!='check') {
1735 $fieldlist[]=rawurlencode($confData['fieldname']);
1736 $fieldlist[]=rawurlencode($confData['label']);
1737 }
1738 }
1739 }
1740 }
1741 if ($conf['stdWrap.']) $content=$this->stdWrap($content, $conf['stdWrap.']);
1742
1743
1744 // redirect (external: where to go afterwards. internal: where to submit to)
1745 $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)
1746 $page=$GLOBALS['TSFE']->page;
1747 if (!$theRedirect) { // Internal: Just submit to current page
1748 $LD=$GLOBALS['TSFE']->tmpl->linkData($page, $conf['target'], $conf['no_cache'],'index.php');
1749 } elseif (t3lib_div::testInt($theRedirect)) { // Internal: Submit to page with id $theRedirect
1750 $page = $GLOBALS['TSFE']->sys_page->getPage_noCheck($theRedirect);
1751 $LD=$GLOBALS['TSFE']->tmpl->linkData($page, $conf['target'], $conf['no_cache'],'index.php');
1752 } else { // External url, redirect-hidden field is rendered!
1753 $LD=$GLOBALS['TSFE']->tmpl->linkData($page, $conf['target'], $conf['no_cache'],'');
1754 $LD['totalURL']=$theRedirect;
1755 $hiddenfields.='<input type="hidden" name="redirect" value="'.htmlspecialchars($LD['totalURL']).'" />'; // 18-09-00 added
1756 }
1757
1758 // Formtype (where to submit to!):
1759 $formtype = $propertyOverride['type'] ? $propertyOverride['type'] : $this->stdWrap($conf['type'], $conf['type.']);
1760 if (t3lib_div::testInt($formtype)) { // Submit to a specific page
1761 $page = $GLOBALS['TSFE']->sys_page->getPage_noCheck($formtype);
1762 $LD_A=$GLOBALS['TSFE']->tmpl->linkData($page,$conf['target'],$conf['no_cache'],'');
1763 $action=$LD_A['totalURL'];
1764 } elseif ($formtype){ // Submit to external script
1765 $LD_A=$LD;
1766 $action = $formtype;
1767 } elseif (t3lib_div::testInt($theRedirect)) {
1768 $LD_A=$LD;
1769 $action=$LD_A['totalURL'];
1770 } else { // Submit to 'nothing' - which is current page
1771 $LD_A=$GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page,$conf['target'],$conf['no_cache'],'');
1772 $action=$LD_A['totalURL'];
1773 }
1774
1775 // copyemail:
1776 $theEmail = $this->stdWrap($conf['recipient'], $conf['recipient.']);
1777 if ($theEmail) {
1778 $hiddenfields.='<input type="hidden" name="recipient" value="'.htmlspecialchars($theEmail).'" />';
1779 }
1780
1781 // location data:
1782 if ($conf['locationData']) {
1783 if ($conf['locationData']=='HTTP_POST_VARS' && isset($GLOBALS['HTTP_POST_VARS']['locationData'])) {
1784 $locationData = $GLOBALS['HTTP_POST_VARS']['locationData'];
1785 } else {
1786 $locationData = $GLOBALS['TSFE']->id.':'.$this->currentRecord; // 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.
1787 }
1788 $hiddenfields.='<input type="hidden" name="locationData" value="'.htmlspecialchars($locationData).'" />';
1789 }
1790
1791 // hidden fields:
1792 if (is_array($conf['hiddenFields.'])) {
1793 reset($conf['hiddenFields.']);
1794 while(list($hF_key,$hF_conf)=each($conf['hiddenFields.'])) {
1795 if (substr($hF_key,-1)!='.') {
1796 $hF_value = $this->cObjGetSingle($hF_conf,$conf['hiddenFields.'][$hF_key.'.'],'hiddenfields');
1797 $hiddenfields.='<input type="hidden" name="'.$hF_key.'" value="'.htmlspecialchars($hF_value).'" />';
1798 }
1799 }
1800 }
1801
1802 // Formname;
1803 $formname = $GLOBALS['TSFE']->uniqueHash();
1804 if ($conf['REQ']) {
1805 $validateForm=' onsubmit="return validateForm(\''.$formname.'\',\''.implode($fieldlist,',').'\',\''.rawurlencode($conf['goodMess']).'\',\''.rawurlencode($conf['badMess']).'\')"';
1806 $GLOBALS['TSFE']->additionalHeaderData['JSFormValidate'] = '<script type="text/javascript" src="'.$GLOBALS['TSFE']->absRefPrefix.'t3lib/jsfunc.validateform.js"></script>';
1807 } else $validateForm='';
1808
1809
1810 $content = Array(
1811 '<form action="'.htmlspecialchars($action).'" name="'.$formname.'" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'" method="'.($conf['method']?$conf['method']:'post').'" target="'.($theRedirect?$LD['target']:$LD_A['target']).'"'.$validateForm.'>',
1812 $hiddenfields.$content,
1813 '</form>'
1814 );
1815 if ($conf['arrayReturnMode']) {
1816 $content['validateForm']=$validateForm;
1817 $content['formname']=$formname;
1818 return $content;
1819 } else {
1820 return implode('',$content);
1821 }
1822 }
1823
1824 /**
1825 * Rendering the cObject, SEARCHRESULT
1826 *
1827 * @param array Array of TypoScript properties
1828 * @return string Output
1829 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=368&cHash=d00731cd7b
1830 */
1831 function SEARCHRESULT($conf) {
1832 if (t3lib_div::GPvar('sword') && t3lib_div::GPvar('scols')) {
1833 $search = t3lib_div::makeInstance('tslib_search');
1834 $search->register_and_explode_search_string(stripSlashes(t3lib_div::GPvar('sword')));
1835 $search->register_tables_and_columns(t3lib_div::GPvar('scols'),$conf['allowedCols']);
1836 // depth
1837 $depth=100;
1838 // the startId is found
1839 $theStartId=0;
1840 if (t3lib_div::testInt(t3lib_div::GPvar('stype'))) {
1841 $temp_theStartId=t3lib_div::GPvar('stype');
1842 $rootLine = $GLOBALS['TSFE']->sys_page->getRootLine($temp_theStartId);
1843 // The page MUST have a rootline with the Level0-page of the current site inside!!
1844 while(list(,$val)=each($rootLine)) {
1845 if($val['uid']==$GLOBALS['TSFE']->tmpl->rootLine[0]['uid']) {
1846 $theStartId=$temp_theStartId;
1847 }
1848 }
1849 } else if (t3lib_div::GPvar('stype')) {
1850 if (substr(t3lib_div::GPvar('stype'),0,1)=='L') {
1851 $pointer = intval(substr(t3lib_div::GPvar('stype'),1));
1852 $theRootLine = $GLOBALS['TSFE']->tmpl->rootLine;
1853 // location Data:
1854 $locDat_arr = explode(':',$GLOBALS['HTTP_POST_VARS']['locationData']);
1855 $pId = intval($locDat_arr[0]);
1856 if ($pId) {
1857 $altRootLine = $GLOBALS['TSFE']->sys_page->getRootLine($pId);
1858 ksort($altRootLine);
1859 if (count($altRootLine)) {
1860 // check if the rootline has the real Level0 in it!!
1861 reset($altRootLine);
1862 $hitRoot=0;
1863 $theNewRoot=array();
1864 while(list(,$val)=each($altRootLine)) {
1865 if($hitRoot || $val['uid']==$GLOBALS['TSFE']->tmpl->rootLine[0]['uid']) {
1866 $hitRoot=1;
1867 $theNewRoot[]=$val;
1868 }
1869 }
1870 if ($hitRoot) {
1871 $theRootLine = $theNewRoot; // Override the real rootline if any thing
1872 }
1873 }
1874 }
1875 $key = $this->getKey($pointer,$theRootLine);
1876 $theStartId = $theRootLine[$key]['uid'];
1877 }
1878 }
1879 if (!$theStartId) {
1880 // If not set, we use current page
1881 $theStartId=$GLOBALS['TSFE']->id;
1882 }
1883 // generate page-tree
1884 $search->pageIdList.=$this->getTreeList($theStartId,$depth);
1885 // debug($search->pageIdList);
1886
1887 $endClause = "pages.uid IN (".$search->pageIdList.$theStartId.") AND pages.doktype in (".$GLOBALS['TYPO3_CONF_VARS']['FE']['content_doktypes'].($conf['addExtUrlsAndShortCuts']?',3,4':'').') AND pages.no_search=0';
1888 #debug($endClause);
1889 $endClause.=$this->enableFields($search->fTable).$this->enableFields('pages');
1890 // build query
1891 $search->build_search_query ($endClause);
1892 #debug($search->query);
1893
1894 // count...
1895 if (t3lib_div::testInt(t3lib_div::GPvar('scount'))) {
1896 $search->res_count=t3lib_div::GPvar('scount');
1897 } else {
1898 $search->count_query();
1899 }
1900 // range
1901 $spointer = intval(t3lib_div::GPvar('spointer'));
1902 if (isset($conf['range'])) {
1903 $theRange = intval($conf['range']);
1904 } else {
1905 $theRange=20;
1906 }
1907 if (!$conf['noOrderBy']) {
1908 $search->query.=' ORDER BY pages.lastUpdated, pages.tstamp';
1909 }
1910 $search->query.=' LIMIT '.$spointer.','.$theRange;
1911 $GLOBALS['TT']->setTSlogMessage('Search query: '.$search->query);
1912
1913 // search...
1914 $search->execute_query();
1915 if (mysql_num_rows($search->result)) {
1916 $GLOBALS['TSFE']->register['SWORD_PARAMS'] = $search->get_searchwords();
1917
1918 $total=$search->res_count;
1919 $rangeLow = t3lib_div::intInRange($spointer+1,1,$total);
1920 $rangeHigh = t3lib_div::intInRange($spointer+$theRange,1,$total);
1921 // prev/next url:
1922 $LD=$GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page,$conf['target'],1,'');
1923 $targetPart = $LD['target'] ? ' target="'.$LD['target'].'"' : '';
1924 $urlParams = $this->URLqMark($LD['totalURL'],
1925 '&sword='.rawurlencode(t3lib_div::GPvar('sword')).
1926 '&scols='.rawurlencode(t3lib_div::GPvar('scols')).
1927 '&stype='.rawurlencode(t3lib_div::GPvar('stype')).
1928 '&scount='.$total);
1929 // substitution:
1930 $result= $this->cObjGetSingle($conf['layout'],$conf['layout.'], 'layout');
1931 $result = str_replace('###RANGELOW###',$rangeLow,$result);
1932 $result = str_replace('###RANGEHIGH###',$rangeHigh,$result);
1933 $result = str_replace('###TOTAL###',$total,$result);
1934
1935 if ($rangeHigh<$total) {
1936 $next = $this->cObjGetSingle($conf['next'], $conf['next.'], 'next');
1937 $next = '<a href="'.htmlspecialchars($urlParams.'&spointer='.($spointer+$theRange)).'"'.$targetPart.$GLOBALS['TSFE']->ATagParams.'>'.$next.'</a>';
1938 } else $next='';
1939 $result = str_replace('###NEXT###',$next,$result);
1940
1941 if ($rangeLow>1) {
1942 $prev = $this->cObjGetSingle($conf['prev'], $conf['prev.'], 'prev');
1943 $prev = '<a href="'.htmlspecialchars($urlParams.'&spointer='.($spointer-$theRange)).'"'.$targetPart.$GLOBALS['TSFE']->ATagParams.'>'.$prev.'</a>';
1944 } else $prev='';
1945 $result = str_replace('###PREV###',$prev,$result);
1946
1947 // searching result
1948 $theValue = $this->cObjGetSingle($conf['resultObj'], $conf['resultObj.'],'resultObj');
1949 $cObj =t3lib_div::makeInstance('tslib_cObj');
1950 $cObj->setParent($this->data,$this->currentRecord);
1951 $renderCode='';
1952 while ($row = mysql_fetch_assoc($search->result)) {
1953 $cObj->start($row);
1954 $renderCode.=$cObj->cObjGetSingle($conf['renderObj'], $conf['renderObj.'],'renderObj');
1955 }
1956 $theValue.=$this->wrap($renderCode,$conf['renderWrap']);
1957 $theValue = str_replace('###RESULT###',$theValue,$result);
1958 } else {
1959 $theValue = $this->cObjGetSingle($conf['noResultObj'], $conf['noResultObj.'],'noResultObj');
1960 }
1961
1962 $GLOBALS['TT']->setTSlogMessage('Search in fields: '.$search->listOfSearchFields);
1963
1964 // wrapping
1965 $content=$theValue;
1966 if ($conf['wrap']) {
1967 $content=$this->wrap($content, $conf['wrap']);
1968 }
1969 if ($conf['stdWrap.']) {
1970 $content=$this->stdWrap($content, $conf['stdWrap.']);
1971 }
1972 // returning
1973 $GLOBALS['TSFE']->set_no_cache();
1974 return $content;
1975 }
1976 }
1977
1978 /**
1979 * Rendering the cObject, PHP_SCRIPT, PHP_SCRIPT_INT and PHP_SCRIPT_EXT
1980 *
1981 * @param array Array of TypoScript properties
1982 * @param string If "INT", then rendering "PHP_SCRIPT_INT"; If "EXT", then rendering "PHP_SCRIPT_EXT"; Default is rendering "PHP_SCRIPT" (cached)
1983 * @return string Output
1984 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=370&cHash=aa107f2ad8
1985 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=371&cHash=53f71d025e
1986 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=372&cHash=91fe391e1c
1987 */
1988 function PHP_SCRIPT($conf,$ext='') {
1989 $incFile = $GLOBALS['TSFE']->tmpl->getFileName($conf['file']);
1990 $content='';
1991 if ($incFile && $GLOBALS['TSFE']->checkFileInclude($incFile)) {
1992 switch($ext) {
1993 case 'INT':
1994 case 'EXT':
1995 $substKey = $ext.'_SCRIPT.'.$GLOBALS['TSFE']->uniqueHash();
1996 $content.='<!--'.$substKey.'-->';
1997 $GLOBALS['TSFE']->config[$ext.'incScript'][$substKey] = array(
1998 'file'=>$incFile,
1999 'conf'=>$conf,
2000 'type'=>'SCRIPT'
2001 );
2002 if ($ext=='INT') {
2003 $GLOBALS['TSFE']->config[$ext.'incScript'][$substKey]['cObj'] = serialize($this);
2004 } else {
2005 $GLOBALS['TSFE']->config[$ext.'incScript'][$substKey]['data'] = $this->data;
2006 }
2007 break;
2008 default:
2009 // Added 31-12-00: Make backup...
2010 $this->oldData = $this->data;
2011 // Include file..
2012 include('./'.$incFile);
2013 // Added 31-12-00: restore...
2014 if ($RESTORE_OLD_DATA) {
2015 $this->data = $this->oldData;
2016 }
2017 break;
2018 }
2019 }
2020 return $content;
2021 }
2022
2023 /**
2024 * Rendering the cObject, TEMPLATE
2025 *
2026 * @param array Array of TypoScript properties
2027 * @return string Output
2028 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=373&cHash=109a171b1e
2029 * @see substituteMarkerArrayCached()
2030 */
2031 function TEMPLATE($conf) {
2032 $subparts = Array();
2033 $marks = Array();
2034 $wraps = Array();
2035 $content='';
2036
2037 list($PRE,$POST) = explode('|',$conf['markerWrap'] ? $conf['markerWrap'] : '### | ###');
2038 $POST = trim($POST);
2039 $PRE = trim($PRE);
2040
2041 // Getting the content
2042 $content = $this->cObjGetSingle($conf['template'],$conf['template.'],'template');
2043 if ($conf['workOnSubpart']) {
2044 $content = $this->getSubpart($content, $PRE.$conf['workOnSubpart'].$POST);
2045 }
2046 if ($content) {
2047 if ($conf['nonCachedSubst']) { // NON-CACHED:
2048 // Getting marks
2049 if (is_array($conf['marks.'])) {
2050 reset($conf['marks.']);
2051 while(list($theKey,$theValue)=each($conf['marks.'])) {
2052 if (!strstr($theKey,'.')) {
2053 $content = str_replace(
2054 $PRE.$theKey.$POST,
2055 $this->cObjGetSingle($theValue,$conf['marks.'][$theKey.'.'],'marks.'.$theKey),
2056 $content);
2057 }
2058 }
2059 }
2060
2061 // Getting subparts.
2062 if (is_array($conf['subparts.'])) {
2063 reset($conf['subparts.']);
2064 while(list($theKey,$theValue)=each($conf['subparts.'])) {
2065 if (!strstr($theKey,'.')) {
2066 $subpart = $this->getSubpart($content, $PRE.$theKey.$POST);
2067 if ($subpart) {
2068 $this->setCurrentVal($subpart);
2069 $content = $this->substituteSubpart(
2070 $content,
2071 $PRE.$theKey.$POST,
2072 $this->cObjGetSingle($theValue,$conf['subparts.'][$theKey.'.'],'subparts.'.$theKey),
2073 1
2074 );
2075 }
2076 }
2077 }
2078 }
2079 // Getting subpart wraps
2080 if (is_array($conf['wraps.'])) {
2081 reset($conf['wraps.']);
2082 while(list($theKey,$theValue)=each($conf['wraps.'])) {
2083 if (!strstr($theKey,'.')) {
2084 $subpart = $this->getSubpart($content, $PRE.$theKey.$POST);
2085 if ($subpart) {
2086 $this->setCurrentVal($subpart);
2087 $content = $this->substituteSubpart(
2088 $content,
2089 $PRE.$theKey.$POST,
2090 explode('|',$this->cObjGetSingle($theValue,$conf['wraps.'][$theKey.'.'],'wraps.'.$theKey)),
2091 1
2092 );
2093 }
2094 }
2095 }
2096 }
2097 } else { // CACHED
2098 // Getting subparts.
2099 if (is_array($conf['subparts.'])) {
2100 reset($conf['subparts.']);
2101 while(list($theKey,$theValue)=each($conf['subparts.'])) {
2102 if (!strstr($theKey,'.')) {
2103 $subpart = $this->getSubpart($content, $PRE.$theKey.$POST);
2104 if ($subpart) {
2105 $GLOBALS['TSFE']->register['SUBPART_'.$theKey] = $subpart;
2106 $subparts[$theKey]['name'] = $theValue;
2107 $subparts[$theKey]['conf'] = $conf['subparts.'][$theKey.'.'];
2108 }
2109 }
2110 }
2111 }
2112 // Getting marks
2113 if (is_array($conf['marks.'])) {
2114 reset($conf['marks.']);
2115 while(list($theKey,$theValue)=each($conf['marks.'])) {
2116 if (!strstr($theKey,'.')) {
2117 $marks[$theKey]['name'] = $theValue;
2118 $marks[$theKey]['conf'] = $conf['marks.'][$theKey.'.'];
2119 }
2120 }
2121 }
2122 // Getting subpart wraps
2123 if (is_array($conf['wraps.'])) {
2124 reset($conf['wraps.']);
2125 while(list($theKey,$theValue)=each($conf['wraps.'])) {
2126 if (!strstr($theKey,'.')) {
2127 $wraps[$theKey]['name'] = $theValue;
2128 $wraps[$theKey]['conf'] = $conf['wraps.'][$theKey.'.'];
2129 }
2130 }
2131 }
2132 // Getting subparts
2133 $subpartArray =array();
2134 reset($subparts);
2135 while(list($theKey,$theValue)=each($subparts)) {
2136 // Set current with the content of the subpart...
2137 $this->data[$this->currentValKey] = $GLOBALS['TSFE']->register['SUBPART_'.$theKey];
2138 // Get subpart cObject and substitute it!
2139 $subpartArray[$PRE.$theKey.$POST] = $this->cObjGetSingle($theValue['name'],$theValue['conf'],'subparts.'.$theKey);
2140 }
2141 $this->data[$this->currentValKey] = ''; // Reset current to empty
2142
2143 // Getting marks
2144 $markerArray =array();
2145 reset($marks);
2146 while(list($theKey,$theValue)=each($marks)) {
2147 $markerArray[$PRE.$theKey.$POST] = $this->cObjGetSingle($theValue['name'],$theValue['conf'],'marks.'.$theKey);
2148 }
2149 // Getting wraps
2150 $subpartWraps =array();
2151 reset($wraps);
2152 while(list($theKey,$theValue)=each($wraps)) {
2153 $subpartWraps[$PRE.$theKey.$POST] = explode('|',$this->cObjGetSingle($theValue['name'],$theValue['conf'],'wraps.'.$theKey));
2154 }
2155
2156 // Substitution
2157 if ($conf['substMarksSeparately']) {
2158 $content = $this->substituteMarkerArrayCached($content,array(),$subpartArray,$subpartWraps);
2159 $content = $this->substituteMarkerArray($content, $markerArray);
2160 } else {
2161 $content = $this->substituteMarkerArrayCached($content,$markerArray,$subpartArray,$subpartWraps);
2162 }
2163 }
2164 }
2165 return $content;
2166 }
2167
2168 /**
2169 * Rendering the cObject, MULTIMEDIA
2170 *
2171 * @param array Array of TypoScript properties
2172 * @return string Output
2173 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=374&cHash=efd88ab4a9
2174 */
2175 function MULTIMEDIA($conf) {
2176 $content='';
2177 $filename=$this->stdWrap($conf['file'],$conf['file.']);
2178 $incFile = $GLOBALS['TSFE']->tmpl->getFileName($filename);
2179 if ($incFile) {
2180 $fileinfo = t3lib_div::split_fileref($incFile);
2181 if (t3lib_div::inList('txt,html,htm',$fileinfo['fileext'])) {
2182 $content = $GLOBALS['TSFE']->tmpl->fileContent($incFile);
2183 } else {
2184 // default params...
2185 $parArray=array();
2186 // src is added
2187 $parArray['src']='src="'.$GLOBALS['TSFE']->absRefPrefix.$incFile.'"';
2188 if (t3lib_div::inList('au,wav,mp3',$fileinfo['fileext'])) {
2189 }
2190 if (t3lib_div::inList('avi,mov,mpg,asf,wmv',$fileinfo['fileext'])) {
2191 $parArray['width'] = 'width="200"';
2192 $parArray['height'] = 'height="200"';
2193 }
2194 if (t3lib_div::inList('swf,swa,dcr',$fileinfo['fileext'])) {
2195 $parArray['quality'] = 'quality="high"';
2196 }
2197 if (t3lib_div::inList('class',$fileinfo['fileext'])) {
2198 $parArray['width'] = 'width="200"';
2199 $parArray['height'] = 'height="200"';
2200 }
2201
2202 // fetching params
2203 $lines = explode(chr(10), $this->stdWrap($conf['params'],$conf['params.']));
2204 while(list(,$l)=each($lines)) {
2205 $parts = explode('=', $l);
2206 $parameter = strtolower(trim($parts[0]));
2207 $value = trim($parts[1]);
2208 if ((string)$value!='') {
2209 $parArray[$parameter] = $parameter.'="'.htmlspecialchars($value).'"';
2210 } else {
2211 unset($parArray[$parameter]);
2212 }
2213 }
2214 if ($fileinfo['fileext']=='class') {
2215 unset($parArray['src']);
2216 $parArray['code'] = 'code="'.htmlspecialchars($fileinfo['file']).'"';
2217 $parArray['codebase'] = 'codebase="'.htmlspecialchars($fileinfo['path']).'"';
2218 $content='<applet '.implode($parArray,' ').'></applet>';
2219 } else {
2220 $content='<embed '.implode($parArray,' ').'></embed>';
2221 }
2222 }
2223 }
2224 return $content;
2225 }
2226
2227
2228
2229
2230
2231
2232
2233
2234
2235
2236
2237
2238
2239
2240
2241
2242
2243 /************************************
2244 *
2245 * Various helper functions for content objects:
2246 *
2247 ************************************/
2248
2249 /**
2250 * Creates a link to a netprint application on another website (where the "netprint" extension is running")
2251 * Related to the extension "netprint"
2252 *
2253 * @param string The input string to add the link to.
2254 * @param array Array with information about the image.
2255 * @param array TypoScript properties for the netprint application.
2256 * @return string The input string possibly with the netprint link before/after
2257 * @access private
2258 */
2259 function netprintApplication_offsiteLinkWrap($str,$imgConf,$conf) {
2260 if ($conf['url'] && @is_file($imgConf['origFile'])) {
2261 $thisUrl = $conf['thisUrl'] ? $conf['thisUrl'] : t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR');
2262 $origFile=$thisUrl.$imgConf['origFile'];
2263 // Original file dimensions:
2264 $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
2265 $gifCreator->init();
2266 $origDim = $gifCreator->getImageDimensions($imgConf['origFile']);
2267 if (!$conf['linkOnlyPixelsAbove'] || $origDim[0]*$origDim[1]>$conf['linkOnlyPixelsAbove']) {
2268 // Set parameters
2269 $thumbFile=$thisUrl.$imgConf['3'].'|'.$imgConf[0].'x'.$imgConf[1].'|'.$origDim[0].'x'.$origDim[1].'|'.filesize($imgConf['origFile']).'|'.filemtime($imgConf['origFile']);
2270 // Set url:
2271 $url = $conf['url']
2272 .'&NP[offsite][1]='.rawurlencode($origFile)
2273 .'&NP[offsite_thumb][1]='.rawurlencode($thumbFile);
2274 $linkCObject = $this->cObjGetSingle($conf['cObject'],$conf['cObject.']);
2275 if ($linkCObject) {
2276 $ATagParams = trim($conf['ATagParams']) ? ' '.trim($conf['ATagParams']) : '';
2277 $linkCObject='<a href="'.htmlspecialchars($url).'"'.$ATagParams.'>'.$linkCObject.'</a>';
2278 $linkCObject=$this->stdWrap($linkCObject,$conf['outerStdWrap.']);
2279 if ($conf['before']) {
2280 $str=$linkCObject.$str;
2281 } else {
2282 $str=$str.$linkCObject;
2283 }
2284 }
2285 }
2286 }
2287 return $str;
2288 }
2289
2290 /**
2291 * Returns a default value for a form field in the FORM cObject.
2292 * Page CANNOT be cached because that would include the inserted value for the current user.
2293 *
2294 * @param boolean If noValueInsert OR if the no_cache flag for this page is NOT set, the original default value is returned.
2295 * @param string $fieldName: The POST var name to get default value for
2296 * @param string $defaultVal: The current default value
2297 * @return string The default value, either from INPUT var or the current default, based on whether caching is enabled or not.
2298 * @access private
2299 */
2300 function getFieldDefaultValue($noValueInsert, $fieldName, $defaultVal) {
2301 if (!$GLOBALS['TSFE']->no_cache || (!isset($GLOBALS['HTTP_POST_VARS'][$fieldName]) && !isset($GLOBALS['HTTP_GET_VARS'][$fieldName])) || $noValueInsert) {
2302 return $defaultVal;
2303 } else {
2304 return t3lib_div::GPvar($fieldName);
2305 }
2306 }
2307
2308 /**
2309 * Returns a <img> tag with the image file defined by $file and processed according to the properties in the TypoScript array.
2310 * Mostly this function is a sub-function to the IMAGE function which renders the IMAGE cObject in TypoScript. This function is called by "$this->cImage($conf['file'],$conf);" from IMAGE().
2311 *
2312 * @param string File TypoScript resource
2313 * @param array TypoScript configuration properties
2314 * @return string <img> tag, (possibly wrapped in links and other HTML) if any image found.
2315 * @access private
2316 * @see IMAGE()
2317 */
2318 function cImage($file,$conf) {
2319 $info = $this->getImgResource($file,$conf['file.']);
2320 $GLOBALS['TSFE']->lastImageInfo=$info;
2321 if (is_array($info)) {
2322 $info[3] = t3lib_div::png_to_gif_by_imagemagick($info[3]);
2323 $GLOBALS['TSFE']->imagesOnPage[]=$info[3]; // This array is used to collect the image-refs on the page...
2324 $alttext = strip_tags($this->stdWrap($conf['alttext'],$conf['alttext.']));
2325 $theValue = '<img src="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.$info[3]).'" width="'.$info[0].'" height="'.$info[1].'" border="'.intval($conf['border']).'"'.($conf['params']?' '.$conf['params']:'').($alttext?' alt="'.htmlspecialchars($alttext).'"':' alt=""').' />';
2326 if ($conf['linkWrap']) {
2327 $theValue = $this->linkWrap($theValue,$conf['linkWrap']);
2328 } elseif ($conf['imageLinkWrap']) {
2329 $theValue = $this->imageLinkWrap($theValue,$info['origFile'],$conf['imageLinkWrap.']);
2330 }
2331 return $this->wrap($theValue,$conf['wrap']);
2332 }
2333 }
2334
2335 /**
2336 * Wraps the input string in link-tags that opens the image in a new window.
2337 *
2338 * @param string String to wrap, probably an <img> tag
2339 * @param string The original image file
2340 * @param array TypoScript properties for the "imageLinkWrap" function
2341 * @return string The input string, $string, wrapped as configured.
2342 * @see cImage()
2343 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=316&cHash=2848266da6
2344 */
2345 function imageLinkWrap($string,$imageFile,$conf) {
2346 $a1='';
2347 $a2='';
2348 $content=$string;
2349 if ($this->stdWrap($conf['enable'],$conf['enable.'])) {
2350 $content=$this->typolink($string, $conf['typolink.']);
2351 // imageFileLink:
2352 if ($content==$string && @is_file($imageFile)) {
2353 $params = '';
2354 if ($conf['width']) {$params.='&width='.rawurlencode($conf['width']);}
2355 if ($conf['height']) {$params.='&height='.rawurlencode($conf['height']);}
2356 if ($conf['effects']) {$params.='&effects='.rawurlencode($conf['effects']);}
2357 if ($conf['sample']) {$params.='&sample=1';}
2358 if ($conf['alternativeTempPath']) {$params.='&alternativeTempPath='.rawurlencode($conf['alternativeTempPath']);}
2359
2360 if ($conf['bodyTag']) {$params.='&bodyTag='.rawurlencode($conf['bodyTag']);}
2361 if ($conf['title']) {$params.='&title='.rawurlencode($conf['title']);}
2362 if ($conf['wrap']) {$params.='&wrap='.rawurlencode($conf['wrap']);}
2363
2364 $md5_value = md5($imageFile.'|'.$conf['width'].'|'.$conf['height'].'|'.$conf['effects'].'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'].'|');
2365
2366 $params.= '&md5='.$md5_value;
2367 $url = $GLOBALS['TSFE']->absRefPrefix.'showpic.php?file='.rawurlencode($imageFile).$params;
2368 if ($conf['JSwindow.']['altUrl'] || $conf['JSwindow.']['altUrl.']) {
2369 $altUrl = $this->stdWrap($conf['JSwindow.']['altUrl'], $conf['JSwindow.']['altUrl.']);
2370 if ($altUrl) {
2371 $url=$altUrl;
2372 }
2373 }
2374
2375 if ($conf['JSwindow']) {
2376 $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
2377 $gifCreator->init();
2378 $gifCreator->mayScaleUp = 0;
2379 $dims = $gifCreator->getImageScale($gifCreator->getImageDimensions($imageFile),$conf['width'],$conf['height'],'');
2380 $offset = t3lib_div::intExplode(',',$conf['JSwindow.']['expand'].',');
2381
2382 $a1='<a href="#" onclick="'.
2383 htmlspecialchars('openPic(\''.$url.'\',\''.($conf['JSwindow.']['newWindow']?md5($url):'thePicture').'\',\'width='.($dims[0]+$offset[0]).',height='.($dims[1]+$offset[1]).',status=0,menubar=0\'); return false;').
2384 '"'.$GLOBALS['TSFE']->ATagParams.'>';
2385 $a2='</a>';
2386 $GLOBALS['TSFE']->setJS('openPic');
2387 } else {
2388 $target = ' target="thePicture"';
2389 if (isset($conf['target'])) {
2390 $target= ($conf['target']) ? ' target="'.$conf['target'].'"' : '';
2391 }
2392 $a1='<a href="'.htmlspecialchars($url).'"'.$target.$GLOBALS['TSFE']->ATagParams.'>';
2393 $a2='</a>';
2394 }
2395 $content=$a1.$string.$a2;
2396 }
2397 }
2398
2399 return $content;
2400 }
2401
2402 /**
2403 * Returns content of a file. If its an image the content of the file is not returned but rather an image tag is.
2404 *
2405 * @param string The filename, being a TypoScript resource data type
2406 * @return string If jpg,gif,jpeg,png: returns image_tag with picture in. If html,txt: returns content string
2407 * @see FILE()
2408 */
2409 function fileResource($fName) {
2410 $incFile = $GLOBALS['TSFE']->tmpl->getFileName($fName);
2411 if ($incFile) {
2412 $fileinfo = t3lib_div::split_fileref($incFile);
2413 if (t3lib_div::inList('jpg,gif,jpeg,png',$fileinfo['fileext'])) {
2414 $imgFile = $incFile;
2415 $imgInfo = @getImageSize($imgFile);
2416 return '<img src="'.$GLOBALS['TSFE']->absRefPrefix.$imgFile.'" width="'.$imgInfo[0].'" height="'.$imgInfo[1].'" border="0" alt="" />';
2417 } elseif (filesize($incFile)<1024*1024) {
2418 return $GLOBALS['TSFE']->tmpl->fileContent($incFile);
2419 }
2420 }
2421 }
2422
2423 /**
2424 * Sets the SYS_LASTCHANGED timestamp if input timestamp is larger than current value.
2425 * The SYS_LASTCHANGED timestamp can be used by various caching/indexing applications to determine if the page has new content.
2426 * Therefore you should call this function with the last-changed timestamp of any element you display.
2427 *
2428 * @param integer Unix timestamp (number of seconds since 1970)
2429 * @return void
2430 * @see tslib_fe::setSysLastChanged()
2431 */
2432 function lastChanged($tstamp) {
2433 $tstamp = intval($tstamp);
2434 if ($tstamp>intval($GLOBALS['TSFE']->register['SYS_LASTCHANGED'])) {
2435 $GLOBALS['TSFE']->register['SYS_LASTCHANGED'] = $tstamp;
2436 }
2437 }
2438
2439 /**
2440 * Wraps the input string by the $wrap value and implements the "linkWrap" data type as well.
2441 * The "linkWrap" data type means that this function will find any integer encapsulated in {} (curly braces) in the first wrap part and substitute it with the corresponding page uid from the rootline where the found integer is pointing to the key in the rootline. See link below.
2442 *
2443 * @param string Input string
2444 * @param string A string where the first two parts separated by "|" (vertical line) will be wrapped around the input string
2445 * @return string Wrapped output string
2446 * @see wrap(), cImage(), FILE()
2447 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=282&cHash=831a95115d
2448 */
2449 function linkWrap($content,$wrap) {
2450 $wrapArr = explode('|', $wrap);
2451 if (ereg("\{([0-9]*)\}",$wrapArr[0],$reg)) {
2452 if ($uid = $GLOBALS['TSFE']->tmpl->rootLine[$reg[1]]['uid']) {
2453 $wrapArr[0] = str_replace($reg[0],$uid,$wrapArr[0]);
2454 }
2455 }
2456 return trim($wrapArr[0]).$content.trim($wrapArr[1]);
2457 }
2458
2459
2460
2461
2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478 /***********************************************
2479 *
2480 * HTML template processing functions
2481 *
2482 ***********************************************/
2483
2484 /**
2485 * Returns a subpart from the input content stream.
2486 * A subpart is a part of the input stream which is encapsulated in a string matching the input string, $marker. If this string is found inside of HTML comment tags the start/end points of the content block returned will be that right outside that comment block.
2487 * Example: The contennt string is "Hello <!--###sub1### begin--> World. How are <!--###sub1### end--> you?" If $marker is "###sub1###" then the content returned is " World. How are ". The input content string could just as well have been "Hello ###sub1### World. How are ###sub1### you?" and the result would be the same
2488 *
2489 * @param string The content stream, typically HTML template content.
2490 * @param string The marker string, typically on the form "###[the marker string]###"
2491 * @return string The subpart found, if found.
2492 * @see substituteSubpart(), t3lib_parsehtml::getSubpart()
2493 */
2494 function getSubpart($content, $marker) {
2495 if ($marker && strstr($content,$marker)) {
2496 $start = strpos($content, $marker)+strlen($marker);
2497 $stop = @strpos($content, $marker, $start+1);
2498 $sub = substr($content, $start, $stop-$start);
2499
2500 $reg=Array();
2501 ereg('^[^<]*-->',$sub,$reg);
2502 $start+=strlen($reg[0]);
2503
2504 $reg=Array();
2505 ereg('<!--[^>]*$',$sub,$reg);
2506 $stop-=strlen($reg[0]);
2507
2508 return substr($content, $start, $stop-$start);
2509 }
2510 }
2511
2512 /**
2513 * Substitute subpart in input template stream.
2514 * This function substitutes a subpart in $content with the content of $subpartContent.
2515 *
2516 * @param string The content stream, typically HTML template content.
2517 * @param string The marker string, typically on the form "###[the marker string]###"
2518 * @param mixed The content to insert instead of the subpart found. If a string, then just plain substitution happens (includes removing the HTML comments of the subpart if found). If $subpartContent happens to be an array, it's [0] and [1] elements are wrapped around the EXISTING content of the subpart (fetched by getSubpart()) thereby not removing the original content.
2519 * @param boolean If $recursive is set, the function calls itself with the content set to the remaining part of the content after the second marker. This means that proceding subparts are ALSO substituted!
2520 * @return string The processed HTML content string.
2521 * @see getSubpart(), t3lib_parsehtml::substituteSubpart()
2522 */
2523 function substituteSubpart($content,$marker,$subpartContent,$recursive=1) {
2524 $start = strpos($content, $marker);
2525 $stop = @strpos($content, $marker, $start+1)+strlen($marker);
2526 if ($start && $stop>$start) {
2527 // code before
2528 $before = substr($content, 0, $start);
2529 $reg=Array();
2530 ereg('<!--[^>]*$',$before,$reg);
2531 $start-=strlen($reg[0]);
2532 $before = substr($content, 0, $start);
2533 // code after
2534 $after = substr($content, $stop);
2535 $reg=Array();
2536 ereg('^[^<]*-->',$after,$reg);
2537 $stop+=strlen($reg[0]);
2538 $after = substr($content, $stop);
2539 // replace?
2540 if (is_array($subpartContent)) {
2541 $substContent=$subpartContent[0].$this->getSubpart($content,$marker).$subpartContent[1];
2542 } else {
2543 $substContent=$subpartContent;
2544 }
2545
2546 if ($recursive && strpos($after, $marker)) {
2547 return $before.$substContent.$this->substituteSubpart($after,$marker,$subpartContent);
2548 } else {
2549 return $before.$substContent.$after;
2550 }
2551 } else {
2552 return $content;
2553 }
2554 }
2555
2556 /**
2557 * Substitutes a marker string in the input content (by a simple str_replace())
2558 *
2559 * @param string The content stream, typically HTML template content.
2560 * @param string The marker string, typically on the form "###[the marker string]###"
2561 * @param mixed The content to insert instead of the marker string found.
2562 * @return string The processed HTML content string.
2563 * @see substituteSubpart()
2564 */
2565 function substituteMarker($content,$marker,$markContent) {
2566 return str_replace($marker,$markContent,$content);
2567 }
2568
2569 /**
2570 * Multi substitution function with caching.
2571 *
2572 * This function should be a one-stop substitution function for working with HTML-template. It does not substitute by str_replace but by splitting. This secures that the value inserted does not themselves contain markers or subparts.
2573 * This function takes three kinds of substitutions in one:
2574 * $markContentArray is a regular marker-array where the 'keys' are substituted in $content with their values
2575 * $subpartContentArray works exactly like markContentArray only is whole subparts substituted and not only a single marker.
2576 * $wrappedSubpartConten