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