Main Page | Directories | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages | Examples

class.tslib_content.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2004 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 ***************************************************************/
00212   // Includes this class since it is used for parsing HTML
00213 require_once(PATH_t3lib."class.t3lib_parsehtml.php");
00214 
00215    // Object TypoScript library included:
00216 if(t3lib_extMgm::isLoaded('obts')) {
00217    require_once(t3lib_extMgm::extPath('obts').'_tsobject/_tso.php');
00218 }
00219 
00220 
00221 
00222 
00223 
00224 
00225 
00226 
00227 
00228 
00229 
00230 
00231 
00232 
00233 
00234 
00235 
00250 class tslib_cObj {
00251    var $align = Array ('center', 'right', 'left');
00252    var $caseConvStrings = array(
00253          'áéúíâêûôîæøåäöü',
00254          'ÁÉÚÍÄËÜÖÏÆØÅÄÖÜ'
00255       );
00256 
00267    var $image_compression = Array(
00268       10 => Array('params'=>'', 'ext'=>'gif'),
00269       11 => Array('params'=>'-colors 128', 'ext'=>'gif'),
00270       12 => Array('params'=>'-colors 64', 'ext'=>'gif'),
00271       13 => Array('params'=>'-colors 32', 'ext'=>'gif'),
00272       14 => Array('params'=>'-colors 16', 'ext'=>'gif'),
00273       15 => Array('params'=>'-colors 8', 'ext'=>'gif'),
00274 
00275       30 => Array('params'=>'-colors 256', 'ext'=>'png'),
00276       31 => Array('params'=>'-colors 128', 'ext'=>'png'),
00277       32 => Array('params'=>'-colors 64', 'ext'=>'png'),
00278       33 => Array('params'=>'-colors 32', 'ext'=>'png'),
00279       34 => Array('params'=>'-colors 16', 'ext'=>'png'),
00280       35 => Array('params'=>'-colors 8', 'ext'=>'png'),
00281       39 => Array('params'=>'', 'ext'=>'png'),
00282 
00283       20 => Array('params'=>'-quality 100', 'ext'=>'jpg'),
00284       21 => Array('params'=>'-quality 90', 'ext'=>'jpg'),
00285       22 => Array('params'=>'-quality 80', 'ext'=>'jpg'),
00286       23 => Array('params'=>'-quality 70', 'ext'=>'jpg'),
00287       24 => Array('params'=>'-quality 60', 'ext'=>'jpg'),
00288       25 => Array('params'=>'-quality 50', 'ext'=>'jpg'),
00289       26 => Array('params'=>'-quality 40', 'ext'=>'jpg'),
00290       27 => Array('params'=>'-quality 30', 'ext'=>'jpg'),
00291       28 => Array('params'=>'-quality 20', 'ext'=>'jpg')
00292    );
00293 
00299    var $image_effects = Array(
00300       1 => '-rotate 90',
00301       2 => '-rotate 270',
00302       3 => '-rotate 180',
00303       10 => '-colorspace GRAY',
00304       11 => '-sharpen 70',
00305       20 => '-normalize',
00306       23 => '-contrast',
00307       25 => '-gamma 1.3',
00308       26 => '-gamma 0.8'
00309    );
00310 
00318    var $data = Array();
00319    var $oldData = Array();          // Used for backup...
00320    var $alternativeData ='';        // If this is set with an array before stdWrap, it's used instead of $this->data in the data-property in stdWrap
00321    var $parameters = Array();       // Used by the parseFunc function and is loaded with tag-parameters when parsing tags.
00322    var $currentValKey = 'currentValue_kidjls9dksoje';
00323    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.
00324    var $currentRecordTotal = 0;     // Set in cObj->RECORDS and cObj->CONTENT to the current number of records selected in a query.
00325    var $currentRecordNumber = 0;    // Incremented in cObj->RECORDS and cObj->CONTENT before each record rendering.
00326    var $parentRecordNumber = 0;     // Incremented in parent cObj->RECORDS and cObj->CONTENT before each record rendering.
00327    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.
00328    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.
00329 
00330    // internal
00331    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)
00332    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.
00333    var $checkPid_badDoktypeList = '255';
00334    var $lastTypoLinkUrl='';   // This will be set by typoLink() to the url of the most recent link created.
00335    var $lastTypoLinkTarget='';   // DO. link target.
00336    var $substMarkerCache=array();   // Caching substituteMarkerArrayCached function
00337    var $recordRegister=array();  // Array that registers rendered content elements (or any table) to make sure they are not rendered recursively!
00338 
00348    function start($data,$table='')  {
00349       $this->data = $data;
00350       $this->currentRecord = $table ? $table.':'.$this->data['uid'] : '';
00351       $this->parameters = Array();
00352    }
00353 
00363    function setParent($data,$currentRecord)  {
00364       $this->parentRecord=array('data'=>$data, 'currentRecord'=>$currentRecord);
00365    }
00366 
00367 
00368 
00369 
00370 
00371 
00372 
00373 
00374    /***********************************************
00375     *
00376     * CONTENT_OBJ:
00377     *
00378     ***********************************************/
00379 
00388    function getCurrentVal()   {
00389       return $this->data[$this->currentValKey];
00390    }
00391 
00399    function setCurrentVal($value)   {
00400       $this->data[$this->currentValKey] = $value;
00401    }
00402 
00412    function cObjGet($setup,$addKey='') {
00413       if (is_array($setup))   {
00414          $sKeyArray=t3lib_TStemplate::sortedKeyList($setup);
00415          $content ='';
00416          foreach($sKeyArray as $theKey)   {
00417             $theValue=$setup[$theKey];
00418             if (intval($theKey) && !strstr($theKey,'.')) {
00419                $conf=$setup[$theKey.'.'];
00420                $content.=$this->cObjGetSingle($theValue,$conf,$addKey.$theKey);  // Get the contentObject
00421             }
00422          }
00423          return $content;
00424       }
00425    }
00426 
00436    function cObjGetSingle($name,$conf,$TSkey='__') {
00437       $content='';
00438          // Checking that the function is not called eternally. This is done by interrupting at a depth of 100
00439       $GLOBALS['TSFE']->cObjectDepthCounter--;
00440       if ($GLOBALS['TSFE']->cObjectDepthCounter>0) {
00441          $name = trim($name);
00442          if ($GLOBALS['TT']->LR) $GLOBALS['TT']->push($TSkey, $name);
00443 
00444             // Checking if the COBJ is a reference to another object. (eg. name of 'blabla.blabla = < styles.something')
00445          if (substr($name,0,1)=='<')   {
00446             $key = trim(substr($name,1));
00447             $cF = t3lib_div::makeInstance('t3lib_TSparser');
00448                // $name and $conf is loaded with the referenced values.
00449             $old_conf=$conf;
00450             list($name, $conf) = $cF->getVal($key,$GLOBALS['TSFE']->tmpl->setup);
00451             if (is_array($old_conf) && count($old_conf)) {
00452                $conf = $this->joinTSarrays($conf,$old_conf);
00453 //             debug($conf);
00454             }
00455                // Getting the cObject
00456             $GLOBALS['TT']->incStackPointer();
00457                $content.=$this->cObjGetSingle($name,$conf,$key);
00458             $GLOBALS['TT']->decStackPointer();
00459          } else {
00460 
00461                // Object TypoScript hook:
00462             if(t3lib_extMgm::isLoaded('obts') && isset($GLOBALS['OBTS']['tso_list'][$name])) {
00463                $content.= obts_dtutil::renderDatatypeContent($name, $GLOBALS['OBTS']['tso_list'][$name], $conf, $this);
00464             } else {
00465                   // Traditional Content Object branching:
00466                switch($name)  {
00467                   case 'COBJ_ARRAY':
00468                   case 'COA':
00469                      $content.=$this->COBJ_ARRAY($conf);
00470                   break;
00471                   case 'COA_INT':
00472                      $content.=$this->COBJ_ARRAY($conf,'INT');
00473                   break;
00474                   case 'HTML':
00475                      $content.=$this->HTML($conf);
00476                   break;
00477                   case 'TEXT':
00478                      $content.=$this->TEXT($conf);
00479                   break;
00480                   case 'CLEARGIF':
00481                      $content.=$this->CLEARGIF($conf);
00482                   break;
00483                   case 'FILE':
00484                      $content.=$this->FILE($conf);
00485                   break;
00486                   case 'IMAGE':
00487                      $content.=$this->IMAGE($conf);
00488                   break;
00489                   case 'IMG_RESOURCE':
00490                      $content.=$this->IMG_RESOURCE($conf);
00491                   break;
00492                   case 'IMGTEXT':
00493                      $content.=$this->IMGTEXT($conf);
00494                   break;
00495                   case 'CONTENT':
00496                      $content.=$this->CONTENT($conf);
00497                   break;
00498                   case 'RECORDS':
00499                      $content.=$this->RECORDS($conf);
00500                   break;
00501                   case 'HMENU':
00502                      $content.=$this->HMENU($conf);
00503                   break;
00504                   case 'CTABLE':
00505                      $content.=$this->CTABLE($conf);
00506                   break;
00507                   case 'OTABLE':
00508                      $content.=$this->OTABLE($conf);
00509                   break;
00510                   case 'COLUMNS':
00511                      $content.=$this->COLUMNS($conf);
00512                   break;
00513                   case 'HRULER':
00514                      $content.=$this->HRULER($conf);
00515                   break;
00516                   case 'CASE':
00517                      $content.=$this->CASEFUNC($conf);
00518                   break;
00519                   case 'LOAD_REGISTER':
00520                   case 'RESTORE_REGISTER':
00521                      $this->LOAD_REGISTER($conf,$name);
00522                   break;
00523                   case 'FORM':
00524                      $content.=$this->FORM($conf);
00525                   break;
00526                   case 'SEARCHRESULT':
00527                      $content.=$this->SEARCHRESULT($conf);
00528                   break;
00529                   case 'PHP_SCRIPT':
00530                      $content.=$this->PHP_SCRIPT($conf);
00531                   break;
00532                   case 'PHP_SCRIPT_EXT':
00533                      $content.=$this->PHP_SCRIPT($conf,'EXT');
00534                   break;
00535                   case 'PHP_SCRIPT_INT':
00536                      $content.=$this->PHP_SCRIPT($conf,'INT');
00537                   break;
00538                   case 'USER':
00539                      $content.=$this->USER($conf);
00540                   break;
00541                   case 'USER_INT':
00542                      $content.=$this->USER($conf,'INT');
00543                   break;
00544                   case 'TEMPLATE':
00545                      $content.=$this->TEMPLATE($conf);
00546                   break;
00547                   case 'EDITPANEL':
00548                      if ($GLOBALS['TSFE']->beUserLogin)  {$content.=$this->editPanel($content, $conf);}
00549                   break;
00550                   case 'MULTIMEDIA':
00551                      $content.=$this->MULTIMEDIA($conf);
00552                   break;
00553                }
00554             }
00555          }
00556          if ($GLOBALS['TT']->LR) $GLOBALS['TT']->pull($content);
00557       }
00558          // Increasing on exit...
00559       $GLOBALS['TSFE']->cObjectDepthCounter++;
00560       return $content;
00561    }
00562 
00563 
00564 
00565 
00566 
00567 
00568 
00569    /********************************************
00570     *
00571     * Functions rendering content objects (cObjects)
00572     *
00573     ********************************************/
00574 
00582    function HTML($conf) {
00583       return $this->stdWrap($conf['value'],$conf['value.']);
00584    }
00585 
00593    function TEXT($conf) {
00594       return $this->stdWrap($conf['value'],$conf);
00595    }
00596 
00604    function CLEARGIF($conf)   {
00605       $w = $this->stdWrap($conf['width'],$conf['width.']);
00606       $h = $this->stdWrap($conf['height'],$conf['height.']);
00607       $w = $w ? $w : 1;
00608       $h = $h ? $h : 1;
00609       $wrap = $conf['wrap'] ? $conf['wrap'] : '|<br />';
00610       $theValue = $this->wrap('<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$w.'" height="'.$h.'" border="0" alt="" title="" />', $wrap);
00611 
00612       return $this->stdWrap($theValue,$conf['stdWrap.']);
00613    }
00614 
00623    function COBJ_ARRAY($conf,$ext='')  {
00624       $content='';
00625       switch($ext)   {
00626          case 'INT':
00627             $substKey = $ext.'_SCRIPT.'.$GLOBALS['TSFE']->uniqueHash();
00628             $content.='<!--'.$substKey.'-->';
00629             $GLOBALS['TSFE']->config[$ext.'incScript'][$substKey] = array(
00630                'file'=>$incFile,
00631                'conf'=>$conf,
00632                'cObj'=>serialize($this),
00633                'type'=>'COA'
00634             );
00635          break;
00636          default:
00637             if ($this->checkIf($conf['if.']))   {
00638                $content=$this->cObjGet($conf);
00639                if ($conf['wrap']) {
00640                   $content=$this->wrap($content, $conf['wrap']);
00641                }
00642                if ($conf['stdWrap.']) {
00643                   $content=$this->stdWrap($content, $conf['stdWrap.']);
00644                }
00645             }
00646          break;
00647       }
00648       return $content;
00649    }
00650 
00659    function USER($conf,$ext='')  {
00660       $content='';
00661       switch($ext)   {
00662          case 'INT':
00663             $substKey = $ext.'_SCRIPT.'.$GLOBALS['TSFE']->uniqueHash();
00664             $content.='<!--'.$substKey.'-->';
00665             $GLOBALS['TSFE']->config[$ext.'incScript'][$substKey] = array(
00666                'file' => $incFile,
00667                'conf' => $conf,
00668                'cObj' => serialize($this),
00669                'type' => 'FUNC'
00670             );
00671          break;
00672          default:
00673             $content.=$this->callUserFunction($conf['userFunc'],$conf,'');
00674          break;
00675       }
00676       return $content;
00677    }
00678 
00686    function FILE($conf) {
00687       $theValue = $this->fileResource($this->stdWrap($conf['file'],$conf['file.']), trim($this->getAltParam($conf)));
00688       if ($conf['linkWrap'])  {
00689          $theValue = $this->linkWrap($theValue,$conf['linkWrap']);
00690       }
00691       return $this->wrap($theValue,$conf['wrap']);
00692    }
00693 
00702    function IMAGE($conf)   {
00703       $content='';
00704       if ($this->checkIf($conf['if.']))   {
00705          $theValue = $this->cImage($conf['file'],$conf);
00706          if ($conf['stdWrap.'])  {
00707             $theValue = $this->stdWrap($theValue,$conf['stdWrap.']);
00708          }
00709          return $theValue;
00710       }
00711    }
00712 
00721    function IMG_RESOURCE($conf)  {
00722       $imgArray = $this->getImgResource($conf['file'],$conf['file.']);
00723       return $this->stdWrap($imgArray[3],$conf['stdWrap.']);
00724    }
00725 
00733    function IMGTEXT($conf) {
00734       $content='';
00735       if (is_array($conf['text.'])) {
00736          $content.= $this->stdWrap($this->cObjGet($conf['text.'],'text.'),$conf['text.']);   // this gets the surrounding content
00737       }
00738       $imgList=trim($this->stdWrap($conf['imgList'],$conf['imgList.']));   // gets images
00739       if ($imgList)  {
00740          $imgs = t3lib_div::trimExplode(',',$imgList);
00741          $imgStart = intval($this->stdWrap($conf['imgStart'],$conf['imgStart.']));
00742 
00743          $imgCount= count($imgs)-$imgStart;
00744 
00745          $imgMax = intval($this->stdWrap($conf['imgMax'],$conf['imgMax.']));
00746          if ($imgMax)   {
00747             $imgCount = t3lib_div::intInRange($imgCount,0,$conf['imgMax']);   // reduces the number of images.
00748          }
00749 
00750          $imgPath = $this->stdWrap($conf['imgPath'],$conf['imgPath.']);
00751 
00752             // initialisation
00753          $caption='';
00754          if (is_array($conf['caption.'])) {
00755             $caption= $this->stdWrap($this->cObjGet($conf['caption.'], 'caption.'),$conf['caption.']);
00756          }
00757          $captionArray=array();
00758          if ($conf['captionSplit']) {
00759             $capSplit = $this->stdWrap($conf['captionSplit.']['token'],$conf['captionSplit.']['token.']);
00760             if (!$capSplit) {$capSplit=chr(10);}
00761             $caption2= $this->cObjGetSingle($conf['captionSplit.']['cObject'],$conf['captionSplit.']['cObject.'],'captionSplit.cObject');
00762             $captionArray=explode($capSplit,$caption2);
00763             while(list($ca_key,$ca_val)=each($captionArray))   {
00764                $captionArray[$ca_key] = $this->stdWrap(trim($captionArray[$ca_key]), $conf['captionSplit.']['stdWrap.']);
00765             }
00766          }
00767 
00768          $tablecode='';
00769          $position=$this->stdWrap($conf['textPos'],$conf['textPos.']);
00770 
00771          $tmppos = $position&7;
00772          $contentPosition = $position&24;
00773          $align = $this->align[$tmppos];
00774          $cap = ($caption)?1:0;
00775          $txtMarg = intval($this->stdWrap($conf['textMargin'],$conf['textMargin.']));
00776          if (!$conf['textMargin_outOfText'] && $contentPosition<16)  {
00777             $txtMarg=0;
00778          }
00779 
00780          $cols = intval($this->stdWrap($conf['cols'],$conf['cols.']));
00781          $rows = intval($this->stdWrap($conf['rows'],$conf['rows.']));
00782          $colspacing = intval($this->stdWrap($conf['colSpace'],$conf['colSpace.']));
00783          $rowspacing = intval($this->stdWrap($conf['rowSpace'],$conf['rowSpace.']));
00784 
00785          $border = intval($this->stdWrap($conf['border'],$conf['border.'])) ? 1:0;
00786          $borderColor = $this->stdWrap($conf['borderCol'],$conf['borderCol.']);
00787          $borderThickness = intval($this->stdWrap($conf['borderThick'],$conf['borderThick.']));
00788 
00789          $borderColor=$borderColor?$borderColor:'black';
00790          $borderThickness=$borderThickness?$borderThickness:1;
00791 
00792          $caption_align = $this->stdWrap($conf['captionAlign'],$conf['captionAlign.']);
00793          if (!$caption_align) {
00794             $caption_align = $align;
00795          }
00796             // generate cols
00797          $colCount = ($cols > 1) ? $cols : 1;
00798          if ($colCount > $imgCount) {$colCount = $imgCount;}
00799          $rowCount = ($colCount > 1) ? ceil($imgCount / $colCount) : $imgCount;
00800             // generate rows
00801          if ($rows>1)  {
00802             $rowCount = $rows;
00803             if ($rowCount > $imgCount) {$rowCount = $imgCount;}
00804             $colCount = ($rowCount>1) ? ceil($imgCount / $rowCount) : $imgCount;
00805          }
00806 
00807             // max Width
00808          $colRelations = trim($this->stdWrap($conf['colRelations'],$conf['colRelations.']));
00809          $maxW = intval($this->stdWrap($conf['maxW'],$conf['maxW.']));
00810 
00811          $maxWInText = intval($this->stdWrap($conf['maxWInText'],$conf['maxWInText.']));
00812          if (!$maxWInText) {  // If maxWInText is not set, it's calculated to the 70 % of the max...
00813             $maxWInText = round($maxW/100*50);
00814          }
00815 
00816          if ($maxWInText && $contentPosition>=16)  {  // inText
00817             $maxW = $maxWInText;
00818          }
00819 
00820          if ($maxW && $colCount > 0) { // If there is a max width and if colCount is greater than  column
00821 /*          debug($border*$borderThickness*2);
00822             debug($maxW);
00823             debug($colspacing);
00824             debug(($maxW-$colspacing*($colCount-1)-$colCount*$border*$borderThickness*2));
00825             */
00826             $maxW = ceil(($maxW-$colspacing*($colCount-1)-$colCount*$border*$borderThickness*2)/$colCount);
00827          }
00828             // create the relation between rows
00829          $colMaxW = Array();
00830          if ($colRelations)   {
00831             $rel_parts = explode(':',$colRelations);
00832             $rel_total = 0;
00833             for ($a=0;$a<$colCount;$a++)  {
00834                $rel_parts[$a] = intval($rel_parts[$a]);
00835                $rel_total+= $rel_parts[$a];
00836             }
00837             if ($rel_total)   {
00838                for ($a=0;$a<$colCount;$a++)  {
00839                   $colMaxW[$a] = round(($maxW*$colCount)/$rel_total*$rel_parts[$a]);
00840                }
00841                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.
00842                   $colMaxW = Array();
00843                }
00844             }
00845          }
00846          $image_compression = intval($this->stdWrap($conf['image_compression'],$conf['image_compression.']));
00847          $image_effects = intval($this->stdWrap($conf['image_effects'],$conf['image_effects.']));
00848          $image_frames = intval($this->stdWrap($conf['image_frames.']['key'],$conf['image_frames.']['key.']));
00849 
00850             // fetches pictures
00851          $splitArr=array();
00852          $splitArr['imgObjNum']=$conf['imgObjNum'];
00853          $splitArr = $GLOBALS['TSFE']->tmpl->splitConfArray($splitArr,$imgCount);
00854 
00855             // EqualHeight
00856          $equalHeight = intval($this->stdWrap($conf['equalH'],$conf['equalH.']));
00857          if ($equalHeight) {  // Initiate gifbuilder object in order to get dimensions AND calculate the imageWidth's
00858             $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
00859             $gifCreator->init();
00860             $relations = Array();
00861             $relations_cols = Array();
00862             $totalMaxW = $maxW*$colCount;
00863             for($a=0;$a<$imgCount;$a++)   {
00864                $imgKey = $a+$imgStart;
00865                $imgInfo = $gifCreator->getImageDimensions($imgPath.$imgs[$imgKey]);
00866                $relations[$a] = $imgInfo[1] / $equalHeight; // relationship between the original height and the wished height
00867                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.
00868                   $relations_cols[floor($a/$colCount)] += $imgInfo[0]/$relations[$a];  // counts the total width of the row with the new height taken into consideration.
00869                }
00870             }
00871          }
00872 
00873          $imageRowsFinalWidths = Array(); // contains the width of every image row
00874          $imageRowsMaxHeights = Array();
00875          $imgsTag=array();
00876          $origImages=array();
00877          for($a=0;$a<$imgCount;$a++)   {
00878             $GLOBALS['TSFE']->register['IMAGE_NUM'] = $a;
00879 
00880             $imgKey = $a+$imgStart;
00881             $totalImagePath = $imgPath.$imgs[$imgKey];
00882             $this->data[$this->currentValKey] = $totalImagePath;
00883             $imgObjNum = intval($splitArr[$a]['imgObjNum']);
00884             $imgConf = $conf[$imgObjNum.'.'];
00885 
00886             if ($equalHeight) {
00887                $scale = 1;
00888                if ($totalMaxW)   {
00889                   $rowTotalMaxW = $relations_cols[floor($a/$colCount)];
00890                   if ($rowTotalMaxW > $totalMaxW)  {
00891                      $scale = $rowTotalMaxW / $totalMaxW;
00892                   }
00893                }
00894                   // transfer info to the imageObject. Please note, that
00895                $imgConf['file.']['height'] = round($equalHeight/$scale);
00896 
00897                unset($imgConf['file.']['width']);
00898                unset($imgConf['file.']['maxW']);
00899                unset($imgConf['file.']['maxH']);
00900                unset($imgConf['file.']['minW']);
00901                unset($imgConf['file.']['minH']);
00902                unset($imgConf['file.']['width.']);
00903                unset($imgConf['file.']['maxW.']);
00904                unset($imgConf['file.']['maxH.']);
00905                unset($imgConf['file.']['minW.']);
00906                unset($imgConf['file.']['minH.']);
00907                $maxW = 0;  // setting this to zero, so that it doesn't disturb
00908             }
00909 
00910             if ($maxW) {
00911                if (count($colMaxW)) {
00912                   $imgConf['file.']['maxW'] = $colMaxW[($a%$colCount)];
00913                } else {
00914                   $imgConf['file.']['maxW'] = $maxW;
00915                }
00916             }
00917 
00918                // Image Object supplied:
00919             if (is_array($imgConf) || $imgConf['file']) {
00920                if ($this->image_effects[$image_effects]) {
00921                   $imgConf['file.']['params'].= ' '.$this->image_effects[$image_effects];
00922                }
00923                if ($image_frames)   {
00924                   if (is_array($conf['image_frames.'][$image_frames.'.'])) {
00925                      $imgConf['file.']['m.'] = $conf['image_frames.'][$image_frames.'.'];
00926                   }
00927                }
00928                if ($image_compression && $imgConf['file']!='GIFBUILDER')   {
00929                   if ($image_compression==1) {
00930                      $tempImport = $imgConf['file.']['import'];
00931                      $tempImport_dot = $imgConf['file.']['import.'];
00932                      unset($imgConf['file.']);
00933                      $imgConf['file.']['import'] = $tempImport;
00934                      $imgConf['file.']['import.'] = $tempImport_dot;
00935                   } elseif (isset($this->image_compression[$image_compression])) {
00936                      $imgConf['file.']['params'].= ' '.$this->image_compression[$image_compression]['params'];
00937                      $imgConf['file.']['ext'] = $this->image_compression[$image_compression]['ext'];
00938                      unset($imgConf['file.']['ext.']);
00939                   }
00940                }
00941 
00942                   // "alt", "title" and "longdesc" attributes:
00943                if (!strlen($imgConf['altText']) && !is_array($imgConf['altText.'])) {
00944                   $imgConf['altText'] = $conf['altText'];
00945                   $imgConf['altText.'] = $conf['altText.'];
00946                }
00947                if (!strlen($imgConf['titleText']) && !is_array($imgConf['titleText.'])) {
00948                   $imgConf['titleText'] = $conf['titleText'];
00949                   $imgConf['titleText.'] = $conf['titleText.'];
00950                }
00951                if (!strlen($imgConf['longdescURL']) && !is_array($imgConf['longdescURL.'])) {
00952                   $imgConf['longdescURL'] = $conf['longdescURL'];
00953                   $imgConf['longdescURL.'] = $conf['longdescURL.'];
00954                }
00955             } else {
00956                $imgConf = array(
00957                   'altText' => $conf['altText'],
00958                   'titleText' => $conf['titleText'],
00959                   'longdescURL' => $conf['longdescURL'],
00960                   'file' => $totalImagePath
00961                );
00962             }
00963 
00964             $imgsTag[$imgKey] = $this->IMAGE($imgConf);
00965 
00966                // Store the original filepath
00967             $origImages[$imgKey]=$GLOBALS['TSFE']->lastImageInfo;
00968 
00969             $imageRowsFinalWidths[floor($a/$colCount)] += $GLOBALS['TSFE']->lastImageInfo[0];
00970             if ($GLOBALS['TSFE']->lastImageInfo[1]>$imageRowsMaxHeights[floor($a/$colCount)])   {
00971                $imageRowsMaxHeights[floor($a/$colCount)] = $GLOBALS['TSFE']->lastImageInfo[1];
00972             }
00973          }
00974             // calculating the tableWidth:
00975             // TableWidth problems: It creates problems if the pictures are NOT as wide as the tableWidth.
00976          $tableWidth = max($imageRowsFinalWidths)+ $colspacing*($colCount-1) + $colCount*$border*$borderThickness*2;
00977 
00978             // make table for pictures
00979          $index=$imgStart;
00980 
00981          $noRows = $this->stdWrap($conf['noRows'],$conf['noRows.']);
00982          $noCols = $this->stdWrap($conf['noCols'],$conf['noCols.']);
00983          if ($noRows) {$noCols=0;}  // noRows overrides noCols. They cannot exist at the same time.
00984          if ($equalHeight) {
00985             $noCols=1;
00986             $noRows=0;
00987          }
00988 
00989          $rowCount_temp=1;
00990          $colCount_temp=$colCount;
00991          if ($noRows)   {
00992             $rowCount_temp = $rowCount;
00993             $rowCount=1;
00994          }
00995          if ($noCols)   {
00996             $colCount=1;
00997          }
00998             // col- and rowspans calculated
00999          $colspan = (($colspacing) ? $colCount*2-1 : $colCount);
01000          $rowspan = (($rowspacing) ? $rowCount*2-1 : $rowCount) + $cap;
01001 
01002 
01003             // Edit icons:
01004          $editIconsHTML = $conf['editIcons']&&$GLOBALS['TSFE']->beUserLogin ? $this->editIcons('',$conf['editIcons'],$conf['editIcons.']) : '';
01005 
01006             // strech out table:
01007          $tablecode='';
01008          $flag=0;
01009          if ($conf['noStretchAndMarginCells']!=1)  {
01010             $tablecode.='<tr>';
01011             if ($txtMarg && $align=='right') {  // If right aligned, the textborder is added on the right side
01012                $tablecode.='<td rowspan="'.($rowspan+1).'" valign="top"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$txtMarg.'" height="1" alt="" title="" />'.($editIconsHTML?'<br />'.$editIconsHTML:'').'</td>';
01013                $editIconsHTML='';
01014                $flag=1;
01015             }
01016             $tablecode.='<td colspan="'.$colspan.'"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$tableWidth.'" height="1" alt="" /></td>';
01017             if ($txtMarg && $align=='left')  {  // If left aligned, the textborder is added on the left side
01018                $tablecode.='<td rowspan="'.($rowspan+1).'" valign="top"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$txtMarg.'" height="1" alt="" title="" />'.($editIconsHTML?'<br />'.$editIconsHTML:'').'</td>';
01019                $editIconsHTML='';
01020                $flag=1;
01021             }
01022             if ($flag) $tableWidth+=$txtMarg+1;
01023    //       $tableWidth=0;
01024             $tablecode.='</tr>';
01025          }
01026 
01027             // draw table
01028          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!
01029             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.
01030                $tablecode.='<tr><td colspan="'.$colspan.'"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$rowspacing.'" border="0" alt="" title="" /></td></tr>';
01031             }
01032             $tablecode.='<tr>';  // starting row
01033             for ($b=0; $b<$colCount_temp; $b++) {  // Looping through the columns
01034                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.
01035                   if (!$noCols)  {
01036                      $tablecode.='<td><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$colspacing.'" height="1" border="0" alt="" title="" /></td>';
01037                   } else {
01038                      $colSpacer='<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.($border?$colspacing-6:$colspacing).'" height="'.($imageRowsMaxHeights[$c]+($border?$borderThickness*2:0)).'" border="0" align="'.($border?'left':'top').'" alt="" title="" />';
01039                      $colSpacer='<td valign="top">'.$colSpacer.'</td>'; // added 160301, needed for the new "noCols"-table...
01040                      $tablecode.=$colSpacer;
01041                   }
01042                }
01043                if (!$noCols || ($noCols && !$b))   {
01044                   $tablecode.='<td valign="top">'; // starting the cell. If "noCols" this cell will hold all images in the row, otherwise only a single image.
01045                   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.
01046                }
01047                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.
01048                   $imgIndex = $index+$a*$colCount_temp;
01049                   if ($imgsTag[$imgIndex])   {
01050                      if ($rowspacing && $noRows && $a) {    // Puts distance between the images IF "noRows" is set and this is the first iteration of the loop
01051                         $tablecode.= '<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$rowspacing.'" alt="" title="" /><br />';
01052                      }
01053 
01054                      $imageHTML = $imgsTag[$imgIndex].'<br />';
01055                      $Talign = (!trim($captionArray[$imgIndex]) && !$noRows && !$conf['netprintApplicationLink']) ? ' align="left"' : '';  // this is necessary if the tablerows are supposed to space properly together! "noRows" is excluded because else the images "layer" together.
01056                      if ($border)   {$imageHTML='<table border="0" cellpadding="'.$borderThickness.'" cellspacing="0" bgcolor="'.$borderColor.'"'.$Talign.'><tr><td>'.$imageHTML.'</td></tr></table>';}     // break-tag added 160301  , ($noRows?'':' align="left"')  removed 160301, break tag removed 160301 (later...)
01057                      $imageHTML.=$editIconsHTML;      $editIconsHTML='';
01058                      if ($conf['netprintApplicationLink'])  {$imageHTML = $this->netprintApplication_offsiteLinkWrap($imageHTML,$origImages[$imgIndex],$conf['netprintApplicationLink.']);}
01059                      $imageHTML.=$captionArray[$imgIndex];  // Adds caption.
01060                      if ($noCols)   {$imageHTML='<td valign="top">'.$imageHTML.'</td>';}     // If noCols, put in table cell.
01061                      $tablecode.=$imageHTML;
01062                   }
01063                }
01064                $index++;
01065                if (!$noCols || ($noCols && $b+1==$colCount_temp)) {
01066                   if ($noCols)   {$tablecode.='</tr></table>';}   // In case of "noCols" we must finish the table that surrounds the images in the row.
01067                   $tablecode.='</td>'; // Ending the cell. In case of "noCols" the cell holds all pictures!
01068                }
01069             }
01070             $tablecode.='</tr>'; // ending row
01071          }
01072          if ($c)  {
01073             // Table-tag is inserted
01074             $i=$contentPosition;
01075             $table_align = (($i==16) ? 'align="'.$align.'"' : '');
01076             $tablecode = '<table'.($tableWidth?' width="'.$tableWidth.'"':'').' border="0" cellspacing="0" cellpadding="0" '.$table_align.' class="imgtext-table">'.$tablecode;
01077             if ($editIconsHTML)  {  // IF this value is not long since reset.
01078                $tablecode.='<tr><td colspan="'.$colspan.'">'.$editIconsHTML.'</td></tr>';
01079                $editIconsHTML='';
01080             }
01081             if ($cap)   {
01082                $tablecode.='<tr><td colspan="'.$colspan.'" align="'.$caption_align.'">'.$caption.'</td></tr>';
01083             }
01084             $tablecode.='</table>';
01085             if ($conf['tableStdWrap.'])   {$tablecode=$this->stdWrap($tablecode,$conf['tableStdWrap.']);}
01086          }
01087 
01088          $spaceBelowAbove = intval($this->stdWrap($conf['spaceBelowAbove'],$conf['spaceBelowAbove.']));
01089          switch ($contentPosition)  {
01090             case '0':   // above
01091                $output= '<div align="'.$align.'">'.$tablecode.'</div>'.$this->wrapSpace($content, $spaceBelowAbove.'|0');
01092             break;
01093             case '8':   // below
01094                $output= $this->wrapSpace($content, '0|'.$spaceBelowAbove).'<div align="'.$align.'">'.$tablecode.'</div>';
01095             break;
01096             case '16':  // in text
01097                $output= $tablecode.$content;
01098             break;
01099             case '24':  // in text, no wrap
01100                $theResult = '';
01101                $theResult.= '<table border="0" cellspacing="0" cellpadding="0" class="imgtext-nowrap"><tr>';
01102                if ($align=='right') {
01103                   $theResult.= '<td valign="top">'.$content.'</td><td valign="top">'.$tablecode.'</td>';
01104                } else {
01105                   $theResult.= '<td valign="top">'.$tablecode.'</td><td valign="top">'.$content.'</td>';
01106                }
01107                $theResult.= '</tr></table>';
01108                $output= $theResult;
01109             break;
01110          }
01111       } else {
01112          $output= $content;
01113       }
01114 
01115       if ($conf['stdWrap.']) {
01116          $output = $this->stdWrap($output, $conf['stdWrap.']);
01117       }
01118 
01119       return $output;
01120    }
01121 
01129    function CONTENT($conf) {
01130       $theValue='';
01131 
01132       $originalRec = $GLOBALS['TSFE']->currentRecord;
01133       if ($originalRec) {     // If the currentRecord is set, we register, that this record has invoked this function. It's should not be allowed to do this again then!!
01134          $GLOBALS['TSFE']->recordRegister[$originalRec]++;
01135       }
01136 
01137       if ($conf['table']=='pages' || substr($conf['table'],0,3)=='tt_' || substr($conf['table'],0,3)=='fe_' || substr($conf['table'],0,3)=='tx_' || substr($conf['table'],0,4)=='ttx_' || substr($conf['table'],0,5)=='user_')   {
01138 
01139          $renderObjName = $conf['renderObj'] ? $conf['renderObj'] : '<'.$conf['table'];
01140          $renderObjKey = $conf['renderObj'] ? 'renderObj' : '';
01141          $renderObjConf = $conf['renderObj.'];
01142 
01143          $res = $this->exec_getQuery($conf['table'],$conf['select.']);
01144          if ($error = $GLOBALS['TYPO3_DB']->sql_error()) {
01145             $GLOBALS['TT']->setTSlogMessage($error,3);
01146          } else {
01147             $this->currentRecordTotal = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
01148             $GLOBALS['TT']->setTSlogMessage('NUMROWS: '.$GLOBALS['TYPO3_DB']->sql_num_rows($res));
01149             $cObj =t3lib_div::makeInstance('tslib_cObj');
01150             $cObj->setParent($this->data,$this->currentRecord);
01151             $this->currentRecordNumber=0;
01152             while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))  {
01153 
01154                   // Versioning preview:
01155                $GLOBALS['TSFE']->sys_page->versionOL($conf['table'],$row);
01156 
01157                   // Language Overlay:
01158                if ($GLOBALS['TSFE']->sys_language_contentOL)   {
01159                   $row = $GLOBALS['TSFE']->sys_page->getRecordOverlay($conf['table'],$row,$GLOBALS['TSFE']->sys_language_content,$GLOBALS['TSFE']->sys_language_contentOL);
01160                }
01161 
01162                if (is_array($row))  {  // Might be unset in the sys_language_contentOL
01163                   if (!$GLOBALS['TSFE']->recordRegister[$conf['table'].':'.$row['uid']])  {
01164                      $this->currentRecordNumber++;
01165                      $cObj->parentRecordNumber = $this->currentRecordNumber;
01166                      $GLOBALS['TSFE']->currentRecord = $conf['table'].':'.$row['uid'];
01167                      $this->lastChanged($row['tstamp']);
01168                      $cObj->start($row,$conf['table']);
01169                      if ($GLOBALS['TSFE']->config['config']['insertDmailerBoundaries'])   { $theValue.='<!--DMAILER_SECTION_BOUNDARY_'.intval($row['module_sys_dmail_category']).'-->'; }
01170                      $theValue.= $cObj->cObjGetSingle($renderObjName, $renderObjConf, $renderObjKey);
01171                   }# else debug($GLOBALS['TSFE']->recordRegister,'CONTENT');
01172                }
01173             }
01174             if ($GLOBALS['TSFE']->config['config']['insertDmailerBoundaries'])   { $theValue.='<!--DMAILER_SECTION_BOUNDARY_END-->'; }
01175          }
01176       }
01177 
01178       $theValue = $this->wrap($theValue,$conf['wrap']);
01179       if ($conf['stdWrap.']) $theValue = $this->stdWrap($theValue,$conf['stdWrap.']);
01180 
01181       $GLOBALS['TSFE']->currentRecord = $originalRec; // Restore
01182       return $theValue;
01183    }
01184 
01192    function RECORDS($conf) {
01193       $theValue='';
01194 
01195       $originalRec = $GLOBALS['TSFE']->currentRecord;
01196       if ($originalRec) {     // If the currentRecord is set, we register, that this record has invoked this function. It's should not be allowed to do this again then!!
01197          $GLOBALS['TSFE']->recordRegister[$originalRec]++;
01198       }
01199 
01200       $conf['source'] = $this->stdWrap($conf['source'],$conf['source.']);
01201       if ($conf['tables'] && $conf['source']) {
01202          $allowedTables = $conf['tables'];
01203          if (is_array($conf['conf.'])) {
01204             reset($conf['conf.']);
01205             while(list($k)=each($conf['conf.']))   {
01206                if (substr($k,-1)!='.')    $allowedTables.=','.$k;
01207             }
01208          }
01209 
01210          $loadDB = t3lib_div::makeInstance('FE_loadDBGroup');
01211          $loadDB->start($conf['source'], $allowedTables);
01212          reset($loadDB->tableArray);
01213          while(list($table,)=each($loadDB->tableArray))  {
01214             if (is_array($GLOBALS['TCA'][$table])) {
01215                $loadDB->additionalWhere[$table]=$this->enableFields($table);
01216             }
01217          }
01218          $loadDB->getFromDB();
01219 
01220          reset($loadDB->itemArray);
01221          $data = $loadDB->results;
01222 
01223          $cObj =t3lib_div::makeInstance('tslib_cObj');
01224          $cObj->setParent($this->data,$this->currentRecord);
01225          $this->currentRecordNumber=0;
01226          $this->currentRecordTotal = count($loadDB->itemArray);
01227          reset($loadDB->itemArray);
01228          while(list(,$val)=each($loadDB->itemArray))  {
01229             $row = $data[$val['table']][$val['id']];
01230 
01231                // Versioning preview:
01232             $GLOBALS['TSFE']->sys_page->versionOL($val['table'],$row);
01233 
01234                // Language Overlay:
01235             if ($GLOBALS['TSFE']->sys_language_contentOL)   {
01236                $row = $GLOBALS['TSFE']->sys_page->getRecordOverlay($val['table'],$row,$GLOBALS['TSFE']->sys_language_content,$GLOBALS['TSFE']->sys_language_contentOL);
01237             }
01238 
01239             if (is_array($row))  {  // Might be unset in the content overlay things...
01240                if (!$conf['dontCheckPid'])   {
01241                   $row = $this->checkPid($row['pid']) ? $row : '';
01242                }
01243                if ($row && !$GLOBALS['TSFE']->recordRegister[$val['table'].':'.$val['id']])  {
01244                   $renderObjName = $conf['conf.'][$val['table']] ? $conf['conf.'][$val['table']] : '<'.$val['table'];
01245                   $renderObjKey = $conf['conf.'][$val['table']] ? 'conf.'.$val['table'] : '';
01246                   $renderObjConf = $conf['conf.'][$val['table'].'.'];
01247                   $this->currentRecordNumber++;
01248                   $cObj->parentRecordNumber=$this->currentRecordNumber;
01249                   $GLOBALS['TSFE']->currentRecord = $val['table'].':'.$val['id'];
01250                   $this->lastChanged($row['tstamp']);
01251                   $cObj->start($row,$val['table']);
01252                   if ($GLOBALS['TSFE']->config['config']['insertDmailerBoundaries'])   {$theValue.='<!--DMAILER_SECTION_BOUNDARY_'.intval($row['module_sys_dmail_category']).'-->';}
01253                   $theValue.=$cObj->cObjGetSingle($renderObjName, $renderObjConf, $renderObjKey);
01254                   if ($GLOBALS['TSFE']->config['config']['insertDmailerBoundaries'])   {$theValue.='<!--DMAILER_SECTION_BOUNDARY_END-->';}
01255                }# else debug($GLOBALS['TSFE']->recordRegister,'RECORDS');
01256             }
01257          }
01258       }
01259       $GLOBALS['TSFE']->currentRecord = $originalRec; // Restore
01260       return $this->wrap($theValue,$conf['wrap']);
01261    }
01262 
01270    function HMENU($conf)   {
01271       $content='';
01272       if ($this->checkIf($conf['if.']))   {
01273          $cls = strtolower($conf[1]);
01274          if (t3lib_div::inList($GLOBALS['TSFE']->tmpl->menuclasses,$cls))  {
01275             if ($conf['special.']['value.']) {
01276                $conf['special.']['value']  = $this->stdWrap($conf['special.']['value'], $conf['special.']['value.']);
01277             }
01278             $GLOBALS['TSFE']->register['count_HMENU']++;
01279             $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ']=0;
01280             $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid']=array();
01281             $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMparentId']=array();
01282 
01283             $menu = t3lib_div::makeInstance('tslib_'.$cls);
01284             $menu->parent_cObj = $this;
01285             $menu->start($GLOBALS['TSFE']->tmpl, $GLOBALS['TSFE']->sys_page, '', $conf, 1);
01286             $menu->makeMenu();
01287             $content.=$menu->writeMenu();
01288          }
01289          if ($conf['wrap'])      $content=$this->wrap($content, $conf['wrap']);
01290          if ($conf['stdWrap.'])  $content = $this->stdWrap($content, $conf['stdWrap.']);
01291       }
01292       return $content;
01293    }
01294 
01302    function CTABLE ($conf) {
01303       $controlTable = t3lib_div::makeInstance('tslib_controlTable');
01304          if ($conf['tableParams'])  {
01305          $controlTable->tableParams = $conf['tableParams'];
01306       }
01307          // loads the pagecontent
01308       $controlTable->contentW = $conf['cWidth'];
01309          // loads the menues if any
01310       if (is_array($conf['c.'])) {
01311          $controlTable->content = $this->cObjGet($conf['c.'],'c.');
01312          $controlTable->contentTDparams = isset($conf['c.']['TDParams']) ? $conf['c.']['TDParams'] : 'valign="top"';
01313       }
01314       if (is_array($conf['lm.']))   {
01315          $controlTable->lm = $this->cObjGet($conf['lm.'],'lm.');
01316          $controlTable->lmTDparams = isset($conf['lm.']['TDParams']) ? $conf['lm.']['TDParams'] : 'valign="top"';
01317       }
01318       if (is_array($conf['tm.']))   {
01319          $controlTable->tm = $this->cObjGet($conf['tm.'],'tm.');
01320          $controlTable->tmTDparams = isset($conf['tm.']['TDParams']) ? $conf['tm.']['TDParams'] : 'valign="top"';
01321       }
01322       if (is_array($conf['rm.']))   {
01323          $controlTable->rm = $this->cObjGet($conf['rm.'],'rm.');
01324          $controlTable->rmTDparams = isset($conf['rm.']['TDParams']) ? $conf['rm.']['TDParams'] : 'valign="top"';
01325       }
01326       if (is_array($conf['bm.']))   {
01327          $controlTable->bm = $this->cObjGet($conf['bm.'],'bm.');
01328          $controlTable->bmTDparams = isset($conf['bm.']['TDParams']) ? $conf['bm.']['TDParams'] : 'valign="top"';
01329       }
01330       return $controlTable->start($conf['offset'],$conf['cMargins']);
01331    }
01332 
01340    function OTABLE ($conf) {
01341       $controlTable = t3lib_div::makeInstance('tslib_tableOffset');
01342       if ($conf['tableParams'])  {
01343          $controlTable->tableParams = $conf['tableParams'];
01344       }
01345       return $controlTable->start($this->cObjGet($conf),$conf['offset']);
01346    }
01347 
01355    function COLUMNS ($conf)   {
01356       $content='';
01357       if (is_array($conf) && $this->checkIf($conf['if.']))  {
01358          $tdRowCount=0;
01359          $tableParams = $conf['tableParams'] ? ' '.$conf['tableParams'] : ' border="0" cellspacing="0" cellpadding="0"';
01360          $TDparams = $conf['TDparams'] ? ' '.$conf['TDparams']:' valign="top"';
01361          $rows = t3lib_div::intInRange($conf['rows'],2,20);
01362          $totalWidth = intval($conf['totalWidth']);
01363          $columnWidth=0;
01364 
01365          $totalGapWidth=0;
01366          $gapData = Array(
01367             'gapWidth' => $this->stdWrap($conf['gapWidth'],$conf['gapWidth.']),
01368             'gapBgCol' => $this->stdWrap($conf['gapBgCol'],$conf['gapBgCol.']),
01369             'gapLineThickness' => $this->stdWrap($conf['gapLineThickness'],$conf['gapLineThickness.']),
01370             'gapLineCol' => $this->stdWrap($conf['gapLineCol'],$conf['gapLineCol.'])
01371          );
01372          $gapData = $GLOBALS['TSFE']->tmpl->splitConfArray($gapData,$rows-1);
01373          reset($gapData);
01374          while(list(,$val)=each($gapData))   {
01375             $totalGapWidth+=intval($val['gapWidth']);
01376          }
01377 
01378          if ($totalWidth)  {
01379             $columnWidth = ceil(($totalWidth-$totalGapWidth)/$rows);
01380             $TDparams.=' width="'.$columnWidth.'"';
01381             $tableParams.=' width="'.$totalWidth.'"';
01382          } else {
01383             $TDparams.=' width="'.floor(100/$rows).'%"';
01384             $tableParams.=' width="100%"';
01385          }
01386 
01387          for ($a=1;$a<=$rows;$a++)  {
01388             $tdRowCount++;
01389             $content.='<td'.$TDparams.'>';
01390             $content.=$this->cObjGetSingle($conf[$a],$conf[$a.'.'], $a);
01391             $content.='</td>';
01392             if ($a < $rows)   {
01393                $gapConf = $gapData[($a-1)];
01394                $gapWidth = intval($gapConf['gapWidth']);
01395                if ($gapWidth) {
01396                   $tdPar = $gapConf['gapBgCol'] ? ' bgcolor="'.$gapConf['gapBgCol'].'"' : '';
01397                   $gapLine = intval($gapConf['gapLineThickness']);
01398                   if ($gapLine)  {
01399                      $gapSurround = t3lib_div::intInRange(($gapWidth-$gapLine)/2, 1, 1000);
01400                         // right gap
01401                      $content.='<td'.$tdPar.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$gapSurround.'" height="1" alt="" title="" /></td>';
01402                      $tdRowCount++;
01403                         // line:
01404                      $GtdPar = $gapConf['gapLineCol'] ? ' bgcolor="'.$gapConf['gapLineCol'].'"' : ' bgcolor="black"';
01405                      $content.='<td'.$GtdPar.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$gapLine.'" height="1" alt="" title="" /></td>';
01406                      $tdRowCount++;
01407                         // left gap
01408                      $content.='<td'.$tdPar.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$gapSurround.'" height="1" alt="" title="" /></td>';
01409                      $tdRowCount++;
01410                   } else {
01411                      $content.='<td'.$tdPar.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$gapWidth.'" height="1" alt="" title="" /></td>';
01412                      $tdRowCount++;
01413                   }
01414                }
01415             }
01416          }
01417          $content='<tr>'.$content.'</tr>';
01418          $content='<table'.$tableParams.'>'.$content.'</table>';
01419          $content.=$this->cObjGetSingle($conf['after'],$conf['after.'], 'after');
01420          if ($conf['stdWrap.'])  {
01421             $content = $this->stdWrap($content,$conf['stdWrap.']);
01422          }
01423       }
01424       return $content;
01425    }
01426 
01434    function HRULER ($conf) {
01435       $lineThickness = t3lib_div::intInRange($this->stdWrap($conf['lineThickness'],$conf['lineThickness.']),1,50);
01436       $lineColor = $conf['lineColor'] ? $conf['lineColor'] : 'black';
01437       $spaceBefore = intval($conf['spaceLeft']);
01438       $spaceAfter = intval($conf['spaceRight']);
01439       $tableWidth = $conf['tableWidth'] ? $conf['tableWidth'] : '99%';
01440       $content='';
01441 
01442       $content.='<table border="0" cellspacing="0" cellpadding="0" width="'.htmlspecialchars($tableWidth).'"><tr>';
01443       if ($spaceBefore) {$content.='<td width="1"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$spaceBefore.'" height="1" alt="" title="" /></td>'; }
01444       $content.='<td bgcolor="'.$lineColor.'"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$lineThickness.'" alt="" title="" /></td>';
01445       if ($spaceAfter)  {$content.='<td width="1"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$spaceAfter.'" height="1" alt="" title="" /></td>'; }
01446       $content.='</tr></table>';
01447 
01448       $content = $this->stdWrap($content, $conf['stdWrap.']);
01449       return $content;
01450    }
01451 
01459    function CASEFUNC ($conf){
01460       $content='';
01461       if ($this->checkIf($conf['if.']))   {
01462          if ($conf['setCurrent'] || $conf['setCurrent.']){$this->data[$this->currentValKey] = $this->stdWrap($conf['setCurrent'], $conf['setCurrent.']);}
01463          $key = $this->stdWrap($conf['key'],$conf['key.']);
01464          $key = $conf[$key] ? $key : 'default';
01465          $name = $conf[$key];
01466          $theValue = $this->cObjGetSingle($name,$conf[$key.'.'], $key);
01467          if ($conf['stdWrap.'])  {
01468             $theValue = $this->stdWrap($theValue,$conf['stdWrap.']);
01469          }
01470          return $theValue;
01471       }
01472    }
01473 
01484    function LOAD_REGISTER($conf,$name) {
01485       if ($name=='RESTORE_REGISTER')   {
01486          $GLOBALS['TSFE']->register = array_pop($GLOBALS['TSFE']->registerStack);
01487       } else {
01488          array_push($GLOBALS['TSFE']->registerStack,$GLOBALS['TSFE']->register);
01489          if (is_array($conf)) {
01490             reset($conf);
01491             while(list($theKey,$theValue)=each($conf))   {
01492                if (!strstr($theKey,'.') || !isset($conf[substr($theKey,0,-1)]))  {     // Only if 1) the property is set but not the value itself, 2) the value and/or any property
01493                   if (strstr($theKey,'.'))   {
01494                      $theKey = substr($theKey,0,-1);
01495                   }
01496                   $GLOBALS['TSFE']->register[$theKey] = $this->stdWrap($conf[$theKey],$conf[$theKey.'.']);
01497                }
01498             }
01499          }
01500       }
01501       return '';
01502    }
01503 
01524    function FORM($conf,$formData='')    {
01525       $content='';
01526       if (is_array($formData))   {
01527          $dataArr = $formData;
01528       } else {
01529          $data=$this->stdWrap($conf['data'],$conf['data.']);
01530             // Clearing dataArr
01531          $dataArr=array();
01532             // Getting the original config
01533          if (trim($data))  {
01534             $data = ereg_replace(chr(10),'||',$data);
01535             $dataArr = explode('||',$data);
01536          }
01537             // Adding the new dataArray config form:
01538          if (is_array($conf['dataArray.'])) {   // dataArray is supplied
01539             $sKeyArray = t3lib_TStemplate::sortedKeyList($conf['dataArray.'], TRUE);
01540             foreach($sKeyArray as $theKey)   {
01541                $dAA = $conf['dataArray.'][$theKey.'.'];
01542                if (is_array($dAA))  {
01543                   $temp=array();
01544                   list($temp[0])= explode('|',$dAA['label.'] ? $this->stdWrap($dAA['label'],$dAA['label.']) : $dAA['label']);
01545                   list($temp[1])= explode('|',$dAA['type']);
01546                   if ($dAA['required'])   {$temp[1]='*'.$temp[1];}
01547                   list($temp[2])= explode('|',$dAA['value.'] ? $this->stdWrap($dAA['value'],$dAA['value.']) : $dAA['value']);
01548                      // If value Array is set, then implode those values.
01549                   if (is_array($dAA['valueArray.']))  {
01550                      reset($dAA['valueArray.']);
01551                      $temp_accum = array();
01552                      while(list($dAKey_vA,$dAA_vA)=each($dAA['valueArray.'])) {
01553                         if (is_array($dAA_vA) && !strcmp(intval($dAKey_vA).'.',$dAKey_vA))   {
01554                            $temp_vA=array();
01555                            list($temp_vA[0])= explode('=',$dAA_vA['label.'] ? $this->stdWrap($dAA_vA['label'],$dAA_vA['label.']) : $dAA_vA['label']);
01556                            if ($dAA_vA['selected'])   {$temp_vA[0]='*'.$temp_vA[0];}
01557                            list($temp_vA[1])= explode(',',$dAA_vA['value']);
01558                         }
01559                         $temp_accum[] = implode('=',$temp_vA);
01560                      }
01561                      $temp[2] = implode(',',$temp_accum);
01562                   }
01563                   list($temp[3])= explode('|',$dAA['specialEval.'] ? $this->stdWrap($dAA['specialEval'],$dAA['specialEval.']) : $dAA['specialEval']);
01564 
01565                      // adding the form entry to the dataArray
01566                   $dataArr[] = implode('|',$temp);
01567                }
01568             }
01569          }
01570       }
01571 
01572       $attachmentCounter = '';
01573       $hiddenfields = '';
01574       $fieldlist = Array();
01575       $propertyOverride = Array();
01576       $fieldname_hashArray = Array();
01577       $cc = 0;
01578 
01579       foreach($dataArr as $val)  {
01580 
01581          $cc++;
01582          $confData=Array();
01583          if (is_array($formData)) {
01584             $parts = $val;
01585             $val = 1;    // true...
01586          } else {
01587             $val = trim($val);
01588             $parts = explode('|',$val);
01589          }
01590          if ($val && strcspn($val,'#/')) {
01591                // label:
01592             $confData['label'] = trim($parts[0]);
01593                // field:
01594             $fParts = explode(',',$parts[1]);
01595             $fParts[0]=trim($fParts[0]);
01596             if (substr($fParts[0],0,1)=='*') {
01597                $confData['required']=1;
01598                $fParts[0] = substr($fParts[0],1);
01599             }
01600             $typeParts = explode('=',$fParts[0]);
01601             $confData['type'] = trim(strtolower(end($typeParts)));
01602             if (count($typeParts)==1)  {
01603                $confData['fieldname'] = substr(ereg_replace('[^a-zA-Z0-9_]','',str_replace(' ','_',trim($parts[0]))),0,30);
01604                if (strtolower(ereg_replace('[^[:alnum:]]','',$confData['fieldname']))=='email') {$confData['fieldname']='email';}
01605                   // Duplicate fieldnames resolved
01606                if (isset($fieldname_hashArray[md5($confData['fieldname'])]))  {
01607                   $confData['fieldname'].='_'.$cc;
01608                }
01609                $fieldname_hashArray[md5($confData['fieldname'])]=$confData['fieldname'];
01610                   // Attachment names...
01611                if ($confData['type']=='file')   {
01612                   $confData['fieldname']='attachment'.$attachmentCounter;
01613                   $attachmentCounter=intval($attachmentCounter)+1;
01614                }
01615             } else {
01616                $confData['fieldname'] = str_replace(' ','_',trim($typeParts[0]));
01617             }
01618             $fieldCode='';
01619 
01620             if ($conf['wrapFieldName'])   {
01621                $confData['fieldname'] = $this->wrap($confData['fieldname'],$conf['wrapFieldName']);
01622             }
01623 
01624                // Set field name as current:
01625             $this->setCurrentVal($confData['fieldname']);
01626 
01627                // Additional parameters
01628             if (trim($confData['type']))  {
01629                $addParams=trim($conf['params']);
01630                if (is_array($conf['params.']) && isset($conf['params.'][$confData['type']])) {
01631                   $addParams=trim($conf['params.'][$confData['type']]);
01632                }
01633                if (strcmp('',$addParams)) $addParams=' '.$addParams;
01634             } else $addParams='';
01635 
01636                // Accessibility: Set id = fieldname attribute:
01637             if ($conf['accessibility'])   {
01638                $elementIdAttribute = ' id="'.$confData['fieldname'].'"';
01639             } else {
01640                $elementIdAttribute = '';
01641             }
01642 
01643                // Create form field based on configuration/type:
01644             switch($confData['type'])  {
01645                case 'textarea':
01646                   $cols=trim($fParts[1]) ? intval($fParts[1]) : 20;
01647                   $compWidth = doubleval($conf['compensateFieldWidth'] ? $conf['compensateFieldWidth'] : $GLOBALS['TSFE']->compensateFieldWidth);
01648                   $compWidth = $compWidth ? $compWidth : 1;
01649                   $cols = t3lib_div::intInRange($cols*$compWidth, 1, 120);
01650 
01651                   $rows=trim($fParts[2]) ? t3lib_div::intInRange($fParts[2],1,30) : 5;
01652                   $wrap=trim($fParts[3]) ? ' wrap="'.trim($fParts[3]).'"' : ' wrap="virtual"';
01653                   $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], str_replace('\n',chr(10),trim($parts[2])));
01654                   $fieldCode=sprintf('<textarea name="%s"'.$elementIdAttribute.' cols="%s" rows="%s"%s'.$addParams.'>%s</textarea>',
01655                      $confData['fieldname'], $cols, $rows, $wrap, t3lib_div::formatForTextarea($default));
01656                break;
01657                case 'input':
01658                case 'password':
01659                   $size=trim($fParts[1]) ? intval($fParts[1]) : 20;
01660                   $compWidth = doubleval($conf['compensateFieldWidth'] ? $conf['compensateFieldWidth'] : $GLOBALS['TSFE']->compensateFieldWidth);
01661                   $compWidth = $compWidth ? $compWidth : 1;
01662                   $size = t3lib_div::intInRange($size*$compWidth, 1, 120);
01663                   $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], trim($parts[2]));
01664 
01665                   if ($confData['type']=='password')  {
01666                      $default='';
01667                   }
01668 
01669                   $max=trim($fParts[2]) ? ' maxlength="'.t3lib_div::intInRange($fParts[2],1,1000).'"' : "";
01670                   $theType = $confData['type']=='input' ? 'text' : 'password';
01671 
01672                   $fieldCode=sprintf('<input type="'.$theType.'" name="%s"'.$elementIdAttribute.' size="%s"%s value="%s"'.$addParams.' />',
01673                      $confData['fieldname'], $size, $max, htmlspecialchars($default));
01674 
01675                break;
01676                case 'file':
01677                   $size=trim($fParts[1]) ? t3lib_div::intInRange($fParts[1],1,60) : 20;
01678                   $fieldCode=sprintf('<input type="file" name="%s"'.$elementIdAttribute.' size="%s"'.$addParams.' />',
01679                      $confData['fieldname'], $size);
01680                break;
01681                case 'check':
01682                      // alternative default value:
01683                   $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], trim($parts[2]));
01684                   $checked = $default ? ' checked="checked"' : '';
01685                   $fieldCode=sprintf('<input type="checkbox" value="%s" name="%s"'.$elementIdAttribute.'%s'.$addParams.' />',
01686                      1, $confData['fieldname'], $checked);
01687                break;
01688                case 'select':
01689                   $option='';
01690                   $valueParts = explode(',',$parts[2]);
01691                      // size
01692                   if (strtolower(trim($fParts[1]))=='auto') {$fParts[1]=count($valueParts);}    // Auto size set here. Max 20
01693                   $size=trim($fParts[1]) ? t3lib_div::intInRange($fParts[1],1,20) : 1;
01694                      // multiple
01695                   $multiple = strtolower(trim($fParts[2]))=='m' ? ' multiple="multiple"' : '';
01696 
01697                   $items=array();      // Where the items will be
01698                   $defaults=array(); //RTF
01699                   for($a=0;$a<count($valueParts);$a++)   {
01700                      $valueParts[$a]=trim($valueParts[$a]);
01701                      if (substr($valueParts[$a],0,1)=='*')  {  // Finding default value
01702                         $sel='selected';
01703                         $valueParts[$a] = substr($valueParts[$a],1);
01704                      } else $sel='';
01705                         // Get value/label
01706                      $subParts=explode('=',$valueParts[$a]);
01707                      $subParts[1] = (isset($subParts[1])?trim($subParts[1]):trim($subParts[0]));      // Sets the value
01708                      $items[] = $subParts;   // Adds the value/label pair to the items-array
01709                      if ($sel) {$defaults[]=$subParts[1];}  // Sets the default value if value/label pair is marked as default.
01710                   }
01711                      // alternative default value:
01712                   $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], $defaults);
01713                   if (!is_array($default)) {
01714                      $defaults=array();
01715                      $defaults[] = $default;
01716                   } else $defaults=$default;
01717                      // Create the select-box:
01718                   for($a=0;$a<count($items);$a++)  {
01719                      $option.='<option value="'.$items[$a][1].'"'.(in_array($items[$a][1],$defaults)?' selected="selected"':'').'>'.trim($items[$a][0]).'</option>'; //RTF
01720                   }
01721 
01722                   if ($multiple) $confData['fieldname'].='[]'; // The fieldname must be prepended '[]' if multiple select. And the reason why it's prepended is, because the required-field list later must also have [] prepended.
01723                   $fieldCode=sprintf('<select name="%s"'.$elementIdAttribute.' size="%s"%s'.$addParams.'>%s</select>',
01724                      $confData['fieldname'], $size, $multiple, $option); //RTF
01725                break;
01726                case 'radio':
01727                   $option='';
01728                   $valueParts = explode(',',$parts[2]);
01729                   $items=array();      // Where the items will be
01730                   $default='';
01731                   for($a=0;$a<count($valueParts);$a++)   {
01732                      $valueParts[$a]=trim($valueParts[$a]);
01733                      if (substr($valueParts[$a],0,1)=='*')  {
01734                         $sel='checked';
01735                         $valueParts[$a] = substr($valueParts[$a],1);
01736                      } else $sel='';
01737                         // Get value/label
01738                      $subParts=explode('=',$valueParts[$a]);
01739                      $subParts[1] = (isset($subParts[1])?trim($subParts[1]):trim($subParts[0]));      // Sets the value
01740                      $items[] = $subParts;   // Adds the value/label pair to the items-array
01741                      if ($sel) {$default=$subParts[1];}  // Sets the default value if value/label pair is marked as default.
01742                   }
01743                      // alternative default value:
01744                   $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], $default);
01745                      // Create the select-box:
01746                   for($a=0;$a<count($items);$a++)  {
01747                      $option.= '<input type="radio" name="'.$confData['fieldname'].'"'.$elementIdAttribute.' value="'.$items[$a][1].'"'.(!strcmp($items[$a][1],$default)?' checked="checked"':'').''.$addParams.' />';
01748                      $option.= $this->stdWrap(trim($items[$a][0]), $conf['radioWrap.']);
01749                      $option.= '<br />';
01750                   }
01751                   $fieldCode = $option;
01752                break;
01753                case 'hidden':
01754                   $value = trim($parts[2]);
01755                   if (strlen($value) && t3lib_div::inList('recipient_copy,recipient',$confData['fieldname']))  {
01756                      $value = $GLOBALS['TSFE']->codeString($value);
01757                   }
01758                   $hiddenfields.=sprintf('<input type="hidden" name="%s"'.$elementIdAttribute.' value="%s" />',
01759                      $confData['fieldname'], htmlspecialchars($value));
01760                break;
01761                case 'property':
01762                   if (t3lib_div::inList('type,locationData,goodMess,badMess,emailMess',$confData['fieldname']))   {
01763                      $value=trim($parts[2]);
01764                      $propertyOverride[$confData['fieldname']] = $value;
01765                      $conf[$confData['fieldname']] = $value;
01766                   }
01767                break;
01768                case 'submit':
01769                   $value=trim($parts[2]);
01770                   if ($conf['image.']) {
01771                      $this->data[$this->currentValKey]=$value;
01772                      $image=$this->IMAGE($conf['image.']);
01773                   } else $image='';
01774                   if($image)  {
01775                      $fieldCode = str_replace('<img','<input type="image"'.$addParams.' name="'.$confData['fieldname'].'"' ,$image);
01776                   } else {
01777                      $fieldCode=sprintf('<input type="submit" name="%s"'.$elementIdAttribute.' value="%s"'.$addParams.' />',
01778                         $confData['fieldname'], t3lib_div::deHSCentities(htmlspecialchars($value)));
01779                   }
01780                break;
01781                case 'label':
01782                   $fieldCode = nl2br(htmlspecialchars(trim($parts[2])));
01783                break;
01784                default:
01785                   $confData['type'] = 'comment';
01786                   $fieldCode = trim($parts[2]).'&nbsp;';
01787                break;
01788             }
01789             if ($fieldCode)   {
01790 
01791                   // Checking for special evaluation modes:
01792                if (t3lib_div::inList('textarea,input,password',$confData['type']) && strlen(trim($parts[3])))  {
01793                   $modeParameters = t3lib_div::trimExplode(':',$parts[3]);
01794                } else {
01795                   $modeParameters = array();
01796                }
01797 
01798                   // Adding evaluation based on settings:
01799                switch((string)$modeParameters[0])  {
01800                   case 'EREG':
01801                      $fieldlist[] = '_EREG';
01802                      $fieldlist[] = rawurlencode($modeParameters[1]);
01803                      $fieldlist[] = rawurlencode($modeParameters[2]);
01804                      $fieldlist[] = rawurlencode($confData['fieldname']);
01805                      $fieldlist[] = rawurlencode($confData['label']);
01806                      $confData['required'] = 1; // Setting this so "required" layout is used.
01807                   break;
01808                   case 'EMAIL':
01809                      $fieldlist[] = '_EMAIL';
01810                      $fieldlist[] = rawurlencode($confData['fieldname']);
01811                      $fieldlist[] = rawurlencode($confData['label']);
01812                      $confData['required'] = 1; // Setting this so "required" layout is used.
01813                   break;
01814                   default:
01815                      if ($confData['required'] && $confData['type']!='check') {
01816                         $fieldlist[] = rawurlencode($confData['fieldname']);
01817                         $fieldlist[] = rawurlencode($confData['label']);
01818                      }
01819                   break;
01820                }
01821 
01822                   // Field:
01823                $fieldLabel = $confData['label'];
01824                if ($conf['accessibility'])   {
01825                   $fieldLabel = '<label for="'.htmlspecialchars($confData['fieldname']).'">'.$fieldLabel.'</label>';
01826                }
01827 
01828                   // Getting template code:
01829                $fieldCode = $this->stdWrap($fieldCode, $conf['fieldWrap.']);
01830                $labelCode = $this->stdWrap($fieldLabel, $conf['labelWrap.']);
01831                $commentCode = $this->stdWrap($confData['label'], $conf['commentWrap.']); // RTF
01832                $result = $conf['layout'];
01833                if ($conf['REQ'] && $confData['required'])   {
01834                   if (is_array($conf['REQ.']['fieldWrap.']))
01835                      $fieldCode = $this->stdWrap($fieldCode, $conf['REQ.']['fieldWrap.']);
01836                   if (is_array($conf['REQ.']['labelWrap.']))
01837                      $labelCode = $this->stdWrap($fieldLabel, $conf['REQ.']['labelWrap.']);
01838                   if ($conf['REQ.']['layout'])  {
01839                      $result = $conf['REQ.']['layout'];
01840                   }
01841                }
01842                if ($confData['type']=='comment' && $conf['COMMENT.']['layout'])  {
01843                   $result = $conf['COMMENT.']['layout'];
01844                }
01845                if ($confData['type']=='check' && $conf['CHECK.']['layout'])   {
01846                   $result = $conf['CHECK.']['layout'];
01847                }
01848                if ($confData['type']=='radio' && $conf['RADIO.']['layout'])   {
01849                   $result = $conf['RADIO.']['layout'];
01850                }
01851                if ($confData['type']=='label' && $conf['LABEL.']['layout']) {
01852                   $result = $conf['LABEL.']['layout'];
01853                }
01854                $result = str_replace('###FIELD###',$fieldCode,$result);
01855                $result = str_replace('###LABEL###',$labelCode,$result);
01856                $result = str_replace('###COMMENT###',$commentCode,$result); //RTF
01857                $content.= $result;
01858             }
01859          }
01860       }
01861       if ($conf['stdWrap.']) $content=$this->stdWrap($content, $conf['stdWrap.']);
01862 
01863 
01864          // redirect (external: where to go afterwards. internal: where to submit to)
01865       $theRedirect = $this->stdWrap($conf['redirect'], $conf['redirect.']);         // redirect should be set to the page to redirect to after an external script has been used. If internal scripts is used, and if no 'type' is set that dictates otherwise, redirect is used as the url to jump to as long as it's an integer (page)
01866       $page = $GLOBALS['TSFE']->page;
01867       if (!$theRedirect)   {     // Internal: Just submit to current page
01868          $LD = $GLOBALS['TSFE']->tmpl->linkData($page, $conf['target'], $conf['no_cache'],'index.php', '', $this->getClosestMPvalueForPage($page['uid']));
01869       } elseif (t3lib_div::testInt($theRedirect))  {     // Internal: Submit to page with id $theRedirect
01870          $page = $GLOBALS['TSFE']->sys_page->getPage_noCheck($theRedirect);
01871          $LD = $GLOBALS['TSFE']->tmpl->linkData($page, $conf['target'], $conf['no_cache'],'index.php', '', $this->getClosestMPvalueForPage($page['uid']));
01872       } else { // External url, redirect-hidden field is rendered!
01873          $LD = $GLOBALS['TSFE']->tmpl->linkData($page, $conf['target'], $conf['no_cache'],'', '', $this->getClosestMPvalueForPage($page['uid']));
01874          $LD['totalURL'] = $theRedirect;
01875          $hiddenfields.= '<input type="hidden" name="redirect" value="'.htmlspecialchars($LD['totalURL']).'" />';    // 18-09-00 added
01876       }
01877 
01878          // Formtype (where to submit to!):
01879       $formtype = $propertyOverride['type'] ? $propertyOverride['type'] : $this->stdWrap($conf['type'], $conf['type.']);
01880       if (t3lib_div::testInt($formtype))  {  // Submit to a specific page
01881          $page = $GLOBALS['TSFE']->sys_page->getPage_noCheck($formtype);
01882          $LD_A = $GLOBALS['TSFE']->tmpl->linkData($page, $conf['target'], $conf['no_cache'], '', '', $this->getClosestMPvalueForPage($page['uid']));
01883          $action = $LD_A['totalURL'];
01884       } elseif ($formtype){      // Submit to external script
01885          $LD_A = $LD;
01886          $action = $formtype;
01887       } elseif (t3lib_div::testInt($theRedirect)) {
01888          $LD_A = $LD;
01889          $action = $LD_A['totalURL'];
01890       } else {    // Submit to 'nothing' - which is current page
01891          $LD_A = $GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page, $conf['target'], $conf['no_cache'], '', '', $this->getClosestMPvalueForPage($page['uid']));
01892          $action = $LD_A['totalURL'];
01893       }
01894 
01895          // Recipient:
01896       $theEmail = $this->stdWrap($conf['recipient'], $conf['recipient.']);
01897       if ($theEmail) {
01898          $theEmail = $GLOBALS['TSFE']->codeString($theEmail);
01899          $hiddenfields.='<input type="hidden" name="recipient" value="'.htmlspecialchars($theEmail).'" />';
01900       }
01901 
01902          // location data:
01903       if ($conf['locationData']) {
01904          if ($conf['locationData']=='HTTP_POST_VARS' && isset($_POST['locationData'])) {
01905             $locationData = t3lib_div::_POST('locationData');
01906          } else {
01907             $locationData = $GLOBALS['TSFE']->id.':'.$this->currentRecord; // locationData is [hte page id]:[tablename]:[uid of record]. Indicates on which page the record (from tablename with uid) is shown. Used to check access.
01908          }
01909          $hiddenfields.='<input type="hidden" name="locationData" value="'.htmlspecialchars($locationData).'" />';
01910       }
01911 
01912          // hidden fields:
01913       if (is_array($conf['hiddenFields.']))  {
01914          reset($conf['hiddenFields.']);
01915          while(list($hF_key,$hF_conf) = each($conf['hiddenFields.']))   {
01916             if (substr($hF_key,-1)!='.')  {
01917                $hF_value = $this->cObjGetSingle($hF_conf,$conf['hiddenFields.'][$hF_key.'.'],'hiddenfields');
01918                if (strlen($hF_value) && t3lib_div::inList('recipient_copy,recipient',$hF_key))  {
01919                   $hF_value = $GLOBALS['TSFE']->codeString($hF_value);
01920                }
01921                $hiddenfields.='<input type="hidden" name="'.$hF_key.'" value="'.htmlspecialchars($hF_value).'" />';
01922             }
01923          }
01924       }
01925 
01926          // Formname;
01927       $formname = $GLOBALS['TSFE']->uniqueHash();
01928       if ($conf['REQ']) {
01929          $validateForm=' onsubmit="return validateForm(\''.$formname.'\',\''.implode(',',$fieldlist).'\',\''.rawurlencode($conf['goodMess']).'\',\''.rawurlencode($conf['badMess']).'\',\''.rawurlencode($conf['emailMess']).'\')"';
01930          $GLOBALS['TSFE']->additionalHeaderData['JSFormValidate'] = '<script type="text/javascript" src="'.$GLOBALS['TSFE']->absRefPrefix.'t3lib/jsfunc.validateform.js"></script>';
01931       } else $validateForm='';
01932 
01933          // Create form tag:
01934       $theTarget = ($theRedirect?$LD['target']:$LD_A['target']);
01935       $content = Array(
01936          '<form'.
01937             ' action="'.htmlspecialchars($action).'"'.
01938             ' name="'.$formname.'"'.
01939             ' enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'"'.
01940             ' method="'.($conf['method']?$conf['method']:'post').'"'.
01941             ($theTarget ? ' target="'.$theTarget.'"' : '').
01942             $validateForm.
01943             '>',
01944          $hiddenfields.$content,
01945          '</form>'
01946       );
01947       if ($conf['arrayReturnMode']) {
01948          $content['validateForm']=$validateForm;
01949          $content['formname']=$formname;
01950          return $content;
01951       } else {
01952          return implode('',$content);
01953       }
01954    }
01955 
01963    function SEARCHRESULT($conf)  {
01964       if (t3lib_div::_GP('sword') && t3lib_div::_GP('scols'))  {
01965          $search = t3lib_div::makeInstance('tslib_search');
01966          $search->register_and_explode_search_string(t3lib_div::_GP('sword'));
01967          $search->register_tables_and_columns(t3lib_div::_GP('scols'),$conf['allowedCols']);
01968             // depth
01969          $depth=100;
01970             // the startId is found
01971          $theStartId=0;
01972          if (t3lib_div::testInt(t3lib_div::_GP('stype')))   {
01973             $temp_theStartId=t3lib_div::_GP('stype');
01974             $rootLine = $GLOBALS['TSFE']->sys_page->getRootLine($temp_theStartId);
01975                // The page MUST have a rootline with the Level0-page of the current site inside!!
01976             while(list(,$val)=each($rootLine))  {
01977                if($val['uid']==$GLOBALS['TSFE']->tmpl->rootLine[0]['uid']) {
01978                   $theStartId=$temp_theStartId;
01979                }
01980             }
01981          } else if (t3lib_div::_GP('stype')) {
01982             if (substr(t3lib_div::_GP('stype'),0,1)=='L')   {
01983                $pointer = intval(substr(t3lib_div::_GP('stype'),1));
01984                $theRootLine = $GLOBALS['TSFE']->tmpl->rootLine;
01985                   // location Data:
01986                $locDat_arr = explode(':',t3lib_div::_POST('locationData'));
01987                $pId = intval($locDat_arr[0]);
01988                if ($pId)   {
01989                   $altRootLine = $GLOBALS['TSFE']->sys_page->getRootLine($pId);
01990                   ksort($altRootLine);
01991                   if (count($altRootLine))   {
01992                         // check if the rootline has the real Level0 in it!!
01993                      reset($altRootLine);
01994                      $hitRoot=0;
01995                      $theNewRoot=array();
01996                      while(list(,$val)=each($altRootLine))  {
01997                         if($hitRoot || $val['uid']==$GLOBALS['TSFE']->tmpl->rootLine[0]['uid']) {
01998                            $hitRoot=1;
01999                            $theNewRoot[]=$val;
02000                         }
02001                      }
02002                      if ($hitRoot)  {
02003                         $theRootLine = $theNewRoot;      // Override the real rootline if any thing
02004                      }
02005                   }
02006                }
02007                $key = $this->getKey($pointer,$theRootLine);
02008                $theStartId = $theRootLine[$key]['uid'];
02009             }
02010          }
02011          if (!$theStartId) {
02012                // If not set, we use current page
02013             $theStartId = $GLOBALS['TSFE']->id;
02014          }
02015             // generate page-tree
02016          $search->pageIdList.= $this->getTreeList(-1*$theStartId,$depth);
02017 
02018          $endClause = 'pages.uid IN ('.$search->pageIdList.')
02019             AND pages.doktype in ('.$GLOBALS['TYPO3_CONF_VARS']['FE']['content_doktypes'].($conf['addExtUrlsAndShortCuts']?',3,4':'').')
02020             AND pages.no_search=0'.
02021             $this->enableFields($search->fTable).
02022             $this->enableFields('pages');
02023 
02024          if ($conf['languageField.'][$search->fTable])   {
02025             $endClause.= ' AND '.$search->fTable.'.'.$conf['languageField.'][$search->fTable].' = '.intval($GLOBALS['TSFE']->sys_language_uid); // (using sys_language_uid which is the ACTUAL language of the page. sys_language_content is only for selecting DISPLAY content!)
02026          }
02027 
02028             // build query
02029          $search->build_search_query($endClause);
02030 
02031             // count...
02032          if (t3lib_div::testInt(t3lib_div::_GP('scount')))  {
02033             $search->res_count = t3lib_div::_GP('scount');
02034          } else {
02035             $search->count_query();
02036          }
02037 
02038             // range
02039          $spointer = intval(t3lib_div::_GP('spointer'));
02040          if (isset($conf['range'])) {
02041             $theRange = intval($conf['range']);
02042          } else {
02043             $theRange = 20;
02044          }
02045 
02046             // Order By:
02047          if (!$conf['noOrderBy'])   {
02048             $search->queryParts['ORDERBY'] = 'pages.lastUpdated, pages.tstamp';
02049          }
02050 
02051          $search->queryParts['LIMIT'] = $spointer.','.$theRange;
02052 
02053             // search...
02054          $search->execute_query();
02055          if ($GLOBALS['TYPO3_DB']->sql_num_rows($search->result)) {
02056             $GLOBALS['TSFE']->register['SWORD_PARAMS'] = $search->get_searchwords();
02057 
02058             $total = $search->res_count;
02059             $rangeLow = t3lib_div::intInRange($spointer+1,1,$total);
02060             $rangeHigh = t3lib_div::intInRange($spointer+$theRange,1,$total);
02061                // prev/next url:
02062             $LD = $GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page,$conf['target'],1,'', '', $this->getClosestMPvalueForPage($GLOBALS['TSFE']->page['uid']));
02063             $targetPart = $LD['target'] ? ' target="'.htmlspecialchars($LD['target']).'"' : '';
02064             $urlParams = $this->URLqMark($LD['totalURL'],
02065                   '&sword='.rawurlencode(t3lib_div::_GP('sword')).
02066                   '&scols='.rawurlencode(t3lib_div::_GP('scols')).
02067                   '&stype='.rawurlencode(t3lib_div::_GP('stype')).
02068                   '&scount='.$total);
02069                // substitution:
02070             $result= $this->cObjGetSingle($conf['layout'],$conf['layout.'], 'layout');
02071             $result = str_replace('###RANGELOW###',$rangeLow,$result);
02072             $result = str_replace('###RANGEHIGH###',$rangeHigh,$result);
02073             $result = str_replace('###TOTAL###',$total,$result);
02074 
02075             if ($rangeHigh<$total)  {
02076                $next = $this->cObjGetSingle($conf['next'], $conf['next.'], 'next');
02077                $next = '<a href="'.htmlspecialchars($urlParams.'&spointer='.($spointer+$theRange)).'"'.$targetPart.$GLOBALS['TSFE']->ATagParams.'>'.$next.'</a>';
02078             } else $next='';
02079             $result = str_replace('###NEXT###',$next,$result);
02080 
02081             if ($rangeLow>1)  {
02082                $prev = $this->cObjGetSingle($conf['prev'], $conf['prev.'], 'prev');
02083                $prev = '<a href="'.htmlspecialchars($urlParams.'&spointer='.($spointer-$theRange)).'"'.$targetPart.$GLOBALS['TSFE']->ATagParams.'>'.$prev.'</a>';
02084             } else $prev='';
02085             $result = str_replace('###PREV###',$prev,$result);
02086 
02087                // searching result
02088             $theValue = $this->cObjGetSingle($conf['resultObj'], $conf['resultObj.'],'resultObj');
02089             $cObj = t3lib_div::makeInstance('tslib_cObj');
02090             $cObj->setParent($this->data,$this->currentRecord);
02091             $renderCode='';
02092             while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($search->result))   {
02093                $cObj->start($row);
02094                $renderCode.=$cObj->cObjGetSingle($conf['renderObj'], $conf['renderObj.'],'renderObj');
02095             }
02096             $theValue.=$this->wrap($renderCode,$conf['renderWrap']);
02097             $theValue = str_replace('###RESULT###',$theValue,$result);
02098          } else {
02099             $theValue = $this->cObjGetSingle($conf['noResultObj'], $conf['noResultObj.'],'noResultObj');
02100          }
02101 
02102          $GLOBALS['TT']->setTSlogMessage('Search in fields:   '.$search->listOfSearchFields);
02103 
02104             // wrapping
02105          $content=$theValue;
02106          if ($conf['wrap']) {
02107             $content=$this->wrap($content, $conf['wrap']);
02108          }
02109          if ($conf['stdWrap.']) {
02110             $content=$this->stdWrap($content, $conf['stdWrap.']);
02111          }
02112             // returning
02113          $GLOBALS['TSFE']->set_no_cache();
02114          return $content;
02115       }
02116    }
02117 
02128    function PHP_SCRIPT($conf,$ext='')  {
02129       $incFile = $GLOBALS['TSFE']->tmpl->getFileName($conf['file']);
02130       $content='';
02131       if ($incFile && $GLOBALS['TSFE']->checkFileInclude($incFile))  {
02132          switch($ext)   {
02133             case 'INT':
02134             case 'EXT':
02135                $substKey = $ext.'_SCRIPT.'.$GLOBALS['TSFE']->uniqueHash();
02136                $content.='<!--'.$substKey.'-->';
02137                $GLOBALS['TSFE']->config[$ext.'incScript'][$substKey] = array(
02138                   'file'=>$incFile,
02139                   'conf'=>$conf,
02140                   'type'=>'SCRIPT'
02141                );
02142                if ($ext=='INT')  {
02143                   $GLOBALS['TSFE']->config[$ext.'incScript'][$substKey]['cObj'] = serialize($this);
02144                } else {
02145                   $GLOBALS['TSFE']->config[$ext.'incScript'][$substKey]['data'] = $this->data;
02146                }
02147             break;
02148             default:
02149                   // Added 31-12-00: Make backup...
02150                $this->oldData = $this->data;
02151                   // Include file..
02152                include('./'.$incFile);
02153                   // Added 31-12-00: restore...
02154                if ($RESTORE_OLD_DATA)  {
02155                   $this->data = $this->oldData;
02156                }
02157             break;
02158          }
02159       }
02160       return $content;
02161    }
02162 
02171    function TEMPLATE($conf)   {
02172       $subparts = Array();
02173       $marks = Array();
02174       $wraps = Array();
02175       $content='';
02176 
02177       list($PRE,$POST) = explode('|',$conf['markerWrap'] ? $conf['markerWrap'] : '### | ###');
02178       $POST = trim($POST);
02179       $PRE  = trim($PRE);
02180 
02181          // Getting the content
02182       $content = $this->cObjGetSingle($conf['template'],$conf['template.'],'template');
02183       if ($conf['workOnSubpart'])   {
02184          $content = $this->getSubpart($content, $PRE.$conf['workOnSubpart'].$POST);
02185       }
02186 
02187          // Fixing all relative paths found:
02188       if ($conf['relPathPrefix'])   {
02189          $htmlParser = t3lib_div::makeInstance('t3lib_parsehtml');
02190          $content = $htmlParser->prefixResourcePath($conf['relPathPrefix'],$content,$conf['relPathPrefix.']);
02191       }
02192 
02193       if ($content)  {
02194          if ($conf['nonCachedSubst'])  {     // NON-CACHED:
02195                // Getting marks
02196             if (is_array($conf['marks.']))   {
02197                reset($conf['marks.']);
02198                while(list($theKey,$theValue)=each($conf['marks.']))  {
02199                   if (!strstr($theKey,'.'))  {
02200                      $content = str_replace(
02201                         $PRE.$theKey.$POST,
02202                         $this->cObjGetSingle($theValue,$conf['marks.'][$theKey.'.'],'marks.'.$theKey),
02203                         $content);
02204                   }
02205                }
02206             }
02207 
02208                // Getting subparts.
02209             if (is_array($conf['subparts.']))   {
02210                reset($conf['subparts.']);
02211                while(list($theKey,$theValue)=each($conf['subparts.']))  {
02212                   if (!strstr($theKey,'.'))  {
02213                      $subpart = $this->getSubpart($content, $PRE.$theKey.$POST);
02214                      if ($subpart)  {
02215                         $this->setCurrentVal($subpart);
02216                         $content = $this->substituteSubpart(
02217                            $content,
02218                            $PRE.$theKey.$POST,
02219                            $this->cObjGetSingle($theValue,$conf['subparts.'][$theKey.'.'],'subparts.'.$theKey),
02220                            1
02221                         );
02222                      }
02223                   }
02224                }
02225             }
02226                // Getting subpart wraps
02227             if (is_array($conf['wraps.']))   {
02228                reset($conf['wraps.']);
02229                while(list($theKey,$theValue)=each($conf['wraps.']))  {
02230                   if (!strstr($theKey,'.'))  {
02231                      $subpart = $this->getSubpart($content, $PRE.$theKey.$POST);
02232                      if ($subpart)  {
02233                         $this->setCurrentVal($subpart);
02234                         $content = $this->substituteSubpart(
02235                            $content,
02236                            $PRE.$theKey.$POST,
02237                            explode('|',$this->cObjGetSingle($theValue,$conf['wraps.'][$theKey.'.'],'wraps.'.$theKey)),
02238                            1
02239                         );
02240                      }
02241                   }
02242                }
02243             }
02244          } else { // CACHED
02245                // Getting subparts.
02246             if (is_array($conf['subparts.']))   {
02247                reset($conf['subparts.']);
02248                while(list($theKey,$theValue)=each($conf['subparts.']))  {
02249                   if (!strstr($theKey,'.'))  {
02250                      $subpart = $this->getSubpart($content, $PRE.$theKey.$POST);
02251                      if ($subpart)  {
02252                         $GLOBALS['TSFE']->register['SUBPART_'.$theKey] = $subpart;
02253                         $subparts[$theKey]['name'] = $theValue;
02254                         $subparts[$theKey]['conf'] = $conf['subparts.'][$theKey.'.'];
02255                      }
02256                   }
02257                }
02258             }
02259                // Getting marks
02260             if (is_array($conf['marks.']))   {
02261                reset($conf['marks.']);
02262                while(list($theKey,$theValue)=each($conf['marks.']))  {
02263                   if (!strstr($theKey,'.'))  {
02264                      $marks[$theKey]['name'] = $theValue;
02265                      $marks[$theKey]['conf'] = $conf['marks.'][$theKey.'.'];
02266                   }
02267                }
02268             }
02269                // Getting subpart wraps
02270             if (is_array($conf['wraps.']))   {
02271                reset($conf['wraps.']);
02272                while(list($theKey,$theValue)=each($conf['wraps.']))  {
02273                   if (!strstr($theKey,'.'))  {
02274                      $wraps[$theKey]['name'] = $theValue;
02275                      $wraps[$theKey]['conf'] = $conf['wraps.'][$theKey.'.'];
02276                   }
02277                }
02278             }
02279                // Getting subparts
02280             $subpartArray =array();
02281             reset($subparts);
02282             while(list($theKey,$theValue)=each($subparts))  {
02283                   // Set current with the content of the subpart...
02284                $this->data[$this->currentValKey] = $GLOBALS['TSFE']->register['SUBPART_'.$theKey];
02285                   // Get subpart cObject and substitute it!
02286                $subpartArray[$PRE.$theKey.$POST] = $this->cObjGetSingle($theValue['name'],$theValue['conf'],'subparts.'.$theKey);
02287             }
02288             $this->data[$this->currentValKey] = '';   // Reset current to empty
02289 
02290                // Getting marks
02291             $markerArray =array();
02292             reset($marks);
02293             while(list($theKey,$theValue)=each($marks))  {
02294                $markerArray[$PRE.$theKey.$POST] = $this->cObjGetSingle($theValue['name'],$theValue['conf'],'marks.'.$theKey);
02295             }
02296                // Getting wraps
02297             $subpartWraps =array();
02298             reset($wraps);
02299             while(list($theKey,$theValue)=each($wraps))  {
02300                $subpartWraps[$PRE.$theKey.$POST] = explode('|',$this->cObjGetSingle($theValue['name'],$theValue['conf'],'wraps.'.$theKey));
02301             }
02302 
02303                // Substitution
02304             if ($conf['substMarksSeparately'])  {
02305                $content = $this->substituteMarkerArrayCached($content,array(),$subpartArray,$subpartWraps);
02306                $content = $this->substituteMarkerArray($content, $markerArray);
02307             } else {
02308                $content = $this->substituteMarkerArrayCached($content,$markerArray,$subpartArray,$subpartWraps);
02309             }
02310          }
02311       }
02312       return $content;
02313    }
02314 
02322    function MULTIMEDIA($conf) {
02323       $content='';
02324       $filename=$this->stdWrap($conf['file'],$conf['file.']);
02325       $incFile = $GLOBALS['TSFE']->tmpl->getFileName($filename);
02326       if ($incFile)  {
02327          $fileinfo = t3lib_div::split_fileref($incFile);
02328          if (t3lib_div::inList('txt,html,htm',$fileinfo['fileext'])) {
02329             $content = $GLOBALS['TSFE']->tmpl->fileContent($incFile);
02330          } else {
02331                // default params...
02332             $parArray=array();
02333                // src is added
02334             $parArray['src']='src="'.$GLOBALS['TSFE']->absRefPrefix.$incFile.'"';
02335             if (t3lib_div::inList('au,wav,mp3',$fileinfo['fileext']))   {
02336             }
02337             if (t3lib_div::inList('avi,mov,mpg,asf,wmv',$fileinfo['fileext']))   {
02338                $parArray['width'] = 'width="200"';
02339                $parArray['height'] = 'height="200"';
02340             }
02341             if (t3lib_div::inList('swf,swa,dcr',$fileinfo['fileext']))  {
02342                $parArray['quality'] = 'quality="high"';
02343             }
02344             if (t3lib_div::inList('class',$fileinfo['fileext']))  {
02345                $parArray['width'] = 'width="200"';
02346                $parArray['height'] = 'height="200"';
02347             }
02348 
02349                // fetching params
02350             $lines = explode(chr(10), $this->stdWrap($conf['params'],$conf['params.']));
02351             while(list(,$l)=each($lines)) {
02352                $parts = explode('=', $l);
02353                $parameter = strtolower(trim($parts[0]));
02354                $value = trim($parts[1]);
02355                if ((string)$value!='') {
02356                   $parArray[$parameter] = $parameter.'="'.htmlspecialchars($value).'"';
02357                } else {
02358                   unset($parArray[$parameter]);
02359                }
02360             }
02361             if ($fileinfo['fileext']=='class')  {
02362                unset($parArray['src']);
02363                $parArray['code'] = 'code="'.htmlspecialchars($fileinfo['file']).'"';
02364                $parArray['codebase'] = 'codebase="'.htmlspecialchars($fileinfo['path']).'"';
02365                $content='<applet '.implode(' ',$parArray).'></applet>';
02366             } else {
02367                $content='<embed '.implode(' ',$parArray).'></embed>';
02368             }
02369          }
02370       }
02371 
02372       if ($conf['stdWrap.']) {
02373          $content=$this->stdWrap($content, $conf['stdWrap.']);
02374       }
02375 
02376       return $content;
02377    }
02378 
02379 
02380 
02381 
02382 
02383 
02384 
02385 
02386 
02387 
02388 
02389 
02390 
02391 
02392 
02393 
02394 
02395    /************************************
02396     *
02397     * Various helper functions for content objects:
02398     *
02399     ************************************/
02400 
02411    function netprintApplication_offsiteLinkWrap($str,$imgConf,$conf) {
02412       if ($conf['url'] && @is_file($imgConf['origFile']))   {
02413          $thisUrl = $conf['thisUrl'] ? $conf['thisUrl'] : t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR');
02414          $origFile=$thisUrl.$imgConf['origFile'];
02415             // Original file dimensions:
02416          $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
02417          $gifCreator->init();
02418          $origDim = $gifCreator->getImageDimensions($imgConf['origFile']);
02419          if (!$conf['linkOnlyPixelsAbove'] || $origDim[0]*$origDim[1]>$conf['linkOnlyPixelsAbove'])   {
02420                // Set parameters
02421             $thumbFile=$thisUrl.$imgConf['3'].'|'.$imgConf[0].'x'.$imgConf[1].'|'.$origDim[0].'x'.$origDim[1].'|'.filesize($imgConf['origFile']).'|'.filemtime($imgConf['origFile']);
02422                // Set url:
02423             $url = $conf['url']
02424                .'&NP[offsite][1]='.rawurlencode($origFile)
02425                .'&NP[offsite_thumb][1]='.rawurlencode($thumbFile);
02426             $linkCObject = $this->cObjGetSingle($conf['cObject'],$conf['cObject.']);
02427             if ($linkCObject) {
02428                $ATagParams = trim($conf['ATagParams']) ? ' '.trim($conf['ATagParams']) : '';
02429                $linkCObject='<a href="'.htmlspecialchars($url).'"'.$ATagParams.'>'.$linkCObject.'</a>';
02430                $linkCObject=$this->stdWrap($linkCObject,$conf['outerStdWrap.']);
02431                if ($conf['before']) {
02432                   $str=$linkCObject.$str;
02433                } else {
02434                   $str=$str.$linkCObject;
02435                }
02436             }
02437          }
02438       }
02439       return $str;
02440    }
02441 
02452    function getFieldDefaultValue($noValueInsert, $fieldName, $defaultVal) {
02453       if (!$GLOBALS['TSFE']->no_cache || (!isset($_POST[$fieldName]) && !isset($_GET[$fieldName])) || $noValueInsert)   {
02454          return $defaultVal;
02455       } else {
02456          return t3lib_div::_GP($fieldName);
02457       }
02458    }
02459 
02470    function cImage($file,$conf) {
02471       $info = $this->getImgResource($file,$conf['file.']);
02472       $GLOBALS['TSFE']->lastImageInfo=$info;
02473       if (is_array($info)) {
02474          $info[3] = t3lib_div::png_to_gif_by_imagemagick($info[3]);
02475          $GLOBALS['TSFE']->imagesOnPage[]=$info[3];      // This array is used to collect the image-refs on the page...
02476 
02477          if (!strlen($conf['altText']) && !is_array($conf['altText.'])) {  // Backwards compatible:
02478             $conf['altText'] = $conf['alttext'];
02479             $conf['altText.'] = $conf['alttext.'];
02480          }
02481          $altParam = $this->getAltParam($conf);
02482 
02483          $theValue = '<img src="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.t3lib_div::rawUrlEncodeFP($info[3])).'" width="'.$info[0].'" height="'.$info[1].'"  border="'.intval($conf['border']).'"'.($conf['params']?' '.$conf['params']:'').($altParam).' />';
02484          if ($conf['linkWrap'])  {
02485             $theValue = $this->linkWrap($theValue,$conf['linkWrap']);
02486          } elseif ($conf['imageLinkWrap']) {
02487             $theValue = $this->imageLinkWrap($theValue,$info['origFile'],$conf['imageLinkWrap.']);
02488          }
02489          return $this->wrap($theValue,$conf['wrap']);
02490       }
02491    }
02492 
02503    function imageLinkWrap($string,$imageFile,$conf) {
02504       $a1='';
02505       $a2='';
02506       $content=$string;
02507       if ($this->stdWrap($conf['enable'],$conf['enable.'])) {
02508          $content=$this->typolink($string, $conf['typolink.']);
02509             // imageFileLink:
02510          if ($content==$string && @is_file($imageFile)) {
02511             $params = '';
02512             if ($conf['width']) {$params.='&width='.rawurlencode($conf['width']);}
02513             if ($conf['height']) {$params.='&height='.rawurlencode($conf['height']);}
02514             if ($conf['effects']) {$params.='&effects='.rawurlencode($conf['effects']);}
02515             if ($conf['sample']) {$params.='&sample=1';}
02516             if ($conf['alternativeTempPath']) {$params.='&alternativeTempPath='.rawurlencode($conf['alternativeTempPath']);}
02517 
02518             if ($conf['bodyTag']) {$params.='&bodyTag='.rawurlencode($conf['bodyTag']);}
02519             if ($conf['title']) {$params.='&title='.rawurlencode($conf['title']);}
02520             if ($conf['wrap']) {$params.='&wrap='.rawurlencode($conf['wrap']);}
02521 
02522             $md5_value = md5($imageFile.'|'.$conf['width'].'|'.$conf['height'].'|'.$conf['effects'].'|'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'].'|');
02523 
02524             $params.= '&md5='.$md5_value;
02525             $url = $GLOBALS['TSFE']->absRefPrefix.'showpic.php?file='.rawurlencode($imageFile).$params;
02526             if ($conf['JSwindow.']['altUrl'] || $conf['JSwindow.']['altUrl.'])   {
02527                $altUrl = $this->stdWrap($conf['JSwindow.']['altUrl'], $conf['JSwindow.']['altUrl.']);
02528                if ($altUrl)   {
02529                   $url=$altUrl;
02530                }
02531             }
02532 
02533             if ($conf['JSwindow'])  {
02534                $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
02535                $gifCreator->init();
02536                $gifCreator->mayScaleUp = 0;
02537                $dims = $gifCreator->getImageScale($gifCreator->getImageDimensions($imageFile),$conf['width'],$conf['height'],'');
02538                $offset = t3lib_div::intExplode(',',$conf['JSwindow.']['expand'].',');
02539 
02540                $a1='<a href="#" onclick="'.
02541                   htmlspecialchars('openPic(\''.$GLOBALS['TSFE']->baseUrlWrap($url).'\',\''.($conf['JSwindow.']['newWindow']?md5($url):'thePicture').'\',\'width='.($dims[0]+$offset[0]).',height='.($dims[1]+$offset[1]).',status=0,menubar=0\'); return false;').
02542                   '"'.$GLOBALS['TSFE']->ATagParams.'>';
02543                $a2='</a>';
02544                $GLOBALS['TSFE']->setJS('openPic');
02545             } else {
02546                $target = ' target="thePicture"';
02547                if (isset($conf['target'])) {
02548                   $target= $conf['target'] ? ' target="'.$conf['target'].'"' : '';
02549                }
02550                $a1='<a href="'.htmlspecialchars($url).'"'.$target.$GLOBALS['TSFE']->ATagParams.'>';
02551                $a2='</a>';
02552             }
02553             $content=$a1.$string.$a2;
02554          }
02555       }
02556 
02557       return $content;
02558    }
02559 
02568    function fileResource($fName, $addParams='alt="" title=""') {
02569       $incFile = $GLOBALS['TSFE']->tmpl->getFileName($fName);
02570       if ($incFile)  {
02571          $fileinfo = t3lib_div::split_fileref($incFile);
02572          if (t3lib_div::inList('jpg,gif,jpeg,png',$fileinfo['fileext']))   {
02573             $imgFile = $incFile;
02574             $imgInfo = @getImageSize($imgFile);
02575             return '<img src="'.$GLOBALS['TSFE']->absRefPrefix.$imgFile.'" width="'.$imgInfo[0].'" height="'.$imgInfo[1].'" border="0" '.$addParams.' />';
02576          } elseif (filesize($incFile)<1024*1024) {
02577             return $GLOBALS['TSFE']->tmpl->fileContent($incFile);
02578          }
02579       }
02580    }
02581 
02591    function lastChanged($tstamp) {
02592       $tstamp = intval($tstamp);
02593       if ($tstamp>intval($GLOBALS['TSFE']->register['SYS_LASTCHANGED']))   {
02594          $GLOBALS['TSFE']->register['SYS_LASTCHANGED'] = $tstamp;
02595       }
02596    }
02597 
02608    function linkWrap($content,$wrap)   {
02609       $wrapArr = explode('|', $wrap);
02610       if (ereg("\{([0-9]*)\}",$wrapArr[0],$reg))   {
02611          if ($uid = $GLOBALS['TSFE']->tmpl->rootLine[$reg[1]]['uid'])   {
02612             $wrapArr[0] = str_replace($reg[0],$uid,$wrapArr[0]);
02613          }
02614       }
02615       return trim($wrapArr[0]).$content.trim($wrapArr[1]);
02616    }
02617 
02626    function getAltParam($conf)   {
02627       $altText = trim($this->stdWrap($conf['altText'], $conf['altText.']));
02628       $titleText = trim($this->stdWrap($conf['titleText'],$conf['titleText.']));
02629       $longDesc = trim($this->stdWrap($conf['longdescURL'],$conf['longdescURL.']));
02630 
02631          // "alt":
02632       $altParam = ' alt="'.htmlspecialchars(strip_tags($altText)).'"';
02633 
02634          // "title":
02635       if ($titleText) {
02636          $altParam.= ' title="'.htmlspecialchars(strip_tags($titleText)).'"';
02637       } else {
02638          $altParam.= ' title="'.htmlspecialchars(strip_tags($altText)).'"';
02639       }
02640 
02641          // "longDesc" URL
02642       if ($longDesc) {
02643          $altParam.= ' longdesc="'.htmlspecialchars($longDesc).'"';
02644       }
02645 
02646       return $altParam;
02647    }
02648 
02649 
02650 
02651 
02652 
02653 
02654 
02655 
02656 
02657 
02658 
02659 
02660 
02661 
02662 
02663 
02664 
02665 
02666 
02667    /***********************************************
02668     *
02669     * HTML template processing functions
02670     *
02671     ***********************************************/
02672 
02683    function getSubpart($content, $marker) {
02684       if ($marker && strstr($content,$marker))  {
02685          $start = strpos($content, $marker)+strlen($marker);
02686          $stop = @strpos($content, $marker, $start+1);
02687          $sub = substr($content, $start, $stop-$start);
02688 
02689          $reg=Array();
02690          ereg('^[^<]*-->',$sub,$reg);
02691          $start+=strlen($reg[0]);
02692 
02693          $reg=Array();
02694          ereg('<!--[^>]*$',$sub,$reg);
02695          $stop-=strlen($reg[0]);
02696 
02697          return substr($content, $start, $stop-$start);
02698       }
02699    }
02700 
02712    function substituteSubpart($content,$marker,$subpartContent,$recursive=1)  {
02713       $start = strpos($content, $marker);
02714       $stop = @strpos($content, $marker, $start+1)+strlen($marker);
02715       if ($start && $stop>$start)   {
02716             // code before
02717          $before = substr($content, 0, $start);
02718          $reg=Array();
02719          ereg('<!--[^>]*$',$before,$reg);
02720          $start-=strlen($reg[0]);
02721          $before = substr($content, 0, $start);
02722             // code after
02723          $after = substr($content, $stop);
02724          $reg=Array();
02725          ereg('^[^<]*-->',$after,$reg);
02726          $stop+=strlen($reg[0]);
02727          $after = substr($content, $stop);
02728             // replace?
02729          if (is_array($subpartContent))   {
02730             $substContent=$subpartContent[0].$this->getSubpart($content,$marker).$subpartContent[1];
02731          } else {
02732             $substContent=$subpartContent;
02733          }
02734 
02735          if ($recursive && strpos($after, $marker))   {
02736             return $before.$substContent.$this->substituteSubpart($after,$marker,$subpartContent);
02737          } else {
02738             return $before.$substContent.$after;
02739          }
02740       } else {
02741          return $content;
02742       }
02743    }
02744 
02754    function substituteMarker($content,$marker,$markContent) {
02755       return str_replace($marker,$markContent,$content);
02756    }
02757 
02774    function substituteMarkerArrayCached($content,$markContentArray=array(),$subpartContentArray=array(),$wrappedSubpartContentArray=array()) {
02775       $GLOBALS['TT']->push('/substituteMarkerArray/');
02776 
02777          // If not arrays then set them
02778       if (!is_array($markContentArray))   $markContentArray=array(); // Plain markers
02779       if (!is_array($subpartContentArray))   $subpartContentArray=array(); // Subparts being directly substituted
02780       if (!is_array($wrappedSubpartContentArray))  $wrappedSubpartContentArray=array();   // Subparts being wrapped
02781          // Finding keys and check hash:
02782       $sPkeys = array_keys($subpartContentArray);
02783       $wPkeys = array_keys($wrappedSubpartContentArray);
02784       $aKeys = array_merge(array_keys($markContentArray),$sPkeys,$wPkeys);
02785       if (!count($aKeys))  {
02786          $GLOBALS['TT']->pull();
02787          return $content;
02788       }
02789       asort($aKeys);
02790       $storeKey = md5('substituteMarkerArrayCached_storeKey:'.serialize(array($content,$aKeys)));
02791       if ($this->substMarkerCache[$storeKey])   {
02792          $storeArr = $this->substMarkerCache[$storeKey];
02793          $GLOBALS['TT']->setTSlogMessage('Cached',0);
02794       } else {
02795          $storeArrDat = $GLOBALS['TSFE']->sys_page->getHash($storeKey,0);
02796          if (!isset($storeArrDat))  {
02797                // Initialize storeArr
02798             $storeArr=array();
02799 
02800                // Finding subparts and substituting them with the subpart as a marker
02801             reset($sPkeys);
02802             while(list(,$sPK)=each($sPkeys)) {
02803                $content =$this->substituteSubpart($content,$sPK,$sPK);
02804             }
02805 
02806                // Finding subparts and wrapping them with markers
02807             reset($wPkeys);
02808             while(list(,$wPK)=each($wPkeys)) {
02809                $content =$this->substituteSubpart($content,$wPK,array($wPK,$wPK));
02810             }
02811 
02812                // traverse keys and quote them for reg ex.
02813             reset($aKeys);
02814             while(list($tK,$tV)=each($aKeys))   {
02815                $aKeys[$tK]=quotemeta($tV);
02816             }
02817             $regex = implode('|',$aKeys);
02818                // Doing regex's
02819             $storeArr['c'] = split($regex,$content);
02820             preg_match_all('/'.$regex.'/',$content,$keyList);
02821             $storeArr['k']=$keyList[0];
02822                // Setting cache:
02823             $this->substMarkerCache[$storeKey] = $storeArr;
02824 
02825                // Storing the cached data:
02826             $GLOBALS['TSFE']->sys_page->storeHash($storeKey, serialize($storeArr), 'substMarkArrayCached');
02827 
02828             $GLOBALS['TT']->setTSlogMessage('Parsing',0);
02829          } else {
02830                // Unserializing
02831             $storeArr = unserialize($storeArrDat);
02832                // Setting cache:
02833             $this->substMarkerCache[$storeKey] = $storeArr;
02834             $GLOBALS['TT']->setTSlogMessage('Cached from DB',0);
02835          }
02836       }
02837 
02838          // Substitution/Merging:
02839          // Merging content types together, resetting
02840       $valueArr = array_merge($markContentArray,$subpartContentArray,$wrappedSubpartContentArray);
02841 
02842       $wSCA_reg=array();
02843       reset($storeArr['k']);
02844       $content = '';
02845          // traversin the keyList array and merging the static and dynamic content
02846       while(list($n,$keyN)=each($storeArr['k']))   {
02847          $content.=$storeArr['c'][$n];
02848          if (!is_array($valueArr[$keyN])) {
02849             $content.=$valueArr[$keyN];
02850          } else {
02851             $content.=$valueArr[$keyN][(intval($wSCA_reg[$keyN])%2)];
02852             $wSCA_reg[$keyN]++;
02853          }
02854       }
02855       $content.=$storeArr['c'][count($storeArr['k'])];
02856 
02857       $GLOBALS['TT']->pull();
02858       return $content;
02859    }
02860 
02872    function substituteMarkerArray($content,$markContentArray,$wrap='',$uppercase=0) {
02873       if (is_array($markContentArray)) {
02874          reset($markContentArray);
02875          $wrapArr=t3lib_div::trimExplode('|',$wrap);
02876          while(list($marker,$markContent)=each($markContentArray))   {
02877             if($uppercase) $marker=strtoupper($marker);
02878             if(strcmp($wrap,''))    $marker=$wrapArr[0].$marker.$wrapArr[1];
02879             $content=str_replace($marker,$markContent,$content);
02880          }
02881       }
02882       return $content;
02883    }
02884 
02893    function substituteMarkerInObject(&$tree, $markContentArray) {
02894       if (is_array ($tree))   {
02895          reset($tree);
02896          while(list($key,$value)=each($tree))   {
02897             $this->substituteMarkerInObject ($tree[$key], $markContentArray);
02898          }
02899       } else {
02900          $tree = $this->substituteMarkerArray($tree,$markContentArray);
02901       }
02902       return $tree;
02903    }
02904 
02916    function fillInMarkerArray($markContentArray, $row, $fieldList='', $nl2br=TRUE, $prefix='FIELD_', $HSC=FALSE)  {
02917       if ($fieldList)   {
02918          $fArr = t3lib_div::trimExplode(',',$fieldList,1);
02919          foreach($fArr as $field)   {
02920             $markContentArray['###'.$prefix.$field.'###'] = $nl2br?nl2br($row[$field]):$row[$field];
02921          }
02922       } else {
02923          if (is_array($row))  {
02924             foreach($row as $field => $value)   {
02925                if (!t3lib_div::testInt($field)) {
02926                   if ($HSC)   $value = htmlspecialchars($value);
02927                   $markContentArray['###'.$prefix.$field.'###'] = $nl2br ? nl2br($value) : $value;
02928                }
02929             }
02930          }
02931       }
02932 
02933       return $markContentArray;
02934    }
02935 
02936 
02937 
02938 
02939 
02940 
02941 
02942 
02943 
02944 
02945 
02946 
02947 
02948 
02949 
02950 
02951 
02952 
02953 
02954 
02955 
02956 
02957 
02958 
02959 
02960    /***********************************************
02961     *
02962     * "stdWrap" + sub functions
02963     *
02964     ***********************************************/
02965 
02966 
02979    function stdWrap($content,$conf) {
02980       if (is_array($conf)) {
02981 
02982             // Setting current value, if so
02983          if ($conf['setContentToCurrent']){$this->data[$this->currentValKey]=$content;}
02984          if ($conf['setCurrent'] || $conf['setCurrent.']){$this->data[$this->currentValKey] = $this->stdWrap($conf['setCurrent'], $conf['setCurrent.']);}
02985 
02986             // Getting data:
02987          if (isset($conf['lang.']) && $GLOBALS['TSFE']->config['config']['language'] && isset($conf['lang.'][$GLOBALS['TSFE']->config['config']['language']])) {
02988             $content = $conf['lang.'][$GLOBALS['TSFE']->config['config']['language']];
02989          }
02990          if ($conf['data']){$content=$this->getData($conf['data'], is_array($this->alternativeData)?$this->alternativeData:$this->data);}
02991             $this->alternativeData='';    // This must be unset directly after
02992          if ($conf['field']) {$content=$this->getFieldVal($conf['field']);}
02993          if ($conf['current']) {$content=$this->data[$this->currentValKey];}
02994          if ($conf['cObject']) {$content=$this->cObjGetSingle($conf['cObject'],$conf['cObject.'],'/stdWrap/.cObject');}
02995          if ($conf['numRows.']) {$content=$this->numRows($conf['numRows.']);}
02996          if ($conf['filelist'] || $conf['filelist.']) {$content=$this->filelist($this->stdWrap($conf['filelist'], $conf['filelist.']));}
02997          if ($conf['preUserFunc'])  {$content = $this->callUserFunction($conf['preUserFunc'], $conf['preUserFunc.'], $content);}
02998 
02999             // Overriding values, evaluating conditions
03000          if ($conf['override'] || $conf['override.']){
03001             $override = $this->stdWrap($conf['override'], $conf['override.']);
03002             if (trim($override)) {$content=$override;}
03003          }
03004          if (isset($conf['preIfEmptyListNum']) || isset($conf['preIfEmptyListNum.']['stdWrap.'])) {
03005             $preIfEmptyListNumber = isset($conf['preIfEmptyListNum.']['stdWrap.'])  ?  $this->stdWrap($conf['preIfEmptyListNum'], $conf['preIfEmptyListNum.']['stdWrap.'])  :  $conf['preIfEmptyListNum'];
03006             $content=$this->listNum($content,$preIfEmptyListNumber,$conf['preIfEmptyListNum.']['splitChar']);
03007          }
03008          if (!trim($content) && ($conf['ifEmpty'] || $conf['ifEmpty.'])){ $content = $this->stdWrap($conf['ifEmpty'], $conf['ifEmpty.']);}
03009 
03010 
03011             // values...
03012          if (isset($conf['listNum']) || isset($conf['listNum.']['stdWrap.'])) {
03013             $listNumber = isset($conf['listNum.']['stdWrap.'])  ?  $this->stdWrap($conf['listNum'], $conf['listNum.']['stdWrap.'])  :  $conf['listNum'];
03014             $content=$this->listNum($content,$listNumber,$conf['listNum.']['splitChar']);
03015          }
03016 
03017          if ($conf['trim']){$content=trim($content);}
03018          if (   ($conf['required'] && (string)$content=='') || ($conf['if.'] && !$this->checkIf($conf['if.'])) || ($conf['fieldRequired'] && !trim($this->data[$conf['fieldRequired']]))    ){
03019             $content = '';
03020          } else {
03021                // Perform data processing:
03022             if ($conf['csConv']) { $content=$GLOBALS['TSFE']->csConv($content,$conf['csConv']); }
03023             if ($conf['parseFunc.'] || $conf['parseFunc']) {$content=$this->parseFunc($content,$conf['parseFunc.'],$conf['parseFunc']);}
03024             if ($conf['HTMLparser'] && is_array($conf['HTMLparser.'])) {$content=$this->HTMLparser_TSbridge($content,$conf['HTMLparser.']);}
03025             if ($conf['split.']){$content=$this->splitObj($content,$conf['split.']);}
03026             if ($conf['prioriCalc']){$content=t3lib_div::calcParenthesis($content); if ($conf['prioriCalc']=='intval') $content=intval($content);}
03027             if ((string)$conf['char']!=''){$content=chr(intval($conf['char']));}
03028             if ($conf['intval']){$content=intval($content);}
03029             if ($conf['date']){$content=date($conf['date'], $content);}
03030             if ($conf['strftime']){
03031                $content = strftime($conf['strftime'], $content);
03032                $tmp_charset = $conf['strftime.']['charset'] ? $conf['strftime.']['charset'] : $GLOBALS['TSFE']->localeCharset;
03033                if ($tmp_charset) {
03034                   $content = $GLOBALS['TSFE']->csConv($content,$tmp_charset);
03035                }
03036             }
03037             if ($conf['age']){$content=$this->calcAge(time()-$content,$conf['age']);}
03038 
03039             if ($conf['case']){$content=$this->HTMLcaseshift($content, $conf['case']);}
03040             if ($conf['bytes']){$content=$this->bytes($content,$conf['bytes.']['labels']);}
03041             if ($conf['substring']){$content=$this->substring($content,$conf['substring']);}
03042             if ($conf['removeBadHTML'])   {$content = $this->removeBadHTML($content, $conf['removeBadHTML.']);}
03043             if ($conf['stripHtml']){$content = strip_tags($content);}
03044             if ($conf['crop']){$content=$this->crop($content, $conf['crop']);}
03045             if ($conf['rawUrlEncode']){$content = rawurlencode($content);}
03046             if ($conf['htmlSpecialChars']){
03047                $content=htmlSpecialChars($content);
03048                if ($conf['htmlSpecialChars.']['preserveEntities'])   $content = t3lib_div::deHSCentities($content);
03049             }
03050 
03051             if ($conf['doubleBrTag']) {
03052                $content=ereg_replace("\r?\n[\t ]*\r?\n",$conf['doubleBrTag'],$content);
03053             }
03054             if ($conf['br']) {$content=nl2br($content);}
03055             if ($conf['brTag']) {$content= ereg_replace(chr(10),$conf['brTag'],$content);}
03056             if ($conf['encapsLines.']) {$content=$this->encaps_lineSplit($content,$conf['encapsLines.']);}
03057             if ($conf['keywords']) {$content= $this->keywords($content);}
03058             if ($conf['innerWrap'] || $conf['innerWrap.']){$content=$this->wrap($content, $this->stdWrap($conf['innerWrap'], $conf['innerWrap.']));}
03059             if ($conf['innerWrap2'] || $conf['innerWrap2.']){$content=$this->wrap($content, $this->stdWrap($conf['innerWrap2'], $conf['innerWrap2.']));}
03060             if ($conf['fontTag']){$content=$this->wrap($content, $conf['fontTag']);}
03061             if ($conf['addParams.']) {$content=$this->addParams($content,$conf['addParams.']);}
03062             if ($conf['textStyle.']) {$content=$this->textStyle($content,$conf['textStyle.']);}
03063             if ($conf['tableStyle.']) {$content=$this->tableStyle($content,$conf['tableStyle.']);}
03064             if ($conf['filelink.']) {$content=$this->filelink($content,$conf['filelink.']);}
03065             if ($conf['preCObject']) {$content=$this->cObjGetSingle($conf['preCObject'],$conf['preCObject.'],'/stdWrap/.preCObject').$content;}
03066             if ($conf['postCObject']) {$content.=$this->cObjGetSingle($conf['postCObject'],$conf['postCObject.'],'/stdWrap/.postCObject');}
03067 
03068             if ($conf['wrapAlign'] || $conf['wrapAlign.']){
03069                $wrapAlign = trim($this->stdWrap($conf['wrapAlign'], $conf['wrapAlign.']));
03070                if ($wrapAlign)   {$content=$this->wrap($content, '<div align="'.$wrapAlign.'">|</div>');}
03071             }
03072             if ($conf['typolink.']){$content=$this->typolink($content, $conf['typolink.']);}
03073 
03074                // Spacing
03075             if ($conf['space']){$content=$this->wrapSpace($content, $conf['space']);}
03076             $spaceBefore = '';
03077             if ($conf['spaceBefore'] || $conf['spaceBefore.']) {$spaceBefore = trim($this->stdWrap($conf['spaceBefore'], $conf['spaceBefore.']));}
03078             $spaceAfter = '';
03079             if ($conf['spaceAfter'] || $conf['spaceAfter.'])   {$spaceAfter = trim($this->stdWrap($conf['spaceAfter'], $conf['spaceAfter.']));}
03080             if ($spaceBefore || $spaceAfter) {$content=$this->wrapSpace($content, $spaceBefore.'|'.$spaceAfter);}
03081 
03082                // Wraps
03083             if ($conf['wrap']){$content=$this->wrap($content, $conf['wrap'], ($conf['wrap.']['splitChar']?$conf['wrap.']['splitChar']:'|'));}
03084             if ($conf['noTrimWrap']){$content=$this->noTrimWrap($content, $conf['noTrimWrap']);}
03085             if ($conf['wrap2']){$content=$this->wrap($content, $conf['wrap2'], ($conf['wrap.']['splitChar']?$conf['wrap.']['splitChar']:'|'));}
03086             if ($conf['dataWrap']){$content=$this->dataWrap($content, $conf['dataWrap']);}
03087             if ($conf['prepend']){$content=$this->cObjGetSingle($conf['prepend'],$conf['prepend.'],'/stdWrap/.prepend').$content;}
03088             if ($conf['append']){$content.=$this->cObjGetSingle($conf['append'],$conf['append.'],'/stdWrap/.append');}
03089             if ($conf['wrap3']){$content=$this->wrap($content, $conf['wrap3'], ($conf['wrap.']['splitChar']?$conf['wrap.']['splitChar']:'|'));}
03090             if ($conf['outerWrap'] || $conf['outerWrap.']){$content=$this->wrap($content, $this->stdWrap($conf['outerWrap'], $conf['outerWrap.']));}
03091             if ($conf['insertData'])   {$content = $this->insertData($content);}
03092             if ($conf['offsetWrap']){
03093                $controlTable = t3lib_div::makeInstance('tslib_tableOffset');
03094                if ($conf['offsetWrap.']['tableParams'] || $conf['offsetWrap.']['tableParams.']) {$controlTable->tableParams = $this->stdWrap($conf['offsetWrap.']['tableParams'], $conf['offsetWrap.']['tableParams.']);}
03095                if ($conf['offsetWrap.']['tdParams'] || $conf['offsetWrap.']['tdParams.']) {$controlTable->tdParams = ' '.$this->stdWrap($conf['offsetWrap.']['tdParams'], $conf['offsetWrap.']['tdParams.']);}
03096                $content=$controlTable->start($content,$conf['offsetWrap']);
03097                if ($conf['offsetWrap.']['stdWrap.'])  {  $content=$this->stdWrap($content,$conf['offsetWrap.']['stdWrap.']);  }
03098             }
03099             if ($conf['postUserFunc']) {$content = $this->callUserFunction($conf['postUserFunc'], $conf['postUserFunc.'], $content);}
03100             if ($conf['postUserFuncInt']) {
03101                $substKey = 'INT_SCRIPT.'.$GLOBALS['TSFE']->uniqueHash();
03102                $GLOBALS['TSFE']->config['INTincScript'][$substKey] = array(
03103                   'content' => $content,
03104                   'postUserFunc' => $conf['postUserFuncInt'],
03105                   'conf' => $conf['postUserFuncInt.'],
03106                   'type' => 'POSTUSERFUNC',
03107                   'cObj' => serialize($this),
03108                );
03109                $content ='<!--'.$substKey.'-->';
03110             }
03111                // Various:
03112             if ($conf['prefixComment'] && !$GLOBALS['TSFE']->config['config']['disablePrefixComment'])   {$content = $this->prefixComment($conf['prefixComment'], $conf['prefixComment.'], $content);}
03113 
03114             if ($conf['editIcons'] && $GLOBALS['TSFE']->beUserLogin){$content=$this->editIcons($content,$conf['editIcons'],$conf['editIcons.']);}
03115             if ($conf['editPanel'] && $GLOBALS['TSFE']->beUserLogin){$content=$this->editPanel($content, $conf['editPanel.']);}
03116          }
03117 
03118             //Debug:
03119          if ($conf['debug'])  {$content = '<pre>'.htmlspecialchars($content).'</pre>';}
03120          if ($conf['debugFunc']) {debug($conf['debugFunc']==2?array($content):$content);}
03121          if ($conf['debugData']) {
03122             echo '<b>$cObj->data:</b>';
03123             debug($this->data,'$cObj->data:');
03124             if (is_array($this->alternativeData))  {
03125                echo '<b>$cObj->alternativeData:</b>';
03126                debug($this->alternativeData,'$this->alternativeData');
03127             }
03128          }
03129       }
03130       return $content;
03131    }
03132 
03144    function numRows($conf) {
03145       $conf['select.']['selectFields'] = 'count(*)';
03146 
03147       $res = $this->exec_getQuery($conf['table'],$conf['select.']);
03148 
03149       if ($error = $GLOBALS['TYPO3_DB']->sql_error()) {
03150          $GLOBALS['TT']->setTSlogMessage($error,3);
03151       } else {
03152          $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
03153          return intval($row[0]);
03154       }
03155    }
03156 
03165    function listNum($content,$listNum,$char) {
03166       $char = $char ? $char : ',';
03167       if (t3lib_div::testInt($char))   {
03168          $char = chr($char);
03169       }
03170       $temp = explode($char,$content);
03171       $last = ''.(count($temp)-1);
03172       $index=$this->calc(eregi_replace('last',$last,$listNum));
03173       return $temp[$index];
03174    }
03175 
03185    function checkIf($conf) {
03186       if (!is_array($conf))   {return true;}
03187       if (isset($conf['directReturn']))   {return $conf['directReturn'] ? 1 : 0;}
03188       $flag = true;
03189          if (isset($conf['isTrue']) || isset($conf['isTrue.']))   {
03190             $isTrue = trim($this->stdWrap($conf['isTrue'],$conf['isTrue.']));
03191             if (!$isTrue)  {
03192                $flag=0;
03193             }
03194          }
03195          if (isset($conf['isFalse']) || isset($conf['isFalse.'])) {
03196             $isFalse = trim($this->stdWrap($conf['isFalse'],$conf['isFalse.']));
03197             if ($isFalse)  {
03198                $flag=0;
03199             }
03200          }
03201          if (isset($conf['isPositive']) || isset($conf['isPositive.'])) {
03202             $number = $this->calc($this->stdWrap($conf['isPositive'],$conf['isPositive.']));
03203             if ($number<1) {
03204                $flag=0;
03205             }
03206          }
03207          if ($flag)  {
03208             $value = trim($this->stdWrap($conf['value'],$conf['value.']));
03209 
03210             if (isset($conf['isGreaterThan']) || isset($conf['isGreaterThan.'])) {
03211                $number = trim($this->stdWrap($conf['isGreaterThan'],$conf['isGreaterThan.']));
03212                if ($number<=$value) {
03213                   $flag=0;
03214                }
03215             }
03216             if (isset($conf['isLessThan']) || isset($conf['isLessThan.'])) {
03217                $number = trim($this->stdWrap($conf['isLessThan'],$conf['isLessThan.']));
03218                if ($number>=$value) {
03219                   $flag=0;
03220                }
03221             }
03222             if (isset($conf['equals']) || isset($conf['equals.']))   {
03223                $number = trim($this->stdWrap($conf['equals'],$conf['equals.']));
03224                if ($number!=$value) {
03225                   $flag=0;
03226                }
03227             }
03228             if (isset($conf['isInList']) || isset($conf['isInList.']))  {
03229                $number = trim($this->stdWrap($conf['isInList'],$conf['isInList.']));
03230                if (!t3lib_div::inList($value,$number))   {
03231                   $flag=0;
03232                }
03233             }
03234          }
03235       if ($conf['negate']) {$flag = $flag ? 0 : 1;}
03236       return $flag;
03237    }
03238 
03248    function filelist($data)   {
03249       $data = trim($data);
03250       if ($data)  {
03251          $data_arr = explode('|',$data);
03252             // read directory:
03253          if ($GLOBALS['TSFE']->lockFilePath) {     // MUST exist!
03254             $path = $this->clean_directory($data_arr[0]);   // Cleaning name..., only relative paths accepted.
03255             $path = substr($path,0,strlen($GLOBALS['TSFE']->lockFilePath))==$GLOBALS['TSFE']->lockFilePath ? $path : '';
03256          }
03257          if ($path)  {
03258             $items = Array('files'=>array(), 'sorting'=>array());
03259             $ext_list = strtolower(t3lib_div::uniqueList($data_arr[1]));
03260             $sorting = trim($data_arr[2]);
03261                // read dir:
03262             $d = @dir($path);
03263             $tempArray=Array();
03264             if (is_object($d))   {
03265                $count=0;
03266                while($entry=$d->read()) {
03267                   if ($entry!='.' && $entry!='..') {
03268                      $wholePath = $path.'/'.$entry;      // Because of odd PHP-error where  <br />-tag is sometimes placed after a filename!!
03269                      if (@file_exists($wholePath) && filetype($wholePath)=='file')  {
03270                         $info = t3lib_div::split_fileref($wholePath);
03271                         if (!$ext_list || t3lib_div::inList($ext_list,$info['fileext']))  {
03272                            $items['files'][] = $info['file'];
03273                            switch($sorting)  {
03274                               case 'name':
03275                                  $items['sorting'][] = strtolower($info['file']);
03276                               break;
03277                               case 'size':
03278                                  $items['sorting'][] = filesize($wholePath);
03279                               break;
03280                               case 'ext':
03281                                  $items['sorting'][] = $info['fileext'];
03282                               break;
03283                               case 'date':
03284                                  $items['sorting'][] = filectime($wholePath);
03285                               break;
03286                               default:
03287                                  $items['sorting'][] = $count;
03288                               break;
03289                            }
03290                            $count++;
03291                         }
03292                      }
03293                   }
03294                }
03295                $d->close();
03296             }
03297                // Sort if required
03298             if (count($items['sorting'])) {
03299                if (strtolower(trim($data_arr[3]))!='r')  {
03300                   asort($items['sorting']);
03301                } else {
03302                   arsort($items['sorting']);
03303                }
03304             }
03305             if (count($items['files']))   {
03306                   // make list
03307                reset($items['sorting']);
03308                $fullPath = trim($data_arr[4]);
03309                $list_arr=Array();
03310                while(list($key,)=each($items['sorting']))   {
03311                   $list_arr[]=  $fullPath ? $path.'/'.$items['files'][$key] : $items['files'][$key];
03312                }
03313                return implode(',',$list_arr);
03314             }
03315          }
03316       }
03317    }
03318 
03327    function clean_directory($theDir)   {
03328       if (t3lib_div::validPathStr($theDir))  {     // proceeds if no '//', '..' or '\' is in the $theFile
03329          $theDir = ereg_replace("[\/\. ]*$",'',$theDir);    // Removes all dots, slashes and spaces after a path...
03330          if (!t3lib_div::isAbsPath($theDir) && @is_dir($theDir))  {
03331             return $theDir;
03332          }
03333       }
03334    }
03335 
03345    function HTMLparser_TSbridge($theValue, $conf)  {
03346       $htmlParser = t3lib_div::makeInstance('t3lib_parsehtml');
03347       $htmlParserCfg =  $htmlParser->HTMLparserConfig($conf);
03348       return $htmlParser->HTMLcleaner($theValue,$htmlParserCfg[0],$htmlParserCfg[1],$htmlParserCfg[2],$htmlParserCfg[3]);
03349    }
03350 
03359    function dataWrap($content,$wrap)   {
03360       return $this->wrap($content,$this->insertData($wrap));
03361    }
03362 
03372    function insertData($str)  {
03373       $inside=0;
03374       $newVal='';
03375       $pointer=0;
03376       $totalLen = strlen($str);
03377       do {
03378          if (!$inside)  {
03379             $len = strcspn(substr($str,$pointer),'{');
03380             $newVal.= substr($str,$pointer,$len);
03381             $inside = 1;
03382          } else {
03383             $len = strcspn(substr($str,$pointer),'}')+1;
03384             $newVal.= $this->getData(substr($str,$pointer+1,$len-2),$this->data);
03385             $inside = 0;
03386          }
03387          $pointer+=$len;
03388       } while($pointer<$totalLen);
03389       return $newVal;
03390    }
03391 
03402    function prefixComment($str,$conf,$content)  {
03403       $parts = explode('|',$str);
03404 
03405       $output =
03406          chr(10).str_pad('',$parts[0],chr(9)).
03407          '<!-- '.htmlspecialchars($this->insertData($parts[1])).' [begin] -->'.
03408          chr(10).str_pad('',$parts[0]+1,chr(9)).
03409             $content.
03410          chr(10).str_pad('',$parts[0],chr(9)).
03411          '<!-- '.htmlspecialchars($this->insertData($parts[1])).' [end] -->'.
03412          chr(10).str_pad('',$parts[0]+1,chr(9));
03413 
03414       return $output;
03415    }
03416 
03426    function substring($content,$options)  {
03427       $options = t3lib_div::intExplode(',',$options.',');
03428       if ($options[1])  {
03429          return $GLOBALS['TSFE']->csConvObj->substr($GLOBALS['TSFE']->renderCharset,$content,$options[0],$options[1]);
03430       } else {
03431          return $GLOBALS['TSFE']->csConvObj->substr($GLOBALS['TSFE']->renderCharset,$content,$options[0]);
03432       }
03433    }
03434 
03444    function crop($content,$options) {
03445       $options = explode('|',$options);
03446       $chars = intval($options[0]);
03447       $afterstring = trim($options[1]);
03448       $crop2space = trim($options[2]);
03449       if ($chars) {
03450          if (strlen($content)>abs($chars))   {
03451             if ($chars<0)  {
03452                $content = $GLOBALS['TSFE']->csConvObj->substr($GLOBALS['TSFE']->renderCharset,$content,$chars);
03453                $trunc_at = strpos($content, ' ');
03454                $content = ($trunc_at&&$crop2space) ? $afterstring.substr($content,$trunc_at) : $afterstring.$content;
03455             } else {
03456                $content = $GLOBALS['TSFE']->csConvObj->substr($GLOBALS['TSFE']->renderCharset,$content,0,$chars);
03457                $trunc_at = strrpos($content, ' ');
03458                $content = ($trunc_at&&$crop2space) ? substr($content, 0, $trunc_at).$afterstring : $content.$afterstring;
03459             }
03460          }
03461       }
03462       return $content;
03463    }
03464 
03476    function removeBadHTML($text, $conf)   {
03477 
03478          // Copyright 2002-2003 Thomas Bley
03479       $text = preg_replace(
03480          array(
03481             "'<script[^>]*?>.*?</script[^>]*?>'si",
03482             "'<applet[^>]*?>.*?</applet[^>]*?>'si",
03483             "'<object[^>]*?>.*?</object[^>]*?>'si",
03484             "'<iframe[^>]*?>.*?</iframe[^>]*?>'si",
03485             "'<frameset[^>]*?>.*?</frameset[^>]*?>'si",
03486             "'<style[^>]*?>.*?</style[^>]*?>'si",
03487             "'<marquee[^>]*?>.*?</marquee[^>]*?>'si",
03488             "'<script[^>]*?>'si",
03489             "'<meta[^>]*?>'si",
03490             "'<base[^>]*?>'si",
03491             "'<applet[^>]*?>'si",
03492             "'<object[^>]*?>'si",
03493             "'<link[^>]*?>'si",
03494             "'<iframe[^>]*?>'si",
03495             "'<frame[^>]*?>'si",
03496             "'<frameset[^>]*?>'si",
03497             "'<input[^>]*?>'si",
03498             "'<form[^>]*?>'si",
03499             "'<embed[^>]*?>'si",
03500             "'background-image:url'si",
03501             "'<\w+.*?(onabort|onbeforeunload|onblur|onchange|onclick|ondblclick|ondragdrop|onerror|onfilterchange|onfocus|onhelp|onkeydown|onkeypress|onkeyup|onload|onmousedown|onmousemove|onmouseout|onmouseover|onmouseup|onmove|onreadystatechange|onreset|onresize|onscroll|onselect|onselectstart|onsubmit|onunload).*?>'si",
03502          ), '', $text);
03503 
03504          $text = eregi_replace('<a[^>]*href[[:space:]]*=[[:space:]]*["\']?[[:space:]]*javascript[^>]*','',$text);
03505 
03506          // Return clean content
03507       return $text;
03508    }
03509 
03520    function textStyle($theValue, $conf) {
03521       $conf['face.'][1] = 'Times New Roman';
03522       $conf['face.'][2] = 'Verdana,Arial,Helvetica,Sans serif';
03523       $conf['face.'][3] = 'Arial,Helvetica,Sans serif';
03524 
03525       $conf['size.'][1] = 1;
03526       $conf['size.'][2] = 2;
03527       $conf['size.'][3] = 3;
03528       $conf['size.'][4] = 4;
03529       $conf['size.'][5] = 5;
03530       $conf['size.'][10] = '+1';
03531       $conf['size.'][11] = '-1';
03532 
03533       $conf['color.'][240] = 'black';
03534       $conf['color.'][241] = 'white';
03535       $conf['color.'][242] = '#333333';
03536       $conf['color.'][243] = 'gray';
03537       $conf['color.'][244] = 'silver';
03538       $conf['color.'][245] = 'red';
03539       $conf['color.'][246] = 'navy';
03540       $conf['color.'][247] = 'yellow';
03541       $conf['color.'][248] = 'green';
03542       $conf['color.'][249] = 'olive';
03543       $conf['color.'][250] = 'maroon';
03544 
03545       $face = $this->data[$conf['face.']['field']];
03546       $size = $this->data[$conf['size.']['field']];
03547       $color = $this->data[$conf['color.']['field']];
03548       $align = $this->data[$conf['align.']['field']];
03549       $properties = $this->data[$conf['properties.']['field']];
03550       if (!$properties) {
03551          $properties=$this->stdWrap($conf['properties.']['default'],$conf['properties.']['default.']);
03552       }
03553 
03554          // properties
03555       if (($properties&8)) {$theValue=$this->HTMLcaseshift($theValue, 'upper');}
03556       if (($properties&1)) {$theValue='<b>'.$theValue.'</b>';}
03557       if (($properties&2)) {$theValue='<i>'.$theValue.'</i>';}
03558       if (($properties&4)) {$theValue='<u>'.$theValue.'</u>';}
03559 
03560          // Fonttag
03561       $theFace = $conf['face.'][$face] ? $conf['face.'][$face] : $this->stdWrap($conf['face.']['default'],$conf['face.']['default.']);
03562       $theSize = $conf['size.'][$size] ? $conf['size.'][$size] : $this->stdWrap($conf['size.']['default'],$conf['size.']['default.']);
03563       $theColor = $conf['color.'][$color] ? $conf['color.'][$color] : $this->stdWrap($conf['color.']['default'],$conf['color.']['default.']);
03564 
03565       if ($conf['altWrap'])   {
03566          $theValue=$this->wrap($theValue, $conf['altWrap']);
03567       } elseif ($theFace || $theSize || $theColor) {
03568          $fontWrap = '<font'.($theFace?' face="'.$theFace.'"':'').($theSize?' size="'.$theSize.'"':'').($theColor?' color="'.$theColor.'"':'').'>|</font>';
03569          $theValue=$this->wrap($theValue, $fontWrap);
03570       }
03571          // align
03572       if ($align) {$theValue=$this->wrap($theValue, '<div align="'.$align.'">|</div>');}
03573          // return
03574       return $theValue;
03575    }
03576 
03587    function tableStyle($theValue, $conf) {
03588       $conf['color.'][240] = 'black';
03589       $conf['color.'][241] = 'white';
03590       $conf['color.'][242] = '#333333';
03591       $conf['color.'][243] = 'gray';
03592       $conf['color.'][244] = 'silver';
03593 
03594       $align = $this->stdWrap($conf['align'],$conf['align.']);
03595       $border = intval($this->stdWrap($conf['border'],$conf['border.']));
03596       $cellspacing = intval($this->stdWrap($conf['cellspacing'],$conf['cellspacing.']));
03597       $cellpadding = intval($this->stdWrap($conf['cellpadding'],$conf['cellpadding.']));
03598 
03599       $color = $this->data[$conf['color.']['field']];
03600       $theColor = $conf['color.'][$color] ? $conf['color.'][$color] : $conf['color.']['default'];
03601          // Assembling the table tag
03602       $tableTagArray = Array('<table');
03603       $tableTagArray[]='border="'.$border.'"';
03604       $tableTagArray[]='cellspacing="'.$cellspacing.'"';
03605       $tableTagArray[]='cellpadding="'.$cellpadding.'"';
03606       if ($align) {$tableTagArray[]='align="'.$align.'"';}
03607       if ($theColor) {$tableTagArray[]='bgcolor="'.$theColor.'"';}
03608 
03609       if ($conf['params']) {
03610          $tableTagArray[] = $conf['params'];
03611       }
03612 
03613       $tableWrap = implode(' ',$tableTagArray).'> | </table>';
03614       $theValue=$this->wrap($theValue, $tableWrap);
03615          // return
03616       return $theValue;
03617    }
03618 
03628    function addParams($content,$conf) {
03629       $lowerCaseAttributes = TRUE;  // For XHTML compliance.
03630 
03631       if (!is_array($conf))   { return $content; }
03632 
03633       $key = 1;
03634       $parts = explode('<',$content);
03635       if (intval($conf['_offset'])) $key = intval($conf['_offset'])<0 ? count($parts)+intval($conf['_offset']) : intval($conf['_offset']);
03636       $subparts=explode('>',$parts[$key]);
03637       if (trim($subparts[0])) {
03638             // Get attributes and name
03639          $attribs = t3lib_div::get_tag_attributes('<'.$subparts[0].'>');
03640          if (!is_array($attribs))   {$attribs=array();}
03641          list($tagName) = explode(' ',$subparts[0],2);
03642             // adds/overrides attributes
03643          reset($conf);
03644          while(list($pkey,$val)=each($conf)) {
03645             if (substr($pkey,-1)!='.' && substr($pkey,0,1)!='_')  {
03646                $tmpVal=$this->stdWrap($conf[$pkey],$conf[$pkey.'.']);
03647                if ($lowerCaseAttributes)  { $pkey = strtolower($pkey); }
03648                if (strcmp($tmpVal,'')) {$attribs[$pkey]=$tmpVal;}
03649             }
03650          }
03651 
03652             // Re-assembles the tag and content
03653          $subparts[0]=trim($tagName.' '.t3lib_div::implodeAttributes($attribs));
03654          $parts[$key] = implode('>',$subparts);
03655          $content = implode('<',$parts);
03656       }
03657       return $content;
03658    }
03659 
03671    function filelink($theValue, $conf) {
03672       $output = '';
03673       $aTagParams = $GLOBALS['TSFE']->ATagParams.($conf['ATagParams']?' '.$conf['ATagParams']:'');
03674       $initP = '?id='.$GLOBALS['TSFE']->id.'&type='.$GLOBALS['TSFE']->type;
03675       $conf['path'] = $this->stdWrap($conf['path'],$conf['path.']);
03676       $theFile = trim($conf['path']).$theValue;
03677       if (@is_file($theFile)) {
03678          $theFileEnc = str_replace('%2F', '/', rawurlencode($theFile));
03679          $locDataAdd = $conf['jumpurl.']['secure'] ? $this->locDataJU($theFileEnc,$conf['jumpurl.']['secure.']) : '';
03680          $url = ($conf['jumpurl']) ? $GLOBALS['TSFE']->config['mainScript'].$initP.'&jumpurl='.rawurlencode($theFileEnc).$locDataAdd.$GLOBALS['TSFE']->getMethodUrlIdToken : $theFileEnc;    // && $GLOBALS['TSFE']->config['config']['jumpurl_enable']
03681          $theLinkWrap = '<a href="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.$url).'"'.($conf['target']?' target="'.$conf['target'].'"':'').$aTagParams.'>|</a>';
03682 
03683          $theSize = filesize($theFile);
03684          $fI = t3lib_div::split_fileref($theFile);
03685          if ($conf['icon'])   {
03686             $iconP = 't3lib/gfx/fileicons/';
03687             $icon = @is_file($iconP.$fI['fileext'].'.gif') ? $iconP.$fI['fileext'].'.gif' : $iconP.'default.gif';
03688                // Checking for images: If image, then return link to thumbnail.
03689             $IEList = $this->stdWrap($conf['icon_image_ext_list'],$conf['icon_image_ext_list.']);
03690             $image_ext_list = str_replace(' ','',strtolower($IEList));
03691             if ($fI['fileext'] && t3lib_div::inList($image_ext_list, $fI['fileext']))  {
03692                if ($conf['iconCObject'])  {
03693                   $icon = $this->cObjGetSingle($conf['iconCObject'],$conf['iconCObject.'],'iconCObject');
03694                } else {
03695                   if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails']) {
03696                      $icon = 't3lib/thumbs.php?&dummy='.$GLOBALS['EXEC_TIME'].'&file='.rawurlencode('../'.$theFile);
03697                   } else {
03698                      $icon = 't3lib/gfx/notfound_thumb.gif';
03699                   }
03700                   $icon = '<img src="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.$icon).'" border="0"'.$this->getAltParam($conf).' />';
03701                }
03702             } else {
03703                $icon = '<img src="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.$icon).'" width="18" height="16" border="0"'.$this->getAltParam($conf).' />';
03704             }
03705             if ($conf['icon_link']) {$icon = $this->wrap($icon, $theLinkWrap);}
03706             $icon = $this->stdWrap($icon,$conf['icon.']);
03707          }
03708          if ($conf['size'])   {
03709             $size = $this->stdWrap($theSize,$conf['size.']);
03710          }
03711 
03712             // Wrapping file label
03713          if ($conf['removePrependedNumbers']) $theValue=ereg_replace('_[0-9][0-9](\.[[:alnum:]]*)$','\1',$theValue);
03714          $theValue = $this->stdWrap($theValue,$conf['labelStdWrap.']);
03715 
03716             // Wrapping file
03717          if ($conf['ATagBeforeWrap'])  {
03718             $theValue = $this->wrap($this->wrap($theValue, $conf['wrap']), $theLinkWrap);
03719          } else {
03720             $theValue = $this->wrap($this->wrap($theValue, $theLinkWrap), $conf['wrap']);
03721          }
03722          $file = $this->stdWrap($theValue,$conf['file.']);
03723             // output
03724          return $this->stdWrap($icon.$file.$size, $conf['stdWrap.']);
03725       }
03726    }
03727 
03738    function locDataJU($jumpUrl,$conf)  {
03739       $fI = pathinfo($jumpUrl);
03740       $mimetype='';
03741       if ($fI['extension'])   {
03742          $mimeTypes = t3lib_div::trimExplode(',',$conf['mimeTypes'],1);
03743          reset($mimeTypes);
03744          while(list(,$v)=each($mimeTypes))   {
03745             $parts = explode('=',$v,2);
03746             if (strtolower($fI['extension']) == strtolower(trim($parts[0])))  {
03747                $mimetype = '&mimeType='.rawurlencode(trim($parts[1]));
03748             }
03749          }
03750       }
03751       $locationData = $GLOBALS['TSFE']->id.':'.$this->currentRecord;
03752       $rec='&locationData='.$locationData;
03753       $hArr = array(
03754          $jumpUrl,
03755          $locationData,
03756          $GLOBALS['TSFE']->TYPO3_CONF_VARS['SYS']['encryptionKey']
03757       );
03758       $juHash='&juHash='.t3lib_div::shortMD5(serialize($hArr));
03759       return '&juSecure=1'.$mimetype.$rec.$juHash;
03760    }
03761 
03769    function calc($val)  {
03770       $parts= t3lib_div::splitCalc($val,'+-*/');
03771       $value=0;
03772       reset($parts);
03773       while(list(,$part)=each($parts)) {
03774          $theVal = $part[1];
03775          $sign =  $part[0];
03776          if ((string)intval($theVal)==(string)$theVal)   {
03777             $theVal = intval($theVal);
03778          } else {
03779             $theVal =0;
03780          }
03781          if ($sign=='-')   {$value-=$theVal;}
03782          if ($sign=='+')   {$value+=$theVal;}
03783          if ($sign=='/')   {if (intval($theVal)) $value/=intval($theVal);}
03784          if ($sign=='*')   {$value*=$theVal;}
03785       }
03786       return $value;
03787    }
03788 
03798    function calcIntExplode($delim, $string)  {
03799       $temp = explode($delim,$string);
03800       while(list($key,$val)=each($temp))  {
03801          $temp[$key]=intval(tslib_cObj::calc($val));
03802       }
03803       return $temp;
03804    }
03805 
03818    function splitObj($value, $conf) {
03819       $conf['token']=$this->stdWrap($conf['token'],$conf['token.']);
03820 
03821       if ($conf['token'])  {
03822          $conf['max']=intval($this->stdWrap($conf['max'],$conf['max.']));
03823          $conf['min']=intval($this->stdWrap($conf['min'],$conf['min.']));
03824 
03825          $valArr=explode($conf['token'],$value);
03826             // calculate splitCount
03827          $splitCount = count($valArr);
03828          if ($conf['max'] && $splitCount>$conf['max']) {
03829             $splitCount=$conf['max'];
03830          }
03831          if ($conf['min'] && $splitCount<$conf['min']) {
03832             $splitCount=$conf['min'];
03833          }
03834 
03835          if ($conf['wrap'] || $conf['cObjNum']) {
03836             $splitArr=array();
03837             $splitArr['wrap']=$conf['wrap'];
03838             $splitArr['cObjNum']=$conf['cObjNum'];
03839             $splitArr = $GLOBALS['TSFE']->tmpl->splitConfArray($splitArr,$splitCount);
03840          }
03841 
03842          $content='';
03843          for($a=0;$a<$splitCount;$a++) {
03844             $GLOBALS['TSFE']->register['SPLIT_COUNT']=$a;
03845             $value = ''.$valArr[$a];
03846             $this->data[$this->currentValKey] = $value;
03847             if ($splitArr[$a]['cObjNum']) {
03848                $objName=intval($splitArr[$a]['cObjNum']);
03849                $value = $this->stdWrap($this->cObjGet($conf[$objName.'.'],$objName.'.'),$conf[$objName.'.']);
03850             }
03851             if ($splitArr[$a]['wrap']) {
03852                $value=$this->wrap($value,$splitArr[$a]['wrap']);
03853             }
03854             $content.=$value;
03855          }
03856       }
03857       return $content;
03858    }
03859 
03874    function parseFunc($theValue, $conf, $ref='') {
03875 
03876          // Fetch / merge reference, if any
03877       if ($ref)   {
03878          $temp_conf = array(
03879                         'parseFunc' => $ref,
03880                         'parseFunc.' => $conf
03881                      );
03882          $temp_conf = $this->mergeTSRef($temp_conf, 'parseFunc');
03883          $conf = $temp_conf['parseFunc.'];
03884       }
03885 
03886          // Process:
03887       if (strcmp($conf['externalBlocks'],''))   {
03888          $tags = strtolower(implode(',',t3lib_div::trimExplode(',',$conf['externalBlocks'])));
03889          $htmlParser = t3lib_div::makeInstance('t3lib_parsehtml');
03890          $parts = $htmlParser->splitIntoBlock($tags,$theValue);
03891 
03892          reset($parts);
03893          while(list($k,$v)=each($parts))  {
03894             if ($k%2)   {  // font:
03895                $tagName=strtolower($htmlParser->getFirstTagName($v));
03896                $cfg=$conf['externalBlocks.'][$tagName.'.'];
03897                if ($cfg['stripNLprev'] || $cfg['stripNL'])  {
03898                   $parts[$k-1]=ereg_replace(chr(13).'?'.chr(10).'[ ]*$', '', $parts[$k-1]);
03899                }
03900                if ($cfg['stripNLnext'] || $cfg['stripNL'])  {
03901                   $parts[$k+1]=ereg_replace('^[ ]*'.chr(13).'?'.chr(10), '', $parts[$k+1]);
03902                }
03903             }
03904          }
03905 
03906          reset($parts);
03907          while(list($k,$v)=each($parts))  {
03908             if ($k%2)   {
03909                $tag=$htmlParser->getFirstTag($v);
03910                $tagName=strtolower($htmlParser->getFirstTagName($v));
03911                $cfg=$conf['externalBlocks.'][$tagName.'.'];
03912                if ($cfg['callRecursive']) {
03913                   $parts[$k]=$this->parseFunc($htmlParser->removeFirstAndLastTag($v), $conf);
03914                   if (!$cfg['callRecursive.']['dontWrapSelf']) {
03915                      if ($cfg['callRecursive.']['alternativeWrap'])  {
03916                         $parts[$k] = $this->wrap($parts[$k], $cfg['callRecursive.']['alternativeWrap']);
03917                      } else {
03918                         if (is_array($cfg['callRecursive.']['tagStdWrap.']))  {
03919                            $tag = $this->stdWrap($tag,$cfg['callRecursive.']['tagStdWrap.']);
03920                         }
03921                         $parts[$k]=$tag.$parts[$k].'</'.$tagName.'>';
03922                      }
03923                   }
03924                } elseif($cfg['HTMLtableCells']) {
03925                   $rowParts = $htmlParser->splitIntoBlock('tr',$parts[$k]);
03926                   reset($rowParts);
03927                   while(list($kk,$vv)=each($rowParts))   {
03928                      if ($kk%2)  {
03929                         $colParts = $htmlParser->splitIntoBlock('td',$vv);
03930                         reset($colParts);
03931                         $cc=0;
03932                         while(list($kkk,$vvv)=each($colParts)) {
03933                            if ($kkk%2) {
03934                               $cc++;
03935                               $tag=$htmlParser->getFirstTag($vvv);
03936                               $tagName=strtolower($htmlParser->getFirstTagName($vvv));
03937                               $colParts[$kkk] = $htmlParser->removeFirstAndLastTag($vvv);
03938 
03939                               if ($cfg['HTMLtableCells.'][$cc.'.']['callRecursive'] || (!isset($cfg['HTMLtableCells.'][$cc.'.']['callRecursive']) && $cfg['HTMLtableCells.']['default.']['callRecursive'])) {
03940                                  if ($cfg['HTMLtableCells.']['addChr10BetweenParagraphs'])   $colParts[$kkk]=str_replace('</p><p>','</p>'.chr(10).'<p>',$colParts[$kkk]);
03941                                  $colParts[$kkk] = $this->parseFunc($colParts[$kkk], $conf);
03942                               }
03943 
03944                               $tagStdWrap = is_array($cfg['HTMLtableCells.'][$cc.'.']['tagStdWrap.'])?$cfg['HTMLtableCells.'][$cc.'.']['tagStdWrap.']:$cfg['HTMLtableCells.']['default.']['tagStdWrap.'];
03945                               if (is_array($tagStdWrap)) {
03946                                  $tag = $this->stdWrap($tag,$tagStdWrap);
03947                               }
03948 
03949                               $stdWrap = is_array($cfg['HTMLtableCells.'][$cc.'.']['stdWrap.'])?$cfg['HTMLtableCells.'][$cc.'.']['stdWrap.']:$cfg['HTMLtableCells.']['default.']['stdWrap.'];
03950                               if (is_array($stdWrap)) {
03951                                  $colParts[$kkk] = $this->stdWrap($colParts[$kkk],$stdWrap);
03952                               }
03953 
03954                               $colParts[$kkk]=$tag.$colParts[$kkk].'</'.$tagName.'>';
03955                            }
03956                         }
03957                         $rowParts[$kk] = implode('',$colParts);
03958                      }
03959                   }
03960                   $parts[$k] = implode('',$rowParts);
03961                }
03962 
03963                if (is_array($cfg['stdWrap.']))  {
03964                   $parts[$k] = $this->stdWrap($parts[$k],$cfg['stdWrap.']);
03965                }
03966             } else {
03967                $parts[$k]=$this->_parseFunc($parts[$k], $conf);
03968             }
03969          }
03970 
03971          return implode('',$parts);
03972       } else return $this->_parseFunc($theValue, $conf);
03973    }
03974 
03984    function _parseFunc ($theValue, $conf) {
03985       if (!$this->checkIf($conf['if.']))  {
03986          return $theValue;
03987       }
03988       $inside=0;  // Indicates that the data is from within a tag.
03989       $pointer=0; // Pointer to the total string position
03990       $currentTag='';   // Loaded with the current typo-tag if any.
03991       $stripNL=0;
03992       $contentAccum=array();
03993       $contentAccumP=0;
03994 
03995       $allowTags=strtolower(str_replace(' ','',$conf['allowTags']));
03996       $denyTags=strtolower(str_replace(' ','',$conf['denyTags']));
03997 
03998       $totalLen = strlen($theValue);
03999       do {
04000          if (!$inside)  {
04001             if (!is_array($currentTag))   {        // These operations should only be performed on code outside the typotags...
04002                   // data: this checks that we enter tags ONLY if the first char in the tag is alphanumeric OR '/'
04003                $len_p=0;
04004                $c=100;
04005                do    {
04006                   $len = strcspn(substr($theValue,$pointer+$len_p),'<');
04007                   $len_p+=$len+1;
04008                   $endChar = ord(strtolower(substr($theValue,$pointer+$len_p,1)));
04009                   $c--;
04010                } while ($c>0 && $endChar && ($endChar<97 || $endChar>122) && $endChar!=47);
04011                $len = $len_p-1;
04012             } else {
04013                   // If we're inside a currentTag, just take it to the end of that tag!
04014                $tempContent = strtolower(substr($theValue,$pointer));
04015                $len = strpos ($tempContent, '</'.$currentTag[0]);
04016                if (is_string ($len) && !$len) {
04017                   $len = strlen($tempContent);
04018                }
04019             }
04020 
04021             $data = substr($theValue,$pointer,$len);  // $data is the content until the next <tag-start or end is detected. In case of a currentTag set, this would mean all data between the start- and end-tags
04022             if ($data!='') {
04023                if ($stripNL)  {     // If the previous tag was set to strip NewLines in the beginning of the next data-chunk.
04024                   $data = ereg_replace('^[ ]*'.chr(13).'?'.chr(10), '', $data);
04025                }
04026 
04027                if (!is_array($currentTag))   {        // These operations should only be performed on code outside the tags...
04028                      // Constants
04029                   if ($conf['constants'] && is_array($GLOBALS['TSFE']->tmpl->setup['constants.'])) {
04030                      reset($GLOBALS['TSFE']->tmpl->setup['constants.']);
04031                      while(list($key,$val)=each($GLOBALS['TSFE']->tmpl->setup['constants.']))   {
04032                         if (is_string($val)) {
04033                            $data = str_replace('###'.$key.'###', $val, $data);
04034                         }
04035                      }
04036                   }
04037                      // Short
04038                   if (is_array($conf['short.']))   {
04039                      $shortWords = $conf['short.'];
04040                      krsort($shortWords);
04041                      reset($shortWords);
04042                      while(list($key,$val)=each($shortWords))  {
04043                         if (is_string($val)) {
04044                            $data = str_replace($key, $val, $data);
04045                         }
04046                      }
04047                   }
04048 
04049                      // stdWrap
04050                   if (is_array($conf['plainTextStdWrap.'])) {$data = $this->stdWrap($data,$conf['plainTextStdWrap.']);}
04051                      // userFunc
04052                   if ($conf['userFunc'])  {$data = $this->callUserFunction($conf['userFunc'], $conf['userFunc.'], $data);}
04053 
04054                      // Makelinks: (Before search-words as we need the links to be generated when searchwords go on...!)
04055                   if ($conf['makelinks']) {
04056                      $data = $this->http_makelinks($data,$conf['makelinks.']['http.']);
04057                      $data = $this->mailto_makelinks($data,$conf['makelinks.']['mailto.']);
04058                   }
04059 
04060                      // Search Words:
04061                   if ($GLOBALS['TSFE']->no_cache && $conf['sword'] && is_array($GLOBALS['TSFE']->sWordList) && $GLOBALS['TSFE']->sWordRegEx) {
04062                      $newstring = '';
04063                      do {
04064                         $pieces = split($GLOBALS['TSFE']->sWordRegEx,$data,2);
04065                         $newstring.=$pieces[0];
04066                         $match_len = strlen($data)-(strlen($pieces[0])+strlen($pieces[1]));
04067                         if (strstr($pieces[0],'<') || strstr($pieces[0],'>')) {
04068                            $inTag = strrpos($pieces[0],'<') > strrpos($pieces[0],'>');    // Returns true, if a '<' is closer to the string-end than '>'. This is the case if we're INSIDE a tag (that could have been made by makelinks...) and we must secure, that the inside of a tag is not marked up.
04069                         }
04070                            // The searchword:
04071                         $match = substr($data,strlen($pieces[0]),$match_len);
04072 
04073                         if (trim($match) && strlen($match)>1 && !$inTag)   {
04074                            $match = $this->wrap($match, $conf['sword']);
04075                         }
04076                            // Concatenate the Search Word again.
04077                         $newstring.= $match;
04078                         $data=$pieces[1];
04079                      } while ($pieces[1]);
04080                      $data = $newstring;
04081                   }
04082                }
04083                $contentAccum[$contentAccumP].=$data;
04084             }
04085             $inside = 1;
04086          } else {
04087                // tags
04088             $len = strcspn(substr($theValue,$pointer),'>')+1;
04089             $data = substr($theValue,$pointer,$len);
04090 
04091             $tag = explode(' ',trim(substr($data,1,-1)),2);
04092             $tag[0]=strtolower($tag[0]);
04093             if (substr($tag[0],0,1)=='/') {
04094                $tag[0]=substr($tag[0],1);
04095                $tag['out']=1;
04096             }
04097             if($conf['tags.'][$tag[0]])   {
04098                $treated=0;
04099                $stripNL = 0;
04100                   // in-tag
04101                if (!$currentTag && !$tag['out'])   {
04102                   $currentTag = $tag;     // $currentTag er lig med det tag (array!), man er igang med!
04103                   $contentAccumP++;
04104                   $treated=1;
04105                }
04106                   // out-tag
04107                if ($currentTag[0]==$tag[0] && $tag['out'])  {
04108                   $theName = $conf['tags.'][$tag[0]];
04109                   $theConf = $conf['tags.'][$tag[0].'.'];
04110                   $stripNL = ($theConf['stripNL'] ? 1 : 0); // This flag indicates, that NL- (13-10-chars) should be stripped first and last.
04111                   $breakOut = ($theConf['breakoutTypoTagContent'] ? 1 : 0);   // This flag indicates, that this TypoTag section should NOT be included in the nonTypoTag content.
04112 
04113                   $this->parameters=Array();
04114                   if ($currentTag[1])  {
04115                      $params=t3lib_div::get_tag_attributes($currentTag[1]);
04116                      if (is_array($params))  {
04117                         reset($params);
04118                         while(list($option,$val)=each($params))   {
04119                            $this->parameters[strtolower($option)]=$val;
04120                         }
04121                      }
04122                   }
04123                   $this->parameters['allParams']=trim($currentTag[1]);
04124                   if ($stripNL)  {  // Removes NL in the beginning and end of the tag-content AND at the end of the currentTagBuffer. $stripNL depends on the configuration of the current tag
04125                      $contentAccum[$contentAccumP-1] = ereg_replace(chr(13).'?'.chr(10).'[ ]*$', '', $contentAccum[$contentAccumP-1]);
04126                      $contentAccum[$contentAccumP] = ereg_replace('^[ ]*'.chr(13).'?'.chr(10), '', $contentAccum[$contentAccumP]);
04127                      $contentAccum[$contentAccumP] = ereg_replace(chr(13).'?'.chr(10).'[ ]*$', '', $contentAccum[$contentAccumP]);
04128                   }
04129                   $this->data[$this->currentValKey] = $contentAccum[$contentAccumP];
04130                   $newInput=$this->cObjGetSingle($theName,$theConf,'/parseFunc/.tags.'.$tag[0]);   // fetch the content object
04131 
04132                   $contentAccum[$contentAccumP]=$newInput;
04133                   $contentAccumP++;
04134 
04135                      // If the TypoTag section
04136                   if (!$breakOut)   {
04137                      $contentAccum[$contentAccumP-2].=$contentAccum[$contentAccumP-1].$contentAccum[$contentAccumP];
04138                      unset($contentAccum[$contentAccumP]);
04139                      unset($contentAccum[$contentAccumP-1]);
04140                      $contentAccumP-=2;
04141                   }
04142 
04143                   unset($currentTag);
04144                   $treated=1;
04145                }
04146                   // other tags...
04147                if (!$treated) {
04148                   $contentAccum[$contentAccumP].=$data;
04149                }
04150             } else {
04151                   // If a tag was not a typo tag, then it is just added to the content
04152                $stripNL = 0;
04153                if (t3lib_div::inList($allowTags,$tag[0]) || ($denyTags!='*' && !t3lib_div::inList($denyTags,$tag[0])))  {
04154                   $contentAccum[$contentAccumP].=$data;
04155                } else {
04156                   $contentAccum[$contentAccumP].=HTMLSpecialChars($data);
04157                }
04158             }
04159             $inside = 0;
04160          }
04161          $pointer+=$len;
04162       } while($pointer<$totalLen);
04163 
04164          // Parsing nonTypoTag content (all even keys):
04165       reset($contentAccum);
04166       for ($a=0;$a<count($contentAccum);$a++)   {
04167          if ($a%2 != 1) {
04168                // stdWrap
04169             if (is_array($conf['nonTypoTagStdWrap.']))   {$contentAccum[$a] = $this->stdWrap($contentAccum[$a],$conf['nonTypoTagStdWrap.']);}
04170                // userFunc
04171             if ($conf['nonTypoTagUserFunc']) {$contentAccum[$a] = $this->callUserFunction($conf['nonTypoTagUserFunc'], $conf['nonTypoTagUserFunc.'], $contentAccum[$a]);}
04172          }
04173       }
04174       return implode('',$contentAccum);
04175    }
04176 
04186    function encaps_lineSplit($theValue, $conf)  {
04187       $lParts = explode(chr(10),$theValue);
04188 
04189       $encapTags = t3lib_div::trimExplode(',',strtolower($conf['encapsTagList']),1);
04190       $nonWrappedTag = $conf['nonWrappedTag'];
04191       $defaultAlign=trim($this->stdWrap($conf['defaultAlign'],$conf['defaultAlign.']));
04192 
04193       if (!strcmp('',$theValue)) return '';
04194 
04195       while(list($k,$l)=each($lParts)) {
04196          $sameBeginEnd=0;
04197          $l=trim($l);
04198          $attrib=array();
04199          $nWrapped=0;
04200          $byPass=0;
04201          if (substr($l,0,1)=='<' && substr($l,-1)=='>')  {
04202             $fwParts = explode('>',substr($l,1),2);
04203             $backParts = t3lib_div::revExplode('<', substr($fwParts[1],0,-1), 2);
04204             $attrib = t3lib_div::get_tag_attributes('<'.$fwParts[0].'>');
04205             list($tagName) = explode(' ',$fwParts[0]);
04206             $str_content = $backParts[0];
04207             $sameBeginEnd = (substr(strtolower($backParts[1]),1,strlen($tagName))==strtolower($tagName));
04208          }
04209 
04210          if ($sameBeginEnd && in_array(strtolower($tagName),$encapTags))   {
04211             $uTagName = strtoupper($tagName);
04212             $uTagName = strtoupper($conf['remapTag.'][$uTagName]?$conf['remapTag.'][$uTagName]:$uTagName);
04213          } else {
04214             $uTagName = strtoupper($nonWrappedTag);
04215             $str_content = $lParts[$k];
04216             $nWrapped=1;
04217             $attrib=array();
04218          }
04219 
04220             // Wrapping all inner-content:
04221          if (is_array($conf['innerStdWrap_all.'])) {$str_content = $this->stdWrap($str_content,$conf['innerStdWrap_all.']);}
04222 
04223          if ($uTagName) {
04224                // Setting common attributes
04225             if (is_array($conf['addAttributes.'][$uTagName.'.'])) {
04226                reset($conf['addAttributes.'][$uTagName.'.']);
04227                while(list($kk,$vv)=each($conf['addAttributes.'][$uTagName.'.'])) {
04228                   if (!is_array($vv))  {
04229                      if ((string)$conf['addAttributes.'][$uTagName.'.'][$kk.'.']['setOnly']=='blank') {
04230                         if (!strcmp($attrib[$kk],'')) $attrib[$kk]=$vv;
04231                      } elseif ((string)$conf['addAttributes.'][$uTagName.'.'][$kk.'.']['setOnly']=='exists')   {
04232                         if (!isset($attrib[$kk]))  $attrib[$kk]=$vv;
04233                      } else {
04234                         $attrib[$kk]=$vv;
04235                      }
04236                   }
04237                }
04238             }
04239                // Wrapping all inner-content:
04240             if (is_array($conf['encapsLinesStdWrap.'][$uTagName.'.']))  {$str_content = $this->stdWrap($str_content,$conf['encapsLinesStdWrap.'][$uTagName.'.']);}
04241                // Default align
04242             if (!$attrib['align'] && $defaultAlign)   $attrib['align']=$defaultAlign;
04243 
04244             $params = t3lib_div::implodeAttributes($attrib,1);
04245             if ($conf['removeWrapping'])  {
04246                $str_content=$str_content;
04247             } else {
04248                $str_content='<'.strtolower($uTagName).(trim($params)?' '.trim($params):'').'>'.$str_content.'</'.strtolower($uTagName).'>';
04249             }
04250          }
04251 
04252          if ($nWrapped && $conf['wrapNonWrappedLines'])  {$str_content = $this->wrap($str_content,$conf['wrapNonWrappedLines']);}
04253          $lParts[$k] = $str_content;
04254       }
04255 
04256       return implode(chr(10),$lParts);
04257    }
04258 
04269    function http_makelinks($data,$conf)   {
04270       $aTagParams = $GLOBALS['TSFE']->ATagParams.($conf['ATagParams']?' '.$conf['ATagParams']:'');
04271       $textpieces = explode('http://', $data);
04272       $pieces = count($textpieces);
04273       $textstr = $textpieces[0];
04274       $initP = '?id='.$GLOBALS['TSFE']->id.'&type='.$GLOBALS['TSFE']->type;
04275       for($i=1; $i<$pieces; $i++)   {
04276          $len=strcspn($textpieces[$i],chr(32).chr(9).chr(13).chr(10));
04277          if (trim(substr($textstr,-1))=='' && $len)   {
04278 
04279             $lastChar=substr($textpieces[$i],$len-1,1);
04280             if (!ereg('[A-Za-z0-9\/#_-]',$lastChar)) {$len--;}    // Included '\/' 3/12
04281 
04282             $parts[0]=substr($textpieces[$i],0,$len);
04283             $parts[1]=substr($textpieces[$i],$len);
04284 
04285             $keep=$conf['keep'];
04286             $linkParts=parse_url('http://'.$parts[0]);
04287             $linktxt='';
04288             if (strstr($keep,'scheme'))   {
04289                $linktxt='http://';
04290             }
04291             $linktxt.= $linkParts['host'];
04292             if (strstr($keep,'path'))  {
04293                $linktxt.= $linkParts['path'];
04294                if (strstr($keep,'query') && $linkParts['query'])  {     // added $linkParts['query'] 3/12
04295                   $linktxt.= '?'.$linkParts['query'];
04296                } elseif ($linkParts['path']=='/')  {  // If query is NOT added and the path is '/' then remove the slash ('/')   (added 3/12)
04297                   $linktxt=substr($linktxt,0,-1);
04298                }
04299             }
04300             $target = isset($conf['extTarget']) ? $conf['extTarget'] : $GLOBALS['TSFE']->extTarget;
04301             if ($GLOBALS['TSFE']->config['config']['jumpurl_enable'])   {
04302                $res = '<a'.
04303                      ' href="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.$GLOBALS['TSFE']->config['mainScript'].$initP.'&jumpurl='.rawurlencode('http://'.$parts[0]).$GLOBALS['TSFE']->getMethodUrlIdToken).'"'.
04304                      ($target ? ' target="'.$target.'"' : '').
04305                      $aTagParams.
04306                      '>';
04307             } else {
04308                $res = '<a'.
04309                      ' href="http://'.htmlspecialchars($parts[0]).'"'.
04310                      ($target ? ' target="'.$target.'"' : '').
04311                      $aTagParams.
04312                      '>';
04313             }
04314             if ($conf['ATagBeforeWrap'])  {
04315                $res= $res.$this->wrap($linktxt, $conf['wrap']).'</a>';
04316             } else {
04317                $res= $this->wrap($res.$linktxt.'</a>', $conf['wrap']);
04318             }
04319             $textstr.=$res.$parts[1];
04320          } else {
04321             $textstr.='http://'.$textpieces[$i];
04322          }
04323       }
04324       return $textstr;
04325    }
04326 
04336    function mailto_makelinks($data,$conf) {
04337       // http-split
04338       $aTagParams = $GLOBALS['TSFE']->ATagParams.($conf['ATagParams']?' '.$conf['ATagParams']:'');
04339       $textpieces = explode('mailto:', $data);
04340       $pieces = count($textpieces);
04341       $textstr = $textpieces[0];
04342       $initP = '?id='.$GLOBALS['TSFE']->id.'&type='.$GLOBALS['TSFE']->type;
04343       for($i=1; $i<$pieces; $i++)   {
04344          $len = strcspn($textpieces[$i],chr(32).chr(9).chr(13).chr(10));
04345          if (trim(substr($textstr,-1))=='' && $len)   {
04346             $lastChar = substr($textpieces[$i],$len-1,1);
04347             if (!ereg('[A-Za-z0-9]',$lastChar)) {$len--;}
04348 
04349             $parts[0] = substr($textpieces[$i],0,$len);
04350             $parts[1] = substr($textpieces[$i],$len);
04351             $linktxt = ereg_replace('\?.*','',$parts[0]);
04352             if (!$GLOBALS['TSFE']->config['config']['jumpurl_enable'] || $GLOBALS['TSFE']->config['config']['jumpurl_mailto_disable']) {
04353                if ($GLOBALS['TSFE']->spamProtectEmailAddresses)   {
04354                   $mailToUrl = "javascript:linkTo_UnCryptMailto('".$GLOBALS['TSFE']->encryptEmail('mailto:'.$parts[0])."');";
04355                   $atLabel = trim($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses_atSubst']);
04356                   $linktxt = str_replace('@',$atLabel ? $atLabel : '(at)', $linktxt);
04357                } else {
04358                   $mailToUrl = 'mailto:'.$parts[0];
04359                }
04360                $res = '<a href="'.htmlspecialchars($mailToUrl).'"'.$aTagParams.'>';
04361             } else {
04362                $res = '<a href="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.$GLOBALS['TSFE']->config['mainScript'].$initP.'&jumpurl='.rawurlencode('mailto:'.$parts[0]).$GLOBALS['TSFE']->getMethodUrlIdToken).'"'.$aTagParams.'>';
04363             }
04364             if ($conf['ATagBeforeWrap'])  {
04365                $res= $res.$this->wrap($linktxt, $conf['wrap']).'</a>';
04366             } else {
04367                $res= $this->wrap($res.$linktxt.'</a>', $conf['wrap']);
04368             }
04369             $textstr.=$res.$parts[1];
04370          } else {
04371             $textstr.='mailto:'.$textpieces[$i];
04372          }
04373       }
04374       return $textstr;
04375    }
04376 
04388    function getImgResource($file,$fileArray) {
04389       if (is_array($fileArray))  {
04390          switch($file)  {
04391             case 'GIFBUILDER':
04392                $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
04393                $gifCreator->init();
04394                $theImage='';
04395                if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib'])   {
04396                   $gifCreator->start($fileArray,$this->data);
04397                   $theImage = $gifCreator->gifBuild();
04398                }
04399                return $gifCreator->getImageDimensions($theImage);
04400             break;
04401             default:
04402                if ($fileArray['import.']) {
04403                   $ifile = $this->stdWrap('',$fileArray['import.']);
04404                   if ($ifile) {$file = $fileArray['import'].$ifile;}
04405                }
04406                $theImage = $GLOBALS['TSFE']->tmpl->getFileName($file);
04407                if ($theImage) {
04408                   $fileArray['width']= $this->stdWrap($fileArray['width'],$fileArray['width.']);
04409                   $fileArray['height']= $this->stdWrap($fileArray['height'],$fileArray['height.']);
04410                   $fileArray['ext']= $this->stdWrap($fileArray['ext'],$fileArray['ext.']);
04411                   $fileArray['maxW']= intval($this->stdWrap($fileArray['maxW'],$fileArray['maxW.']));
04412                   $fileArray['maxH']= intval($this->stdWrap($fileArray['maxH'],$fileArray['maxH.']));
04413                   $fileArray['minW']= intval($fileArray['minW']);
04414                   $fileArray['minH']= intval($fileArray['minH']);
04415                   $maskArray= $fileArray['m.'];
04416                   $maskImages=array();
04417                   if (is_array($fileArray['m.']))  {  // Must render mask images and include in hash-calculating - else we cannot be sure the filename is unique for the setup!
04418                      $maskImages['m_mask'] = $this->getImgResource($maskArray['mask'],$maskArray['mask.']);
04419                      $maskImages['m_bgImg'] = $this->getImgResource($maskArray['bgImg'],$maskArray['bgImg.']);
04420                      $maskImages['m_bottomImg'] = $this->getImgResource($maskArray['bottomImg'],$maskArray['bottomImg.']);
04421                      $maskImages['m_bottomImg_mask'] = $this->getImgResource($maskArray['bottomImg_mask'],$maskArray['bottomImg_mask.']);
04422                   }
04423                   $hash = t3lib_div::shortMD5($theImage.serialize($fileArray).serialize($maskImages));
04424                   if (!isset($GLOBALS['TSFE']->tmpl->fileCache[$hash])) {
04425                      $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
04426                      $gifCreator->init();
04427                      if ($fileArray['sample'])  {
04428                         $gifCreator->scalecmd = '-sample';
04429                         $GLOBALS['TT']->setTSlogMessage('Sample option: Images are scaled with -sample.');
04430                      }
04431                      if ($fileArray['alternativeTempPath'] && t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['FE']['allowedTempPaths'],$fileArray['alternativeTempPath']))  {
04432                         $gifCreator->tempPath = $fileArray['alternativeTempPath'];
04433                         $GLOBALS['TT']->setTSlogMessage('Set alternativeTempPath: '.$fileArray['alternativeTempPath']);
04434                      }
04435 
04436                      if (!trim($fileArray['ext'])){$fileArray['ext']='web';}
04437                      $options = Array();
04438                      if ($fileArray['maxW']) {$options['maxW']=$fileArray['maxW'];}
04439                      if ($fileArray['maxH']) {$options['maxH']=$fileArray['maxH'];}
04440                      if ($fileArray['minW']) {$options['minW']=$fileArray['minW'];}
04441                      if ($fileArray['minH']) {$options['minH']=$fileArray['minH'];}
04442 
04443                         // checks to see if m (the mask array) is defined
04444                      if (is_array($maskArray) && $GLOBALS['TYPO3_CONF_VARS']['GFX']['im'])   {
04445                            // Filename:
04446                         $fI = t3lib_div::split_fileref($theImage);
04447                         $dest = $gifCreator->tempPath.$hash.'.'.($fI['fileext']==$gifCreator->gifExtension ? $gifCreator->gifExtension : 'jpg');
04448                         if (!@file_exists($dest))  {     // Generate!
04449                            $m_mask= $maskImages['m_mask'];
04450                            $m_bgImg = $maskImages['m_bgImg'];
04451                            if ($m_mask && $m_bgImg)   {
04452                               $negate = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_negate_mask'] ? ' -negate' : '';
04453 
04454                               $temp_ext='png';
04455                               if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_mask_temp_ext_gif'])   {     // If ImageMagick version 5+
04456                                  $temp_ext=$gifCreator->gifExtension;
04457                               }
04458 
04459                               $tempFileInfo = $gifCreator->imageMagickConvert($theImage,$temp_ext,$fileArray['width'],$fileArray['height'],$fileArray['params'],$fileArray['frame'],$options);
04460                               if (is_array($tempFileInfo))  {
04461                                  $m_bottomImg = $maskImages['m_bottomImg'];
04462                                  if ($m_bottomImg) {
04463                                     $m_bottomImg_mask = $maskImages['m_bottomImg_mask'];
04464                                  }
04465                                     // Scaling: ****
04466                                  $tempScale=array();
04467                                  $command = '-geometry '.$tempFileInfo[0].'x'.$tempFileInfo[1].'!';
04468                                  $tmpStr = $gifCreator->randomName();
04469 
04470                                     // m_mask
04471                                  $tempScale['m_mask']=$tmpStr.'_mask.'.$temp_ext;
04472                                  $gifCreator->imageMagickExec($m_mask[3],$tempScale['m_mask'],$command.$negate);
04473                                     // m_bgImg
04474                                  $tempScale['m_bgImg']=$tmpStr.'_bgImg.'.trim($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_mask_temp_ext_noloss']);
04475                                  $gifCreator->imageMagickExec($m_bgImg[3],$tempScale['m_bgImg'],$command);
04476 
04477                                     // m_bottomImg / m_bottomImg_mask
04478                                  if ($m_bottomImg && $m_bottomImg_mask) {
04479                                     $tempScale['m_bottomImg']=$tmpStr.'_bottomImg.'.$temp_ext;
04480                                     $gifCreator->imageMagickExec($m_bottomImg[3],$tempScale['m_bottomImg'],$command);
04481                                     $tempScale['m_bottomImg_mask']=$tmpStr.'_bottomImg_mask.'.$temp_ext;
04482                                     $gifCreator->imageMagickExec($m_bottomImg_mask[3],$tempScale['m_bottomImg_mask'],$command.$negate);
04483 
04484                                        // BEGIN combining:
04485                                        // The image onto the background
04486                                     $gifCreator->combineExec($tempScale['m_bgImg'],$tempScale['m_bottomImg'],$tempScale['m_bottomImg_mask'],$tempScale['m_bgImg']);
04487                                  }
04488                                     // The image onto the background
04489                                  $gifCreator->combineExec($tempScale['m_bgImg'],$tempFileInfo[3],$tempScale['m_mask'],$dest);
04490                                     // Unlink the temp-images...
04491                                  reset($tempScale);
04492                                  while(list(,$file)=each($tempScale))   {
04493                                     if (@is_file($file)) {
04494                                        unlink($file);
04495                                     }
04496                                  }
04497                                     // t3lib_div::print_array($GLOBALS['TSFE']->tmpl->fileCache[$hash]);
04498                               }
04499                            }
04500                         }
04501                            // Finish off
04502                         $GLOBALS['TSFE']->tmpl->fileCache[$hash]= $gifCreator->getImageDimensions($dest);
04503                      } else {    // Normal situation:
04504                         $GLOBALS['TSFE']->tmpl->fileCache[$hash]= $gifCreator->imageMagickConvert($theImage,$fileArray['ext'],$fileArray['width'],$fileArray['height'],$fileArray['params'],$fileArray['frame'],$options);
04505                      }
04506                      $GLOBALS['TSFE']->tmpl->fileCache[$hash]['origFile'] = $theImage;
04507                      $GLOBALS['TSFE']->tmpl->fileCache[$hash]['origFile_mtime'] = @filemtime($theImage); // This is needed by tslib_gifbuilder, ln 100ff in order for the setup-array to create a unique filename hash.
04508                   }
04509                   return $GLOBALS['TSFE']->tmpl->fileCache[$hash];
04510                }
04511 
04512             break;
04513          }
04514       }
04515       $theImage = $GLOBALS['TSFE']->tmpl->getFileName($file);
04516       if ($theImage) {
04517          $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
04518          $gifCreator->init();
04519          $info= $gifCreator->imageMagickConvert($theImage,'WEB','','','','','');
04520          $info['origFile'] = $theImage;
04521          $info['origFile_mtime'] = @filemtime($theImage);   // This is needed by tslib_gifbuilder, ln 100ff in order for the setup-array to create a unique filename hash.
04522          return $info;
04523       }
04524    }
04525 
04526 
04527 
04528 
04529 
04530 
04531 
04532 
04533 
04534 
04535 
04536 
04537 
04538 
04539 
04540 
04541 
04542 
04543 
04544 
04545 
04546 
04547    /***********************************************
04548     *
04549     * Data retrieval etc.
04550     *
04551     ***********************************************/
04552 
04553 
04560    function getFieldVal($field)  {
04561       if (!strstr($field,'//'))  {
04562          return $this->data[trim($field)];
04563       } else {
04564          $sections = t3lib_div::trimExplode('//',$field,1);
04565          while (list(,$k)=each($sections)) {
04566             if (strcmp($this->data[$k],''))  return $this->data[$k];
04567          }
04568       }
04569    }
04570 
04580    function getData($string,$fieldArray)  {
04581       if (!is_array($fieldArray))   {
04582          $fieldArray=$GLOBALS['TSFE']->page;
04583       }
04584       $retVal = '';
04585       $sections = explode('//',$string);
04586 
04587       while (!$retVal AND list($secKey, $secVal)=each($sections)) {
04588          $parts = explode(':',$secVal,2);
04589          $key = trim($parts[1]);
04590          if ((string)$key!='')   {
04591             switch(strtolower(trim($parts[0]))) {
04592                case 'gpvar':
04593                   list($firstKey, $rest) = explode('|', $key, 2);
04594                   if (strlen(trim($firstKey)))  {
04595                      $retVal = t3lib_div::_GP(trim($firstKey));
04596                         // Look for deeper levels:
04597                      if (strlen(trim($rest)))   {
04598                         $retVal = is_array($retVal) ? $this->getGlobal($rest, $retVal) : '';
04599                      }
04600                         // Check that output is not an array:
04601                      if (is_array($retVal))  $retVal = '';
04602                   }
04603                break;
04604                case 'tsfe':
04605                   $retVal = $GLOBALS['TSFE']->$key;
04606                break;
04607                case 'getenv':
04608                   $retVal = getenv($key);
04609                break;
04610                case 'getindpenv':
04611                   $retVal = t3lib_div::getIndpEnv($key);
04612                break;
04613                case 'field':
04614                   $retVal = $fieldArray[$key];
04615                break;
04616                case 'parameters':
04617                   $retVal = $this->parameters[$key];
04618                break;
04619                case 'register':
04620                   $retVal = $GLOBALS['TSFE']->register[$key];
04621                break;
04622                case 'global':
04623                   $retVal = $this->getGlobal($key);
04624                break;
04625                case 'leveltitle':
04626                   $nkey = $this->getKey($key,$GLOBALS['TSFE']->tmpl->rootLine);
04627                   $retVal = $this->rootLineValue($nkey,'title',stristr($key,'slide'));
04628                break;
04629                case 'levelmedia':
04630                   $nkey = $this->getKey($key,$GLOBALS['TSFE']->tmpl->rootLine);
04631                   $retVal = $this->rootLineValue($nkey,'media',stristr($key,'slide'));
04632                break;
04633                case 'leveluid':
04634                   $nkey = $this->getKey($key,$GLOBALS['TSFE']->tmpl->rootLine);
04635                   $retVal = $this->rootLineValue($nkey,'uid',stristr($key,'slide'));
04636                break;
04637                case 'levelfield':
04638                   $keyP = t3lib_div::trimExplode(',',$key);
04639                   $nkey = $this->getKey($keyP[0],$GLOBALS['TSFE']->tmpl->rootLine);
04640                   $retVal = $this->rootLineValue($nkey,$keyP[1],strtolower($keyP[2])=='slide');
04641                break;
04642                case 'fullrootline':
04643                   $keyP = t3lib_div::trimExplode(',',$key);
04644                   $fullKey = intval($keyP[0])-count($GLOBALS['TSFE']->tmpl->rootLine)+count($GLOBALS['TSFE']->rootLine);
04645                   if ($fullKey>=0)  {
04646                      $retVal = $this->rootLineValue($fullKey,$keyP[1],stristr($keyP[2],'slide'),$GLOBALS['TSFE']->rootLine);
04647                   }
04648                break;
04649                case 'date':
04650                   if (!$key) {$key = 'd/m Y';}
04651                   $retVal = date($key, time());
04652                break;
04653                case 'page':
04654                   $retVal = $GLOBALS['TSFE']->page[$key];
04655                break;
04656                case 'current':
04657                   $retVal = $this->data[$this->currentValKey];
04658                break;
04659                case 'level':
04660                   $retVal = count($GLOBALS['TSFE']->tmpl->rootLine)-1;
04661                break;
04662                case 'db':
04663                   $selectParts = t3lib_div::trimExplode(':',$key);
04664                   $db_rec = $GLOBALS['TSFE']->sys_page->getRawRecord($selectParts[0],$selectParts[1]);
04665                   if (is_array($db_rec) && $selectParts[2]) {$retVal = $db_rec[$selectParts[2]];}
04666                break;
04667                case 'lll':
04668                   $retVal = $GLOBALS['TSFE']->sL('LLL:'.$key);
04669                break;
04670                case 'cobj':
04671                   switch((string)$key) {
04672                      case 'parentRecordNumber':
04673                         $retVal = $this->parentRecordNumber;
04674                      break;
04675                   }
04676                break;
04677                case 'debug':
04678                   switch((string)$key) {
04679                      case 'rootLine':
04680                         $retVal = t3lib_div::view_array($GLOBALS['TSFE']->tmpl->rootLine);
04681                      break;
04682                      case 'fullRootLine':
04683                         $retVal = t3lib_div::view_array($GLOBALS['TSFE']->rootLine);
04684                      break;
04685                      case 'data':
04686                         $retVal = t3lib_div::view_array($this->data);
04687                      break;
04688                   }
04689                break;
04690             }
04691          }
04692       }
04693       return $retVal;
04694    }
04695 
04707    function rootLineValue($key,$field,$slideBack=0,$altRootLine='')  {
04708       $rootLine = is_array($altRootLine) ? $altRootLine : $GLOBALS['TSFE']->tmpl->rootLine;
04709       if (!$slideBack)  {
04710          return $rootLine[$key][$field];
04711       } else {
04712          for ($a=$key;$a>=0;$a--)   {
04713             $val = $rootLine[$a][$field];
04714             if ($val)   {return $val;}
04715          }
04716       }
04717    }
04718 
04729    function getGlobal($var, $source=NULL) {
04730       $vars = explode('|', $var);
04731       $c = count($vars);
04732       $theVar = isset($source) ? $source[trim($vars[0])] : $GLOBALS[trim($vars[0])];
04733       for ($a=1;$a<$c;$a++) {
04734          if (!isset($theVar)) {break;}
04735          $theVar = $theVar[trim($vars[$a])];
04736       }
04737       if (!is_array($theVar)) {
04738          return $theVar;
04739       } else {
04740          return '';
04741       }
04742    }
04743 
04754    function getKey($key,$arr) {
04755       $key = intval($key);
04756       if (is_array($arr))  {
04757          if ($key < 0)  {
04758             $key = count($arr)+$key;
04759          }
04760          if ($key < 0)  {
04761             $key=0;
04762          }
04763       }
04764       return $key;
04765    }
04766 
04767 
04768 
04769 
04770 
04771 
04772 
04773 
04774 
04775 
04776 
04777 
04778 
04779 
04780 
04781 
04782 
04783 
04784 
04785 
04786    /***********************************************
04787     *
04788     * Link functions (typolink)
04789     *
04790     ***********************************************/
04791 
04792 
04806    function typoLink($linktxt, $conf)  {
04807       $finalTagParts = array();
04808       $finalTagParts['aTagParams'] = $GLOBALS['TSFE']->ATagParams.($conf['ATagParams']?' '.$conf['ATagParams']:'');
04809 
04810       $link_param = trim($this->stdWrap($conf['parameter'],$conf['parameter.']));
04811       $sectionMark = trim($this->stdWrap($conf['section'],$conf['section.']));
04812       $sectionMark = $sectionMark ? '#'.$sectionMark : '';
04813       $initP = '?id='.$GLOBALS['TSFE']->id.'&type='.$GLOBALS['TSFE']->type;
04814       $this->lastTypoLinkUrl = '';
04815       $this->lastTypoLinkTarget = '';
04816       if ($link_param)  {
04817          $link_paramA = t3lib_div::trimExplode(' ',$link_param,1);
04818          $link_param = trim($link_paramA[0]);   // Link parameter value
04819          $linkClass = trim($link_paramA[2]);    // Link class
04820          $forceTarget = trim($link_paramA[1]);  // Target value
04821          if ($forceTarget=='-')  $forceTarget = '';   // The '-' character means 'no target'. Necessary in order to specify a class as third parameter without setting the target!
04822             // Check, if the target is coded as a JS open window link:
04823          $JSwindowParts = array();
04824          $JSwindowParams = '';
04825          $onClick = '';
04826          if ($forceTarget && ereg('^([0-9]+)x([0-9]+)(:(.*)|.*)$',$forceTarget,$JSwindowParts)) {
04827                // Take all pre-configured and inserted parameters and compile parameter list, including width+height:
04828             $JSwindow_tempParamsArr = t3lib_div::trimExplode(',',strtolower($conf['JSwindow_params'].','.$JSwindowParts[4]),1);
04829             $JSwindow_paramsArr=array();
04830             foreach($JSwindow_tempParamsArr as $JSv)  {
04831                list($JSp,$JSv) = explode('=',$JSv);
04832                $JSwindow_paramsArr[$JSp]=$JSp.'='.$JSv;
04833             }
04834                // Add width/height:
04835             $JSwindow_paramsArr['width']='width='.$JSwindowParts[1];
04836             $JSwindow_paramsArr['height']='height='.$JSwindowParts[2];
04837                // Imploding into string:
04838             $JSwindowParams = implode(',',$JSwindow_paramsArr);
04839             $forceTarget = '';   // Resetting the target since we will use onClick.
04840          }
04841 
04842             // Internal target:
04843          $target = isset($conf['target']) ? $conf['target'] : $GLOBALS['TSFE']->intTarget;
04844          if ($conf['target.'])   {$target=$this->stdWrap($target, $conf['target.']);}
04845 
04846             // Parse URL:
04847          $pU = parse_url($link_param);
04848 
04849             // Detecting kind of link:
04850          if(strstr($link_param,'@') && !$pU['scheme'])   {     // If it's a mail address:
04851             $link_param = eregi_replace('^mailto:','',$link_param);
04852             if ($linktxt=='') $linktxt = $link_param;
04853             if (!$GLOBALS['TSFE']->config['config']['jumpurl_enable'] || $GLOBALS['TSFE']->config['config']['jumpurl_mailto_disable']) {
04854                $this->lastTypoLinkUrl = 'mailto:'.$link_param;
04855                if ($GLOBALS['TSFE']->spamProtectEmailAddresses)   {
04856                   $this->lastTypoLinkUrl = "javascript:linkTo_UnCryptMailto('".$GLOBALS['TSFE']->encryptEmail($this->lastTypoLinkUrl)."');";
04857                   $atLabel = trim($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses_atSubst']);
04858                   $linktxt=str_replace('@',$atLabel?$atLabel:'(at)',$linktxt);
04859                }
04860             } else {
04861                $this->lastTypoLinkUrl = $GLOBALS['TSFE']->absRefPrefix.$GLOBALS['TSFE']->config['mainScript'].$initP.'&jumpurl='.rawurlencode('mailto:'.$link_param).$GLOBALS['TSFE']->getMethodUrlIdToken;
04862             }
04863             $finalTagParts['url']=$this->lastTypoLinkUrl;
04864             $finalTagParts['TYPE']='mailto';
04865          } else {
04866             $isLocalFile=0;
04867             $fileChar=intval(strpos($link_param, '/'));
04868             $urlChar=intval(strpos($link_param, '.'));
04869 
04870                // Detects if a file is found in site-root (or is a 'virtual' simulateStaticDocument file!) and if so it will be treated like a normal file.
04871             list($rootFileDat) = explode('?',rawurldecode($link_param));
04872             $containsSlash = strstr($rootFileDat,'/');
04873             $rFD_fI = pathinfo($rootFileDat);
04874             if (trim($rootFileDat) && !$containsSlash && (@is_file(PATH_site.$rootFileDat) || t3lib_div::inList('php,html,htm',strtolower($rFD_fI['extension']))))   {
04875                $isLocalFile = 1;
04876             } elseif ($containsSlash)  {
04877                $isLocalFile = 2;    // Adding this so realurl directories are linked right (non-existing).
04878             }
04879 
04880             if($pU['scheme'] || ($isLocalFile!=1 && $urlChar && (!$containsSlash || $urlChar<$fileChar)))   {  // url (external): If doubleSlash or if a '.' comes before a '/'.
04881                $target = isset($conf['extTarget']) ? $conf['extTarget'] : $GLOBALS['TSFE']->extTarget;
04882                if ($conf['extTarget.'])   {$target = $this->stdWrap($target, $conf['extTarget.']);}
04883                if ($forceTarget) {$target=$forceTarget;}
04884                if ($linktxt=='') $linktxt = $link_param;
04885                if (!$pU['scheme'])  {$scheme='http://';} else {$scheme='';}
04886                if ($GLOBALS['TSFE']->config['config']['jumpurl_enable'])   {
04887                   $this->lastTypoLinkUrl = $GLOBALS['TSFE']->absRefPrefix.$GLOBALS['TSFE']->config['mainScript'].$initP.'&jumpurl='.rawurlencode($scheme.$link_param).$GLOBALS['TSFE']->getMethodUrlIdToken;
04888                } else {
04889                   $this->lastTypoLinkUrl = $scheme.$link_param;
04890                }
04891                $this->lastTypoLinkTarget = $target;
04892                $finalTagParts['url']=$this->lastTypoLinkUrl;
04893                $finalTagParts['targetParams'] = $target ? ' target="'.$target.'"' : '';
04894                $finalTagParts['TYPE']='url';
04895             } elseif ($containsSlash || $isLocalFile) {  // file (internal)
04896                $splitLinkParam = explode('?', $link_param);
04897                if (@file_exists(rawurldecode($splitLinkParam[0])) || $isLocalFile)  {
04898                   if ($linktxt=='') $linktxt = rawurldecode($link_param);
04899                   if ($GLOBALS['TSFE']->config['config']['jumpurl_enable'])   {
04900                      $this->lastTypoLinkUrl = $GLOBALS['TSFE']->absRefPrefix.$GLOBALS['TSFE']->config['mainScript'].$initP.'&jumpurl='.rawurlencode($link_param).$GLOBALS['TSFE']->getMethodUrlIdToken;
04901                   } else {
04902                      $this->lastTypoLinkUrl = $GLOBALS['TSFE']->absRefPrefix.$link_param;
04903                   }
04904                   if ($forceTarget) {$target=$forceTarget;}
04905                   $this->lastTypoLinkTarget = $target;
04906 
04907                   $finalTagParts['url'] = $this->lastTypoLinkUrl;
04908                   $finalTagParts['targetParams'] = $target ? ' target="'.$target.'"' : '';
04909                   $finalTagParts['TYPE'] = 'file';
04910                } else {
04911                   $GLOBALS['TT']->setTSlogMessage("typolink(): File '".$splitLinkParam[0]."' did not exist, so '".$linktxt."' was not linked.",1);
04912                   return $linktxt;
04913                }
04914             } else { // integer or alias (alias is without slashes or periods or commas, that is 'nospace,alphanum_x,lower,unique' according to tables.php!!)
04915                if ($conf['no_cache.']) $conf['no_cache']=$this->stdWrap($conf['no_cache'], $conf['no_cache.']);
04916                $link_params_parts=explode('#',$link_param);
04917                $link_param = trim($link_params_parts[0]);      // Link-data del
04918                if (!strcmp($link_param,''))  {$link_param=$GLOBALS['TSFE']->id;} // If no id or alias is given
04919                if ($link_params_parts[1] && !$sectionMark)  {
04920                   $sectionMark='#'.trim($link_params_parts[1]);
04921                }
04922                   // Splitting the parameter by ',' and if the array counts more than 1 element it's a id/type/? pair
04923                unset($theTypeP);
04924                $pairParts = t3lib_div::trimExplode(',',$link_param);
04925                if (count($pairParts)>1)   {
04926                   $link_param = $pairParts[0];
04927                   $theTypeP = $pairParts[1];    // Overruling 'type'
04928                }
04929                   // Checking if the id-parameter is an alias.
04930                if (!t3lib_div::testInt($link_param))  {
04931                   $link_param = $GLOBALS['TSFE']->sys_page->getPageIdFromAlias($link_param);
04932                }
04933 
04934                   // Looking up the page record to verify its existence:
04935                $page = $GLOBALS['TSFE']->sys_page->getPage($link_param);
04936                if (count($page)) {
04937                      // This checks if the linked id is in the rootline of this site and if not it will find the domain for that ID and prefix it:
04938                   $tCR_domain='';
04939                   if ($GLOBALS['TSFE']->config['config']['typolinkCheckRootline'])  {
04940                      $tCR_rootline = $GLOBALS['TSFE']->sys_page->getRootLine($page['uid']);  // Gets rootline of linked-to page
04941                      $tCR_flag = 0;
04942                      foreach($tCR_rootline as $tCR_data) {
04943                         if ($tCR_data['uid']==$GLOBALS['TSFE']->tmpl->rootLine[0]['uid']) {
04944                            $tCR_flag = 1; // OK, it was in rootline!
04945                            break;
04946                         }
04947                      }
04948                      if (!$tCR_flag)   {
04949                         foreach($tCR_rootline as $tCR_data) {
04950                            $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_domain', 'pid='.intval($tCR_data['uid']).' AND redirectTo=""'.$this->enableFields('sys_domain'), '', 'sorting');
04951                            if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))  {
04952                               $tCR_domain = ereg_replace('\/$','',$row['domainName']);
04953                               break;
04954                            }
04955                         }
04956                      }
04957                   }
04958                      // MointPoints, look for closest MPvar:
04959                   $MPvarAcc = array();
04960                   if (!$GLOBALS['TSFE']->config['config']['MP_disableTypolinkClosestMPvalue'])  {
04961                      $temp_MP = $this->getClosestMPvalueForPage($page['uid'],TRUE);
04962                      if ($temp_MP)  $MPvarAcc['closest'] = $temp_MP;
04963                   }
04964                      // Look for overlay Mount Point:
04965                   $mount_info = $GLOBALS['TSFE']->sys_page->getMountPointInfo($page['uid'], $page);
04966                   if (is_array($mount_info) && $mount_info['overlay'])  {
04967                      $page = $GLOBALS['TSFE']->sys_page->getPage($mount_info['mount_pid']);
04968                      if (!count($page))   {
04969                         $GLOBALS['TT']->setTSlogMessage("typolink(): Mount point '".$mount_info['mount_pid']."' was not available, so '".$linktxt."' was not linked.",1);
04970                         return $linktxt;
04971                      }
04972                      $MPvarAcc['re-map'] = $mount_info['MPvar'];
04973                   }
04974 
04975                      // Setting title if blank value to link:
04976                   if ($linktxt=='') $linktxt = $page['title'];
04977 
04978                      // Query Params:
04979                   $addQueryParams = trim($this->stdWrap($conf['additionalParams'],$conf['additionalParams.']));
04980                   if (substr($addQueryParams,0,1)!='&')     {
04981                      $addQueryParams = '';
04982                   } elseif ($conf['useCacheHash']) {  // cache hashing:
04983                      $pA = $GLOBALS['TSFE']->cHashParams($addQueryParams.$GLOBALS['TSFE']->linkVars); // Added '.$this->linkVars' dec 2003: The need for adding the linkVars is that they will be included in the link, but not the cHash. Thus the linkVars will always be the problem that prevents the cHash from working. I cannot see what negative implications in terms of incompatibilities this could bring, but for now I hope there are none. So here we go... (- kasper)
04984                      $addQueryParams.= '&cHash='.t3lib_div::shortMD5(serialize($pA));
04985                   }
04986                      // Add "&MP" var:
04987                   if (count($MPvarAcc))   {
04988                      $addQueryParams.= '&MP='.rawurlencode(implode(',',$MPvarAcc));
04989                   }
04990                      // If other domain, overwrite
04991                   if ($tCR_domain)  {
04992                      $target = isset($conf['extTarget']) ? $conf['extTarget'] : $GLOBALS['TSFE']->extTarget;
04993                      if ($conf['extTarget.'])   {$target = $this->stdWrap($target, $conf['extTarget.']);}
04994                      if ($forceTarget) {$target=$forceTarget;}
04995                      $LD['target'] = $target;
04996                      $this->lastTypoLinkUrl = $this->URLqMark('http://'.$tCR_domain.'/?id='.$page['uid'],$addQueryParams).$sectionMark;
04997                   } else { // Internal link:
04998                      if ($forceTarget) {$target=$forceTarget;}
04999                      $LD = $GLOBALS['TSFE']->tmpl->linkData($page,$target,$conf['no_cache'],'','',$addQueryParams,$theTypeP);
05000                      $this->lastTypoLinkUrl = $this->URLqMark($LD['totalURL'],'').$sectionMark;
05001                   }
05002 
05003                   $this->lastTypoLinkTarget = $LD['target'];
05004                   $targetPart = $LD['target'] ? ' target="'.$LD['target'].'"' : '';
05005 
05006                      // If sectionMark is set AND the current page is the page the link is to, check if there are any additional parameters and is not, drop the url.
05007                   if ($sectionMark && !trim($addQueryParams) && $page['uid']==$GLOBALS['TSFE']->id)   {
05008                      list(,$URLparams) = explode('?',$this->lastTypoLinkUrl);
05009                      list($URLparams) = explode('#',$URLparams);
05010                      parse_str ($URLparams.$LD['orig_type'], $URLparamsArray);
05011                      if (intval($URLparamsArray['type'])==$GLOBALS['TSFE']->type)   {  // type nums must match as well as page ids
05012                         unset($URLparamsArray['id']);
05013                         unset($URLparamsArray['type']);
05014                         if (!count($URLparamsArray))  {  // If there are no parameters left.... set the new url.
05015                            $this->lastTypoLinkUrl = $sectionMark;
05016                         }
05017                      }
05018                   }
05019                      // Rendering the tag.
05020                   $finalTagParts['url']=$this->lastTypoLinkUrl;
05021                   $finalTagParts['targetParams']=$targetPart;
05022                   $finalTagParts['TYPE']='page';
05023                } else {
05024                   $GLOBALS['TT']->setTSlogMessage("typolink(): Page id '".$link_param."' was not found, so '".$linktxt."' was not linked.",1);
05025                   return $linktxt;
05026                }
05027             }
05028          }
05029 
05030          if ($JSwindowParams) {
05031             $onClick="vHWin=window.open('".$GLOBALS['TSFE']->baseUrlWrap($finalTagParts['url'])."','FEopenLink','".$JSwindowParams."');vHWin.focus();return false;";
05032             $res = '<a href="#" onclick="'.htmlspecialchars($onClick).'"'.($linkClass?' class="'.$linkClass.'"':'').$finalTagParts['aTagParams'].'>';
05033          } else {
05034             $res = '<a href="'.htmlspecialchars($finalTagParts['url']).'"'.$finalTagParts['targetParams'].($linkClass?' class="'.$linkClass.'"':'').$finalTagParts['aTagParams'].'>';
05035          }
05036 
05037             // Call user function:
05038          if ($conf['userFunc'])  {
05039             $finalTagParts['TAG']=$res;
05040             $res = $this->callUserFunction($conf['userFunc'],$conf['userFunc.'],$finalTagParts);
05041          }
05042 
05043             // If flag "returnLastTypoLinkUrl" set, then just return the latest URL made:
05044          if ($conf['returnLast'])   {
05045             switch($conf['returnLast'])   {
05046                case 'url':
05047                   return $this->lastTypoLinkUrl;
05048                break;
05049                case 'target':
05050                   return $this->lastTypoLinkTarget;
05051                break;
05052             }
05053          }
05054 
05055          if ($conf['ATagBeforeWrap'])  {
05056             return $res.$this->wrap($linktxt, $conf['wrap']).'</a>';
05057          } else {
05058             return $this->wrap($res.$linktxt.'</a>', $conf['wrap']);
05059          }
05060       } else {
05061          return $linktxt;
05062       }
05063    }
05064 
05073    function typoLink_URL($conf)  {
05074       $this->typolink('|',$conf);
05075       return $this->lastTypoLinkUrl;
05076    }
05077 
05091    function getTypoLink($label,$params,$urlParameters=array(),$target='')  {
05092       $conf=array();
05093       $conf['parameter'] = $params;
05094       if ($target)   {
05095          $conf['target']=$target;
05096          $conf['extTarget']=$target;
05097       }
05098       if (is_array($urlParameters)) {
05099          if (count($urlParameters)) {
05100             reset($urlParameters);
05101             while(list($k,$v)=each($urlParameters))   {
05102                $conf['additionalParams'].='&'.$k.'='.rawurlencode($v);
05103             }
05104          }
05105       } else {
05106          $conf['additionalParams'].=$urlParameters;
05107       }
05108       $out = $this->typolink($label,$conf);
05109       return $out;
05110    }
05111 
05121    function getTypoLink_URL($params,$urlParameters=array(),$target='')  {
05122       $this->getTypoLink('',$params,$urlParameters,$target);
05123       return $this->lastTypoLinkUrl;
05124    }
05125 
05133    function typolinkWrap($conf)  {
05134       $k=md5(microtime());
05135       return explode($k,$this->typolink($k,$conf));
05136    }
05137 
05146    function currentPageUrl($urlParameters=array(),$id=0) {
05147       return $this->getTypoLink_URL($id?$id:$GLOBALS['TSFE']->id,$urlParameters,$GLOBALS['TSFE']->sPre);
05148    }
05149 
05159    function getClosestMPvalueForPage($pageId, $raw=FALSE)   {
05160          // MointPoints:
05161       if ($GLOBALS['TYPO3_CONF_VARS']['FE']['enable_mount_pids'] && $GLOBALS['TSFE']->MP) {
05162 
05163          if (!strcmp($GLOBALS['TSFE']->id, $pageId))  {  // same page as current.
05164             $MP = $GLOBALS['TSFE']->MP;
05165          } else { // ... otherwise find closest meeting point:
05166             $tCR_rootline = $GLOBALS['TSFE']->sys_page->getRootLine($pageId, '', TRUE);   // Gets rootline of linked-to page
05167             $inverseTmplRootline = array_reverse($GLOBALS['TSFE']->tmpl->rootLine);
05168 
05169             $rl_mpArray = array();
05170             $startMPaccu = FALSE;
05171 
05172                // Traverse root line of link uid and inside of that the REAL root line of current position.
05173             foreach($tCR_rootline as $tCR_data) {
05174                foreach($inverseTmplRootline as $rlKey => $invTmplRLRec) {
05175 
05176                      // Accumulate MP data:
05177                   if ($startMPaccu && $invTmplRLRec['_MP_PARAM']) {
05178                      $rl_mpArray[] = $invTmplRLRec['_MP_PARAM'];
05179                   }
05180 
05181                      // If two PIDs matches and this is NOT the site root, start accumulation of MP data (on the next level):
05182                      // (The check for site root is done so links to branches outsite the site but sharing the site roots PID is NOT detected as within the branch!)
05183                   if ($tCR_data['pid']==$invTmplRLRec['pid'] && count($inverseTmplRootline)!=$rlKey+1)   {
05184                      $startMPaccu = TRUE;
05185                   }
05186                }
05187                if ($startMPaccu) break;   // Good enough...
05188             }
05189 
05190             if (count($rl_mpArray)) {
05191                $MP = implode(',', array_reverse($rl_mpArray));
05192             }
05193          }
05194       }
05195 
05196       return !$raw  ? ($MP ? '&MP='.rawurlencode($MP) : '') : $MP;
05197    }
05198 
05199 
05200 
05201 
05202 
05203 
05204 
05205 
05206 
05207 
05208 
05209 
05210 
05211 
05212 
05213 
05214 
05215 
05216 
05217 
05218    /***********************************************
05219     *
05220     * Miscellaneous functions, stand alone
05221     *
05222     ***********************************************/
05223 
05235    function wrap($content,$wrap,$char='|')   {
05236       if ($wrap)  {
05237          $wrapArr = explode($char, $wrap);
05238          return trim($wrapArr[0]).$content.trim($wrapArr[1]);
05239       } else return $content;
05240    }
05241 
05251    function noTrimWrap($content,$wrap) {
05252       if ($wrap)  {
05253          $wrapArr = explode('|', $wrap);
05254          return $wrapArr[1].$content.$wrapArr[2];
05255       } else return $content;
05256    }
05257 
05265    function wrapSpace($content, $wrap) {
05266       $result = $content;
05267       if (trim($wrap))  {
05268          $wrapArray = explode('|',$wrap);
05269          $wrapBefore = intval($wrapArray[0]);
05270          $wrapAfter = intval($wrapArray[1]);
05271          if ($wrapBefore)  {
05272             $result = '<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$wrapBefore.'" border="0" class="spacer-gif" alt="" title="" /><br />'.$result;
05273          }
05274          if ($wrapAfter)   {
05275             $result.='<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$wrapAfter.'" border="0" class="spacer-gif" alt="" title="" /><br />';
05276          }
05277       }
05278       return $result;
05279    }
05280 
05291    function callUserFunction($funcName,$conf,$content)   {
05292       $pre = $GLOBALS['TSFE']->TYPO3_CONF_VARS['FE']['userFuncClassPrefix'];
05293       if ($pre &&
05294          !t3lib_div::isFirstPartOfStr(trim($funcName),$pre) &&
05295          !t3lib_div::isFirstPartOfStr(trim($funcName),'tx_')
05296          )  {
05297          $GLOBALS['TT']->setTSlogMessage('Function "'.$funcName.'" was not prepended with "'.$pre.'"',3);
05298          return $content;
05299       }
05300          // Split parts
05301       $parts = explode('->',$funcName);
05302       if (count($parts)==2)   {  // Class
05303          $cls = t3lib_div::makeInstanceClassName($parts[0]);
05304          if (class_exists ($cls))   {
05305             $classObj = new $cls;
05306             if (method_exists($classObj, $parts[1]))  {
05307                $classObj->cObj = &$this;
05308                $content = call_user_method($parts[1], $classObj, $content, $conf);
05309             } else {
05310                $GLOBALS['TT']->setTSlogMessage('Method "'.$parts[1].'" did not exist in class "'.$cls.'"',3);
05311             }
05312          } else {
05313             $GLOBALS['TT']->setTSlogMessage('Class "'.$cls.'" did not exist',3);
05314          }
05315       } else { // Function
05316          if (function_exists($funcName))  {
05317             $content = call_user_func($funcName, $content, $conf);
05318          } else {
05319             $GLOBALS['TT']->setTSlogMessage('Function "'.$funcName.'" did not exist',3);
05320          }
05321       }
05322       return $content;
05323    }
05324 
05332    function processParams($params)  {
05333       $paramArr=array();
05334       $lines=t3lib_div::trimExplode(chr(10),$params,1);
05335       foreach($lines as $val) {
05336          $pair = explode('=',$val,2);
05337          if (!t3lib_div::inList('#,/',substr(trim($pair[0]),0,1)))   {
05338             $paramArr[trim($pair[0])] = trim($pair[1]);
05339          }
05340       }
05341       return $paramArr;
05342    }
05343 
05350    function keywords($content)   {
05351       $listArr = split(',|;|'.chr(10),$content);
05352       reset($listArr);
05353       while(list($k,$v)=each($listArr))   {
05354          $listArr[$k]=trim($v);
05355       }
05356       return implode(',',$listArr);
05357    }
05358 
05367    function caseshift($theValue, $case)   {
05368       $case = strtolower($case);
05369       switch($case)  {
05370          case 'upper':
05371             $theValue = $GLOBALS['TSFE']->csConvObj->conv_case($GLOBALS['TSFE']->renderCharset,$theValue,'toUpper');
05372             #$theValue = strtoupper($theValue);
05373             #$theValue = strtr($theValue, $this->caseConvStrings[0], $this->caseConvStrings[1]);
05374          break;
05375          case 'lower':
05376             $theValue = $GLOBALS['TSFE']->csConvObj->conv_case($GLOBALS['TSFE']->renderCharset,$theValue,'toLower');
05377             #$theValue = strtolower($theValue);
05378             #$theValue = strtr($theValue, $this->caseConvStrings[1], $this->caseConvStrings[0]);
05379          break;
05380       }
05381       return $theValue;
05382    }
05383 
05392    function HTMLcaseshift($theValue, $case)  {
05393       $inside = 0;
05394       $newVal = '';
05395       $pointer = 0;
05396       $totalLen = strlen($theValue);
05397       do {
05398          if (!$inside)  {
05399             $len = strcspn(substr($theValue,$pointer),'<');
05400             $newVal.= $this->caseshift(substr($theValue,$pointer,$len),$case);
05401             $inside = 1;
05402          } else {
05403             $len = strcspn(substr($theValue,$pointer),'>')+1;
05404             $newVal.= substr($theValue,$pointer,$len);
05405             $inside = 0;
05406          }
05407          $pointer+=$len;
05408       } while($pointer<$totalLen);
05409       return $newVal;
05410    }
05411 
05421    function bytes($sizeInBytes,$labels)   {
05422       return t3lib_div::formatSize($sizeInBytes,$labels);
05423    }
05424 
05432    function calcAge($seconds,$labels)  {
05433       if (t3lib_div::testInt($labels)) {
05434          $labels = ' min| hrs| days| yrs';
05435       } else {
05436          $labels=str_replace('"','',$labels);
05437       }
05438 
05439       $labelArr = explode('|',$labels);
05440       if ($seconds<3600)   {
05441          $seconds = round ($seconds/60).$labelArr[0];
05442       } elseif ($seconds<24*3600)   {
05443          $seconds = round ($seconds/3600).$labelArr[1];
05444       } elseif ($seconds<365*24*3600)  {
05445          $seconds = round ($seconds/(24*3600)).$labelArr[2];
05446       } else {
05447          $seconds = round ($seconds/(365*24*3600)).$labelArr[3];
05448       }
05449       return $seconds;
05450    }
05451 
05463    function sendNotifyEmail($msg, $recipients, $cc, $email_from, $email_fromName='', $replyTo='')  {
05464          // Sends order emails:
05465       $headers=array();
05466       if ($email_from)  {$headers[]='From: '.$email_fromName.' <'.$email_from.'>';}
05467       if ($replyTo)     {$headers[]='Reply-To: '.$replyTo;}
05468 
05469       $recipients=implode(',',t3lib_div::trimExplode(',',$recipients,1));
05470 
05471       $emailContent = trim($msg);
05472       if ($emailContent)   {
05473          $parts = split(chr(10),$emailContent,2);     // First line is subject
05474          $subject=trim($parts[0]);
05475          $plain_message=trim($parts[1]);
05476 
05477          if ($recipients)  $GLOBALS['TSFE']->plainMailEncoded($recipients, $subject, $plain_message, implode(chr(10),$headers));
05478          if ($cc) $GLOBALS['TSFE']->plainMailEncoded($cc, $subject, $plain_message, implode(chr(10),$headers));
05479          return true;
05480       }
05481    }
05482 
05490    function URLqMark($url,$params)  {
05491       if ($params && !strstr($url,'?'))   {
05492          return $url.'?'.$params;
05493       } else {
05494          return $url.$params;
05495       }
05496    }
05497 
05506    function checkEmail($email)   {
05507       return t3lib_div::validEmail($email);
05508    }
05509 
05518    function clearTSProperties($TSArr,$propList) {
05519       $list = explode(',',$propList);
05520       while(list(,$prop)=each($list))  {
05521          $prop = trim($prop);
05522          unset($TSArr[$prop]);
05523          unset($TSArr[$prop.'.']);
05524       }
05525       return $TSArr;
05526    }
05527 
05537    function mergeTSRef($confArr,$prop) {
05538       if (substr($confArr[$prop],0,1)=='<')  {
05539          $key = trim(substr($confArr[$prop],1));
05540          $cF = t3lib_div::makeInstance('t3lib_TSparser');
05541             // $name and $conf is loaded with the referenced values.
05542          $old_conf=$confArr[$prop.'.'];
05543          list($name, $conf) = $cF->getVal($key,$GLOBALS['TSFE']->tmpl->setup);
05544          if (is_array($old_conf) && count($old_conf)) {
05545             $conf = $this->joinTSarrays($conf,$old_conf);
05546          }
05547          $confArr[$prop.'.']=$conf;
05548       }
05549       return $confArr;
05550    }
05551 
05560    function joinTSarrays($conf,$old_conf) {
05561       if (is_array($old_conf))   {
05562          reset($old_conf);
05563          while(list($key,$val)=each($old_conf)) {
05564             if (is_array($val))  {
05565                $conf[$key] = $this->joinTSarrays($conf[$key],$val);
05566             } else {
05567                $conf[$key] = $val;
05568             }
05569          }
05570       }
05571       return $conf;
05572    }
05573 
05583    function gifBuilderTextBox($gifbuilderConf, $conf, $text)   {
05584       $chars = intval($conf['chars']) ? intval($conf['chars']) : 20;
05585       $lineDist = intval($conf['lineDist']) ? intval($conf['lineDist']) : 20;
05586       $Valign = strtolower(trim($conf['Valign']));
05587       $tmplObjNumber = intval($conf['tmplObjNumber']);
05588       $maxLines = intval($conf['maxLines']);
05589 
05590       if ($tmplObjNumber && $gifbuilderConf[$tmplObjNumber]=='TEXT') {
05591          $textArr = $this->linebreaks($text,$chars,$maxLines);
05592          $angle = intval($gifbuilderConf[$tmplObjNumber.'.']['angle']);
05593          reset($textArr);
05594          while(list($c,$textChunk)=each($textArr)) {
05595             $index = $tmplObjNumber+1+($c*2);
05596                // Workarea
05597             $gifbuilderConf = $this->clearTSProperties($gifbuilderConf,$index);
05598             $rad_angle = 2*pi()/360*$angle;
05599             $x_d = sin($rad_angle)*$lineDist;
05600             $y_d = cos($rad_angle)*$lineDist;
05601 
05602             $diff_x_d=0;
05603             $diff_y_d=0;
05604             if ($Valign=='center')  {
05605                $diff_x_d = $x_d*count($textArr);
05606                $diff_x_d = $diff_x_d/2;
05607                $diff_y_d = $y_d*count($textArr);
05608                $diff_y_d = $diff_y_d/2;
05609             }
05610 
05611 
05612             $x_d = round($x_d*$c - $diff_x_d);
05613             $y_d = round($y_d*$c - $diff_y_d);
05614 
05615             $gifbuilderConf[$index] = 'WORKAREA';
05616             $gifbuilderConf[$index.'.']['set'] = $x_d.','.$y_d;
05617                // Text
05618             $index++;
05619             $gifbuilderConf = $this->clearTSProperties($gifbuilderConf,$index);
05620             $gifbuilderConf[$index] = 'TEXT';
05621             $gifbuilderConf[$index.'.'] = $this->clearTSProperties($gifbuilderConf[$tmplObjNumber.'.'],'text');
05622             $gifbuilderConf[$index.'.']['text'] = $textChunk;
05623          }
05624          $gifbuilderConf = $this->clearTSProperties($gifbuilderConf,$tmplObjNumber);
05625       }
05626       return $gifbuilderConf;
05627    }
05628 
05639    function linebreaks($string,$chars,$maxLines=0) {
05640       $lines = explode(chr(10),$string);
05641       $lineArr=Array();
05642       $c=0;
05643       while(list(,$paragraph)=each($lines))  {
05644          $words = explode(' ',$paragraph);
05645          while(list(,$word)=each($words)) {
05646             if (strlen($lineArr[$c].$word)>$chars) {
05647                $c++;
05648             }
05649             if (!$maxLines || $c<$maxLines)  {
05650                $lineArr[$c].= $word.' ';
05651             }
05652          }
05653          $c++;
05654       }
05655       return $lineArr;
05656    }
05657 
05670    function getUpdateJS($dataArray, $formName, $arrPrefix, $fieldList)  {
05671       $JSPart='';
05672       $updateValues=t3lib_div::trimExplode(',',$fieldList);
05673       while(list(,$fKey)=each($updateValues))   {
05674          $value = $dataArray[$fKey];
05675          if (is_array($value))   {
05676             reset($value);
05677             while(list(,$Nvalue)=each($value))  {
05678                $JSPart.="
05679    updateForm('".$formName."','".$arrPrefix."[".$fKey."][]',unescape('".rawurlencode($Nvalue)."'))";
05680             }
05681 
05682          } else {
05683             $JSPart.="
05684    updateForm('".$formName."','".$arrPrefix."[".$fKey."]',unescape('".rawurlencode($value)."'))";
05685          }
05686       }
05687       $JSPart='<script type="text/javascript">
05688    /*<![CDATA[*/ '.$JSPart.'
05689    /*]]>*/
05690 </script>
05691 ';
05692       $GLOBALS['TSFE']->additionalHeaderData['JSincludeFormupdate']='<script type="text/javascript" src="'.$GLOBALS['TSFE']->absRefPrefix.'t3lib/jsfunc.updateform.js"></script>';
05693       return $JSPart;
05694    }
05695 
05696 
05697 
05698 
05699 
05700 
05701 
05702 
05703 
05704 
05705 
05706 
05707 
05708 
05709 
05710 
05711 
05712 
05713 
05714 
05715 
05716 
05717 
05718 
05719 
05720 
05721 
05722 
05723    /***********************************************
05724     *
05725     * Database functions, making of queries
05726     *
05727     ***********************************************/
05728 
05739    function DBgetDelete($table, $uid, $doExec=FALSE)  {
05740       if (intval($uid)) {
05741          if ($GLOBALS['TCA'][$table]['ctrl']['delete'])  {
05742             if ($doExec)   {
05743                return $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid='.intval($uid), array($GLOBALS['TCA'][$table]['ctrl']['delete'] => 1));
05744             } else {
05745                return $GLOBALS['TYPO3_DB']->UPDATEquery($table, 'uid='.intval($uid), array($GLOBALS['TCA'][$table]['ctrl']['delete'] => 1));
05746             }
05747          } else {
05748             if ($doExec)   {
05749                return $GLOBALS['TYPO3_DB']->exec_DELETEquery($table, 'uid='.intval($uid));
05750             } else {
05751                return $GLOBALS['TYPO3_DB']->DELETEquery($table, 'uid='.intval($uid));
05752             }
05753          }
05754       }
05755    }
05756 
05771    function DBgetUpdate($table, $uid, $dataArr, $fieldList, $doExec=FALSE) {
05772       unset($dataArr['uid']); // uid can never be set
05773       $uid=intval($uid);
05774 
05775       if ($uid)   {
05776          $fieldList = implode(',',t3lib_div::trimExplode(',',$fieldList,1));
05777          $updateFields=array();
05778 
05779          foreach($dataArr as $f => $v) {
05780             if (t3lib_div::inList($fieldList,$f))  {
05781                $updateFields[$f] = $v;
05782             }
05783          }
05784 
05785          if ($GLOBALS['TCA'][$table]['ctrl']['tstamp'])  {
05786             $updateFields[$GLOBALS['TCA'][$table]['ctrl']['tstamp']] = time();
05787          }
05788 
05789          if (count($updateFields))  {
05790             if ($doExec)   {
05791                return $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid='.intval($uid), $updateFields);
05792             } else {
05793                return $GLOBALS['TYPO3_DB']->UPDATEquery($table, 'uid='.intval($uid), $updateFields);
05794             }
05795          }
05796       }
05797    }
05798 
05813    function DBgetInsert($table, $pid, $dataArr, $fieldList, $doExec=FALSE) {
05814       $extraList='pid';
05815       if ($GLOBALS['TCA'][$table]['ctrl']['tstamp'])  {$field=$GLOBALS['TCA'][$table]['ctrl']['tstamp']; $dataArr[$field]=time(); $extraList.=','.$field;}
05816       if ($GLOBALS['TCA'][$table]['ctrl']['crdate'])  {$field=$GLOBALS['TCA'][$table]['ctrl']['crdate']; $dataArr[$field]=time(); $extraList.=','.$field;}
05817       if ($GLOBALS['TCA'][$table]['ctrl']['cruser_id'])  {$field=$GLOBALS['TCA'][$table]['ctrl']['cruser_id']; $dataArr[$field]=0; $extraList.=','.$field;}
05818       if ($GLOBALS['TCA'][$table]['ctrl']['fe_cruser_id'])  {$field=$GLOBALS['TCA'][$table]['ctrl']['fe_cruser_id']; $dataArr[$field]=intval($GLOBALS['TSFE']->fe_user->user['uid']); $extraList.=','.$field;}
05819       if ($GLOBALS['TCA'][$table]['ctrl']['fe_crgroup_id']) {$field=$GLOBALS['TCA'][$table]['ctrl']['fe_crgroup_id']; list($dataArr[$field])=explode(',',$GLOBALS['TSFE']->fe_user->user['usergroup']); $dataArr[$field]=intval($dataArr[$field]); $extraList.=','.$field;}
05820 
05821       unset($dataArr['uid']); // uid can never be set
05822       if ($pid>=0)   { $dataArr['pid'] = $pid; }      // Set pid < 0 and the dataarr-pid will be used!
05823       $fieldList = implode(',',t3lib_div::trimExplode(',',$fieldList.','.$extraList,1));
05824 
05825       $insertFields = array();
05826       foreach($dataArr as $f => $v) {
05827          if (t3lib_div::inList($fieldList,$f))  {
05828             $insertFields[$f] = $v;
05829          }
05830       }
05831 
05832       if ($doExec)   {
05833          return $GLOBALS['TYPO3_DB']->exec_INSERTquery($table, $insertFields);
05834       } else {
05835          return $GLOBALS['TYPO3_DB']->INSERTquery($table, $insertFields);
05836       }
05837    }
05838 
05850    function DBmayFEUserEdit($table,$row, $feUserRow, $allowedGroups='',$feEditSelf=0)  {
05851       $groupList = $allowedGroups ? implode(',',array_intersect(t3lib_div::trimExplode(',',$feUserRow['usergroup'],1),t3lib_div::trimExplode(',',$allowedGroups,1))) : $feUserRow['usergroup'];
05852       $ok=0;
05853          // points to the field that allows further editing from frontend if not set. If set the record is locked.
05854       if (!$GLOBALS['TCA'][$table]['ctrl']['fe_admin_lock'] || !$row[$GLOBALS['TCA'][$table]['ctrl']['fe_admin_lock']]) {
05855             // points to the field (integer) that holds the fe_users-id of the creator fe_user
05856          if ($GLOBALS['TCA'][$table]['ctrl']['fe_cruser_id'])  {
05857             $rowFEUser = intval($row[$GLOBALS['TCA'][$table]['ctrl']['fe_cruser_id']]);
05858             if ($rowFEUser && $rowFEUser==$feUserRow['uid'])   {
05859                $ok=1;
05860             }
05861          }
05862             // If $feEditSelf is set, fe_users may always edit them selves...
05863          if ($feEditSelf && $table=='fe_users' && !strcmp($feUserRow['uid'],$row['uid'])) {
05864             $ok=1;
05865          }
05866             // points to the field (integer) that holds the fe_group-id of the creator fe_user's first group
05867          if ($GLOBALS['TCA'][$table]['ctrl']['fe_crgroup_id']) {
05868             $rowFEUser = intval($row[$GLOBALS['TCA'][$table]['ctrl']['fe_crgroup_id']]);
05869             if ($rowFEUser)   {
05870                if (t3lib_div::inList($groupList, $rowFEUser))  {
05871                   $ok=1;
05872                }
05873             }
05874          }
05875       }
05876       return $ok;
05877    }
05878 
05890    function DBmayFEUserEditSelect($table,$feUserRow,$allowedGroups='',$feEditSelf=0)   {
05891          // Returns where-definition that selects user-editable records.
05892       $groupList = $allowedGroups ? implode(',',array_intersect(t3lib_div::trimExplode(',',$feUserRow['usergroup'],1),t3lib_div::trimExplode(',',$allowedGroups,1))) : $feUserRow['usergroup'];
05893       $OR_arr=array();
05894          // points to the field (integer) that holds the fe_users-id of the creator fe_user
05895       if ($GLOBALS['TCA'][$table]['ctrl']['fe_cruser_id'])  {
05896          $OR_arr[]=$GLOBALS['TCA'][$table]['ctrl']['fe_cruser_id'].'='.$feUserRow['uid'];
05897       }
05898          // points to the field (integer) that holds the fe_group-id of the creator fe_user's first group
05899       if ($GLOBALS['TCA'][$table]['ctrl']['fe_crgroup_id']) {
05900          $values = t3lib_div::intExplode(',',$groupList);
05901          while(list(,$theGroupUid)=each($values))  {
05902             if ($theGroupUid) {$OR_arr[]=$GLOBALS['TCA'][$table]['ctrl']['fe_crgroup_id'].'='.$theGroupUid;}
05903          }
05904       }
05905          // If $feEditSelf is set, fe_users may always edit them selves...
05906       if ($feEditSelf && $table=='fe_users') {
05907          $OR_arr[]='uid='.intval($feUserRow['uid']);
05908       }
05909 
05910       $whereDef=' AND 1=0';
05911       if (count($OR_arr))  {
05912          $whereDef=' AND ('.implode(' OR ',$OR_arr).')';
05913          if ($GLOBALS['TCA'][$table]['ctrl']['fe_admin_lock']) {
05914             $whereDef.=' AND NOT '.$GLOBALS['TCA'][$table]['ctrl']['fe_admin_lock'];
05915          }
05916       }
05917       return $whereDef;
05918    }
05919 
05930    function enableFields($table,$show_hidden=0) {
05931       return $GLOBALS['TSFE']->sys_page->enableFields($table,$show_hidden?$show_hidden:($table=='pages' ? $GLOBALS['TSFE']->showHiddenPage : $GLOBALS['TSFE']->showHiddenRecords));
05932    }
05933 
05954    function getTreeList($id,$depth,$begin=0,$dontCheckEnableFields=FALSE,$addSelectFields='',$moreWhereClauses='', $prevId_array=array(), $recursionLevel=0)   {
05955 
05956          // Init vars:
05957       $allFields = 'uid,hidden,starttime,endtime,fe_group,extendToSubpages,doktype,php_tree_stop,mount_pid,mount_pid_ol'.$addSelectFields;
05958       $depth = intval($depth);
05959       $begin = intval($begin);
05960       $id = intval($id);
05961       $theList = '';
05962       $addId = 0;
05963 
05964       if ($id) {
05965 
05966             // First level, check id (second level, this is done BEFORE the recursive call)
05967          if (!$recursionLevel)   {
05968                // If Id less than zero it means we should add the real id to list:
05969             if ($id < 0)   {
05970                $addId = $id = abs($id);
05971             }
05972                // Check start page:
05973             if ($GLOBALS['TSFE']->sys_page->getRawRecord('pages',$id,'uid'))  {
05974 
05975                   // Find mount point if any:
05976                $mount_info = $GLOBALS['TSFE']->sys_page->getMountPointInfo($id);
05977                if (is_array($mount_info)) {
05978                   $id = $mount_info['mount_pid'];
05979                      // In Overlay mode, use the mounted page uid as added ID!:
05980                   if ($addId && $mount_info['overlay'])  {
05981                      $addId = $id;
05982                   }
05983                }
05984             } else return ''; // Return blank if the start page was NOT found at all!
05985          }
05986 
05987             // Add this ID to the array of IDs
05988          if ($begin<=0) {
05989             $prevId_array[] = $id;
05990          }
05991 
05992             // Select sublevel:
05993          if ($depth>0)  {
05994             $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($allFields, 'pages', 'pid='.intval($id).' AND NOT deleted AND doktype!=255 AND doktype!=6'.$moreWhereClauses, '' ,'sorting');
05995             while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))  {
05996 #??            $GLOBALS['TSFE']->sys_page->versionOL('pages',$row);
05997 
05998                   // Find mount point if any:
05999                $next_id = $row['uid'];
06000                $mount_info = $GLOBALS['TSFE']->sys_page->getMountPointInfo($next_id, $row);
06001                   // Overlay mode:
06002                if (is_array($mount_info) && $mount_info['overlay'])  {
06003                   $next_id = $mount_info['mount_pid'];
06004                   $res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery($allFields, 'pages', 'uid='.intval($next_id).' AND NOT deleted AND doktype!=255 AND doktype!=6'.$moreWhereClauses, '' ,'sorting');
06005                   $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res2);
06006 #??                  $GLOBALS['TSFE']->sys_page->versionOL('pages',$row);
06007                }
06008                   // Add record:
06009                if (is_array($row) && $dontCheckEnableFields || $GLOBALS['TSFE']->checkPagerecordForIncludeSection($row))   {
06010                      // Add ID to list:
06011                   if ($begin<=0) {
06012                      if ($dontCheckEnableFields || $GLOBALS['TSFE']->checkEnableFields($row))   {
06013                         $theList.= $next_id.',';
06014                      }
06015                   }
06016                      // Next level:
06017                   if ($depth>1 && !$row['php_tree_stop'])   {
06018                         // Normal mode:
06019                      if (is_array($mount_info) && !$mount_info['overlay']) {
06020                         $next_id = $mount_info['mount_pid'];
06021                      }
06022                         // Call recursively, if the id is not in prevID_array:
06023                      if (!in_array($next_id,$prevId_array)) {
06024                         $theList.= tslib_cObj::getTreeList($next_id, $depth-1, $begin-1, $dontCheckEnableFields, $addSelectFields, $moreWhereClauses, $prevId_array, $recursionLevel+1);
06025                      }
06026                   }
06027                }
06028             }
06029          }
06030       }
06031          // If first run, check if the ID should be returned:
06032       if (!$recursionLevel)   {
06033          if ($addId) {
06034             if ($begin>0)  {
06035                $theList.= 0;
06036             } else {
06037                $theList.= $addId;
06038             }
06039          }
06040       }
06041          // Return list:
06042       return $theList;
06043    }
06044 
06054    function whereSelectFromList($field,$value)  {
06055       return $GLOBALS['TYPO3_DB']->listQuery($field,$value,'');
06056    }
06057 
06072    function exec_mm_query($select,$local_table,$mm_table,$foreign_table,$whereClause='',$groupBy='',$orderBy='',$limit='') {
06073       return $GLOBALS['TYPO3_DB']->exec_SELECTquery(
06074                $select,
06075                $local_table.','.$mm_table.($foreign_table?','.$foreign_table:''),
06076                $local_table.'.uid='.$mm_table.'.uid_local'.($foreign_table?' AND '.$foreign_table.'.uid='.$mm_table.'.uid_foreign':'').
06077                   $whereClause,  // whereClauseMightContainGroupOrderBy
06078                $groupBy,
06079                $orderBy,
06080                $limit
06081             );
06082    }
06083 
06099    function exec_mm_query_uidList($select,$local_table_uidlist,$mm_table,$foreign_table='',$whereClause='',$groupBy='',$orderBy='',$limit='')   {
06100       return $GLOBALS['TYPO3_DB']->exec_SELECTquery(
06101                $select,
06102                $mm_table.($foreign_table?','.$foreign_table:''),
06103                $mm_table.'.uid_local IN ('.$local_table_uidlist.')'.($foreign_table?' AND '.$foreign_table.'.uid='.$mm_table.'.uid_foreign':'').
06104                   $whereClause,  // whereClauseMightContainGroupOrderBy
06105                $groupBy,
06106                $orderBy,
06107                $limit
06108             );
06109    }
06110 
06120    function searchWhere($sw,$searchFieldList,$searchTable='')  {
06121       $prefixTableName = $searchTable ? $searchTable.'.' : '';
06122       $where = '';
06123       if ($sw) {
06124          $searchFields = explode(',',$searchFieldList);
06125          $kw = split('[ ,]',$sw);
06126 
06127          while(list(,$val)=each($kw))  {
06128             $val = trim($val);
06129             $where_p = array();
06130             if (strlen($val)>=2) {
06131                reset($searchFields);
06132                while(list(,$field)=each($searchFields))  {
06133                   $where_p[]=$prefixTableName.$field.' LIKE "%'.$GLOBALS['TYPO3_DB']->quoteStr($val, $searchTable).'%"';
06134                }
06135             }
06136             if (count($where_p)) {
06137                $where.=' AND ('.implode(' OR ',$where_p).')';
06138             }
06139          }
06140       }
06141       return $where;
06142    }
06143 
06153    function exec_getQuery($table, $conf)  {
06154       $queryParts = $this->getQuery($table, $conf, TRUE);
06155 
06156       return $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
06157    }
06158 
06171    function getQuery($table, $conf, $returnQueryArray=FALSE)   {
06172 
06173          // Construct WHERE clause:
06174       $conf['pidInList'] = trim($this->stdWrap($conf['pidInList'],$conf['pidInList.']));
06175       if (!strcmp($conf['pidInList'],'')) {
06176          $conf['pidInList'] = 'this';
06177       }
06178       $queryParts = $this->getWhere($table,$conf,TRUE);
06179 
06180          // Fields:
06181       $queryParts['SELECT'] = $conf['selectFields'] ? $conf['selectFields'] : '*';
06182 
06183          // Setting LIMIT:
06184       if ($conf['max'] || $conf['begin']) {
06185          $error=0;
06186 
06187             // Finding the total number of records, if used:
06188          if (strstr(strtolower($conf['begin'].$conf['max']),'total'))   {
06189             $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', $table, $queryParts['WHERE'], $queryParts['GROUPBY']);
06190             if ($error = $GLOBALS['TYPO3_DB']->sql_error()) {
06191                $GLOBALS['TT']->setTSlogMessage($error);
06192             } else {
06193                $total = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
06194                $conf['max'] = eregi_replace('total', (string)$total, $conf['max']);
06195                $conf['begin'] = eregi_replace('total', (string)$total, $conf['begin']);
06196             }
06197          }
06198          if (!$error)   {
06199             $conf['begin'] = t3lib_div::intInRange(ceil($this->calc($conf['begin'])),0);
06200             $conf['max'] = t3lib_div::intInRange(ceil($this->calc($conf['max'])),0);
06201             if ($conf['begin'] && !$conf['max'])   {
06202                $conf['max'] = 100000;
06203             }
06204 
06205             if ($conf['begin'] && $conf['max']) {
06206                $queryParts['LIMIT'] = $conf['begin'].','.$conf['max'];
06207             } elseif (!$conf['begin'] && $conf['max'])   {
06208                $queryParts['LIMIT'] = $conf['max'];
06209             }
06210          }
06211       }
06212 
06213       if (!$error)   {
06214 
06215             // Setting up tablejoins:
06216          $joinPart='';
06217          if ($conf['join'])   {
06218             $joinPart = 'JOIN ' .trim($conf['join']);
06219          } elseif ($conf['leftjoin'])  {
06220             $joinPart = 'LEFT OUTER JOIN ' .trim($conf['leftjoin']);
06221          } elseif ($conf['rightjoin']) {
06222             $joinPart = 'RIGHT OUTER JOIN ' .trim($conf['rightjoin']);
06223          }
06224 
06225             // Compile and return query:
06226          $queryParts['FROM'] = trim($table.' '.$joinPart);
06227          $query = $GLOBALS['TYPO3_DB']->SELECTquery(
06228                   $queryParts['SELECT'],
06229                   $queryParts['FROM'],
06230                   $queryParts['WHERE'],
06231                   $queryParts['GROUPBY'],
06232                   $queryParts['ORDERBY'],
06233                   $queryParts['LIMIT']
06234                );
06235          return $returnQueryArray ? $queryParts : $query;
06236       }
06237    }
06238 
06250    function getWhere($table,$conf, $returnQueryArray=FALSE) {
06251       global $TCA;
06252 
06253          // Init:
06254       $query = '';
06255       $pid_uid_flag=0;
06256       $queryParts = array(
06257          'SELECT' => '',
06258          'FROM' => '',
06259          'WHERE' => '',
06260          'GROUPBY' => '',
06261          'ORDERBY' => '',
06262          'LIMIT' => ''
06263       );
06264 
06265       if (trim($conf['uidInList'])) {
06266          $listArr = t3lib_div::intExplode(',',str_replace('this',$GLOBALS['TSFE']->contentPid,$conf['uidInList']));  // str_replace instead of ereg_replace 020800
06267          if (count($listArr)==1) {
06268             $query.=' AND '.$table.'.uid='.intval($listArr[0]);
06269          } else {
06270             $query.=' AND '.$table.'.uid IN ('.implode(',',$GLOBALS['TYPO3_DB']->cleanIntArray($listArr)).')';
06271          }
06272          $pid_uid_flag++;
06273       }
06274       if (trim($conf['pidInList'])) {
06275          $listArr = t3lib_div::intExplode(',',str_replace('this',$GLOBALS['TSFE']->contentPid,$conf['pidInList']));  // str_replace instead of ereg_replace 020800
06276             // removes all pages which are not visible for the user!
06277          $listArr = $this->checkPidArray($listArr);
06278          if (count($listArr)) {
06279              $query.=' AND '.$table.'.pid IN ('.implode(',',$GLOBALS['TYPO3_DB']->cleanIntArray($listArr)).')';
06280             $pid_uid_flag++;
06281          } else {
06282             $pid_uid_flag=0;     // If not uid and not pid then uid is set to 0 - which results in nothing!!
06283          }
06284       }
06285       if (!$pid_uid_flag)  {     // If not uid and not pid then uid is set to 0 - which results in nothing!!
06286          $query.=' AND '.$table.'.uid=0';
06287       }
06288       if ($where = trim($conf['where']))  {
06289          $query.=' AND '.$where;
06290       }
06291 
06292       if ($conf['languageField'])   {
06293          if ($GLOBALS['TSFE']->sys_language_contentOL && $TCA[$table] && $TCA[$table]['ctrl']['languageField'] && $TCA[$table]['ctrl']['transOrigPointerField'])  {
06294                // Sys language content is set to zero/-1 - and it is expected that whatever routine processes the output will OVERLAY the records with localized versions!
06295             $sys_language_content = '0,-1';
06296          } else {
06297             $sys_language_content = intval($GLOBALS['TSFE']->sys_language_content);
06298          }
06299          $query.=' AND '.$conf['languageField'].' IN ('.$sys_language_content.')';
06300       }
06301 
06302       $andWhere = trim($this->stdWrap($conf['andWhere'],$conf['andWhere.']));
06303       if ($andWhere) {
06304          $query.=' AND '.$andWhere;
06305       }
06306 
06307          // enablefields
06308       if ($table=='pages') {
06309          $query.=' '.$GLOBALS['TSFE']->sys_page->where_hid_del;
06310       } else {
06311          $query.=$this->enableFields($table);
06312       }
06313 
06314          // MAKE WHERE:
06315       if ($query) {
06316          $queryParts['WHERE'] = trim(substr($query,4));  // Stripping of " AND"...
06317          $query = 'WHERE '.$queryParts['WHERE'];
06318       }
06319 
06320          // GROUP BY
06321       if (trim($conf['groupBy']))   {
06322          $queryParts['GROUPBY'] = trim($conf['groupBy']);
06323          $query.=' GROUP BY '.$queryParts['GROUPBY'];
06324       }
06325 
06326          // ORDER BY
06327       if (trim($conf['orderBy']))   {
06328          $queryParts['ORDERBY'] = trim($conf['orderBy']);
06329          $query.=' ORDER BY '.$queryParts['ORDERBY'];
06330       }
06331 
06332          // Return result:
06333       return $returnQueryArray ? $queryParts : $query;
06334    }
06335 
06344    function checkPidArray($listArr) {
06345       $outArr = Array();
06346       if (is_array($listArr) && count($listArr))   {
06347          $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'uid IN ('.implode(',',$listArr).')'.$this->enableFields('pages').' AND doktype NOT IN ('.$this->checkPid_badDoktypeList.')');
06348          if ($error = $GLOBALS['TYPO3_DB']->sql_error()) {
06349             $GLOBALS['TT']->setTSlogMessage($error.': '.$query,3);
06350          } else {
06351             while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))   {
06352                $outArr[] = $row['uid'];
06353             }
06354          }
06355       }
06356       return $outArr;
06357    }
06358 
06367    function checkPid($uid) {
06368       $uid = intval($uid);
06369       if (!isset($this->checkPid_cache[$uid]))  {
06370          $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'uid='.intval($uid).$this->enableFields('pages').' AND doktype NOT IN ('.$this->checkPid_badDoktypeList.')');
06371          if ($GLOBALS['TYPO3_DB']->sql_num_rows($res))   {
06372             $this->checkPid_cache[$uid] = 1;
06373          } else {
06374             $this->checkPid_cache[$uid] = 0;
06375          }
06376       }
06377       return $this->checkPid_cache[$uid];
06378    }
06379 
06380 
06381 
06382 
06383 
06384 
06385 
06386 
06387 
06388 
06389 
06390 
06391 
06392 
06393 
06394 
06395 
06396 
06397 
06398 
06399 
06400 
06401 
06402 
06403 
06404 
06405    /***********************************************
06406     *
06407     * Frontend editing functions
06408     *
06409     ***********************************************/
06410 
06423    function editPanel($content, $conf, $currentRecord='', $dataArr=array())   {
06424       global $TCA,$BE_USER;
06425 
06426          // If no backend user, return immediately
06427       if (!$GLOBALS['TSFE']->beUserLogin)    {return $content;}
06428 
06429          // If a backend user is logged in, then go on...
06430       if ($conf['newRecordFromTable']) {
06431          $currentRecord = $conf['newRecordFromTable'].':NEW';
06432          $conf['allow']='new';
06433       }
06434 
06435       if (!$currentRecord) $currentRecord=$this->currentRecord;
06436       if (!count($dataArr))   $dataArr=$this->data;
06437       list($table,$uid) = explode(':',$currentRecord);
06438       $mayEdit=0;
06439 
06440       if (!$conf['onlyCurrentPid'] || $dataArr['pid']==$GLOBALS['TSFE']->id)  {
06441             // Permissions:
06442          $types = t3lib_div::trimExplode(',',strtolower($conf['allow']),1);
06443          $allow = array_flip($types);
06444 
06445          $perms = $GLOBALS['BE_USER']->calcPerms($GLOBALS['TSFE']->page);
06446          if ($table=='pages') {
06447             if (count($GLOBALS['TSFE']->config['rootLine'])==1)   {unset($allow['move']); unset($allow['hide']); unset($allow['delete']);}   // rootpage!
06448             if (!($perms&2))  {unset($allow['edit']);unset($allow['move']);unset($allow['hide']);}
06449             if (!($perms&4))  unset($allow['delete']);
06450             if (!($perms&8))  unset($allow['new']);
06451             if (count($allow))   $mayEdit=1;    // Can only display editbox if there are options in the menu
06452             $newUid = $uid;
06453          } else {
06454             $mayEdit = count($allow)&&($perms&16);
06455             if ($conf['newRecordFromTable']) {
06456                $newUid=$GLOBALS['TSFE']->id;
06457             } else {
06458                $newUid = -1*$uid;
06459             }
06460          }
06461       }
06462 
06463       if ($GLOBALS['TSFE']->displayEditIcons && $table && $mayEdit)  {
06464          $GLOBALS['TSFE']->set_no_cache();      // Special content is about to be shown, so the cache must be disabled.
06465          $formName = 'TSFE_EDIT_FORM_'.substr($GLOBALS['TSFE']->uniqueHash(),0,4);
06466          $formTag = '<form name="'.$formName.'" action="'.htmlspecialchars(t3lib_div::getIndpEnv('REQUEST_URI')).'" method="post" enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'" onsubmit="return TBE_EDITOR_checkSubmit(1);" style="margin: 0 0 0 0;">';
06467          $sortField = $TCA[$table]['ctrl']['sortby'];
06468          $labelField = $TCA[$table]['ctrl']['label'];
06469          $hideField = $TCA[$table]['ctrl']['enablecolumns']['disabled'];
06470          $blackLine = $conf['line']?'<img src="clear.gif" width="1" height="'.intval($conf['line']).'" alt="" title="" /><br /><table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="black" style="border: 0px;"><tr style="border: 0px;"><td style="border: 0px;"><img src="clear.gif" width="1" height="1" alt="" title="" /></td></tr></table><br />':'';
06471 
06472          $theCmd='';
06473          $TSFE_EDIT = t3lib_div::_POST('TSFE_EDIT');
06474          if (is_array($TSFE_EDIT) && $TSFE_EDIT['record']==$currentRecord && !$TSFE_EDIT['update_close'])   {
06475             $theCmd =$TSFE_EDIT['cmd'];
06476          }
06477 
06478          switch($theCmd)   {
06479             case 'edit':
06480             case 'new':
06481                $tceforms = t3lib_div::makeInstance('t3lib_TCEforms_FE');
06482                $tceforms->prependFormFieldNames = 'TSFE_EDIT[data]';
06483                $tceforms->prependFormFieldNames_file = 'TSFE_EDIT_file';
06484                $tceforms->doSaveFieldName = 'TSFE_EDIT[doSave]';
06485                $tceforms->formName = $formName;
06486                $tceforms->backPath = TYPO3_mainDir;
06487                $tceforms->setFancyDesign();
06488                $tceforms->defStyle = 'font-family:Verdana;font-size:10px;';
06489                $tceforms->edit_showFieldHelp = $GLOBALS['BE_USER']->uc['edit_showFieldHelp'];
06490                $tceforms->helpTextFontTag='<font face="verdana,sans-serif" color="#333333" size="1">';
06491 
06492                $trData = t3lib_div::makeInstance('t3lib_transferData');
06493                $trData->addRawData = TRUE;
06494                $trData->defVals = t3lib_div::_GP('defVals');      // Added without testing - should provide ability to submit default values in frontend editing, in-page.
06495                $trData->fetchRecord($table,  ($theCmd=='new'?$newUid:$dataArr['uid']), ($theCmd=='new'?'new':'') );
06496                reset($trData->regTableItems_data);
06497                $processedDataArr = current($trData->regTableItems_data);
06498                $processedDataArr['uid']=$theCmd=='new'?'NEW':$dataArr['uid'];
06499                $processedDataArr['pid']=$theCmd=='new'?$newUid:$dataArr['pid'];
06500 
06501                $panel='';
06502                $buttons = '<input type="image" border="0" name="TSFE_EDIT[update]" src="'.$tceforms->backPath.'gfx/savedok.gif" hspace="2" width="21" height="16" title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveDoc',1).'" />';
06503                $buttons.= '<input type="image" border="0" name="TSFE_EDIT[update_close]" src="'.$tceforms->backPath.'gfx/saveandclosedok.gif" hspace="2" width="21" height="16" title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.saveCloseDoc',1).'" />';
06504                $buttons.= '<input type="image" border="0" name="TSFE_EDIT[cancel]" onclick="'.
06505                   htmlspecialchars('document.location=\''.t3lib_div::getIndpEnv('REQUEST_URI').'\';return false;').
06506                   '" src="'.$tceforms->backPath.'gfx/closedok.gif" hspace="2" width="21" height="16" title="'.$GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:rm.closeDoc',1).'" />';
06507                $panel.=$tceforms->intoTemplate(array('ITEM'=>$buttons));      // Buttons top
06508                $panel.=$tceforms->getMainFields($table,$processedDataArr);
06509 
06510                $hiddenF="";
06511                if ($theCmd=='new')  {
06512                   $hiddenF.='<input type="hidden" name="TSFE_EDIT[data]['.$table.'][NEW][pid]" value="'.$newUid.'" />';
06513                   if ($table=='pages') $hiddenF.='<input type="hidden" name="TSFE_EDIT[data]['.$table.'][NEW][hidden]" value="0" />';     // If a new page is created in front-end, then show it by default!
06514                } else {
06515                   $hiddenF.='<input type="hidden" name="TSFE_EDIT[record]" value="'.$currentRecord.'" />';
06516                   $hiddenF.='<input type="hidden" name="TSFE_EDIT[cmd]" value="edit" />';
06517                }
06518                $hiddenF.='<input type="hidden" name="TSFE_EDIT[doSave]" value="0" />';
06519                $panel.=$tceforms->intoTemplate(array('ITEM'=>$buttons.$hiddenF));   // Buttons AND hidden fields bottom.
06520 
06521                $panel=$formTag.$tceforms->wrapTotal($panel,$dataArr,$table).'</form>'.($theCmd!='new'?$blackLine:'');
06522                $finalOut = $tceforms->printNeededJSFunctions_top().($conf['edit.']['displayRecord']?$content:'').$panel.($theCmd=='new'?$blackLine:'').$tceforms->printNeededJSFunctions();
06523             break;
06524             default:
06525                $panel = '';
06526                if (isset($allow['toolbar']))    $panel.=$GLOBALS['BE_USER']->ext_makeToolBar().'<img src="clear.gif" width="2" height="1" alt="" title="" />';
06527                if (isset($allow['edit']))    $panel.=$this->editPanelLinkWrap('<img src="t3lib/gfx/edit2.gif" width="11" height="12" hspace="2" border="0" title="'.$BE_USER->extGetLL('p_editRecord').'" align="top" alt="" title="" />',$formName,'edit',$currentRecord);
06528                if (isset($allow['move']) && $sortField)  {
06529                   $panel.=$this->editPanelLinkWrap('<img src="t3lib/gfx/button_up.gif" width="11" height="10" vspace="1" hspace="2" border="0" title="'.$BE_USER->extGetLL('p_moveUp').'" align="top" alt="" title="" />',$formName,'up');
06530                   $panel.=$this->editPanelLinkWrap('<img src="t3lib/gfx/button_down.gif" width="11" height="10" vspace="1" hspace="2" border="0" title="'.$BE_USER->extGetLL('p_moveDown').'" align="top" alt="" title="" />',$formName,'down');
06531                }
06532                if (isset($allow['hide']) && $hideField)  {
06533                   if ($dataArr[$hideField])  {
06534                      $panel.=$this->editPanelLinkWrap('<img src="t3lib/gfx/button_unhide.gif" width="11" height="10" vspace="1" hspace="2" border="0" title="'.$BE_USER->extGetLL('p_unhide').'" align="top" alt="" title="" />',$formName,'unhide');
06535                   } else {
06536                      $panel.=$this->editPanelLinkWrap('<img src="t3lib/gfx/button_hide.gif" width="11" height="10" vspace="1" hspace="2" border="0" title="'.$BE_USER->extGetLL('p_hide').'" align="top" alt="" title="" />',$formName,'hide','',$BE_USER->extGetLL('p_hideConfirm'));
06537                   }
06538                }
06539                if (isset($allow['new']))  {
06540                   if ($table=='pages') {
06541                      $panel.=$this->editPanelLinkWrap('<img src="t3lib/gfx/new_page.gif" width="13" height="12" vspace="1" hspace="2" border="0" title="'.$BE_USER->extGetLL('p_newSubpage').'" align="top" alt="" title="" />',$formName,'new',$currentRecord);
06542                   } else {
06543                      $panel.=$this->editPanelLinkWrap('<img src="t3lib/gfx/new_record.gif" width="16" height="12" vspace="1" hspace="2" border="0" title="'.$BE_USER->extGetLL('p_newRecordAfter').'" align="top" alt="" title="" />',$formName,'new',$currentRecord);
06544                   }
06545                }
06546                if (isset($allow['delete']))     {$panel.=$this->editPanelLinkWrap('<img src="t3lib/gfx/delete_record.gif" width="12" height="12" vspace="1" hspace="2" border="0" title="'.$BE_USER->extGetLL('p_delete').'" align="top" alt="" title="" />',$formName,'delete','',$BE_USER->extGetLL('p_deleteConfirm')); }
06547 
06548                   // Final
06549                $labelTxt = $this->stdWrap($conf['label'],$conf['label.']);
06550                $panel='
06551 
06552                         <!-- BE_USER Edit Panel: -->
06553                         '.$formTag.'
06554                            <input type="hidden" name="TSFE_EDIT[cmd]" value="" />
06555                            <input type="hidden" name="TSFE_EDIT[record]" value="'.$currentRecord.'" />
06556                            <table border="0" cellpadding="0" cellspacing="0" border="1" bordercolor="black" class="typo3-editPanel">
06557                               <tr>
06558                                  <td nowrap="nowrap" bgcolor="#ABBBB4" class="typo3-editPanel-controls">'.$panel.'</td>'.($labelTxt?'
06559                                  <td nowrap="nowrap" bgcolor="#F6F2E6" class="typo3-editPanel-label"><font face="verdana" size="1" color="black">&nbsp;'.sprintf($labelTxt,htmlspecialchars(t3lib_div::fixed_lgd($dataArr[$labelField],50))).'&nbsp;</font></td>':'').'
06560                               </tr>
06561                            </table>
06562                         </form>';
06563                   // add black line:
06564                $panel.=$blackLine;
06565                $finalOut = $content.$panel;
06566             break;
06567          }
06568 
06569          if ($conf['previewBorder']) $finalOut = $this->editPanelPreviewBorder($table,$dataArr,$finalOut,$conf['previewBorder']);
06570          return $finalOut;
06571       } else {
06572          return $content;
06573       }
06574    }
06575 
06588    function editIcons($content,$params, $conf=array(), $currentRecord='', $dataArr=array(),$addUrlParamStr='') {
06589       global $BE_USER;
06590 
06591          // If no backend user, return immediately
06592       if (!$GLOBALS['TSFE']->beUserLogin)    {return $content;}
06593 
06594          // Check incoming params:
06595       $rParts = explode(':',$currentRecord?$currentRecord:$this->currentRecord);
06596 
06597       list($table,$fieldList)=t3lib_div::trimExplode(':',$params,1);
06598       if (!$fieldList)  {
06599          $fieldList=$table;
06600          $table=$rParts[0];
06601       } else {
06602          if ($table!=$rParts[0]) return $content;  // If the table is set as the first parameter, and does not match the table of the current record, then just return.
06603       }
06604 
06605       // Check if allowed to edit content:
06606       $mayEdit=0;
06607       $dataArr=count($dataArr)?$dataArr:$this->data;  // If pages-record, should contain correct perms-field, if not, should contain correct pid value.
06608 
06609       if ($table=='pages') {
06610          $mayEdit = $BE_USER->isAdmin()||$BE_USER->doesUserHaveAccess($dataArr,2)?1:0;
06611       } else {
06612          $mayEdit = $BE_USER->isAdmin()||$BE_USER->doesUserHaveAccess(t3lib_BEfunc::getRecord('pages',$dataArr['pid']),16)?1:0;
06613       }
06614 
06615       if ($GLOBALS['TSFE']->displayFieldEditIcons && $table && $mayEdit && $fieldList) {
06616          $GLOBALS['TSFE']->set_no_cache();      // Special content is about to be shown, so the cache must be disabled.
06617          $style = $conf['styleAttribute'] ? ' style="'.htmlspecialchars($conf['styleAttribute']).'"' : '';
06618          $iconTitle = $this->stdWrap($conf['iconTitle'],$conf['iconTitle.']);
06619          $iconImg = $conf['iconImg'] ? $conf['iconImg'] : '<img src="t3lib/gfx/edit_fe.gif" width="11" height="12" border="0" align="top" title="'.t3lib_div::deHSCentities(htmlspecialchars($iconTitle)).'"'.$style.' class="frontEndEditIcons" alt="" title="" />';
06620          $nV=t3lib_div::_GP('ADMCMD_view')?1:0;
06621          $adminURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL').TYPO3_mainDir;
06622          $icon = $this->editPanelLinkWrap_doWrap($iconImg, $adminURL.'alt_doc.php?edit['.$rParts[0].']['.$rParts[1].']=edit&columnsOnly='.rawurlencode($fieldList).'&noView='.$nV.$addUrlParamStr,implode(':',$rParts));
06623          if ($conf['beforeLastTag']<0) {
06624             $content=$icon.$content;
06625          } elseif ($conf['beforeLastTag']>0) {
06626             $cBuf = rtrim($content);
06627             $securCount=30;
06628             while($securCount && substr($cBuf,-1)=='>' && substr($cBuf,-4)!='</a>') {
06629                $cBuf = rtrim(ereg_replace('<[^<]*>$','',$cBuf));
06630                $securCount--;
06631             }
06632             $content = strlen($cBuf)&&$securCount ? substr($content,0,strlen($cBuf)).$icon.substr($content,strlen($cBuf)) : $content=$icon.$content;
06633          } else {
06634             $content.=$icon;
06635          }
06636       }
06637       return $content;
06638    }
06639 
06653    function editPanelLinkWrap($string,$formName,$cmd,$currentRecord='',$confirm='') {
06654       $eFONPage = $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_editFormsOnPage'];
06655       $nV=t3lib_div::_GP('ADMCMD_view')?1:0;
06656       $adminURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL').TYPO3_mainDir;
06657 
06658       if ($cmd=='edit' && !$eFONPage)  {
06659          $rParts = explode(':',$currentRecord);
06660          $out=$this->editPanelLinkWrap_doWrap($string,$adminURL.'alt_doc.php?edit['.$rParts[0].']['.$rParts[1].']=edit&noView='.$nV,$currentRecord);
06661       } elseif ($cmd=='new' && !$eFONPage)   {
06662          $rParts = explode(':',$currentRecord);
06663          if ($rParts[0]=='pages')   {
06664             $out=$this->editPanelLinkWrap_doWrap($string,$adminURL.'db_new.php?id='.$rParts[1].'&pagesOnly=1',$currentRecord);
06665          } else {
06666             $nPid = t3lib_div::testInt($rParts[1]) ? -$rParts[1] : $GLOBALS['TSFE']->id;
06667             $out=$this->editPanelLinkWrap_doWrap($string,$adminURL.'alt_doc.php?edit['.$rParts[0].']['.$nPid.']=new&noView='.$nV,$currentRecord);
06668          }
06669       } else {
06670          if ($confirm)  {
06671             $cf1="if (confirm(unescape('".t3lib_div::rawurlencodeJS($confirm)."'))){";
06672             $cf2='}';
06673          } else {
06674             $cf1=$cf2='';
06675          }
06676          $out='<a href="#" onclick="'.
06677             htmlspecialchars($cf1.'document.'.$formName.'[\'TSFE_EDIT[cmd]\'].value=\''.$cmd.'\'; document.'.$formName.'.submit();'.$cf2.' return false;').
06678             '">'.$string.'</a>';
06679       }
06680       return $out;
06681    }
06682 
06693    function editPanelLinkWrap_doWrap($string,$url,$currentRecord) {
06694       if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_editNoPopup'] || $GLOBALS['BE_USER']->extAdminConfig['module.']['edit.']['forceNoPopup']) {
06695          $retUrl = t3lib_div::getIndpEnv('REQUEST_URI');
06696          $rParts = explode(':',$currentRecord);
06697          if ($rParts[0]=='tt_content' && $this->parentRecordNumber>2)   {  // This parentRecordNumber is used to make sure that only elements 3- of ordinary content elements makes a 'anchor' jump down the page.
06698             $retUrl.='#'.$rParts[1];
06699          }
06700          return '<a href="'.htmlspecialchars($url.'&returnUrl='.rawurlencode($retUrl)).'">'.$string.'</a>';
06701       } else {
06702          return '<a href="#" onclick="'.
06703             htmlspecialchars('vHWin=window.open(\''.$url.'&returnUrl=close.html\',\'FEquickEditWindow\',\''.($GLOBALS['BE_USER']->uc['edit_wideDocument']?'width=690,height=500':'width=540,height=400').',status=0,menubar=0,scrollbars=1,resizable=1\');vHWin.focus();return false;').
06704             '">'.$string.'</a>';
06705       }
06706    }
06707 
06720    function editPanelPreviewBorder($table,$row,$content,$thick)   {
06721       $thick = t3lib_div::intInRange($thick,1,100);
06722       if ($this->isDisabled($table,$row)) {
06723          $content='<table border="'.$thick.'" cellpadding="0" cellspacing="0" bordercolor="#cccccc" width="100%"><tr><td>'.$content.'</td></tr></table>';
06724       }
06725       return $content;
06726    }
06727 
06737    function isDisabled($table,$row) {
06738       global $TCA;
06739       if (
06740          ($TCA[$table]['ctrl']['enablecolumns']['disabled'] && $row[$TCA[$table]['ctrl']['enablecolumns']['disabled']]) ||
06741          ($TCA[$table]['ctrl']['enablecolumns']['fe_group'] && $GLOBALS['TSFE']->simUserGroup && $row[$TCA[$table]['ctrl']['enablecolumns']['fe_group']]==$GLOBALS['TSFE']->simUserGroup) ||
06742          ($TCA[$table]['ctrl']['enablecolumns']['starttime'] && $row[$TCA[$table]['ctrl']['enablecolumns']['starttime']]>time() ) ||
06743          ($TCA[$table]['ctrl']['enablecolumns']['endtime'] && $row[$TCA[$table]['ctrl']['enablecolumns']['endtime']] && $row[$TCA[$table]['ctrl']['enablecolumns']['endtime']]<time())
06744       )  return true;
06745    }
06746 }
06747 
06748 
06749 
06750 
06751 
06752 
06753 
06754 
06755 
06756 
06757 
06758 
06759 
06760 
06768 class tslib_frameset {
06769 
06778    function make($setup)   {
06779       $content = '';
06780       if (is_array($setup))   {
06781          $sKeyArray=t3lib_TStemplate::sortedKeyList($setup);
06782          reset($sKeyArray);
06783          while(list(,$theKey)=each($sKeyArray)) {
06784             $theValue=$setup[$theKey];
06785             if (intval($theKey) && $conf=$setup[$theKey.'.'])  {
06786                switch($theValue) {
06787                   case 'FRAME':
06788                      $typeNum = intval($GLOBALS['TSFE']->tmpl->setup[$conf['obj'].'.']['typeNum']);
06789                      if (!$conf['src'] && !$typeNum)  {
06790                         $typeNum = -1;
06791                      }
06792                      $content.='<frame'.$this->frameParams($conf,$typeNum).' />'.chr(10);
06793                   break;
06794                   case 'FRAMESET':
06795                      $frameset = t3lib_div::makeInstance('tslib_frameset');
06796                      $content.=$frameset->make($conf).chr(10);
06797                   break;
06798                }
06799             }
06800          }
06801          return '<frameset'.$this->framesetParams($setup).'>'.chr(10).$content.'</frameset>';
06802       }
06803    }
06804 
06815    function frameParams($setup, $typeNum) {
06816       $paramStr = '';
06817       $name = $setup['obj'];
06818 
06819       /*
06820       if ($GLOBALS['TSFE']->config['config']['simulateStaticDocuments'])   {
06821          $theCompURL='';
06822          $theCompURL.=$GLOBALS['TSFE']->makeSimulFileName($GLOBALS['TSFE']->page['title'],
06823             ($GLOBALS['TSFE']->page['alias'] ? $GLOBALS['TSFE']->page['alias'] : $GLOBALS['TSFE']->page['uid']),
06824             intval($typeNum));
06825          if ($GLOBALS['TSFE']->config['config']['simulateStaticDocuments']=='PATH_INFO')  {
06826             $theCompURL = str_replace('.','/',$theCompURL);
06827             $theCompURL = 'index.php/'.$theCompURL.'/?';
06828          } else {
06829             $theCompURL.='.html?';
06830          }
06831       } else {
06832          $theCompURL = $GLOBALS['TSFE']->config['mainScript'].'?id='.$GLOBALS['TSFE']->page['uid'].'&type='.intval($typeNum);
06833       }
06834          // Add absRefPrefix if exists.
06835       $finalURL = $GLOBALS['TSFE']->absRefPrefix.$theCompURL.($setup['options']?'&'.$setup['options']:'').$GLOBALS['TSFE']->linkVars.$GLOBALS['TSFE']->getMethodUrlIdToken.($GLOBALS['TSFE']->no_cache?'&no_cache=1':'');
06836       $finalURL = $GLOBALS['TSFE']->tmpl->removeQueryString($finalURL);
06837       */
06838 
06839          // From 3.6.0, use "linkData" for ALL links:
06840       $LD = $GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page,'',$GLOBALS['TSFE']->no_cache,'','',($setup['options']?'&'.$setup['options']:'').$GLOBALS['TSFE']->cObj->getClosestMPvalueForPage($GLOBALS['TSFE']->page['uid']), intval($typeNum));
06841       $finalURL = $LD['totalURL'];
06842 
06843 
06844       if ($setup['src']) {$paramStr.=' src="'.htmlspecialchars($setup['src']).'"';} else {$paramStr.=' src="'.htmlspecialchars($finalURL).'"';}
06845       if ($setup['name']) {$paramStr.=' name="'.$setup['name'].'"';} else {$paramStr.=' name="'.$name.'"';}
06846       if ($setup['params']) {$paramStr.=' '.$setup['params'];}
06847       return $paramStr;
06848    }
06849 
06858    function framesetParams($setup)  {
06859       $paramStr = '';
06860       if ($setup['cols']) {      $paramStr.=' cols="'.$setup['cols'].'"';  }
06861       if ($setup['rows']) {      $paramStr.=' rows="'.$setup['rows'].'"';  }
06862       if ($setup['params']) { $paramStr.=' '.$setup['params']; }
06863       return $paramStr;
06864    }
06865 }
06866 
06867 
06868 
06869 
06870 
06871 
06872 
06873 
06874 
06875 
06876 
06877 
06878 
06879 
06880 
06881 
06882 
06891 class tslib_tableOffset {
06892    var $tableParams = 'border="0" cellspacing="0" cellpadding="0"';
06893    var $default_tableParams = 'border="0" cellspacing="0" cellpadding="0"';
06894    var $tdParams = ' width="99%" valign="top"';
06895 
06903    function start($content,$offset) {
06904       $valPairs = t3lib_div::intExplode(',',$offset.',,,,,');
06905 
06906       if ($valPairs[0] || $valPairs[1] || $valPairs[2] || $valPairs[3] || $valPairs[4] || $valPairs[5])  {
06907             // If width is defined AND there has been no change to the default table params, then extend them to a tablewidth of 1
06908          if ($valPairs[4] && $this->default_tableParams==$this->tableParams)  {$this->tableParams.=' width="1"';}
06909             // Init:
06910          $this->begin = chr(10).'<table '.$this->tableParams.'>';
06911          $this->end = '</table>';
06912          $rows=array();
06913          $widthImg = '';
06914          $heightImg = '';
06915             // If width is required, set so bottom column will display for sure
06916          if ($valPairs[4]) {
06917             if (!$valPairs[3])   $valPairs[3]=1;
06918             $widthImg='<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$valPairs[4].'" height="1" alt="" title="" />';
06919          }
06920             // If height is required, set so right column will display for sure
06921          if ($valPairs[5]) {
06922             if (!$valPairs[2])   $valPairs[2]=1;
06923             $valPairs[2]=1; $heightImg='<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$valPairs[5].'" alt="" title="" />';
06924          }
06925 
06926             // First row:
06927          if ($valPairs[1]) {  // top
06928             $rows[1].= '<tr>';
06929             $rows[1].= '<td><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.($valPairs[0]?$valPairs[0]:1).'" height="'.$valPairs[1].'" alt="" title="" /></td>';
06930             if ($valPairs[0]) $rows[1].= '<td></td>';
06931             if ($valPairs[2]) $rows[1].= '<td></td>';
06932             $rows[1].= '</tr>';
06933          }
06934             // Middle row:
06935          $rows[2].= '<tr>';
06936          if ($valPairs[0]) {$rows[2].= $valPairs[1] ? '<td></td>' : '<td><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$valPairs[0].'" height="1" alt="" title="" /></td>';}
06937          $rows[2].= '<td'.$this->tdParams.'>'.$content.'</td>';
06938          if ($valPairs[2]) {$rows[2].= $valPairs[3] ? '<td>'.$heightImg.'</td>' : '<td><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$valPairs[2].'" height="'.($valPairs[5]?$valPairs[5]:1).'" alt="" title="" /></td>';}
06939          $rows[2].= '</tr>';
06940             // Bottom row:
06941          if ($valPairs[3]) {  // bottom
06942             $rows[3].= '<tr>';
06943             if ($valPairs[0]) $rows[3].= '<td></td>';
06944             if ($valPairs[2]) $rows[3].= '<td>'.$widthImg.'</td>';
06945             $rows[3].= '<td><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.($valPairs[2]?$valPairs[2]:($valPairs[4]?$valPairs[4]:1)).'" height="'.$valPairs[3].'" alt="" title="" /></td>';
06946             $rows[3].= '</tr>';
06947          }
06948          return $this->begin.implode('',$rows).$this->end;
06949       } else return $content;
06950    }
06951 }
06952 
06953 
06954 
06955 
06956 
06957 
06958 
06959 
06960 
06961 
06962 
06963 
06964 
06965 
06966 
06967 
06968 
06969 
06970 
06971 
06972 
06981 class tslib_controlTable   {
06982    var $offX = 0;    // offset, x
06983    var $offY = 0;    // offset, y
06984 
06985    var $tm = '';     // top menu
06986    var $lm = '';     // left menu
06987    var $rm = '';     // right menu
06988    var $bm = '';     // bottom menu
06989    var $content = '';   // content
06990 
06991    var $tmTDparams = 'valign="top"';      // top menu TDparams
06992    var $lmTDparams = 'valign="top"';      // left menu TDparams
06993    var $rmTDparams = 'valign="top"';      // right menu TDparams
06994    var $bmTDparams = 'valign="top"';      // bottom menu TDparams
06995    var $contentTDparams = 'valign="top"'; // content TDparams
06996 
06997    var $cMl = 1;     // content margin, left
06998    var $cMr = 1;     // content margin, right
06999    var $cMt = 0;     // content margin, top
07000    var $cMb = 1;     // content margin, bottom
07001 
07002    var $contentW = 0;   // sætter en lille gif-spacer nedest i content-framen
07003 
07004    var $tableParams = 'border="0" cellspacing="0" cellpadding="0"';
07005 
07016    function start($offset,$cMargins)   {
07017       $offArr = t3lib_div::intExplode(',',$offset);
07018       $cMargArr = t3lib_div::intExplode(',',$cMargins);
07019 
07020       $cols = 0;
07021       $rows = 0;
07022 
07023       if ($this->lm) $cols++;
07024       if ($this->rm) $cols++;
07025       if ($cMargArr[0]) $cols++;
07026       if ($cMargArr[2]) $cols++;
07027       if ($cMargArr[1]||$cMargArr[3]||$this->tm||$this->bm||$this->content||$this->contentW) $cols++;
07028 
07029       if ($cMargArr[1]) $rows++;
07030       if ($cMargArr[3]) $rows++;
07031       if ($this->tm) $rows++;
07032       if ($this->bm) $rows++;
07033       if ($this->content) $rows++;
07034       if ($this->contentW) $rows++;
07035       if (!$rows && $cols) $rows=1;    // hvis der slet ingen rækker er sat i midten men der trods alt er nogle kolonner
07036 
07037       if ($rows&&$cols) {
07038          $res = chr(10).'<table '.$this->tableParams.'>';
07039             // top offset:
07040          if ($offArr[1])   {
07041             $xoff = $offArr[0] ? 1 : 0;
07042             if ($cols+$xoff > 1) {$colspan =' colspan="'.($cols+$xoff).'"';}
07043             $res.= '<tr><td'.$colspan.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$offArr[1].'" alt="" title="" /></td></tr>';
07044          }
07045             // The rows:
07046          if ($rows>1)   {$rowspan =' rowspan="'.($rows).'"';}
07047          $res.= '<tr>';
07048          if ($offArr[0])   {  $res.='<td'.$rowspan.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" height="1" width="'.$offArr[0].'" alt="" title="" /></td>'; }
07049          if ($this->lm) {  $res.='<td'.$rowspan.' '.$this->lmTDparams.'>'.$this->lm.'</td>';    }
07050          if ($cMargArr[0]) {  $res.='<td'.$rowspan.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" height="1" width="'.$cMargArr[0].'" alt="" title="" /></td>';     }
07051             // content...
07052 
07053          $middle=Array();
07054          if ($this->tm) {  $middle[]='<td '.$this->tmTDparams.'>'.$this->tm.'</td>';}
07055          if ($cMargArr[1]) {  $middle[]='<td><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$cMargArr[1].'" alt="" title="" /></td>';}
07056          if ($this->content)  {  $middle[]='<td '.$this->contentTDparams.'>'.$this->content.'</td>';}
07057          if ($cMargArr[3]) {  $middle[]='<td><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$cMargArr[3].'" alt="" title="" /></td>';}
07058          if ($this->bm) {  $middle[]='<td '.$this->bmTDparams.'>'.$this->bm.'</td>';}
07059          if ($this->contentW) {  $middle[]='<td><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" height="1" width="'.$this->contentW.'" alt="" title="" /></td>';}
07060          if (isset($middle[0]))  {$res.=$middle[0];}
07061 
07062             // venstre for content
07063          if ($cMargArr[2]) {  $res.='<td'.$rowspan.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" height="1" width="'.$cMargArr[2].'" alt="" title="" /></td>';     }
07064          if ($this->rm) {  $res.='<td'.$rowspan.' '.$this->rmTDparams.'>'.$this->rm.'</td>';    }
07065          $res.= '</tr>';
07066 
07067             // flere end de 2 rækker
07068          $mCount = count($middle);
07069          for($a=1;$a<$mCount;$a++)  {
07070             $res.='<tr>'.$middle[$a].'</tr>';
07071          }
07072          $res.='</table>';
07073          return $res;
07074       }
07075    }
07076 }
07077 
07078 
07079 
07080 
07081 
07082 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_content.php']) {
07083    include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_content.php']);
07084 }
07085 ?>

Generated on Sun Oct 3 01:05:58 2004 for TYPO3core 3.7.0 dev by  doxygen 1.3.8-20040913