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