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