* Added Jens Ellerbrocks suggestion for "postUserFuncInt" in stdWrap.
[Packages/TYPO3.CMS.git] / typo3 / sysext / cms / tslib / class.tslib_content.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2004 Kasper Skaarhoj (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 * $Id$
31 * Revised for TYPO3 3.6 June/2003 by Kasper Skaarhoj
32 * XHTML compliant
33 *
34 * class tslib_cObj : All main TypoScript features, rendering of content objects (cObjects). This class is the backbone of TypoScript Template rendering.
35 * class tslib_controlTable : Makes a table CTABLE (TS cObject)
36 * class tslib_tableOffset : Makes a table-offset (TS)
37 * class tslib_frameset : Generates framesets (TS)
38 *
39 * @author Kasper Skaarhoj <kasper@typo3.com>
40 */
41 /**
42 * [CLASS/FUNCTION INDEX of SCRIPT]
43 *
44 *
45 *
46 * 243: class tslib_cObj
47 * 340: function start($data,$table='')
48 * 355: function setParent($data,$currentRecord)
49 *
50 * SECTION: CONTENT_OBJ:
51 * 380: function getCurrentVal()
52 * 391: function setCurrentVal($value)
53 * 404: function cObjGet($setup,$addKey='')
54 * 428: function cObjGetSingle($name,$conf,$TSkey='__')
55 *
56 * SECTION: Functions rendering content objects (cObjects)
57 * 567: function HTML($conf)
58 * 578: function TEXT($conf)
59 * 589: function CLEARGIF($conf)
60 * 608: function COBJ_ARRAY($conf,$ext='')
61 * 644: function USER($conf,$ext='')
62 * 671: function FILE($conf)
63 * 687: function IMAGE($conf)
64 * 706: function IMG_RESOURCE($conf)
65 * 718: function IMGTEXT($conf)
66 * 1097: function CONTENT($conf)
67 * 1148: function RECORDS($conf)
68 * 1215: function HMENU($conf)
69 * 1247: function CTABLE ($conf)
70 * 1285: function OTABLE ($conf)
71 * 1300: function COLUMNS ($conf)
72 * 1379: function HRULER ($conf)
73 * 1403: function CASEFUNC ($conf)
74 * 1428: function LOAD_REGISTER($conf,$name)
75 * 1468: function FORM($conf,$formData='')
76 * 1843: function SEARCHRESULT($conf)
77 * 2002: function PHP_SCRIPT($conf,$ext='')
78 * 2045: function TEMPLATE($conf)
79 * 2189: function MULTIMEDIA($conf)
80 *
81 * SECTION: Various helper functions for content objects:
82 * 2278: function netprintApplication_offsiteLinkWrap($str,$imgConf,$conf)
83 * 2319: function getFieldDefaultValue($noValueInsert, $fieldName, $defaultVal)
84 * 2337: function cImage($file,$conf)
85 * 2364: function imageLinkWrap($string,$imageFile,$conf)
86 * 2428: function fileResource($fName)
87 * 2451: function lastChanged($tstamp)
88 * 2468: function linkWrap($content,$wrap)
89 *
90 * SECTION: HTML template processing functions
91 * 2513: function getSubpart($content, $marker)
92 * 2542: function substituteSubpart($content,$marker,$subpartContent,$recursive=1)
93 * 2584: function substituteMarker($content,$marker,$markContent)
94 * 2604: function substituteMarkerArrayCached($content,$markContentArray=array(),$subpartContentArray=array(),$wrappedSubpartContentArray=array())
95 * 2702: function substituteMarkerArray($content,$markContentArray,$wrap='',$uppercase=0)
96 * 2723: function substituteMarkerInObject(&$tree, $markContentArray)
97 * 2746: function fillInMarkerArray($markContentArray, $row, $fieldList='', $nl2br=TRUE, $prefix='FIELD_', $HSC=FALSE)
98 *
99 * SECTION: "stdWrap" + sub functions
100 * 2809: function stdWrap($content,$conf)
101 * 2956: function numRows($conf)
102 * 2977: function listNum($content,$listNum,$char)
103 * 2997: function checkIf($conf)
104 * 3060: function filelist($data)
105 * 3139: function clean_directory($theDir)
106 * 3157: function HTMLparser_TSbridge($theValue, $conf)
107 * 3171: function dataWrap($content,$wrap)
108 * 3184: function insertData($str)
109 * 3214: function prefixComment($str,$conf,$content)
110 * 3238: function substring($content,$options)
111 * 3256: function crop($content,$options)
112 * 3282: function textStyle($theValue, $conf)
113 * 3349: function tableStyle($theValue, $conf)
114 * 3390: function addParams($content,$conf)
115 * 3433: function filelink($theValue, $conf)
116 * 3500: function locDataJU($jumpUrl,$conf)
117 * 3531: function calc($val)
118 * 3560: function calcIntExplode($delim, $string)
119 * 3580: function splitObj($value, $conf)
120 * 3636: function parseFunc($theValue, $conf, $ref='')
121 * 3742: function _parseFunc ($theValue, $conf)
122 * 3944: function encaps_lineSplit($theValue, $conf)
123 * 4027: function http_makelinks($data,$conf)
124 * 4094: function mailto_makelinks($data,$conf)
125 * 4139: function getImgResource($file,$fileArray)
126 *
127 * SECTION: Data retrieval etc.
128 * 4311: function getFieldVal($field)
129 * 4331: function getData($string,$fieldArray)
130 * 4446: function rootLineValue($key,$field,$slideBack=0,$altRootLine='')
131 * 4467: function getGlobal($var)
132 * 4492: function getKey($key,$arr)
133 *
134 * SECTION: Link functions (typolink)
135 * 4544: function typoLink($linktxt, $conf)
136 * 4787: function typoLink_URL($conf)
137 * 4805: function getTypoLink($label,$params,$urlParameters=array(),$target='')
138 * 4835: function getTypoLink_URL($params,$urlParameters=array(),$target='')
139 * 4847: function typolinkWrap($conf)
140 * 4860: function currentPageUrl($urlParameters=array(),$id=0)
141 *
142 * SECTION: Miscellaneous functions, stand alone
143 * 4904: function wrap($content,$wrap,$char='|')
144 * 4920: function noTrimWrap($content,$wrap)
145 * 4934: function wrapSpace($content, $wrap)
146 * 4960: function callUserFunction($funcName,$conf,$content)
147 * 5001: function processParams($params)
148 * 5019: function keywords($content)
149 * 5036: function caseshift($theValue, $case)
150 * 5059: function HTMLcaseshift($theValue, $case)
151 * 5088: function bytes($sizeInBytes,$labels)
152 * 5099: function calcAge($seconds,$labels)
153 * 5130: function sendNotifyEmail($msg, $recipients, $cc, $email_from, $email_fromName='', $replyTo='')
154 * 5157: function URLqMark($url,$params)
155 * 5173: function checkEmail($email)
156 * 5185: function clearTSProperties($TSArr,$propList)
157 * 5204: function mergeTSRef($confArr,$prop)
158 * 5227: function joinTSarrays($conf,$old_conf)
159 * 5250: function gifBuilderTextBox($gifbuilderConf, $conf, $text)
160 * 5306: function linebreaks($string,$chars,$maxLines=0)
161 * 5337: function getUpdateJS($dataArray, $formName, $arrPrefix, $fieldList)
162 *
163 * SECTION: Database functions, making of queries
164 * 5406: function DBgetDelete($table, $uid, $doExec=FALSE)
165 * 5438: function DBgetUpdate($table, $uid, $dataArr, $fieldList, $doExec=FALSE)
166 * 5480: function DBgetInsert($table, $pid, $dataArr, $fieldList, $doExec=FALSE)
167 * 5517: function DBmayFEUserEdit($table,$row, $feUserRow, $allowedGroups='',$feEditSelf=0)
168 * 5557: function DBmayFEUserEditSelect($table,$feUserRow,$allowedGroups='',$feEditSelf=0)
169 * 5597: function enableFields($table,$show_hidden=0)
170 * 5620: function getTreeList($id,$depth,$begin=0,$dontCheckEnableFields=0,$addSelectFields='',$moreWhereClauses='')
171 * 5653: function whereSelectFromList($field,$value)
172 * 5671: function exec_mm_query($select,$local_table,$mm_table,$foreign_table,$whereClause='',$groupBy='',$orderBy='',$limit='')
173 * 5698: function exec_mm_query_uidList($select,$local_table_uidlist,$mm_table,$foreign_table='',$whereClause='',$groupBy='',$orderBy='',$limit='')
174 * 5719: function searchWhere($sw,$searchFieldList,$searchTable='')
175 * 5752: function exec_getQuery($table, $conf)
176 * 5770: function getQuery($table, $conf, $returnQueryArray=FALSE)
177 * 5849: function getWhere($table,$conf, $returnQueryArray=FALSE)
178 * 5935: function checkPidArray($listArr)
179 * 5958: function checkPid($uid)
180 *
181 * SECTION: Frontend editing functions
182 * 6014: function editPanel($content, $conf, $currentRecord='', $dataArr=array())
183 * 6179: function editIcons($content,$params, $conf=array(), $currentRecord='', $dataArr=array(),$addUrlParamStr='')
184 * 6243: function editPanelLinkWrap($string,$formName,$cmd,$currentRecord='',$confirm='')
185 * 6281: function editPanelLinkWrap_doWrap($string,$url,$currentRecord)
186 * 6308: function editPanelPreviewBorder($table,$row,$content,$thick)
187 * 6325: function isDisabled($table,$row)
188 *
189 *
190 * 6356: class tslib_frameset
191 * 6366: function make($setup)
192 * 6403: function frameParams($setup, $typeNum)
193 * 6446: function framesetParams($setup)
194 *
195 *
196 * 6479: class tslib_tableOffset
197 * 6491: function start($content,$offset)
198 *
199 *
200 * 6569: class tslib_controlTable
201 * 6604: function start($offset,$cMargins)
202 *
203 * TOTAL FUNCTIONS: 126
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 Skaarhoj <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="" title="" />', $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 $altP = $this->getAltParam($conf);
841
842 // EqualHeight
843 $equalHeight = intval($this->stdWrap($conf['equalH'],$conf['equalH.']));
844 if ($equalHeight) { // Initiate gifbuilder object in order to get dimensions AND calculate the imageWidth's
845 $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
846 $gifCreator->init();
847 $relations = Array();
848 $relations_cols = Array();
849 $totalMaxW = $maxW*$colCount;
850 for($a=0;$a<$imgCount;$a++) {
851 $imgKey = $a+$imgStart;
852 $imgInfo = $gifCreator->getImageDimensions($imgPath.$imgs[$imgKey]);
853 $relations[$a] = $imgInfo[1] / $equalHeight; // relationship between the original height and the wished height
854 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.
855 $relations_cols[floor($a/$colCount)] += $imgInfo[0]/$relations[$a]; // counts the total width of the row with the new height taken into consideration.
856 }
857 }
858 }
859
860 $imageRowsFinalWidths = Array(); // contains the width of every image row
861 $imageRowsMaxHeights = Array();
862 $imgsTag=array();
863 $origImages=array();
864 for($a=0;$a<$imgCount;$a++) {
865 $GLOBALS['TSFE']->register['IMAGE_NUM'] = $a;
866
867 $imgKey = $a+$imgStart;
868 $totalImagePath = $imgPath.$imgs[$imgKey];
869 $this->data[$this->currentValKey] = $totalImagePath;
870 $imgObjNum = intval($splitArr[$a]['imgObjNum']);
871 $imgConf = $conf[$imgObjNum.'.'];
872
873 if ($equalHeight) {
874 $scale = 1;
875 if ($totalMaxW) {
876 $rowTotalMaxW = $relations_cols[floor($a/$colCount)];
877 if ($rowTotalMaxW > $totalMaxW) {
878 $scale = $rowTotalMaxW / $totalMaxW;
879 }
880 }
881 // transfer info to the imageObject. Please note, that
882 $imgConf['file.']['height'] = round($equalHeight/$scale);
883
884 unset($imgConf['file.']['width']);
885 unset($imgConf['file.']['maxW']);
886 unset($imgConf['file.']['maxH']);
887 unset($imgConf['file.']['minW']);
888 unset($imgConf['file.']['minH']);
889 unset($imgConf['file.']['width.']);
890 unset($imgConf['file.']['maxW.']);
891 unset($imgConf['file.']['maxH.']);
892 unset($imgConf['file.']['minW.']);
893 unset($imgConf['file.']['minH.']);
894 $maxW = 0; // setting this to zero, so that it doesn't disturb
895 }
896
897 if ($maxW) {
898 if (count($colMaxW)) {
899 $imgConf['file.']['maxW'] = $colMaxW[($a%$colCount)];
900 } else {
901 $imgConf['file.']['maxW'] = $maxW;
902 }
903 }
904
905 if ($imgConf || $imgConf['file']) {
906 $imgConf['params'].=$altP;
907 if ($this->image_effects[$image_effects]) {
908 $imgConf['file.']['params'].= ' '.$this->image_effects[$image_effects];
909 }
910 if ($image_frames) {
911 if (is_array($conf['image_frames.'][$image_frames.'.'])) {
912 $imgConf['file.']['m.'] = $conf['image_frames.'][$image_frames.'.'];
913 }
914 }
915 if ($image_compression && $imgConf['file']!='GIFBUILDER') {
916 if ($image_compression==1) {
917 $tempImport = $imgConf['file.']['import'];
918 $tempImport_dot = $imgConf['file.']['import.'];
919 unset($imgConf['file.']);
920 $imgConf['file.']['import'] = $tempImport;
921 $imgConf['file.']['import.'] = $tempImport_dot;
922 } elseif (isset($this->image_compression[$image_compression])) {
923 $imgConf['file.']['params'].= ' '.$this->image_compression[$image_compression]['params'];
924 $imgConf['file.']['ext'] = $this->image_compression[$image_compression]['ext'];
925 unset($imgConf['file.']['ext.']);
926 }
927 }
928 $imgsTag[$imgKey] = $this->IMAGE($imgConf);
929 } else {
930 $imgsTag[$imgKey] = $this->IMAGE(Array('params'=>$altP, 'file'=>$totalImagePath)); // currentValKey !!!
931 }
932 // Store the original filepath
933 $origImages[$imgKey]=$GLOBALS['TSFE']->lastImageInfo;
934
935 $imageRowsFinalWidths[floor($a/$colCount)] += $GLOBALS['TSFE']->lastImageInfo[0];
936 if ($GLOBALS['TSFE']->lastImageInfo[1]>$imageRowsMaxHeights[floor($a/$colCount)]) {
937 $imageRowsMaxHeights[floor($a/$colCount)] = $GLOBALS['TSFE']->lastImageInfo[1];
938 }
939 }
940 // calculating the tableWidth:
941 // TableWidth problems: It creates problems if the pictures are NOT as wide as the tableWidth.
942 $tableWidth = max($imageRowsFinalWidths)+ $colspacing*($colCount-1) + $colCount*$border*$borderThickness*2;
943
944 // make table for pictures
945 $index=$imgStart;
946
947 $noRows = $this->stdWrap($conf['noRows'],$conf['noRows.']);
948 $noCols = $this->stdWrap($conf['noCols'],$conf['noCols.']);
949 if ($noRows) {$noCols=0;} // noRows overrides noCols. They cannot exist at the same time.
950 if ($equalHeight) {
951 $noCols=1;
952 $noRows=0;
953 }
954
955 $rowCount_temp=1;
956 $colCount_temp=$colCount;
957 if ($noRows) {
958 $rowCount_temp = $rowCount;
959 $rowCount=1;
960 }
961 if ($noCols) {
962 $colCount=1;
963 }
964 // col- and rowspans calculated
965 $colspan = (($colspacing) ? $colCount*2-1 : $colCount);
966 $rowspan = (($rowspacing) ? $rowCount*2-1 : $rowCount) + $cap;
967
968
969 // Edit icons:
970 $editIconsHTML = $conf['editIcons']&&$GLOBALS['TSFE']->beUserLogin ? $this->editIcons('',$conf['editIcons'],$conf['editIcons.']) : '';
971
972 // strech out table:
973 $tablecode='';
974 $flag=0;
975 if ($conf['noStretchAndMarginCells']!=1) {
976 $tablecode.='<tr>';
977 if ($txtMarg && $align=='right') { // If right aligned, the textborder is added on the right side
978 $tablecode.='<td rowspan="'.($rowspan+1).'" valign="top"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$txtMarg.'" height="1" alt="" title="" />'.($editIconsHTML?'<br />'.$editIconsHTML:'').'</td>';
979 $editIconsHTML='';
980 $flag=1;
981 }
982 $tablecode.='<td colspan="'.$colspan.'"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$tableWidth.'" height="1" alt="" /></td>';
983 if ($txtMarg && $align=='left') { // If left aligned, the textborder is added on the left side
984 $tablecode.='<td rowspan="'.($rowspan+1).'" valign="top"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$txtMarg.'" height="1" alt="" title="" />'.($editIconsHTML?'<br />'.$editIconsHTML:'').'</td>';
985 $editIconsHTML='';
986 $flag=1;
987 }
988 if ($flag) $tableWidth+=$txtMarg+1;
989 // $tableWidth=0;
990 $tablecode.='</tr>';
991 }
992
993 // draw table
994 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!
995 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.
996 $tablecode.='<tr><td colspan="'.$colspan.'"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$rowspacing.'" border="0" alt="" title="" /></td></tr>';
997 }
998 $tablecode.='<tr>'; // starting row
999 for ($b=0; $b<$colCount_temp; $b++) { // Looping through the columns
1000 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.
1001 if (!$noCols) {
1002 $tablecode.='<td><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$colspacing.'" height="1" border="0" alt="" title="" /></td>';
1003 } else {
1004 $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="" title="" />';
1005 $colSpacer='<td valign="top">'.$colSpacer.'</td>'; // added 160301, needed for the new "noCols"-table...
1006 $tablecode.=$colSpacer;
1007 }
1008 }
1009 if (!$noCols || ($noCols && !$b)) {
1010 $tablecode.='<td valign="top">'; // starting the cell. If "noCols" this cell will hold all images in the row, otherwise only a single image.
1011 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.
1012 }
1013 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.
1014 $imgIndex = $index+$a*$colCount_temp;
1015 if ($imgsTag[$imgIndex]) {
1016 if ($rowspacing && $noRows && $a) { // Puts distance between the images IF "noRows" is set and this is the first iteration of the loop
1017 $tablecode.= '<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$rowspacing.'" alt="" title="" /><br />';
1018 }
1019
1020 $imageHTML = $imgsTag[$imgIndex].'<br />';
1021 $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.
1022 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...)
1023 $imageHTML.=$editIconsHTML; $editIconsHTML='';
1024 if ($conf['netprintApplicationLink']) {$imageHTML = $this->netprintApplication_offsiteLinkWrap($imageHTML,$origImages[$imgIndex],$conf['netprintApplicationLink.']);}
1025 $imageHTML.=$captionArray[$imgIndex]; // Adds caption.
1026 if ($noCols) {$imageHTML='<td valign="top">'.$imageHTML.'</td>';} // If noCols, put in table cell.
1027 $tablecode.=$imageHTML;
1028 }
1029 }
1030 $index++;
1031 if (!$noCols || ($noCols && $b+1==$colCount_temp)) {
1032 if ($noCols) {$tablecode.='</tr></table>';} // In case of "noCols" we must finish the table that surrounds the images in the row.
1033 $tablecode.='</td>'; // Ending the cell. In case of "noCols" the cell holds all pictures!
1034 }
1035 }
1036 $tablecode.='</tr>'; // ending row
1037 }
1038 if ($c) {
1039 // Table-tag is inserted
1040 $i=$contentPosition;
1041 $table_align = (($i==16) ? 'align="'.$align.'"' : '');
1042 $tablecode = '<table'.($tableWidth?' width="'.$tableWidth.'"':'').' border="0" cellspacing="0" cellpadding="0" '.$table_align.' class="imgtext-table">'.$tablecode;
1043 if ($editIconsHTML) { // IF this value is not long since reset.
1044 $tablecode.='<tr><td colspan="'.$colspan.'">'.$editIconsHTML.'</td></tr>';
1045 $editIconsHTML='';
1046 }
1047 if ($cap) {
1048 $tablecode.='<tr><td colspan="'.$colspan.'" align="'.$caption_align.'">'.$caption.'</td></tr>';
1049 }
1050 $tablecode.='</table>';
1051 if ($conf['tableStdWrap.']) {$tablecode=$this->stdWrap($tablecode,$conf['tableStdWrap.']);}
1052 }
1053
1054 $spaceBelowAbove = intval($this->stdWrap($conf['spaceBelowAbove'],$conf['spaceBelowAbove.']));
1055 switch ($contentPosition) {
1056 case '0': // above
1057 $output= '<div align="'.$align.'">'.$tablecode.'</div>'.$this->wrapSpace($content, $spaceBelowAbove.'|0');
1058 break;
1059 case '8': // below
1060 $output= $this->wrapSpace($content, '0|'.$spaceBelowAbove).'<div align="'.$align.'">'.$tablecode.'</div>';
1061 break;
1062 case '16': // in text
1063 $output= $tablecode.$content;
1064 break;
1065 case '24': // in text, no wrap
1066 $theResult = '';
1067 $theResult.= '<table border="0" cellspacing="0" cellpadding="0" class="imgtext-nowrap"><tr>';
1068 if ($align=='right') {
1069 $theResult.= '<td valign="top">'.$content.'</td><td valign="top">'.$tablecode.'</td>';
1070 } else {
1071 $theResult.= '<td valign="top">'.$tablecode.'</td><td valign="top">'.$content.'</td>';
1072 }
1073 $theResult.= '</tr></table>';
1074 $output= $theResult;
1075 break;
1076 }
1077 } else {
1078 $output= $content;
1079 }
1080
1081 if ($conf['stdWrap.']) {
1082 $output = $this->stdWrap($output, $conf['stdWrap.']);
1083 }
1084
1085 return $output;
1086 }
1087
1088 /**
1089 * Rendering the cObject, CONTENT
1090 *
1091 * @param array Array of TypoScript properties
1092 * @return string Output
1093 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=356&cHash=9f3b5c6ba2
1094 */
1095 function CONTENT($conf) {
1096 $theValue='';
1097
1098 $originalRec=$GLOBALS['TSFE']->currentRecord;
1099 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!!
1100 $GLOBALS['TSFE']->recordRegister[md5($originalRec)]++;
1101 }
1102
1103 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_') {
1104
1105 $renderObjName = $conf['renderObj'] ? $conf['renderObj'] : '<'.$conf['table'];
1106 $renderObjKey = $conf['renderObj'] ? 'renderObj' : '';
1107 $renderObjConf = $conf['renderObj.'];
1108
1109 $res = $this->exec_getQuery($conf['table'],$conf['select.']);
1110 if ($error = $GLOBALS['TYPO3_DB']->sql_error()) {
1111 $GLOBALS['TT']->setTSlogMessage($error,3);
1112 } else {
1113 $this->currentRecordTotal = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
1114 $GLOBALS['TT']->setTSlogMessage('NUMROWS: '.$GLOBALS['TYPO3_DB']->sql_num_rows($res));
1115 $cObj =t3lib_div::makeInstance('tslib_cObj');
1116 $cObj->setParent($this->data,$this->currentRecord);
1117 $this->currentRecordNumber=0;
1118 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
1119 if (!$GLOBALS['TSFE']->recordRegister[md5($val['table'].':'.$val['id'])]) {
1120 $this->currentRecordNumber++;
1121 $cObj->parentRecordNumber=$this->currentRecordNumber;
1122 $GLOBALS['TSFE']->currentRecord=$conf['table'].':'.$row['uid'];
1123 $this->lastChanged($row['tstamp']);
1124 $cObj->start($row,$conf['table']);
1125 if ($GLOBALS['TSFE']->config['config']['insertDmailerBoundaries']) {$theValue.='<!--DMAILER_SECTION_BOUNDARY_'.intval($row['module_sys_dmail_category']).'-->';}
1126 $theValue.=$cObj->cObjGetSingle($renderObjName, $renderObjConf, $renderObjKey);
1127 } else {debug($val['table'].':'.$val['id']);}
1128 }
1129 if ($GLOBALS['TSFE']->config['config']['insertDmailerBoundaries']) {$theValue.='<!--DMAILER_SECTION_BOUNDARY_END-->';}
1130 }
1131 }
1132
1133 $theValue = $this->wrap($theValue,$conf['wrap']);
1134 if ($conf['stdWrap.']) $theValue = $this->stdWrap($theValue,$conf['stdWrap.']);
1135 $GLOBALS['TSFE']->currentRecord=$originalRec;
1136 return $theValue;
1137 }
1138
1139 /**
1140 * Rendering the cObject, RECORDS
1141 *
1142 * @param array Array of TypoScript properties
1143 * @return string Output
1144 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=357&cHash=303e959472
1145 */
1146 function RECORDS($conf) {
1147 $theValue='';
1148
1149 $originalRec=$GLOBALS['TSFE']->currentRecord;
1150 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!!
1151 $GLOBALS['TSFE']->recordRegister[md5($originalRec)]++;
1152 }
1153
1154 $conf['source'] = $this->stdWrap($conf['source'],$conf['source.']);
1155 if ($conf['tables'] && $conf['source']) {
1156 $allowedTables = $conf['tables'];
1157 if (is_array($conf['conf.'])) {
1158 reset($conf['conf.']);
1159 while(list($k)=each($conf['conf.'])) {
1160 if (substr($k,-1)!='.') $allowedTables.=','.$k;
1161 }
1162 }
1163
1164 $loadDB = t3lib_div::makeInstance('FE_loadDBGroup');
1165 $loadDB->start($conf['source'], $allowedTables);
1166 reset($loadDB->tableArray);
1167 while(list($table,)=each($loadDB->tableArray)) {
1168 if (is_array($GLOBALS['TCA'][$table])) {
1169 $loadDB->additionalWhere[$table]=$this->enableFields($table);
1170 }
1171 }
1172 $loadDB->getFromDB();
1173
1174 reset($loadDB->itemArray);
1175 $data = $loadDB->results;
1176
1177 $cObj =t3lib_div::makeInstance('tslib_cObj');
1178 $cObj->setParent($this->data,$this->currentRecord);
1179 $this->currentRecordNumber=0;
1180 $this->currentRecordTotal = count($loadDB->itemArray);
1181 reset($loadDB->itemArray);
1182 while(list(,$val)=each($loadDB->itemArray)) {
1183 $row = $data[$val['table']][$val['id']];
1184 if (!$conf['dontCheckPid']) {
1185 $row = $this->checkPid($row['pid']) ? $row : '';
1186 }
1187 if ($row && !$GLOBALS['TSFE']->recordRegister[md5($val['table'].':'.$val['id'])]) {
1188 $renderObjName = $conf['conf.'][$val['table']] ? $conf['conf.'][$val['table']] : '<'.$val['table'];
1189 $renderObjKey = $conf['conf.'][$val['table']] ? 'conf.'.$val['table'] : '';
1190 $renderObjConf = $conf['conf.'][$val['table'].'.'];
1191 $this->currentRecordNumber++;
1192 $cObj->parentRecordNumber=$this->currentRecordNumber;
1193 $GLOBALS['TSFE']->currentRecord=$val['table'].':'.$val['id'];
1194 $this->lastChanged($row['tstamp']);
1195 $cObj->start($row,$val['table']);
1196 if ($GLOBALS['TSFE']->config['config']['insertDmailerBoundaries']) {$theValue.='<!--DMAILER_SECTION_BOUNDARY_'.intval($row['module_sys_dmail_category']).'-->';}
1197 $theValue.=$cObj->cObjGetSingle($renderObjName, $renderObjConf, $renderObjKey);
1198 if ($GLOBALS['TSFE']->config['config']['insertDmailerBoundaries']) {$theValue.='<!--DMAILER_SECTION_BOUNDARY_END-->';}
1199 }
1200 }
1201 }
1202 $GLOBALS['TSFE']->currentRecord=$originalRec;
1203 return $this->wrap($theValue,$conf['wrap']);
1204 }
1205
1206 /**
1207 * Rendering the cObject, HMENU
1208 *
1209 * @param array Array of TypoScript properties
1210 * @return string Output
1211 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=358&cHash=5400c1c06a
1212 */
1213 function HMENU($conf) {
1214 $content='';
1215 if ($this->checkIf($conf['if.'])) {
1216 $cls=strtolower($conf[1]);
1217 if (t3lib_div::inList($GLOBALS['TSFE']->tmpl->menuclasses,$cls)) {
1218 if ($conf['special.']['value.']) {
1219 $conf['special.']['value'] = $this->stdWrap($conf['special.']['value'],$conf['special.']['value.']);
1220 }
1221 $GLOBALS['TSFE']->register['count_HMENU']++;
1222 $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ']=0;
1223 $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid']=array();
1224 $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMparentId']=array();
1225
1226 $menu = t3lib_div::makeInstance('tslib_'.$cls);
1227 $menu->parent_cObj = $this;
1228 $menu->start($GLOBALS['TSFE']->tmpl,$GLOBALS['TSFE']->sys_page,'',$conf,1);
1229 $menu->makeMenu();
1230 $content.=$menu->writeMenu();
1231 }
1232 if ($conf['wrap']) $content=$this->wrap($content, $conf['wrap']);
1233 if ($conf['stdWrap.']) $content = $this->stdWrap($content, $conf['stdWrap.']);
1234 }
1235 return $content;
1236 }
1237
1238 /**
1239 * Rendering the cObject, CTABLE
1240 *
1241 * @param array Array of TypoScript properties
1242 * @return string Output
1243 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=359&cHash=2e0065b4e7
1244 */
1245 function CTABLE ($conf) {
1246 $controlTable = t3lib_div::makeInstance('tslib_controlTable');
1247 if ($conf['tableParams']) {
1248 $controlTable->tableParams = $conf['tableParams'];
1249 }
1250 // loads the pagecontent
1251 $controlTable->contentW = $conf['cWidth'];
1252 // loads the menues if any
1253 if (is_array($conf['c.'])) {
1254 $controlTable->content = $this->cObjGet($conf['c.'],'c.');
1255 $controlTable->contentTDparams = isset($conf['c.']['TDParams']) ? $conf['c.']['TDParams'] : 'valign="top"';
1256 }
1257 if (is_array($conf['lm.'])) {
1258 $controlTable->lm = $this->cObjGet($conf['lm.'],'lm.');
1259 $controlTable->lmTDparams = isset($conf['lm.']['TDParams']) ? $conf['lm.']['TDParams'] : 'valign="top"';
1260 }
1261 if (is_array($conf['tm.'])) {
1262 $controlTable->tm = $this->cObjGet($conf['tm.'],'tm.');
1263 $controlTable->tmTDparams = isset($conf['tm.']['TDParams']) ? $conf['tm.']['TDParams'] : 'valign="top"';
1264 }
1265 if (is_array($conf['rm.'])) {
1266 $controlTable->rm = $this->cObjGet($conf['rm.'],'rm.');
1267 $controlTable->rmTDparams = isset($conf['rm.']['TDParams']) ? $conf['rm.']['TDParams'] : 'valign="top"';
1268 }
1269 if (is_array($conf['bm.'])) {
1270 $controlTable->bm = $this->cObjGet($conf['bm.'],'bm.');
1271 $controlTable->bmTDparams = isset($conf['bm.']['TDParams']) ? $conf['bm.']['TDParams'] : 'valign="top"';
1272 }
1273 return $controlTable->start($conf['offset'],$conf['cMargins']);
1274 }
1275
1276 /**
1277 * Rendering the cObject, OTABLE
1278 *
1279 * @param array Array of TypoScript properties
1280 * @return string Output
1281 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=360&cHash=02c9552d38
1282 */
1283 function OTABLE ($conf) {
1284 $controlTable = t3lib_div::makeInstance('tslib_tableOffset');
1285 if ($conf['tableParams']) {
1286 $controlTable->tableParams = $conf['tableParams'];
1287 }
1288 return $controlTable->start($this->cObjGet($conf),$conf['offset']);
1289 }
1290
1291 /**
1292 * Rendering the cObject, COLUMNS
1293 *
1294 * @param array Array of TypoScript properties
1295 * @return string Output
1296 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=361&cHash=7e4e228cad
1297 */
1298 function COLUMNS ($conf) {
1299 $content='';
1300 if (is_array($conf) && $this->checkIf($conf['if.'])) {
1301 $tdRowCount=0;
1302 $tableParams = $conf['tableParams'] ? ' '.$conf['tableParams'] : ' border="0" cellspacing="0" cellpadding="0"';
1303 $TDparams = $conf['TDparams'] ? ' '.$conf['TDparams']:' valign="top"';
1304 $rows = t3lib_div::intInRange($conf['rows'],2,20);
1305 $totalWidth = intval($conf['totalWidth']);
1306 $columnWidth=0;
1307
1308 $totalGapWidth=0;
1309 $gapData = Array(
1310 'gapWidth' => $this->stdWrap($conf['gapWidth'],$conf['gapWidth.']),
1311 'gapBgCol' => $this->stdWrap($conf['gapBgCol'],$conf['gapBgCol.']),
1312 'gapLineThickness' => $this->stdWrap($conf['gapLineThickness'],$conf['gapLineThickness.']),
1313 'gapLineCol' => $this->stdWrap($conf['gapLineCol'],$conf['gapLineCol.'])
1314 );
1315 $gapData = $GLOBALS['TSFE']->tmpl->splitConfArray($gapData,$rows-1);
1316 reset($gapData);
1317 while(list(,$val)=each($gapData)) {
1318 $totalGapWidth+=intval($val['gapWidth']);
1319 }
1320
1321 if ($totalWidth) {
1322 $columnWidth = ceil(($totalWidth-$totalGapWidth)/$rows);
1323 $TDparams.=' width="'.$columnWidth.'"';
1324 $tableParams.=' width="'.$totalWidth.'"';
1325 } else {
1326 $TDparams.=' width="'.floor(100/$rows).'%"';
1327 $tableParams.=' width="100%"';
1328 }
1329
1330 for ($a=1;$a<=$rows;$a++) {
1331 $tdRowCount++;
1332 $content.='<td'.$TDparams.'>';
1333 $content.=$this->cObjGetSingle($conf[$a],$conf[$a.'.'], $a);
1334 $content.='</td>';
1335 if ($a < $rows) {
1336 $gapConf = $gapData[($a-1)];
1337 $gapWidth = intval($gapConf['gapWidth']);
1338 if ($gapWidth) {
1339 $tdPar = $gapConf['gapBgCol'] ? ' bgcolor="'.$gapConf['gapBgCol'].'"' : '';
1340 $gapLine = intval($gapConf['gapLineThickness']);
1341 if ($gapLine) {
1342 $gapSurround = t3lib_div::intInRange(($gapWidth-$gapLine)/2, 1, 1000);
1343 // right gap
1344 $content.='<td'.$tdPar.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$gapSurround.'" height="1" alt="" title="" /></td>';
1345 $tdRowCount++;
1346 // line:
1347 $GtdPar = $gapConf['gapLineCol'] ? ' bgcolor="'.$gapConf['gapLineCol'].'"' : ' bgcolor="black"';
1348 $content.='<td'.$GtdPar.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$gapLine.'" height="1" alt="" title="" /></td>';
1349 $tdRowCount++;
1350 // left gap
1351 $content.='<td'.$tdPar.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$gapSurround.'" height="1" alt="" title="" /></td>';
1352 $tdRowCount++;
1353 } else {
1354 $content.='<td'.$tdPar.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$gapWidth.'" height="1" alt="" title="" /></td>';
1355 $tdRowCount++;
1356 }
1357 }
1358 }
1359 }
1360 $content='<tr>'.$content.'</tr>';
1361 $content='<table'.$tableParams.'>'.$content.'</table>';
1362 $content.=$this->cObjGetSingle($conf['after'],$conf['after.'], 'after');
1363 if ($conf['stdWrap.']) {
1364 $content = $this->stdWrap($content,$conf['stdWrap.']);
1365 }
1366 }
1367 return $content;
1368 }
1369
1370 /**
1371 * Rendering the cObject, HRULER
1372 *
1373 * @param array Array of TypoScript properties
1374 * @return string Output
1375 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=362&cHash=2a462aa084
1376 */
1377 function HRULER ($conf) {
1378 $lineThickness = t3lib_div::intInRange($this->stdWrap($conf['lineThickness'],$conf['lineThickness.']),1,50);
1379 $lineColor = $conf['lineColor'] ? $conf['lineColor'] : 'black';
1380 $spaceBefore = intval($conf['spaceLeft']);
1381 $spaceAfter = intval($conf['spaceRight']);
1382 $tableWidth = $conf['tableWidth'] ? $conf['tableWidth'] : '99%';
1383 $content='';
1384
1385 $content.='<table border="0" cellspacing="0" cellpadding="0" width="'.htmlspecialchars($tableWidth).'"><tr>';
1386 if ($spaceBefore) {$content.='<td width="1"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$spaceBefore.'" height="1" alt="" title="" /></td>'; }
1387 $content.='<td bgcolor="'.$lineColor.'"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$lineThickness.'" alt="" title="" /></td>';
1388 if ($spaceAfter) {$content.='<td width="1"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$spaceAfter.'" height="1" alt="" title="" /></td>'; }
1389 $content.='</tr></table>';
1390
1391 $content = $this->stdWrap($content, $conf['stdWrap.']);
1392 return $content;
1393 }
1394
1395 /**
1396 * Rendering the cObject, CASE
1397 *
1398 * @param array Array of TypoScript properties
1399 * @return string Output
1400 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=364&cHash=cffedd09e3
1401 */
1402 function CASEFUNC ($conf){
1403 $content='';
1404 if ($this->checkIf($conf['if.'])) {
1405 if ($conf['setCurrent'] || $conf['setCurrent.']){$this->data[$this->currentValKey] = $this->stdWrap($conf['setCurrent'], $conf['setCurrent.']);}
1406 $key = $this->stdWrap($conf['key'],$conf['key.']);
1407 $key = $conf[$key] ? $key : 'default';
1408 $name = $conf[$key];
1409 $theValue = $this->cObjGetSingle($name,$conf[$key.'.'], $key);
1410 if ($conf['stdWrap.']) {
1411 $theValue = $this->stdWrap($theValue,$conf['stdWrap.']);
1412 }
1413 return $theValue;
1414 }
1415 }
1416
1417 /**
1418 * Rendering the cObject, LOAD_REGISTER and RESTORE_REGISTER
1419 * NOTICE: This cObject does NOT return any content since it just sets internal data based on the TypoScript properties.
1420 *
1421 * @param array Array of TypoScript properties
1422 * @param string If "RESTORE_REGISTER" then the cObject rendered is "RESTORE_REGISTER", otherwise "LOAD_REGISTER"
1423 * @return string Empty string (the cObject only sets internal data!)
1424 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=365&cHash=4935524e2e
1425 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=366&cHash=4f9485e8cc
1426 */
1427 function LOAD_REGISTER($conf,$name) {
1428 if ($name=='RESTORE_REGISTER') {
1429 $GLOBALS['TSFE']->register = array_pop($GLOBALS['TSFE']->registerStack);
1430 } else {
1431 array_push($GLOBALS['TSFE']->registerStack,$GLOBALS['TSFE']->register);
1432 if (is_array($conf)) {
1433 reset($conf);
1434 while(list($theKey,$theValue)=each($conf)) {
1435 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
1436 if (strstr($theKey,'.')) {
1437 $theKey = substr($theKey,0,-1);
1438 }
1439 $GLOBALS['TSFE']->register[$theKey] = $this->stdWrap($conf[$theKey],$conf[$theKey.'.']);
1440 }
1441 }
1442 }
1443 }
1444 return '';
1445 }
1446
1447 /**
1448 * Rendering the cObject, FORM
1449 *
1450 * Note on $formData:
1451 * In the optional $formData array each entry represents a line in the ordinary setup.
1452 * In those entries each entry (0,1,2...) represents a space normally divided by the '|' line.
1453 *
1454 * $formData [] = array('Name:', 'name=input, 25 ', 'Default value....');
1455 * $formData [] = array('Email:', 'email=input, 25 ', 'Default value for email....');
1456 *
1457 * - corresponds to the $conf['data'] value being :
1458 * Name:|name=input, 25 |Default value....||Email:|email=input, 25 |Default value for email....
1459 *
1460 * If $formData is an array the value of $conf['data'] is ignored.
1461 *
1462 * @param array Array of TypoScript properties
1463 * @param array Alternative formdata overriding whatever comes from TypoScript
1464 * @return string Output
1465 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=367&cHash=bbc518d930
1466 */
1467 function FORM($conf,$formData='') {
1468 $content='';
1469 if (is_array($formData)) {
1470 $dataArr = $formData;
1471 } else {
1472 $data=$this->stdWrap($conf['data'],$conf['data.']);
1473 // Clearing dataArr
1474 $dataArr=array();
1475 // Getting the original config
1476 if (trim($data)) {
1477 $data = ereg_replace(chr(10),'||',$data);
1478 $dataArr = explode('||',$data);
1479 }
1480 // Adding the new dataArray config form:
1481 if (is_array($conf['dataArray.'])) { // dataArray is supplied
1482 reset($conf['dataArray.']);
1483 while(list($dAKey,$dAA)=each($conf['dataArray.'])) {
1484 if (is_array($dAA) && !strcmp(intval($dAKey).'.',$dAKey)) {
1485 $temp=array();
1486 list($temp[0])= explode('|',$dAA['label.'] ? $this->stdWrap($dAA['label'],$dAA['label.']) : $dAA['label']);
1487 list($temp[1])= explode('|',$dAA['type']);
1488 if ($dAA['required']) {$temp[1]='*'.$temp[1];}
1489 list($temp[2])= explode('|',$dAA['value.'] ? $this->stdWrap($dAA['value'],$dAA['value.']) : $dAA['value']);
1490 // If value Array is set, then implode those values.
1491 if (is_array($dAA['valueArray.'])) {
1492 reset($dAA['valueArray.']);
1493 $temp_accum = array();
1494 while(list($dAKey_vA,$dAA_vA)=each($dAA['valueArray.'])) {
1495 if (is_array($dAA_vA) && !strcmp(intval($dAKey_vA).'.',$dAKey_vA)) {
1496 $temp_vA=array();
1497 list($temp_vA[0])= explode('=',$dAA_vA['label.'] ? $this->stdWrap($dAA_vA['label'],$dAA_vA['label.']) : $dAA_vA['label']);
1498 if ($dAA_vA['selected']) {$temp_vA[0]='*'.$temp_vA[0];}
1499 list($temp_vA[1])= explode(',',$dAA_vA['value']);
1500 }
1501 $temp_accum[] = implode('=',$temp_vA);
1502 }
1503 $temp[2] = implode(',',$temp_accum);
1504 }
1505 // adding the form entry to the dataArray
1506 $dataArr[] = implode('|',$temp);
1507 }
1508 }
1509 }
1510 }
1511 $attachmentCounter='';
1512 $hiddenfields='';
1513 $fieldlist=Array();
1514 $propertyOverride = Array();
1515 $fieldname_hashArray = Array();
1516 $cc=0;
1517 reset($dataArr);
1518 while(list(,$val)=each($dataArr)) {
1519 $cc++;
1520 $confData=Array();
1521 if (is_array($formData)) {
1522 $parts = $val;
1523 $val=1; // true...
1524 } else {
1525 $val=trim($val);
1526 $parts = explode('|',$val);
1527 }
1528 if ($val && strcspn($val,'#/')) {
1529 // label:
1530 $confData['label'] = trim($parts[0]);
1531 // field:
1532 $fParts = explode(',',$parts[1]);
1533 $fParts[0]=trim($fParts[0]);
1534 if (substr($fParts[0],0,1)=='*') {
1535 $confData['required']=1;
1536 $fParts[0] = substr($fParts[0],1);
1537 }
1538 $typeParts = explode('=',$fParts[0]);
1539 $confData['type'] = trim(strtolower(end($typeParts)));
1540 if (count($typeParts)==1) {
1541 $confData['fieldname'] = substr(ereg_replace('[^a-zA-Z0-9_]','',str_replace(' ','_',trim($parts[0]))),0,30);
1542 if (strtolower(ereg_replace('[^[:alnum:]]','',$confData['fieldname']))=='email') {$confData['fieldname']='email';}
1543 // Duplicate fieldnames resolved
1544 if (isset($fieldname_hashArray[md5($confData['fieldname'])])) {
1545 $confData['fieldname'].='_'.$cc;
1546 }
1547 $fieldname_hashArray[md5($confData['fieldname'])]=$confData['fieldname'];
1548 // Attachment names...
1549 if ($confData['type']=='file') {
1550 $confData['fieldname']='attachment'.$attachmentCounter;
1551 $attachmentCounter=intval($attachmentCounter)+1;
1552 }
1553 } else {
1554 $confData['fieldname'] = str_replace(' ','_',trim($typeParts[0]));
1555 }
1556 $fieldCode='';
1557
1558
1559 if ($conf['wrapFieldName']) {
1560 $confData['fieldname'] = $this->wrap($confData['fieldname'],$conf['wrapFieldName']);
1561 }
1562
1563 // Additional parameters
1564 if (trim($confData['type'])) {
1565 $addParams=trim($conf['params']);
1566 if (is_array($conf['params.']) && isset($conf['params.'][$confData['type']])) {
1567 $addParams=trim($conf['params.'][$confData['type']]);
1568 }
1569 if (strcmp('',$addParams)) $addParams=' '.$addParams;
1570 } else $addParams='';
1571
1572 switch($confData['type']) {
1573 case 'textarea':
1574 $cols=trim($fParts[1]) ? intval($fParts[1]) : 20;
1575 $compWidth = doubleval($conf['compensateFieldWidth'] ? $conf['compensateFieldWidth'] : $GLOBALS['TSFE']->compensateFieldWidth);
1576 $compWidth = $compWidth ? $compWidth : 1;
1577 $cols = t3lib_div::intInRange($cols*$compWidth, 1, 120);
1578
1579 $rows=trim($fParts[2]) ? t3lib_div::intInRange($fParts[2],1,30) : 5;
1580 $wrap=trim($fParts[3]) ? ' wrap="'.trim($fParts[3]).'"' : ' wrap="virtual"';
1581 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], trim($parts[2]));
1582 $fieldCode=sprintf('<textarea name="%s" cols="%s" rows="%s"%s'.$addParams.'>%s</textarea>',
1583 $confData['fieldname'], $cols, $rows, $wrap, t3lib_div::formatForTextarea($default));
1584 break;
1585 case 'input':
1586 case 'password':
1587 $size=trim($fParts[1]) ? intval($fParts[1]) : 20;
1588 $compWidth = doubleval($conf['compensateFieldWidth'] ? $conf['compensateFieldWidth'] : $GLOBALS['TSFE']->compensateFieldWidth);
1589 $compWidth = $compWidth ? $compWidth : 1;
1590 $size = t3lib_div::intInRange($size*$compWidth, 1, 120);
1591 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], trim($parts[2]));
1592 if ($confData['type']=='password') {
1593 $default='';
1594 }
1595
1596 $max=trim($fParts[2]) ? ' maxlength="'.t3lib_div::intInRange($fParts[2],1,1000).'"' : "";
1597 $theType = $confData['type']=='input' ? 'text' : 'password';
1598
1599 $fieldCode=sprintf('<input type="'.$theType.'" name="%s" size="%s"%s value="%s"'.$addParams.' />',
1600 $confData['fieldname'], $size, $max, htmlspecialchars($default));
1601 break;
1602 case 'file':
1603 $size=trim($fParts[1]) ? t3lib_div::intInRange($fParts[1],1,60) : 20;
1604 $fieldCode=sprintf('<input type="file" name="%s" size="%s"'.$addParams.' />',
1605 $confData['fieldname'], $size);
1606 break;
1607 case 'check':
1608 // alternative default value:
1609 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], trim($parts[2]));
1610 $checked = $default ? ' checked="checked"' : '';
1611 $fieldCode=sprintf('<input type="checkbox" value="%s" name="%s"%s'.$addParams.' />',
1612 1, $confData['fieldname'], $checked);
1613 break;
1614 case 'select':
1615 $option='';
1616 $valueParts = explode(',',$parts[2]);
1617 // size
1618 if (strtolower(trim($fParts[1]))=='auto') {$fParts[1]=count($valueParts);} // Auto size set here. Max 20
1619 $size=trim($fParts[1]) ? t3lib_div::intInRange($fParts[1],1,20) : 1;
1620 // multiple
1621 $multiple = strtolower(trim($fParts[2]))=='m' ? ' multiple="multiple"' : '';
1622
1623 $items=array(); // Where the items will be
1624 $defaults=array(); //RTF
1625 for($a=0;$a<count($valueParts);$a++) {
1626 $valueParts[$a]=trim($valueParts[$a]);
1627 if (substr($valueParts[$a],0,1)=='*') { // Finding default value
1628 $sel='selected';
1629 $valueParts[$a] = substr($valueParts[$a],1);
1630 } else $sel='';
1631 // Get value/label
1632 $subParts=explode('=',$valueParts[$a]);
1633 $subParts[1] = (isset($subParts[1])?trim($subParts[1]):trim($subParts[0])); // Sets the value
1634 $items[] = $subParts; // Adds the value/label pair to the items-array
1635 if ($sel) {$defaults[]=$subParts[1];} // Sets the default value if value/label pair is marked as default.
1636 }
1637 // alternative default value:
1638 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], $defaults);
1639 if (!is_array($default)) {
1640 $defaults=array();
1641 $defaults[] = $default;
1642 } else $defaults=$default;
1643 // Create the select-box:
1644 for($a=0;$a<count($items);$a++) {
1645 $option.='<option value="'.$items[$a][1].'"'.(in_array($items[$a][1],$defaults)?' selected="selected"':'').'>'.trim($items[$a][0]).'</option>'; //RTF
1646 }
1647
1648 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.
1649 $fieldCode=sprintf('<select name="%s" size="%s"%s'.$addParams.'>%s</select>',
1650 $confData['fieldname'], $size, $multiple, $option); //RTF
1651 break;
1652 case 'radio':
1653 $option='';
1654 $valueParts = explode(',',$parts[2]);
1655 $items=array(); // Where the items will be
1656 $default='';
1657 for($a=0;$a<count($valueParts);$a++) {
1658 $valueParts[$a]=trim($valueParts[$a]);
1659 if (substr($valueParts[$a],0,1)=='*') {
1660 $sel='checked';
1661 $valueParts[$a] = substr($valueParts[$a],1);
1662 } else $sel='';
1663 // Get value/label
1664 $subParts=explode('=',$valueParts[$a]);
1665 $subParts[1] = (isset($subParts[1])?trim($subParts[1]):trim($subParts[0])); // Sets the value
1666 $items[] = $subParts; // Adds the value/label pair to the items-array
1667 if ($sel) {$default=$subParts[1];} // Sets the default value if value/label pair is marked as default.
1668 }
1669 // alternative default value:
1670 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], $default);
1671 // Create the select-box:
1672 for($a=0;$a<count($items);$a++) {
1673 $option.= '<input type="radio" name="'.$confData['fieldname'].'" value="'.$items[$a][1].'"'.(!strcmp($items[$a][1],$default)?' checked="checked"':'').''.$addParams.' />';
1674 $option.= $this->stdWrap(trim($items[$a][0]), $conf['radioWrap.']);
1675 $option.= '<br />';
1676 }
1677 $fieldCode=$option;
1678 break;
1679 case 'hidden':
1680 $value=trim($parts[2]);
1681 $hiddenfields.=sprintf('<input type="hidden" name="%s" value="%s" />',
1682 $confData['fieldname'], $value);
1683 break;
1684 case 'property':
1685 if (t3lib_div::inList('type,locationData,goodMess,badMess',$confData['fieldname'])) {
1686 $value=trim($parts[2]);
1687 $propertyOverride[$confData['fieldname']] = $value;
1688 $conf[$confData['fieldname']] = $value;
1689 }
1690 break;
1691 case 'submit':
1692 $value=trim($parts[2]);
1693 if ($conf['image.']) {
1694 $this->data[$this->currentValKey]=$value;
1695 $image=$this->IMAGE($conf['image.']);
1696 } else $image='';
1697 if($image) {
1698 $fieldCode = str_replace('<img','<input type="image"'.$addParams.' name="'.$confData['fieldname'].'"' ,$image);
1699 } else {
1700 $fieldCode=sprintf('<input type="submit" name="%s" value="%s"'.$addParams.' />',
1701 $confData['fieldname'], t3lib_div::deHSCentities(htmlspecialchars($value)));
1702 }
1703 break;
1704 default:
1705 $confData['type']='comment';
1706 $fieldCode=trim($parts[2]).'&nbsp;';
1707 break;
1708 }
1709 if ($fieldCode) {
1710 $fieldCode = $this->stdWrap($fieldCode, $conf['fieldWrap.']);
1711 $labelCode = $this->stdWrap($confData['label'], $conf['labelWrap.']);
1712 $commentCode = $this->stdWrap($confData['label'], $conf['commentWrap.']); // RTF
1713 $result = $conf['layout'];
1714 if ($conf['REQ'] && $confData['required']) {
1715 if (is_array($conf['REQ.']['fieldWrap.']))
1716 $fieldCode = $this->stdWrap($fieldCode, $conf['REQ.']['fieldWrap.']);
1717 if (is_array($conf['REQ.']['labelWrap.']))
1718 $labelCode = $this->stdWrap($confData['label'], $conf['REQ.']['labelWrap.']);
1719 if ($conf['REQ.']['layout']) {
1720 $result = $conf['REQ.']['layout'];
1721 }
1722 }
1723 if ($confData['type']=='comment' && $conf['COMMENT.']['layout']) {
1724 $result = $conf['COMMENT.']['layout'];
1725 }
1726 if ($confData['type']=='check' && $conf['CHECK.']['layout']) {
1727 $result = $conf['CHECK.']['layout'];
1728 }
1729 if ($confData['type']=='radio' && $conf['RADIO.']['layout']) {
1730 $result = $conf['RADIO.']['layout'];
1731 }
1732 $result = str_replace('###FIELD###',$fieldCode,$result);
1733 $result = str_replace('###LABEL###',$labelCode,$result);
1734 $result = str_replace('###COMMENT###',$commentCode,$result); //RTF
1735 $content.=$result;
1736 // Required:
1737 if ($confData['required'] && $confData['type']!='check') {
1738 $fieldlist[]=rawurlencode($confData['fieldname']);
1739 $fieldlist[]=rawurlencode($confData['label']);
1740 }
1741 }
1742 }
1743 }
1744 if ($conf['stdWrap.']) $content=$this->stdWrap($content, $conf['stdWrap.']);
1745
1746
1747 // redirect (external: where to go afterwards. internal: where to submit to)
1748 $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)
1749 $page=$GLOBALS['TSFE']->page;
1750 if (!$theRedirect) { // Internal: Just submit to current page
1751 $LD=$GLOBALS['TSFE']->tmpl->linkData($page, $conf['target'], $conf['no_cache'],'index.php');
1752 } elseif (t3lib_div::testInt($theRedirect)) { // Internal: Submit to page with id $theRedirect
1753 $page = $GLOBALS['TSFE']->sys_page->getPage_noCheck($theRedirect);
1754 $LD=$GLOBALS['TSFE']->tmpl->linkData($page, $conf['target'], $conf['no_cache'],'index.php');
1755 } else { // External url, redirect-hidden field is rendered!
1756 $LD=$GLOBALS['TSFE']->tmpl->linkData($page, $conf['target'], $conf['no_cache'],'');
1757 $LD['totalURL']=$theRedirect;
1758 $hiddenfields.='<input type="hidden" name="redirect" value="'.htmlspecialchars($LD['totalURL']).'" />'; // 18-09-00 added
1759 }
1760
1761 // Formtype (where to submit to!):
1762 $formtype = $propertyOverride['type'] ? $propertyOverride['type'] : $this->stdWrap($conf['type'], $conf['type.']);
1763 if (t3lib_div::testInt($formtype)) { // Submit to a specific page
1764 $page = $GLOBALS['TSFE']->sys_page->getPage_noCheck($formtype);
1765 $LD_A=$GLOBALS['TSFE']->tmpl->linkData($page,$conf['target'],$conf['no_cache'],'');
1766 $action=$LD_A['totalURL'];
1767 } elseif ($formtype){ // Submit to external script
1768 $LD_A=$LD;
1769 $action = $formtype;
1770 } elseif (t3lib_div::testInt($theRedirect)) {
1771 $LD_A=$LD;
1772 $action=$LD_A['totalURL'];
1773 } else { // Submit to 'nothing' - which is current page
1774 $LD_A=$GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page,$conf['target'],$conf['no_cache'],'');
1775 $action=$LD_A['totalURL'];
1776 }
1777
1778 // copyemail:
1779 $theEmail = $this->stdWrap($conf['recipient'], $conf['recipient.']);
1780 if ($theEmail) {
1781 $hiddenfields.='<input type="hidden" name="recipient" value="'.htmlspecialchars($theEmail).'" />';
1782 }
1783
1784 // location data:
1785 if ($conf['locationData']) {
1786 if ($conf['locationData']=='HTTP_POST_VARS' && isset($GLOBALS['HTTP_POST_VARS']['locationData'])) {
1787 $locationData = t3lib_div::_POST('locationData');
1788 } else {
1789 $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.
1790 }
1791 $hiddenfields.='<input type="hidden" name="locationData" value="'.htmlspecialchars($locationData).'" />';
1792 }
1793
1794 // hidden fields:
1795 if (is_array($conf['hiddenFields.'])) {
1796 reset($conf['hiddenFields.']);
1797 while(list($hF_key,$hF_conf)=each($conf['hiddenFields.'])) {
1798 if (substr($hF_key,-1)!='.') {
1799 $hF_value = $this->cObjGetSingle($hF_conf,$conf['hiddenFields.'][$hF_key.'.'],'hiddenfields');
1800 $hiddenfields.='<input type="hidden" name="'.$hF_key.'" value="'.htmlspecialchars($hF_value).'" />';
1801 }
1802 }
1803 }
1804
1805 // Formname;
1806 $formname = $GLOBALS['TSFE']->uniqueHash();
1807 if ($conf['REQ']) {
1808 $validateForm=' onsubmit="return validateForm(\''.$formname.'\',\''.implode($fieldlist,',').'\',\''.rawurlencode($conf['goodMess']).'\',\''.rawurlencode($conf['badMess']).'\')"';
1809 $GLOBALS['TSFE']->additionalHeaderData['JSFormValidate'] = '<script type="text/javascript" src="'.$GLOBALS['TSFE']->absRefPrefix.'t3lib/jsfunc.validateform.js"></script>';
1810 } else $validateForm='';
1811
1812 // Create form tag:
1813 $theTarget = ($theRedirect?$LD['target']:$LD_A['target']);
1814 $content = Array(
1815 '<form'.
1816 ' action="'.htmlspecialchars($action).'"'.
1817 ' name="'.$formname.'"'.
1818 ' enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'"'.
1819 ' method="'.($conf['method']?$conf['method']:'post').'"'.
1820 ($theTarget ? ' target="'.$theTarget.'"' : '').
1821 $validateForm.
1822 '>',
1823 $hiddenfields.$content,
1824 '</form>'
1825 );
1826 if ($conf['arrayReturnMode']) {
1827 $content['validateForm']=$validateForm;
1828 $content['formname']=$formname;
1829 return $content;
1830 } else {
1831 return implode('',$content);
1832 }
1833 }
1834
1835 /**
1836 * Rendering the cObject, SEARCHRESULT
1837 *
1838 * @param array Array of TypoScript properties
1839 * @return string Output
1840 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=368&cHash=d00731cd7b
1841 */
1842 function SEARCHRESULT($conf) {
1843 if (t3lib_div::_GP('sword') && t3lib_div::_GP('scols')) {
1844 $search = t3lib_div::makeInstance('tslib_search');
1845 $search->register_and_explode_search_string(t3lib_div::_GP('sword'));
1846 $search->register_tables_and_columns(t3lib_div::_GP('scols'),$conf['allowedCols']);
1847 // depth
1848 $depth=100;
1849 // the startId is found
1850 $theStartId=0;
1851 if (t3lib_div::testInt(t3lib_div::_GP('stype'))) {
1852 $temp_theStartId=t3lib_div::_GP('stype');
1853 $rootLine = $GLOBALS['TSFE']->sys_page->getRootLine($temp_theStartId);
1854 // The page MUST have a rootline with the Level0-page of the current site inside!!
1855 while(list(,$val)=each($rootLine)) {
1856 if($val['uid']==$GLOBALS['TSFE']->tmpl->rootLine[0]['uid']) {
1857 $theStartId=$temp_theStartId;
1858 }
1859 }
1860 } else if (t3lib_div::_GP('stype')) {
1861 if (substr(t3lib_div::_GP('stype'),0,1)=='L') {
1862 $pointer = intval(substr(t3lib_div::_GP('stype'),1));
1863 $theRootLine = $GLOBALS['TSFE']->tmpl->rootLine;
1864 // location Data:
1865 $locDat_arr = explode(':',t3lib_div::_POST('locationData'));
1866 $pId = intval($locDat_arr[0]);
1867 if ($pId) {
1868 $altRootLine = $GLOBALS['TSFE']->sys_page->getRootLine($pId);
1869 ksort($altRootLine);
1870 if (count($altRootLine)) {
1871 // check if the rootline has the real Level0 in it!!
1872 reset($altRootLine);
1873 $hitRoot=0;
1874 $theNewRoot=array();
1875 while(list(,$val)=each($altRootLine)) {
1876 if($hitRoot || $val['uid']==$GLOBALS['TSFE']->tmpl->rootLine[0]['uid']) {
1877 $hitRoot=1;
1878 $theNewRoot[]=$val;
1879 }
1880 }
1881 if ($hitRoot) {
1882 $theRootLine = $theNewRoot; // Override the real rootline if any thing
1883 }
1884 }
1885 }
1886 $key = $this->getKey($pointer,$theRootLine);
1887 $theStartId = $theRootLine[$key]['uid'];
1888 }
1889 }
1890 if (!$theStartId) {
1891 // If not set, we use current page
1892 $theStartId=$GLOBALS['TSFE']->id;
1893 }
1894 // generate page-tree
1895 $search->pageIdList.=$this->getTreeList($theStartId,$depth);
1896
1897 $endClause = 'pages.uid IN ('.$search->pageIdList.$theStartId.')
1898 AND pages.doktype in ('.$GLOBALS['TYPO3_CONF_VARS']['FE']['content_doktypes'].($conf['addExtUrlsAndShortCuts']?',3,4':'').')
1899 AND pages.no_search=0'.
1900 $this->enableFields($search->fTable).
1901 $this->enableFields('pages');
1902
1903 if ($conf['languageField.'][$search->fTable]) {
1904 $endClause.= ' AND '.$search->fTable.'.'. $conf['languageField.'][$search->fTable].' = '.intval($GLOBALS['TSFE']->sys_language_uid);
1905 }
1906
1907 // build query
1908 $search->build_search_query($endClause);
1909
1910 // count...
1911 if (t3lib_div::testInt(t3lib_div::_GP('scount'))) {
1912 $search->res_count = t3lib_div::_GP('scount');
1913 } else {
1914 $search->count_query();
1915 }
1916
1917 // range
1918 $spointer = intval(t3lib_div::_GP('spointer'));
1919 if (isset($conf['range'])) {
1920 $theRange = intval($conf['range']);
1921 } else {
1922 $theRange = 20;
1923 }
1924
1925 // Order By:
1926 if (!$conf['noOrderBy']) {
1927 $search->queryParts['ORDERBY'] = 'pages.lastUpdated, pages.tstamp';
1928 }
1929
1930 $search->queryParts['LIMIT'] = $spointer.','.$theRange;
1931
1932 // search...
1933 $search->execute_query();
1934 if ($GLOBALS['TYPO3_DB']->sql_num_rows($search->result)) {
1935 $GLOBALS['TSFE']->register['SWORD_PARAMS'] = $search->get_searchwords();
1936
1937 $total = $search->res_count;
1938 $rangeLow = t3lib_div::intInRange($spointer+1,1,$total);
1939 $rangeHigh = t3lib_div::intInRange($spointer+$theRange,1,$total);
1940 // prev/next url:
1941 $LD = $GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page,$conf['target'],1,'');
1942 $targetPart = $LD['target'] ? ' target="'.htmlspecialchars($LD['target']).'"' : '';
1943 $urlParams = $this->URLqMark($LD['totalURL'],
1944 '&sword='.rawurlencode(t3lib_div::_GP('sword')).
1945 '&scols='.rawurlencode(t3lib_div::_GP('scols')).
1946 '&stype='.rawurlencode(t3lib_div::_GP('stype')).
1947 '&scount='.$total);
1948 // substitution:
1949 $result= $this->cObjGetSingle($conf['layout'],$conf['layout.'], 'layout');
1950 $result = str_replace('###RANGELOW###',$rangeLow,$result);
1951 $result = str_replace('###RANGEHIGH###',$rangeHigh,$result);
1952 $result = str_replace('###TOTAL###',$total,$result);
1953
1954 if ($rangeHigh<$total) {
1955 $next = $this->cObjGetSingle($conf['next'], $conf['next.'], 'next');
1956 $next = '<a href="'.htmlspecialchars($urlParams.'&spointer='.($spointer+$theRange)).'"'.$targetPart.$GLOBALS['TSFE']->ATagParams.'>'.$next.'</a>';
1957 } else $next='';
1958 $result = str_replace('###NEXT###',$next,$result);
1959
1960 if ($rangeLow>1) {
1961 $prev = $this->cObjGetSingle($conf['prev'], $conf['prev.'], 'prev');
1962 $prev = '<a href="'.htmlspecialchars($urlParams.'&spointer='.($spointer-$theRange)).'"'.$targetPart.$GLOBALS['TSFE']->ATagParams.'>'.$prev.'</a>';
1963 } else $prev='';
1964 $result = str_replace('###PREV###',$prev,$result);
1965
1966 // searching result
1967 $theValue = $this->cObjGetSingle($conf['resultObj'], $conf['resultObj.'],'resultObj');
1968 $cObj =t3lib_div::makeInstance('tslib_cObj');
1969 $cObj->setParent($this->data,$this->currentRecord);
1970 $renderCode='';
1971 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($search->result)) {
1972 $cObj->start($row);
1973 $renderCode.=$cObj->cObjGetSingle($conf['renderObj'], $conf['renderObj.'],'renderObj');
1974 }
1975 $theValue.=$this->wrap($renderCode,$conf['renderWrap']);
1976 $theValue = str_replace('###RESULT###',$theValue,$result);
1977 } else {
1978 $theValue = $this->cObjGetSingle($conf['noResultObj'], $conf['noResultObj.'],'noResultObj');
1979 }
1980
1981 $GLOBALS['TT']->setTSlogMessage('Search in fields: '.$search->listOfSearchFields);
1982
1983 // wrapping
1984 $content=$theValue;
1985 if ($conf['wrap']) {
1986 $content=$this->wrap($content, $conf['wrap']);
1987 }
1988 if ($conf['stdWrap.']) {
1989 $content=$this->stdWrap($content, $conf['stdWrap.']);
1990 }
1991 // returning
1992 $GLOBALS['TSFE']->set_no_cache();
1993 return $content;
1994 }
1995 }
1996
1997 /**
1998 * Rendering the cObject, PHP_SCRIPT, PHP_SCRIPT_INT and PHP_SCRIPT_EXT
1999 *
2000 * @param array Array of TypoScript properties
2001 * @param string If "INT", then rendering "PHP_SCRIPT_INT"; If "EXT", then rendering "PHP_SCRIPT_EXT"; Default is rendering "PHP_SCRIPT" (cached)
2002 * @return string Output
2003 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=370&cHash=aa107f2ad8
2004 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=371&cHash=53f71d025e
2005 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=372&cHash=91fe391e1c
2006 */
2007 function PHP_SCRIPT($conf,$ext='') {
2008 $incFile = $GLOBALS['TSFE']->tmpl->getFileName($conf['file']);
2009 $content='';
2010 if ($incFile && $GLOBALS['TSFE']->checkFileInclude($incFile)) {
2011 switch($ext) {
2012 case 'INT':
2013 case 'EXT':
2014 $substKey = $ext.'_SCRIPT.'.$GLOBALS['TSFE']->uniqueHash();
2015 $content.='<!--'.$substKey.'-->';
2016 $GLOBALS['TSFE']->config[$ext.'incScript'][$substKey] = array(
2017 'file'=>$incFile,
2018 'conf'=>$conf,
2019 'type'=>'SCRIPT'
2020 );
2021 if ($ext=='INT') {
2022 $GLOBALS['TSFE']->config[$ext.'incScript'][$substKey]['cObj'] = serialize($this);
2023 } else {
2024 $GLOBALS['TSFE']->config[$ext.'incScript'][$substKey]['data'] = $this->data;
2025 }
2026 break;
2027 default:
2028 // Added 31-12-00: Make backup...
2029 $this->oldData = $this->data;
2030 // Include file..
2031 include('./'.$incFile);
2032 // Added 31-12-00: restore...
2033 if ($RESTORE_OLD_DATA) {
2034 $this->data = $this->oldData;
2035 }
2036 break;
2037 }
2038 }
2039 return $content;
2040 }
2041
2042 /**
2043 * Rendering the cObject, TEMPLATE
2044 *
2045 * @param array Array of TypoScript properties
2046 * @return string Output
2047 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=373&cHash=109a171b1e
2048 * @see substituteMarkerArrayCached()
2049 */
2050 function TEMPLATE($conf) {
2051 $subparts = Array();
2052 $marks = Array();
2053 $wraps = Array();
2054 $content='';
2055
2056 list($PRE,$POST) = explode('|',$conf['markerWrap'] ? $conf['markerWrap'] : '### | ###');
2057 $POST = trim($POST);
2058 $PRE = trim($PRE);
2059
2060 // Getting the content
2061 $content = $this->cObjGetSingle($conf['template'],$conf['template.'],'template');
2062 if ($conf['workOnSubpart']) {
2063 $content = $this->getSubpart($content, $PRE.$conf['workOnSubpart'].$POST);
2064 }
2065 if ($content) {
2066 if ($conf['nonCachedSubst']) { // NON-CACHED:
2067 // Getting marks
2068 if (is_array($conf['marks.'])) {
2069 reset($conf['marks.']);
2070 while(list($theKey,$theValue)=each($conf['marks.'])) {
2071 if (!strstr($theKey,'.')) {
2072 $content = str_replace(
2073 $PRE.$theKey.$POST,
2074 $this->cObjGetSingle($theValue,$conf['marks.'][$theKey.'.'],'marks.'.$theKey),
2075 $content);
2076 }
2077 }
2078 }
2079
2080 // Getting subparts.
2081 if (is_array($conf['subparts.'])) {
2082 reset($conf['subparts.']);
2083 while(list($theKey,$theValue)=each($conf['subparts.'])) {
2084 if (!strstr($theKey,'.')) {
2085 $subpart = $this->getSubpart($content, $PRE.$theKey.$POST);
2086 if ($subpart) {
2087 $this->setCurrentVal($subpart);
2088 $content = $this->substituteSubpart(
2089 $content,
2090 $PRE.$theKey.$POST,
2091 $this->cObjGetSingle($theValue,$conf['subparts.'][$theKey.'.'],'subparts.'.$theKey),
2092 1
2093 );
2094 }
2095 }
2096 }
2097 }
2098 // Getting subpart wraps
2099 if (is_array($conf['wraps.'])) {
2100 reset($conf['wraps.']);
2101 while(list($theKey,$theValue)=each($conf['wraps.'])) {
2102 if (!strstr($theKey,'.')) {
2103 $subpart = $this->getSubpart($content, $PRE.$theKey.$POST);
2104 if ($subpart) {
2105 $this->setCurrentVal($subpart);
2106 $content = $this->substituteSubpart(
2107 $content,
2108 $PRE.$theKey.$POST,
2109 explode('|',$this->cObjGetSingle($theValue,$conf['wraps.'][$theKey.'.'],'wraps.'.$theKey)),
2110 1
2111 );
2112 }
2113 }
2114 }
2115 }
2116 } else { // CACHED
2117 // Getting subparts.
2118 if (is_array($conf['subparts.'])) {
2119 reset($conf['subparts.']);
2120 while(list($theKey,$theValue)=each($conf['subparts.'])) {
2121 if (!strstr($theKey,'.')) {
2122 $subpart = $this->getSubpart($content, $PRE.$theKey.$POST);
2123 if ($subpart) {
2124 $GLOBALS['TSFE']->register['SUBPART_'.$theKey] = $subpart;
2125 $subparts[$theKey]['name'] = $theValue;
2126 $subparts[$theKey]['conf'] = $conf['subparts.'][$theKey.'.'];
2127 }
2128 }
2129 }
2130 }
2131 // Getting marks
2132 if (is_array($conf['marks.'])) {
2133 reset($conf['marks.']);
2134 while(list($theKey,$theValue)=each($conf['marks.'])) {
2135 if (!strstr($theKey,'.')) {
2136 $marks[$theKey]['name'] = $theValue;
2137 $marks[$theKey]['conf'] = $conf['marks.'][$theKey.'.'];
2138 }
2139 }
2140 }
2141 // Getting subpart wraps
2142 if (is_array($conf['wraps.'])) {
2143 reset($conf['wraps.']);
2144 while(list($theKey,$theValue)=each($conf['wraps.'])) {
2145 if (!strstr($theKey,'.')) {
2146 $wraps[$theKey]['name'] = $theValue;
2147 $wraps[$theKey]['conf'] = $conf['wraps.'][$theKey.'.'];
2148 }
2149 }
2150 }
2151 // Getting subparts
2152 $subpartArray =array();
2153 reset($subparts);
2154 while(list($theKey,$theValue)=each($subparts)) {
2155 // Set current with the content of the subpart...
2156 $this->data[$this->currentValKey] = $GLOBALS['TSFE']->register['SUBPART_'.$theKey];
2157 // Get subpart cObject and substitute it!
2158 $subpartArray[$PRE.$theKey.$POST] = $this->cObjGetSingle($theValue['name'],$theValue['conf'],'subparts.'.$theKey);
2159 }
2160 $this->data[$this->currentValKey] = ''; // Reset current to empty
2161
2162 // Getting marks
2163 $markerArray =array();
2164 reset($marks);
2165 while(list($theKey,$theValue)=each($marks)) {
2166 $markerArray[$PRE.$theKey.$POST] = $this->cObjGetSingle($theValue['name'],$theValue['conf'],'marks.'.$theKey);
2167 }
2168 // Getting wraps
2169 $subpartWraps =array();
2170 reset($wraps);
2171 while(list($theKey,$theValue)=each($wraps)) {
2172 $subpartWraps[$PRE.$theKey.$POST] = explode('|',$this->cObjGetSingle($theValue['name'],$theValue['conf'],'wraps.'.$theKey));
2173 }
2174
2175 // Substitution
2176 if ($conf['substMarksSeparately']) {
2177 $content = $this->substituteMarkerArrayCached($content,array(),$subpartArray,$subpartWraps);
2178 $content = $this->substituteMarkerArray($content, $markerArray);
2179 } else {
2180 $content = $this->substituteMarkerArrayCached($content,$markerArray,$subpartArray,$subpartWraps);
2181 }
2182 }
2183 }
2184 return $content;
2185 }
2186
2187 /**
2188 * Rendering the cObject, MULTIMEDIA
2189 *
2190 * @param array Array of TypoScript properties
2191 * @return string Output
2192 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=374&cHash=efd88ab4a9
2193 */
2194 function MULTIMEDIA($conf) {
2195 $content='';
2196 $filename=$this->stdWrap($conf['file'],$conf['file.']);
2197 $incFile = $GLOBALS['TSFE']->tmpl->getFileName($filename);
2198 if ($incFile) {
2199 $fileinfo = t3lib_div::split_fileref($incFile);
2200 if (t3lib_div::inList('txt,html,htm',$fileinfo['fileext'])) {
2201 $content = $GLOBALS['TSFE']->tmpl->fileContent($incFile);
2202 } else {
2203 // default params...
2204 $parArray=array();
2205 // src is added
2206 $parArray['src']='src="'.$GLOBALS['TSFE']->absRefPrefix.$incFile.'"';
2207 if (t3lib_div::inList('au,wav,mp3',$fileinfo['fileext'])) {
2208 }
2209 if (t3lib_div::inList('avi,mov,mpg,asf,wmv',$fileinfo['fileext'])) {
2210 $parArray['width'] = 'width="200"';
2211 $parArray['height'] = 'height="200"';
2212 }
2213 if (t3lib_div::inList('swf,swa,dcr',$fileinfo['fileext'])) {
2214 $parArray['quality'] = 'quality="high"';
2215 }
2216 if (t3lib_div::inList('class',$fileinfo['fileext'])) {
2217 $parArray['width'] = 'width="200"';
2218 $parArray['height'] = 'height="200"';
2219 }
2220
2221 // fetching params
2222 $lines = explode(chr(10), $this->stdWrap($conf['params'],$conf['params.']));
2223 while(list(,$l)=each($lines)) {
2224 $parts = explode('=', $l);
2225 $parameter = strtolower(trim($parts[0]));
2226 $value = trim($parts[1]);
2227 if ((string)$value!='') {
2228 $parArray[$parameter] = $parameter.'="'.htmlspecialchars($value).'"';
2229 } else {
2230 unset($parArray[$parameter]);
2231 }
2232 }
2233 if ($fileinfo['fileext']=='class') {
2234 unset($parArray['src']);
2235 $parArray['code'] = 'code="'.htmlspecialchars($fileinfo['file']).'"';
2236 $parArray['codebase'] = 'codebase="'.htmlspecialchars($fileinfo['path']).'"';
2237 $content='<applet '.implode($parArray,' ').'></applet>';
2238 } else {
2239 $content='<embed '.implode($parArray,' ').'></embed>';
2240 }
2241 }
2242 }
2243
2244 if ($conf['stdWrap.']) {
2245 $content=$this->stdWrap($content, $conf['stdWrap.']);
2246 }
2247
2248 return $content;
2249 }
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
2265
2266
2267 /************************************
2268 *
2269 * Various helper functions for content objects:
2270 *
2271 ************************************/
2272
2273 /**
2274 * Creates a link to a netprint application on another website (where the "netprint" extension is running")
2275 * Related to the extension "netprint"
2276 *
2277 * @param string The input string to add the link to.
2278 * @param array Array with information about the image.
2279 * @param array TypoScript properties for the netprint application.
2280 * @return string The input string possibly with the netprint link before/after
2281 * @access private
2282 */
2283 function netprintApplication_offsiteLinkWrap($str,$imgConf,$conf) {
2284 if ($conf['url'] && @is_file($imgConf['origFile'])) {
2285 $thisUrl = $conf['thisUrl'] ? $conf['thisUrl'] : t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR');
2286 $origFile=$thisUrl.$imgConf['origFile'];
2287 // Original file dimensions:
2288 $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
2289 $gifCreator->init();
2290 $origDim = $gifCreator->getImageDimensions($imgConf['origFile']);
2291 if (!$conf['linkOnlyPixelsAbove'] || $origDim[0]*$origDim[1]>$conf['linkOnlyPixelsAbove']) {
2292 // Set parameters
2293 $thumbFile=$thisUrl.$imgConf['3'].'|'.$imgConf[0].'x'.$imgConf[1].'|'.$origDim[0].'x'.$origDim[1].'|'.filesize($imgConf['origFile']).'|'.filemtime($imgConf['origFile']);
2294 // Set url:
2295 $url = $conf['url']
2296 .'&NP[offsite][1]='.rawurlencode($origFile)
2297 .'&NP[offsite_thumb][1]='.rawurlencode($thumbFile);
2298 $linkCObject = $this->cObjGetSingle($conf['cObject'],$conf['cObject.']);
2299 if ($linkCObject) {
2300 $ATagParams = trim($conf['ATagParams']) ? ' '.trim($conf['ATagParams']) : '';
2301 $linkCObject='<a href="'.htmlspecialchars($url).'"'.$ATagParams.'>'.$linkCObject.'</a>';
2302 $linkCObject=$this->stdWrap($linkCObject,$conf['outerStdWrap.']);
2303 if ($conf['before']) {
2304 $str=$linkCObject.$str;
2305 } else {
2306 $str=$str.$linkCObject;
2307 }
2308 }
2309 }
2310 }
2311 return $str;
2312 }
2313
2314 /**
2315 * Returns a default value for a form field in the FORM cObject.
2316 * Page CANNOT be cached because that would include the inserted value for the current user.
2317 *
2318 * @param boolean If noValueInsert OR if the no_cache flag for this page is NOT set, the original default value is returned.
2319 * @param string $fieldName: The POST var name to get default value for
2320 * @param string $defaultVal: The current default value
2321 * @return string The default value, either from INPUT var or the current default, based on whether caching is enabled or not.
2322 * @access private
2323 */
2324 function getFieldDefaultValue($noValueInsert, $fieldName, $defaultVal) {
2325 if (!$GLOBALS['TSFE']->no_cache || (!isset($GLOBALS['HTTP_POST_VARS'][$fieldName]) && !isset($GLOBALS['HTTP_GET_VARS'][$fieldName])) || $noValueInsert) {
2326 return $defaultVal;
2327 } else {
2328 return t3lib_div::_GP($fieldName);
2329 }
2330 }
2331
2332 /**
2333 * Returns a <img> tag with the image file defined by $file and processed according to the properties in the TypoScript array.
2334 * 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().
2335 *
2336 * @param string File TypoScript resource
2337 * @param array TypoScript configuration properties
2338 * @return string <img> tag, (possibly wrapped in links and other HTML) if any image found.
2339 * @access private
2340 * @see IMAGE()
2341 */
2342 function cImage($file,$conf) {
2343 $info = $this->getImgResource($file,$conf['file.']);
2344 $GLOBALS['TSFE']->lastImageInfo=$info;
2345 if (is_array($info)) {
2346 $info[3] = t3lib_div::png_to_gif_by_imagemagick($info[3]);
2347 $GLOBALS['TSFE']->imagesOnPage[]=$info[3]; // This array is used to collect the image-refs on the page...
2348 $altParam = $this->getAltParam($conf);
2349 $theValue = '<img src="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.t3lib_div::rawUrlEncodeFP($info[3])).'" width="'.$info[0].'" height="'.$info[1].'" border="'.intval($conf['border']).'"'.($conf['params']?' '.$conf['params']:'').($altParam).' />';
2350 if ($conf['linkWrap']) {
2351 $theValue = $this->linkWrap($theValue,$conf['linkWrap']);
2352 } elseif ($conf['imageLinkWrap']) {
2353 $theValue = $this->imageLinkWrap($theValue,$info['origFile'],$conf['imageLinkWrap.']);
2354 }
2355 return $this->wrap($theValue,$conf['wrap']);
2356 }
2357 }
2358
2359 /**
2360 * Wraps the input string in link-tags that opens the image in a new window.
2361 *
2362 * @param string String to wrap, probably an <img> tag
2363 * @param string The original image file
2364 * @param array TypoScript properties for the "imageLinkWrap" function
2365 * @return string The input string, $string, wrapped as configured.
2366 * @see cImage()
2367 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=316&cHash=2848266da6
2368 */
2369 function imageLinkWrap($string,$imageFile,$conf) {
2370 $a1='';
2371 $a2='';
2372 $content=$string;
2373 if ($this->stdWrap($conf['enable'],$conf['enable.'])) {
2374 $content=$this->typolink($string, $conf['typolink.']);
2375 // imageFileLink:
2376 if ($content==$string && @is_file($imageFile)) {
2377 $params = '';
2378 if ($conf['width']) {$params.='&width='.rawurlencode($conf['width']);}
2379 if ($conf['height']) {$params.='&height='.rawurlencode($conf['height']);}
2380 if ($conf['effects']) {$params.='&effects='.rawurlencode($conf['effects']);}
2381 if ($conf['sample']) {$params.='&sample=1';}
2382 if ($conf['alternativeTempPath']) {$params.='&alternativeTempPath='.rawurlencode($conf['alternativeTempPath']);}
2383
2384 if ($conf['bodyTag']) {$params.='&bodyTag='.rawurlencode($conf['bodyTag']);}
2385 if ($conf['title']) {$params.='&title='.rawurlencode($conf['title']);}
2386 if ($conf['wrap']) {$params.='&wrap='.rawurlencode($conf['wrap']);}
2387
2388 $md5_value = md5($imageFile.'|'.$conf['width'].'|'.$conf['height'].'|'.$conf['effects'].'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'].'|');
2389
2390 $params.= '&md5='.$md5_value;
2391 $url = $GLOBALS['TSFE']->absRefPrefix.'showpic.php?file='.rawurlencode($imageFile).$params;
2392 if ($conf['JSwindow.']['altUrl'] || $conf['JSwindow.']['altUrl.']) {
2393 $altUrl = $this->stdWrap($conf['JSwindow.']['altUrl'], $conf['JSwindow.']['altUrl.']);
2394 if ($altUrl) {
2395 $url=$altUrl;
2396 }
2397 }
2398
2399 if ($conf['JSwindow']) {
2400 $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
2401 $gifCreator->init();
2402 $gifCreator->mayScaleUp = 0;
2403 $dims = $gifCreator->getImageScale($gifCreator->getImageDimensions($imageFile),$conf['width'],$conf['height'],'');
2404 $offset = t3lib_div::intExplode(',',$conf['JSwindow.']['expand'].',');
2405
2406 $a1='<a href="#" onclick="'.
2407 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;').
2408 '"'.$GLOBALS['TSFE']->ATagParams.'>';
2409 $a2='</a>';
2410 $GLOBALS['TSFE']->setJS('openPic');
2411 } else {
2412 $target = ' target="thePicture"';
2413 if (isset($conf['target'])) {
2414 $target= $conf['target'] ? ' target="'.$conf['target'].'"' : '';
2415 }
2416 $a1='<a href="'.htmlspecialchars($url).'"'.$target.$GLOBALS['TSFE']->ATagParams.'>';
2417 $a2='</a>';
2418 }
2419 $content=$a1.$string.$a2;
2420 }
2421 }
2422
2423 return $content;
2424 }
2425
2426 /**
2427 * Returns content of a file. If its an image the content of the file is not returned but rather an image tag is.
2428 *
2429 * @param string The filename, being a TypoScript resource data type
2430 * @return string If jpg,gif,jpeg,png: returns image_tag with picture in. If html,txt: returns content string
2431 * @see FILE()
2432 */
2433 function fileResource($fName) {
2434 $incFile = $GLOBALS['TSFE']->tmpl->getFileName($fName);
2435 if ($incFile) {
2436 $fileinfo = t3lib_div::split_fileref($incFile);
2437 if (t3lib_div::inList('jpg,gif,jpeg,png',$fileinfo['fileext'])) {
2438 $imgFile = $incFile;
2439 $imgInfo = @getImageSize($imgFile);
2440 return '<img src="'.$GLOBALS['TSFE']->absRefPrefix.$imgFile.'" width="'.$imgInfo[0].'" height="'.$imgInfo[1].'" border="0" alt="" title="" />';
2441 } elseif (filesize($incFile)<1024*1024) {
2442 return $GLOBALS['TSFE']->tmpl->fileContent($incFile);
2443 }
2444 }
2445 }
2446
2447 /**
2448 * Sets the SYS_LASTCHANGED timestamp if input timestamp is larger than current value.
2449 * The SYS_LASTCHANGED timestamp can be used by various caching/indexing applications to determine if the page has new content.
2450 * Therefore you should call this function with the last-changed timestamp of any element you display.
2451 *
2452 * @param integer Unix timestamp (number of seconds since 1970)
2453 * @return void
2454 * @see tslib_fe::setSysLastChanged()
2455 */
2456 function lastChanged($tstamp) {
2457 $tstamp = intval($tstamp);
2458 if ($tstamp>intval($GLOBALS['TSFE']->register['SYS_LASTCHANGED'])) {
2459 $GLOBALS['TSFE']->register['SYS_LASTCHANGED'] = $tstamp;
2460 }
2461 }
2462
2463 /**
2464 * Wraps the input string by the $wrap value and implements the "linkWrap" data type as well.
2465 * 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.
2466 *
2467 * @param string Input string
2468 * @param string A string where the first two parts separated by "|" (vertical line) will be wrapped around the input string
2469 * @return string Wrapped output string
2470 * @see wrap(), cImage(), FILE()
2471 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=282&cHash=831a95115d
2472 */
2473 function linkWrap($content,$wrap) {
2474 $wrapArr = explode('|', $wrap);
2475 if (ereg("\{([0-9]*)\}",$wrapArr[0],$reg)) {
2476 if ($uid = $GLOBALS['TSFE']->tmpl->rootLine[$reg[1]]['uid']) {
2477 $wrapArr[0] = str_replace($reg[0],$uid,$wrapArr[0]);
2478 }
2479 }
2480 return trim($wrapArr[0]).$content.trim($wrapArr[1]);
2481 }
2482
2483 /**
2484 * An abstraction method which creates an alt or title parameter for an HTML img tag.
2485 *
2486 * @param array TypoScript configuration properties
2487 * @return string Parameter string containing alt and title parameters (if any)
2488 * @see IMGTEXT(), cImage()
2489 */
2490 function getAltParam($conf) {
2491 $altText = $this->stdWrap($conf['altText'],$conf['altText.']);
2492 $altParam = ' alt="'.htmlspecialchars(strip_tags($altText)).'"';
2493
2494 $titleText = $this->stdWrap($conf['titleText'],$conf['titleText.']);
2495 if ($titleText) {
2496 $altParam .= ' title="'.htmlspecialchars(strip_tags($titleText)).'"';
2497 } else {
2498 $altParam .= ' title="'.htmlspecialchars(strip_tags($altText)).'"';
2499 }
2500 return $altParam;
2501 }
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521 /***********************************************
2522 *
2523 * HTML template processing functions
2524 *
2525 ***********************************************/
2526
2527 /**
2528 * Returns a subpart from the input content stream.
2529 * 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.
2530 * 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
2531 *
2532 * @param string The content stream, typically HTML template content.
2533 * @param string The marker string, typically on the form "###[the marker string]###"
2534 * @return string The subpart found, if found.
2535 * @see substituteSubpart(), t3lib_parsehtml::getSubpart()
2536 */
2537 function getSubpart($content, $marker) {
2538 if ($marker && strstr($content,$marker)) {
2539 $start = strpos($content, $marker)+strlen($marker);
2540 $stop = @strpos($content, $marker, $start+1);
2541 $sub = substr($content, $start, $stop-$start);
2542
2543 $reg=Array();
2544 ereg('^[^<]*-->',$sub,$reg);
2545 $start+=strlen($reg[0]);
2546
2547 $reg=Array();
2548 ereg('<!--[^>]*$',$sub,$reg);
2549 $stop-=strlen($reg[0]);
2550
2551 return substr($content, $start, $stop-$start);
2552 }
2553 }
2554
2555 /**
2556 * Substitute subpart in input template stream.
2557 * This function substitutes a subpart in $content with the content of $subpartContent.
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 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.
2562 * @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!
2563 * @return string The processed HTML content string.
2564 * @see getSubpart(), t3lib_parsehtml::substituteSubpart()
2565 */
2566 function substituteSubpart($content,$marker,$subpartContent,$recursive=1) {
2567 $start = strpos($content, $marker);
2568 $stop = @strpos($content, $marker, $start+1)+strlen($marker);
2569 if ($start && $stop>$start) {
2570 // code before
2571 $before = substr($content, 0, $start);
2572 $reg=Array();
2573 ereg('<!--[^>]*$',$before,$reg);
2574 $start-=strlen($reg[0]);
2575 $before = substr($content, 0, $start);