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