Added getindpenv keyword to TYpoScript "getText" data types
[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 $content='';
1383
1384 $content.='<table border="0" cellspacing="0" cellpadding="0" width="99%"><tr>';
1385 if ($spaceBefore) {$content.='<td width="1"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$spaceBefore.'" height="1" alt="" title="" /></td>'; }
1386 $content.='<td bgcolor="'.$lineColor.'"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$lineThickness.'" alt="" title="" /></td>';
1387 if ($spaceAfter) {$content.='<td width="1"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$spaceAfter.'" height="1" alt="" title="" /></td>'; }
1388 $content.='</tr></table>';
1389
1390 $content = $this->stdWrap($content, $conf['stdWrap.']);
1391 return $content;
1392 }
1393
1394 /**
1395 * Rendering the cObject, CASE
1396 *
1397 * @param array Array of TypoScript properties
1398 * @return string Output
1399 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=364&cHash=cffedd09e3
1400 */
1401 function CASEFUNC ($conf){
1402 $content='';
1403 if ($this->checkIf($conf['if.'])) {
1404 if ($conf['setCurrent'] || $conf['setCurrent.']){$this->data[$this->currentValKey] = $this->stdWrap($conf['setCurrent'], $conf['setCurrent.']);}
1405 $key = $this->stdWrap($conf['key'],$conf['key.']);
1406 $key = $conf[$key] ? $key : 'default';
1407 $name = $conf[$key];
1408 $theValue = $this->cObjGetSingle($name,$conf[$key.'.'], $key);
1409 if ($conf['stdWrap.']) {
1410 $theValue = $this->stdWrap($theValue,$conf['stdWrap.']);
1411 }
1412 return $theValue;
1413 }
1414 }
1415
1416 /**
1417 * Rendering the cObject, LOAD_REGISTER and RESTORE_REGISTER
1418 * NOTICE: This cObject does NOT return any content since it just sets internal data based on the TypoScript properties.
1419 *
1420 * @param array Array of TypoScript properties
1421 * @param string If "RESTORE_REGISTER" then the cObject rendered is "RESTORE_REGISTER", otherwise "LOAD_REGISTER"
1422 * @return string Empty string (the cObject only sets internal data!)
1423 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=365&cHash=4935524e2e
1424 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=366&cHash=4f9485e8cc
1425 */
1426 function LOAD_REGISTER($conf,$name) {
1427 if ($name=='RESTORE_REGISTER') {
1428 $GLOBALS['TSFE']->register = array_pop($GLOBALS['TSFE']->registerStack);
1429 } else {
1430 array_push($GLOBALS['TSFE']->registerStack,$GLOBALS['TSFE']->register);
1431 if (is_array($conf)) {
1432 reset($conf);
1433 while(list($theKey,$theValue)=each($conf)) {
1434 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
1435 if (strstr($theKey,'.')) {
1436 $theKey = substr($theKey,0,-1);
1437 }
1438 $GLOBALS['TSFE']->register[$theKey] = $this->stdWrap($conf[$theKey],$conf[$theKey.'.']);
1439 }
1440 }
1441 }
1442 }
1443 return '';
1444 }
1445
1446 /**
1447 * Rendering the cObject, FORM
1448 *
1449 * Note on $formData:
1450 * In the optional $formData array each entry represents a line in the ordinary setup.
1451 * In those entries each entry (0,1,2...) represents a space normally divided by the '|' line.
1452 *
1453 * $formData [] = array('Name:', 'name=input, 25 ', 'Default value....');
1454 * $formData [] = array('Email:', 'email=input, 25 ', 'Default value for email....');
1455 *
1456 * - corresponds to the $conf['data'] value being :
1457 * Name:|name=input, 25 |Default value....||Email:|email=input, 25 |Default value for email....
1458 *
1459 * If $formData is an array the value of $conf['data'] is ignored.
1460 *
1461 * @param array Array of TypoScript properties
1462 * @param array Alternative formdata overriding whatever comes from TypoScript
1463 * @return string Output
1464 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=367&cHash=bbc518d930
1465 */
1466 function FORM($conf,$formData='') {
1467 $content='';
1468 if (is_array($formData)) {
1469 $dataArr = $formData;
1470 } else {
1471 $data=$this->stdWrap($conf['data'],$conf['data.']);
1472 // Clearing dataArr
1473 $dataArr=array();
1474 // Getting the original config
1475 if (trim($data)) {
1476 $data = ereg_replace(chr(10),'||',$data);
1477 $dataArr = explode('||',$data);
1478 }
1479 // Adding the new dataArray config form:
1480 if (is_array($conf['dataArray.'])) { // dataArray is supplied
1481 reset($conf['dataArray.']);
1482 while(list($dAKey,$dAA)=each($conf['dataArray.'])) {
1483 if (is_array($dAA) && !strcmp(intval($dAKey).'.',$dAKey)) {
1484 $temp=array();
1485 list($temp[0])= explode('|',$dAA['label.'] ? $this->stdWrap($dAA['label'],$dAA['label.']) : $dAA['label']);
1486 list($temp[1])= explode('|',$dAA['type']);
1487 if ($dAA['required']) {$temp[1]='*'.$temp[1];}
1488 list($temp[2])= explode('|',$dAA['value.'] ? $this->stdWrap($dAA['value'],$dAA['value.']) : $dAA['value']);
1489 // If value Array is set, then implode those values.
1490 if (is_array($dAA['valueArray.'])) {
1491 reset($dAA['valueArray.']);
1492 $temp_accum = array();
1493 while(list($dAKey_vA,$dAA_vA)=each($dAA['valueArray.'])) {
1494 if (is_array($dAA_vA) && !strcmp(intval($dAKey_vA).'.',$dAKey_vA)) {
1495 $temp_vA=array();
1496 list($temp_vA[0])= explode('=',$dAA_vA['label.'] ? $this->stdWrap($dAA_vA['label'],$dAA_vA['label.']) : $dAA_vA['label']);
1497 if ($dAA_vA['selected']) {$temp_vA[0]='*'.$temp_vA[0];}
1498 list($temp_vA[1])= explode(',',$dAA_vA['value']);
1499 }
1500 $temp_accum[] = implode('=',$temp_vA);
1501 }
1502 $temp[2] = implode(',',$temp_accum);
1503 }
1504 // adding the form entry to the dataArray
1505 $dataArr[] = implode('|',$temp);
1506 }
1507 }
1508 }
1509 }
1510 $attachmentCounter='';
1511 $hiddenfields='';
1512 $fieldlist=Array();
1513 $propertyOverride = Array();
1514 $fieldname_hashArray = Array();
1515 $cc=0;
1516 reset($dataArr);
1517 while(list(,$val)=each($dataArr)) {
1518 $cc++;
1519 $confData=Array();
1520 if (is_array($formData)) {
1521 $parts = $val;
1522 $val=1; // true...
1523 } else {
1524 $val=trim($val);
1525 $parts = explode('|',$val);
1526 }
1527 if ($val && strcspn($val,'#/')) {
1528 // label:
1529 $confData['label'] = trim($parts[0]);
1530 // field:
1531 $fParts = explode(',',$parts[1]);
1532 $fParts[0]=trim($fParts[0]);
1533 if (substr($fParts[0],0,1)=='*') {
1534 $confData['required']=1;
1535 $fParts[0] = substr($fParts[0],1);
1536 }
1537 $typeParts = explode('=',$fParts[0]);
1538 $confData['type'] = trim(strtolower(end($typeParts)));
1539 if (count($typeParts)==1) {
1540 $confData['fieldname'] = substr(ereg_replace('[^a-zA-Z0-9_]','',str_replace(' ','_',trim($parts[0]))),0,30);
1541 if (strtolower(ereg_replace('[^[:alnum:]]','',$confData['fieldname']))=='email') {$confData['fieldname']='email';}
1542 // Duplicate fieldnames resolved
1543 if (isset($fieldname_hashArray[md5($confData['fieldname'])])) {
1544 $confData['fieldname'].='_'.$cc;
1545 }
1546 $fieldname_hashArray[md5($confData['fieldname'])]=$confData['fieldname'];
1547 // Attachment names...
1548 if ($confData['type']=='file') {
1549 $confData['fieldname']='attachment'.$attachmentCounter;
1550 $attachmentCounter=intval($attachmentCounter)+1;
1551 }
1552 } else {
1553 $confData['fieldname'] = str_replace(' ','_',trim($typeParts[0]));
1554 }
1555 $fieldCode='';
1556
1557
1558 if ($conf['wrapFieldName']) {
1559 $confData['fieldname'] = $this->wrap($confData['fieldname'],$conf['wrapFieldName']);
1560 }
1561
1562 // Additional parameters
1563 if (trim($confData['type'])) {
1564 $addParams=trim($conf['params']);
1565 if (is_array($conf['params.']) && isset($conf['params.'][$confData['type']])) {
1566 $addParams=trim($conf['params.'][$confData['type']]);
1567 }
1568 if (strcmp('',$addParams)) $addParams=' '.$addParams;
1569 } else $addParams='';
1570
1571 switch($confData['type']) {
1572 case 'textarea':
1573 $cols=trim($fParts[1]) ? intval($fParts[1]) : 20;
1574 $compWidth = doubleval($conf['compensateFieldWidth'] ? $conf['compensateFieldWidth'] : $GLOBALS['TSFE']->compensateFieldWidth);
1575 $compWidth = $compWidth ? $compWidth : 1;
1576 $cols = t3lib_div::intInRange($cols*$compWidth, 1, 120);
1577
1578 $rows=trim($fParts[2]) ? t3lib_div::intInRange($fParts[2],1,30) : 5;
1579 $wrap=trim($fParts[3]) ? ' wrap="'.trim($fParts[3]).'"' : ' wrap="virtual"';
1580 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], trim($parts[2]));
1581 $fieldCode=sprintf('<textarea name="%s" cols="%s" rows="%s"%s'.$addParams.'>%s</textarea>',
1582 $confData['fieldname'], $cols, $rows, $wrap, t3lib_div::formatForTextarea($default));
1583 break;
1584 case 'input':
1585 case 'password':
1586 $size=trim($fParts[1]) ? intval($fParts[1]) : 20;
1587 $compWidth = doubleval($conf['compensateFieldWidth'] ? $conf['compensateFieldWidth'] : $GLOBALS['TSFE']->compensateFieldWidth);
1588 $compWidth = $compWidth ? $compWidth : 1;
1589 $size = t3lib_div::intInRange($size*$compWidth, 1, 120);
1590 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], trim($parts[2]));
1591 if ($confData['type']=='password') {
1592 $default='';
1593 }
1594
1595 $max=trim($fParts[2]) ? ' maxlength="'.t3lib_div::intInRange($fParts[2],1,1000).'"' : "";
1596 $theType = $confData['type']=='input' ? 'text' : 'password';
1597
1598 $fieldCode=sprintf('<input type="'.$theType.'" name="%s" size="%s"%s value="%s"'.$addParams.' />',
1599 $confData['fieldname'], $size, $max, htmlspecialchars($default));
1600 break;
1601 case 'file':
1602 $size=trim($fParts[1]) ? t3lib_div::intInRange($fParts[1],1,60) : 20;
1603 $fieldCode=sprintf('<input type="file" name="%s" size="%s"'.$addParams.' />',
1604 $confData['fieldname'], $size);
1605 break;
1606 case 'check':
1607 // alternative default value:
1608 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], trim($parts[2]));
1609 $checked = $default ? ' checked="checked"' : '';
1610 $fieldCode=sprintf('<input type="checkbox" value="%s" name="%s"%s'.$addParams.' />',
1611 1, $confData['fieldname'], $checked);
1612 break;
1613 case 'select':
1614 $option='';
1615 $valueParts = explode(',',$parts[2]);
1616 // size
1617 if (strtolower(trim($fParts[1]))=='auto') {$fParts[1]=count($valueParts);} // Auto size set here. Max 20
1618 $size=trim($fParts[1]) ? t3lib_div::intInRange($fParts[1],1,20) : 1;
1619 // multiple
1620 $multiple = strtolower(trim($fParts[2]))=='m' ? ' multiple="multiple"' : '';
1621
1622 $items=array(); // Where the items will be
1623 $defaults=array(); //RTF
1624 for($a=0;$a<count($valueParts);$a++) {
1625 $valueParts[$a]=trim($valueParts[$a]);
1626 if (substr($valueParts[$a],0,1)=='*') { // Finding default value
1627 $sel='selected';
1628 $valueParts[$a] = substr($valueParts[$a],1);
1629 } else $sel='';
1630 // Get value/label
1631 $subParts=explode('=',$valueParts[$a]);
1632 $subParts[1] = (isset($subParts[1])?trim($subParts[1]):trim($subParts[0])); // Sets the value
1633 $items[] = $subParts; // Adds the value/label pair to the items-array
1634 if ($sel) {$defaults[]=$subParts[1];} // Sets the default value if value/label pair is marked as default.
1635 }
1636 // alternative default value:
1637 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], $defaults);
1638 if (!is_array($default)) {
1639 $defaults=array();
1640 $defaults[] = $default;
1641 } else $defaults=$default;
1642 // Create the select-box:
1643 for($a=0;$a<count($items);$a++) {
1644 $option.='<option value="'.$items[$a][1].'"'.(in_array($items[$a][1],$defaults)?' selected="selected"':'').'>'.trim($items[$a][0]).'</option>'; //RTF
1645 }
1646
1647 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.
1648 $fieldCode=sprintf('<select name="%s" size="%s"%s'.$addParams.'>%s</select>',
1649 $confData['fieldname'], $size, $multiple, $option); //RTF
1650 break;
1651 case 'radio':
1652 $option='';
1653 $valueParts = explode(',',$parts[2]);
1654 $items=array(); // Where the items will be
1655 $default='';
1656 for($a=0;$a<count($valueParts);$a++) {
1657 $valueParts[$a]=trim($valueParts[$a]);
1658 if (substr($valueParts[$a],0,1)=='*') {
1659 $sel='checked';
1660 $valueParts[$a] = substr($valueParts[$a],1);
1661 } else $sel='';
1662 // Get value/label
1663 $subParts=explode('=',$valueParts[$a]);
1664 $subParts[1] = (isset($subParts[1])?trim($subParts[1]):trim($subParts[0])); // Sets the value
1665 $items[] = $subParts; // Adds the value/label pair to the items-array
1666 if ($sel) {$default=$subParts[1];} // Sets the default value if value/label pair is marked as default.
1667 }
1668 // alternative default value:
1669 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], $default);
1670 // Create the select-box:
1671 for($a=0;$a<count($items);$a++) {
1672 $option.= '<input type="radio" name="'.$confData['fieldname'].'" value="'.$items[$a][1].'"'.(!strcmp($items[$a][1],$default)?' checked="checked"':'').''.$addParams.' />';
1673 $option.= $this->stdWrap(trim($items[$a][0]), $conf['radioWrap.']);
1674 $option.= '<br />';
1675 }
1676 $fieldCode=$option;
1677 break;
1678 case 'hidden':
1679 $value=trim($parts[2]);
1680 $hiddenfields.=sprintf('<input type="hidden" name="%s" value="%s" />',
1681 $confData['fieldname'], $value);
1682 break;
1683 case 'property':
1684 if (t3lib_div::inList('type,locationData,goodMess,badMess',$confData['fieldname'])) {
1685 $value=trim($parts[2]);
1686 $propertyOverride[$confData['fieldname']] = $value;
1687 $conf[$confData['fieldname']] = $value;
1688 }
1689 break;
1690 case 'submit':
1691 $value=trim($parts[2]);
1692 if ($conf['image.']) {
1693 $this->data[$this->currentValKey]=$value;
1694 $image=$this->IMAGE($conf['image.']);
1695 } else $image='';
1696 if($image) {
1697 $fieldCode = str_replace('<img','<input type="image"'.$addParams.' name="'.$confData['fieldname'].'"' ,$image);
1698 } else {
1699 $fieldCode=sprintf('<input type="submit" name="%s" value="%s"'.$addParams.' />',
1700 $confData['fieldname'], t3lib_div::deHSCentities(htmlspecialchars($value)));
1701 }
1702 break;
1703 default:
1704 $confData['type']='comment';
1705 $fieldCode=trim($parts[2]).'&nbsp;';
1706 break;
1707 }
1708 if ($fieldCode) {
1709 $fieldCode = $this->stdWrap($fieldCode, $conf['fieldWrap.']);
1710 $labelCode = $this->stdWrap($confData['label'], $conf['labelWrap.']);
1711 $commentCode = $this->stdWrap($confData['label'], $conf['commentWrap.']); // RTF
1712 $result = $conf['layout'];
1713 if ($conf['REQ'] && $confData['required']) {
1714 if (is_array($conf['REQ.']['fieldWrap.']))
1715 $fieldCode = $this->stdWrap($fieldCode, $conf['REQ.']['fieldWrap.']);
1716 if (is_array($conf['REQ.']['labelWrap.']))
1717 $labelCode = $this->stdWrap($confData['label'], $conf['REQ.']['labelWrap.']);
1718 if ($conf['REQ.']['layout']) {
1719 $result = $conf['REQ.']['layout'];
1720 }
1721 }
1722 if ($confData['type']=='comment' && $conf['COMMENT.']['layout']) {
1723 $result = $conf['COMMENT.']['layout'];
1724 }
1725 if ($confData['type']=='check' && $conf['CHECK.']['layout']) {
1726 $result = $conf['CHECK.']['layout'];
1727 }
1728 if ($confData['type']=='radio' && $conf['RADIO.']['layout']) {
1729 $result = $conf['RADIO.']['layout'];
1730 }
1731 $result = str_replace('###FIELD###',$fieldCode,$result);
1732 $result = str_replace('###LABEL###',$labelCode,$result);
1733 $result = str_replace('###COMMENT###',$commentCode,$result); //RTF
1734 $content.=$result;
1735 // Required:
1736 if ($confData['required'] && $confData['type']!='check') {
1737 $fieldlist[]=rawurlencode($confData['fieldname']);
1738 $fieldlist[]=rawurlencode($confData['label']);
1739 }
1740 }
1741 }
1742 }
1743 if ($conf['stdWrap.']) $content=$this->stdWrap($content, $conf['stdWrap.']);
1744
1745
1746 // redirect (external: where to go afterwards. internal: where to submit to)
1747 $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)
1748 $page=$GLOBALS['TSFE']->page;
1749 if (!$theRedirect) { // Internal: Just submit to current page
1750 $LD=$GLOBALS['TSFE']->tmpl->linkData($page, $conf['target'], $conf['no_cache'],'index.php');
1751 } elseif (t3lib_div::testInt($theRedirect)) { // Internal: Submit to page with id $theRedirect
1752 $page = $GLOBALS['TSFE']->sys_page->getPage_noCheck($theRedirect);
1753 $LD=$GLOBALS['TSFE']->tmpl->linkData($page, $conf['target'], $conf['no_cache'],'index.php');
1754 } else { // External url, redirect-hidden field is rendered!
1755 $LD=$GLOBALS['TSFE']->tmpl->linkData($page, $conf['target'], $conf['no_cache'],'');
1756 $LD['totalURL']=$theRedirect;
1757 $hiddenfields.='<input type="hidden" name="redirect" value="'.htmlspecialchars($LD['totalURL']).'" />'; // 18-09-00 added
1758 }
1759
1760 // Formtype (where to submit to!):
1761 $formtype = $propertyOverride['type'] ? $propertyOverride['type'] : $this->stdWrap($conf['type'], $conf['type.']);
1762 if (t3lib_div::testInt($formtype)) { // Submit to a specific page
1763 $page = $GLOBALS['TSFE']->sys_page->getPage_noCheck($formtype);
1764 $LD_A=$GLOBALS['TSFE']->tmpl->linkData($page,$conf['target'],$conf['no_cache'],'');
1765 $action=$LD_A['totalURL'];
1766 } elseif ($formtype){ // Submit to external script
1767 $LD_A=$LD;
1768 $action = $formtype;
1769 } elseif (t3lib_div::testInt($theRedirect)) {
1770 $LD_A=$LD;
1771 $action=$LD_A['totalURL'];
1772 } else { // Submit to 'nothing' - which is current page
1773 $LD_A=$GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page,$conf['target'],$conf['no_cache'],'');
1774 $action=$LD_A['totalURL'];
1775 }
1776
1777 // copyemail:
1778 $theEmail = $this->stdWrap($conf['recipient'], $conf['recipient.']);
1779 if ($theEmail) {
1780 $hiddenfields.='<input type="hidden" name="recipient" value="'.htmlspecialchars($theEmail).'" />';
1781 }
1782
1783 // location data:
1784 if ($conf['locationData']) {
1785 if ($conf['locationData']=='HTTP_POST_VARS' && isset($GLOBALS['HTTP_POST_VARS']['locationData'])) {
1786 $locationData = t3lib_div::_POST('locationData');
1787 } else {
1788 $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.
1789 }
1790 $hiddenfields.='<input type="hidden" name="locationData" value="'.htmlspecialchars($locationData).'" />';
1791 }
1792
1793 // hidden fields:
1794 if (is_array($conf['hiddenFields.'])) {
1795 reset($conf['hiddenFields.']);
1796 while(list($hF_key,$hF_conf)=each($conf['hiddenFields.'])) {
1797 if (substr($hF_key,-1)!='.') {
1798 $hF_value = $this->cObjGetSingle($hF_conf,$conf['hiddenFields.'][$hF_key.'.'],'hiddenfields');
1799 $hiddenfields.='<input type="hidden" name="'.$hF_key.'" value="'.htmlspecialchars($hF_value).'" />';
1800 }
1801 }
1802 }
1803
1804 // Formname;
1805 $formname = $GLOBALS['TSFE']->uniqueHash();
1806 if ($conf['REQ']) {
1807 $validateForm=' onsubmit="return validateForm(\''.$formname.'\',\''.implode($fieldlist,',').'\',\''.rawurlencode($conf['goodMess']).'\',\''.rawurlencode($conf['badMess']).'\')"';
1808 $GLOBALS['TSFE']->additionalHeaderData['JSFormValidate'] = '<script type="text/javascript" src="'.$GLOBALS['TSFE']->absRefPrefix.'t3lib/jsfunc.validateform.js"></script>';
1809 } else $validateForm='';
1810
1811 // Create form tag:
1812 $theTarget = ($theRedirect?$LD['target']:$LD_A['target']);
1813 $content = Array(
1814 '<form'.
1815 ' action="'.htmlspecialchars($action).'"'.
1816 ' name="'.$formname.'"'.
1817 ' enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'"'.
1818 ' method="'.($conf['method']?$conf['method']:'post').'"'.
1819 ($theTarget ? ' target="'.$theTarget.'"' : '').
1820 $validateForm.
1821 '>',
1822 $hiddenfields.$content,
1823 '</form>'
1824 );
1825 if ($conf['arrayReturnMode']) {
1826 $content['validateForm']=$validateForm;
1827 $content['formname']=$formname;
1828 return $content;
1829 } else {
1830 return implode('',$content);
1831 }
1832 }
1833
1834 /**
1835 * Rendering the cObject, SEARCHRESULT
1836 *
1837 * @param array Array of TypoScript properties
1838 * @return string Output
1839 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=368&cHash=d00731cd7b
1840 */
1841 function SEARCHRESULT($conf) {
1842 if (t3lib_div::_GP('sword') && t3lib_div::_GP('scols')) {
1843 $search = t3lib_div::makeInstance('tslib_search');
1844 $search->register_and_explode_search_string(t3lib_div::_GP('sword'));
1845 $search->register_tables_and_columns(t3lib_div::_GP('scols'),$conf['allowedCols']);
1846 // depth
1847 $depth=100;
1848 // the startId is found
1849 $theStartId=0;
1850 if (t3lib_div::testInt(t3lib_div::_GP('stype'))) {
1851 $temp_theStartId=t3lib_div::_GP('stype');
1852 $rootLine = $GLOBALS['TSFE']->sys_page->getRootLine($temp_theStartId);
1853 // The page MUST have a rootline with the Level0-page of the current site inside!!
1854 while(list(,$val)=each($rootLine)) {
1855 if($val['uid']==$GLOBALS['TSFE']->tmpl->rootLine[0]['uid']) {
1856 $theStartId=$temp_theStartId;
1857 }
1858 }
1859 } else if (t3lib_div::_GP('stype')) {
1860 if (substr(t3lib_div::_GP('stype'),0,1)=='L') {
1861 $pointer = intval(substr(t3lib_div::_GP('stype'),1));
1862 $theRootLine = $GLOBALS['TSFE']->tmpl->rootLine;
1863 // location Data:
1864 $locDat_arr = explode(':',t3lib_div::_POST('locationData'));
1865 $pId = intval($locDat_arr[0]);
1866 if ($pId) {
1867 $altRootLine = $GLOBALS['TSFE']->sys_page->getRootLine($pId);
1868 ksort($altRootLine);
1869 if (count($altRootLine)) {
1870 // check if the rootline has the real Level0 in it!!
1871 reset($altRootLine);
1872 $hitRoot=0;
1873 $theNewRoot=array();
1874 while(list(,$val)=each($altRootLine)) {
1875 if($hitRoot || $val['uid']==$GLOBALS['TSFE']->tmpl->rootLine[0]['uid']) {
1876 $hitRoot=1;
1877 $theNewRoot[]=$val;
1878 }
1879 }
1880 if ($hitRoot) {
1881 $theRootLine = $theNewRoot; // Override the real rootline if any thing
1882 }
1883 }
1884 }
1885 $key = $this->getKey($pointer,$theRootLine);
1886 $theStartId = $theRootLine[$key]['uid'];
1887 }
1888 }
1889 if (!$theStartId) {
1890 // If not set, we use current page
1891 $theStartId=$GLOBALS['TSFE']->id;
1892 }
1893 // generate page-tree
1894 $search->pageIdList.=$this->getTreeList($theStartId,$depth);
1895
1896 $endClause = 'pages.uid IN ('.$search->pageIdList.$theStartId.') AND pages.doktype in ('.$GLOBALS['TYPO3_CONF_VARS']['FE']['content_doktypes'].($conf['addExtUrlsAndShortCuts']?',3,4':'').') AND pages.no_search=0';
1897 $endClause.=$this->enableFields($search->fTable).$this->enableFields('pages');
1898
1899 // build query
1900 $search->build_search_query($endClause);
1901 #debug($search->queryParts);
1902
1903 // count...
1904 if (t3lib_div::testInt(t3lib_div::_GP('scount'))) {
1905 $search->res_count = t3lib_div::_GP('scount');
1906 } else {
1907 $search->count_query();
1908 }
1909
1910 // range
1911 $spointer = intval(t3lib_div::_GP('spointer'));
1912 if (isset($conf['range'])) {
1913 $theRange = intval($conf['range']);
1914 } else {
1915 $theRange = 20;
1916 }
1917
1918 // Order By:
1919 if (!$conf['noOrderBy']) {
1920 $search->queryParts['ORDERBY'] = 'pages.lastUpdated, pages.tstamp';
1921 }
1922
1923 $search->queryParts['LIMIT'] = $spointer.','.$theRange;
1924
1925 // search...
1926 $search->execute_query();
1927 if ($GLOBALS['TYPO3_DB']->sql_num_rows($search->result)) {
1928 $GLOBALS['TSFE']->register['SWORD_PARAMS'] = $search->get_searchwords();
1929
1930 $total = $search->res_count;
1931 $rangeLow = t3lib_div::intInRange($spointer+1,1,$total);
1932 $rangeHigh = t3lib_div::intInRange($spointer+$theRange,1,$total);
1933 // prev/next url:
1934 $LD = $GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page,$conf['target'],1,'');
1935 $targetPart = $LD['target'] ? ' target="'.htmlspecialchars($LD['target']).'"' : '';
1936 $urlParams = $this->URLqMark($LD['totalURL'],
1937 '&sword='.rawurlencode(t3lib_div::_GP('sword')).
1938 '&scols='.rawurlencode(t3lib_div::_GP('scols')).
1939 '&stype='.rawurlencode(t3lib_div::_GP('stype')).
1940 '&scount='.$total);
1941 // substitution:
1942 $result= $this->cObjGetSingle($conf['layout'],$conf['layout.'], 'layout');
1943 $result = str_replace('###RANGELOW###',$rangeLow,$result);
1944 $result = str_replace('###RANGEHIGH###',$rangeHigh,$result);
1945 $result = str_replace('###TOTAL###',$total,$result);
1946
1947 if ($rangeHigh<$total) {
1948 $next = $this->cObjGetSingle($conf['next'], $conf['next.'], 'next');
1949 $next = '<a href="'.htmlspecialchars($urlParams.'&spointer='.($spointer+$theRange)).'"'.$targetPart.$GLOBALS['TSFE']->ATagParams.'>'.$next.'</a>';
1950 } else $next='';
1951 $result = str_replace('###NEXT###',$next,$result);
1952
1953 if ($rangeLow>1) {
1954 $prev = $this->cObjGetSingle($conf['prev'], $conf['prev.'], 'prev');
1955 $prev = '<a href="'.htmlspecialchars($urlParams.'&spointer='.($spointer-$theRange)).'"'.$targetPart.$GLOBALS['TSFE']->ATagParams.'>'.$prev.'</a>';
1956 } else $prev='';
1957 $result = str_replace('###PREV###',$prev,$result);
1958
1959 // searching result
1960 $theValue = $this->cObjGetSingle($conf['resultObj'], $conf['resultObj.'],'resultObj');
1961 $cObj =t3lib_div::makeInstance('tslib_cObj');
1962 $cObj->setParent($this->data,$this->currentRecord);
1963 $renderCode='';
1964 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($search->result)) {
1965 $cObj->start($row);
1966 $renderCode.=$cObj->cObjGetSingle($conf['renderObj'], $conf['renderObj.'],'renderObj');
1967 }
1968 $theValue.=$this->wrap($renderCode,$conf['renderWrap']);
1969 $theValue = str_replace('###RESULT###',$theValue,$result);
1970 } else {
1971 $theValue = $this->cObjGetSingle($conf['noResultObj'], $conf['noResultObj.'],'noResultObj');
1972 }
1973
1974 $GLOBALS['TT']->setTSlogMessage('Search in fields: '.$search->listOfSearchFields);
1975
1976 // wrapping
1977 $content=$theValue;
1978 if ($conf['wrap']) {
1979 $content=$this->wrap($content, $conf['wrap']);
1980 }
1981 if ($conf['stdWrap.']) {
1982 $content=$this->stdWrap($content, $conf['stdWrap.']);
1983 }
1984 // returning
1985 $GLOBALS['TSFE']->set_no_cache();
1986 return $content;
1987 }
1988 }
1989
1990 /**
1991 * Rendering the cObject, PHP_SCRIPT, PHP_SCRIPT_INT and PHP_SCRIPT_EXT
1992 *
1993 * @param array Array of TypoScript properties
1994 * @param string If "INT", then rendering "PHP_SCRIPT_INT"; If "EXT", then rendering "PHP_SCRIPT_EXT"; Default is rendering "PHP_SCRIPT" (cached)
1995 * @return string Output
1996 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=370&cHash=aa107f2ad8
1997 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=371&cHash=53f71d025e
1998 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=372&cHash=91fe391e1c
1999 */
2000 function PHP_SCRIPT($conf,$ext='') {
2001 $incFile = $GLOBALS['TSFE']->tmpl->getFileName($conf['file']);
2002 $content='';
2003 if ($incFile && $GLOBALS['TSFE']->checkFileInclude($incFile)) {
2004 switch($ext) {
2005 case 'INT':
2006 case 'EXT':
2007 $substKey = $ext.'_SCRIPT.'.$GLOBALS['TSFE']->uniqueHash();
2008 $content.='<!--'.$substKey.'-->';
2009 $GLOBALS['TSFE']->config[$ext.'incScript'][$substKey] = array(
2010 'file'=>$incFile,
2011 'conf'=>$conf,
2012 'type'=>'SCRIPT'
2013 );
2014 if ($ext=='INT') {
2015 $GLOBALS['TSFE']->config[$ext.'incScript'][$substKey]['cObj'] = serialize($this);
2016 } else {
2017 $GLOBALS['TSFE']->config[$ext.'incScript'][$substKey]['data'] = $this->data;
2018 }
2019 break;
2020 default:
2021 // Added 31-12-00: Make backup...
2022 $this->oldData = $this->data;
2023 // Include file..
2024 include('./'.$incFile);
2025 // Added 31-12-00: restore...
2026 if ($RESTORE_OLD_DATA) {
2027 $this->data = $this->oldData;
2028 }
2029 break;
2030 }
2031 }
2032 return $content;
2033 }
2034
2035 /**
2036 * Rendering the cObject, TEMPLATE
2037 *
2038 * @param array Array of TypoScript properties
2039 * @return string Output
2040 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=373&cHash=109a171b1e
2041 * @see substituteMarkerArrayCached()
2042 */
2043 function TEMPLATE($conf) {
2044 $subparts = Array();
2045 $marks = Array();
2046 $wraps = Array();
2047 $content='';
2048
2049 list($PRE,$POST) = explode('|',$conf['markerWrap'] ? $conf['markerWrap'] : '### | ###');
2050 $POST = trim($POST);
2051 $PRE = trim($PRE);
2052
2053 // Getting the content
2054 $content = $this->cObjGetSingle($conf['template'],$conf['template.'],'template');
2055 if ($conf['workOnSubpart']) {
2056 $content = $this->getSubpart($content, $PRE.$conf['workOnSubpart'].$POST);
2057 }
2058 if ($content) {
2059 if ($conf['nonCachedSubst']) { // NON-CACHED:
2060 // Getting marks
2061 if (is_array($conf['marks.'])) {
2062 reset($conf['marks.']);
2063 while(list($theKey,$theValue)=each($conf['marks.'])) {
2064 if (!strstr($theKey,'.')) {
2065 $content = str_replace(
2066 $PRE.$theKey.$POST,
2067 $this->cObjGetSingle($theValue,$conf['marks.'][$theKey.'.'],'marks.'.$theKey),
2068 $content);
2069 }
2070 }
2071 }
2072
2073 // Getting subparts.
2074 if (is_array($conf['subparts.'])) {
2075 reset($conf['subparts.']);
2076 while(list($theKey,$theValue)=each($conf['subparts.'])) {
2077 if (!strstr($theKey,'.')) {
2078 $subpart = $this->getSubpart($content, $PRE.$theKey.$POST);
2079 if ($subpart) {
2080 $this->setCurrentVal($subpart);
2081 $content = $this->substituteSubpart(
2082 $content,
2083 $PRE.$theKey.$POST,
2084 $this->cObjGetSingle($theValue,$conf['subparts.'][$theKey.'.'],'subparts.'.$theKey),
2085 1
2086 );
2087 }
2088 }
2089 }
2090 }
2091 // Getting subpart wraps
2092 if (is_array($conf['wraps.'])) {
2093 reset($conf['wraps.']);
2094 while(list($theKey,$theValue)=each($conf['wraps.'])) {
2095 if (!strstr($theKey,'.')) {
2096 $subpart = $this->getSubpart($content, $PRE.$theKey.$POST);
2097 if ($subpart) {
2098 $this->setCurrentVal($subpart);
2099 $content = $this->substituteSubpart(
2100 $content,
2101 $PRE.$theKey.$POST,
2102 explode('|',$this->cObjGetSingle($theValue,$conf['wraps.'][$theKey.'.'],'wraps.'.$theKey)),
2103 1
2104 );
2105 }
2106 }
2107 }
2108 }
2109 } else { // CACHED
2110 // Getting subparts.
2111 if (is_array($conf['subparts.'])) {
2112 reset($conf['subparts.']);
2113 while(list($theKey,$theValue)=each($conf['subparts.'])) {
2114 if (!strstr($theKey,'.')) {
2115 $subpart = $this->getSubpart($content, $PRE.$theKey.$POST);
2116 if ($subpart) {
2117 $GLOBALS['TSFE']->register['SUBPART_'.$theKey] = $subpart;
2118 $subparts[$theKey]['name'] = $theValue;
2119 $subparts[$theKey]['conf'] = $conf['subparts.'][$theKey.'.'];
2120 }
2121 }
2122 }
2123 }
2124 // Getting marks
2125 if (is_array($conf['marks.'])) {
2126 reset($conf['marks.']);
2127 while(list($theKey,$theValue)=each($conf['marks.'])) {
2128 if (!strstr($theKey,'.')) {
2129 $marks[$theKey]['name'] = $theValue;
2130 $marks[$theKey]['conf'] = $conf['marks.'][$theKey.'.'];
2131 }
2132 }
2133 }
2134 // Getting subpart wraps
2135 if (is_array($conf['wraps.'])) {
2136 reset($conf['wraps.']);
2137 while(list($theKey,$theValue)=each($conf['wraps.'])) {
2138 if (!strstr($theKey,'.')) {
2139 $wraps[$theKey]['name'] = $theValue;
2140 $wraps[$theKey]['conf'] = $conf['wraps.'][$theKey.'.'];
2141 }
2142 }
2143 }
2144 // Getting subparts
2145 $subpartArray =array();
2146 reset($subparts);
2147 while(list($theKey,$theValue)=each($subparts)) {
2148 // Set current with the content of the subpart...
2149 $this->data[$this->currentValKey] = $GLOBALS['TSFE']->register['SUBPART_'.$theKey];
2150 // Get subpart cObject and substitute it!
2151 $subpartArray[$PRE.$theKey.$POST] = $this->cObjGetSingle($theValue['name'],$theValue['conf'],'subparts.'.$theKey);
2152 }
2153 $this->data[$this->currentValKey] = ''; // Reset current to empty
2154
2155 // Getting marks
2156 $markerArray =array();
2157 reset($marks);
2158 while(list($theKey,$theValue)=each($marks)) {
2159 $markerArray[$PRE.$theKey.$POST] = $this->cObjGetSingle($theValue['name'],$theValue['conf'],'marks.'.$theKey);
2160 }
2161 // Getting wraps
2162 $subpartWraps =array();
2163 reset($wraps);
2164 while(list($theKey,$theValue)=each($wraps)) {
2165 $subpartWraps[$PRE.$theKey.$POST] = explode('|',$this->cObjGetSingle($theValue['name'],$theValue['conf'],'wraps.'.$theKey));
2166 }
2167
2168 // Substitution
2169 if ($conf['substMarksSeparately']) {
2170 $content = $this->substituteMarkerArrayCached($content,array(),$subpartArray,$subpartWraps);
2171 $content = $this->substituteMarkerArray($content, $markerArray);
2172 } else {
2173 $content = $this->substituteMarkerArrayCached($content,$markerArray,$subpartArray,$subpartWraps);
2174 }
2175 }
2176 }
2177 return $content;
2178 }
2179
2180 /**
2181 * Rendering the cObject, MULTIMEDIA
2182 *
2183 * @param array Array of TypoScript properties
2184 * @return string Output
2185 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=374&cHash=efd88ab4a9
2186 */
2187 function MULTIMEDIA($conf) {
2188 $content='';
2189 $filename=$this->stdWrap($conf['file'],$conf['file.']);
2190 $incFile = $GLOBALS['TSFE']->tmpl->getFileName($filename);
2191 if ($incFile) {
2192 $fileinfo = t3lib_div::split_fileref($incFile);
2193 if (t3lib_div::inList('txt,html,htm',$fileinfo['fileext'])) {
2194 $content = $GLOBALS['TSFE']->tmpl->fileContent($incFile);
2195 } else {
2196 // default params...
2197 $parArray=array();
2198 // src is added
2199 $parArray['src']='src="'.$GLOBALS['TSFE']->absRefPrefix.$incFile.'"';
2200 if (t3lib_div::inList('au,wav,mp3',$fileinfo['fileext'])) {
2201 }
2202 if (t3lib_div::inList('avi,mov,mpg,asf,wmv',$fileinfo['fileext'])) {
2203 $parArray['width'] = 'width="200"';
2204 $parArray['height'] = 'height="200"';
2205 }
2206 if (t3lib_div::inList('swf,swa,dcr',$fileinfo['fileext'])) {
2207 $parArray['quality'] = 'quality="high"';
2208 }
2209 if (t3lib_div::inList('class',$fileinfo['fileext'])) {
2210 $parArray['width'] = 'width="200"';
2211 $parArray['height'] = 'height="200"';
2212 }
2213
2214 // fetching params
2215 $lines = explode(chr(10), $this->stdWrap($conf['params'],$conf['params.']));
2216 while(list(,$l)=each($lines)) {
2217 $parts = explode('=', $l);
2218 $parameter = strtolower(trim($parts[0]));
2219 $value = trim($parts[1]);
2220 if ((string)$value!='') {
2221 $parArray[$parameter] = $parameter.'="'.htmlspecialchars($value).'"';
2222 } else {
2223 unset($parArray[$parameter]);
2224 }
2225 }
2226 if ($fileinfo['fileext']=='class') {
2227 unset($parArray['src']);
2228 $parArray['code'] = 'code="'.htmlspecialchars($fileinfo['file']).'"';
2229 $parArray['codebase'] = 'codebase="'.htmlspecialchars($fileinfo['path']).'"';
2230 $content='<applet '.implode($parArray,' ').'></applet>';
2231 } else {
2232 $content='<embed '.implode($parArray,' ').'></embed>';
2233 }
2234 }
2235 }
2236
2237 if ($conf['stdWrap.']) {
2238 $content=$this->stdWrap($content, $conf['stdWrap.']);
2239 }
2240
2241 return $content;
2242 }
2243
2244
2245
2246
2247
2248
2249
2250
2251
2252
2253
2254
2255
2256
2257
2258
2259
2260 /************************************
2261 *
2262 * Various helper functions for content objects:
2263 *
2264 ************************************/
2265
2266 /**
2267 * Creates a link to a netprint application on another website (where the "netprint" extension is running")
2268 * Related to the extension "netprint"
2269 *
2270 * @param string The input string to add the link to.
2271 * @param array Array with information about the image.
2272 * @param array TypoScript properties for the netprint application.
2273 * @return string The input string possibly with the netprint link before/after
2274 * @access private
2275 */
2276 function netprintApplication_offsiteLinkWrap($str,$imgConf,$conf) {
2277 if ($conf['url'] && @is_file($imgConf['origFile'])) {
2278 $thisUrl = $conf['thisUrl'] ? $conf['thisUrl'] : t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR');
2279 $origFile=$thisUrl.$imgConf['origFile'];
2280 // Original file dimensions:
2281 $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
2282 $gifCreator->init();
2283 $origDim = $gifCreator->getImageDimensions($imgConf['origFile']);
2284 if (!$conf['linkOnlyPixelsAbove'] || $origDim[0]*$origDim[1]>$conf['linkOnlyPixelsAbove']) {
2285 // Set parameters
2286 $thumbFile=$thisUrl.$imgConf['3'].'|'.$imgConf[0].'x'.$imgConf[1].'|'.$origDim[0].'x'.$origDim[1].'|'.filesize($imgConf['origFile']).'|'.filemtime($imgConf['origFile']);
2287 // Set url:
2288 $url = $conf['url']
2289 .'&NP[offsite][1]='.rawurlencode($origFile)
2290 .'&NP[offsite_thumb][1]='.rawurlencode($thumbFile);
2291 $linkCObject = $this->cObjGetSingle($conf['cObject'],$conf['cObject.']);
2292 if ($linkCObject) {
2293 $ATagParams = trim($conf['ATagParams']) ? ' '.trim($conf['ATagParams']) : '';
2294 $linkCObject='<a href="'.htmlspecialchars($url).'"'.$ATagParams.'>'.$linkCObject.'</a>';
2295 $linkCObject=$this->stdWrap($linkCObject,$conf['outerStdWrap.']);
2296 if ($conf['before']) {
2297 $str=$linkCObject.$str;
2298 } else {
2299 $str=$str.$linkCObject;
2300 }
2301 }
2302 }
2303 }
2304 return $str;
2305 }
2306
2307 /**
2308 * Returns a default value for a form field in the FORM cObject.
2309 * Page CANNOT be cached because that would include the inserted value for the current user.
2310 *
2311 * @param boolean If noValueInsert OR if the no_cache flag for this page is NOT set, the original default value is returned.
2312 * @param string $fieldName: The POST var name to get default value for
2313 * @param string $defaultVal: The current default value
2314 * @return string The default value, either from INPUT var or the current default, based on whether caching is enabled or not.
2315 * @access private
2316 */
2317 function getFieldDefaultValue($noValueInsert, $fieldName, $defaultVal) {
2318 if (!$GLOBALS['TSFE']->no_cache || (!isset($GLOBALS['HTTP_POST_VARS'][$fieldName]) && !isset($GLOBALS['HTTP_GET_VARS'][$fieldName])) || $noValueInsert) {
2319 return $defaultVal;
2320 } else {
2321 return t3lib_div::_GP($fieldName);
2322 }
2323 }
2324
2325 /**
2326 * Returns a <img> tag with the image file defined by $file and processed according to the properties in the TypoScript array.
2327 * 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().
2328 *
2329 * @param string File TypoScript resource
2330 * @param array TypoScript configuration properties
2331 * @return string <img> tag, (possibly wrapped in links and other HTML) if any image found.
2332 * @access private
2333 * @see IMAGE()
2334 */
2335 function cImage($file,$conf) {
2336 $info = $this->getImgResource($file,$conf['file.']);
2337 $GLOBALS['TSFE']->lastImageInfo=$info;
2338 if (is_array($info)) {
2339 $info[3] = t3lib_div::png_to_gif_by_imagemagick($info[3]);
2340 $GLOBALS['TSFE']->imagesOnPage[]=$info[3]; // This array is used to collect the image-refs on the page...
2341 $altParam = $this->getAltParam($conf);
2342 $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).' />';
2343 if ($conf['linkWrap']) {
2344 $theValue = $this->linkWrap($theValue,$conf['linkWrap']);
2345 } elseif ($conf['imageLinkWrap']) {
2346 $theValue = $this->imageLinkWrap($theValue,$info['origFile'],$conf['imageLinkWrap.']);
2347 }
2348 return $this->wrap($theValue,$conf['wrap']);
2349 }
2350 }
2351
2352 /**
2353 * Wraps the input string in link-tags that opens the image in a new window.
2354 *
2355 * @param string String to wrap, probably an <img> tag
2356 * @param string The original image file
2357 * @param array TypoScript properties for the "imageLinkWrap" function
2358 * @return string The input string, $string, wrapped as configured.
2359 * @see cImage()
2360 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=316&cHash=2848266da6
2361 */
2362 function imageLinkWrap($string,$imageFile,$conf) {
2363 $a1='';
2364 $a2='';
2365 $content=$string;
2366 if ($this->stdWrap($conf['enable'],$conf['enable.'])) {
2367 $content=$this->typolink($string, $conf['typolink.']);
2368 // imageFileLink:
2369 if ($content==$string && @is_file($imageFile)) {
2370 $params = '';
2371 if ($conf['width']) {$params.='&width='.rawurlencode($conf['width']);}
2372 if ($conf['height']) {$params.='&height='.rawurlencode($conf['height']);}
2373 if ($conf['effects']) {$params.='&effects='.rawurlencode($conf['effects']);}
2374 if ($conf['sample']) {$params.='&sample=1';}
2375 if ($conf['alternativeTempPath']) {$params.='&alternativeTempPath='.rawurlencode($conf['alternativeTempPath']);}
2376
2377 if ($conf['bodyTag']) {$params.='&bodyTag='.rawurlencode($conf['bodyTag']);}
2378 if ($conf['title']) {$params.='&title='.rawurlencode($conf['title']);}
2379 if ($conf['wrap']) {$params.='&wrap='.rawurlencode($conf['wrap']);}
2380
2381 $md5_value = md5($imageFile.'|'.$conf['width'].'|'.$conf['height'].'|'.$conf['effects'].'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'].'|');
2382
2383 $params.= '&md5='.$md5_value;
2384 $url = $GLOBALS['TSFE']->absRefPrefix.'showpic.php?file='.rawurlencode($imageFile).$params;
2385 if ($conf['JSwindow.']['altUrl'] || $conf['JSwindow.']['altUrl.']) {
2386 $altUrl = $this->stdWrap($conf['JSwindow.']['altUrl'], $conf['JSwindow.']['altUrl.']);
2387 if ($altUrl) {
2388 $url=$altUrl;
2389 }
2390 }
2391
2392 if ($conf['JSwindow']) {
2393 $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
2394 $gifCreator->init();
2395 $gifCreator->mayScaleUp = 0;
2396 $dims = $gifCreator->getImageScale($gifCreator->getImageDimensions($imageFile),$conf['width'],$conf['height'],'');
2397 $offset = t3lib_div::intExplode(',',$conf['JSwindow.']['expand'].',');
2398
2399 $a1='<a href="#" onclick="'.
2400 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;').
2401 '"'.$GLOBALS['TSFE']->ATagParams.'>';
2402 $a2='</a>';
2403 $GLOBALS['TSFE']->setJS('openPic');
2404 } else {
2405 $target = ' target="thePicture"';
2406 if (isset($conf['target'])) {
2407 $target= $conf['target'] ? ' target="'.$conf['target'].'"' : '';
2408 }
2409 $a1='<a href="'.htmlspecialchars($url).'"'.$target.$GLOBALS['TSFE']->ATagParams.'>';
2410 $a2='</a>';
2411 }
2412 $content=$a1.$string.$a2;
2413 }
2414 }
2415
2416 return $content;
2417 }
2418
2419 /**
2420 * Returns content of a file. If its an image the content of the file is not returned but rather an image tag is.
2421 *
2422 * @param string The filename, being a TypoScript resource data type
2423 * @return string If jpg,gif,jpeg,png: returns image_tag with picture in. If html,txt: returns content string
2424 * @see FILE()
2425 */
2426 function fileResource($fName) {
2427 $incFile = $GLOBALS['TSFE']->tmpl->getFileName($fName);
2428 if ($incFile) {
2429 $fileinfo = t3lib_div::split_fileref($incFile);
2430 if (t3lib_div::inList('jpg,gif,jpeg,png',$fileinfo['fileext'])) {
2431 $imgFile = $incFile;
2432 $imgInfo = @getImageSize($imgFile);
2433 return '<img src="'.$GLOBALS['TSFE']->absRefPrefix.$imgFile.'" width="'.$imgInfo[0].'" height="'.$imgInfo[1].'" border="0" alt="" title="" />';
2434 } elseif (filesize($incFile)<1024*1024) {
2435 return $GLOBALS['TSFE']->tmpl->fileContent($incFile);
2436 }
2437 }
2438 }
2439
2440 /**
2441 * Sets the SYS_LASTCHANGED timestamp if input timestamp is larger than current value.
2442 * The SYS_LASTCHANGED timestamp can be used by various caching/indexing applications to determine if the page has new content.
2443 * Therefore you should call this function with the last-changed timestamp of any element you display.
2444 *
2445 * @param integer Unix timestamp (number of seconds since 1970)
2446 * @return void
2447 * @see tslib_fe::setSysLastChanged()
2448 */
2449 function lastChanged($tstamp) {
2450 $tstamp = intval($tstamp);
2451 if ($tstamp>intval($GLOBALS['TSFE']->register['SYS_LASTCHANGED'])) {
2452 $GLOBALS['TSFE']->register['SYS_LASTCHANGED'] = $tstamp;
2453 }
2454 }
2455
2456 /**
2457 * Wraps the input string by the $wrap value and implements the "linkWrap" data type as well.
2458 * 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.
2459 *
2460 * @param string Input string
2461 * @param string A string where the first two parts separated by "|" (vertical line) will be wrapped around the input string
2462 * @return string Wrapped output string
2463 * @see wrap(), cImage(), FILE()
2464 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=282&cHash=831a95115d
2465 */
2466 function linkWrap($content,$wrap) {
2467 $wrapArr = explode('|', $wrap);
2468 if (ereg("\{([0-9]*)\}",$wrapArr[0],$reg)) {
2469 if ($uid = $GLOBALS['TSFE']->tmpl->rootLine[$reg[1]]['uid']) {
2470 $wrapArr[0] = str_replace($reg[0],$uid,$wrapArr[0]);
2471 }
2472 }
2473 return trim($wrapArr[0]).$content.trim($wrapArr[1]);
2474 }
2475
2476 /**
2477 * An abstraction method which creates an alt or title parameter for an HTML img tag.
2478 *
2479 * @param array TypoScript configuration properties
2480 * @return string Parameter string containing alt and title parameters (if any)
2481 * @see IMGTEXT(), cImage()
2482 */
2483 function getAltParam($conf) {
2484 $altText = $this->stdWrap($conf['altText'],$conf['altText.']);
2485 $altParam = ' alt="'.htmlspecialchars(strip_tags($altText)).'"';
2486
2487 $titleText = $this->stdWrap($conf['titleText'],$conf['titleText.']);
2488 if ($titleText) {
2489 $altParam .= ' title="'.htmlspecialchars(strip_tags($titleText)).'"';
2490 } else {
2491 $altParam .= ' title="'.htmlspecialchars(strip_tags($altText)).'"';
2492 }
2493 return $altParam;
2494 }
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514 /***********************************************
2515 *
2516 * HTML template processing functions
2517 *
2518 ***********************************************/
2519
2520 /**
2521 * Returns a subpart from the input content stream.
2522 * 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.
2523 * 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
2524 *
2525 * @param string The content stream, typically HTML template content.
2526 * @param string The marker string, typically on the form "###[the marker string]###"
2527 * @return string The subpart found, if found.
2528 * @see substituteSubpart(), t3lib_parsehtml::getSubpart()
2529 */
2530 function getSubpart($content, $marker) {
2531 if ($marker && strstr($content,$marker)) {
2532 $start = strpos($content, $marker)+strlen($marker);
2533 $stop = @strpos($content, $marker, $start+1);
2534 $sub = substr($content, $start, $stop-$start);
2535
2536 $reg=Array();
2537 ereg('^[^<]*-->',$sub,$reg);
2538 $start+=strlen($reg[0]);
2539
2540 $reg=Array();
2541 ereg('<!--[^>]*$',$sub,$reg);
2542 $stop-=strlen($reg[0]);
2543
2544 return substr($content, $start, $stop-$start);
2545 }
2546 }
2547
2548 /**
2549 * Substitute subpart in input template stream.
2550 * This function substitutes a subpart in $content with the content of $subpartContent.
2551 *
2552 * @param string The content stream, typically HTML template content.
2553 * @param string The marker string, typically on the form "###[the marker string]###"
2554 * @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.
2555 * @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!
2556 * @return string The processed HTML content string.
2557 * @see getSubpart(), t3lib_parsehtml::substituteSubpart()
2558 */
2559 function substituteSubpart($content,$marker,$subpartContent,$recursive=1) {
2560 $start = strpos($content, $marker);
2561 $stop = @strpos($content, $marker, $start+1)+strlen($marker);
2562 if ($start && $stop>$start) {
2563 // code before
2564 $before = substr($content, 0, $start);
2565 $reg=Array();
2566 ereg('<!--[^>]*$',$before,$reg);
2567 $start-=strlen($reg[0]);
2568 $before = substr($content, 0, $start);
2569 // code after
2570 $after = substr($content, $stop);
2571 $reg=Array();
2572 ereg('^[^<]*-->',$after,$reg);
2573 $stop+=strlen($reg[0]);
2574 $after = substr($content, $stop);
2575 // replace?
2576 if (is_array($subpartContent)) {