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