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