PageRenderTime 77ms CodeModel.GetById 26ms RepoModel.GetById 1ms app.codeStats 1ms

/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
Possible License(s): BSD-3-Clause, GPL-2.0, Unlicense, LGPL-2.1, Apache-2.0

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. // Object TypoScript library included:
  217. if(t3lib_extMgm::isLoaded('obts')) {
  218. require_once(t3lib_extMgm::extPath('obts').'_tsobject/_tso.php');
  219. }
  220. /**
  221. * This class contains all main TypoScript features.
  222. * This includes the rendering of TypoScript content objects (cObjects).
  223. * Is the backbone of TypoScript Template rendering.
  224. *
  225. * There are lots of functions you can use from your include-scripts.
  226. * The class "tslib_cObj" is normally instantiated and referred to as "cObj".
  227. * 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.
  228. *
  229. * @author Kasper Skaarhoj <kasperYYYY@typo3.com>
  230. * @package TYPO3
  231. * @subpackage tslib
  232. * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&cHash=4ad9d7acb4
  233. */
  234. class tslib_cObj {
  235. var $align = Array ('center', 'right', 'left');
  236. /**
  237. * Holds ImageMagick parameters and extensions used for compression
  238. *
  239. * @see IMGTEXT()
  240. *
  241. * 0= Default
  242. * 1= Dont change! (removes all parameters for the image_object!!)
  243. * 1x = GIFs
  244. * 2x = JPGs
  245. */
  246. var $image_compression = Array(
  247. 10 => Array('params'=>'', 'ext'=>'gif'),
  248. 11 => Array('params'=>'-colors 128', 'ext'=>'gif'),
  249. 12 => Array('params'=>'-colors 64', 'ext'=>'gif'),
  250. 13 => Array('params'=>'-colors 32', 'ext'=>'gif'),
  251. 14 => Array('params'=>'-colors 16', 'ext'=>'gif'),
  252. 15 => Array('params'=>'-colors 8', 'ext'=>'gif'),
  253. 30 => Array('params'=>'-colors 256', 'ext'=>'png'),
  254. 31 => Array('params'=>'-colors 128', 'ext'=>'png'),
  255. 32 => Array('params'=>'-colors 64', 'ext'=>'png'),
  256. 33 => Array('params'=>'-colors 32', 'ext'=>'png'),
  257. 34 => Array('params'=>'-colors 16', 'ext'=>'png'),
  258. 35 => Array('params'=>'-colors 8', 'ext'=>'png'),
  259. 39 => Array('params'=>'', 'ext'=>'png'),
  260. 20 => Array('params'=>'-quality 100', 'ext'=>'jpg'),
  261. 21 => Array('params'=>'-quality 90', 'ext'=>'jpg'),
  262. 22 => Array('params'=>'-quality 80', 'ext'=>'jpg'),
  263. 23 => Array('params'=>'-quality 70', 'ext'=>'jpg'),
  264. 24 => Array('params'=>'-quality 60', 'ext'=>'jpg'),
  265. 25 => Array('params'=>'-quality 50', 'ext'=>'jpg'),
  266. 26 => Array('params'=>'-quality 40', 'ext'=>'jpg'),
  267. 27 => Array('params'=>'-quality 30', 'ext'=>'jpg'),
  268. 28 => Array('params'=>'-quality 20', 'ext'=>'jpg')
  269. );
  270. /**
  271. * ImageMagick parameters for image effects
  272. *
  273. * @see IMGTEXT()
  274. */
  275. var $image_effects = Array(
  276. 1 => '-rotate 90',
  277. 2 => '-rotate 270',
  278. 3 => '-rotate 180',
  279. 10 => '-colorspace GRAY',
  280. 11 => '-sharpen 70',
  281. 20 => '-normalize',
  282. 23 => '-contrast',
  283. 25 => '-gamma 1.3',
  284. 26 => '-gamma 0.8'
  285. );
  286. /**
  287. * Loaded with the current data-record.
  288. *
  289. * If the instance of this class is used to render records from the database those records are found in this array.
  290. * The function stdWrap has TypoScript properties that fetch field-data from this array.
  291. * @see init()
  292. */
  293. var $data = Array();
  294. protected $table = '';
  295. var $oldData = Array(); // Used for backup...
  296. var $alternativeData =''; // If this is set with an array before stdWrap, it's used instead of $this->data in the data-property in stdWrap
  297. var $parameters = Array(); // Used by the parseFunc function and is loaded with tag-parameters when parsing tags.
  298. var $currentValKey = 'currentValue_kidjls9dksoje';
  299. 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.
  300. var $currentRecordTotal = 0; // Set in cObj->RECORDS and cObj->CONTENT to the current number of records selected in a query.
  301. var $currentRecordNumber = 0; // Incremented in cObj->RECORDS and cObj->CONTENT before each record rendering.
  302. var $parentRecordNumber = 0; // Incremented in parent cObj->RECORDS and cObj->CONTENT before each record rendering.
  303. 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.
  304. 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.
  305. // internal
  306. 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)
  307. 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.
  308. var $checkPid_badDoktypeList = '255';
  309. var $lastTypoLinkUrl=''; // This will be set by typoLink() to the url of the most recent link created.
  310. var $lastTypoLinkTarget=''; // DO. link target.
  311. var $lastTypoLinkLD = array();
  312. var $substMarkerCache=array(); // Caching substituteMarkerArrayCached function
  313. var $recordRegister=array(); // Array that registers rendered content elements (or any table) to make sure they are not rendered recursively!
  314. var $cObjHookObjectsArr = array(); // Containig hooks for userdefined cObjects
  315. protected $stdWrapHookObjects = array(); // Containing hook objects for stdWrap
  316. protected $getImgResourceHookObjects; // Containing hook objects for getImgResource
  317. /**
  318. * Set to true by doConvertToUserIntObject() if USER object wants to become USER_INT
  319. */
  320. protected $doConvertToUserIntObject = false;
  321. /**
  322. * Indicates current object type. Can hold one of OBJECTTYPE_ constants or false.
  323. * The value is set and reset inside USER() function. Any time outside of
  324. * USER() it is false.
  325. */
  326. protected $userObjectType = false;
  327. /**
  328. * Indicates that object type is USER.
  329. *
  330. * @see tslib_cObjh::$userObjectType
  331. */
  332. const OBJECTTYPE_USER_INT = 1;
  333. /**
  334. * Indicates that object type is USER.
  335. *
  336. * @see tslib_cObjh::$userObjectType
  337. */
  338. const OBJECTTYPE_USER = 2;
  339. /**
  340. * Class constructor.
  341. * Well, it has to be called manually since it is not a real constructor function.
  342. * 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.
  343. *
  344. * @param array $data the record data that is rendered.
  345. * @param string $table the table that the data record is from.
  346. * @return void
  347. */
  348. function start($data,$table='') {
  349. global $TYPO3_CONF_VARS;
  350. $this->data = $data;
  351. $this->table = $table;
  352. $this->currentRecord = $table ? $table.':'.$this->data['uid'] : '';
  353. $this->parameters = Array();
  354. if (is_array ($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClass'])) {
  355. foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClass'] as $classArr) {
  356. $this->cObjHookObjectsArr[$classArr[0]] = t3lib_div::getUserObj($classArr[1]);
  357. }
  358. }
  359. $this->stdWrapHookObjects = array();
  360. if(is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['stdWrap'])) {
  361. foreach($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['stdWrap'] as $classData) {
  362. $hookObject = t3lib_div::getUserObj($classData);
  363. if(!($hookObject instanceof tslib_content_stdWrapHook)) {
  364. throw new UnexpectedValueException('$hookObject must implement interface tslib_content_stdWrapHook', 1195043965);
  365. }
  366. $this->stdWrapHookObjects[] = $hookObject;
  367. }
  368. }
  369. if (is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['postInit'])) {
  370. foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['postInit'] as $classData) {
  371. $postInitializationProcessor = t3lib_div::getUserObj($classData);
  372. if(!($postInitializationProcessor instanceof tslib_content_PostInitHook)) {
  373. throw new UnexpectedValueException('$postInitializationProcessor must implement interface tslib_content_PostInitHook', 1274563549);
  374. }
  375. $postInitializationProcessor->postProcessContentObjectInitialization($this);
  376. }
  377. }
  378. }
  379. /**
  380. * Gets the 'getImgResource' hook objects.
  381. * The first call initializes the accordant objects.
  382. *
  383. * @return array The 'getImgResource' hook objects (if any)
  384. */
  385. protected function getGetImgResourceHookObjects() {
  386. if (!isset($this->getImgResourceHookObjects)) {
  387. $this->getImgResourceHookObjects = array();
  388. if(is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['getImgResource'])) {
  389. foreach($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_content.php']['getImgResource'] as $classData) {
  390. $hookObject = t3lib_div::getUserObj($classData);
  391. if(!($hookObject instanceof tslib_cObj_getImgResourceHook)) {
  392. throw new UnexpectedValueException('$hookObject must implement interface tslib_cObj_getImgResourceHook', 1218636383);
  393. }
  394. $this->getImgResourceHookObjects[] = $hookObject;
  395. }
  396. }
  397. }
  398. return $this->getImgResourceHookObjects;
  399. }
  400. /**
  401. * Sets the internal variable parentRecord with information about current record.
  402. * 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.
  403. *
  404. * @param array $data: The record array
  405. * @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.
  406. * @return void
  407. * @access private
  408. */
  409. function setParent($data,$currentRecord) {
  410. $this->parentRecord=array('data'=>$data, 'currentRecord'=>$currentRecord);
  411. }
  412. /***********************************************
  413. *
  414. * CONTENT_OBJ:
  415. *
  416. ***********************************************/
  417. /**
  418. * Returns the "current" value.
  419. * 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.
  420. * It's like "load accumulator" in the good old C64 days... basically a "register" you can use as you like.
  421. * 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.
  422. *
  423. * @return mixed The "current" value
  424. */
  425. function getCurrentVal() {
  426. return $this->data[$this->currentValKey];
  427. }
  428. /**
  429. * Sets the "current" value.
  430. *
  431. * @param mixed The variable that you want to set as "current"
  432. * @return void
  433. * @see getCurrentVal()
  434. */
  435. function setCurrentVal($value) {
  436. $this->data[$this->currentValKey] = $value;
  437. }
  438. /**
  439. * Rendering of a "numerical array" of cObjects from TypoScript
  440. * Will call ->cObjGetSingle() for each cObject found and accumulate the output.
  441. *
  442. * @param array $setup: Array with cObjects as values.
  443. * @param string $addKey: A prefix for the debugging information
  444. * @return string Rendered output from the cObjects in the array.
  445. * @see cObjGetSingle()
  446. */
  447. function cObjGet($setup,$addKey='') {
  448. if (is_array($setup)) {
  449. $sKeyArray=t3lib_TStemplate::sortedKeyList($setup);
  450. $content ='';
  451. foreach($sKeyArray as $theKey) {
  452. $theValue=$setup[$theKey];
  453. if (intval($theKey) && !strstr($theKey,'.')) {
  454. $conf=$setup[$theKey.'.'];
  455. $content.=$this->cObjGetSingle($theValue,$conf,$addKey.$theKey); // Get the contentObject
  456. }
  457. }
  458. return $content;
  459. }
  460. }
  461. /**
  462. * Renders a content object
  463. *
  464. * @param string The content object name, eg. "TEXT" or "USER" or "IMAGE"
  465. * @param array The array with TypoScript properties for the content object
  466. * @param string A string label used for the internal debugging tracking.
  467. * @return string cObject output
  468. * @example http://typo3.org/doc.0.html?&encryptionKey=&tx_extrepmgm_pi1[extUid]=267&tx_extrepmgm_pi1[tocEl]=153&cHash=7e74f4d331
  469. */
  470. function cObjGetSingle($name,$conf,$TSkey='__') {
  471. global $TYPO3_CONF_VARS;
  472. $content='';
  473. // Checking that the function is not called eternally. This is done by interrupting at a depth of 100
  474. $GLOBALS['TSFE']->cObjectDepthCounter--;
  475. if ($GLOBALS['TSFE']->cObjectDepthCounter>0) {
  476. $name = trim($name);
  477. if ($GLOBALS['TT']->LR) $GLOBALS['TT']->push($TSkey, $name);
  478. // Checking if the COBJ is a reference to another object. (eg. name of 'blabla.blabla = < styles.something')
  479. if (substr($name,0,1)=='<') {
  480. $key = trim(substr($name,1));
  481. $cF = t3lib_div::makeInstance('t3lib_TSparser');
  482. // $name and $conf is loaded with the referenced values.
  483. $old_conf=$conf;
  484. list($name, $conf) = $cF->getVal($key,$GLOBALS['TSFE']->tmpl->setup);
  485. if (is_array($old_conf) && count($old_conf)) {
  486. $conf = $this->joinTSarrays($conf,$old_conf);
  487. }
  488. // Getting the cObject
  489. $GLOBALS['TT']->incStackPointer();
  490. $content.=$this->cObjGetSingle($name,$conf,$key);
  491. $GLOBALS['TT']->decStackPointer();
  492. } else {
  493. $hooked = false;
  494. // Application defined cObjects
  495. foreach ($this->cObjHookObjectsArr as $cObjName => $hookObj) {
  496. if (($name===$cObjName) && method_exists($hookObj, 'cObjGetSingleExt')) {
  497. $content.= $hookObj->cObjGetSingleExt($name, $conf, $TSkey, $this);
  498. $hooked = true;
  499. }
  500. }
  501. if (!$hooked && isset($GLOBALS['OBTS']['tso_list'][$name]) && t3lib_extMgm::isLoaded('obts')) {
  502. $content.= obts_dtutil::renderDatatypeContent($name, $GLOBALS['OBTS']['tso_list'][$name], $conf, $this);
  503. } elseif (!$hooked) {
  504. // Traditional Content Object branching:
  505. switch($name) {
  506. case 'COBJ_ARRAY':
  507. case 'COA':
  508. $content.=$this->COBJ_ARRAY($conf);
  509. break;
  510. case 'COA_INT':
  511. $content.=$this->COBJ_ARRAY($conf,'INT');
  512. break;
  513. case 'HTML':
  514. $content.=$this->HTML($conf);
  515. break;
  516. case 'TEXT':
  517. $content.=$this->TEXT($conf);
  518. break;
  519. case 'CLEARGIF':
  520. $content.=$this->CLEARGIF($conf);
  521. break;
  522. case 'FILE':
  523. $content.=$this->FILE($conf);
  524. break;
  525. case 'IMAGE':
  526. $content.=$this->IMAGE($conf);
  527. break;
  528. case 'IMG_RESOURCE':
  529. $content.=$this->IMG_RESOURCE($conf);
  530. break;
  531. case 'IMGTEXT':
  532. $content.=$this->IMGTEXT($conf);
  533. break;
  534. case 'CONTENT':
  535. $content.=$this->CONTENT($conf);
  536. break;
  537. case 'RECORDS':
  538. $content.=$this->RECORDS($conf);
  539. break;
  540. case 'HMENU':
  541. $content.=$this->HMENU($conf);
  542. break;
  543. case 'CTABLE':
  544. $content.=$this->CTABLE($conf);
  545. break;
  546. case 'OTABLE':
  547. $content.=$this->OTABLE($conf);
  548. break;
  549. case 'COLUMNS':
  550. $content.=$this->COLUMNS($conf);
  551. break;
  552. case 'HRULER':
  553. $content.=$this->HRULER($conf);
  554. break;
  555. case 'CASE':
  556. $content.=$this->CASEFUNC($conf);
  557. break;
  558. case 'LOAD_REGISTER':
  559. case 'RESTORE_REGISTER':
  560. $this->LOAD_REGISTER($conf,$name);
  561. break;
  562. case 'FORM':
  563. $content.=$this->FORM($conf);
  564. break;
  565. case 'SEARCHRESULT':
  566. $content.=$this->SEARCHRESULT($conf);
  567. break;
  568. case 'PHP_SCRIPT':
  569. $content.=$this->PHP_SCRIPT($conf);
  570. break;
  571. case 'PHP_SCRIPT_EXT':
  572. $content.=$this->PHP_SCRIPT($conf,'EXT');
  573. break;
  574. case 'PHP_SCRIPT_INT':
  575. $content.=$this->PHP_SCRIPT($conf,'INT');
  576. break;
  577. case 'USER':
  578. $content.=$this->USER($conf);
  579. break;
  580. case 'USER_INT':
  581. $content.=$this->USER($conf,'INT');
  582. break;
  583. case 'TEMPLATE':
  584. $content.=$this->TEMPLATE($conf);
  585. break;
  586. case 'EDITPANEL':
  587. if ($GLOBALS['TSFE']->beUserLogin) {$content.=$this->editPanel($content, $conf);}
  588. break;
  589. case 'MULTIMEDIA':
  590. $content.=$this->MULTIMEDIA($conf);
  591. break;
  592. case 'MEDIA':
  593. $content.=$this->MEDIA($conf);
  594. break;
  595. case 'SWFOBJECT':
  596. $content.=$this->SWFOBJECT($conf);
  597. break;
  598. case 'QTOBJECT':
  599. $content.=$this->QTOBJECT($conf);
  600. break;
  601. default:
  602. // call hook functions for extra processing
  603. if($name && is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClassDefault'])) {
  604. foreach($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClassDefault'] as $classData) {
  605. $hookObject = t3lib_div::getUserObj($classData);
  606. if(!($hookObject instanceof tslib_content_cObjGetSingleHook)) {
  607. throw new UnexpectedValueException('$hookObject must implement interface tslib_content_cObjGetSingleHook', 1195043731);
  608. }
  609. /* @var $hookObject tslib_content_cObjGetSingleHook */
  610. $content .= $hookObject->getSingleContentObject($name, (array) $conf, $TSkey, $this);
  611. }
  612. }
  613. break;
  614. }
  615. }
  616. }
  617. if ($GLOBALS['TT']->LR) $GLOBALS['TT']->pull($content);
  618. }
  619. // Increasing on exit...
  620. $GLOBALS['TSFE']->cObjectDepthCounter++;
  621. return $content;
  622. }
  623. /********************************************
  624. *
  625. * Functions rendering content objects (cObjects)
  626. *
  627. ********************************************/
  628. /**
  629. * Rendering the cObject, HTML
  630. *
  631. * @param array Array of TypoScript properties
  632. * @return string Output
  633. * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=349&cHash=d3fd0c70b4
  634. */
  635. function HTML($conf) {
  636. return $this->stdWrap($conf['value'],$conf['value.']);
  637. }
  638. /**
  639. * Rendering the cObject, TEXT
  640. *
  641. * @param array Array of TypoScript properties
  642. * @return string Output
  643. * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=350&cHash=b49de28f83
  644. */
  645. function TEXT($conf) {
  646. return $this->stdWrap($conf['value'],$conf);
  647. }
  648. /**
  649. * Rendering the cObject, CLEARGIF
  650. *
  651. * @param array Array of TypoScript properties
  652. * @return string Output
  653. * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=355&cHash=70c0f19915
  654. */
  655. function CLEARGIF($conf) {
  656. $w = $this->stdWrap($conf['width'],$conf['width.']);
  657. $h = $this->stdWrap($conf['height'],$conf['height.']);
  658. $w = $w ? $w : 1;
  659. $h = $h ? $h : 1;
  660. $wrap = $conf['wrap'] ? $conf['wrap'] : '|<br />';
  661. $theValue = $this->wrap('<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$w.'" height="'.$h.'"'.$this->getBorderAttr(' border="0"').' alt="" title="" />', $wrap);
  662. return $this->stdWrap($theValue,$conf['stdWrap.']);
  663. }
  664. /**
  665. * Rendering the cObject, COBJ_ARRAY / COA and COBJ_ARRAY_INT
  666. *
  667. * @param array Array of TypoScript properties
  668. * @param string If "INT" then the cObject is a "COBJ_ARRAY_INT" (non-cached), otherwise just "COBJ_ARRAY" (cached)
  669. * @return string Output
  670. * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=351&cHash=a09db0329c
  671. */
  672. function COBJ_ARRAY($conf,$ext='') {
  673. if (is_array($conf)) {
  674. $content = '';
  675. switch($ext) {
  676. case 'INT':
  677. $substKey = $ext . '_SCRIPT.' . $GLOBALS['TSFE']->uniqueHash();
  678. $content .= '<!--'.$substKey.'-->';
  679. $GLOBALS['TSFE']->config[$ext . 'incScript'][$substKey] = array (
  680. 'file' => $conf['includeLibs'],
  681. 'conf' => $conf,
  682. 'cObj' => serialize($this),
  683. 'type' => 'COA'
  684. );
  685. break;
  686. default:
  687. if ($this->checkIf($conf['if.'])) {
  688. $this->includeLibs($conf);
  689. $content = $this->cObjGet($conf);
  690. if ($conf['wrap']) {
  691. $content = $this->wrap($content, $conf['wrap']);
  692. }
  693. if ($conf['stdWrap.']) {
  694. $content = $this->stdWrap($content, $conf['stdWrap.']);
  695. }
  696. }
  697. break;
  698. }
  699. return $content;
  700. } else {
  701. $GLOBALS['TT']->setTSlogMessage('No elements in this content object array (COBJ_ARRAY, COA, COA_INT).', 2);
  702. }
  703. }
  704. /**
  705. * Rendering the cObject, USER and USER_INT
  706. *
  707. * @param array Array of TypoScript properties
  708. * @param string If "INT" then the cObject is a "USER_INT" (non-cached), otherwise just "USER" (cached)
  709. * @return string Output
  710. * @link http://typo3.org/documentation/document-library/references/doc_core_tsref/4.1.0/view/8/22/
  711. */
  712. function USER($conf, $ext = '') {
  713. $content = '';
  714. switch ($ext) {
  715. case 'INT':
  716. $this->userObjectType = self::OBJECTTYPE_USER_INT;
  717. $substKey = $ext . '_SCRIPT.' . $GLOBALS['TSFE']->uniqueHash();
  718. $content.='<!--' . $substKey . '-->';
  719. $GLOBALS['TSFE']->config[$ext . 'incScript'][$substKey] = array(
  720. 'file' => $conf['includeLibs'],
  721. 'conf' => $conf,
  722. 'cObj' => serialize($this),
  723. 'type' => 'FUNC'
  724. );
  725. break;
  726. default:
  727. if ($this->userObjectType === false) {
  728. // Come here only if we are not called from $TSFE->INTincScript_process()!
  729. $this->userObjectType = self::OBJECTTYPE_USER;
  730. }
  731. $this->includeLibs($conf);
  732. $tempContent = $this->callUserFunction($conf['userFunc'], $conf, '');
  733. if ($this->doConvertToUserIntObject) {
  734. $this->doConvertToUserIntObject = false;
  735. $content = $this->USER($conf, 'INT');
  736. } else {
  737. $content .= $tempContent;
  738. }
  739. break;
  740. }
  741. $this->userObjectType = false;
  742. return $content;
  743. }
  744. /**
  745. * Retrieves a type of object called as USER or USER_INT. Object can detect their
  746. * type by using this call. It returns OBJECTTYPE_USER_INT or OBJECTTYPE_USER depending on the
  747. * current object execution. In all other cases it will return false to indicate
  748. * a call out of context.
  749. *
  750. * @return mixed One of OBJECTTYPE_ class constants or false
  751. */
  752. public function getUserObjectType() {
  753. return $this->userObjectType;
  754. }
  755. /**
  756. * Requests the current USER object to be converted to USER_INT.
  757. *
  758. * @return void
  759. */
  760. public function convertToUserIntObject() {
  761. if ($this->userObjectType !== self::OBJECTTYPE_USER) {
  762. $GLOBALS['TT']->setTSlogMessage('tslib_cObj::convertToUserIntObject() ' .
  763. 'is called in the wrong context or for the wrong object type', 2);
  764. }
  765. else {
  766. $this->doConvertToUserIntObject = true;
  767. }
  768. }
  769. /**
  770. * Rendering the cObject, FILE
  771. *
  772. * @param array Array of TypoScript properties
  773. * @return string Output
  774. * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=352&cHash=379c60f8bc
  775. */
  776. function FILE($conf) {
  777. $theValue = $this->fileResource($this->stdWrap($conf['file'],$conf['file.']), trim($this->getAltParam($conf, false)));
  778. if ($conf['linkWrap']) {
  779. $theValue = $this->linkWrap($theValue,$conf['linkWrap']);
  780. }
  781. return $this->wrap($theValue,$conf['wrap']);
  782. }
  783. /**
  784. * Rendering the cObject, IMAGE
  785. *
  786. * @param array Array of TypoScript properties
  787. * @return string Output
  788. * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=353&cHash=440681ea56
  789. * @see cImage()
  790. */
  791. function IMAGE($conf) {
  792. $content='';
  793. if ($this->checkIf($conf['if.'])) {
  794. $theValue = $this->cImage($conf['file'],$conf);
  795. if ($conf['stdWrap.']) {
  796. $theValue = $this->stdWrap($theValue,$conf['stdWrap.']);
  797. }
  798. return $theValue;
  799. }
  800. }
  801. /**
  802. * Rendering the cObject, IMG_RESOURCE
  803. *
  804. * @param array Array of TypoScript properties
  805. * @return string Output
  806. * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=354&cHash=46f9299706
  807. * @see getImgResource()
  808. */
  809. function IMG_RESOURCE($conf) {
  810. $GLOBALS['TSFE']->lastImgResourceInfo = $this->getImgResource($conf['file'],$conf['file.']);
  811. return $this->stdWrap($GLOBALS['TSFE']->lastImgResourceInfo[3],$conf['stdWrap.']);
  812. }
  813. /**
  814. * Rendering the cObject, IMGTEXT
  815. *
  816. * @param array Array of TypoScript properties
  817. * @return string Output
  818. * @link http://typo3.org/doc.0.html?&tx_extrepmgm_pi1[extUid]=270&tx_extrepmgm_pi1[tocEl]=363&cHash=cf2969bce1
  819. */
  820. function IMGTEXT($conf) {
  821. $content='';
  822. if (is_array($conf['text.'])) {
  823. $content.= $this->stdWrap($this->cObjGet($conf['text.'],'text.'),$conf['text.']); // this gets the surrounding content
  824. }
  825. $imgList=trim($this->stdWrap($conf['imgList'],$conf['imgList.'])); // gets images
  826. if ($imgList) {
  827. $imgs = t3lib_div::trimExplode(',',$imgList);
  828. $imgStart = intval($this->stdWrap($conf['imgStart'],$conf['imgStart.']));
  829. $imgCount= count($imgs)-$imgStart;
  830. $imgMax = intval($this->stdWrap($conf['imgMax'],$conf['imgMax.']));
  831. if ($imgMax) {
  832. $imgCount = t3lib_div::intInRange($imgCount,0,$imgMax); // reduces the number of images.
  833. }
  834. $imgPath = $this->stdWrap($conf['imgPath'],$conf['imgPath.']);
  835. // initialisation
  836. $caption='';
  837. $captionArray = array();
  838. if (!$conf['captionSplit'] && !$conf['imageTextSplit'] && is_array($conf['caption.'])) {
  839. $caption = $this->stdWrap($this->cObjGet($conf['caption.'], 'caption.'),$conf['caption.']); // global caption, no splitting
  840. }
  841. if ($conf['captionSplit'] && $conf['captionSplit.']['cObject']) {
  842. $legacyCaptionSplit = 1;
  843. $capSplit = $this->stdWrap($conf['captionSplit.']['token'], $conf['captionSplit.']['token.']);
  844. if (!$capSplit) {$capSplit=LF;}
  845. $captionArray = explode($capSplit, $this->cObjGetSingle($conf['captionSplit.']['cObject'], $conf['captionSplit.']['cObject.'], 'captionSplit.cObject'));
  846. foreach ($captionArray as $ca_key => $ca_val) {
  847. $captionArray[$ca_key] = $this->stdWrap(trim($captionArray[$ca_key]), $conf['captionSplit.']['stdWrap.']);
  848. }
  849. }
  850. $tablecode='';
  851. $position=$this->stdWrap($conf['textPos'],$conf['textPos.']);
  852. $tmppos = $position&7;
  853. $contentPosition = $position&24;
  854. $align = $this->align[$tmppos];
  855. $cap = ($caption)?1:0;
  856. $txtMarg = intval($this->stdWrap($conf['textMargin'],$conf['textMargin.']));
  857. if (!$conf['textMargin_outOfText'] && $contentPosition<16) {
  858. $txtMarg=0;
  859. }
  860. $cols = intval($this->stdWrap($conf['cols'],$conf['cols.']));
  861. $rows = intval($this->stdWrap($conf['rows'],$conf['rows.']));
  862. $colspacing = intval($this->stdWrap($conf['colSpace'],$conf['colSpace.']));
  863. $rowspacing = intval($this->stdWrap($conf['rowSpace'],$conf['rowSpace.']));
  864. $border = intval($this->stdWrap($conf['border'],$conf['border.'])) ? 1:0;
  865. $borderColor = $this->stdWrap($conf['borderCol'],$conf['borderCol.']);
  866. $borderThickness = intval($this->stdWrap($conf['borderThick'],$conf['borderThick.']));
  867. $borderColor=$borderColor?$borderColor:'black';
  868. $borderThickness=$borderThickness?$borderThickness:1;
  869. $caption_align = $this->stdWrap($conf['captionAlign'],$conf['captionAlign.']);
  870. if (!$caption_align) {
  871. $caption_align = $align;
  872. }
  873. // generate cols
  874. $colCount = ($cols > 1) ? $cols : 1;
  875. if ($colCount > $imgCount) {$colCount = $imgCount;}
  876. $rowCount = ($colCount > 1) ? ceil($imgCount / $colCount) : $imgCount;
  877. // generate rows
  878. if ($rows>1) {
  879. $rowCount = $rows;
  880. if ($rowCount > $imgCount) {$rowCount = $imgCount;}
  881. $colCount = ($rowCount>1) ? ceil($imgCount / $rowCount) : $imgCount;
  882. }
  883. // max Width
  884. $colRelations = trim($this->stdWrap($conf['colRelations'],$conf['colRelations.']));
  885. $maxW = intval($this->stdWrap($conf['maxW'],$conf['maxW.']));
  886. $maxWInText = intval($this->stdWrap($conf['maxWInText'],$conf['maxWInText.']));
  887. if (!$maxWInText) { // If maxWInText is not set, it's calculated to the 50 % of the max...
  888. $maxWInText = round($maxW/2);
  889. }
  890. if ($maxWInText && $contentPosition>=16) { // inText
  891. $maxW = $maxWInText;
  892. }
  893. if ($maxW && $colCount > 0) { // If there is a max width and if colCount is greater than column
  894. /* debug($border*$borderThickness*2);
  895. debug($maxW);
  896. debug($colspacing);
  897. debug(($maxW-$colspacing*($colCount-1)-$colCount*$border*$borderThickness*2));
  898. */
  899. $maxW = ceil(($maxW-$colspacing*($colCount-1)-$colCount*$border*$borderThickness*2)/$colCount);
  900. }
  901. // create the relation between rows
  902. $colMaxW = Array();
  903. if ($colRelations) {
  904. $rel_parts = explode(':',$colRelations);
  905. $rel_total = 0;
  906. for ($a=0;$a<$colCount;$a++) {
  907. $rel_parts[$a] = intval($rel_parts[$a]);
  908. $rel_total+= $rel_parts[$a];
  909. }
  910. if ($rel_total) {
  911. for ($a=0;$a<$colCount;$a++) {
  912. $colMaxW[$a] = round(($maxW*$colCount)/$rel_total*$rel_parts[$a]);
  913. }
  914. 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.
  915. $colMaxW = Array();
  916. }
  917. }
  918. }
  919. $image_compression = intval($this->stdWrap($conf['image_compression'],$conf['image_compression.']));
  920. $image_effects = intval($this->stdWrap($conf['image_effects'],$conf['image_effects.']));
  921. $image_frames = intval($this->stdWrap($conf['image_frames.']['key'],$conf['image_frames.']['key.']));
  922. // fetches pictures
  923. $splitArr=array();
  924. $splitArr['imgObjNum']=$conf['imgObjNum'];
  925. $splitArr = $GLOBALS['TSFE']->tmpl->splitConfArray($splitArr,$imgCount);
  926. // EqualHeight
  927. $equalHeight = intval($this->stdWrap($conf['equalH'],$conf['equalH.']));
  928. if ($equalHeight) { // Initiate gifbuilder object in order to get dimensions AND calculate the imageWidth's
  929. $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
  930. $gifCreator->init();
  931. $relations = Array();
  932. $relations_cols = Array();
  933. $totalMaxW = $maxW*$colCount;
  934. for($a=0;$a<$imgCount;$a++) {
  935. $imgKey = $a+$imgStart;
  936. $imgInfo = $gifCreator->getImageDimensions($imgPath.$imgs[$imgKey]);
  937. $relations[$a] = $imgInfo[1] / $equalHeight; // relationship between the original height and the wished height
  938. 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.
  939. $relations_cols[floor($a/$colCount)] += $imgInfo[0]/$relations[$a]; // counts the total width of the row with the new height taken into consideration.
  940. }
  941. }
  942. }
  943. $imageRowsFinalWidths = Array(); // contains the width of every image row
  944. $imageRowsMaxHeights = Array();
  945. $imgsTag=array();
  946. $origImages=array();
  947. for($a=0;$a<$imgCount;$a++) {
  948. $GLOBALS['TSFE']->register['IMAGE_NUM'] = $a;
  949. $GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = $a;
  950. $imgKey = $a+$imgStart;
  951. $totalImagePath = $imgPath.$imgs[$imgKey];
  952. $this->data[$this->currentValKey] = $totalImagePath;
  953. $imgObjNum = intval($splitArr[$a]['imgObjNum']);
  954. $imgConf = $conf[$imgObjNum.'.'];
  955. if ($equalHeight) {
  956. $scale = 1;
  957. if ($totalMaxW) {
  958. $rowTotalMaxW = $relations_cols[floor($a/$colCount)];
  959. if ($rowTotalMaxW > $totalMaxW) {
  960. $scale = $rowTotalMaxW / $totalMaxW;
  961. }
  962. }
  963. // transfer info to the imageObject. Please note, that
  964. $imgConf['file.']['height'] = round($equalHeight/$scale);
  965. unset($imgConf['file.']['width']);
  966. unset($imgConf['file.']['maxW']);
  967. unset($imgConf['file.']['maxH']);
  968. unset($imgConf['file.']['minW']);
  969. unset($imgConf['file.']['minH']);
  970. unset($imgConf['file.']['width.']);
  971. unset($imgConf['file.']['maxW.']);
  972. unset($imgConf['file.']['maxH.']);
  973. unset($imgConf['file.']['minW.']);
  974. unset($imgConf['file.']['minH.']);
  975. $maxW = 0; // setting this to zero, so that it doesn't disturb
  976. }
  977. if ($maxW) {
  978. if (count($colMaxW)) {
  979. $imgConf['file.']['maxW'] = $colMaxW[($a%$colCount)];
  980. } else {
  981. $imgConf['file.']['maxW'] = $maxW;
  982. }
  983. }
  984. // Image Object supplied:
  985. if (is_array($imgConf)) {
  986. if ($this->image_effects[$image_effects]) {
  987. $imgConf['file.']['params'].= ' '.$this->image_effects[$image_effects];
  988. }
  989. if ($image_frames) {
  990. if (is_array($conf['image_frames.'][$image_frames.'.'])) {
  991. $imgConf['file.']['m.'] = $conf['image_frames.'][$image_frames.'.'];
  992. }
  993. }
  994. if ($image_compression && $imgConf['file']!='GIFBUILDER') {
  995. if ($image_compression==1) {
  996. $tempImport = $imgConf['file.']['import'];
  997. $tempImport_dot = $imgConf['file.']['import.'];
  998. unset($imgConf['file.']);
  999. $imgConf['file.']['import'] = $tempImport;
  1000. $imgConf['file.']['import.'] = $tempImport_dot;
  1001. } elseif (isset($this->image_compression[$image_compression])) {
  1002. $imgConf['file.']['params'].= ' '.$this->image_compression[$image_compression]['params'];
  1003. $imgConf['file.']['ext'] = $this->image_compression[$image_compression]['ext'];
  1004. unset($imgConf['file.']['ext.']);
  1005. }
  1006. }
  1007. // "alt", "title" and "longdesc" attributes:
  1008. if (!strlen($imgConf['altText']) && !is_array($imgConf['altText.'])) {
  1009. $imgConf['altText'] = $conf['altText'];
  1010. $imgConf['altText.'] = $conf['altText.'];
  1011. }
  1012. if (!strlen($imgConf['titleText']) && !is_array($imgConf['titleText.'])) {
  1013. $imgConf['titleText'] = $conf['titleText'];
  1014. $imgConf['titleText.'] = $conf['titleText.'];
  1015. }
  1016. if (!strlen($imgConf['longdescURL']) && !is_array($imgConf['longdescURL.'])) {
  1017. $imgConf['longdescURL'] = $conf['longdescURL'];
  1018. $imgConf['longdescURL.'] = $conf['longdescURL.'];
  1019. }
  1020. } else {
  1021. $imgConf = array(
  1022. 'altText' => $conf['altText'],
  1023. 'titleText' => $conf['titleText'],
  1024. 'longdescURL' => $conf['longdescURL'],
  1025. 'file' => $totalImagePath
  1026. );
  1027. }
  1028. $imgsTag[$imgKey] = $this->IMAGE($imgConf);
  1029. // Store the original filepath
  1030. $origImages[$imgKey]=$GLOBALS['TSFE']->lastImageInfo;
  1031. $imageRowsFinalWidths[floor($a/$colCount)] += $GLOBALS['TSFE']->lastImageInfo[0];
  1032. if ($GLOBALS['TSFE']->lastImageInfo[1]>$imageRowsMaxHeights[floor($a/$colCount)]) {
  1033. $imageRowsMaxHeights[floor($a/$colCount)] = $GLOBALS['TSFE']->lastImageInfo[1];
  1034. }
  1035. }
  1036. // calculating the tableWidth:
  1037. // TableWidth problems: It creates problems if the pictures are NOT as wide as the tableWidth.
  1038. $tableWidth = max($imageRowsFinalWidths)+ $colspacing*($colCount-1) + $colCount*$border*$borderThickness*2;
  1039. // make table for pictures
  1040. $index=$imgStart;
  1041. $noRows = $this->stdWrap($conf['noRows'],$conf['noRows.']);
  1042. $noCols = $this->stdWrap($conf['noCols'],$conf['noCols.']);
  1043. if ($noRows) {$noCols=0;} // noRows overrides noCols. They cannot exist at the same time.
  1044. if ($equalHeight) {
  1045. $noCols=1;
  1046. $noRows=0;
  1047. }
  1048. $rowCount_temp=1;
  1049. $colCount_temp=$colCount;
  1050. if ($noRows) {
  1051. $rowCount_temp = $rowCount;
  1052. $rowCount=1;
  1053. }
  1054. if ($noCols) {
  1055. $colCount=1;
  1056. }
  1057. // col- and rowspans calculated
  1058. $colspan = (($colspacing) ? $colCount*2-1 : $colCount);
  1059. $rowspan = (($rowspacing) ? $rowCount*2-1 : $rowCount) + $cap;
  1060. // Edit icons:
  1061. $editIconsHTML = $conf['editIcons']&&$GLOBALS['TSFE']->beUserLogin ? $this->editIcons('',$conf['editIcons'],$conf['editIcons.']) : '';
  1062. // strech out table:
  1063. $tablecode='';
  1064. $flag=0;
  1065. if ($conf['noStretchAndMarginCells']!=1) {
  1066. $tablecode.='<tr>';
  1067. if ($txtMarg && $align=='right') { // If right aligned, the textborder is added on the right side
  1068. $tablecode.='<td rowspan="'.($rowspan+1).'" valign="top"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$txtMarg.'" height="1" alt="" title="" />'.($editIconsHTML?'<br />'.$editIconsHTML:'').'</td>';
  1069. $editIconsHTML='';
  1070. $flag=1;
  1071. }
  1072. $tablecode.='<td colspan="'.$colspan.'"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$tableWidth.'" height="1" alt="" /></td>';
  1073. if ($txtMarg && $align=='left') { // If left aligned, the textborder is added on the left side
  1074. $tablecode.='<td rowspan="'.($rowspan+1).'" valign="top"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$txtMarg.'" height="1" alt="" title="" />'.($editIconsHTML?'<br />'.$editIconsHTML:'').'</td>';
  1075. $editIconsHTML='';
  1076. $flag=1;
  1077. }
  1078. if ($flag) $tableWidth+=$txtMarg+1;
  1079. // $tableWidth=0;
  1080. $tablecode.='</tr>';
  1081. }
  1082. // draw table
  1083. 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!
  1084. 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.
  1085. $tablecode.='<tr><td colspan="'.$colspan.'"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$rowspacing.'"'.$this->getBorderAttr(' border="0"').' alt="" title="" /></td></tr>';
  1086. }
  1087. $tablecode.='<tr>'; // starting row
  1088. for ($b=0; $b<$colCount_temp; $b++) { // Looping through the columns
  1089. 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.
  1090. if (!$noCols) {
  1091. $tablecode.='<td><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$colspacing.'" height="1"'.$this->getBorderAttr(' border="0"').' alt="" title="" /></td>';
  1092. } else {
  1093. $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="" />';
  1094. $colSpacer='<td valign="top">'.$colSpacer.'</td>'; // added 160301, needed for the new "noCols"-table...
  1095. $tablecode.=$colSpacer;
  1096. }
  1097. }
  1098. if (!$noCols || ($noCols && !$b)) {
  1099. $tablecode.='<td valign="top">'; // starting the cell. If "noCols" this cell will hold all images in the row, otherwise only a single image.
  1100. 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.
  1101. }
  1102. 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.
  1103. $GLOBALS['TSFE']->register['IMAGE_NUM'] = $imgIndex; // register previous imgIndex
  1104. $imgIndex = $index+$a*$colCount_temp;
  1105. $GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = $imgIndex;
  1106. if ($imgsTag[$imgIndex]) {
  1107. if ($rowspacing && $noRows && $a) { // Puts distance between the images IF "noRows" is set and this is the first iteration of the loop
  1108. $tablecode.= '<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$rowspacing.'" alt="" title="" /><br />';
  1109. }
  1110. if ($legacyCaptionSplit) {
  1111. $thisCaption = $captionArray[$imgIndex];
  1112. } else if ($conf['captionSplit'] || $conf['imageTextSplit']) {
  1113. $thisCaption = $this->stdWrap($this->cObjGet($conf['caption.'], 'caption.'), $conf['caption.']);
  1114. }
  1115. $imageHTML = $imgsTag[$imgIndex].'<br />';
  1116. $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.
  1117. if ($border) {$imageHTML='<table border="0" cell…

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