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