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