• Main Page
  • Related Pages
  • Packages
  • Classes
  • Files
  • Examples

/home/thomas/API/sources/typo3_src-4.2.1/typo3/sysext/cms/tslib/class.tslib_content.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00218   // Includes this classes since it is used for parsing HTML
00219 require_once(PATH_t3lib."class.t3lib_parsehtml.php");
00220 
00221         // Object TypoScript library included:
00222 if(t3lib_extMgm::isLoaded('obts')) {
00223         require_once(t3lib_extMgm::extPath('obts').'_tsobject/_tso.php');
00224 }
00225 
00226 
00227 
00228 
00229 
00230 
00231 
00232 
00233 
00234 
00235 
00236 
00237 
00238 
00239 
00240 
00241 
00256 class tslib_cObj {
00257         var $align = Array ('center', 'right', 'left');
00258 
00269         var $image_compression = Array(
00270                 10 => Array('params'=>'', 'ext'=>'gif'),
00271                 11 => Array('params'=>'-colors 128', 'ext'=>'gif'),
00272                 12 => Array('params'=>'-colors 64', 'ext'=>'gif'),
00273                 13 => Array('params'=>'-colors 32', 'ext'=>'gif'),
00274                 14 => Array('params'=>'-colors 16', 'ext'=>'gif'),
00275                 15 => Array('params'=>'-colors 8', 'ext'=>'gif'),
00276 
00277                 30 => Array('params'=>'-colors 256', 'ext'=>'png'),
00278                 31 => Array('params'=>'-colors 128', 'ext'=>'png'),
00279                 32 => Array('params'=>'-colors 64', 'ext'=>'png'),
00280                 33 => Array('params'=>'-colors 32', 'ext'=>'png'),
00281                 34 => Array('params'=>'-colors 16', 'ext'=>'png'),
00282                 35 => Array('params'=>'-colors 8', 'ext'=>'png'),
00283                 39 => Array('params'=>'', 'ext'=>'png'),
00284 
00285                 20 => Array('params'=>'-quality 100', 'ext'=>'jpg'),
00286                 21 => Array('params'=>'-quality 90', 'ext'=>'jpg'),
00287                 22 => Array('params'=>'-quality 80', 'ext'=>'jpg'),
00288                 23 => Array('params'=>'-quality 70', 'ext'=>'jpg'),
00289                 24 => Array('params'=>'-quality 60', 'ext'=>'jpg'),
00290                 25 => Array('params'=>'-quality 50', 'ext'=>'jpg'),
00291                 26 => Array('params'=>'-quality 40', 'ext'=>'jpg'),
00292                 27 => Array('params'=>'-quality 30', 'ext'=>'jpg'),
00293                 28 => Array('params'=>'-quality 20', 'ext'=>'jpg')
00294         );
00295 
00301         var $image_effects = Array(
00302                 1 => '-rotate 90',
00303                 2 => '-rotate 270',
00304                 3 => '-rotate 180',
00305                 10 => '-colorspace GRAY',
00306                 11 => '-sharpen 70',
00307                 20 => '-normalize',
00308                 23 => '-contrast',
00309                 25 => '-gamma 1.3',
00310                 26 => '-gamma 0.8'
00311         );
00312 
00320         var $data = Array();
00321         var $oldData = Array();                         // Used for backup...
00322         var $alternativeData ='';                       // If this is set with an array before stdWrap, it's used instead of $this->data in the data-property in stdWrap
00323         var $parameters = Array();                      // Used by the parseFunc function and is loaded with tag-parameters when parsing tags.
00324         var $currentValKey = 'currentValue_kidjls9dksoje';
00325         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.
00326         var $currentRecordTotal = 0;            // Set in cObj->RECORDS and cObj->CONTENT to the current number of records selected in a query.
00327         var $currentRecordNumber = 0;           // Incremented in cObj->RECORDS and cObj->CONTENT before each record rendering.
00328         var $parentRecordNumber = 0;            // Incremented in parent cObj->RECORDS and cObj->CONTENT before each record rendering.
00329         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.
00330         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.
00331 
00332         // internal
00333         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)
00334         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.
00335         var $checkPid_badDoktypeList = '255';
00336         var $lastTypoLinkUrl='';        // This will be set by typoLink() to the url of the most recent link created.
00337         var $lastTypoLinkTarget='';     // DO. link target.
00338         var $lastTypoLinkLD = array();
00339         var $substMarkerCache=array();  // Caching substituteMarkerArrayCached function
00340         var $recordRegister=array();    // Array that registers rendered content elements (or any table) to make sure they are not rendered recursively!
00341         var $cObjHookObjectsArr = array();              // Containig hooks for userdefined cObjects
00342         protected $stdWrapHookObjects = array();                // Containig hook objects for stdWrap
00343 
00353         function start($data,$table='') {
00354                 global $TYPO3_CONF_VARS;
00355                 $this->data = $data;
00356                 $this->currentRecord = $table ? $table.':'.$this->data['uid'] : '';
00357                 $this->parameters = Array();
00358                 if (is_array ($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClass'])) {
00359                         foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClass'] as $classArr) {
00360                                 $this->cObjHookObjectsArr[$classArr[0]] = &t3lib_div::getUserObj($classArr[1]);
00361                         }
00362                 }
00363 
00364                 if(is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['stdWrap'])) {
00365                         foreach($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['stdWrap'] as $classData) {
00366                                 $hookObject = &t3lib_div::getUserObj($classData);
00367 
00368                                 if(!($hookObject instanceof tslib_content_stdWrapHook)) {
00369                                         throw new UnexpectedValueException('$hookObject must implement interface tslib_content_stdWrapHook', 1195043965);
00370                                 }
00371 
00372                                 $this->stdWrapHookObjects[] = $hookObject;
00373                         }
00374                 }
00375 
00376         }
00377 
00387         function setParent($data,$currentRecord)        {
00388                 $this->parentRecord=array('data'=>$data, 'currentRecord'=>$currentRecord);
00389         }
00390 
00391 
00392 
00393 
00394 
00395 
00396 
00397 
00398         /***********************************************
00399          *
00400          * CONTENT_OBJ:
00401          *
00402          ***********************************************/
00403 
00412         function getCurrentVal()        {
00413                 return $this->data[$this->currentValKey];
00414         }
00415 
00423         function setCurrentVal($value)  {
00424                 $this->data[$this->currentValKey] = $value;
00425         }
00426 
00436         function cObjGet($setup,$addKey='')     {
00437                 if (is_array($setup))   {
00438                         $sKeyArray=t3lib_TStemplate::sortedKeyList($setup);
00439                         $content ='';
00440                         foreach($sKeyArray as $theKey)  {
00441                                 $theValue=$setup[$theKey];
00442                                 if (intval($theKey) && !strstr($theKey,'.'))    {
00443                                         $conf=$setup[$theKey.'.'];
00444                                         $content.=$this->cObjGetSingle($theValue,$conf,$addKey.$theKey);        // Get the contentObject
00445                                 }
00446                         }
00447                         return $content;
00448                 }
00449         }
00450 
00460         function cObjGetSingle($name,$conf,$TSkey='__') {
00461                 global $TYPO3_CONF_VARS;
00462 
00463                 $content='';
00464                         // Checking that the function is not called eternally. This is done by interrupting at a depth of 100
00465                 $GLOBALS['TSFE']->cObjectDepthCounter--;
00466                 if ($GLOBALS['TSFE']->cObjectDepthCounter>0)    {
00467                         $name = trim($name);
00468                         if ($GLOBALS['TT']->LR) $GLOBALS['TT']->push($TSkey, $name);
00469 
00470                                 // Checking if the COBJ is a reference to another object. (eg. name of 'blabla.blabla = < styles.something')
00471                         if (substr($name,0,1)=='<')     {
00472                                 $key = trim(substr($name,1));
00473                                 $cF = t3lib_div::makeInstance('t3lib_TSparser');
00474                                         // $name and $conf is loaded with the referenced values.
00475                                 $old_conf=$conf;
00476                                 list($name, $conf) = $cF->getVal($key,$GLOBALS['TSFE']->tmpl->setup);
00477                                 if (is_array($old_conf) && count($old_conf))    {
00478                                         $conf = $this->joinTSarrays($conf,$old_conf);
00479 //                                      debug($conf);
00480                                 }
00481                                         // Getting the cObject
00482                                 $GLOBALS['TT']->incStackPointer();
00483                                         $content.=$this->cObjGetSingle($name,$conf,$key);
00484                                 $GLOBALS['TT']->decStackPointer();
00485                         } else {
00486 
00487                                 $hooked = false;
00488                                         // Application defined cObjects
00489                                 foreach ($this->cObjHookObjectsArr as $cObjName => $hookObj)    {
00490                                         if (($name===$cObjName) && method_exists($hookObj, 'cObjGetSingleExt')) {
00491                                                 $content.= $hookObj->cObjGetSingleExt($name, $conf, $TSkey, $this);
00492                                                 $hooked = true;
00493                                         }
00494                                 }
00495                                 if (!$hooked && t3lib_extMgm::isLoaded('obts') && isset($GLOBALS['OBTS']['tso_list'][$name])) {
00496                                         $content.= obts_dtutil::renderDatatypeContent($name, $GLOBALS['OBTS']['tso_list'][$name], $conf, $this);
00497                                 } elseif (!$hooked) {
00498                                                 // Traditional Content Object branching:
00499                                         switch($name)   {
00500                                                 case 'COBJ_ARRAY':
00501                                                 case 'COA':
00502                                                         $content.=$this->COBJ_ARRAY($conf);
00503                                                 break;
00504                                                 case 'COA_INT':
00505                                                         $content.=$this->COBJ_ARRAY($conf,'INT');
00506                                                 break;
00507                                                 case 'HTML':
00508                                                         $content.=$this->HTML($conf);
00509                                                 break;
00510                                                 case 'TEXT':
00511                                                         $content.=$this->TEXT($conf);
00512                                                 break;
00513                                                 case 'CLEARGIF':
00514                                                         $content.=$this->CLEARGIF($conf);
00515                                                 break;
00516                                                 case 'FILE':
00517                                                         $content.=$this->FILE($conf);
00518                                                 break;
00519                                                 case 'IMAGE':
00520                                                         $content.=$this->IMAGE($conf);
00521                                                 break;
00522                                                 case 'IMG_RESOURCE':
00523                                                         $content.=$this->IMG_RESOURCE($conf);
00524                                                 break;
00525                                                 case 'IMGTEXT':
00526                                                         $content.=$this->IMGTEXT($conf);
00527                                                 break;
00528                                                 case 'CONTENT':
00529                                                         $content.=$this->CONTENT($conf);
00530                                                 break;
00531                                                 case 'RECORDS':
00532                                                         $content.=$this->RECORDS($conf);
00533                                                 break;
00534                                                 case 'HMENU':
00535                                                         $content.=$this->HMENU($conf);
00536                                                 break;
00537                                                 case 'CTABLE':
00538                                                         $content.=$this->CTABLE($conf);
00539                                                 break;
00540                                                 case 'OTABLE':
00541                                                         $content.=$this->OTABLE($conf);
00542                                                 break;
00543                                                 case 'COLUMNS':
00544                                                         $content.=$this->COLUMNS($conf);
00545                                                 break;
00546                                                 case 'HRULER':
00547                                                         $content.=$this->HRULER($conf);
00548                                                 break;
00549                                                 case 'CASE':
00550                                                         $content.=$this->CASEFUNC($conf);
00551                                                 break;
00552                                                 case 'LOAD_REGISTER':
00553                                                 case 'RESTORE_REGISTER':
00554                                                         $this->LOAD_REGISTER($conf,$name);
00555                                                 break;
00556                                                 case 'FORM':
00557                                                         $content.=$this->FORM($conf);
00558                                                 break;
00559                                                 case 'SEARCHRESULT':
00560                                                         $content.=$this->SEARCHRESULT($conf);
00561                                                 break;
00562                                                 case 'PHP_SCRIPT':
00563                                                         $content.=$this->PHP_SCRIPT($conf);
00564                                                 break;
00565                                                 case 'PHP_SCRIPT_EXT':
00566                                                         $content.=$this->PHP_SCRIPT($conf,'EXT');
00567                                                 break;
00568                                                 case 'PHP_SCRIPT_INT':
00569                                                         $content.=$this->PHP_SCRIPT($conf,'INT');
00570                                                 break;
00571                                                 case 'USER':
00572                                                         $content.=$this->USER($conf);
00573                                                 break;
00574                                                 case 'USER_INT':
00575                                                         $content.=$this->USER($conf,'INT');
00576                                                 break;
00577                                                 case 'TEMPLATE':
00578                                                         $content.=$this->TEMPLATE($conf);
00579                                                 break;
00580                                                 case 'EDITPANEL':
00581                                                         if ($GLOBALS['TSFE']->beUserLogin)      {$content.=$this->editPanel($content, $conf);}
00582                                                 break;
00583                                                 case 'MULTIMEDIA':
00584                                                         $content.=$this->MULTIMEDIA($conf);
00585                                                 break;
00586                                                 default:
00587                                                                 // call hook functions for extra processing
00588                                                         if($name && is_array($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClassDefault']))    {
00589                                                                 foreach($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClassDefault'] as $classData)    {
00590                                                                         $hookObject = &t3lib_div::getUserObj($classData);
00591 
00592                                                                         if(!($hookObject instanceof tslib_content_cObjGetSingleHook)) {
00593                                                                                 throw new UnexpectedValueException('$hookObject must implement interface tslib_content_cObjGetSingleHook', 1195043731);
00594                                                                         }
00595                                                                         /* @var $hookObject tslib_content_cObjGetSingleHook */
00596                                                                         $content .= $hookObject->getSingleContentObject($name, (array) $conf, $TSkey, $this);
00597                                                                 }
00598                                                         }
00599                                                 break;
00600                                         }
00601                                 }
00602                         }
00603                         if ($GLOBALS['TT']->LR) $GLOBALS['TT']->pull($content);
00604                 }
00605                         // Increasing on exit...
00606                 $GLOBALS['TSFE']->cObjectDepthCounter++;
00607                 return $content;
00608         }
00609 
00610 
00611 
00612 
00613 
00614 
00615 
00616         /********************************************
00617          *
00618          * Functions rendering content objects (cObjects)
00619          *
00620          ********************************************/
00621 
00629         function HTML($conf)    {
00630                 return $this->stdWrap($conf['value'],$conf['value.']);
00631         }
00632 
00640         function TEXT($conf)    {
00641                 return $this->stdWrap($conf['value'],$conf);
00642         }
00643 
00651         function CLEARGIF($conf)        {
00652                 $w = $this->stdWrap($conf['width'],$conf['width.']);
00653                 $h = $this->stdWrap($conf['height'],$conf['height.']);
00654                 $w = $w ? $w : 1;
00655                 $h = $h ? $h : 1;
00656                 $wrap = $conf['wrap'] ? $conf['wrap'] : '|<br />';
00657                 $theValue = $this->wrap('<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$w.'" height="'.$h.'"'.$this->getBorderAttr(' border="0"').' alt="" title="" />', $wrap);
00658 
00659                 return $this->stdWrap($theValue,$conf['stdWrap.']);
00660         }
00661 
00670         function COBJ_ARRAY($conf,$ext='')      {
00671                 $content='';
00672                 switch($ext)    {
00673                         case 'INT':
00674                                 $substKey = $ext.'_SCRIPT.'.$GLOBALS['TSFE']->uniqueHash();
00675                                 $content.='<!--'.$substKey.'-->';
00676                                 $GLOBALS['TSFE']->config[$ext.'incScript'][$substKey] = array(
00677                                         'file' => $conf['includeLibs'],
00678                                         'conf'=>$conf,
00679                                         'cObj'=>serialize($this),
00680                                         'type'=>'COA'
00681                                 );
00682                         break;
00683                         default:
00684                                 if ($this->checkIf($conf['if.']))       {
00685                                         $content=$this->cObjGet($conf);
00686                                         if ($conf['wrap']) {
00687                                                 $content=$this->wrap($content, $conf['wrap']);
00688                                         }
00689                                         if ($conf['stdWrap.']) {
00690                                                 $content=$this->stdWrap($content, $conf['stdWrap.']);
00691                                         }
00692                                 }
00693                         break;
00694                 }
00695                 return $content;
00696         }
00697 
00706         function USER($conf,$ext='')    {
00707                 $content='';
00708                 switch($ext)    {
00709                         case 'INT':
00710                                 $substKey = $ext.'_SCRIPT.'.$GLOBALS['TSFE']->uniqueHash();
00711                                 $content.='<!--'.$substKey.'-->';
00712                                 $GLOBALS['TSFE']->config[$ext.'incScript'][$substKey] = array(
00713                                         'file' => $conf['includeLibs'],
00714                                         'conf' => $conf,
00715                                         'cObj' => serialize($this),
00716                                         'type' => 'FUNC'
00717                                 );
00718                         break;
00719                         default:
00720                                 $content.=$this->callUserFunction($conf['userFunc'],$conf,'');
00721                         break;
00722                 }
00723                 return $content;
00724         }
00725 
00733         function FILE($conf)    {
00734                 $theValue = $this->fileResource($this->stdWrap($conf['file'],$conf['file.']), trim($this->getAltParam($conf, false)));
00735                 if ($conf['linkWrap'])  {
00736                         $theValue = $this->linkWrap($theValue,$conf['linkWrap']);
00737                 }
00738                 return $this->wrap($theValue,$conf['wrap']);
00739         }
00740 
00749         function IMAGE($conf)   {
00750                 $content='';
00751                 if ($this->checkIf($conf['if.']))       {
00752                         $theValue = $this->cImage($conf['file'],$conf);
00753                         if ($conf['stdWrap.'])  {
00754                                 $theValue = $this->stdWrap($theValue,$conf['stdWrap.']);
00755                         }
00756                         return $theValue;
00757                 }
00758         }
00759 
00768         function IMG_RESOURCE($conf)    {
00769                 $GLOBALS['TSFE']->lastImgResourceInfo = $this->getImgResource($conf['file'],$conf['file.']);
00770                 return $this->stdWrap($GLOBALS['TSFE']->lastImgResourceInfo[3],$conf['stdWrap.']);
00771         }
00772 
00780         function IMGTEXT($conf) {
00781                 $content='';
00782                 if (is_array($conf['text.']))   {
00783                         $content.= $this->stdWrap($this->cObjGet($conf['text.'],'text.'),$conf['text.']);       // this gets the surrounding content
00784                 }
00785                 $imgList=trim($this->stdWrap($conf['imgList'],$conf['imgList.']));      // gets images
00786                 if ($imgList)   {
00787                         $imgs = t3lib_div::trimExplode(',',$imgList);
00788                         $imgStart = intval($this->stdWrap($conf['imgStart'],$conf['imgStart.']));
00789 
00790                         $imgCount= count($imgs)-$imgStart;
00791 
00792                         $imgMax = intval($this->stdWrap($conf['imgMax'],$conf['imgMax.']));
00793                         if ($imgMax)    {
00794                                 $imgCount = t3lib_div::intInRange($imgCount,0,$imgMax); // reduces the number of images.
00795                         }
00796 
00797                         $imgPath = $this->stdWrap($conf['imgPath'],$conf['imgPath.']);
00798 
00799                                 // initialisation
00800                         $caption='';
00801                         $captionArray = array();
00802                         if (!$conf['captionSplit'] && !$conf['imageTextSplit'] && is_array($conf['caption.']))  {
00803                                 $caption = $this->stdWrap($this->cObjGet($conf['caption.'], 'caption.'),$conf['caption.']);     // global caption, no splitting
00804                         }
00805                         if ($conf['captionSplit'] && $conf['captionSplit.']['cObject']) {
00806                                 $legacyCaptionSplit = 1;
00807                                 $capSplit = $this->stdWrap($conf['captionSplit.']['token'], $conf['captionSplit.']['token.']);
00808                                 if (!$capSplit) {$capSplit=chr(10);}
00809                                 $captionArray = explode($capSplit, $this->cObjGetSingle($conf['captionSplit.']['cObject'], $conf['captionSplit.']['cObject.'], 'captionSplit.cObject'));
00810                                 while (list($ca_key, $ca_val) = each($captionArray))    {
00811                                         $captionArray[$ca_key] = $this->stdWrap(trim($captionArray[$ca_key]), $conf['captionSplit.']['stdWrap.']);
00812                                 }
00813                         }
00814 
00815                         $tablecode='';
00816                         $position=$this->stdWrap($conf['textPos'],$conf['textPos.']);
00817 
00818                         $tmppos = $position&7;
00819                         $contentPosition = $position&24;
00820                         $align = $this->align[$tmppos];
00821                         $cap = ($caption)?1:0;
00822                         $txtMarg = intval($this->stdWrap($conf['textMargin'],$conf['textMargin.']));
00823                         if (!$conf['textMargin_outOfText'] && $contentPosition<16)      {
00824                                 $txtMarg=0;
00825                         }
00826 
00827                         $cols = intval($this->stdWrap($conf['cols'],$conf['cols.']));
00828                         $rows = intval($this->stdWrap($conf['rows'],$conf['rows.']));
00829                         $colspacing = intval($this->stdWrap($conf['colSpace'],$conf['colSpace.']));
00830                         $rowspacing = intval($this->stdWrap($conf['rowSpace'],$conf['rowSpace.']));
00831 
00832                         $border = intval($this->stdWrap($conf['border'],$conf['border.'])) ? 1:0;
00833                         $borderColor = $this->stdWrap($conf['borderCol'],$conf['borderCol.']);
00834                         $borderThickness = intval($this->stdWrap($conf['borderThick'],$conf['borderThick.']));
00835 
00836                         $borderColor=$borderColor?$borderColor:'black';
00837                         $borderThickness=$borderThickness?$borderThickness:1;
00838 
00839                         $caption_align = $this->stdWrap($conf['captionAlign'],$conf['captionAlign.']);
00840                         if (!$caption_align) {
00841                                 $caption_align = $align;
00842                         }
00843                                 // generate cols
00844                         $colCount = ($cols > 1) ? $cols : 1;
00845                         if ($colCount > $imgCount)      {$colCount = $imgCount;}
00846                         $rowCount = ($colCount > 1) ? ceil($imgCount / $colCount) : $imgCount;
00847                                 // generate rows
00848                         if ($rows>1)  {
00849                                 $rowCount = $rows;
00850                                 if ($rowCount > $imgCount)      {$rowCount = $imgCount;}
00851                                 $colCount = ($rowCount>1) ? ceil($imgCount / $rowCount) : $imgCount;
00852                         }
00853 
00854                                 // max Width
00855                         $colRelations = trim($this->stdWrap($conf['colRelations'],$conf['colRelations.']));
00856                         $maxW = intval($this->stdWrap($conf['maxW'],$conf['maxW.']));
00857 
00858                         $maxWInText = intval($this->stdWrap($conf['maxWInText'],$conf['maxWInText.']));
00859                         if (!$maxWInText)       {       // If maxWInText is not set, it's calculated to the 50 % of the max...
00860                                 $maxWInText = round($maxW/2);
00861                         }
00862 
00863                         if ($maxWInText && $contentPosition>=16)        {       // inText
00864                                 $maxW = $maxWInText;
00865                         }
00866 
00867                         if ($maxW && $colCount > 0) {   // If there is a max width and if colCount is greater than  column
00868 /*                              debug($border*$borderThickness*2);
00869                                 debug($maxW);
00870                                 debug($colspacing);
00871                                 debug(($maxW-$colspacing*($colCount-1)-$colCount*$border*$borderThickness*2));
00872                                 */
00873                                 $maxW = ceil(($maxW-$colspacing*($colCount-1)-$colCount*$border*$borderThickness*2)/$colCount);
00874                         }
00875                                 // create the relation between rows
00876                         $colMaxW = Array();
00877                         if ($colRelations)      {
00878                                 $rel_parts = explode(':',$colRelations);
00879                                 $rel_total = 0;
00880                                 for ($a=0;$a<$colCount;$a++)    {
00881                                         $rel_parts[$a] = intval($rel_parts[$a]);
00882                                         $rel_total+= $rel_parts[$a];
00883                                 }
00884                                 if ($rel_total) {
00885                                         for ($a=0;$a<$colCount;$a++)    {
00886                                                 $colMaxW[$a] = round(($maxW*$colCount)/$rel_total*$rel_parts[$a]);
00887                                         }
00888                                         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.
00889                                                 $colMaxW = Array();
00890                                         }
00891                                 }
00892                         }
00893                         $image_compression = intval($this->stdWrap($conf['image_compression'],$conf['image_compression.']));
00894                         $image_effects = intval($this->stdWrap($conf['image_effects'],$conf['image_effects.']));
00895                         $image_frames = intval($this->stdWrap($conf['image_frames.']['key'],$conf['image_frames.']['key.']));
00896 
00897                                 // fetches pictures
00898                         $splitArr=array();
00899                         $splitArr['imgObjNum']=$conf['imgObjNum'];
00900                         $splitArr = $GLOBALS['TSFE']->tmpl->splitConfArray($splitArr,$imgCount);
00901 
00902                                 // EqualHeight
00903                         $equalHeight = intval($this->stdWrap($conf['equalH'],$conf['equalH.']));
00904                         if ($equalHeight)       {       // Initiate gifbuilder object in order to get dimensions AND calculate the imageWidth's
00905                                 $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
00906                                 $gifCreator->init();
00907                                 $relations = Array();
00908                                 $relations_cols = Array();
00909                                 $totalMaxW = $maxW*$colCount;
00910                                 for($a=0;$a<$imgCount;$a++)     {
00911                                         $imgKey = $a+$imgStart;
00912                                         $imgInfo = $gifCreator->getImageDimensions($imgPath.$imgs[$imgKey]);
00913                                         $relations[$a] = $imgInfo[1] / $equalHeight;    // relationship between the original height and the wished height
00914                                         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.
00915                                                 $relations_cols[floor($a/$colCount)] += $imgInfo[0]/$relations[$a];     // counts the total width of the row with the new height taken into consideration.
00916                                         }
00917                                 }
00918                         }
00919 
00920                         $imageRowsFinalWidths = Array();        // contains the width of every image row
00921                         $imageRowsMaxHeights = Array();
00922                         $imgsTag=array();
00923                         $origImages=array();
00924                         for($a=0;$a<$imgCount;$a++)     {
00925                                 $GLOBALS['TSFE']->register['IMAGE_NUM'] = $a;
00926                                 $GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = $a;
00927 
00928                                 $imgKey = $a+$imgStart;
00929                                 $totalImagePath = $imgPath.$imgs[$imgKey];
00930                                 $this->data[$this->currentValKey] = $totalImagePath;
00931                                 $imgObjNum = intval($splitArr[$a]['imgObjNum']);
00932                                 $imgConf = $conf[$imgObjNum.'.'];
00933 
00934                                 if ($equalHeight)       {
00935                                         $scale = 1;
00936                                         if ($totalMaxW) {
00937                                                 $rowTotalMaxW = $relations_cols[floor($a/$colCount)];
00938                                                 if ($rowTotalMaxW > $totalMaxW) {
00939                                                         $scale = $rowTotalMaxW / $totalMaxW;
00940                                                 }
00941                                         }
00942                                                 // transfer info to the imageObject. Please note, that
00943                                         $imgConf['file.']['height'] = round($equalHeight/$scale);
00944 
00945                                         unset($imgConf['file.']['width']);
00946                                         unset($imgConf['file.']['maxW']);
00947                                         unset($imgConf['file.']['maxH']);
00948                                         unset($imgConf['file.']['minW']);
00949                                         unset($imgConf['file.']['minH']);
00950                                         unset($imgConf['file.']['width.']);
00951                                         unset($imgConf['file.']['maxW.']);
00952                                         unset($imgConf['file.']['maxH.']);
00953                                         unset($imgConf['file.']['minW.']);
00954                                         unset($imgConf['file.']['minH.']);
00955                                         $maxW = 0;      // setting this to zero, so that it doesn't disturb
00956                                 }
00957 
00958                                 if ($maxW) {
00959                                         if (count($colMaxW))    {
00960                                                 $imgConf['file.']['maxW'] = $colMaxW[($a%$colCount)];
00961                                         } else {
00962                                                 $imgConf['file.']['maxW'] = $maxW;
00963                                         }
00964                                 }
00965 
00966                                         // Image Object supplied:
00967                                 if (is_array($imgConf)) {
00968                                         if ($this->image_effects[$image_effects])       {
00969                                                 $imgConf['file.']['params'].= ' '.$this->image_effects[$image_effects];
00970                                         }
00971                                         if ($image_frames)      {
00972                                                 if (is_array($conf['image_frames.'][$image_frames.'.']))        {
00973                                                         $imgConf['file.']['m.'] = $conf['image_frames.'][$image_frames.'.'];
00974                                                 }
00975                                         }
00976                                         if ($image_compression && $imgConf['file']!='GIFBUILDER')       {
00977                                                 if ($image_compression==1)      {
00978                                                         $tempImport = $imgConf['file.']['import'];
00979                                                         $tempImport_dot = $imgConf['file.']['import.'];
00980                                                         unset($imgConf['file.']);
00981                                                         $imgConf['file.']['import'] = $tempImport;
00982                                                         $imgConf['file.']['import.'] = $tempImport_dot;
00983                                                 } elseif (isset($this->image_compression[$image_compression])) {
00984                                                         $imgConf['file.']['params'].= ' '.$this->image_compression[$image_compression]['params'];
00985                                                         $imgConf['file.']['ext'] = $this->image_compression[$image_compression]['ext'];
00986                                                         unset($imgConf['file.']['ext.']);
00987                                                 }
00988                                         }
00989 
00990                                                 // "alt", "title" and "longdesc" attributes:
00991                                         if (!strlen($imgConf['altText']) && !is_array($imgConf['altText.'])) {
00992                                                 $imgConf['altText'] = $conf['altText'];
00993                                                 $imgConf['altText.'] = $conf['altText.'];
00994                                         }
00995                                         if (!strlen($imgConf['titleText']) && !is_array($imgConf['titleText.'])) {
00996                                                 $imgConf['titleText'] = $conf['titleText'];
00997                                                 $imgConf['titleText.'] = $conf['titleText.'];
00998                                         }
00999                                         if (!strlen($imgConf['longdescURL']) && !is_array($imgConf['longdescURL.'])) {
01000                                                 $imgConf['longdescURL'] = $conf['longdescURL'];
01001                                                 $imgConf['longdescURL.'] = $conf['longdescURL.'];
01002                                         }
01003                                 } else {
01004                                         $imgConf = array(
01005                                                 'altText' => $conf['altText'],
01006                                                 'titleText' => $conf['titleText'],
01007                                                 'longdescURL' => $conf['longdescURL'],
01008                                                 'file' => $totalImagePath
01009                                         );
01010                                 }
01011 
01012                                 $imgsTag[$imgKey] = $this->IMAGE($imgConf);
01013 
01014                                         // Store the original filepath
01015                                 $origImages[$imgKey]=$GLOBALS['TSFE']->lastImageInfo;
01016 
01017                                 $imageRowsFinalWidths[floor($a/$colCount)] += $GLOBALS['TSFE']->lastImageInfo[0];
01018                                 if ($GLOBALS['TSFE']->lastImageInfo[1]>$imageRowsMaxHeights[floor($a/$colCount)])       {
01019                                         $imageRowsMaxHeights[floor($a/$colCount)] = $GLOBALS['TSFE']->lastImageInfo[1];
01020                                 }
01021                         }
01022                                 // calculating the tableWidth:
01023                                 // TableWidth problems: It creates problems if the pictures are NOT as wide as the tableWidth.
01024                         $tableWidth = max($imageRowsFinalWidths)+ $colspacing*($colCount-1) + $colCount*$border*$borderThickness*2;
01025 
01026                                 // make table for pictures
01027                         $index=$imgStart;
01028 
01029                         $noRows = $this->stdWrap($conf['noRows'],$conf['noRows.']);
01030                         $noCols = $this->stdWrap($conf['noCols'],$conf['noCols.']);
01031                         if ($noRows) {$noCols=0;}       // noRows overrides noCols. They cannot exist at the same time.
01032                         if ($equalHeight) {
01033                                 $noCols=1;
01034                                 $noRows=0;
01035                         }
01036 
01037                         $rowCount_temp=1;
01038                         $colCount_temp=$colCount;
01039                         if ($noRows)    {
01040                                 $rowCount_temp = $rowCount;
01041                                 $rowCount=1;
01042                         }
01043                         if ($noCols)    {
01044                                 $colCount=1;
01045                         }
01046                                 // col- and rowspans calculated
01047                         $colspan = (($colspacing) ? $colCount*2-1 : $colCount);
01048                         $rowspan = (($rowspacing) ? $rowCount*2-1 : $rowCount) + $cap;
01049 
01050 
01051                                 // Edit icons:
01052                         $editIconsHTML = $conf['editIcons']&&$GLOBALS['TSFE']->beUserLogin ? $this->editIcons('',$conf['editIcons'],$conf['editIcons.']) : '';
01053 
01054                                 // strech out table:
01055                         $tablecode='';
01056                         $flag=0;
01057                         if ($conf['noStretchAndMarginCells']!=1)        {
01058                                 $tablecode.='<tr>';
01059                                 if ($txtMarg && $align=='right')        {       // If right aligned, the textborder is added on the right side
01060                                         $tablecode.='<td rowspan="'.($rowspan+1).'" valign="top"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$txtMarg.'" height="1" alt="" title="" />'.($editIconsHTML?'<br />'.$editIconsHTML:'').'</td>';
01061                                         $editIconsHTML='';
01062                                         $flag=1;
01063                                 }
01064                                 $tablecode.='<td colspan="'.$colspan.'"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$tableWidth.'" height="1" alt="" /></td>';
01065                                 if ($txtMarg && $align=='left') {       // If left aligned, the textborder is added on the left side
01066                                         $tablecode.='<td rowspan="'.($rowspan+1).'" valign="top"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$txtMarg.'" height="1" alt="" title="" />'.($editIconsHTML?'<br />'.$editIconsHTML:'').'</td>';
01067                                         $editIconsHTML='';
01068                                         $flag=1;
01069                                 }
01070                                 if ($flag) $tableWidth+=$txtMarg+1;
01071         //                      $tableWidth=0;
01072                                 $tablecode.='</tr>';
01073                         }
01074 
01075                                 // draw table
01076                         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!
01077                                 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.
01078                                         $tablecode.='<tr><td colspan="'.$colspan.'"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$rowspacing.'"'.$this->getBorderAttr(' border="0"').' alt="" title="" /></td></tr>';
01079                                 }
01080                                 $tablecode.='<tr>';     // starting row
01081                                 for ($b=0; $b<$colCount_temp; $b++)     {       // Looping through the columns
01082                                         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.
01083                                                 if (!$noCols)   {
01084                                                         $tablecode.='<td><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$colspacing.'" height="1"'.$this->getBorderAttr(' border="0"').' alt="" title="" /></td>';
01085                                                 } else {
01086                                                         $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="" />';
01087                                                         $colSpacer='<td valign="top">'.$colSpacer.'</td>';      // added 160301, needed for the new "noCols"-table...
01088                                                         $tablecode.=$colSpacer;
01089                                                 }
01090                                         }
01091                                         if (!$noCols || ($noCols && !$b))       {
01092                                                 $tablecode.='<td valign="top">';        // starting the cell. If "noCols" this cell will hold all images in the row, otherwise only a single image.
01093                                                 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.
01094                                         }
01095                                         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.
01096                                                 $GLOBALS['TSFE']->register['IMAGE_NUM'] = $imgIndex;    // register previous imgIndex
01097                                                 $imgIndex = $index+$a*$colCount_temp;
01098                                                 $GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = $imgIndex;
01099                                                 if ($imgsTag[$imgIndex])        {
01100                                                         if ($rowspacing && $noRows && $a) {             // Puts distance between the images IF "noRows" is set and this is the first iteration of the loop
01101                                                                 $tablecode.= '<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$rowspacing.'" alt="" title="" /><br />';
01102                                                         }
01103                                                         if ($legacyCaptionSplit)        {
01104                                                                 $thisCaption = $captionArray[$imgIndex];
01105                                                         } else if ($conf['captionSplit'] || $conf['imageTextSplit'])    {
01106                                                                 $thisCaption = $this->stdWrap($this->cObjGet($conf['caption.'], 'caption.'), $conf['caption.']);
01107                                                         }
01108                                                         $imageHTML = $imgsTag[$imgIndex].'<br />';
01109                                                         $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.
01110                                                         if ($border)    {$imageHTML='<table border="0" cellpadding="'.$borderThickness.'" cellspacing="0" bgcolor="'.$borderColor.'"'.$Talign.'><tr><td>'.$imageHTML.'</td></tr></table>';}
01111                                                         $imageHTML.=$editIconsHTML;
01112                                                         $editIconsHTML='';
01113                                                         $imageHTML.=$thisCaption;       // Adds caption.
01114                                                         if ($noCols)    {$imageHTML='<td valign="top">'.$imageHTML.'</td>';}            // If noCols, put in table cell.
01115                                                         $tablecode.=$imageHTML;
01116                                                 }
01117                                         }
01118                                         $index++;
01119                                         if (!$noCols || ($noCols && $b+1==$colCount_temp))      {
01120                                                 if ($noCols)    {$tablecode.='</tr></table>';}  // In case of "noCols" we must finish the table that surrounds the images in the row.
01121                                                 $tablecode.='</td>';    // Ending the cell. In case of "noCols" the cell holds all pictures!
01122                                         }
01123                                 }
01124                                 $tablecode.='</tr>';    // ending row
01125                         }
01126