PageRenderTime 13ms CodeModel.GetById 88ms app.highlight 242ms RepoModel.GetById 12ms app.codeStats 22ms

/typo3/sysext/cms/tslib/class.tslib_content.php

https://bitbucket.org/linxpinx/mercurial
PHP | 8482 lines | 5452 code | 889 blank | 2141 comment | 1421 complexity | e3ae4b6f9839aee5a8f8d74520ec6656 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1<?php
   2/***************************************************************
   3*  Copyright notice
   4*
   5*  (c) 1999-2010 Kasper Skaarhoj (kasperYYYY@typo3.com)
   6*  All rights reserved
   7*
   8*  This script is part of the TYPO3 project. The TYPO3 project is
   9*  free software; you can redistribute it and/or modify
  10*  it under the terms of the GNU General Public License as published by
  11*  the Free Software Foundation; either version 2 of the License, or
  12*  (at your option) any later version.
  13*
  14*  The GNU General Public License can be found at
  15*  http://www.gnu.org/copyleft/gpl.html.
  16*  A copy is found in the textfile GPL.txt and important notices to the license
  17*  from the author is found in LICENSE.txt distributed with these scripts.
  18*
  19*
  20*  This script is distributed in the hope that it will be useful,
  21*  but WITHOUT ANY WARRANTY; without even the implied warranty of
  22*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  23*  GNU General Public License for more details.
  24*
  25*  This copyright notice MUST APPEAR in all copies of the script!
  26***************************************************************/
  27/**
  28 * Contains classes for Content Rendering based on TypoScript Template configuration
  29 *
  30 * $Id: class.tslib_content.php 8420 2010-07-28 09:15:53Z ohader $
  31 * Revised for TYPO3 3.6 June/2003 by Kasper Skaarhoj
  32 * XHTML compliant
  33 *
  34 * class tslib_cObj			:		All main TypoScript features, rendering of content objects (cObjects). This class is the backbone of TypoScript Template rendering.
  35 * class tslib_controlTable		:		Makes a table CTABLE (TS cObject)
  36 * class tslib_tableOffset		:		Makes a table-offset (TS)
  37 * class tslib_frameset			: 		Generates framesets (TS)
  38 *
  39 * @author	Kasper Skaarhoj <kasperYYYY@typo3.com>
  40 */
  41/**
  42 * [CLASS/FUNCTION INDEX of SCRIPT]
  43 *
  44 *
  45 *
  46 *  256: class tslib_cObj
  47 *  353:     function start($data,$table='')
  48 *  387:     function setParent($data,$currentRecord)
  49 *
  50 *              SECTION: CONTENT_OBJ:
  51 *  412:     function getCurrentVal()
  52 *  423:     function setCurrentVal($value)
  53 *  436:     function cObjGet($setup,$addKey='')
  54 *  460:     function cObjGetSingle($name,$conf,$TSkey='__')
  55 *
  56 *              SECTION: Functions rendering content objects (cObjects)
  57 *  629:     function HTML($conf)
  58 *  640:     function TEXT($conf)
  59 *  651:     function CLEARGIF($conf)
  60 *  670:     function COBJ_ARRAY($conf,$ext='')
  61 *  706:     function USER($conf,$ext='')
  62 *  733:     function FILE($conf)
  63 *  749:     function IMAGE($conf)
  64 *  768:     function IMG_RESOURCE($conf)
  65 *  780:     function IMGTEXT($conf)
  66 * 1203:     function CONTENT($conf)
  67 * 1290:     function RECORDS($conf)
  68 * 1370:     function HMENU($conf)
  69 * 1402:     function CTABLE ($conf)
  70 * 1440:     function OTABLE ($conf)
  71 * 1455:     function COLUMNS ($conf)
  72 * 1534:     function HRULER ($conf)
  73 * 1559:     function CASEFUNC ($conf)
  74 * 1584:     function LOAD_REGISTER($conf,$name)
  75 * 1624:     function FORM($conf,$formData='')
  76 * 2145:     function SEARCHRESULT($conf)
  77 * 2311:     function PHP_SCRIPT($conf,$ext='')
  78 * 2354:     function TEMPLATE($conf)
  79 * 2505:     function MULTIMEDIA($conf)
  80 *
  81 *              SECTION: Various helper functions for content objects:
  82 * 2592:     function getSlidePids($pidList, $pidConf)
  83 * 2623:     function getFieldDefaultValue($noValueInsert, $fieldName, $defaultVal)
  84 * 2641:     function cImage($file,$conf)
  85 * 2669:     function getBorderAttr($borderAttr)
  86 * 2685:     function imageLinkWrap($string,$imageFile,$conf)
  87 * 2765:     function fileResource($fName, $addParams='alt="" title=""')
  88 * 2788:     function lastChanged($tstamp)
  89 * 2805:     function linkWrap($content,$wrap)
  90 * 2824:     function getAltParam($conf, $longDesc=true)
  91 * 2859:     function cleanFormName($name)
  92 * 2875:     function getATagParams($conf, $addGlobal=1)
  93 *
  94 *              SECTION: HTML template processing functions
  95 * 2922:     function getSubpart($content, $marker)
  96 * 2938:     function substituteSubpart($content,$marker,$subpartContent,$recursive=1)
  97 * 2951:     function substituteMarker($content,$marker,$markContent)
  98 * 2971:     function substituteMarkerArrayCached($content,$markContentArray=array(),$subpartContentArray=array(),$wrappedSubpartContentArray=array())
  99 * 3069:     function substituteMarkerArray($content,$markContentArray,$wrap='',$uppercase=0)
 100 * 3081:     function substituteMarkerInObject(&$tree, $markContentArray)
 101 * 3104:     function fillInMarkerArray($markContentArray, $row, $fieldList='', $nl2br=TRUE, $prefix='FIELD_', $HSC=FALSE)
 102 *
 103 *              SECTION: "stdWrap" + sub functions
 104 * 3167:     function stdWrap($content,$conf)
 105 * 3364:     function numRows($conf)
 106 * 3388:     function listNum($content,$listNum,$char)
 107 * 3408:     function checkIf($conf)
 108 * 3471:     function filelist($data)
 109 * 3553:     function clean_directory($theDir)
 110 * 3571:     function HTMLparser_TSbridge($theValue, $conf)
 111 * 3585:     function dataWrap($content,$wrap)
 112 * 3598:     function insertData($str)
 113 * 3628:     function prefixComment($str,$conf,$content)
 114 * 3652:     function substring($content,$options)
 115 * 3670:     function crop($content,$options)
 116 * 3702:     function removeBadHTML($text, $conf)
 117 * 3746:     function textStyle($theValue, $conf)
 118 * 3813:     function tableStyle($theValue, $conf)
 119 * 3854:     function addParams($content,$conf)
 120 * 3895:     function filelink($theValue, $conf)
 121 * 3966:     function locDataJU($jumpUrl,$conf)
 122 * 3997:     function calc($val)
 123 * 4026:     function calcIntExplode($delim, $string)
 124 * 4046:     function splitObj($value, $conf)
 125 * 4108:     function parseFunc($theValue, $conf, $ref='')
 126 * 4218:     function _parseFunc ($theValue, $conf)
 127 * 4424:     function encaps_lineSplit($theValue, $conf)
 128 * 4507:     function http_makelinks($data,$conf)
 129 * 4574:     function mailto_makelinks($data,$conf)
 130 * 4617:     function getImgResource($file,$fileArray)
 131 *
 132 *              SECTION: Data retrieval etc.
 133 * 4810:     function getFieldVal($field)
 134 * 4830:     function getData($string,$fieldArray)
 135 * 4975:     function rootLineValue($key,$field,$slideBack=0,$altRootLine='')
 136 * 4997:     function getGlobal($var, $source=NULL)
 137 * 5033:     function getKey($key,$arr)
 138 * 5056:     function TCAlookup($inputValue,$conf)
 139 *
 140 *              SECTION: Link functions (typolink)
 141 * 5116:     function typoLink($linktxt, $conf)
 142 * 5481:     function typoLink_URL($conf)
 143 * 5499:     function getTypoLink($label,$params,$urlParameters=array(),$target='')
 144 * 5526:     function getTypoLink_URL($params,$urlParameters=array(),$target='')
 145 * 5538:     function typolinkWrap($conf)
 146 * 5551:     function currentPageUrl($urlParameters=array(),$id=0)
 147 * 5564:     function getClosestMPvalueForPage($pageId, $raw=FALSE)
 148 * 5619:     function getMailTo($mailAddress,$linktxt,$initP='?')
 149 * 5658:     function getQueryArguments($conf,$overruleQueryArgs=array(),$forceArgs=FALSE)
 150 *
 151 *              SECTION: Miscellaneous functions, stand alone
 152 * 5754:     function wrap($content,$wrap,$char='|')
 153 * 5770:     function noTrimWrap($content,$wrap)
 154 * 5784:     function wrapSpace($content, $wrap)
 155 * 5810:     function callUserFunction($funcName,$conf,$content)
 156 * 5851:     function processParams($params)
 157 * 5869:     function keywords($content)
 158 * 5886:     function caseshift($theValue, $case)
 159 * 5911:     function HTMLcaseshift($theValue, $case)
 160 * 5940:     function bytes($sizeInBytes,$labels)
 161 * 5951:     function calcAge($seconds,$labels)
 162 * 5983:     function sendNotifyEmail($msg, $recipients, $cc, $email_from, $email_fromName='', $replyTo='')
 163 * 6010:     function URLqMark($url,$params)
 164 * 6026:     function checkEmail($email)
 165 * 6038:     function clearTSProperties($TSArr,$propList)
 166 * 6057:     function mergeTSRef($confArr,$prop)
 167 * 6080:     function joinTSarrays($conf,$old_conf)
 168 * 6103:     function gifBuilderTextBox($gifbuilderConf, $conf, $text)
 169 * 6159:     function linebreaks($string,$chars,$maxLines=0)
 170 * 6190:     function getUpdateJS($dataArray, $formName, $arrPrefix, $fieldList)
 171 *
 172 *              SECTION: Database functions, making of queries
 173 * 6260:     function DBgetDelete($table, $uid, $doExec=FALSE)
 174 * 6292:     function DBgetUpdate($table, $uid, $dataArr, $fieldList, $doExec=FALSE)
 175 * 6334:     function DBgetInsert($table, $pid, $dataArr, $fieldList, $doExec=FALSE)
 176 * 6371:     function DBmayFEUserEdit($table,$row, $feUserRow, $allowedGroups='',$feEditSelf=0)
 177 * 6411:     function DBmayFEUserEditSelect($table,$feUserRow,$allowedGroups='',$feEditSelf=0)
 178 * 6451:     function enableFields($table,$show_hidden=0)
 179 * 6475:     function getTreeList($id,$depth,$begin=0,$dontCheckEnableFields=FALSE,$addSelectFields='',$moreWhereClauses='', $prevId_array=array(), $recursionLevel=0)
 180 * 6583:     function whereSelectFromList($field,$value)
 181 * 6601:     function exec_mm_query($select,$local_table,$mm_table,$foreign_table,$whereClause='',$groupBy='',$orderBy='',$limit='')
 182 * 6628:     function exec_mm_query_uidList($select,$local_table_uidlist,$mm_table,$foreign_table='',$whereClause='',$groupBy='',$orderBy='',$limit='')
 183 * 6649:     function searchWhere($sw,$searchFieldList,$searchTable='')
 184 * 6685:     function exec_getQuery($table, $conf)
 185 * 6703:     function getQuery($table, $conf, $returnQueryArray=FALSE)
 186 * 6783:     function getWhere($table,$conf, $returnQueryArray=FALSE)
 187 * 6878:     function checkPidArray($listArr)
 188 * 6902:     function checkPid($uid)
 189 *
 190 *              SECTION: Frontend editing functions
 191 * 6959:     function editPanel($content, $conf, $currentRecord='', $dataArr=array())
 192 * 7146:     function editIcons($content,$params, $conf=array(), $currentRecord='', $dataArr=array(),$addUrlParamStr='')
 193 * 7228:     function editPanelLinkWrap($string,$formName,$cmd,$currentRecord='',$confirm='',$nPid='')
 194 * 7270:     function editPanelLinkWrap_doWrap($string,$url,$currentRecord)
 195 * 7298:     function editPanelPreviewBorder($table,$row,$content,$thick,$conf=array())
 196 * 7320:     function isDisabled($table,$row)
 197 *
 198 *
 199 * 7351: class tslib_frameset
 200 * 7361:     function make($setup)
 201 * 7398:     function frameParams($setup, $typeNum)
 202 * 7426:     function framesetParams($setup)
 203 *
 204 *
 205 * 7459: class tslib_tableOffset
 206 * 7471:     function start($content,$offset)
 207 *
 208 *
 209 * 7549: class tslib_controlTable
 210 * 7584:     function start($offset,$cMargins)
 211 *
 212 * TOTAL FUNCTIONS: 135
 213 * (This index is automatically created/updated by the extension "extdeveval")
 214 *
 215 */
 216
 217	// Object TypoScript library included:
 218if(t3lib_extMgm::isLoaded('obts')) {
 219	require_once(t3lib_extMgm::extPath('obts').'_tsobject/_tso.php');
 220}
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238/**
 239 * This class contains all main TypoScript features.
 240 * This includes the rendering of TypoScript content objects (cObjects).
 241 * Is the backbone of TypoScript Template rendering.
 242 *
 243 * There are lots of functions you can use from your include-scripts.
 244 * The class "tslib_cObj" is normally instantiated and referred to as "cObj".
 245 * When you call your own PHP-code typically through a USER or USER_INT cObject then it is this class that instantiates the object and calls the main method. Before it does so it will set (if you are using classes) a reference to itself in the internal variable "cObj" of the object. Thus you can access all functions and data from this class by $this->cObj->... from within you classes written to be USER or USER_INT content objects.
 246 *
 247 * @author	Kasper Skaarhoj <kasperYYYY@typo3.com>
 248 * @package TYPO3
 249 * @subpackage tslib
 250 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&cHash=4ad9d7acb4
 251 */
 252class tslib_cObj {
 253	var $align = Array ('center', 'right', 'left');
 254
 255	/**
 256	 * Holds ImageMagick parameters and extensions used for compression
 257	 *
 258	 * @see IMGTEXT()
 259	 *
 260	 * 0= Default
 261	 * 1= Dont change! (removes all parameters for the image_object!!)
 262	 * 1x = GIFs
 263	 * 2x = JPGs
 264	 */
 265	var $image_compression = Array(
 266		10 => Array('params'=>'', 'ext'=>'gif'),
 267		11 => Array('params'=>'-colors 128', 'ext'=>'gif'),
 268		12 => Array('params'=>'-colors 64', 'ext'=>'gif'),
 269		13 => Array('params'=>'-colors 32', 'ext'=>'gif'),
 270		14 => Array('params'=>'-colors 16', 'ext'=>'gif'),
 271		15 => Array('params'=>'-colors 8', 'ext'=>'gif'),
 272
 273		30 => Array('params'=>'-colors 256', 'ext'=>'png'),
 274		31 => Array('params'=>'-colors 128', 'ext'=>'png'),
 275		32 => Array('params'=>'-colors 64', 'ext'=>'png'),
 276		33 => Array('params'=>'-colors 32', 'ext'=>'png'),
 277		34 => Array('params'=>'-colors 16', 'ext'=>'png'),
 278		35 => Array('params'=>'-colors 8', 'ext'=>'png'),
 279		39 => Array('params'=>'', 'ext'=>'png'),
 280
 281		20 => Array('params'=>'-quality 100', 'ext'=>'jpg'),
 282		21 => Array('params'=>'-quality 90', 'ext'=>'jpg'),
 283		22 => Array('params'=>'-quality 80', 'ext'=>'jpg'),
 284		23 => Array('params'=>'-quality 70', 'ext'=>'jpg'),
 285		24 => Array('params'=>'-quality 60', 'ext'=>'jpg'),
 286		25 => Array('params'=>'-quality 50', 'ext'=>'jpg'),
 287		26 => Array('params'=>'-quality 40', 'ext'=>'jpg'),
 288		27 => Array('params'=>'-quality 30', 'ext'=>'jpg'),
 289		28 => Array('params'=>'-quality 20', 'ext'=>'jpg')
 290	);
 291
 292	/**
 293	 * ImageMagick parameters for image effects
 294	 *
 295	 * @see IMGTEXT()
 296	 */
 297	var $image_effects = Array(
 298		1 => '-rotate 90',
 299		2 => '-rotate 270',
 300		3 => '-rotate 180',
 301		10 => '-colorspace GRAY',
 302		11 => '-sharpen 70',
 303		20 => '-normalize',
 304		23 => '-contrast',
 305		25 => '-gamma 1.3',
 306		26 => '-gamma 0.8'
 307	);
 308
 309	/**
 310	 * Loaded with the current data-record.
 311	 *
 312	 * If the instance of this class is used to render records from the database those records are found in this array.
 313	 * The function stdWrap has TypoScript properties that fetch field-data from this array.
 314	 * @see init()
 315	 */
 316	var $data = Array();
 317	protected $table = '';
 318	var $oldData = Array();				// Used for backup...
 319	var $alternativeData ='';			// If this is set with an array before stdWrap, it's used instead of $this->data in the data-property in stdWrap
 320	var $parameters = Array();			// Used by the parseFunc function and is loaded with tag-parameters when parsing tags.
 321	var $currentValKey = 'currentValue_kidjls9dksoje';
 322	var $currentRecord = '';			// This is set to the [table]:[uid] of the record delivered in the $data-array, if the cObjects CONTENT or RECORD is in operation. Note that $GLOBALS['TSFE']->currentRecord is set to an equal value but always indicating the latest record rendered.
 323	var $currentRecordTotal = 0;		// Set in cObj->RECORDS and cObj->CONTENT to the current number of records selected in a query.
 324	var $currentRecordNumber = 0;		// Incremented in cObj->RECORDS and cObj->CONTENT before each record rendering.
 325	var $parentRecordNumber = 0;		// Incremented in parent cObj->RECORDS and cObj->CONTENT before each record rendering.
 326	var $parentRecord = array();		// If the tslib_cObj was started from CONTENT, RECORD or SEARCHRESULT cObject's this array has two keys, 'data' and 'currentRecord' which indicates the record and data for the parent cObj.
 327	var $regObj;		// This may be set as a reference to the calling object of eg. cObjGetSingle. Anyway, just use it as you like. It's used in productsLib.inc for example.
 328
 329	// internal
 330	var $INT_include=0;		// Is set to 1 if the instance of this cObj is executed from a PHP_SCRIPT_INT -include script (see pagegen, bottom of document)
 331	var $checkPid_cache = Array();		// This is used by checkPid, that checks if pages are accessible. The $checkPid_cache['page_uid'] is set true or false upon this check featuring a caching function for the next request.
 332	var $checkPid_badDoktypeList = '255';
 333	var $lastTypoLinkUrl=''; 	// This will be set by typoLink() to the url of the most recent link created.
 334	var $lastTypoLinkTarget=''; 	// DO. link target.
 335	var $lastTypoLinkLD = array();
 336	var $substMarkerCache=array();	// Caching substituteMarkerArrayCached function
 337	var $recordRegister=array();	// Array that registers rendered content elements (or any table) to make sure they are not rendered recursively!
 338	var $cObjHookObjectsArr = array();		// Containig hooks for userdefined cObjects
 339	protected $stdWrapHookObjects = array();		// Containing hook objects for stdWrap
 340	protected $getImgResourceHookObjects;			// Containing hook objects for getImgResource
 341
 342	/**
 343	 * Set to true by doConvertToUserIntObject() if USER object wants to become USER_INT
 344	 */
 345	protected $doConvertToUserIntObject = false;
 346
 347	/**
 348	 * Indicates current object type. Can hold one of OBJECTTYPE_ constants or false.
 349	 * The value is set and reset inside USER() function. Any time outside of
 350	 * USER() it is false.
 351	 */
 352	protected $userObjectType = false;
 353
 354	/**
 355	 * Indicates that object type is USER.
 356	 *
 357	 * @see tslib_cObjh::$userObjectType
 358	 */
 359	const OBJECTTYPE_USER_INT = 1;
 360
 361	/**
 362	 * Indicates that object type is USER.
 363	 *
 364	 * @see tslib_cObjh::$userObjectType
 365	 */
 366	const OBJECTTYPE_USER = 2;
 367
 368	/**
 369	 * Class constructor.
 370	 * Well, it has to be called manually since it is not a real constructor function.
 371	 * So after making an instance of the class, call this function and pass to it a database record and the tablename from where the record is from. That will then become the "current" record loaded into memory and accessed by the .fields property found in eg. stdWrap.
 372	 *
 373	 * @param	array		$data	the record data that is rendered.
 374	 * @param	string		$table	the table that the data record is from.
 375	 * @return	void
 376	 */
 377	function start($data,$table='')	{
 378		global $TYPO3_CONF_VARS;
 379		$this->data = $data;
 380		$this->table = $table;
 381		$this->currentRecord = $table ? $table.':'.$this->data['uid'] : '';
 382		$this->parameters = Array();
 383		if (is_array ($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClass'])) {
 384			foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClass'] as $classArr) {
 385				$this->cObjHookObjectsArr[$classArr[0]] = t3lib_div::getUserObj($classArr[1]);
 386			}
 387		}
 388
 389		$this->stdWrapHookObjects = array();
 390		if(is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['stdWrap'])) {
 391			foreach($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['stdWrap'] as $classData) {
 392				$hookObject = t3lib_div::getUserObj($classData);
 393
 394				if(!($hookObject instanceof tslib_content_stdWrapHook)) {
 395					throw new UnexpectedValueException('$hookObject must implement interface tslib_content_stdWrapHook', 1195043965);
 396				}
 397
 398				$this->stdWrapHookObjects[] = $hookObject;
 399			}
 400		}
 401
 402		if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['postInit'])) {
 403			foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['postInit'] as $classData) {
 404				$postInitializationProcessor = t3lib_div::getUserObj($classData);
 405
 406				if(!($postInitializationProcessor instanceof tslib_content_PostInitHook)) {
 407					throw new UnexpectedValueException('$postInitializationProcessor must implement interface tslib_content_PostInitHook', 1274563549);
 408				}
 409
 410				$postInitializationProcessor->postProcessContentObjectInitialization($this);
 411			}
 412		}
 413	}
 414
 415	/**
 416	 * Gets the 'getImgResource' hook objects.
 417	 * The first call initializes the accordant objects.
 418	 *
 419	 * @return	array		The 'getImgResource' hook objects (if any)
 420	 */
 421	protected function getGetImgResourceHookObjects() {
 422		if (!isset($this->getImgResourceHookObjects)) {
 423			$this->getImgResourceHookObjects = array();
 424
 425			if(is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['getImgResource'])) {
 426				foreach($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['getImgResource'] as $classData) {
 427					$hookObject = t3lib_div::getUserObj($classData);
 428
 429					if(!($hookObject instanceof tslib_cObj_getImgResourceHook)) {
 430						throw new UnexpectedValueException('$hookObject must implement interface tslib_cObj_getImgResourceHook', 1218636383);
 431					}
 432
 433					$this->getImgResourceHookObjects[] = $hookObject;
 434				}
 435			}
 436		}
 437
 438		return $this->getImgResourceHookObjects;
 439	}
 440
 441	/**
 442	 * Sets the internal variable parentRecord with information about current record.
 443	 * If the tslib_cObj was started from CONTENT, RECORD or SEARCHRESULT cObject's this array has two keys, 'data' and 'currentRecord' which indicates the record and data for the parent cObj.
 444	 *
 445	 * @param	array		$data: The record array
 446	 * @param	string		$currentRecord: This is set to the [table]:[uid] of the record delivered in the $data-array, if the cObjects CONTENT or RECORD is in operation. Note that $GLOBALS['TSFE']->currentRecord is set to an equal value but always indicating the latest record rendered.
 447	 * @return	void
 448	 * @access private
 449	 */
 450	function setParent($data,$currentRecord)	{
 451		$this->parentRecord=array('data'=>$data, 'currentRecord'=>$currentRecord);
 452	}
 453
 454
 455
 456
 457
 458
 459
 460
 461	/***********************************************
 462	 *
 463	 * CONTENT_OBJ:
 464	 *
 465	 ***********************************************/
 466
 467	/**
 468	 * Returns the "current" value.
 469	 * The "current" value is just an internal variable that can be used by functions to pass a single value on to another function later in the TypoScript processing.
 470	 * It's like "load accumulator" in the good old C64 days... basically a "register" you can use as you like.
 471	 * The TSref will tell if functions are setting this value before calling some other object so that you know if it holds any special information.
 472	 *
 473	 * @return	mixed		The "current" value
 474	 */
 475	function getCurrentVal()	{
 476		return $this->data[$this->currentValKey];
 477	}
 478
 479	/**
 480	 * Sets the "current" value.
 481	 *
 482	 * @param	mixed		The variable that you want to set as "current"
 483	 * @return	void
 484	 * @see getCurrentVal()
 485	 */
 486	function setCurrentVal($value)	{
 487		$this->data[$this->currentValKey] = $value;
 488	}
 489
 490	/**
 491	 * Rendering of a "numerical array" of cObjects from TypoScript
 492	 * Will call ->cObjGetSingle() for each cObject found and accumulate the output.
 493	 *
 494	 * @param	array		$setup: Array with cObjects as values.
 495	 * @param	string		$addKey: A prefix for the debugging information
 496	 * @return	string		Rendered output from the cObjects in the array.
 497	 * @see cObjGetSingle()
 498	 */
 499	function cObjGet($setup,$addKey='')	{
 500		if (is_array($setup))	{
 501			$sKeyArray=t3lib_TStemplate::sortedKeyList($setup);
 502			$content ='';
 503			foreach($sKeyArray as $theKey)	{
 504				$theValue=$setup[$theKey];
 505				if (intval($theKey) && !strstr($theKey,'.'))	{
 506					$conf=$setup[$theKey.'.'];
 507					$content.=$this->cObjGetSingle($theValue,$conf,$addKey.$theKey);	// Get the contentObject
 508				}
 509			}
 510			return $content;
 511		}
 512	}
 513
 514	/**
 515	 * Renders a content object
 516	 *
 517	 * @param	string		The content object name, eg. "TEXT" or "USER" or "IMAGE"
 518	 * @param	array		The array with TypoScript properties for the content object
 519	 * @param	string		A string label used for the internal debugging tracking.
 520	 * @return	string		cObject output
 521	 * @example http://typo3.org/doc.0.html?&encryptionKey=&tx_extrepmgm_pi1[extUid]=267&tx_extrepmgm_pi1[tocEl]=153&cHash=7e74f4d331
 522	 */
 523	function cObjGetSingle($name,$conf,$TSkey='__')	{
 524		global $TYPO3_CONF_VARS;
 525
 526		$content='';
 527			// Checking that the function is not called eternally. This is done by interrupting at a depth of 100
 528		$GLOBALS['TSFE']->cObjectDepthCounter--;
 529		if ($GLOBALS['TSFE']->cObjectDepthCounter>0)	{
 530			$name = trim($name);
 531			if ($GLOBALS['TT']->LR) $GLOBALS['TT']->push($TSkey, $name);
 532
 533				// Checking if the COBJ is a reference to another object. (eg. name of 'blabla.blabla = < styles.something')
 534			if (substr($name,0,1)=='<')	{
 535				$key = trim(substr($name,1));
 536				$cF = t3lib_div::makeInstance('t3lib_TSparser');
 537					// $name and $conf is loaded with the referenced values.
 538				$old_conf=$conf;
 539				list($name, $conf) = $cF->getVal($key,$GLOBALS['TSFE']->tmpl->setup);
 540				if (is_array($old_conf) && count($old_conf))	{
 541					$conf = $this->joinTSarrays($conf,$old_conf);
 542				}
 543					// Getting the cObject
 544				$GLOBALS['TT']->incStackPointer();
 545					$content.=$this->cObjGetSingle($name,$conf,$key);
 546				$GLOBALS['TT']->decStackPointer();
 547			} else {
 548
 549				$hooked = false;
 550					// Application defined cObjects
 551				foreach ($this->cObjHookObjectsArr as $cObjName => $hookObj)	{
 552					if (($name===$cObjName) && method_exists($hookObj, 'cObjGetSingleExt')) {
 553						$content.= $hookObj->cObjGetSingleExt($name, $conf, $TSkey, $this);
 554						$hooked = true;
 555					}
 556				}
 557				if (!$hooked && isset($GLOBALS['OBTS']['tso_list'][$name]) && t3lib_extMgm::isLoaded('obts')) {
 558					$content.= obts_dtutil::renderDatatypeContent($name, $GLOBALS['OBTS']['tso_list'][$name], $conf, $this);
 559				} elseif (!$hooked) {
 560						// Traditional Content Object branching:
 561					switch($name)	{
 562						case 'COBJ_ARRAY':
 563						case 'COA':
 564							$content.=$this->COBJ_ARRAY($conf);
 565						break;
 566						case 'COA_INT':
 567							$content.=$this->COBJ_ARRAY($conf,'INT');
 568						break;
 569						case 'HTML':
 570							$content.=$this->HTML($conf);
 571						break;
 572						case 'TEXT':
 573							$content.=$this->TEXT($conf);
 574						break;
 575						case 'CLEARGIF':
 576							$content.=$this->CLEARGIF($conf);
 577						break;
 578						case 'FILE':
 579							$content.=$this->FILE($conf);
 580						break;
 581						case 'IMAGE':
 582							$content.=$this->IMAGE($conf);
 583						break;
 584						case 'IMG_RESOURCE':
 585							$content.=$this->IMG_RESOURCE($conf);
 586						break;
 587						case 'IMGTEXT':
 588							$content.=$this->IMGTEXT($conf);
 589						break;
 590						case 'CONTENT':
 591							$content.=$this->CONTENT($conf);
 592						break;
 593						case 'RECORDS':
 594							$content.=$this->RECORDS($conf);
 595						break;
 596						case 'HMENU':
 597							$content.=$this->HMENU($conf);
 598						break;
 599						case 'CTABLE':
 600							$content.=$this->CTABLE($conf);
 601						break;
 602						case 'OTABLE':
 603							$content.=$this->OTABLE($conf);
 604						break;
 605						case 'COLUMNS':
 606							$content.=$this->COLUMNS($conf);
 607						break;
 608						case 'HRULER':
 609							$content.=$this->HRULER($conf);
 610						break;
 611						case 'CASE':
 612							$content.=$this->CASEFUNC($conf);
 613						break;
 614						case 'LOAD_REGISTER':
 615						case 'RESTORE_REGISTER':
 616							$this->LOAD_REGISTER($conf,$name);
 617						break;
 618						case 'FORM':
 619							$content.=$this->FORM($conf);
 620						break;
 621						case 'SEARCHRESULT':
 622							$content.=$this->SEARCHRESULT($conf);
 623						break;
 624						case 'PHP_SCRIPT':
 625							$content.=$this->PHP_SCRIPT($conf);
 626						break;
 627						case 'PHP_SCRIPT_EXT':
 628							$content.=$this->PHP_SCRIPT($conf,'EXT');
 629						break;
 630						case 'PHP_SCRIPT_INT':
 631							$content.=$this->PHP_SCRIPT($conf,'INT');
 632						break;
 633						case 'USER':
 634							$content.=$this->USER($conf);
 635						break;
 636						case 'USER_INT':
 637							$content.=$this->USER($conf,'INT');
 638						break;
 639						case 'TEMPLATE':
 640							$content.=$this->TEMPLATE($conf);
 641						break;
 642						case 'EDITPANEL':
 643							if ($GLOBALS['TSFE']->beUserLogin)	{$content.=$this->editPanel($content, $conf);}
 644						break;
 645						case 'MULTIMEDIA':
 646							$content.=$this->MULTIMEDIA($conf);
 647						break;
 648						case 'MEDIA':
 649							$content.=$this->MEDIA($conf);
 650						break;
 651						case 'SWFOBJECT':
 652							$content.=$this->SWFOBJECT($conf);
 653						break;
 654						case 'QTOBJECT':
 655							$content.=$this->QTOBJECT($conf);
 656						break;
 657						default:
 658								// call hook functions for extra processing
 659							if($name && is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClassDefault']))    {
 660								foreach($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClassDefault'] as $classData)    {
 661									$hookObject = t3lib_div::getUserObj($classData);
 662
 663									if(!($hookObject instanceof tslib_content_cObjGetSingleHook)) {
 664										throw new UnexpectedValueException('$hookObject must implement interface tslib_content_cObjGetSingleHook', 1195043731);
 665									}
 666									/* @var $hookObject tslib_content_cObjGetSingleHook */
 667									$content .= $hookObject->getSingleContentObject($name, (array) $conf, $TSkey, $this);
 668								}
 669							}
 670						break;
 671					}
 672				}
 673			}
 674			if ($GLOBALS['TT']->LR) $GLOBALS['TT']->pull($content);
 675		}
 676			// Increasing on exit...
 677		$GLOBALS['TSFE']->cObjectDepthCounter++;
 678		return $content;
 679	}
 680
 681
 682
 683
 684
 685
 686
 687	/********************************************
 688	 *
 689	 * Functions rendering content objects (cObjects)
 690	 *
 691	 ********************************************/
 692
 693	/**
 694	 * Rendering the cObject, HTML
 695	 *
 696	 * @param	array		Array of TypoScript properties
 697	 * @return	string		Output
 698	 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=349&cHash=d3fd0c70b4
 699	 */
 700	function HTML($conf)	{
 701		return $this->stdWrap($conf['value'],$conf['value.']);
 702	}
 703
 704	/**
 705	 * Rendering the cObject, TEXT
 706	 *
 707	 * @param	array		Array of TypoScript properties
 708	 * @return	string		Output
 709	 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=350&cHash=b49de28f83
 710	 */
 711	function TEXT($conf)	{
 712		return $this->stdWrap($conf['value'],$conf);
 713	}
 714
 715	/**
 716	 * Rendering the cObject, CLEARGIF
 717	 *
 718	 * @param	array		Array of TypoScript properties
 719	 * @return	string		Output
 720	 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=355&cHash=70c0f19915
 721	 */
 722	function CLEARGIF($conf)	{
 723		$w = $this->stdWrap($conf['width'],$conf['width.']);
 724		$h = $this->stdWrap($conf['height'],$conf['height.']);
 725		$w = $w ? $w : 1;
 726		$h = $h ? $h : 1;
 727		$wrap = $conf['wrap'] ? $conf['wrap'] : '|<br />';
 728		$theValue = $this->wrap('<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$w.'" height="'.$h.'"'.$this->getBorderAttr(' border="0"').' alt="" title="" />', $wrap);
 729
 730		return $this->stdWrap($theValue,$conf['stdWrap.']);
 731	}
 732
 733	/**
 734	 * Rendering the cObject, COBJ_ARRAY / COA and COBJ_ARRAY_INT
 735	 *
 736	 * @param	array		Array of TypoScript properties
 737	 * @param	string		If "INT" then the cObject is a "COBJ_ARRAY_INT" (non-cached), otherwise just "COBJ_ARRAY" (cached)
 738	 * @return	string		Output
 739	 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=351&cHash=a09db0329c
 740	 */
 741	function COBJ_ARRAY($conf,$ext='')	{
 742
 743		if (is_array($conf)) {
 744			$content = '';
 745			switch($ext) {
 746				case 'INT':
 747					$substKey = $ext . '_SCRIPT.' . $GLOBALS['TSFE']->uniqueHash();
 748					$content .= '<!--'.$substKey.'-->';
 749					$GLOBALS['TSFE']->config[$ext . 'incScript'][$substKey] = array (
 750						'file' => $conf['includeLibs'],
 751						'conf' => $conf,
 752						'cObj' => serialize($this),
 753						'type' => 'COA'
 754					);
 755				break;
 756				default:
 757					if ($this->checkIf($conf['if.'])) {
 758						$this->includeLibs($conf);
 759						$content = $this->cObjGet($conf);
 760						if ($conf['wrap']) {
 761							$content = $this->wrap($content, $conf['wrap']);
 762						}
 763						if ($conf['stdWrap.']) {
 764							$content = $this->stdWrap($content, $conf['stdWrap.']);
 765						}
 766					}
 767				break;
 768			}
 769			return $content;
 770		} else {
 771			$GLOBALS['TT']->setTSlogMessage('No elements in this content object array (COBJ_ARRAY, COA, COA_INT).', 2);
 772		}
 773	}
 774
 775	/**
 776	 * Rendering the cObject, USER and USER_INT
 777	 *
 778	 * @param	array		Array of TypoScript properties
 779	 * @param	string		If "INT" then the cObject is a "USER_INT" (non-cached), otherwise just "USER" (cached)
 780	 * @return	string		Output
 781	 * @link	http://typo3.org/documentation/document-library/references/doc_core_tsref/4.1.0/view/8/22/
 782	 */
 783	function USER($conf, $ext = '') {
 784		$content = '';
 785		switch ($ext) {
 786			case 'INT':
 787				$this->userObjectType = self::OBJECTTYPE_USER_INT;
 788				$substKey = $ext . '_SCRIPT.' . $GLOBALS['TSFE']->uniqueHash();
 789				$content.='<!--' . $substKey . '-->';
 790				$GLOBALS['TSFE']->config[$ext . 'incScript'][$substKey] = array(
 791					'file' => $conf['includeLibs'],
 792					'conf' => $conf,
 793					'cObj' => serialize($this),
 794					'type' => 'FUNC'
 795				);
 796				break;
 797			default:
 798				if ($this->userObjectType === false) {
 799					// Come here only if we are not called from $TSFE->INTincScript_process()!
 800					$this->userObjectType = self::OBJECTTYPE_USER;
 801				}
 802				$this->includeLibs($conf);
 803				$tempContent = $this->callUserFunction($conf['userFunc'], $conf, '');
 804				if ($this->doConvertToUserIntObject) {
 805					$this->doConvertToUserIntObject = false;
 806					$content = $this->USER($conf, 'INT');
 807				} else {
 808					$content .= $tempContent;
 809				}
 810				break;
 811		}
 812		$this->userObjectType = false;
 813		return $content;
 814	}
 815
 816	/**
 817	 * Retrieves a type of object called as USER or USER_INT. Object can detect their
 818	 * type by using this call. It returns OBJECTTYPE_USER_INT or OBJECTTYPE_USER depending on the
 819	 * current object execution. In all other cases it will return false to indicate
 820	 * a call out of context.
 821	 *
 822	 * @return	mixed	One of OBJECTTYPE_ class constants or false
 823	 */
 824	public function getUserObjectType() {
 825		return $this->userObjectType;
 826	}
 827
 828	/**
 829	 * Requests the current USER object to be converted to USER_INT.
 830	 *
 831	 * @return	void
 832	 */
 833	public function convertToUserIntObject() {
 834		if ($this->userObjectType !== self::OBJECTTYPE_USER) {
 835			$GLOBALS['TT']->setTSlogMessage('tslib_cObj::convertToUserIntObject() ' .
 836				'is called in the wrong context or for the wrong object type', 2);
 837		}
 838		else {
 839			$this->doConvertToUserIntObject = true;
 840		}
 841	}
 842
 843	/**
 844	 * Rendering the cObject, FILE
 845	 *
 846	 * @param	array		Array of TypoScript properties
 847	 * @return	string		Output
 848	 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=352&cHash=379c60f8bc
 849	 */
 850	function FILE($conf)	{
 851		$theValue = $this->fileResource($this->stdWrap($conf['file'],$conf['file.']), trim($this->getAltParam($conf, false)));
 852		if ($conf['linkWrap'])	{
 853			$theValue = $this->linkWrap($theValue,$conf['linkWrap']);
 854		}
 855		return $this->wrap($theValue,$conf['wrap']);
 856	}
 857
 858	/**
 859	 * Rendering the cObject, IMAGE
 860	 *
 861	 * @param	array		Array of TypoScript properties
 862	 * @return	string		Output
 863	 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=353&cHash=440681ea56
 864	 * @see cImage()
 865	 */
 866	function IMAGE($conf)	{
 867		$content='';
 868		if ($this->checkIf($conf['if.']))	{
 869			$theValue = $this->cImage($conf['file'],$conf);
 870			if ($conf['stdWrap.'])	{
 871				$theValue = $this->stdWrap($theValue,$conf['stdWrap.']);
 872			}
 873			return $theValue;
 874		}
 875	}
 876
 877	/**
 878	 * Rendering the cObject, IMG_RESOURCE
 879	 *
 880	 * @param	array		Array of TypoScript properties
 881	 * @return	string		Output
 882	 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=354&cHash=46f9299706
 883	 * @see getImgResource()
 884	 */
 885	function IMG_RESOURCE($conf)	{
 886		$GLOBALS['TSFE']->lastImgResourceInfo = $this->getImgResource($conf['file'],$conf['file.']);
 887		return $this->stdWrap($GLOBALS['TSFE']->lastImgResourceInfo[3],$conf['stdWrap.']);
 888	}
 889
 890	/**
 891	 * Rendering the cObject, IMGTEXT
 892	 *
 893	 * @param	array		Array of TypoScript properties
 894	 * @return	string		Output
 895	 * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=363&cHash=cf2969bce1
 896	 */
 897	function IMGTEXT($conf) {
 898		$content='';
 899		if (is_array($conf['text.']))	{
 900			$content.= $this->stdWrap($this->cObjGet($conf['text.'],'text.'),$conf['text.']);	// this gets the surrounding content
 901		}
 902		$imgList=trim($this->stdWrap($conf['imgList'],$conf['imgList.']));	// gets images
 903		if ($imgList)	{
 904			$imgs = t3lib_div::trimExplode(',',$imgList);
 905			$imgStart = intval($this->stdWrap($conf['imgStart'],$conf['imgStart.']));
 906
 907			$imgCount= count($imgs)-$imgStart;
 908
 909			$imgMax = intval($this->stdWrap($conf['imgMax'],$conf['imgMax.']));
 910			if ($imgMax)	{
 911				$imgCount = t3lib_div::intInRange($imgCount,0,$imgMax);	// reduces the number of images.
 912			}
 913
 914			$imgPath = $this->stdWrap($conf['imgPath'],$conf['imgPath.']);
 915
 916				// initialisation
 917			$caption='';
 918			$captionArray = array();
 919			if (!$conf['captionSplit'] && !$conf['imageTextSplit'] && is_array($conf['caption.']))	{
 920				$caption = $this->stdWrap($this->cObjGet($conf['caption.'], 'caption.'),$conf['caption.']);	// global caption, no splitting
 921			}
 922			if ($conf['captionSplit'] && $conf['captionSplit.']['cObject'])	{
 923				$legacyCaptionSplit = 1;
 924				$capSplit = $this->stdWrap($conf['captionSplit.']['token'], $conf['captionSplit.']['token.']);
 925				if (!$capSplit) {$capSplit=LF;}
 926				$captionArray = explode($capSplit, $this->cObjGetSingle($conf['captionSplit.']['cObject'], $conf['captionSplit.']['cObject.'], 'captionSplit.cObject'));
 927				foreach ($captionArray as $ca_key => $ca_val) {
 928					$captionArray[$ca_key] = $this->stdWrap(trim($captionArray[$ca_key]), $conf['captionSplit.']['stdWrap.']);
 929				}
 930			}
 931
 932			$tablecode='';
 933			$position=$this->stdWrap($conf['textPos'],$conf['textPos.']);
 934
 935			$tmppos = $position&7;
 936			$contentPosition = $position&24;
 937			$align = $this->align[$tmppos];
 938			$cap = ($caption)?1:0;
 939			$txtMarg = intval($this->stdWrap($conf['textMargin'],$conf['textMargin.']));
 940			if (!$conf['textMargin_outOfText'] && $contentPosition<16)	{
 941				$txtMarg=0;
 942			}
 943
 944			$cols = intval($this->stdWrap($conf['cols'],$conf['cols.']));
 945			$rows = intval($this->stdWrap($conf['rows'],$conf['rows.']));
 946			$colspacing = intval($this->stdWrap($conf['colSpace'],$conf['colSpace.']));
 947			$rowspacing = intval($this->stdWrap($conf['rowSpace'],$conf['rowSpace.']));
 948
 949			$border = intval($this->stdWrap($conf['border'],$conf['border.'])) ? 1:0;
 950			$borderColor = $this->stdWrap($conf['borderCol'],$conf['borderCol.']);
 951			$borderThickness = intval($this->stdWrap($conf['borderThick'],$conf['borderThick.']));
 952
 953			$borderColor=$borderColor?$borderColor:'black';
 954			$borderThickness=$borderThickness?$borderThickness:1;
 955
 956			$caption_align = $this->stdWrap($conf['captionAlign'],$conf['captionAlign.']);
 957			if (!$caption_align) {
 958				$caption_align = $align;
 959			}
 960				// generate cols
 961			$colCount = ($cols > 1) ? $cols : 1;
 962			if ($colCount > $imgCount)	{$colCount = $imgCount;}
 963			$rowCount = ($colCount > 1) ? ceil($imgCount / $colCount) : $imgCount;
 964				// generate rows
 965			if ($rows>1)  {
 966				$rowCount = $rows;
 967				if ($rowCount > $imgCount)	{$rowCount = $imgCount;}
 968				$colCount = ($rowCount>1) ? ceil($imgCount / $rowCount) : $imgCount;
 969			}
 970
 971				// max Width
 972			$colRelations = trim($this->stdWrap($conf['colRelations'],$conf['colRelations.']));
 973			$maxW = intval($this->stdWrap($conf['maxW'],$conf['maxW.']));
 974
 975			$maxWInText = intval($this->stdWrap($conf['maxWInText'],$conf['maxWInText.']));
 976			if (!$maxWInText)	{	// If maxWInText is not set, it's calculated to the 50 % of the max...
 977				$maxWInText = round($maxW/2);
 978			}
 979
 980			if ($maxWInText && $contentPosition>=16)	{	// inText
 981				$maxW = $maxWInText;
 982			}
 983
 984			if ($maxW && $colCount > 0) {	// If there is a max width and if colCount is greater than  column
 985/*				debug($border*$borderThickness*2);
 986				debug($maxW);
 987				debug($colspacing);
 988				debug(($maxW-$colspacing*($colCount-1)-$colCount*$border*$borderThickness*2));
 989				*/
 990				$maxW = ceil(($maxW-$colspacing*($colCount-1)-$colCount*$border*$borderThickness*2)/$colCount);
 991			}
 992				// create the relation between rows
 993			$colMaxW = Array();
 994			if ($colRelations)	{
 995				$rel_parts = explode(':',$colRelations);
 996				$rel_total = 0;
 997				for ($a=0;$a<$colCount;$a++)	{
 998					$rel_parts[$a] = intval($rel_parts[$a]);
 999					$rel_total+= $rel_parts[$a];
1000				}
1001				if ($rel_total)	{
1002					for ($a=0;$a<$colCount;$a++)	{
1003						$colMaxW[$a] = round(($maxW*$colCount)/$rel_total*$rel_parts[$a]);
1004					}
1005					if (min($colMaxW)<=0 || max($rel_parts)/min($rel_parts)>10)	{		// The difference in size between the largest and smalles must be within a factor of ten.
1006						$colMaxW = Array();
1007					}
1008				}
1009			}
1010			$image_compression = intval($this->stdWrap($conf['image_compression'],$conf['image_compression.']));
1011			$image_effects = intval($this->stdWrap($conf['image_effects'],$conf['image_effects.']));
1012			$image_frames = intval($this->stdWrap($conf['image_frames.']['key'],$conf['image_frames.']['key.']));
1013
1014				// fetches pictures
1015			$splitArr=array();
1016			$splitArr['imgObjNum']=$conf['imgObjNum'];
1017			$splitArr = $GLOBALS['TSFE']->tmpl->splitConfArray($splitArr,$imgCount);
1018
1019				// EqualHeight
1020			$equalHeight = intval($this->stdWrap($conf['equalH'],$conf['equalH.']));
1021			if ($equalHeight)	{	// Initiate gifbuilder object in order to get dimensions AND calculate the imageWidth's
1022				$gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
1023				$gifCreator->init();
1024				$relations = Array();
1025				$relations_cols = Array();
1026				$totalMaxW = $maxW*$colCount;
1027				for($a=0;$a<$imgCount;$a++)	{
1028					$imgKey = $a+$imgStart;
1029					$imgInfo = $gifCreator->getImageDimensions($imgPath.$imgs[$imgKey]);
1030					$relations[$a] = $imgInfo[1] / $equalHeight;	// relationship between the original height and the wished height
1031					if ($relations[$a])	{	// if relations is zero, then the addition of this value is omitted as the image is not expected to display because of some error.
1032						$relations_cols[floor($a/$colCount)] += $imgInfo[0]/$relations[$a];	// counts the total width of the row with the new height taken into consideration.
1033					}
1034				}
1035			}
1036
1037			$imageRowsFinalWidths = Array();	// contains the width of every image row
1038			$imageRowsMaxHeights = Array();
1039			$imgsTag=array();
1040			$origImages=array();
1041			for($a=0;$a<$imgCount;$a++)	{
1042				$GLOBALS['TSFE']->register['IMAGE_NUM'] = $a;
1043				$GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = $a;
1044
1045				$imgKey = $a+$imgStart;
1046				$totalImagePath = $imgPath.$imgs[$imgKey];
1047				$this->data[$this->currentValKey] = $totalImagePath;
1048				$imgObjNum = intval($splitArr[$a]['imgObjNum']);
1049				$imgConf = $conf[$imgObjNum.'.'];
1050
1051				if ($equalHeight)	{
1052					$scale = 1;
1053					if ($totalMaxW)	{
1054						$rowTotalMaxW = $relations_cols[floor($a/$colCount)];
1055						if ($rowTotalMaxW > $totalMaxW)	{
1056							$scale = $rowTotalMaxW / $totalMaxW;
1057						}
1058					}
1059						// transfer info to the imageObject. Please note, that
1060					$imgConf['file.']['height'] = round($equalHeight/$scale);
1061
1062					unset($imgConf['file.']['width']);
1063					unset($imgConf['file.']['maxW']);
1064					unset($imgConf['file.']['maxH']);
1065					unset($imgConf['file.']['minW']);
1066					unset($imgConf['file.']['minH']);
1067					unset($imgConf['file.']['width.']);
1068					unset($imgConf['file.']['maxW.']);
1069					unset($imgConf['file.']['maxH.']);
1070					unset($imgConf['file.']['minW.']);
1071					unset($imgConf['file.']['minH.']);
1072					$maxW = 0;	// setting this to zero, so that it doesn't disturb
1073				}
1074
1075				if ($maxW) {
1076					if (count($colMaxW))	{
1077						$imgConf['file.']['maxW'] = $colMaxW[($a%$colCount)];
1078					} else {
1079						$imgConf['file.']['maxW'] = $maxW;
1080					}
1081				}
1082
1083					// Image Object supplied:
1084				if (is_array($imgConf)) {
1085					if ($this->image_effects[$image_effects])	{
1086						$imgConf['file.']['params'].= ' '.$this->image_effects[$image_effects];
1087					}
1088					if ($image_frames)	{
1089						if (is_array($conf['image_frames.'][$image_frames.'.']))	{
1090							$imgConf['file.']['m.'] = $conf['image_frames.'][$image_frames.'.'];
1091						}
1092					}
1093					if ($image_compression && $imgConf['file']!='GIFBUILDER')	{
1094						if ($image_compression==1)	{
1095							$tempImport = $imgConf['file.']['import'];
1096							$tempImport_dot = $imgConf['file.']['import.'];
1097							unset($imgConf['file.']);
1098							$imgConf['file.']['import'] = $tempImport;
1099							$imgConf['file.']['import.'] = $tempImport_dot;
1100						} elseif (isset($this->image_compression[$image_compression])) {
1101							$imgConf['file.']['params'].= ' '.$this->image_compression[$image_compression]['params'];
1102							$imgConf['file.']['ext'] = $this->image_compression[$image_compression]['ext'];
1103							unset($imgConf['file.']['ext.']);
1104						}
1105					}
1106
1107						// "alt", "title" and "longdesc" attributes:
1108					if (!strlen($imgConf['altText']) && !is_array($imgConf['altText.'])) {
1109						$imgConf['altText'] = $conf['altText'];
1110						$imgConf['altText.'] = $conf['altText.'];
1111					}
1112					if (!strlen($imgConf['titleText']) && !is_array($imgConf['titleText.'])) {
1113						$imgConf['titleText'] = $conf['titleText'];
1114						$imgConf['titleText.'] = $conf['titleText.'];
1115					}
1116					if (!strlen($imgConf['longdescURL']) && !is_array($imgConf['longdescURL.'])) {
1117						$imgConf['longdescURL'] = $conf['longdescURL'];
1118						$imgConf['longdescURL.'] = $conf['longdescURL.'];
1119					}
1120				} else {
1121					$imgConf = array(
1122						'altText' => $conf['altText'],
1123						'titleText' => $conf['titleText'],
1124						'longdescURL' => $conf['longdescURL'],
1125						'file' => $totalImagePath
1126					);
1127				}
1128
1129				$imgsTag[$imgKey] = $this->IMAGE($imgConf);
1130
1131					// Store the original filepath
1132				$origImages[$imgKey]=$GLOBALS['TSFE']->lastImageInfo;
1133
1134				$imageRowsFinalWidths[floor($a/$colCount)] += $GLOBALS['TSFE']->lastImageInfo[0];
1135				if ($GLOBALS['TSFE']->lastImageInfo[1]>$imageRowsMaxHeights[floor($a/$colCount)])	{
1136					$imageRowsMaxHeights[floor($a/$colCount)] = $GLOBALS['TSFE']->lastImageInfo[1];
1137				}
1138			}
1139				// calculating the tableWidth:
1140				// TableWidth problems: It creates problems if the pictures are NOT as wide as the tableWidth.
1141			$tableWidth = max($imageRowsFinalWidths)+ $colspacing*($colCount-1) + $colCount*$border*$borderThickness*2;
1142
1143				// make table for pictures
1144			$index=$imgStart;
1145
1146			$noRows = $this->stdWrap($conf['noRows'],$conf['noRows.']);
1147			$noCols = $this->stdWrap($conf['noCols'],$conf['noCols.']);
1148			if ($noRows) {$noCols=0;}	// noRows overrides noCols. They cannot exist at the same time.
1149			if ($equalHeight) {
1150				$noCols=1;
1151				$noRows=0;
1152			}
1153
1154			$rowCount_temp=1;
1155			$colCount_temp=$colCount;
1156			if ($noRows)	{
1157				$rowCount_temp = $rowCount;
1158				$rowCount=1;
1159			}
1160			if ($noCols)	{
1161				$colCount=1;
1162			}
1163				// col- and rowspans calculated
1164			$colspan = (($colspacing) ? $colCount*2-1 : $colCount);
1165			$rowspan = (($rowspacing) ? $rowCount*2-1 : $rowCount) + $cap;
1166
1167
1168				// Edit icons:
1169			$editIconsHTML = $conf['editIcons']&&$GLOBALS['TSFE']->beUserLogin ? $this->editIcons('',$conf['editIcons'],$conf['editIcons.']) : '';
1170
1171				// strech out table:
1172			$tablecode='';
1173			$flag=0;
1174			if ($conf['noStretchAndMarginCells']!=1)	{
1175				$tablecode.='<tr>';
1176				if ($txtMarg && $align=='right')	{	// If right aligned, the textborder is added on the right side
1177					$tablecode.='<td rowspan="'.($rowspan+1).'" valign="top"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$txtMarg.'" height="1" alt="" title="" />'.($editIconsHTML?'<br />'.$editIconsHTML:'').'</td>';
1178					$editIconsHTML='';
1179					$flag=1;
1180				}
1181				$tablecode.='<td colspan="'.$colspan.'"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$tableWidth.'" height="1" alt="" /></td>';
1182				if ($txtMarg && $align=='left')	{	// If left aligned, the textborder is added on the left side
1183					$tablecode.='<td rowspan="'.($rowspan+1).'" valign="top"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$txtMarg.'" height="1" alt="" title="" />'.($editIconsHTML?'<br />'.$editIconsHTML:'').'</td>';
1184					$editIconsHTML='';
1185					$flag=1;
1186				}
1187				if ($flag) $tableWidth+=$txtMarg+1;
1188	//			$tableWidth=0;
1189				$tablecode.='</tr>';
1190			}
1191
1192				// draw table
1193			for ($c=0;$c<$rowCount;$c++) {	// Looping through rows. If 'noRows' is set, this is '1 time', but $rowCount_temp will hold the actual number of rows!
1194				if ($c && $rowspacing)	{		// If this is NOT the first time in the loop AND if space is required, a row-spacer is added. In case of "noRows" rowspacing is done further down.
1195					$tablecode.='<tr><td colspan="'.$colspan.'"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$rowspacing.'"'.$this->getBorderAttr(' border="0"').' alt="" title="" /></td></tr>';
1196				}
1197				$tablecode.='<tr>';	// starting row
1198				for ($b=0; $b<$colCount_temp; $b++)	{	// Looping through the columns
1199					if ($b && $colspacing)	{		// If this is NOT the first iteration AND if column space is required. In case of "noCols", the space is done without a separate cell.
1200						if (!$noCols)	{
1201							$tablecode.='<td><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$colspacing.'" height="1"'.$this->getBorderAttr(' border="0"').' alt="" title="" /></td>';
1202						} else {
1203							$colSpacer='<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.($border?$colspacing-6:$colspacing).'" height="'.($imageRowsMaxHeights[$c]+($border?$borderThickness*2:0)).'"'.$this->getBorderAttr(' border="0"').' align="'.($border?'left':'top').'" alt="" title="" />';
1204							$colSpacer='<td valign="top">'.$colSpacer.'</td>';	// added 160301, needed for the new "noCols"-table...
1205							$tablecode.=$colSpacer;
1206						}
1207					}
1208					if (!$noCols || ($noCols && !$b))	{
1209						$tablecode.='<td valign="top">';	// starting the cell. If "noCols" this cell will hold all images in the row, otherwise only a single image.
1210						if ($noCols)	{$tablecode.='<table width="'.$imageRowsFinalWidths[$c].'" border="0" cellpadding="0" cellspacing="0"><tr>';}		// In case of "noCols" we must set the table-tag that surrounds the images in the row.
1211					}
1212					for ($a=0;$a<$rowCount_temp;$a++)	{	// Looping through the rows IF "noRows" is set. "noRows"  means that the rows of images is not rendered by physical table rows but images are all in one column and spaced apart with clear-gifs. This loop is only one time if "noRows" is not set.
1213						$GLOBALS['TSFE']->register['IMAGE_NUM'] = $imgIndex;	// register previous imgIndex
1214						$imgIndex = $index+$a*$colCount_temp;
1215						$GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = $imgIndex;
1216						if ($imgsTag[$imgIndex])	{
1217							if ($rowspacing && $noRows && $a) {		// Puts distance between the images IF "noRows" is set and this is the first iteration of the loop
1218								$tablecode.= '<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$rowspacing.'" alt="" title="" /><br />';
1219							}
1220							if ($legacyCaptionSplit)	{
1221								$thisCaption = $captionArray[$imgIndex];
1222							} else if ($conf['captionSplit'] || $conf['imageTextSplit'])	{
1223								$thisCaption = $this->stdWrap($this->cObjGet($conf['caption.'], 'caption.'), $conf['caption.']);
1224							}
1225							$imageHTML = $imgsTag[$imgIndex].'<br />';
1226							$Talign = (!trim($thisCaption) && !$noRows) ? ' align="left"' : '';  // this is necessary if the tablerows are supposed to space properly together! "noRows" is excluded because else the images "layer" together.
1227							if ($border)	{$imageHTML='<table border="0" cell…

Large files files are truncated, but you can click here to view the full file