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