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