Documentation TYPO3 par Ameos

class.tslib_content.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2007 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00218   // Includes this class since it is used for parsing HTML
00219 require_once(PATH_t3lib."class.t3lib_parsehtml.php");
00220 
00221         // Object TypoScript library included:
00222 if(t3lib_extMgm::isLoaded('obts')) {
00223         require_once(t3lib_extMgm::extPath('obts').'_tsobject/_tso.php');
00224 }
00225 
00226 
00227 
00228 
00229 
00230 
00231 
00232 
00233 
00234 
00235 
00236 
00237 
00238 
00239 
00240 
00241 
00256 class tslib_cObj {
00257         var $align = Array ('center', 'right', 'left');
00258 
00269         var $image_compression = Array(
00270                 10 => Array('params'=>'', 'ext'=>'gif'),
00271                 11 => Array('params'=>'-colors 128', 'ext'=>'gif'),
00272                 12 => Array('params'=>'-colors 64', 'ext'=>'gif'),
00273                 13 => Array('params'=>'-colors 32', 'ext'=>'gif'),
00274                 14 => Array('params'=>'-colors 16', 'ext'=>'gif'),
00275                 15 => Array('params'=>'-colors 8', 'ext'=>'gif'),
00276 
00277                 30 => Array('params'=>'-colors 256', 'ext'=>'png'),
00278                 31 => Array('params'=>'-colors 128', 'ext'=>'png'),
00279                 32 => Array('params'=>'-colors 64', 'ext'=>'png'),
00280                 33 => Array('params'=>'-colors 32', 'ext'=>'png'),
00281                 34 => Array('params'=>'-colors 16', 'ext'=>'png'),
00282                 35 => Array('params'=>'-colors 8', 'ext'=>'png'),
00283                 39 => Array('params'=>'', 'ext'=>'png'),
00284 
00285                 20 => Array('params'=>'-quality 100', 'ext'=>'jpg'),
00286                 21 => Array('params'=>'-quality 90', 'ext'=>'jpg'),
00287                 22 => Array('params'=>'-quality 80', 'ext'=>'jpg'),
00288                 23 => Array('params'=>'-quality 70', 'ext'=>'jpg'),
00289                 24 => Array('params'=>'-quality 60', 'ext'=>'jpg'),
00290                 25 => Array('params'=>'-quality 50', 'ext'=>'jpg'),
00291                 26 => Array('params'=>'-quality 40', 'ext'=>'jpg'),
00292                 27 => Array('params'=>'-quality 30', 'ext'=>'jpg'),
00293                 28 => Array('params'=>'-quality 20', 'ext'=>'jpg')
00294         );
00295 
00301         var $image_effects = Array(
00302                 1 => '-rotate 90',
00303                 2 => '-rotate 270',
00304                 3 => '-rotate 180',
00305                 10 => '-colorspace GRAY',
00306                 11 => '-sharpen 70',
00307                 20 => '-normalize',
00308                 23 => '-contrast',
00309                 25 => '-gamma 1.3',
00310                 26 => '-gamma 0.8'
00311         );
00312 
00320         var $data = Array();
00321         var $oldData = Array();                         // Used for backup...
00322         var $alternativeData ='';                       // If this is set with an array before stdWrap, it's used instead of $this->data in the data-property in stdWrap
00323         var $parameters = Array();                      // Used by the parseFunc function and is loaded with tag-parameters when parsing tags.
00324         var $currentValKey = 'currentValue_kidjls9dksoje';
00325         var $currentRecord = '';                        // This is set to the [table]:[uid] of the record delivered in the $data-array, if the cObjects CONTENT or RECORD is in operation. Note that $GLOBALS['TSFE']->currentRecord is set to an equal value but always indicating the latest record rendered.
00326         var $currentRecordTotal = 0;            // Set in cObj->RECORDS and cObj->CONTENT to the current number of records selected in a query.
00327         var $currentRecordNumber = 0;           // Incremented in cObj->RECORDS and cObj->CONTENT before each record rendering.
00328         var $parentRecordNumber = 0;            // Incremented in parent cObj->RECORDS and cObj->CONTENT before each record rendering.
00329         var $parentRecord = array();            // If the tslib_cObj was started from CONTENT, RECORD or SEARCHRESULT cObject's this array has two keys, 'data' and 'currentRecord' which indicates the record and data for the parent cObj.
00330         var $regObj;            // This may be set as a reference to the calling object of eg. cObjGetSingle. Anyway, just use it as you like. It's used in productsLib.inc for example.
00331 
00332         // internal
00333         var $INT_include=0;             // Is set to 1 if the instance of this cObj is executed from a PHP_SCRIPT_INT -include script (see pagegen, bottom of document)
00334         var $checkPid_cache = Array();          // This is used by checkPid, that checks if pages are accessible. The $checkPid_cache['page_uid'] is set true or false upon this check featuring a caching function for the next request.
00335         var $checkPid_badDoktypeList = '255';
00336         var $lastTypoLinkUrl='';        // This will be set by typoLink() to the url of the most recent link created.
00337         var $lastTypoLinkTarget='';     // DO. link target.
00338         var $substMarkerCache=array();  // Caching substituteMarkerArrayCached function
00339         var $recordRegister=array();    // Array that registers rendered content elements (or any table) to make sure they are not rendered recursively!
00340         var $cObjHookObjectsArr = array();              // Containig hooks for userdefined cObjects
00341 
00351         function start($data,$table='') {
00352                 global $TYPO3_CONF_VARS;
00353                 $this->data = $data;
00354                 $this->currentRecord = $table ? $table.':'.$this->data['uid'] : '';
00355                 $this->parameters = Array();
00356                 if (is_array ($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClass'])) {
00357                         foreach ($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['cObjTypeAndClass'] as $classArr) {
00358                                 $this->cObjHookObjectsArr[$classArr[0]] = &t3lib_div::getUserObj($classArr[1]);
00359                         }
00360                 }
00361         }
00362 
00372         function setParent($data,$currentRecord)        {
00373                 $this->parentRecord=array('data'=>$data, 'currentRecord'=>$currentRecord);
00374         }
00375 
00376 
00377 
00378 
00379 
00380 
00381 
00382 
00383         /***********************************************
00384          *
00385          * CONTENT_OBJ:
00386          *
00387          ***********************************************/
00388 
00397         function getCurrentVal()        {
00398                 return $this->data[$this->currentValKey];
00399         }
00400 
00408         function setCurrentVal($value)  {
00409                 $this->data[$this->currentValKey] = $value;
00410         }
00411 
00421         function cObjGet($setup,$addKey='')     {
00422                 if (is_array($setup))   {
00423                         $sKeyArray=t3lib_TStemplate::sortedKeyList($setup);
00424                         $content ='';
00425                         foreach($sKeyArray as $theKey)  {
00426                                 $theValue=$setup[$theKey];
00427                                 if (intval($theKey) && !strstr($theKey,'.'))    {
00428                                         $conf=$setup[$theKey.'.'];
00429                                         $content.=$this->cObjGetSingle($theValue,$conf,$addKey.$theKey);        // Get the contentObject
00430                                 }
00431                         }
00432                         return $content;
00433                 }
00434         }
00435 
00445         function cObjGetSingle($name,$conf,$TSkey='__') {
00446                 $content='';
00447                         // Checking that the function is not called eternally. This is done by interrupting at a depth of 100
00448                 $GLOBALS['TSFE']->cObjectDepthCounter--;
00449                 if ($GLOBALS['TSFE']->cObjectDepthCounter>0)    {
00450                         $name = trim($name);
00451                         if ($GLOBALS['TT']->LR) $GLOBALS['TT']->push($TSkey, $name);
00452 
00453                                 // Checking if the COBJ is a reference to another object. (eg. name of 'blabla.blabla = < styles.something')
00454                         if (substr($name,0,1)=='<')     {
00455                                 $key = trim(substr($name,1));
00456                                 $cF = t3lib_div::makeInstance('t3lib_TSparser');
00457                                         // $name and $conf is loaded with the referenced values.
00458                                 $old_conf=$conf;
00459                                 list($name, $conf) = $cF->getVal($key,$GLOBALS['TSFE']->tmpl->setup);
00460                                 if (is_array($old_conf) && count($old_conf))    {
00461                                         $conf = $this->joinTSarrays($conf,$old_conf);
00462 //                                      debug($conf);
00463                                 }
00464                                         // Getting the cObject
00465                                 $GLOBALS['TT']->incStackPointer();
00466                                         $content.=$this->cObjGetSingle($name,$conf,$key);
00467                                 $GLOBALS['TT']->decStackPointer();
00468                         } else {
00469 
00470                                 $hooked = false;
00471                                         // Application defined cObjects
00472                                 foreach ($this->cObjHookObjectsArr as $cObjName => $hookObj)    {
00473                                         if (($name===$cObjName) && method_exists($hookObj, 'cObjGetSingleExt')) {
00474                                                 $content.= $hookObj->cObjGetSingleExt($name, $conf, $TSkey, $this);
00475                                                 $hooked = true;
00476                                         }
00477                                 }
00478                                 if (!$hooked && t3lib_extMgm::isLoaded('obts') && isset($GLOBALS['OBTS']['tso_list'][$name])) {
00479                                         $content.= obts_dtutil::renderDatatypeContent($name, $GLOBALS['OBTS']['tso_list'][$name], $conf, $this);
00480                                 } elseif (!$hooked) {
00481                                                 // Traditional Content Object branching:
00482                                         switch($name)   {
00483                                                 case 'COBJ_ARRAY':
00484                                                 case 'COA':
00485                                                         $content.=$this->COBJ_ARRAY($conf);
00486                                                 break;
00487                                                 case 'COA_INT':
00488                                                         $content.=$this->COBJ_ARRAY($conf,'INT');
00489                                                 break;
00490                                                 case 'HTML':
00491                                                         $content.=$this->HTML($conf);
00492                                                 break;
00493                                                 case 'TEXT':
00494                                                         $content.=$this->TEXT($conf);
00495                                                 break;
00496                                                 case 'CLEARGIF':
00497                                                         $content.=$this->CLEARGIF($conf);
00498                                                 break;
00499                                                 case 'FILE':
00500                                                         $content.=$this->FILE($conf);
00501                                                 break;
00502                                                 case 'IMAGE':
00503                                                         $content.=$this->IMAGE($conf);
00504                                                 break;
00505                                                 case 'IMG_RESOURCE':
00506                                                         $content.=$this->IMG_RESOURCE($conf);
00507                                                 break;
00508                                                 case 'IMGTEXT':
00509                                                         $content.=$this->IMGTEXT($conf);
00510                                                 break;
00511                                                 case 'CONTENT':
00512                                                         $content.=$this->CONTENT($conf);
00513                                                 break;
00514                                                 case 'RECORDS':
00515                                                         $content.=$this->RECORDS($conf);
00516                                                 break;
00517                                                 case 'HMENU':
00518                                                         $content.=$this->HMENU($conf);
00519                                                 break;
00520                                                 case 'CTABLE':
00521                                                         $content.=$this->CTABLE($conf);
00522                                                 break;
00523                                                 case 'OTABLE':
00524                                                         $content.=$this->OTABLE($conf);
00525                                                 break;
00526                                                 case 'COLUMNS':
00527                                                         $content.=$this->COLUMNS($conf);
00528                                                 break;
00529                                                 case 'HRULER':
00530                                                         $content.=$this->HRULER($conf);
00531                                                 break;
00532                                                 case 'CASE':
00533                                                         $content.=$this->CASEFUNC($conf);
00534                                                 break;
00535                                                 case 'LOAD_REGISTER':
00536                                                 case 'RESTORE_REGISTER':
00537                                                         $this->LOAD_REGISTER($conf,$name);
00538                                                 break;
00539                                                 case 'FORM':
00540                                                         $content.=$this->FORM($conf);
00541                                                 break;
00542                                                 case 'SEARCHRESULT':
00543                                                         $content.=$this->SEARCHRESULT($conf);
00544                                                 break;
00545                                                 case 'PHP_SCRIPT':
00546                                                         $content.=$this->PHP_SCRIPT($conf);
00547                                                 break;
00548                                                 case 'PHP_SCRIPT_EXT':
00549                                                         $content.=$this->PHP_SCRIPT($conf,'EXT');
00550                                                 break;
00551                                                 case 'PHP_SCRIPT_INT':
00552                                                         $content.=$this->PHP_SCRIPT($conf,'INT');
00553                                                 break;
00554                                                 case 'USER':
00555                                                         $content.=$this->USER($conf);
00556                                                 break;
00557                                                 case 'USER_INT':
00558                                                         $content.=$this->USER($conf,'INT');
00559                                                 break;
00560                                                 case 'TEMPLATE':
00561                                                         $content.=$this->TEMPLATE($conf);
00562                                                 break;
00563                                                 case 'EDITPANEL':
00564                                                         if ($GLOBALS['TSFE']->beUserLogin)      {$content.=$this->editPanel($content, $conf);}
00565                                                 break;
00566                                                 case 'MULTIMEDIA':
00567                                                         $content.=$this->MULTIMEDIA($conf);
00568                                                 break;
00569                                         }
00570                                 }
00571                         }
00572                         if ($GLOBALS['TT']->LR) $GLOBALS['TT']->pull($content);
00573                 }
00574                         // Increasing on exit...
00575                 $GLOBALS['TSFE']->cObjectDepthCounter++;
00576                 return $content;
00577         }
00578 
00579 
00580 
00581 
00582 
00583 
00584 
00585         /********************************************
00586          *
00587          * Functions rendering content objects (cObjects)
00588          *
00589          ********************************************/
00590 
00598         function HTML($conf)    {
00599                 return $this->stdWrap($conf['value'],$conf['value.']);
00600         }
00601 
00609         function TEXT($conf)    {
00610                 return $this->stdWrap($conf['value'],$conf);
00611         }
00612 
00620         function CLEARGIF($conf)        {
00621                 $w = $this->stdWrap($conf['width'],$conf['width.']);
00622                 $h = $this->stdWrap($conf['height'],$conf['height.']);
00623                 $w = $w ? $w : 1;
00624                 $h = $h ? $h : 1;
00625                 $wrap = $conf['wrap'] ? $conf['wrap'] : '|<br />';
00626                 $theValue = $this->wrap('<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$w.'" height="'.$h.'"'.$this->getBorderAttr(' border="0"').' alt="" title="" />', $wrap);
00627 
00628                 return $this->stdWrap($theValue,$conf['stdWrap.']);
00629         }
00630 
00639         function COBJ_ARRAY($conf,$ext='')      {
00640                 $content='';
00641                 switch($ext)    {
00642                         case 'INT':
00643                                 $substKey = $ext.'_SCRIPT.'.$GLOBALS['TSFE']->uniqueHash();
00644                                 $content.='<!--'.$substKey.'-->';
00645                                 $GLOBALS['TSFE']->config[$ext.'incScript'][$substKey] = array(
00646                                         'file'=>$incFile,
00647                                         'conf'=>$conf,
00648                                         'cObj'=>serialize($this),
00649                                         'type'=>'COA'
00650                                 );
00651                         break;
00652                         default:
00653                                 if ($this->checkIf($conf['if.']))       {
00654                                         $content=$this->cObjGet($conf);
00655                                         if ($conf['wrap']) {
00656                                                 $content=$this->wrap($content, $conf['wrap']);
00657                                         }
00658                                         if ($conf['stdWrap.']) {
00659                                                 $content=$this->stdWrap($content, $conf['stdWrap.']);
00660                                         }
00661                                 }
00662                         break;
00663                 }
00664                 return $content;
00665         }
00666 
00675         function USER($conf,$ext='')    {
00676                 $content='';
00677                 switch($ext)    {
00678                         case 'INT':
00679                                 $substKey = $ext.'_SCRIPT.'.$GLOBALS['TSFE']->uniqueHash();
00680                                 $content.='<!--'.$substKey.'-->';
00681                                 $GLOBALS['TSFE']->config[$ext.'incScript'][$substKey] = array(
00682                                         'file' => $incFile,
00683                                         'conf' => $conf,
00684                                         'cObj' => serialize($this),
00685                                         'type' => 'FUNC'
00686                                 );
00687                         break;
00688                         default:
00689                                 $content.=$this->callUserFunction($conf['userFunc'],$conf,'');
00690                         break;
00691                 }
00692                 return $content;
00693         }
00694 
00702         function FILE($conf)    {
00703                 $theValue = $this->fileResource($this->stdWrap($conf['file'],$conf['file.']), trim($this->getAltParam($conf, false)));
00704                 if ($conf['linkWrap'])  {
00705                         $theValue = $this->linkWrap($theValue,$conf['linkWrap']);
00706                 }
00707                 return $this->wrap($theValue,$conf['wrap']);
00708         }
00709 
00718         function IMAGE($conf)   {
00719                 $content='';
00720                 if ($this->checkIf($conf['if.']))       {
00721                         $theValue = $this->cImage($conf['file'],$conf);
00722                         if ($conf['stdWrap.'])  {
00723                                 $theValue = $this->stdWrap($theValue,$conf['stdWrap.']);
00724                         }
00725                         return $theValue;
00726                 }
00727         }
00728 
00737         function IMG_RESOURCE($conf)    {
00738                 $GLOBALS['TSFE']->lastImgResourceInfo = $this->getImgResource($conf['file'],$conf['file.']);
00739                 return $this->stdWrap($GLOBALS['TSFE']->lastImgResourceInfo[3],$conf['stdWrap.']);
00740         }
00741 
00749         function IMGTEXT($conf) {
00750                 $content='';
00751                 if (is_array($conf['text.']))   {
00752                         $content.= $this->stdWrap($this->cObjGet($conf['text.'],'text.'),$conf['text.']);       // this gets the surrounding content
00753                 }
00754                 $imgList=trim($this->stdWrap($conf['imgList'],$conf['imgList.']));      // gets images
00755                 if ($imgList)   {
00756                         $imgs = t3lib_div::trimExplode(',',$imgList);
00757                         $imgStart = intval($this->stdWrap($conf['imgStart'],$conf['imgStart.']));
00758 
00759                         $imgCount= count($imgs)-$imgStart;
00760 
00761                         $imgMax = intval($this->stdWrap($conf['imgMax'],$conf['imgMax.']));
00762                         if ($imgMax)    {
00763                                 $imgCount = t3lib_div::intInRange($imgCount,0,$conf['imgMax']); // reduces the number of images.
00764                         }
00765 
00766                         $imgPath = $this->stdWrap($conf['imgPath'],$conf['imgPath.']);
00767 
00768                                 // initialisation
00769                         $caption='';
00770                         $captionArray = array();
00771                         if (!$conf['captionSplit'] && !$conf['imageTextSplit'] && is_array($conf['caption.']))  {
00772                                 $caption = $this->stdWrap($this->cObjGet($conf['caption.'], 'caption.'),$conf['caption.']);     // global caption, no splitting
00773                         }
00774                         if ($conf['captionSplit'] && $conf['captionSplit.']['cObject']) {
00775                                 $legacyCaptionSplit = 1;
00776                                 $capSplit = $this->stdWrap($conf['captionSplit.']['token'], $conf['captionSplit.']['token.']);
00777                                 if (!$capSplit) {$capSplit=chr(10);}
00778                                 $captionArray = explode($capSplit, $this->cObjGetSingle($conf['captionSplit.']['cObject'], $conf['captionSplit.']['cObject.'], 'captionSplit.cObject'));
00779                                 while (list($ca_key, $ca_val) = each($captionArray))    {
00780                                         $captionArray[$ca_key] = $this->stdWrap(trim($captionArray[$ca_key]), $conf['captionSplit.']['stdWrap.']);
00781                                 }
00782                         }
00783 
00784                         $tablecode='';
00785                         $position=$this->stdWrap($conf['textPos'],$conf['textPos.']);
00786 
00787                         $tmppos = $position&7;
00788                         $contentPosition = $position&24;
00789                         $align = $this->align[$tmppos];
00790                         $cap = ($caption)?1:0;
00791                         $txtMarg = intval($this->stdWrap($conf['textMargin'],$conf['textMargin.']));
00792                         if (!$conf['textMargin_outOfText'] && $contentPosition<16)      {
00793                                 $txtMarg=0;
00794                         }
00795 
00796                         $cols = intval($this->stdWrap($conf['cols'],$conf['cols.']));
00797                         $rows = intval($this->stdWrap($conf['rows'],$conf['rows.']));
00798                         $colspacing = intval($this->stdWrap($conf['colSpace'],$conf['colSpace.']));
00799                         $rowspacing = intval($this->stdWrap($conf['rowSpace'],$conf['rowSpace.']));
00800 
00801                         $border = intval($this->stdWrap($conf['border'],$conf['border.'])) ? 1:0;
00802                         $borderColor = $this->stdWrap($conf['borderCol'],$conf['borderCol.']);
00803                         $borderThickness = intval($this->stdWrap($conf['borderThick'],$conf['borderThick.']));
00804 
00805                         $borderColor=$borderColor?$borderColor:'black';
00806                         $borderThickness=$borderThickness?$borderThickness:1;
00807 
00808                         $caption_align = $this->stdWrap($conf['captionAlign'],$conf['captionAlign.']);
00809                         if (!$caption_align) {
00810                                 $caption_align = $align;
00811                         }
00812                                 // generate cols
00813                         $colCount = ($cols > 1) ? $cols : 1;
00814                         if ($colCount > $imgCount)      {$colCount = $imgCount;}
00815                         $rowCount = ($colCount > 1) ? ceil($imgCount / $colCount) : $imgCount;
00816                                 // generate rows
00817                         if ($rows>1)  {
00818                                 $rowCount = $rows;
00819                                 if ($rowCount > $imgCount)      {$rowCount = $imgCount;}
00820                                 $colCount = ($rowCount>1) ? ceil($imgCount / $rowCount) : $imgCount;
00821                         }
00822 
00823                                 // max Width
00824                         $colRelations = trim($this->stdWrap($conf['colRelations'],$conf['colRelations.']));
00825                         $maxW = intval($this->stdWrap($conf['maxW'],$conf['maxW.']));
00826 
00827                         $maxWInText = intval($this->stdWrap($conf['maxWInText'],$conf['maxWInText.']));
00828                         if (!$maxWInText)       {       // If maxWInText is not set, it's calculated to the 50 % of the max...
00829                                 $maxWInText = round($maxW/2);
00830                         }
00831 
00832                         if ($maxWInText && $contentPosition>=16)        {       // inText
00833                                 $maxW = $maxWInText;
00834                         }
00835 
00836                         if ($maxW && $colCount > 0) {   // If there is a max width and if colCount is greater than  column
00837 /*                              debug($border*$borderThickness*2);
00838                                 debug($maxW);
00839                                 debug($colspacing);
00840                                 debug(($maxW-$colspacing*($colCount-1)-$colCount*$border*$borderThickness*2));
00841                                 */
00842                                 $maxW = ceil(($maxW-$colspacing*($colCount-1)-$colCount*$border*$borderThickness*2)/$colCount);
00843                         }
00844                                 // create the relation between rows
00845                         $colMaxW = Array();
00846                         if ($colRelations)      {
00847                                 $rel_parts = explode(':',$colRelations);
00848                                 $rel_total = 0;
00849                                 for ($a=0;$a<$colCount;$a++)    {
00850                                         $rel_parts[$a] = intval($rel_parts[$a]);
00851                                         $rel_total+= $rel_parts[$a];
00852                                 }
00853                                 if ($rel_total) {
00854                                         for ($a=0;$a<$colCount;$a++)    {
00855                                                 $colMaxW[$a] = round(($maxW*$colCount)/$rel_total*$rel_parts[$a]);
00856                                         }
00857                                         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.
00858                                                 $colMaxW = Array();
00859                                         }
00860                                 }
00861                         }
00862                         $image_compression = intval($this->stdWrap($conf['image_compression'],$conf['image_compression.']));
00863                         $image_effects = intval($this->stdWrap($conf['image_effects'],$conf['image_effects.']));
00864                         $image_frames = intval($this->stdWrap($conf['image_frames.']['key'],$conf['image_frames.']['key.']));
00865 
00866                                 // fetches pictures
00867                         $splitArr=array();
00868                         $splitArr['imgObjNum']=$conf['imgObjNum'];
00869                         $splitArr = $GLOBALS['TSFE']->tmpl->splitConfArray($splitArr,$imgCount);
00870 
00871                                 // EqualHeight
00872                         $equalHeight = intval($this->stdWrap($conf['equalH'],$conf['equalH.']));
00873                         if ($equalHeight)       {       // Initiate gifbuilder object in order to get dimensions AND calculate the imageWidth's
00874                                 $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
00875                                 $gifCreator->init();
00876                                 $relations = Array();
00877                                 $relations_cols = Array();
00878                                 $totalMaxW = $maxW*$colCount;
00879                                 for($a=0;$a<$imgCount;$a++)     {
00880                                         $imgKey = $a+$imgStart;
00881                                         $imgInfo = $gifCreator->getImageDimensions($imgPath.$imgs[$imgKey]);
00882                                         $relations[$a] = $imgInfo[1] / $equalHeight;    // relationship between the original height and the wished height
00883                                         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.
00884                                                 $relations_cols[floor($a/$colCount)] += $imgInfo[0]/$relations[$a];     // counts the total width of the row with the new height taken into consideration.
00885                                         }
00886                                 }
00887                         }
00888 
00889                         $imageRowsFinalWidths = Array();        // contains the width of every image row
00890                         $imageRowsMaxHeights = Array();
00891                         $imgsTag=array();
00892                         $origImages=array();
00893                         for($a=0;$a<$imgCount;$a++)     {
00894                                 $GLOBALS['TSFE']->register['IMAGE_NUM'] = $a;
00895                                 $GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = $a;
00896 
00897                                 $imgKey = $a+$imgStart;
00898                                 $totalImagePath = $imgPath.$imgs[$imgKey];
00899                                 $this->data[$this->currentValKey] = $totalImagePath;
00900                                 $imgObjNum = intval($splitArr[$a]['imgObjNum']);
00901                                 $imgConf = $conf[$imgObjNum.'.'];
00902 
00903                                 if ($equalHeight)       {
00904                                         $scale = 1;
00905                                         if ($totalMaxW) {
00906                                                 $rowTotalMaxW = $relations_cols[floor($a/$colCount)];
00907                                                 if ($rowTotalMaxW > $totalMaxW) {
00908                                                         $scale = $rowTotalMaxW / $totalMaxW;
00909                                                 }
00910                                         }
00911                                                 // transfer info to the imageObject. Please note, that
00912                                         $imgConf['file.']['height'] = round($equalHeight/$scale);
00913 
00914                                         unset($imgConf['file.']['width']);
00915                                         unset($imgConf['file.']['maxW']);
00916                                         unset($imgConf['file.']['maxH']);
00917                                         unset($imgConf['file.']['minW']);
00918                                         unset($imgConf['file.']['minH']);
00919                                         unset($imgConf['file.']['width.']);
00920                                         unset($imgConf['file.']['maxW.']);
00921                                         unset($imgConf['file.']['maxH.']);
00922                                         unset($imgConf['file.']['minW.']);
00923                                         unset($imgConf['file.']['minH.']);
00924                                         $maxW = 0;      // setting this to zero, so that it doesn't disturb
00925                                 }
00926 
00927                                 if ($maxW) {
00928                                         if (count($colMaxW))    {
00929                                                 $imgConf['file.']['maxW'] = $colMaxW[($a%$colCount)];
00930                                         } else {
00931                                                 $imgConf['file.']['maxW'] = $maxW;
00932                                         }
00933                                 }
00934 
00935                                         // Image Object supplied:
00936                                 if (is_array($imgConf)) {
00937                                         if ($this->image_effects[$image_effects])       {
00938                                                 $imgConf['file.']['params'].= ' '.$this->image_effects[$image_effects];
00939                                         }
00940                                         if ($image_frames)      {
00941                                                 if (is_array($conf['image_frames.'][$image_frames.'.']))        {
00942                                                         $imgConf['file.']['m.'] = $conf['image_frames.'][$image_frames.'.'];
00943                                                 }
00944                                         }
00945                                         if ($image_compression && $imgConf['file']!='GIFBUILDER')       {
00946                                                 if ($image_compression==1)      {
00947                                                         $tempImport = $imgConf['file.']['import'];
00948                                                         $tempImport_dot = $imgConf['file.']['import.'];
00949                                                         unset($imgConf['file.']);
00950                                                         $imgConf['file.']['import'] = $tempImport;
00951                                                         $imgConf['file.']['import.'] = $tempImport_dot;
00952                                                 } elseif (isset($this->image_compression[$image_compression])) {
00953                                                         $imgConf['file.']['params'].= ' '.$this->image_compression[$image_compression]['params'];
00954                                                         $imgConf['file.']['ext'] = $this->image_compression[$image_compression]['ext'];
00955                                                         unset($imgConf['file.']['ext.']);
00956                                                 }
00957                                         }
00958 
00959                                                 // "alt", "title" and "longdesc" attributes:
00960                                         if (!strlen($imgConf['altText']) && !is_array($imgConf['altText.'])) {
00961                                                 $imgConf['altText'] = $conf['altText'];
00962                                                 $imgConf['altText.'] = $conf['altText.'];
00963                                         }
00964                                         if (!strlen($imgConf['titleText']) && !is_array($imgConf['titleText.'])) {
00965                                                 $imgConf['titleText'] = $conf['titleText'];
00966                                                 $imgConf['titleText.'] = $conf['titleText.'];
00967                                         }
00968                                         if (!strlen($imgConf['longdescURL']) && !is_array($imgConf['longdescURL.'])) {
00969                                                 $imgConf['longdescURL'] = $conf['longdescURL'];
00970                                                 $imgConf['longdescURL.'] = $conf['longdescURL.'];
00971                                         }
00972                                 } else {
00973                                         $imgConf = array(
00974                                                 'altText' => $conf['altText'],
00975                                                 'titleText' => $conf['titleText'],
00976                                                 'longdescURL' => $conf['longdescURL'],
00977                                                 'file' => $totalImagePath
00978                                         );
00979                                 }
00980 
00981                                 $imgsTag[$imgKey] = $this->IMAGE($imgConf);
00982 
00983                                         // Store the original filepath
00984                                 $origImages[$imgKey]=$GLOBALS['TSFE']->lastImageInfo;
00985 
00986                                 $imageRowsFinalWidths[floor($a/$colCount)] += $GLOBALS['TSFE']->lastImageInfo[0];
00987                                 if ($GLOBALS['TSFE']->lastImageInfo[1]>$imageRowsMaxHeights[floor($a/$colCount)])       {
00988                                         $imageRowsMaxHeights[floor($a/$colCount)] = $GLOBALS['TSFE']->lastImageInfo[1];
00989                                 }
00990                         }
00991                                 // calculating the tableWidth:
00992                                 // TableWidth problems: It creates problems if the pictures are NOT as wide as the tableWidth.
00993                         $tableWidth = max($imageRowsFinalWidths)+ $colspacing*($colCount-1) + $colCount*$border*$borderThickness*2;
00994 
00995                                 // make table for pictures
00996                         $index=$imgStart;
00997 
00998                         $noRows = $this->stdWrap($conf['noRows'],$conf['noRows.']);
00999                         $noCols = $this->stdWrap($conf['noCols'],$conf['noCols.']);
01000                         if ($noRows) {$noCols=0;}       // noRows overrides noCols. They cannot exist at the same time.
01001                         if ($equalHeight) {
01002                                 $noCols=1;
01003                                 $noRows=0;
01004                         }
01005 
01006                         $rowCount_temp=1;
01007                         $colCount_temp=$colCount;
01008                         if ($noRows)    {
01009                                 $rowCount_temp = $rowCount;
01010                                 $rowCount=1;
01011                         }
01012                         if ($noCols)    {
01013                                 $colCount=1;
01014                         }
01015                                 // col- and rowspans calculated
01016                         $colspan = (($colspacing) ? $colCount*2-1 : $colCount);
01017                         $rowspan = (($rowspacing) ? $rowCount*2-1 : $rowCount) + $cap;
01018 
01019 
01020                                 // Edit icons:
01021                         $editIconsHTML = $conf['editIcons']&&$GLOBALS['TSFE']->beUserLogin ? $this->editIcons('',$conf['editIcons'],$conf['editIcons.']) : '';
01022 
01023                                 // strech out table:
01024                         $tablecode='';
01025                         $flag=0;
01026                         if ($conf['noStretchAndMarginCells']!=1)        {
01027                                 $tablecode.='<tr>';
01028                                 if ($txtMarg && $align=='right')        {       // If right aligned, the textborder is added on the right side
01029                                         $tablecode.='<td rowspan="'.($rowspan+1).'" valign="top"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$txtMarg.'" height="1" alt="" title="" />'.($editIconsHTML?'<br />'.$editIconsHTML:'').'</td>';
01030                                         $editIconsHTML='';
01031                                         $flag=1;
01032                                 }
01033                                 $tablecode.='<td colspan="'.$colspan.'"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$tableWidth.'" height="1" alt="" /></td>';
01034                                 if ($txtMarg && $align=='left') {       // If left aligned, the textborder is added on the left side
01035                                         $tablecode.='<td rowspan="'.($rowspan+1).'" valign="top"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$txtMarg.'" height="1" alt="" title="" />'.($editIconsHTML?'<br />'.$editIconsHTML:'').'</td>';
01036                                         $editIconsHTML='';
01037                                         $flag=1;
01038                                 }
01039                                 if ($flag) $tableWidth+=$txtMarg+1;
01040         //                      $tableWidth=0;
01041                                 $tablecode.='</tr>';
01042                         }
01043 
01044                                 // draw table
01045                         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!
01046                                 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.
01047                                         $tablecode.='<tr><td colspan="'.$colspan.'"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$rowspacing.'"'.$this->getBorderAttr(' border="0"').' alt="" title="" /></td></tr>';
01048                                 }
01049                                 $tablecode.='<tr>';     // starting row
01050                                 for ($b=0; $b<$colCount_temp; $b++)     {       // Looping through the columns
01051                                         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.
01052                                                 if (!$noCols)   {
01053                                                         $tablecode.='<td><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$colspacing.'" height="1"'.$this->getBorderAttr(' border="0"').' alt="" title="" /></td>';
01054                                                 } else {
01055                                                         $colSpacer='<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.($border?$colspacing-6:$colspacing).'" height="'.($imageRowsMaxHeights[$c]+($border?$borderThickness*2:0)).'"'.$this->getBorderAttr(' border="0"').' align="'.($border?'left':'top').'" alt="" title="" />';
01056                                                         $colSpacer='<td valign="top">'.$colSpacer.'</td>';      // added 160301, needed for the new "noCols"-table...
01057                                                         $tablecode.=$colSpacer;
01058                                                 }
01059                                         }
01060                                         if (!$noCols || ($noCols && !$b))       {
01061                                                 $tablecode.='<td valign="top">';        // starting the cell. If "noCols" this cell will hold all images in the row, otherwise only a single image.
01062                                                 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.
01063                                         }
01064                                         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.
01065                                                 $GLOBALS['TSFE']->register['IMAGE_NUM'] = $imgIndex;    // register previous imgIndex
01066                                                 $imgIndex = $index+$a*$colCount_temp;
01067                                                 $GLOBALS['TSFE']->register['IMAGE_NUM_CURRENT'] = $imgIndex;
01068                                                 if ($imgsTag[$imgIndex])        {
01069                                                         if ($rowspacing && $noRows && $a) {             // Puts distance between the images IF "noRows" is set and this is the first iteration of the loop
01070                                                                 $tablecode.= '<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$rowspacing.'" alt="" title="" /><br />';
01071                                                         }
01072                                                         if ($legacyCaptionSplit)        {
01073                                                                 $thisCaption = $captionArray[$imgIndex];
01074                                                         } else if ($conf['captionSplit'] || $conf['imageTextSplit'])    {
01075                                                                 $thisCaption = $this->stdWrap($this->cObjGet($conf['caption.'], 'caption.'), $conf['caption.']);
01076                                                         }
01077                                                         $imageHTML = $imgsTag[$imgIndex].'<br />';
01078                                                         $Talign = (!trim($thisCaption) && !$noRows) ? ' align="left"' : '';  // this is necessary if the tablerows are supposed to space properly together! "noRows" is excluded because else the images "layer" together.
01079                                                         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...)
01080                                                         $imageHTML.=$editIconsHTML;
01081                                                         $editIconsHTML='';
01082                                                         $imageHTML.=$thisCaption;       // Adds caption.
01083                                                         if ($noCols)    {$imageHTML='<td valign="top">'.$imageHTML.'</td>';}            // If noCols, put in table cell.
01084                                                         $tablecode.=$imageHTML;
01085                                                 }
01086                                         }
01087                                         $index++;
01088                                         if (!$noCols || ($noCols && $b+1==$colCount_temp))      {
01089                                                 if ($noCols)    {$tablecode.='</tr></table>';}  // In case of "noCols" we must finish the table that surrounds the images in the row.
01090                                                 $tablecode.='</td>';    // Ending the cell. In case of "noCols" the cell holds all pictures!
01091                                         }
01092                                 }
01093                                 $tablecode.='</tr>';    // ending row
01094                         }
01095                         if ($c) {
01096                                 switch ($contentPosition)       {
01097                                         case '0':       // above
01098                                         case '8':       // below
01099                                                 switch ($align)        {        // These settings are needed for Firefox
01100                                                         case 'center':
01101                                                                 $table_align = 'margin-left: auto; margin-right: auto';
01102                                                         break;
01103                                                         case 'right':
01104                                                                 $table_align = 'margin-left: auto; margin-right: 0px';
01105                                                         break;
01106                                                         default:        // Most of all: left
01107                                                                 $table_align = 'margin-left: 0px; margin-right: auto';
01108                                                 }
01109                                                 $table_align = 'style="'.$table_align.'"';
01110                                         break;
01111                                         case '16':      // in text
01112                                                 $table_align = 'align="'.$align.'"';
01113                                         break;
01114                                         default:
01115                                                 $table_align = '';
01116                                 }
01117 
01118                                         // Table-tag is inserted
01119                                 $tablecode = '<table'.($tableWidth?' width="'.$tableWidth.'"':'').' border="0" cellspacing="0" cellpadding="0" '.$table_align.' class="imgtext-table">'.$tablecode;
01120                                 if ($editIconsHTML)     {       // IF this value is not long since reset.
01121                                         $tablecode.='<tr><td colspan="'.$colspan.'">'.$editIconsHTML.'</td></tr>';
01122                                         $editIconsHTML='';
01123                                 }
01124                                 if ($cap)       {
01125                                         $tablecode.='<tr><td colspan="'.$colspan.'" align="'.$caption_align.'">'.$caption.'</td></tr>';
01126                                 }
01127                                 $tablecode.='</table>';
01128                                 if ($conf['tableStdWrap.'])     {$tablecode=$this->stdWrap($tablecode,$conf['tableStdWrap.']);}
01129                         }
01130 
01131                         $spaceBelowAbove = intval($this->stdWrap($conf['spaceBelowAbove'],$conf['spaceBelowAbove.']));
01132                         switch ($contentPosition)       {
01133                                 case '0':       // above
01134                                         $output= '<div style="text-align:'.$align.';">'.$tablecode.'</div>'.$this->wrapSpace($content, $spaceBelowAbove.'|0');
01135                                 break;
01136                                 case '8':       // below
01137                                         $output= $this->wrapSpace($content, '0|'.$spaceBelowAbove).'<div style="text-align:'.$align.';">'.$tablecode.'</div>';
01138                                 break;
01139                                 case '16':      // in text
01140                                         $output= $tablecode.$content;
01141                                 break;
01142                                 case '24':      // in text, no wrap
01143                                         $theResult = '';
01144                                         $theResult.= '<table border="0" cellspacing="0" cellpadding="0" class="imgtext-nowrap"><tr>';
01145                                         if ($align=='right')    {
01146                                                 $theResult.= '<td valign="top">'.$content.'</td><td valign="top">'.$tablecode.'</td>';
01147                                         } else {
01148                                                 $theResult.= '<td valign="top">'.$tablecode.'</td><td valign="top">'.$content.'</td>';
01149                                         }
01150                                         $theResult.= '</tr></table>';
01151                                         $output= $theResult;
01152                                 break;
01153                         }
01154                 } else {
01155                         $output= $content;
01156                 }
01157 
01158                 if ($conf['stdWrap.']) {
01159                         $output = $this->stdWrap($output, $conf['stdWrap.']);
01160                 }
01161 
01162                 return $output;
01163         }
01164 
01172         function CONTENT($conf) {
01173                 $theValue='';
01174 
01175                 $originalRec = $GLOBALS['TSFE']->currentRecord;
01176                 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!!
01177                         $GLOBALS['TSFE']->recordRegister[$originalRec]++;
01178                 }
01179 
01180                 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_')        {
01181 
01182                         $renderObjName = $conf['renderObj'] ? $conf['renderObj'] : '<'.$conf['table'];
01183                         $renderObjKey = $conf['renderObj'] ? 'renderObj' : '';
01184                         $renderObjConf = $conf['renderObj.'];
01185 
01186                         $slide = intval($conf['slide'])?intval($conf['slide']):0;
01187                         $slideCollect = intval($conf['slide.']['collect'])?intval($conf['slide.']['collect']):0;
01188                         $slideCollectReverse = intval($conf['slide.']['collectReverse'])?true:false;
01189                         $slideCollectFuzzy = $slideCollect?(intval($conf['slide.']['collectFuzzy'])?true:false):true;
01190                         $again = false;
01191 
01192                         do {
01193                                 $res = $this->exec_getQuery($conf['table'],$conf['select.']);
01194                                 if ($error = $GLOBALS['TYPO3_DB']->sql_error()) {
01195                                         $GLOBALS['TT']->setTSlogMessage($error,3);
01196                                 } else {
01197                                         $this->currentRecordTotal = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
01198                                         $GLOBALS['TT']->setTSlogMessage('NUMROWS: '.$GLOBALS['TYPO3_DB']->sql_num_rows($res));
01199                                         $cObj =t3lib_div::makeInstance('tslib_cObj');
01200                                         $cObj->setParent($this->data,$this->currentRecord);
01201                                         $this->currentRecordNumber=0;
01202                                         $cobjValue = '';
01203                                         while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
01204 
01205                                                         // Versioning preview:
01206                                                 $GLOBALS['TSFE']->sys_page->versionOL($conf['table'],$row);
01207 
01208                                                         // Language Overlay:
01209                                                 if (is_array($row) && $GLOBALS['TSFE']->sys_language_contentOL) {
01210                                                         $row = $GLOBALS['TSFE']->sys_page->getRecordOverlay($conf['table'],$row,$GLOBALS['TSFE']->sys_language_content,$GLOBALS['TSFE']->sys_language_contentOL);
01211                                                 }
01212 
01213                                                 if (is_array($row)) { // Might be unset in the sys_language_contentOL
01214                                                         if (!$GLOBALS['TSFE']->recordRegister[$conf['table'].':'.$row['uid']]) {
01215                                                                 $this->currentRecordNumber++;
01216                                                                 $cObj->parentRecordNumber = $this->currentRecordNumber;
01217                                                                 $GLOBALS['TSFE']->currentRecord = $conf['table'].':'.$row['uid'];
01218                                                                 $this->lastChanged($row['tstamp']);
01219                                                                 $cObj->start($row,$conf['table']);
01220                                                                 $tmpValue = $cObj->cObjGetSingle($renderObjName, $renderObjConf, $renderObjKey);
01221                                                                 $cobjValue .= $tmpValue;
01222                                                         }# else debug($GLOBALS['TSFE']->recordRegister,'CONTENT');
01223                                                 }
01224                                         }
01225                                 }
01226                                 if ($slideCollectReverse) {
01227                                         $theValue = $cobjValue.$theValue;
01228                                 } else {
01229                                         $theValue .= $cobjValue;
01230                                 }
01231                                 if ($slideCollect>0) {
01232                                         $slideCollect--;
01233                                 }
01234                                 if ($slide) {
01235                                         if ($slide>0) {
01236                                                 $slide--;
01237                                         }
01238                                         $conf['select.']['pidInList'] = $this->getSlidePids($conf['select.']['pidInList'], $conf['select.']['pidInList.']);
01239                                         $again = strlen($conf['select.']['pidInList'])?true:false;
01240                                 }
01241                         } while ($again&&(($slide&&!strlen($tmpValue)&&$slideCollectFuzzy)||($slide&&$slideCollect)));
01242                 }
01243 
01244                 $theValue = $this->wrap($theValue,$conf['wrap']);
01245                 if ($conf['stdWrap.']) $theValue = $this->stdWrap($theValue,$conf['stdWrap.']);
01246 
01247                 $GLOBALS['TSFE']->currentRecord = $originalRec; // Restore
01248                 return $theValue;
01249         }
01250 
01258         function RECORDS($conf) {
01259                 $theValue='';
01260 
01261                 $originalRec = $GLOBALS['TSFE']->currentRecord;
01262                 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!!
01263                         $GLOBALS['TSFE']->recordRegister[$originalRec]++;
01264                 }
01265 
01266                 $conf['source'] = $this->stdWrap($conf['source'],$conf['source.']);
01267                 if ($conf['tables'] && $conf['source']) {
01268                         $allowedTables = $conf['tables'];
01269                         if (is_array($conf['conf.']))   {
01270                                 reset($conf['conf.']);
01271                                 while(list($k)=each($conf['conf.']))    {
01272                                         if (substr($k,-1)!='.')         $allowedTables.=','.$k;
01273                                 }
01274                         }
01275 
01276                         $loadDB = t3lib_div::makeInstance('FE_loadDBGroup');
01277                         $loadDB->start($conf['source'], $allowedTables);
01278                         reset($loadDB->tableArray);
01279                         while(list($table,)=each($loadDB->tableArray))  {
01280                                 if (is_array($GLOBALS['TCA'][$table]))  {
01281                                         $loadDB->additionalWhere[$table]=$this->enableFields($table);
01282                                 }
01283                         }
01284                         $loadDB->getFromDB();
01285 
01286                         reset($loadDB->itemArray);
01287                         $data = $loadDB->results;
01288 
01289                         $cObj =t3lib_div::makeInstance('tslib_cObj');
01290                         $cObj->setParent($this->data,$this->currentRecord);
01291                         $this->currentRecordNumber=0;
01292                         $this->currentRecordTotal = count($loadDB->itemArray);
01293                         reset($loadDB->itemArray);
01294                         while(list(,$val)=each($loadDB->itemArray))     {
01295                                 $row = $data[$val['table']][$val['id']];
01296 
01297                                         // Versioning preview:
01298                                 $GLOBALS['TSFE']->sys_page->versionOL($val['table'],$row);
01299 
01300                                         // Language Overlay:
01301                                 if (is_array($row) && $GLOBALS['TSFE']->sys_language_contentOL) {
01302                                         $row = $GLOBALS['TSFE']->sys_page->getRecordOverlay($val['table'],$row,$GLOBALS['TSFE']->sys_language_content,$GLOBALS['TSFE']->sys_language_contentOL);
01303                                 }
01304 
01305                                 if (is_array($row))     {       // Might be unset in the content overlay things...
01306                                         if (!$conf['dontCheckPid'])     {
01307                                                 $row = $this->checkPid($row['pid']) ? $row : '';
01308                                         }
01309                                         if ($row && !$GLOBALS['TSFE']->recordRegister[$val['table'].':'.$val['id']])    {
01310                                                 $renderObjName = $conf['conf.'][$val['table']] ? $conf['conf.'][$val['table']] : '<'.$val['table'];
01311                                                 $renderObjKey = $conf['conf.'][$val['table']] ? 'conf.'.$val['table'] : '';
01312                                                 $renderObjConf = $conf['conf.'][$val['table'].'.'];
01313                                                 $this->currentRecordNumber++;
01314                                                 $cObj->parentRecordNumber=$this->currentRecordNumber;
01315                                                 $GLOBALS['TSFE']->currentRecord = $val['table'].':'.$val['id'];
01316                                                 $this->lastChanged($row['tstamp']);
01317                                                 $cObj->start($row,$val['table']);
01318                                                 $tmpValue = $cObj->cObjGetSingle($renderObjName, $renderObjConf, $renderObjKey);
01319                                                 $theValue .= $tmpValue;
01320                                         }# else debug($GLOBALS['TSFE']->recordRegister,'RECORDS');
01321                                 }
01322                         }
01323                 }
01324                 if ($conf['wrap'])      $theValue = $this->wrap($theValue,$conf['wrap']);
01325                 if ($conf['stdWrap.'])  $theValue = $this->stdWrap($theValue,$conf['stdWrap.']);
01326 
01327                 $GLOBALS['TSFE']->currentRecord = $originalRec; // Restore
01328                 return $theValue;
01329         }
01330 
01338         function HMENU($conf)   {
01339                 $content='';
01340                 if ($this->checkIf($conf['if.']))       {
01341                         $cls = strtolower($conf[1]);
01342                         if (t3lib_div::inList($GLOBALS['TSFE']->tmpl->menuclasses,$cls))        {
01343                                 if ($conf['special.']['value.'])        {
01344                                         $conf['special.']['value']  = $this->stdWrap($conf['special.']['value'], $conf['special.']['value.']);
01345                                 }
01346                                 $GLOBALS['TSFE']->register['count_HMENU']++;
01347                                 $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ']=0;
01348                                 $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid']=array();
01349                                 $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMparentId']=array();
01350 
01351                                 $menu = t3lib_div::makeInstance('tslib_'.$cls);
01352                                 $menu->parent_cObj = $this;
01353                                 $menu->start($GLOBALS['TSFE']->tmpl, $GLOBALS['TSFE']->sys_page, '', $conf, 1);
01354                                 $menu->makeMenu();
01355                                 $content.=$menu->writeMenu();
01356                         }
01357                         if ($conf['wrap'])              $content=$this->wrap($content, $conf['wrap']);
01358                         if ($conf['stdWrap.'])  $content = $this->stdWrap($content, $conf['stdWrap.']);
01359                 }
01360                 return $content;
01361         }
01362 
01370         function CTABLE ($conf) {
01371                 $controlTable = t3lib_div::makeInstance('tslib_controlTable');
01372                         if ($conf['tableParams'])       {
01373                         $controlTable->tableParams = $conf['tableParams'];
01374                 }
01375                         // loads the pagecontent
01376                 $controlTable->contentW = $conf['cWidth'];
01377                         // loads the menues if any
01378                 if (is_array($conf['c.']))      {
01379                         $controlTable->content = $this->cObjGet($conf['c.'],'c.');
01380                         $controlTable->contentTDparams = isset($conf['c.']['TDParams']) ? $conf['c.']['TDParams'] : 'valign="top"';
01381                 }
01382                 if (is_array($conf['lm.']))     {
01383                         $controlTable->lm = $this->cObjGet($conf['lm.'],'lm.');
01384                         $controlTable->lmTDparams = isset($conf['lm.']['TDParams']) ? $conf['lm.']['TDParams'] : 'valign="top"';
01385                 }
01386                 if (is_array($conf['tm.']))     {
01387                         $controlTable->tm = $this->cObjGet($conf['tm.'],'tm.');
01388                         $controlTable->tmTDparams = isset($conf['tm.']['TDParams']) ? $conf['tm.']['TDParams'] : 'valign="top"';
01389                 }
01390                 if (is_array($conf['rm.']))     {
01391                         $controlTable->rm = $this->cObjGet($conf['rm.'],'rm.');
01392                         $controlTable->rmTDparams = isset($conf['rm.']['TDParams']) ? $conf['rm.']['TDParams'] : 'valign="top"';
01393                 }
01394                 if (is_array($conf['bm.']))     {
01395                         $controlTable->bm = $this->cObjGet($conf['bm.'],'bm.');
01396                         $controlTable->bmTDparams = isset($conf['bm.']['TDParams']) ? $conf['bm.']['TDParams'] : 'valign="top"';
01397                 }
01398                 return $controlTable->start($conf['offset'],$conf['cMargins']);
01399         }
01400 
01408         function OTABLE ($conf) {
01409                 $controlTable = t3lib_div::makeInstance('tslib_tableOffset');
01410                 if ($conf['tableParams'])       {
01411                         $controlTable->tableParams = $conf['tableParams'];
01412                 }
01413                 return $controlTable->start($this->cObjGet($conf),$conf['offset']);
01414         }
01415 
01423         function COLUMNS ($conf)        {
01424                 $content='';
01425                 if (is_array($conf) && $this->checkIf($conf['if.']))    {
01426                         $tdRowCount=0;
01427                         $tableParams = $conf['tableParams'] ? ' '.$conf['tableParams'] : ' border="0" cellspacing="0" cellpadding="0"';
01428                         $TDparams = $conf['TDparams'] ? ' '.$conf['TDparams']:' valign="top"';
01429                         $rows = t3lib_div::intInRange($conf['rows'],2,20);
01430                         $totalWidth = intval($conf['totalWidth']);
01431                         $columnWidth=0;
01432 
01433                         $totalGapWidth=0;
01434                         $gapData = Array(
01435                                 'gapWidth' => $this->stdWrap($conf['gapWidth'],$conf['gapWidth.']),
01436                                 'gapBgCol' => $this->stdWrap($conf['gapBgCol'],$conf['gapBgCol.']),
01437                                 'gapLineThickness' => $this->stdWrap($conf['gapLineThickness'],$conf['gapLineThickness.']),
01438                                 'gapLineCol' => $this->stdWrap($conf['gapLineCol'],$conf['gapLineCol.'])
01439                         );
01440                         $gapData = $GLOBALS['TSFE']->tmpl->splitConfArray($gapData,$rows-1);
01441                         reset($gapData);
01442                         while(list(,$val)=each($gapData))       {
01443                                 $totalGapWidth+=intval($val['gapWidth']);
01444                         }
01445 
01446                         if ($totalWidth)        {
01447                                 $columnWidth = ceil(($totalWidth-$totalGapWidth)/$rows);
01448                                 $TDparams.=' width="'.$columnWidth.'"';
01449                                 $tableParams.=' width="'.$totalWidth.'"';
01450                         } else {
01451                                 $TDparams.=' width="'.floor(100/$rows).'%"';
01452                                 $tableParams.=' width="100%"';
01453                         }
01454 
01455                         for ($a=1;$a<=$rows;$a++)       {
01456                                 $tdRowCount++;
01457                                 $content.='<td'.$TDparams.'>';
01458                                 $content.=$this->cObjGetSingle($conf[$a],$conf[$a.'.'], $a);
01459                                 $content.='</td>';
01460                                 if ($a < $rows) {
01461                                         $gapConf = $gapData[($a-1)];
01462                                         $gapWidth = intval($gapConf['gapWidth']);
01463                                         if ($gapWidth)  {
01464                                                 $tdPar = $gapConf['gapBgCol'] ? ' bgcolor="'.$gapConf['gapBgCol'].'"' : '';
01465                                                 $gapLine = intval($gapConf['gapLineThickness']);
01466                                                 if ($gapLine)   {
01467                                                         $gapSurround = t3lib_div::intInRange(($gapWidth-$gapLine)/2, 1, 1000);
01468                                                                 // right gap
01469                                                         $content.='<td'.$tdPar.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$gapSurround.'" height="1" alt="" title="" /></td>';
01470                                                         $tdRowCount++;
01471                                                                 // line:
01472                                                         $GtdPar = $gapConf['gapLineCol'] ? ' bgcolor="'.$gapConf['gapLineCol'].'"' : ' bgcolor="black"';
01473                                                         $content.='<td'.$GtdPar.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$gapLine.'" height="1" alt="" title="" /></td>';
01474                                                         $tdRowCount++;
01475                                                                 // left gap
01476                                                         $content.='<td'.$tdPar.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$gapSurround.'" height="1" alt="" title="" /></td>';
01477                                                         $tdRowCount++;
01478                                                 } else {
01479                                                         $content.='<td'.$tdPar.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$gapWidth.'" height="1" alt="" title="" /></td>';
01480                                                         $tdRowCount++;
01481                                                 }
01482                                         }
01483                                 }
01484                         }
01485                         $content = '<tr>'.$content.'</tr>';
01486                         $content = '<table'.$tableParams.'>'.$content.'</table>';
01487                         $content.= $this->cObjGetSingle($conf['after'],$conf['after.'], 'after');
01488                         if ($conf['stdWrap.'])  {
01489                                 $content = $this->stdWrap($content,$conf['stdWrap.']);
01490                         }
01491                 }
01492                 return $content;
01493         }
01494 
01502         function HRULER ($conf) {
01503                 $lineThickness = t3lib_div::intInRange($this->stdWrap($conf['lineThickness'],$conf['lineThickness.']),1,50);
01504                 $lineColor = $conf['lineColor'] ? $conf['lineColor'] : 'black';
01505                 $spaceBefore = intval($conf['spaceLeft']);
01506                 $spaceAfter = intval($conf['spaceRight']);
01507                 $tableWidth = $conf['tableWidth'] ? $conf['tableWidth'] : '99%';
01508                 $content='';
01509 
01510                 $content.='<table border="0" cellspacing="0" cellpadding="0" width="'.htmlspecialchars($tableWidth).'"><tr>';
01511                 if ($spaceBefore)       {$content.='<td width="1"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$spaceBefore.'" height="1" alt="" title="" /></td>'; }
01512                 $content.='<td bgcolor="'.$lineColor.'"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$lineThickness.'" alt="" title="" /></td>';
01513                 if ($spaceAfter)        {$content.='<td width="1"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$spaceAfter.'" height="1" alt="" title="" /></td>'; }
01514                 $content.='</tr></table>';
01515 
01516                 $content = $this->stdWrap($content, $conf['stdWrap.']);
01517                 return $content;
01518         }
01519 
01527         function CASEFUNC ($conf){
01528                 $content='';
01529                 if ($this->checkIf($conf['if.']))       {
01530                         if ($conf['setCurrent'] || $conf['setCurrent.']){$this->data[$this->currentValKey] = $this->stdWrap($conf['setCurrent'], $conf['setCurrent.']);}
01531                         $key = $this->stdWrap($conf['key'],$conf['key.']);
01532                         $key = strlen($conf[$key]) ? $key : 'default';
01533                         $name = $conf[$key];
01534                         $theValue = $this->cObjGetSingle($name,$conf[$key.'.'], $key);
01535                         if ($conf['stdWrap.'])  {
01536                                 $theValue = $this->stdWrap($theValue,$conf['stdWrap.']);
01537                         }
01538                         return $theValue;
01539                 }
01540         }
01541 
01552         function LOAD_REGISTER($conf,$name)     {
01553                 if ($name=='RESTORE_REGISTER')  {
01554                         $GLOBALS['TSFE']->register = array_pop($GLOBALS['TSFE']->registerStack);
01555                 } else {
01556                         array_push($GLOBALS['TSFE']->registerStack,$GLOBALS['TSFE']->register);
01557                         if (is_array($conf))    {
01558                                 reset($conf);
01559                                 while(list($theKey,$theValue)=each($conf))      {
01560                                         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
01561                                                 if (strstr($theKey,'.'))        {
01562                                                         $theKey = substr($theKey,0,-1);
01563                                                 }
01564                                                 $GLOBALS['TSFE']->register[$theKey] = $this->stdWrap($conf[$theKey],$conf[$theKey.'.']);
01565                                         }
01566                                 }
01567                         }
01568                 }
01569                 return '';
01570         }
01571 
01592         function FORM($conf,$formData='')    {
01593                 $content='';
01594                 if (is_array($formData))        {
01595                         $dataArr = $formData;
01596                 } else {
01597                         $data=$this->stdWrap($conf['data'],$conf['data.']);
01598                                 // Clearing dataArr
01599                         $dataArr=array();
01600                                 // Getting the original config
01601                         if (trim($data))        {
01602                                 $data = ereg_replace(chr(10),'||',$data);
01603                                 $dataArr = explode('||',$data);
01604                         }
01605                                 // Adding the new dataArray config form:
01606                         if (is_array($conf['dataArray.'])) {    // dataArray is supplied
01607                                 $sKeyArray = t3lib_TStemplate::sortedKeyList($conf['dataArray.'], TRUE);
01608                                 foreach ($sKeyArray as $theKey) {
01609                                         $dAA = $conf['dataArray.'][$theKey.'.'];
01610                                         if (is_array($dAA))     {
01611                                                 $temp=array();
01612                                                 list($temp[0])= explode('|',$dAA['label.'] ? $this->stdWrap($dAA['label'],$dAA['label.']) : $dAA['label']);
01613                                                 list($temp[1])= explode('|',$dAA['type']);
01614                                                 if ($dAA['required'])   {$temp[1]='*'.$temp[1];}
01615                                                 list($temp[2])= explode('|',$dAA['value.'] ? $this->stdWrap($dAA['value'],$dAA['value.']) : $dAA['value']);
01616                                                         // If value Array is set, then implode those values.
01617                                                 if (is_array($dAA['valueArray.']))      {
01618                                                         reset($dAA['valueArray.']);
01619                                                         $temp_accum = array();
01620                                                         while(list($dAKey_vA,$dAA_vA)=each($dAA['valueArray.']))        {
01621                                                                 if (is_array($dAA_vA) && !strcmp(intval($dAKey_vA).'.',$dAKey_vA))      {
01622                                                                         $temp_vA=array();
01623                                                                         list($temp_vA[0])= explode('=',$dAA_vA['label.'] ? $this->stdWrap($dAA_vA['label'],$dAA_vA['label.']) : $dAA_vA['label']);
01624                                                                         if ($dAA_vA['selected'])        {$temp_vA[0]='*'.$temp_vA[0];}
01625                                                                         list($temp_vA[1])= explode(',',$dAA_vA['value']);
01626                                                                 }
01627                                                                 $temp_accum[] = implode('=',$temp_vA);
01628                                                         }
01629                                                         $temp[2] = implode(',',$temp_accum);
01630                                                 }
01631                                                 list($temp[3])= explode('|',$dAA['specialEval.'] ? $this->stdWrap($dAA['specialEval'],$dAA['specialEval.']) : $dAA['specialEval']);
01632 
01633                                                         // adding the form entry to the dataArray
01634                                                 $dataArr[] = implode('|',$temp);
01635                                         }
01636                                 }
01637                         }
01638                 }
01639 
01640                 $attachmentCounter = '';
01641                 $hiddenfields = '';
01642                 $fieldlist = Array();
01643                 $propertyOverride = Array();
01644                 $fieldname_hashArray = Array();
01645                 $cc = 0;
01646 
01647                 $xhtmlStrict = t3lib_div::inList('xhtml_strict,xhtml_11,xhtml_2',$GLOBALS['TSFE']->xhtmlDoctype);
01648                         // Formname
01649                 if ($conf['formName'])  {
01650                         $formname = $this->cleanFormName($conf['formName']);
01651                 } else {
01652                         $formname = $GLOBALS['TSFE']->uniqueHash();
01653                         $formname = 'a'.$formname;      // form name has to start with a letter to reach XHTML compliance
01654                 }
01655 
01656                 if (isset($conf['fieldPrefix']))        {
01657                         if ($conf['fieldPrefix'])       {
01658                                 $prefix = $this->cleanFormName($conf['fieldPrefix']);
01659                         } else {
01660                                 $prefix = '';
01661                         }
01662                 } else {
01663                         $prefix = $formname;
01664                 }
01665 
01666                 foreach ($dataArr as $val)      {
01667 
01668                         $cc++;
01669                         $confData=Array();
01670                         if (is_array($formData)) {
01671                                 $parts = $val;
01672                                 $val = 1;    // true...
01673                         } else {
01674                                 $val = trim($val);
01675                                 $parts = explode('|',$val);
01676                         }
01677                         if ($val && strcspn($val,'#/')) {
01678                                         // label:
01679                                 $confData['label'] = trim($parts[0]);
01680                                         // field:
01681                                 $fParts = explode(',',$parts[1]);
01682                                 $fParts[0]=trim($fParts[0]);
01683                                 if (substr($fParts[0],0,1)=='*')        {
01684                                         $confData['required']=1;
01685                                         $fParts[0] = substr($fParts[0],1);
01686                                 }
01687                                 $typeParts = explode('=',$fParts[0]);
01688                                 $confData['type'] = trim(strtolower(end($typeParts)));
01689                                 if (count($typeParts)==1)       {
01690                                         $confData['fieldname'] = $this->cleanFormName($parts[0]);
01691                                         if (strtolower(ereg_replace('[^[:alnum:]]','',$confData['fieldname']))=='email')        {$confData['fieldname']='email';}
01692                                                 // Duplicate fieldnames resolved
01693                                         if (isset($fieldname_hashArray[md5($confData['fieldname'])]))   {
01694                                                 $confData['fieldname'].='_'.$cc;
01695                                         }
01696                                         $fieldname_hashArray[md5($confData['fieldname'])]=$confData['fieldname'];
01697                                                 // Attachment names...
01698                                         if ($confData['type']=='file')  {
01699                                                 $confData['fieldname']='attachment'.$attachmentCounter;
01700                                                 $attachmentCounter=intval($attachmentCounter)+1;
01701                                         }
01702                                 } else {
01703                                         $confData['fieldname'] = str_replace(' ','_',trim($typeParts[0]));
01704                                 }
01705                                 $fieldCode='';
01706 
01707                                 if ($conf['wrapFieldName'])     {
01708                                         $confData['fieldname'] = $this->wrap($confData['fieldname'],$conf['wrapFieldName']);
01709                                 }
01710 
01711                                         // Set field name as current:
01712                                 $this->setCurrentVal($confData['fieldname']);
01713 
01714                                         // Additional parameters
01715                                 if (trim($confData['type']))    {
01716                                         $addParams=trim($conf['params']);
01717                                         if (is_array($conf['params.']) && isset($conf['params.'][$confData['type']]))   {
01718                                                 $addParams=trim($conf['params.'][$confData['type']]);
01719                                         }
01720                                         if (strcmp('',$addParams))      { $addParams=' '.$addParams; }
01721                                 } else $addParams='';
01722 
01723                                 if ($conf['dontMd5FieldNames']) {
01724                                         $fName = $confData['fieldname'];
01725                                 } else {
01726                                         $fName = md5($confData['fieldname']);
01727                                 }
01728 
01729                                         // Accessibility: Set id = fieldname attribute:
01730                                 if ($conf['accessibility'] || $xhtmlStrict)     {
01731                                         $elementIdAttribute = ' id="'.$prefix.$fName.'"';
01732                                 } else {
01733                                         $elementIdAttribute = '';
01734                                 }
01735 
01736                                         // Create form field based on configuration/type:
01737                                 switch ($confData['type'])      {
01738                                         case 'textarea':
01739                                                 $cols=trim($fParts[1]) ? intval($fParts[1]) : 20;
01740                                                 $compWidth = doubleval($conf['compensateFieldWidth'] ? $conf['compensateFieldWidth'] : $GLOBALS['TSFE']->compensateFieldWidth);
01741                                                 $compWidth = $compWidth ? $compWidth : 1;
01742                                                 $cols = t3lib_div::intInRange($cols*$compWidth, 1, 120);
01743 
01744                                                 $rows=trim($fParts[2]) ? t3lib_div::intInRange($fParts[2],1,30) : 5;
01745                                                 $wrap=trim($fParts[3]);
01746                                                 if ($conf['noWrapAttr'] || $wrap === 'disabled')        {
01747                                                         $wrap='';
01748                                                 } else {
01749                                                         $wrap = $wrap ? ' wrap="'.$wrap.'"' : ' wrap="virtual"';
01750                                                 }
01751                                                 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], str_replace('\n',chr(10),trim($parts[2])));
01752                                                 $fieldCode=sprintf('<textarea name="%s"%s cols="%s" rows="%s"%s%s>%s</textarea>',
01753                                                         $confData['fieldname'], $elementIdAttribute, $cols, $rows, $wrap, $addParams, t3lib_div::formatForTextarea($default));
01754                                         break;
01755                                         case 'input':
01756                                         case 'password':
01757                                                 $size=trim($fParts[1]) ? intval($fParts[1]) : 20;
01758                                                 $compWidth = doubleval($conf['compensateFieldWidth'] ? $conf['compensateFieldWidth'] : $GLOBALS['TSFE']->compensateFieldWidth);
01759                                                 $compWidth = $compWidth ? $compWidth : 1;
01760                                                 $size = t3lib_div::intInRange($size*$compWidth, 1, 120);
01761                                                 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], trim($parts[2]));
01762 
01763                                                 if ($confData['type']=='password')      {
01764                                                         $default='';
01765                                                 }
01766 
01767                                                 $max=trim($fParts[2]) ? ' maxlength="'.t3lib_div::intInRange($fParts[2],1,1000).'"' : "";
01768                                                 $theType = $confData['type']=='input' ? 'text' : 'password';
01769 
01770                                                 $fieldCode=sprintf('<input type="%s" name="%s"%s size="%s"%s value="%s"%s />',
01771                                                         $theType, $confData['fieldname'], $elementIdAttribute, $size, $max, htmlspecialchars($default), $addParams);
01772 
01773                                         break;
01774                                         case 'file':
01775                                                 $size=trim($fParts[1]) ? t3lib_div::intInRange($fParts[1],1,60) : 20;
01776                                                 $fieldCode=sprintf('<input type="file" name="%s"%s size="%s"%s />',
01777                                                         $confData['fieldname'], $elementIdAttribute, $size, $addParams);
01778                                         break;
01779                                         case 'check':
01780                                                         // alternative default value:
01781                                                 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], trim($parts[2]));
01782                                                 $checked = $default ? ' checked="checked"' : '';
01783                                                 $fieldCode=sprintf('<input type="checkbox" value="%s" name="%s"%s%s%s />',
01784                                                         1, $confData['fieldname'], $elementIdAttribute, $checked, $addParams);
01785                                         break;
01786                                         case 'select':
01787                                                 $option='';
01788                                                 $valueParts = explode(',',$parts[2]);
01789                                                         // size
01790                                                 if (strtolower(trim($fParts[1]))=='auto')       {$fParts[1]=count($valueParts);}                // Auto size set here. Max 20
01791                                                 $size=trim($fParts[1]) ? t3lib_div::intInRange($fParts[1],1,20) : 1;
01792                                                         // multiple
01793                                                 $multiple = strtolower(trim($fParts[2]))=='m' ? ' multiple="multiple"' : '';
01794 
01795                                                 $items=array();         // Where the items will be
01796                                                 $defaults=array(); //RTF
01797                                                 $pCount = count($valueParts);
01798                                                 for($a=0;$a<$pCount;$a++)       {
01799                                                         $valueParts[$a]=trim($valueParts[$a]);
01800                                                         if (substr($valueParts[$a],0,1)=='*')   {       // Finding default value
01801                                                                 $sel='selected';
01802                                                                 $valueParts[$a] = substr($valueParts[$a],1);
01803                                                         } else $sel='';
01804                                                                 // Get value/label
01805                                                         $subParts=explode('=',$valueParts[$a]);
01806                                                         $subParts[1] = (isset($subParts[1])?trim($subParts[1]):trim($subParts[0]));             // Sets the value
01807                                                         $items[] = $subParts;   // Adds the value/label pair to the items-array
01808                                                         if ($sel) {$defaults[]=$subParts[1];}   // Sets the default value if value/label pair is marked as default.
01809                                                 }
01810                                                         // alternative default value:
01811                                                 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], $defaults);
01812                                                 if (!is_array($default)) {
01813                                                         $defaults=array();
01814                                                         $defaults[] = $default;
01815                                                 } else $defaults=$default;
01816                                                         // Create the select-box:
01817                                                 $iCount = count($items);
01818                                                 for($a=0;$a<$iCount;$a++)       {
01819                                                         $option.='<option value="'.$items[$a][1].'"'.(in_array($items[$a][1],$defaults)?' selected="selected"':'').'>'.trim($items[$a][0]).'</option>'; //RTF
01820                                                 }
01821 
01822                                                 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.
01823                                                 $fieldCode=sprintf('<select name="%s"%s size="%s"%s%s>%s</select>',
01824                                                         $confData['fieldname'], $elementIdAttribute, $size, $multiple, $addParams, $option); //RTF
01825                                         break;
01826                                         case 'radio':
01827                                                 $option='';
01828                                                 if ($conf['accessibility'])     {
01829                                                         $option.='<fieldset'.$elementIdAttribute.'><legend>'.$confData['label'].'</legend>';
01830                                                 }
01831                                                 $valueParts = explode(',',$parts[2]);
01832                                                 $items=array();         // Where the items will be
01833                                                 $default='';
01834                                                 $pCount = count($valueParts);
01835                                                 for($a=0;$a<$pCount;$a++)       {
01836                                                         $valueParts[$a]=trim($valueParts[$a]);
01837                                                         if (substr($valueParts[$a],0,1)=='*')   {
01838                                                                 $sel='checked';
01839                                                                 $valueParts[$a] = substr($valueParts[$a],1);
01840                                                         } else $sel='';
01841                                                                 // Get value/label
01842                                                         $subParts=explode('=',$valueParts[$a]);
01843                                                         $subParts[1] = (isset($subParts[1])?trim($subParts[1]):trim($subParts[0]));             // Sets the value
01844                                                         $items[] = $subParts;   // Adds the value/label pair to the items-array
01845                                                         if ($sel) {$default=$subParts[1];}      // Sets the default value if value/label pair is marked as default.
01846                                                 }
01847                                                         // alternative default value:
01848                                                 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], $default);
01849                                                         // Create the select-box:
01850                                                 $iCount = count($items);
01851                                                 for($a=0;$a<$iCount;$a++)       {
01852                                                         $radioId = $prefix.$fName.$this->cleanFormName($items[$a][0]);
01853                                                         if ($conf['accessibility'])     {
01854                                                                 $radioLabelIdAttribute = ' id="'.$radioId.'"';
01855                                                         } else {
01856                                                                 $radioLabelIdAttribute = '';
01857                                                         }
01858                                                         $option .= '<input type="radio" name="'.$confData['fieldname'].'"'.$radioLabelIdAttribute.' value="'.$items[$a][1].'"'.(!strcmp($items[$a][1],$default)?' checked="checked"':'').$addParams.' />';
01859                                                         if ($conf['accessibility'])     {
01860                                                                 $option .= '<label for="'.$radioId.'">' . $this->stdWrap(trim($items[$a][0]), $conf['radioWrap.']) . '</label>';
01861                                                         } else {
01862                                                                 $option .= $this->stdWrap(trim($items[$a][0]), $conf['radioWrap.']);
01863                                                         }
01864                                                 }
01865                                                 if ($conf['accessibility'])     {
01866                                                         $option.='</fieldset>';
01867                                                 }
01868                                                 $fieldCode = $option;
01869                                         break;
01870                                         case 'hidden':
01871                                                 $value = trim($parts[2]);
01872                                                 if (strlen($value) && t3lib_div::inList('recipient_copy,recipient',$confData['fieldname']) && $GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail'])      {
01873                                                         break;
01874                                                 }
01875                                                 if (strlen($value) && t3lib_div::inList('recipient_copy,recipient',$confData['fieldname']))     {
01876                                                         $value = $GLOBALS['TSFE']->codeString($value);
01877                                                 }
01878                                                 $hiddenfields.= sprintf('<input type="hidden" name="%s"%s value="%s" />',
01879                                                         $confData['fieldname'], $elementIdAttribute, htmlspecialchars($value));
01880                                         break;
01881                                         case 'property':
01882                                                 if (t3lib_div::inList('type,locationData,goodMess,badMess,emailMess',$confData['fieldname']))   {
01883                                                         $value=trim($parts[2]);
01884                                                         $propertyOverride[$confData['fieldname']] = $value;
01885                                                         $conf[$confData['fieldname']] = $value;
01886                                                 }
01887                                         break;
01888                                         case 'submit':
01889                                                 $value=trim($parts[2]);
01890                                                 if ($conf['image.'])    {
01891                                                         $this->data[$this->currentValKey] = $value;
01892                                                         $image = $this->IMG_RESOURCE($conf['image.']);
01893                                                         $params = $conf['image.']['params'] ? ' '.$conf['image.']['params'] : '';
01894                                                         $params.= $this->getAltParam($conf['image.'], false);
01895                                                         $params.= $addParams;
01896                                                 } else {
01897                                                         $image = '';
01898                                                 }
01899                                                 if ($image)     {
01900                                                         $fieldCode=sprintf('<input type="image" name="%s"%s src="%s"%s />',
01901                                                                 $confData['fieldname'], $elementIdAttribute, $image, $params);
01902                                                 } else  {
01903                                                         $fieldCode=sprintf('<input type="submit" name="%s"%s value="%s"%s />',
01904                                                                 $confData['fieldname'], $elementIdAttribute, t3lib_div::deHSCentities(htmlspecialchars($value)), $addParams);
01905                                                 }
01906                                         break;
01907                                         case 'reset':
01908                                                 $value=trim($parts[2]);
01909                                                 $fieldCode=sprintf('<input type="reset" name="%s"%s value="%s"%s />',
01910                                                         $confData['fieldname'], $elementIdAttribute, t3lib_div::deHSCentities(htmlspecialchars($value)), $addParams);
01911                                         break;
01912                                         case 'label':
01913                                                 $fieldCode = nl2br(htmlspecialchars(trim($parts[2])));
01914                                         break;
01915                                         default:
01916                                                 $confData['type'] = 'comment';
01917                                                 $fieldCode = trim($parts[2]).'&nbsp;';
01918                                         break;
01919                                 }
01920                                 if ($fieldCode) {
01921 
01922                                                 // Checking for special evaluation modes:
01923                                         if (t3lib_div::inList('textarea,input,password',$confData['type']) && strlen(trim($parts[3])))  {
01924                                                 $modeParameters = t3lib_div::trimExplode(':',$parts[3]);
01925                                         } else {
01926                                                 $modeParameters = array();
01927                                         }
01928 
01929                                                 // Adding evaluation based on settings:
01930                                         switch ((string)$modeParameters[0])     {
01931                                                 case 'EREG':
01932                                                         $fieldlist[] = '_EREG';
01933                                                         $fieldlist[] = rawurlencode($modeParameters[1]);
01934                                                         $fieldlist[] = rawurlencode($modeParameters[2]);
01935                                                         $fieldlist[] = rawurlencode($confData['fieldname']);
01936                                                         $fieldlist[] = rawurlencode($confData['label']);
01937                                                         $confData['required'] = 1;      // Setting this so "required" layout is used.
01938                                                 break;
01939                                                 case 'EMAIL':
01940                                                         $fieldlist[] = '_EMAIL';
01941                                                         $fieldlist[] = rawurlencode($confData['fieldname']);
01942                                                         $fieldlist[] = rawurlencode($confData['label']);
01943                                                         $confData['required'] = 1;      // Setting this so "required" layout is used.
01944                                                 break;
01945                                                 default:
01946                                                         if ($confData['required'] && $confData['type']!='check')        {
01947                                                                 $fieldlist[] = rawurlencode($confData['fieldname']);
01948                                                                 $fieldlist[] = rawurlencode($confData['label']);
01949                                                         }
01950                                                 break;
01951                                         }
01952 
01953                                                 // Field:
01954                                         $fieldLabel = $confData['label'];
01955                                         if ($conf['accessibility'] && trim($fieldLabel) && !preg_match('/^(label|hidden|comment)$/',$confData['type'])) {
01956                                                 $fieldLabel = '<label for="'.$prefix.$fName.'">'.$fieldLabel.'</label>';
01957                                         }
01958 
01959                                                 // Getting template code:
01960                                         $fieldCode = $this->stdWrap($fieldCode, $conf['fieldWrap.']);
01961                                         $labelCode = $this->stdWrap($fieldLabel, $conf['labelWrap.']);
01962                                         $commentCode = $this->stdWrap($confData['label'], $conf['commentWrap.']); // RTF
01963                                         $result = $conf['layout'];
01964                                         if ($conf['REQ'] && $confData['required'])      {
01965                                                 if (is_array($conf['REQ.']['fieldWrap.']))
01966                                                         $fieldCode = $this->stdWrap($fieldCode, $conf['REQ.']['fieldWrap.']);
01967                                                 if (is_array($conf['REQ.']['labelWrap.']))
01968                                                         $labelCode = $this->stdWrap($fieldLabel, $conf['REQ.']['labelWrap.']);
01969                                                 if ($conf['REQ.']['layout'])    {
01970                                                         $result = $conf['REQ.']['layout'];
01971                                                 }
01972                                         }
01973                                         if ($confData['type']=='comment' && $conf['COMMENT.']['layout'])        {
01974                                                 $result = $conf['COMMENT.']['layout'];
01975                                         }
01976                                         if ($confData['type']=='check' && $conf['CHECK.']['layout'])    {
01977                                                 $result = $conf['CHECK.']['layout'];
01978                                         }
01979                                         if ($confData['type']=='radio' && $conf['RADIO.']['layout'])    {
01980                                                 $result = $conf['RADIO.']['layout'];
01981                                         }
01982                                         if ($confData['type']=='label' && $conf['LABEL.']['layout']) {
01983                                                 $result = $conf['LABEL.']['layout'];
01984                                         }
01985                                         $result = str_replace('###FIELD###',$fieldCode,$result);
01986                                         $result = str_replace('###LABEL###',$labelCode,$result);
01987                                         $result = str_replace('###COMMENT###',$commentCode,$result); //RTF
01988                                         $content.= $result;
01989                                 }
01990                         }
01991                 }
01992                 if ($conf['stdWrap.'])  { $content = $this->stdWrap($content, $conf['stdWrap.']); }
01993 
01994 
01995                         // redirect (external: where to go afterwards. internal: where to submit to)
01996                 $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)
01997                 $page = $GLOBALS['TSFE']->page;
01998                 if (!$theRedirect)      {               // Internal: Just submit to current page
01999                         $LD = $GLOBALS['TSFE']->tmpl->linkData($page, $conf['target'], $conf['no_cache'],'index.php', '', $this->getClosestMPvalueForPage($page['uid']));
02000                 } elseif (t3lib_div::testInt($theRedirect))     {               // Internal: Submit to page with ID $theRedirect
02001                         $page = $GLOBALS['TSFE']->sys_page->getPage_noCheck($theRedirect);
02002                         $LD = $GLOBALS['TSFE']->tmpl->linkData($page, $conf['target'], $conf['no_cache'],'index.php', '', $this->getClosestMPvalueForPage($page['uid']));
02003                 } else {        // External URL, redirect-hidden field is rendered!
02004                         $LD = $GLOBALS['TSFE']->tmpl->linkData($page, $conf['target'], $conf['no_cache'],'', '', $this->getClosestMPvalueForPage($page['uid']));
02005                         $LD['totalURL'] = $theRedirect;
02006                         $hiddenfields.= '<input type="hidden" name="redirect" value="'.htmlspecialchars($LD['totalURL']).'" />';                // 18-09-00 added
02007                 }
02008 
02009                         // Formtype (where to submit to!):
02010                 $formtype = $propertyOverride['type'] ? $propertyOverride['type'] : $this->stdWrap($conf['type'], $conf['type.']);
02011                 if (t3lib_div::testInt($formtype))      {       // Submit to a specific page
02012                         $page = $GLOBALS['TSFE']->sys_page->getPage_noCheck($formtype);
02013                         $LD_A = $GLOBALS['TSFE']->tmpl->linkData($page, $conf['target'], $conf['no_cache'], '', '', $this->getClosestMPvalueForPage($page['uid']));
02014                         $action = $LD_A['totalURL'];
02015                 } elseif ($formtype)    {       // Submit to external script
02016                         $LD_A = $LD;
02017                         $action = $formtype;
02018                 } elseif (t3lib_div::testInt($theRedirect))     {
02019                         $LD_A = $LD;
02020                         $action = $LD_A['totalURL'];
02021                 } else {                // Submit to "nothing" - which is current page
02022                         $LD_A = $GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page, $conf['target'], $conf['no_cache'], '', '', $this->getClosestMPvalueForPage($page['uid']));
02023                         $action = $LD_A['totalURL'];
02024                 }
02025 
02026                         // Recipient:
02027                 $theEmail = $this->stdWrap($conf['recipient'], $conf['recipient.']);
02028                 if ($theEmail && !$GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail'])  {
02029                         $theEmail = $GLOBALS['TSFE']->codeString($theEmail);
02030                         $hiddenfields.= '<input type="hidden" name="recipient" value="'.htmlspecialchars($theEmail).'" />';
02031                 }
02032 
02033                         // location data:
02034                 if ($conf['locationData'])      {
02035                         if ($conf['locationData']=='HTTP_POST_VARS' && isset($_POST['locationData']))   {
02036                                 $locationData = t3lib_div::_POST('locationData');
02037                         } else {
02038                                 $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.
02039                         }
02040                         $hiddenfields.='<input type="hidden" name="locationData" value="'.htmlspecialchars($locationData).'" />';
02041                 }
02042 
02043                         // hidden fields:
02044                 if (is_array($conf['hiddenFields.']))   {
02045                         reset($conf['hiddenFields.']);
02046                         while (list($hF_key,$hF_conf) = each($conf['hiddenFields.']))   {
02047                                 if (substr($hF_key,-1)!='.')    {
02048                                         $hF_value = $this->cObjGetSingle($hF_conf,$conf['hiddenFields.'][$hF_key.'.'],'hiddenfields');
02049                                         if (strlen($hF_value) && t3lib_div::inList('recipient_copy,recipient',$hF_key)) {
02050                                                 if ($GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail'])        {
02051                                                         continue;
02052                                                 }
02053                                                 $hF_value = $GLOBALS['TSFE']->codeString($hF_value);
02054                                         }
02055                                         $hiddenfields.= '<input type="hidden" name="'.$hF_key.'" value="'.htmlspecialchars($hF_value).'" />';
02056                                 }
02057                         }
02058                 }
02059 
02060                         // Wrap all hidden fields in a div tag (see http://bugs.typo3.org/view.php?id=678)
02061                 $hiddenfields = '<div style="display:none;">'.$hiddenfields.'</div>';
02062 
02063                 if ($conf['REQ'])       {
02064                         $validateForm=' onsubmit="return validateForm(\''.$formname.'\',\''.implode(',',$fieldlist).'\','.t3lib_div::quoteJSvalue($conf['goodMess']).','.t3lib_div::quoteJSvalue($conf['badMess']).','.t3lib_div::quoteJSvalue($conf['emailMess']).')"';
02065                         $GLOBALS['TSFE']->additionalHeaderData['JSFormValidate'] = '<script type="text/javascript" src="'.$GLOBALS['TSFE']->absRefPrefix.'t3lib/jsfunc.validateform.js"></script>';
02066                 } else $validateForm='';
02067 
02068                         // Create form tag:
02069                 $theTarget = ($theRedirect?$LD['target']:$LD_A['target']);
02070                 $content = array(
02071                         '<form'.
02072                                 ' action="'.htmlspecialchars($action).'"'.
02073                                 ' id="'.$formname.'"'.($xhtmlStrict ? '' : ' name="'.$formname.'"').
02074                                 ' enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'"'.
02075                                 ' method="'.($conf['method']?$conf['method']:'post').'"'.
02076                                 ($theTarget ? ' target="'.$theTarget.'"' : '').
02077                                 $validateForm.
02078                                 '>',
02079                         $hiddenfields.$content,
02080                         '</form>'
02081                 );
02082 
02083                 if ($conf['arrayReturnMode'])   {
02084                         $content['validateForm']=$validateForm;
02085                         $content['formname']=$formname;
02086                         return $content;
02087                 } else {
02088                         return implode('',$content);
02089                 }
02090         }
02091 
02099         function SEARCHRESULT($conf)    {
02100                 if (t3lib_div::_GP('sword') && t3lib_div::_GP('scols')) {
02101                         $search = t3lib_div::makeInstance('tslib_search');
02102                         $search->register_and_explode_search_string(t3lib_div::_GP('sword'));
02103                         $search->register_tables_and_columns(t3lib_div::_GP('scols'),$conf['allowedCols']);
02104                                 // depth
02105                         $depth=100;
02106                                 // the startId is found
02107                         $theStartId=0;
02108                         if (t3lib_div::testInt(t3lib_div::_GP('stype')))        {
02109                                 $temp_theStartId=t3lib_div::_GP('stype');
02110                                 $rootLine = $GLOBALS['TSFE']->sys_page->getRootLine($temp_theStartId);
02111                                         // The page MUST have a rootline with the Level0-page of the current site inside!!
02112                                 while(list(,$val)=each($rootLine))      {
02113                                         if($val['uid']==$GLOBALS['TSFE']->tmpl->rootLine[0]['uid'])     {
02114                                                 $theStartId=$temp_theStartId;
02115                                         }
02116                                 }
02117                         } else if (t3lib_div::_GP('stype'))     {
02118                                 if (substr(t3lib_div::_GP('stype'),0,1)=='L')   {
02119                                         $pointer = intval(substr(t3lib_div::_GP('stype'),1));
02120                                         $theRootLine = $GLOBALS['TSFE']->tmpl->rootLine;
02121                                                 // location Data:
02122                                         $locDat_arr = explode(':',t3lib_div::_POST('locationData'));
02123                                         $pId = intval($locDat_arr[0]);
02124                                         if ($pId)       {
02125                                                 $altRootLine = $GLOBALS['TSFE']->sys_page->getRootLine($pId);
02126                                                 ksort($altRootLine);
02127                                                 if (count($altRootLine))        {
02128                                                                 // check if the rootline has the real Level0 in it!!
02129                                                         reset($altRootLine);
02130                                                         $hitRoot=0;
02131                                                         $theNewRoot=array();
02132                                                         while(list(,$val)=each($altRootLine))   {
02133                                                                 if($hitRoot || $val['uid']==$GLOBALS['TSFE']->tmpl->rootLine[0]['uid']) {
02134                                                                         $hitRoot=1;
02135                                                                         $theNewRoot[]=$val;
02136                                                                 }
02137                                                         }
02138                                                         if ($hitRoot)   {
02139                                                                 $theRootLine = $theNewRoot;             // Override the real rootline if any thing
02140                                                         }
02141                                                 }
02142                                         }
02143                                         $key = $this->getKey($pointer,$theRootLine);
02144                                         $theStartId = $theRootLine[$key]['uid'];
02145                                 }
02146                         }
02147                         if (!$theStartId)       {
02148                                         // If not set, we use current page
02149                                 $theStartId = $GLOBALS['TSFE']->id;
02150                         }
02151                                 // generate page-tree
02152                         $search->pageIdList.= $this->getTreeList(-1*$theStartId,$depth);
02153 
02154                         $endClause = 'pages.uid IN ('.$search->pageIdList.')
02155                                 AND pages.doktype in ('.$GLOBALS['TYPO3_CONF_VARS']['FE']['content_doktypes'].($conf['addExtUrlsAndShortCuts']?',3,4':'').')
02156                                 AND pages.no_search=0'.
02157                                 $this->enableFields($search->fTable).
02158                                 $this->enableFields('pages');
02159 
02160                         if ($conf['languageField.'][$search->fTable])   {
02161                                 $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!)
02162                         }
02163 
02164                                 // build query
02165                         $search->build_search_query($endClause);
02166 
02167                                 // count...
02168                         if (t3lib_div::testInt(t3lib_div::_GP('scount')))       {
02169                                 $search->res_count = t3lib_div::_GP('scount');
02170                         } else {
02171                                 $search->count_query();
02172                         }
02173 
02174                                 // range
02175                         $spointer = intval(t3lib_div::_GP('spointer'));
02176                         if (isset($conf['range']))      {
02177                                 $theRange = intval($conf['range']);
02178                         } else {
02179                                 $theRange = 20;
02180                         }
02181 
02182                                 // Order By:
02183                         if (!$conf['noOrderBy'])        {
02184                                 $search->queryParts['ORDERBY'] = 'pages.lastUpdated, pages.tstamp';
02185                         }
02186 
02187                         $search->queryParts['LIMIT'] = $spointer.','.$theRange;
02188 
02189                                 // search...
02190                         $search->execute_query();
02191                         if ($GLOBALS['TYPO3_DB']->sql_num_rows($search->result))        {
02192                                 $GLOBALS['TSFE']->register['SWORD_PARAMS'] = $search->get_searchwords();
02193 
02194                                 $total = $search->res_count;
02195                                 $rangeLow = t3lib_div::intInRange($spointer+1,1,$total);
02196                                 $rangeHigh = t3lib_div::intInRange($spointer+$theRange,1,$total);
02197                                         // prev/next url:
02198                                 $LD = $GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page,$conf['target'],1,'', '', $this->getClosestMPvalueForPage($GLOBALS['TSFE']->page['uid']));
02199                                 $targetPart = $LD['target'] ? ' target="'.htmlspecialchars($LD['target']).'"' : '';
02200                                 $urlParams = $this->URLqMark($LD['totalURL'],
02201                                                 '&sword='.rawurlencode(t3lib_div::_GP('sword')).
02202                                                 '&scols='.rawurlencode(t3lib_div::_GP('scols')).
02203                                                 '&stype='.rawurlencode(t3lib_div::_GP('stype')).
02204                                                 '&scount='.$total);
02205                                         // substitution:
02206                                 $result= $this->cObjGetSingle($conf['layout'],$conf['layout.'], 'layout');
02207                                 $result = str_replace('###RANGELOW###',$rangeLow,$result);
02208                                 $result = str_replace('###RANGEHIGH###',$rangeHigh,$result);
02209                                 $result = str_replace('###TOTAL###',$total,$result);
02210 
02211                                 if ($rangeHigh<$total)  {
02212                                         $next = $this->cObjGetSingle($conf['next'], $conf['next.'], 'next');
02213                                         $next = '<a href="'.htmlspecialchars($urlParams.'&spointer='.($spointer+$theRange)).'"'.$targetPart.$GLOBALS['TSFE']->ATagParams.'>'.$next.'</a>';
02214                                 } else $next='';
02215                                 $result = str_replace('###NEXT###',$next,$result);
02216 
02217                                 if ($rangeLow>1)        {
02218                                         $prev = $this->cObjGetSingle($conf['prev'], $conf['prev.'], 'prev');
02219                                         $prev = '<a href="'.htmlspecialchars($urlParams.'&spointer='.($spointer-$theRange)).'"'.$targetPart.$GLOBALS['TSFE']->ATagParams.'>'.$prev.'</a>';
02220                                 } else $prev='';
02221                                 $result = str_replace('###PREV###',$prev,$result);
02222 
02223                                         // searching result
02224                                 $theValue = $this->cObjGetSingle($conf['resultObj'], $conf['resultObj.'],'resultObj');
02225                                 $cObj = t3lib_div::makeInstance('tslib_cObj');
02226                                 $cObj->setParent($this->data,$this->currentRecord);
02227                                 $renderCode='';
02228                                 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($search->result))   {
02229                                                 // versionOL() here? This is search result displays, is that possible to preview anyway? Or are records selected here already future versions?
02230                                         $cObj->start($row);
02231                                         $renderCode.=$cObj->cObjGetSingle($conf['renderObj'], $conf['renderObj.'],'renderObj');
02232                                 }
02233                                 $theValue.=$this->wrap($renderCode,$conf['renderWrap']);
02234                                 $theValue = str_replace('###RESULT###',$theValue,$result);
02235                         } else {
02236                                 $theValue = $this->cObjGetSingle($conf['noResultObj'], $conf['noResultObj.'],'noResultObj');
02237                         }
02238 
02239                         $GLOBALS['TT']->setTSlogMessage('Search in fields:   '.$search->listOfSearchFields);
02240 
02241                                 // wrapping
02242                         $content=$theValue;
02243                         if ($conf['wrap']) {
02244                                 $content=$this->wrap($content, $conf['wrap']);
02245                         }
02246                         if ($conf['stdWrap.']) {
02247                                 $content=$this->stdWrap($content, $conf['stdWrap.']);
02248                         }
02249                                 // returning
02250                         $GLOBALS['TSFE']->set_no_cache();
02251                         return $content;
02252                 }
02253         }
02254 
02265         function PHP_SCRIPT($conf,$ext='')      {
02266                 $incFile = $GLOBALS['TSFE']->tmpl->getFileName($conf['file']);
02267                 $content='';
02268                 if ($incFile && $GLOBALS['TSFE']->checkFileInclude($incFile))   {
02269                         switch($ext)    {
02270                                 case 'INT':
02271                                 case 'EXT':
02272                                         $substKey = $ext.'_SCRIPT.'.$GLOBALS['TSFE']->uniqueHash();
02273                                         $content.='<!--'.$substKey.'-->';
02274                                         $GLOBALS['TSFE']->config[$ext.'incScript'][$substKey] = array(
02275                                                 'file'=>$incFile,
02276                                                 'conf'=>$conf,
02277                                                 'type'=>'SCRIPT'
02278                                         );
02279                                         if ($ext=='INT')        {
02280                                                 $GLOBALS['TSFE']->config[$ext.'incScript'][$substKey]['cObj'] = serialize($this);
02281                                         } else {
02282                                                 $GLOBALS['TSFE']->config[$ext.'incScript'][$substKey]['data'] = $this->data;
02283                                         }
02284                                 break;
02285                                 default:
02286                                                 // Added 31-12-00: Make backup...
02287                                         $this->oldData = $this->data;
02288                                                 // Include file..
02289                                         include('./'.$incFile);
02290                                                 // Added 31-12-00: restore...
02291                                         if ($RESTORE_OLD_DATA)  {
02292                                                 $this->data = $this->oldData;
02293                                         }
02294                                 break;
02295                         }
02296                 }
02297                 return $content;
02298         }
02299 
02308         function TEMPLATE($conf)        {
02309                 $subparts = Array();
02310                 $marks = Array();
02311                 $wraps = Array();
02312                 $content='';
02313 
02314                 list($PRE,$POST) = explode('|',$conf['markerWrap'] ? $conf['markerWrap'] : '### | ###');
02315                 $POST = trim($POST);
02316                 $PRE  = trim($PRE);
02317 
02318                         // Getting the content
02319                 $content = $this->cObjGetSingle($conf['template'],$conf['template.'],'template');
02320                 if ($conf['workOnSubpart'])     {
02321                         $content = $this->getSubpart($content, $PRE.$conf['workOnSubpart'].$POST);
02322                 }
02323 
02324                         // Fixing all relative paths found:
02325                 if ($conf['relPathPrefix'])     {
02326                         $htmlParser = t3lib_div::makeInstance('t3lib_parsehtml');
02327                         $content = $htmlParser->prefixResourcePath($conf['relPathPrefix'],$content,$conf['relPathPrefix.']);
02328                 }
02329 
02330                 if ($content)   {
02331                         if ($conf['nonCachedSubst'])    {               // NON-CACHED:
02332                                         // Getting marks
02333                                 if (is_array($conf['marks.']))  {
02334                                         reset($conf['marks.']);
02335                                         while(list($theKey,$theValue)=each($conf['marks.']))    {
02336                                                 if (!strstr($theKey,'.'))       {
02337                                                         $content = str_replace(
02338                                                                 $PRE.$theKey.$POST,
02339                                                                 $this->cObjGetSingle($theValue,$conf['marks.'][$theKey.'.'],'marks.'.$theKey),
02340                                                                 $content);
02341                                                 }
02342                                         }
02343                                 }
02344 
02345                                         // Getting subparts.
02346                                 if (is_array($conf['subparts.']))       {
02347                                         reset($conf['subparts.']);
02348                                         while(list($theKey,$theValue)=each($conf['subparts.'])) {
02349                                                 if (!strstr($theKey,'.'))       {
02350                                                         $subpart = $this->getSubpart($content, $PRE.$theKey.$POST);
02351                                                         if ($subpart)   {
02352                                                                 $this->setCurrentVal($subpart);
02353                                                                 $content = $this->substituteSubpart(
02354                                                                         $content,
02355                                                                         $PRE.$theKey.$POST,
02356                                                                         $this->cObjGetSingle($theValue,$conf['subparts.'][$theKey.'.'],'subparts.'.$theKey),
02357                                                                         1
02358                                                                 );
02359                                                         }
02360                                                 }
02361                                         }
02362                                 }
02363                                         // Getting subpart wraps
02364                                 if (is_array($conf['wraps.']))  {
02365                                         reset($conf['wraps.']);
02366                                         while(list($theKey,$theValue)=each($conf['wraps.']))    {
02367                                                 if (!strstr($theKey,'.'))       {
02368                                                         $subpart = $this->getSubpart($content, $PRE.$theKey.$POST);
02369                                                         if ($subpart)   {
02370                                                                 $this->setCurrentVal($subpart);
02371                                                                 $content = $this->substituteSubpart(
02372                                                                         $content,
02373                                                                         $PRE.$theKey.$POST,
02374                                                                         explode('|',$this->cObjGetSingle($theValue,$conf['wraps.'][$theKey.'.'],'wraps.'.$theKey)),
02375                                                                         1
02376                                                                 );
02377                                                         }
02378                                                 }
02379                                         }
02380                                 }
02381                         } else {        // CACHED
02382                                         // Getting subparts.
02383                                 if (is_array($conf['subparts.']))       {
02384                                         reset($conf['subparts.']);
02385                                         while(list($theKey,$theValue)=each($conf['subparts.'])) {
02386                                                 if (!strstr($theKey,'.'))       {
02387                                                         $subpart = $this->getSubpart($content, $PRE.$theKey.$POST);
02388                                                         if ($subpart)   {
02389                                                                 $GLOBALS['TSFE']->register['SUBPART_'.$theKey] = $subpart;
02390                                                                 $subparts[$theKey]['name'] = $theValue;
02391                                                                 $subparts[$theKey]['conf'] = $conf['subparts.'][$theKey.'.'];
02392                                                         }
02393                                                 }
02394                                         }
02395                                 }
02396                                         // Getting marks
02397                                 if (is_array($conf['marks.']))  {
02398                                         reset($conf['marks.']);
02399                                         while(list($theKey,$theValue)=each($conf['marks.']))    {
02400                                                 if (!strstr($theKey,'.'))       {
02401                                                         $marks[$theKey]['name'] = $theValue;
02402                                                         $marks[$theKey]['conf'] = $conf['marks.'][$theKey.'.'];
02403                                                 }
02404                                         }
02405                                 }
02406                                         // Getting subpart wraps
02407                                 if (is_array($conf['wraps.']))  {
02408                                         reset($conf['wraps.']);
02409                                         while(list($theKey,$theValue)=each($conf['wraps.']))    {
02410                                                 if (!strstr($theKey,'.'))       {
02411                                                         $wraps[$theKey]['name'] = $theValue;
02412                                                         $wraps[$theKey]['conf'] = $conf['wraps.'][$theKey.'.'];
02413                                                 }
02414                                         }
02415                                 }
02416                                         // Getting subparts
02417                                 $subpartArray =array();
02418                                 reset($subparts);
02419                                 while(list($theKey,$theValue)=each($subparts))  {
02420                                                 // Set current with the content of the subpart...
02421                                         $this->data[$this->currentValKey] = $GLOBALS['TSFE']->register['SUBPART_'.$theKey];
02422                                                 // Get subpart cObject and substitute it!
02423                                         $subpartArray[$PRE.$theKey.$POST] = $this->cObjGetSingle($theValue['name'],$theValue['conf'],'subparts.'.$theKey);
02424                                 }
02425                                 $this->data[$this->currentValKey] = ''; // Reset current to empty
02426 
02427                                         // Getting marks
02428                                 $markerArray =array();
02429                                 reset($marks);
02430                                 while(list($theKey,$theValue)=each($marks))     {
02431                                         $markerArray[$PRE.$theKey.$POST] = $this->cObjGetSingle($theValue['name'],$theValue['conf'],'marks.'.$theKey);
02432                                 }
02433                                         // Getting wraps
02434                                 $subpartWraps =array();
02435                                 reset($wraps);
02436                                 while(list($theKey,$theValue)=each($wraps))     {
02437                                         $subpartWraps[$PRE.$theKey.$POST] = explode('|',$this->cObjGetSingle($theValue['name'],$theValue['conf'],'wraps.'.$theKey));
02438                                 }
02439 
02440                                         // Substitution
02441                                 if ($conf['substMarksSeparately'])      {
02442                                         $content = $this->substituteMarkerArrayCached($content,array(),$subpartArray,$subpartWraps);
02443                                         $content = $this->substituteMarkerArray($content, $markerArray);
02444                                 } else {
02445                                         $content = $this->substituteMarkerArrayCached($content,$markerArray,$subpartArray,$subpartWraps);
02446                                 }
02447                         }
02448                 }
02449                 return $content;
02450         }
02451 
02459         function MULTIMEDIA($conf)      {
02460                 $content='';
02461                 $filename=$this->stdWrap($conf['file'],$conf['file.']);
02462                 $incFile = $GLOBALS['TSFE']->tmpl->getFileName($filename);
02463                 if ($incFile)   {
02464                         $fileinfo = t3lib_div::split_fileref($incFile);
02465                         if (t3lib_div::inList('txt,html,htm',$fileinfo['fileext']))     {
02466                                 $content = $GLOBALS['TSFE']->tmpl->fileContent($incFile);
02467                         } else {
02468                                         // default params...
02469                                 $parArray=array();
02470                                         // src is added
02471                                 $parArray['src']='src="'.$GLOBALS['TSFE']->absRefPrefix.$incFile.'"';
02472                                 if (t3lib_div::inList('au,wav,mp3',$fileinfo['fileext']))       {
02473                                 }
02474                                 if (t3lib_div::inList('avi,mov,mpg,asf,wmv',$fileinfo['fileext']))      {
02475                                         $parArray['width'] = 'width="200"';
02476                                         $parArray['height'] = 'height="200"';
02477                                 }
02478                                 if (t3lib_div::inList('swf,swa,dcr',$fileinfo['fileext']))      {
02479                                         $parArray['quality'] = 'quality="high"';
02480                                 }
02481                                 if (t3lib_div::inList('class',$fileinfo['fileext']))    {
02482                                         $parArray['width'] = 'width="200"';
02483                                         $parArray['height'] = 'height="200"';
02484                                 }
02485 
02486                                         // fetching params
02487                                 $lines = explode(chr(10), $this->stdWrap($conf['params'],$conf['params.']));
02488                                 while(list(,$l)=each($lines))   {
02489                                         $parts = explode('=', $l);
02490                                         $parameter = strtolower(trim($parts[0]));
02491                                         $value = trim($parts[1]);
02492                                         if ((string)$value!='') {
02493                                                 $parArray[$parameter] = $parameter.'="'.htmlspecialchars($value).'"';
02494                                         } else {
02495                                                 unset($parArray[$parameter]);
02496                                         }
02497                                 }
02498                                 if ($fileinfo['fileext']=='class')      {
02499                                         unset($parArray['src']);
02500                                         $parArray['code'] = 'code="'.htmlspecialchars($fileinfo['file']).'"';
02501                                         $parArray['codebase'] = 'codebase="'.htmlspecialchars($fileinfo['path']).'"';
02502                                         $content='<applet '.implode(' ',$parArray).'></applet>';
02503                                 } else {
02504                                         $content='<embed '.implode(' ',$parArray).'></embed>';
02505                                 }
02506                         }
02507                 }
02508 
02509                 if ($conf['stdWrap.']) {
02510                         $content=$this->stdWrap($content, $conf['stdWrap.']);
02511                 }
02512 
02513                 return $content;
02514         }
02515 
02516 
02517 
02518 
02519 
02520 
02521 
02522 
02523 
02524 
02525 
02526 
02527 
02528 
02529 
02530 
02531 
02532         /************************************
02533          *
02534          * Various helper functions for content objects:
02535          *
02536          ************************************/
02537 
02546         function getSlidePids($pidList, $pidConf)       {
02547                 $pidList = trim($this->stdWrap($pidList,$pidConf));
02548                 if (!strcmp($pidList,''))       {
02549                         $pidList = 'this';
02550                 }
02551                 if (trim($pidList))     {
02552                         $listArr = t3lib_div::intExplode(',',str_replace('this',$GLOBALS['TSFE']->contentPid,$pidList));
02553                         $listArr = $this->checkPidArray($listArr);
02554                 }
02555                 $pidList = array();
02556                 if (is_array($listArr)&&count($listArr))        {
02557                         foreach ($listArr as $uid)      {
02558                                 $page = $GLOBALS['TSFE']->sys_page->getPage($uid);
02559                                 if (!$page['is_siteroot'])      {
02560                                         $pidList[] = $page['pid'];
02561                                 }
02562                         }
02563                 }
02564                 return implode(',', $pidList);
02565         }
02566 
02577         function getFieldDefaultValue($noValueInsert, $fieldName, $defaultVal) {
02578                 if (!$GLOBALS['TSFE']->no_cache || (!isset($_POST[$fieldName]) && !isset($_GET[$fieldName])) || $noValueInsert) {
02579                         return $defaultVal;
02580                 } else {
02581                         return t3lib_div::_GP($fieldName);
02582                 }
02583         }
02584 
02595         function cImage($file,$conf) {
02596                 $info = $this->getImgResource($file,$conf['file.']);
02597                 $GLOBALS['TSFE']->lastImageInfo=$info;
02598                 if (is_array($info))    {
02599                         $info[3] = t3lib_div::png_to_gif_by_imagemagick($info[3]);
02600                         $GLOBALS['TSFE']->imagesOnPage[]=$info[3];              // This array is used to collect the image-refs on the page...
02601 
02602                         if (!strlen($conf['altText']) && !is_array($conf['altText.']))  {       // Backwards compatible:
02603                                 $conf['altText'] = $conf['alttext'];
02604                                 $conf['altText.'] = $conf['alttext.'];
02605                         }
02606                         $altParam = $this->getAltParam($conf);
02607 
02608                         $theValue = '<img src="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.t3lib_div::rawUrlEncodeFP($info[3])).'" width="'.$info[0].'" height="'.$info[1].'"'.$this->getBorderAttr(' border="'.intval($conf['border']).'"').($conf['params']?' '.$conf['params']:'').($altParam).' />';
02609                         if ($conf['linkWrap'])  {
02610                                 $theValue = $this->linkWrap($theValue,$conf['linkWrap']);
02611                         } elseif ($conf['imageLinkWrap']) {
02612                                 $theValue = $this->imageLinkWrap($theValue,$info['origFile'],$conf['imageLinkWrap.']);
02613                         }
02614                         return $this->wrap($theValue,$conf['wrap']);
02615                 }
02616         }
02617 
02624         function getBorderAttr($borderAttr) {
02625                 if (!t3lib_div::inList('xhtml_strict,xhtml_11,xhtml_2',$GLOBALS['TSFE']->xhtmlDoctype) && !$GLOBALS['TSFE']->config['config']['disableImgBorderAttr']) {
02626                         return $borderAttr;
02627                 }
02628         }
02629 
02640         function imageLinkWrap($string,$imageFile,$conf) {
02641                 $a1='';
02642                 $a2='';
02643                 $content=$string;
02644                 if ($this->stdWrap($conf['enable'],$conf['enable.']))   {
02645                         $content=$this->typolink($string, $conf['typolink.']);
02646                                 // imageFileLink:
02647                         if ($content==$string && @is_file($imageFile)) {
02648                                 $params = '';
02649                                 if ($conf['width']) {$params.='&width='.rawurlencode($conf['width']);}
02650                                 if ($conf['height']) {$params.='&height='.rawurlencode($conf['height']);}
02651                                 if ($conf['effects']) {$params.='&effects='.rawurlencode($conf['effects']);}
02652                                 if ($conf['sample']) {$params.='&sample=1';}
02653                                 if ($conf['alternativeTempPath']) {$params.='&alternativeTempPath='.rawurlencode($conf['alternativeTempPath']);}
02654 
02655                                 if ($conf['bodyTag']) {$params.='&bodyTag='.rawurlencode($conf['bodyTag']);}
02656                                 if ($conf['title']) {$params.='&title='.rawurlencode($conf['title']);}
02657                                 if ($conf['wrap']) {$params.='&wrap='.rawurlencode($conf['wrap']);}
02658 
02659                                 $md5_value = md5(
02660                                                 $imageFile.'|'.
02661                                                 $conf['width'].'|'.
02662                                                 $conf['height'].'|'.
02663                                                 $conf['effects'].'|'.
02664                                                 $conf['bodyTag'].'|'.
02665                                                 $conf['title'].'|'.
02666                                                 $conf['wrap'].'|'.
02667                                                 $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'].'|');
02668 
02669                                 $params.= '&md5='.$md5_value;
02670                                 $url = $GLOBALS['TSFE']->absRefPrefix.'index.php?eID=tx_cms_showpic&file='.rawurlencode($imageFile).$params;
02671                                 if ($conf['JSwindow.']['altUrl'] || $conf['JSwindow.']['altUrl.'])      {
02672                                         $altUrl = $this->stdWrap($conf['JSwindow.']['altUrl'], $conf['JSwindow.']['altUrl.']);
02673                                         if ($altUrl)    {
02674                                                 $url = $altUrl . ($conf['JSwindow.']['altUrl_noDefaultParams'] ? '' : '?file='.rawurlencode($imageFile).$params);
02675                                         }
02676                                 }
02677 
02678                                         // Create TARGET-attribute only if the right doctype is used
02679                                 if (!t3lib_div::inList('xhtml_strict,xhtml_11,xhtml_2', $GLOBALS['TSFE']->xhtmlDoctype))        {
02680                                         if (isset($conf['target']))     {
02681                                                 $target = sprintf(' target="%s"', $conf['target']);
02682                                         } else {
02683                                                 $target = ' target="thePicture"';
02684                                         }
02685                                 } else {
02686                                         $target = '';
02687                                 }
02688 
02689                                 if ($conf['JSwindow'])  {
02690                                         $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
02691                                         $gifCreator->init();
02692                                         $gifCreator->mayScaleUp = 0;
02693                                         $dims = $gifCreator->getImageScale($gifCreator->getImageDimensions($imageFile),$conf['width'],$conf['height'],'');
02694                                         $offset = t3lib_div::intExplode(',',$conf['JSwindow.']['expand'].',');
02695 
02696                                         $a1='<a href="'. htmlspecialchars($url) .'" onclick="'.
02697                                                 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;').
02698                                                 '"'.$target.$GLOBALS['TSFE']->ATagParams.'>';
02699                                         $a2='</a>';
02700                                         $GLOBALS['TSFE']->setJS('openPic');
02701                                 } else {
02702                                         $a1='<a href="'.htmlspecialchars($url).'"'.$target.$GLOBALS['TSFE']->ATagParams.'>';
02703                                         $a2='</a>';
02704                                 }
02705                                 $content=$a1.$string.$a2;
02706                         }
02707                 }
02708 
02709                 return $content;
02710         }
02711 
02720         function fileResource($fName, $addParams='alt="" title=""')     {
02721                 $incFile = $GLOBALS['TSFE']->tmpl->getFileName($fName);
02722                 if ($incFile)   {
02723                         $fileinfo = t3lib_div::split_fileref($incFile);
02724                         if (t3lib_div::inList('jpg,gif,jpeg,png',$fileinfo['fileext'])) {
02725                                 $imgFile = $incFile;
02726                                 $imgInfo = @getImageSize($imgFile);
02727                                 return '<img src="'.$GLOBALS['TSFE']->absRefPrefix.$imgFile.'" width="'.$imgInfo[0].'" height="'.$imgInfo[1].'"'.$this->getBorderAttr(' border="0"').' '.$addParams.' />';
02728                         } elseif (filesize($incFile)<1024*1024) {
02729                                 return $GLOBALS['TSFE']->tmpl->fileContent($incFile);
02730                         }
02731                 }
02732         }
02733 
02743         function lastChanged($tstamp)   {
02744                 $tstamp = intval($tstamp);
02745                 if ($tstamp>intval($GLOBALS['TSFE']->register['SYS_LASTCHANGED']))      {
02746                         $GLOBALS['TSFE']->register['SYS_LASTCHANGED'] = $tstamp;
02747                 }
02748         }
02749 
02760         function linkWrap($content,$wrap)       {
02761                 $wrapArr = explode('|', $wrap);
02762                 if (ereg("\{([0-9]*)\}",$wrapArr[0],$reg))      {
02763                         if ($uid = $GLOBALS['TSFE']->tmpl->rootLine[$reg[1]]['uid'])    {
02764                                 $wrapArr[0] = str_replace($reg[0],$uid,$wrapArr[0]);
02765                         }
02766                 }
02767                 return trim($wrapArr[0]).$content.trim($wrapArr[1]);
02768         }
02769 
02779         function getAltParam($conf, $longDesc=true)     {
02780                 $altText = trim($this->stdWrap($conf['altText'], $conf['altText.']));
02781                 $titleText = trim($this->stdWrap($conf['titleText'],$conf['titleText.']));
02782                 $longDesc = trim($this->stdWrap($conf['longdescURL'],$conf['longdescURL.']));
02783 
02784                         // "alt":
02785                 $altParam = ' alt="'.htmlspecialchars(strip_tags($altText)).'"';
02786 
02787                         // "title":
02788                 $emptyTitleHandling = 'useAlt';
02789                 if ($conf['emptyTitleHandling'])        {
02790                                 // choices: 'keepEmpty' | 'useAlt' | 'removeAttr'
02791                         $emptyTitleHandling = $conf['emptyTitleHandling'];
02792                 }
02793                 if ($titleText || $emptyTitleHandling == 'keepEmpty')   {
02794                         $altParam.= ' title="'.htmlspecialchars(strip_tags($titleText)).'"';
02795                 } elseif (!$titleText && $emptyTitleHandling == 'useAlt')       {
02796                         $altParam.= ' title="'.htmlspecialchars(strip_tags($altText)).'"';
02797                 }
02798 
02799                         // "longDesc" URL
02800                 if ($longDesc)  {
02801                         $altParam.= ' longdesc="'.htmlspecialchars(strip_tags($longDesc)).'"';
02802                 }
02803 
02804                 return $altParam;
02805         }
02806 
02814         function cleanFormName($name) {
02815                         // turn data[x][y] into data:x:y:
02816                 $name = preg_replace('/\[|\]\[?/',':',trim($name));
02817                         // remove illegal chars like _
02818                 return preg_replace('#[^:a-zA-Z0-9]#','',$name);
02819         }
02820 
02830          function getATagParams($conf, $addGlobal=1)    {
02831                 $aTagParams = '';
02832                 if ($conf['ATagParams.'])       {
02833                         $aTagParams = ' '.$this->stdWrap($conf['ATagParams'], $conf['ATagParams.']);
02834                 } elseif ($conf['ATagParams'])  {
02835                         $aTagParams = ' '.$conf['ATagParams'];
02836                 }
02837                 if ($addGlobal) {
02838                         $aTagParams = ' '.trim($GLOBALS['TSFE']->ATagParams.$aTagParams);
02839                 }
02840                 return $aTagParams;
02841          }
02842 
02843 
02844 
02845 
02846 
02847 
02848 
02849 
02850 
02851 
02852 
02853 
02854 
02855 
02856 
02857 
02858 
02859 
02860         /***********************************************
02861          *
02862          * HTML template processing functions
02863          *
02864          ***********************************************/
02865 
02877         function getSubpart($content, $marker)  {
02878                 return t3lib_parsehtml::getSubpart($content, $marker);
02879         }
02880 
02893         function substituteSubpart($content,$marker,$subpartContent,$recursive=1)       {
02894                 return t3lib_parsehtml::substituteSubpart($content, $marker, $subpartContent, $recursive);
02895         }
02896 
02906         function substituteMarker($content,$marker,$markContent)        {
02907                 return str_replace($marker,$markContent,$content);
02908         }
02909 
02926         function substituteMarkerArrayCached($content,$markContentArray=array(),$subpartContentArray=array(),$wrappedSubpartContentArray=array())       {
02927                 $GLOBALS['TT']->push('substituteMarkerArray');
02928 
02929                         // If not arrays then set them
02930                 if (!is_array($markContentArray))       $markContentArray=array();      // Plain markers
02931                 if (!is_array($subpartContentArray))    $subpartContentArray=array();   // Subparts being directly substituted
02932                 if (!is_array($wrappedSubpartContentArray))     $wrappedSubpartContentArray=array();    // Subparts being wrapped
02933                         // Finding keys and check hash:
02934                 $sPkeys = array_keys($subpartContentArray);
02935                 $wPkeys = array_keys($wrappedSubpartContentArray);
02936                 $aKeys = array_merge(array_keys($markContentArray),$sPkeys,$wPkeys);
02937                 if (!count($aKeys))     {
02938                         $GLOBALS['TT']->pull();
02939                         return $content;
02940                 }
02941                 asort($aKeys);
02942                 $storeKey = md5('substituteMarkerArrayCached_storeKey:'.serialize(array($content,$aKeys)));
02943                 if ($this->substMarkerCache[$storeKey]) {
02944                         $storeArr = $this->substMarkerCache[$storeKey];
02945                         $GLOBALS['TT']->setTSlogMessage('Cached',0);
02946                 } else {
02947                         $storeArrDat = $GLOBALS['TSFE']->sys_page->getHash($storeKey,0);
02948                         if (!isset($storeArrDat))       {
02949                                         // Initialize storeArr
02950                                 $storeArr=array();
02951 
02952                                         // Finding subparts and substituting them with the subpart as a marker
02953                                 reset($sPkeys);
02954                                 while(list(,$sPK)=each($sPkeys))        {
02955                                         $content =$this->substituteSubpart($content,$sPK,$sPK);
02956                                 }
02957 
02958                                         // Finding subparts and wrapping them with markers
02959                                 reset($wPkeys);
02960                                 while(list(,$wPK)=each($wPkeys))        {
02961                                         $content =$this->substituteSubpart($content,$wPK,array($wPK,$wPK));
02962                                 }
02963 
02964                                         // traverse keys and quote them for reg ex.
02965                                 reset($aKeys);
02966                                 while(list($tK,$tV)=each($aKeys))       {
02967                                         $aKeys[$tK]=quotemeta($tV);
02968                                 }
02969                                 $regex = implode('|',$aKeys);
02970                                         // Doing regex's
02971                                 $storeArr['c'] = split($regex,$content);
02972                                 preg_match_all('/'.$regex.'/',$content,$keyList);
02973                                 $storeArr['k']=$keyList[0];
02974                                         // Setting cache:
02975                                 $this->substMarkerCache[$storeKey] = $storeArr;
02976 
02977                                         // Storing the cached data:
02978                                 $GLOBALS['TSFE']->sys_page->storeHash($storeKey, serialize($storeArr), 'substMarkArrayCached');
02979 
02980                                 $GLOBALS['TT']->setTSlogMessage('Parsing',0);
02981                         } else {
02982                                         // Unserializing
02983                                 $storeArr = unserialize($storeArrDat);
02984                                         // Setting cache:
02985                                 $this->substMarkerCache[$storeKey] = $storeArr;
02986                                 $GLOBALS['TT']->setTSlogMessage('Cached from DB',0);
02987                         }
02988                 }
02989 
02990                         // Substitution/Merging:
02991                         // Merging content types together, resetting
02992                 $valueArr = array_merge($markContentArray,$subpartContentArray,$wrappedSubpartContentArray);
02993 
02994                 $wSCA_reg=array();
02995                 reset($storeArr['k']);
02996                 $content = '';
02997                         // traversin the keyList array and merging the static and dynamic content
02998                 while(list($n,$keyN)=each($storeArr['k']))      {
02999                         $content.=$storeArr['c'][$n];
03000                         if (!is_array($valueArr[$keyN]))        {
03001                                 $content.=$valueArr[$keyN];
03002                         } else {
03003                                 $content.=$valueArr[$keyN][(intval($wSCA_reg[$keyN])%2)];
03004                                 $wSCA_reg[$keyN]++;
03005                         }
03006                 }
03007                 $content.=$storeArr['c'][count($storeArr['k'])];
03008 
03009                 $GLOBALS['TT']->pull();
03010                 return $content;
03011         }
03012 
03024         function substituteMarkerArray($content,$markContentArray,$wrap='',$uppercase=0)        {
03025                 if (is_array($markContentArray))        {
03026                         reset($markContentArray);
03027                         $wrapArr=t3lib_div::trimExplode('|',$wrap);
03028                         while(list($marker,$markContent)=each($markContentArray))       {
03029                                 if($uppercase)  $marker=strtoupper($marker);
03030                                 if(strcmp($wrap,''))            $marker=$wrapArr[0].$marker.$wrapArr[1];
03031                                 $content=str_replace($marker,$markContent,$content);
03032                         }
03033                 }
03034                 return $content;
03035         }
03036 
03045         function substituteMarkerInObject(&$tree, $markContentArray) {
03046                 if (is_array ($tree))   {
03047                         reset($tree);
03048                         while(list($key,$value)=each($tree))    {
03049                                 $this->substituteMarkerInObject ($tree[$key], $markContentArray);
03050                         }
03051                 } else {
03052                         $tree = $this->substituteMarkerArray($tree,$markContentArray);
03053                 }
03054                 return $tree;
03055         }
03056 
03068         function fillInMarkerArray($markContentArray, $row, $fieldList='', $nl2br=TRUE, $prefix='FIELD_', $HSC=FALSE)   {
03069                 if ($fieldList) {
03070                         $fArr = t3lib_div::trimExplode(',',$fieldList,1);
03071                         foreach($fArr as $field)        {
03072                                 $markContentArray['###'.$prefix.$field.'###'] = $nl2br?nl2br($row[$field]):$row[$field];
03073                         }
03074                 } else {
03075                         if (is_array($row))     {
03076                                 foreach($row as $field => $value)       {
03077                                         if (!t3lib_div::testInt($field))        {
03078                                                 if ($HSC)       $value = htmlspecialchars($value);
03079                                                 $markContentArray['###'.$prefix.$field.'###'] = $nl2br ? nl2br($value) : $value;
03080                                         }
03081                                 }
03082                         }
03083                 }
03084 
03085                 return $markContentArray;
03086         }
03087 
03088 
03089 
03090 
03091 
03092 
03093 
03094 
03095 
03096 
03097 
03098 
03099 
03100 
03101 
03102 
03103 
03104 
03105 
03106 
03107 
03108 
03109 
03110 
03111 
03112         /***********************************************
03113          *
03114          * "stdWrap" + sub functions
03115          *
03116          ***********************************************/
03117 
03118 
03131         function stdWrap($content,$conf)        {
03132                 if (is_array($conf))    {
03133 
03134                                 // Setting current value, if so
03135                         if ($conf['setContentToCurrent']){$this->data[$this->currentValKey]=$content;}
03136                         if ($conf['setCurrent'] || $conf['setCurrent.']){$this->data[$this->currentValKey] = $this->stdWrap($conf['setCurrent'], $conf['setCurrent.']);}
03137 
03138                                 // Getting data:
03139                         if (isset($conf['lang.']) && $GLOBALS['TSFE']->config['config']['language'] && isset($conf['lang.'][$GLOBALS['TSFE']->config['config']['language']]))   {
03140                                 $content = $conf['lang.'][$GLOBALS['TSFE']->config['config']['language']];
03141                         }
03142                         if ($conf['data']){$content=$this->getData($conf['data'], is_array($this->alternativeData)?$this->alternativeData:$this->data);}
03143                                 $this->alternativeData='';              // This must be unset directly after
03144                         if ($conf['field']) {$content=$this->getFieldVal($conf['field']);}
03145                         if ($conf['current']) {$content=$this->data[$this->currentValKey];}
03146                         if ($conf['cObject']) {$content=$this->cObjGetSingle($conf['cObject'],$conf['cObject.'],'/stdWrap/.cObject');}
03147                         if ($conf['numRows.']) {$content=$this->numRows($conf['numRows.']);}
03148                         if ($conf['filelist'] || $conf['filelist.'])    {$content=$this->filelist($this->stdWrap($conf['filelist'], $conf['filelist.']));}
03149                         if ($conf['preUserFunc'])       {$content = $this->callUserFunction($conf['preUserFunc'], $conf['preUserFunc.'], $content);}
03150 
03151                                 // Overriding values, evaluating conditions
03152                         if ($conf['override'] || $conf['override.']){
03153                                 $override = $this->stdWrap($conf['override'], $conf['override.']);
03154                                 if (trim($override)) {$content=$override;}
03155                         }
03156                         if (isset($conf['preIfEmptyListNum']) || isset($conf['preIfEmptyListNum.']['stdWrap.'])) {
03157                                 $preIfEmptyListNumber = isset($conf['preIfEmptyListNum.']['stdWrap.'])  ?  $this->stdWrap($conf['preIfEmptyListNum'], $conf['preIfEmptyListNum.']['stdWrap.'])  :  $conf['preIfEmptyListNum'];
03158                                 $content=$this->listNum($content,$preIfEmptyListNumber,$conf['preIfEmptyListNum.']['splitChar']);
03159                         }
03160                         if (!trim($content) && ($conf['ifEmpty'] || $conf['ifEmpty.'])) {
03161                                 $content = $this->stdWrap($conf['ifEmpty'], $conf['ifEmpty.']);
03162                         }
03163                         if (!strlen(trim($content)) && ($conf['ifBlank'] || $conf['ifBlank.'])) {
03164                                 $content = $this->stdWrap($conf['ifBlank'], $conf['ifBlank.']);
03165                         }
03166 
03167                                 // values...
03168                         if (isset($conf['listNum']) || isset($conf['listNum.']['stdWrap.'])) {
03169                                 $listNumber = isset($conf['listNum.']['stdWrap.'])  ?  $this->stdWrap($conf['listNum'], $conf['listNum.']['stdWrap.'])  :  $conf['listNum'];
03170                                 $content=$this->listNum($content,$listNumber,$conf['listNum.']['splitChar']);
03171                         }
03172 
03173                         if ($conf['trim'])      { $content=trim($content); }
03174 
03175                                 // Call stdWrap recursively
03176                         if ($conf['stdWrap.'])  { $content=$this->stdWrap($content,$conf['stdWrap.']); }
03177 
03178                         if (   ($conf['required'] && (string)$content=='') || ($conf['if.'] && !$this->checkIf($conf['if.'])) || ($conf['fieldRequired'] && !trim($this->data[$conf['fieldRequired']]))    ){
03179                                 $content = '';
03180                         } else  {
03181                                         // Perform data processing:
03182                                 if ($conf['csConv'])    { $content=$GLOBALS['TSFE']->csConv($content,$conf['csConv']); }
03183                                 if ($conf['parseFunc.'] || $conf['parseFunc']) {$content=$this->parseFunc($content,$conf['parseFunc.'],$conf['parseFunc']);}
03184                                 if ($conf['HTMLparser'] && is_array($conf['HTMLparser.'])) {$content=$this->HTMLparser_TSbridge($content,$conf['HTMLparser.']);}
03185                                 if ($conf['split.']){$content=$this->splitObj($content,$conf['split.']);}
03186                                 if ($conf['prioriCalc']){$content=t3lib_div::calcParenthesis($content); if ($conf['prioriCalc']=='intval') $content=intval($content);}
03187                                 if ((string)$conf['char']!=''){$content=chr(intval($conf['char']));}
03188                                 if ($conf['intval']){$content=intval($content);}
03189                                 if ($conf['date']){$content=date($conf['date'], $content);}
03190                                 if ($conf['strftime']){
03191                                         $content = strftime($conf['strftime'], $content);
03192                                         $tmp_charset = $conf['strftime.']['charset'] ? $conf['strftime.']['charset'] : $GLOBALS['TSFE']->localeCharset;
03193                                         if ($tmp_charset)       {
03194                                                 $content = $GLOBALS['TSFE']->csConv($content,$tmp_charset);
03195                                         }
03196                                 }
03197                                 if ($conf['age']){$content=$this->calcAge(time()-$content,$conf['age']);}
03198 
03199                                 if ($conf['case']){$content=$this->HTMLcaseshift($content, $conf['case']);}
03200                                 if ($conf['bytes']){$content=$this->bytes($content,$conf['bytes.']['labels']);}
03201                                 if ($conf['substring']){$content=$this->substring($content,$conf['substring']);}
03202                                 if ($conf['removeBadHTML'])     {$content = $this->removeBadHTML($content, $conf['removeBadHTML.']);}
03203                                 if ($conf['stripHtml']){$content = strip_tags($content);}
03204                                 if ($conf['crop']){$content=$this->crop($content, $conf['crop']);}
03205                                 if ($conf['rawUrlEncode']){$content = rawurlencode($content);}
03206                                 if ($conf['htmlSpecialChars']){
03207                                         $content=htmlSpecialChars($content);
03208                                         if ($conf['htmlSpecialChars.']['preserveEntities'])     $content = t3lib_div::deHSCentities($content);
03209                                 }
03210 
03211                                 if ($conf['doubleBrTag']) {
03212                                         $content=ereg_replace("\r?\n[\t ]*\r?\n",$conf['doubleBrTag'],$content);
03213                                 }
03214                                 if ($conf['br']) {$content=nl2br($content);}
03215                                 if ($conf['brTag']) {$content= ereg_replace(chr(10),$conf['brTag'],$content);}
03216                                 if ($conf['encapsLines.']) {$content=$this->encaps_lineSplit($content,$conf['encapsLines.']);}
03217                                 if ($conf['keywords']) {$content= $this->keywords($content);}
03218                                 if ($conf['innerWrap'] || $conf['innerWrap.']){$content=$this->wrap($content, $this->stdWrap($conf['innerWrap'], $conf['innerWrap.']));}
03219                                 if ($conf['innerWrap2'] || $conf['innerWrap2.']){$content=$this->wrap($content, $this->stdWrap($conf['innerWrap2'], $conf['innerWrap2.']));}
03220                                 if ($conf['fontTag']){$content=$this->wrap($content, $conf['fontTag']);}
03221                                 if ($conf['addParams.']) {$content=$this->addParams($content,$conf['addParams.']);}
03222                                 if ($conf['textStyle.']) {$content=$this->textStyle($content,$conf['textStyle.']);}
03223                                 if ($conf['tableStyle.']) {$content=$this->tableStyle($content,$conf['tableStyle.']);}
03224                                 if ($conf['filelink.']) {$content=$this->filelink($content,$conf['filelink.']);}
03225                                 if ($conf['preCObject']) {$content=$this->cObjGetSingle($conf['preCObject'],$conf['preCObject.'],'/stdWrap/.preCObject').$content;}
03226                                 if ($conf['postCObject']) {$content.=$this->cObjGetSingle($conf['postCObject'],$conf['postCObject.'],'/stdWrap/.postCObject');}
03227 
03228                                 if ($conf['wrapAlign'] || $conf['wrapAlign.']){
03229                                         $wrapAlign = trim($this->stdWrap($conf['wrapAlign'], $conf['wrapAlign.']));
03230                                         if ($wrapAlign) {$content=$this->wrap($content, '<div style="text-align:'.$wrapAlign.';">|</div>');}
03231                                 }
03232                                 if ($conf['typolink.']){$content=$this->typolink($content, $conf['typolink.']);}
03233                                 if (is_array($conf['TCAselectItem.'])) {$content=$this->TCAlookup($content,$conf['TCAselectItem.']);}
03234 
03235                                         // Spacing
03236                                 if ($conf['space']){$content=$this->wrapSpace($content, $conf['space']);}
03237                                 $spaceBefore = '';
03238                                 if ($conf['spaceBefore'] || $conf['spaceBefore.'])      {$spaceBefore = trim($this->stdWrap($conf['spaceBefore'], $conf['spaceBefore.']));}
03239                                 $spaceAfter = '';
03240                                 if ($conf['spaceAfter'] || $conf['spaceAfter.'])        {$spaceAfter = trim($this->stdWrap($conf['spaceAfter'], $conf['spaceAfter.']));}
03241                                 if ($spaceBefore || $spaceAfter)        {$content=$this->wrapSpace($content, $spaceBefore.'|'.$spaceAfter);}
03242 
03243                                         // Wraps
03244                                 if ($conf['wrap']){$content=$this->wrap($content, $conf['wrap'], ($conf['wrap.']['splitChar']?$conf['wrap.']['splitChar']:'|'));}
03245                                 if ($conf['noTrimWrap']){$content=$this->noTrimWrap($content, $conf['noTrimWrap']);}
03246                                 if ($conf['wrap2']){$content=$this->wrap($content, $conf['wrap2'], ($conf['wrap2.']['splitChar']?$conf['wrap2.']['splitChar']:'|'));}
03247                                 if ($conf['dataWrap']){$content=$this->dataWrap($content, $conf['dataWrap']);}
03248                                 if ($conf['prepend']){$content=$this->cObjGetSingle($conf['prepend'],$conf['prepend.'],'/stdWrap/.prepend').$content;}
03249                                 if ($conf['append']){$content.=$this->cObjGetSingle($conf['append'],$conf['append.'],'/stdWrap/.append');}
03250                                 if ($conf['wrap3']){$content=$this->wrap($content, $conf['wrap3'], ($conf['wrap3.']['splitChar']?$conf['wrap3.']['splitChar']:'|'));}
03251                                 if ($conf['outerWrap'] || $conf['outerWrap.']){$content=$this->wrap($content, $this->stdWrap($conf['outerWrap'], $conf['outerWrap.']));}
03252                                 if ($conf['insertData'])        {$content = $this->insertData($content);}
03253                                 if ($conf['offsetWrap']){
03254                                         $controlTable = t3lib_div::makeInstance('tslib_tableOffset');
03255                                         if ($conf['offsetWrap.']['tableParams'] || $conf['offsetWrap.']['tableParams.'])        {$controlTable->tableParams = $this->stdWrap($conf['offsetWrap.']['tableParams'], $conf['offsetWrap.']['tableParams.']);}
03256                                         if ($conf['offsetWrap.']['tdParams'] || $conf['offsetWrap.']['tdParams.'])      {$controlTable->tdParams = ' '.$this->stdWrap($conf['offsetWrap.']['tdParams'], $conf['offsetWrap.']['tdParams.']);}
03257                                         $content=$controlTable->start($content,$conf['offsetWrap']);
03258                                         if ($conf['offsetWrap.']['stdWrap.'])   {       $content=$this->stdWrap($content,$conf['offsetWrap.']['stdWrap.']);     }
03259                                 }
03260                                 if ($conf['postUserFunc'])      {$content = $this->callUserFunction($conf['postUserFunc'], $conf['postUserFunc.'], $content);}
03261                                 if ($conf['postUserFuncInt'])   {
03262                                         $substKey = 'INT_SCRIPT.'.$GLOBALS['TSFE']->uniqueHash();
03263                                         $GLOBALS['TSFE']->config['INTincScript'][$substKey] = array(
03264                                                 'content' => $content,
03265                                                 'postUserFunc' => $conf['postUserFuncInt'],
03266                                                 'conf' => $conf['postUserFuncInt.'],
03267                                                 'type' => 'POSTUSERFUNC',
03268                                                 'cObj' => serialize($this),
03269                                         );
03270                                         $content ='<!--'.$substKey.'-->';
03271                                 }
03272                                         // Various:
03273                                 if ($conf['prefixComment'] && !$GLOBALS['TSFE']->config['config']['disablePrefixComment'])      {$content = $this->prefixComment($conf['prefixComment'], $conf['prefixComment.'], $content);}
03274 
03275                                 if ($conf['editIcons'] && $GLOBALS['TSFE']->beUserLogin){$content=$this->editIcons($content,$conf['editIcons'],$conf['editIcons.']);}
03276                                 if ($conf['editPanel'] && $GLOBALS['TSFE']->beUserLogin){$content=$this->editPanel($content, $conf['editPanel.']);}
03277                         }
03278 
03279                                 //Debug:
03280                         if ($conf['debug'])     {$content = '<pre>'.htmlspecialchars($content).'</pre>';}
03281                         if ($conf['debugFunc']) {debug($conf['debugFunc']==2?array($content):$content);}
03282                         if ($conf['debugData']) {
03283                                 echo '<b>$cObj->data:</b>';
03284                                 debug($this->data,'$cObj->data:');
03285                                 if (is_array($this->alternativeData))   {
03286                                         echo '<b>$cObj->alternativeData:</b>';
03287                                         debug($this->alternativeData,'$this->alternativeData');
03288                                 }
03289                         }
03290                 }
03291                 return $content;
03292         }
03293 
03305         function numRows($conf) {
03306                 $conf['select.']['selectFields'] = 'count(*)';
03307 
03308                 $res = $this->exec_getQuery($conf['table'],$conf['select.']);
03309 
03310                 if ($error = $GLOBALS['TYPO3_DB']->sql_error()) {
03311                         $GLOBALS['TT']->setTSlogMessage($error,3);
03312                 } else {
03313                         $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res);
03314                         return intval($row[0]);
03315                 }
03316         }
03317 
03326         function listNum($content,$listNum,$char) {
03327                 $char = $char ? $char : ',';
03328                 if (t3lib_div::testInt($char))  {
03329                         $char = chr($char);
03330                 }
03331                 $temp = explode($char,$content);
03332                 $last = ''.(count($temp)-1);
03333                 $index=$this->calc(eregi_replace('last',$last,$listNum));
03334                 return $temp[$index];
03335         }
03336 
03346         function checkIf($conf) {
03347                 if (!is_array($conf))   {return true;}
03348                 if (isset($conf['directReturn']))       {return $conf['directReturn'] ? 1 : 0;}
03349                 $flag = true;
03350                         if (isset($conf['isTrue']) || isset($conf['isTrue.']))  {
03351                                 $isTrue = trim($this->stdWrap($conf['isTrue'],$conf['isTrue.']));
03352                                 if (!$isTrue)   {
03353                                         $flag=0;
03354                                 }
03355                         }
03356                         if (isset($conf['isFalse']) || isset($conf['isFalse.']))        {
03357                                 $isFalse = trim($this->stdWrap($conf['isFalse'],$conf['isFalse.']));
03358                                 if ($isFalse)   {
03359                                         $flag=0;
03360                                 }
03361                         }
03362                         if (isset($conf['isPositive']) || isset($conf['isPositive.']))  {
03363                                 $number = $this->calc($this->stdWrap($conf['isPositive'],$conf['isPositive.']));
03364                                 if ($number<1)  {
03365                                         $flag=0;
03366                                 }
03367                         }
03368                         if ($flag)      {
03369                                 $value = trim($this->stdWrap($conf['value'],$conf['value.']));
03370 
03371                                 if (isset($conf['isGreaterThan']) || isset($conf['isGreaterThan.']))    {
03372                                         $number = trim($this->stdWrap($conf['isGreaterThan'],$conf['isGreaterThan.']));
03373                                         if ($number<=$value)    {
03374                                                 $flag=0;
03375                                         }
03376                                 }
03377                                 if (isset($conf['isLessThan']) || isset($conf['isLessThan.']))  {
03378                                         $number = trim($this->stdWrap($conf['isLessThan'],$conf['isLessThan.']));
03379                                         if ($number>=$value)    {
03380                                                 $flag=0;
03381                                         }
03382                                 }
03383                                 if (isset($conf['equals']) || isset($conf['equals.']))  {
03384                                         $number = trim($this->stdWrap($conf['equals'],$conf['equals.']));
03385                                         if ($number!=$value)    {
03386                                                 $flag=0;
03387                                         }
03388                                 }
03389                                 if (isset($conf['isInList']) || isset($conf['isInList.']))      {
03390                                         $number = trim($this->stdWrap($conf['isInList'],$conf['isInList.']));
03391                                         if (!t3lib_div::inList($value,$number)) {
03392                                                 $flag=0;
03393                                         }
03394                                 }
03395                         }
03396                 if ($conf['negate'])    {$flag = $flag ? 0 : 1;}
03397                 return $flag;
03398         }
03399 
03409         function filelist($data)        {
03410                 $data = trim($data);
03411                 if ($data)      {
03412                         $data_arr = explode('|',$data);
03413                                 // read directory:
03414                         if ($GLOBALS['TSFE']->lockFilePath)     {               // MUST exist!
03415                                 $path = $this->clean_directory($data_arr[0]);   // Cleaning name..., only relative paths accepted.
03416                                 $path = substr($path,0,strlen($GLOBALS['TSFE']->lockFilePath))==$GLOBALS['TSFE']->lockFilePath ? $path : '';
03417                         }
03418                         if ($path)      {
03419                                 $items = Array('files'=>array(), 'sorting'=>array());
03420                                 $ext_list = strtolower(t3lib_div::uniqueList($data_arr[1]));
03421                                 $sorting = trim($data_arr[2]);
03422                                         // read dir:
03423                                 $d = @dir($path);
03424                                 $tempArray=Array();
03425                                 if (is_object($d))      {
03426                                         $count=0;
03427                                         while($entry=$d->read()) {
03428                                                 if ($entry!='.' && $entry!='..')        {
03429                                                         $wholePath = $path.'/'.$entry;          // Because of odd PHP-error where  <br />-tag is sometimes placed after a filename!!
03430                                                         if (@file_exists($wholePath) && filetype($wholePath)=='file')   {
03431                                                                 $info = t3lib_div::split_fileref($wholePath);
03432                                                                 if (!$ext_list || t3lib_div::inList($ext_list,$info['fileext']))        {
03433                                                                         $items['files'][] = $info['file'];
03434                                                                         switch($sorting)        {
03435                                                                                 case 'name':
03436                                                                                         $items['sorting'][] = strtolower($info['file']);
03437                                                                                 break;
03438                                                                                 case 'size':
03439                                                                                         $items['sorting'][] = filesize($wholePath);
03440                                                                                 break;
03441                                                                                 case 'ext':
03442                                                                                         $items['sorting'][] = $info['fileext'];
03443                                                                                 break;
03444                                                                                 case 'date':
03445                                                                                         $items['sorting'][] = filectime($wholePath);
03446                                                                                 break;
03447                                                                                 case 'mdate':
03448                                                                                         $items['sorting'][] = filemtime($wholePath);
03449                                                                                 break;
03450                                                                                 default:
03451                                                                                         $items['sorting'][] = $count;
03452                                                                                 break;
03453                                                                         }
03454                                                                         $count++;
03455                                                                 }
03456                                                         }
03457                                                 }
03458                                         }
03459                                         $d->close();
03460                                 }
03461                                         // Sort if required
03462                                 if (count($items['sorting']))   {
03463                                         if (strtolower(trim($data_arr[3]))!='r')        {
03464                                                 asort($items['sorting']);
03465                                         } else {
03466                                                 arsort($items['sorting']);
03467                                         }
03468                                 }
03469                                 if (count($items['files']))     {
03470                                                 // make list
03471                                         reset($items['sorting']);
03472                                         $fullPath = trim($data_arr[4]);
03473                                         $list_arr=Array();
03474                                         while(list($key,)=each($items['sorting']))      {
03475                                                 $list_arr[]=  $fullPath ? $path.'/'.$items['files'][$key] : $items['files'][$key];
03476                                         }
03477                                         return implode(',',$list_arr);
03478                                 }
03479                         }
03480                 }
03481         }
03482 
03491         function clean_directory($theDir)       {
03492                 if (t3lib_div::validPathStr($theDir))   {               // proceeds if no '//', '..' or '\' is in the $theFile
03493                         $theDir = ereg_replace("[\/\. ]*$",'',$theDir);         // Removes all dots, slashes and spaces after a path...
03494                         if (!t3lib_div::isAbsPath($theDir) && @is_dir($theDir)) {
03495                                 return $theDir;
03496                         }
03497                 }
03498         }
03499 
03509         function HTMLparser_TSbridge($theValue, $conf)  {
03510                 $htmlParser = t3lib_div::makeInstance('t3lib_parsehtml');
03511                 $htmlParserCfg =  $htmlParser->HTMLparserConfig($conf);
03512                 return $htmlParser->HTMLcleaner($theValue,$htmlParserCfg[0],$htmlParserCfg[1],$htmlParserCfg[2],$htmlParserCfg[3]);
03513         }
03514 
03523         function dataWrap($content,$wrap)       {
03524                 return $this->wrap($content,$this->insertData($wrap));
03525         }
03526 
03536         function insertData($str)       {
03537                 $inside=0;
03538                 $newVal='';
03539                 $pointer=0;
03540                 $totalLen = strlen($str);
03541                 do      {
03542                         if (!$inside)   {
03543                                 $len = strcspn(substr($str,$pointer),'{');
03544                                 $newVal.= substr($str,$pointer,$len);
03545                                 $inside = 1;
03546                         } else {
03547                                 $len = strcspn(substr($str,$pointer),'}')+1;
03548                                 $newVal.= $this->getData(substr($str,$pointer+1,$len-2),$this->data);
03549                                 $inside = 0;
03550                         }
03551                         $pointer+=$len;
03552                 } while($pointer<$totalLen);
03553                 return $newVal;
03554         }
03555 
03566         function prefixComment($str,$conf,$content)     {
03567                 $parts = explode('|',$str);
03568 
03569                 $output =
03570                         chr(10).str_pad('',$parts[0],chr(9)).
03571                         '<!-- '.htmlspecialchars($this->insertData($parts[1])).' [begin] -->'.
03572                         chr(10).str_pad('',$parts[0]+1,chr(9)).
03573                                 $content.
03574                         chr(10).str_pad('',$parts[0],chr(9)).
03575                         '<!-- '.htmlspecialchars($this->insertData($parts[1])).' [end] -->'.
03576                         chr(10).str_pad('',$parts[0]+1,chr(9));
03577 
03578                 return $output;
03579         }
03580 
03590         function substring($content,$options)   {
03591                 $options = t3lib_div::intExplode(',',$options.',');
03592                 if ($options[1])        {
03593                         return $GLOBALS['TSFE']->csConvObj->substr($GLOBALS['TSFE']->renderCharset,$content,$options[0],$options[1]);
03594                 } else {
03595                         return $GLOBALS['TSFE']->csConvObj->substr($GLOBALS['TSFE']->renderCharset,$content,$options[0]);
03596                 }
03597         }
03598 
03608         function crop($content,$options)        {
03609                 $options = explode('|',$options);
03610                 $chars = intval($options[0]);
03611                 $afterstring = trim($options[1]);
03612                 $crop2space = trim($options[2]);
03613                 if ($chars)     {
03614                         if (strlen($content)>abs($chars))       {
03615                                 if ($chars<0)   {
03616                                         $content = $GLOBALS['TSFE']->csConvObj->substr($GLOBALS['TSFE']->renderCharset,$content,$chars);
03617                                         $trunc_at = strpos($content, ' ');
03618                                         $content = ($trunc_at&&$crop2space) ? $afterstring.substr($content,$trunc_at) : $afterstring.$content;
03619                                 } else {
03620                                         $content = $GLOBALS['TSFE']->csConvObj->substr($GLOBALS['TSFE']->renderCharset,$content,0,$chars);
03621                                         $trunc_at = strrpos($content, ' ');
03622                                         $content = ($trunc_at&&$crop2space) ? substr($content, 0, $trunc_at).$afterstring : $content.$afterstring;
03623                                 }
03624                         }
03625                 }
03626                 return $content;
03627         }
03628 
03640         function removeBadHTML($text, $conf)    {
03641 
03642                         // Copyright 2002-2003 Thomas Bley
03643                 $text = preg_replace(
03644                         array(
03645                                 "'<script[^>]*?>.*?</script[^>]*?>'si",
03646                                 "'<applet[^>]*?>.*?</applet[^>]*?>'si",
03647                                 "'<object[^>]*?>.*?</object[^>]*?>'si",
03648                                 "'<iframe[^>]*?>.*?</iframe[^>]*?>'si",
03649                                 "'<frameset[^>]*?>.*?</frameset[^>]*?>'si",
03650                                 "'<style[^>]*?>.*?</style[^>]*?>'si",
03651                                 "'<marquee[^>]*?>.*?</marquee[^>]*?>'si",
03652                                 "'<script[^>]*?>'si",
03653                                 "'<meta[^>]*?>'si",
03654                                 "'<base[^>]*?>'si",
03655                                 "'<applet[^>]*?>'si",
03656                                 "'<object[^>]*?>'si",
03657                                 "'<link[^>]*?>'si",
03658                                 "'<iframe[^>]*?>'si",
03659                                 "'<frame[^>]*?>'si",
03660                                 "'<frameset[^>]*?>'si",
03661                                 "'<input[^>]*?>'si",
03662                                 "'<form[^>]*?>'si",
03663                                 "'<embed[^>]*?>'si",
03664                                 "'background-image:url'si",
03665                                 "'<\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",
03666                         ), '', $text);
03667 
03668                         $text = eregi_replace('<a[^>]*href[[:space:]]*=[[:space:]]*["\']?[[:space:]]*javascript[^>]*','',$text);
03669 
03670                         // Return clean content
03671                 return $text;
03672         }
03673 
03684         function textStyle($theValue, $conf) {
03685                 $conf['face.'][1] = 'Times New Roman';
03686                 $conf['face.'][2] = 'Verdana,Arial,Helvetica,Sans serif';
03687                 $conf['face.'][3] = 'Arial,Helvetica,Sans serif';
03688 
03689                 $conf['size.'][1] = 1;
03690                 $conf['size.'][2] = 2;
03691                 $conf['size.'][3] = 3;
03692                 $conf['size.'][4] = 4;
03693                 $conf['size.'][5] = 5;
03694                 $conf['size.'][10] = '+1';
03695                 $conf['size.'][11] = '-1';
03696 
03697                 $conf['color.'][240] = 'black';
03698                 $conf['color.'][241] = 'white';
03699                 $conf['color.'][242] = '#333333';
03700                 $conf['color.'][243] = 'gray';
03701                 $conf['color.'][244] = 'silver';
03702                 $conf['color.'][245] = 'red';
03703                 $conf['color.'][246] = 'navy';
03704                 $conf['color.'][247] = 'yellow';
03705                 $conf['color.'][248] = 'green';
03706                 $conf['color.'][249] = 'olive';
03707                 $conf['color.'][250] = 'maroon';
03708 
03709                 $face = $this->data[$conf['face.']['field']];
03710                 $size = $this->data[$conf['size.']['field']];
03711                 $color = $this->data[$conf['color.']['field']];
03712                 $align = $this->data[$conf['align.']['field']];
03713                 $properties = $this->data[$conf['properties.']['field']];
03714                 if (!$properties)       {
03715                         $properties=$this->stdWrap($conf['properties.']['default'],$conf['properties.']['default.']);
03716                 }
03717 
03718                         // properties
03719                 if (($properties&8))    {$theValue=$this->HTMLcaseshift($theValue, 'upper');}
03720                 if (($properties&1))    {$theValue='<b>'.$theValue.'</b>';}
03721                 if (($properties&2))    {$theValue='<i>'.$theValue.'</i>';}
03722                 if (($properties&4))    {$theValue='<u>'.$theValue.'</u>';}
03723 
03724                         // Fonttag
03725                 $theFace = $conf['face.'][$face] ? $conf['face.'][$face] : $this->stdWrap($conf['face.']['default'],$conf['face.']['default.']);
03726                 $theSize = $conf['size.'][$size] ? $conf['size.'][$size] : $this->stdWrap($conf['size.']['default'],$conf['size.']['default.']);
03727                 $theColor = $conf['color.'][$color] ? $conf['color.'][$color] : $this->stdWrap($conf['color.']['default'],$conf['color.']['default.']);
03728 
03729                 if ($conf['altWrap'])   {
03730                         $theValue=$this->wrap($theValue, $conf['altWrap']);
03731                 } elseif ($theFace || $theSize || $theColor)    {
03732                         $fontWrap = '<font'.($theFace?' face="'.$theFace.'"':'').($theSize?' size="'.$theSize.'"':'').($theColor?' color="'.$theColor.'"':'').'>|</font>';
03733                         $theValue=$this->wrap($theValue, $fontWrap);
03734                 }
03735                         // align
03736                 if ($align)     {$theValue=$this->wrap($theValue, '<div style="text-align:'.$align.';">|</div>');}
03737                         // return
03738                 return $theValue;
03739         }
03740 
03751         function tableStyle($theValue, $conf) {
03752                 $conf['color.'][240] = 'black';
03753                 $conf['color.'][241] = 'white';
03754                 $conf['color.'][242] = '#333333';
03755                 $conf['color.'][243] = 'gray';
03756                 $conf['color.'][244] = 'silver';
03757 
03758                 $align = $this->stdWrap($conf['align'],$conf['align.']);
03759                 $border = intval($this->stdWrap($conf['border'],$conf['border.']));
03760                 $cellspacing = intval($this->stdWrap($conf['cellspacing'],$conf['cellspacing.']));
03761                 $cellpadding = intval($this->stdWrap($conf['cellpadding'],$conf['cellpadding.']));
03762 
03763                 $color = $this->data[$conf['color.']['field']];
03764                 $theColor = $conf['color.'][$color] ? $conf['color.'][$color] : $conf['color.']['default'];
03765                         // Assembling the table tag
03766                 $tableTagArray = Array('<table');
03767                 $tableTagArray[]='border="'.$border.'"';
03768                 $tableTagArray[]='cellspacing="'.$cellspacing.'"';
03769                 $tableTagArray[]='cellpadding="'.$cellpadding.'"';
03770                 if ($align)     {$tableTagArray[]='align="'.$align.'"';}
03771                 if ($theColor)  {$tableTagArray[]='bgcolor="'.$theColor.'"';}
03772 
03773                 if ($conf['params'])    {
03774                         $tableTagArray[] = $conf['params'];
03775                 }
03776 
03777                 $tableWrap = implode(' ',$tableTagArray).'> | </table>';
03778                 $theValue=$this->wrap($theValue, $tableWrap);
03779                         // return
03780                 return $theValue;
03781         }
03782 
03792         function addParams($content,$conf) {
03793                 $lowerCaseAttributes = TRUE;    // For XHTML compliance.
03794 
03795                 if (!is_array($conf))   { return $content; }
03796 
03797                 $key = 1;
03798                 $parts = explode('<',$content);
03799                 if (intval($conf['_offset']))   $key = intval($conf['_offset'])<0 ? count($parts)+intval($conf['_offset']) : intval($conf['_offset']);
03800                 $subparts=explode('>',$parts[$key]);
03801                 if (trim($subparts[0])) {
03802                                 // Get attributes and name
03803                         $attribs = t3lib_div::get_tag_attributes('<'.$subparts[0].'>');
03804                         if (!is_array($attribs))        {$attribs=array();}
03805                         list($tagName) = explode(' ',$subparts[0],2);
03806                                 // adds/overrides attributes
03807                         reset($conf);
03808                         while(list($pkey,$val)=each($conf))     {
03809                                 if (substr($pkey,-1)!='.' && substr($pkey,0,1)!='_')    {
03810                                         $tmpVal=$this->stdWrap($conf[$pkey],$conf[$pkey.'.']);
03811                                         if ($lowerCaseAttributes)       { $pkey = strtolower($pkey); }
03812                                         if (strcmp($tmpVal,'')) {$attribs[$pkey]=$tmpVal;}
03813                                 }
03814                         }
03815 
03816                                 // Re-assembles the tag and content
03817                         $subparts[0]=trim($tagName.' '.t3lib_div::implodeAttributes($attribs));
03818                         $parts[$key] = implode('>',$subparts);
03819                         $content = implode('<',$parts);
03820                 }
03821                 return $content;
03822         }
03823 
03835         function filelink($theValue, $conf)     {
03836                 $output = '';
03837                 $aTagParams = $this->getATagParams($conf);
03838                 $initP = '?id='.$GLOBALS['TSFE']->id.'&type='.$GLOBALS['TSFE']->type;
03839                 $conf['path'] = $this->stdWrap($conf['path'],$conf['path.']);
03840                 $theFile = trim($conf['path']).$theValue;
03841                 if (@is_file($theFile)) {
03842                         $theFileEnc = str_replace('%2F', '/', rawurlencode($theFile));
03843                         $locDataAdd = $conf['jumpurl.']['secure'] ? $this->locDataJU($theFileEnc,$conf['jumpurl.']['secure.']) : '';
03844                         $url = ($conf['jumpurl']) ? $GLOBALS['TSFE']->config['mainScript'].$initP.'&jumpurl='.rawurlencode($theFileEnc).$locDataAdd.$GLOBALS['TSFE']->getMethodUrlIdToken : $theFileEnc;                // && $GLOBALS['TSFE']->config['config']['jumpurl_enable']
03845                         $theLinkWrap = '<a href="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.$url).'"'.($conf['target']?' target="'.$conf['target'].'"':'').$aTagParams.'>|</a>';
03846 
03847                         $theSize = filesize($theFile);
03848                         $fI = t3lib_div::split_fileref($theFile);
03849                         if ($conf['icon'])      {
03850 // TODO the path should be configurable (see bug #1378)
03851                                 $iconP = t3lib_extMgm::siteRelPath('cms').'tslib/media/fileicons/';
03852                                 $icon = @is_file($iconP.$fI['fileext'].'.gif') ? $iconP.$fI['fileext'].'.gif' : $iconP.'default.gif';
03853                                         // Checking for images: If image, then return link to thumbnail.
03854                                 $IEList = $this->stdWrap($conf['icon_image_ext_list'],$conf['icon_image_ext_list.']);
03855                                 $image_ext_list = str_replace(' ','',strtolower($IEList));
03856                                 if ($fI['fileext'] && t3lib_div::inList($image_ext_list, $fI['fileext']))       {
03857                                         if ($conf['iconCObject'])       {
03858                                                 $icon = $this->cObjGetSingle($conf['iconCObject'],$conf['iconCObject.'],'iconCObject');
03859                                         } else {
03860                                                 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails'])   {
03861                                                         $thumbSize = '';
03862                                                         if ($conf['icon_thumbSize'] || $conf['icon_thumbSize.'])        { $thumbSize = '&size='.$this->stdWrap($conf['icon_thumbSize'], $conf['icon_thumbSize.']); }
03863                                                         $check = basename($theFile).':'.filemtime($theFile).':'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'];
03864                                                         $md5sum = '&md5sum='.t3lib_div::shortMD5($check);
03865                                                         $icon = 't3lib/thumbs.php?dummy='.$GLOBALS['EXEC_TIME'].'&file='.rawurlencode('../'.$theFile).$thumbSize.$md5sum;
03866                                                 } else {
03867                                                         $icon = t3lib_extMgm::siteRelPath('cms').'tslib/media/miscicons/notfound_thumb.gif';
03868                                                 }
03869                                                 $icon = '<img src="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.$icon).'"'.$this->getBorderAttr(' border="0"').''.$this->getAltParam($conf).' />';
03870                                         }
03871                                 } else {
03872                                         $icon = '<img src="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.$icon).'" width="18" height="16"'.$this->getBorderAttr(' border="0"').''.$this->getAltParam($conf).' />';
03873                                 }
03874                                 if ($conf['icon_link']) {$icon = $this->wrap($icon, $theLinkWrap);}
03875                                 $icon = $this->stdWrap($icon,$conf['icon.']);
03876                         }
03877                         if ($conf['size'])      {
03878                                 $size = $this->stdWrap($theSize,$conf['size.']);
03879                         }
03880 
03881                                 // Wrapping file label
03882                         if ($conf['removePrependedNumbers']) $theValue=ereg_replace('_[0-9][0-9](\.[[:alnum:]]*)$','\1',$theValue);
03883                         $theValue = $this->stdWrap($theValue,$conf['labelStdWrap.']);
03884 
03885                                 // Wrapping file
03886                         if ($conf['ATagBeforeWrap'])    {
03887                                 $theValue = $this->wrap($this->wrap($theValue, $conf['wrap']), $theLinkWrap);
03888                         } else {
03889                                 $theValue = $this->wrap($this->wrap($theValue, $theLinkWrap), $conf['wrap']);
03890                         }
03891                         $file = $this->stdWrap($theValue,$conf['file.']);
03892                                 // output
03893                         return $this->stdWrap($icon.$file.$size, $conf['stdWrap.']);
03894                 }
03895         }
03896 
03907         function locDataJU($jumpUrl,$conf)      {
03908                 $fI = pathinfo($jumpUrl);
03909                 $mimetype='';
03910                 if ($fI['extension'])   {
03911                         $mimeTypes = t3lib_div::trimExplode(',',$conf['mimeTypes'],1);
03912                         reset($mimeTypes);
03913                         while(list(,$v)=each($mimeTypes))       {
03914                                 $parts = explode('=',$v,2);
03915                                 if (strtolower($fI['extension']) == strtolower(trim($parts[0])))        {
03916                                         $mimetype = '&mimeType='.rawurlencode(trim($parts[1]));
03917                                 }
03918                         }
03919                 }
03920                 $locationData = $GLOBALS['TSFE']->id.':'.$this->currentRecord;
03921                 $rec='&locationData='.rawurlencode($locationData);
03922                 $hArr = array(
03923                         $jumpUrl,
03924                         $locationData,
03925                         $GLOBALS['TSFE']->TYPO3_CONF_VARS['SYS']['encryptionKey']
03926                 );
03927                 $juHash='&juHash='.t3lib_div::shortMD5(serialize($hArr));
03928                 return '&juSecure=1'.$mimetype.$rec.$juHash;
03929         }
03930 
03938         function calc($val)     {
03939                 $parts= t3lib_div::splitCalc($val,'+-*/');
03940                 $value=0;
03941                 reset($parts);
03942                 while(list(,$part)=each($parts))        {
03943                         $theVal = $part[1];
03944                         $sign =  $part[0];
03945                         if ((string)intval($theVal)==(string)$theVal)   {
03946                                 $theVal = intval($theVal);
03947                         } else {
03948                                 $theVal =0;
03949                         }
03950                         if ($sign=='-') {$value-=$theVal;}
03951                         if ($sign=='+') {$value+=$theVal;}
03952                         if ($sign=='/') {if (intval($theVal)) $value/=intval($theVal);}
03953                         if ($sign=='*') {$value*=$theVal;}
03954                 }
03955                 return $value;
03956         }
03957 
03967         function calcIntExplode($delim, $string)        {
03968                 $temp = explode($delim,$string);
03969                 while(list($key,$val)=each($temp))      {
03970                         $temp[$key]=intval(tslib_cObj::calc($val));
03971                 }
03972                 return $temp;
03973         }
03974 
03987         function splitObj($value, $conf)        {
03988                 $conf['token']=$this->stdWrap($conf['token'],$conf['token.']);
03989                 if (!$conf['token'])    {
03990                         return $value;
03991                 }
03992                 $conf['max']=intval($this->stdWrap($conf['max'],$conf['max.']));
03993                 $conf['min']=intval($this->stdWrap($conf['min'],$conf['min.']));
03994 
03995                 $valArr=explode($conf['token'],$value);
03996 
03997                 if (count($valArr) && ($conf['returnKey'] || $conf['returnKey.']))      {
03998                         $key = intval($this->stdWrap($conf['returnKey'],$conf['returnKey.']));
03999                         $content = isset($valArr[$key]) ? $valArr[$key] : '';
04000                 } else {
04001                                 // calculate splitCount
04002                         $splitCount = count($valArr);
04003                         if ($conf['max'] && $splitCount>$conf['max'])   {
04004                                 $splitCount=$conf['max'];
04005                         }
04006                         if ($conf['min'] && $splitCount<$conf['min'])   {
04007                                 $splitCount=$conf['min'];
04008                         }
04009 
04010                         if ($conf['wrap'] || $conf['cObjNum'])  {
04011                                 $splitArr=array();
04012                                 $splitArr['wrap']=$conf['wrap'];
04013                                 $splitArr['cObjNum']=$conf['cObjNum'];
04014                                 $splitArr = $GLOBALS['TSFE']->tmpl->splitConfArray($splitArr,$splitCount);
04015                         }
04016 
04017                         $content='';
04018                         for($a=0;$a<$splitCount;$a++)   {
04019                                 $GLOBALS['TSFE']->register['SPLIT_COUNT']=$a;
04020                                 $value = ''.$valArr[$a];
04021                                 $this->data[$this->currentValKey] = $value;
04022                                 if ($splitArr[$a]['cObjNum'])   {
04023                                         $objName=intval($splitArr[$a]['cObjNum']);
04024                                         $value = $this->stdWrap($this->cObjGet($conf[$objName.'.'],$objName.'.'),$conf[$objName.'.']);
04025                                 }
04026                                 if ($splitArr[$a]['wrap'])      {
04027                                         $value=$this->wrap($value,$splitArr[$a]['wrap']);
04028                                 }
04029                                 $content.=$value;
04030                         }
04031                 }
04032                 return $content;
04033         }
04034 
04049         function parseFunc($theValue, $conf, $ref='') {
04050 
04051                         // Fetch / merge reference, if any
04052                 if ($ref)       {
04053                         $temp_conf = array(
04054                                                                 'parseFunc' => $ref,
04055                                                                 'parseFunc.' => $conf
04056                                                         );
04057                         $temp_conf = $this->mergeTSRef($temp_conf, 'parseFunc');
04058                         $conf = $temp_conf['parseFunc.'];
04059                 }
04060 
04061                         // Process:
04062                 if (strcmp($conf['externalBlocks'],'')) {
04063                         $tags = strtolower(implode(',',t3lib_div::trimExplode(',',$conf['externalBlocks'])));
04064                         $htmlParser = t3lib_div::makeInstance('t3lib_parsehtml');
04065                         $parts = $htmlParser->splitIntoBlock($tags,$theValue);
04066 
04067                         reset($parts);
04068                         while(list($k,$v)=each($parts)) {
04069                                 if ($k%2)       {       // font:
04070                                         $tagName=strtolower($htmlParser->getFirstTagName($v));
04071                                         $cfg=$conf['externalBlocks.'][$tagName.'.'];
04072                                         if ($cfg['stripNLprev'] || $cfg['stripNL'])     {
04073                                                 $parts[$k-1]=ereg_replace(chr(13).'?'.chr(10).'[ ]*$', '', $parts[$k-1]);
04074                                         }
04075                                         if ($cfg['stripNLnext'] || $cfg['stripNL'])     {
04076                                                 $parts[$k+1]=ereg_replace('^[ ]*'.chr(13).'?'.chr(10), '', $parts[$k+1]);
04077                                         }
04078                                 }
04079                         }
04080 
04081                         reset($parts);
04082                         while(list($k,$v)=each($parts)) {
04083                                 if ($k%2)       {
04084                                         $tag=$htmlParser->getFirstTag($v);
04085                                         $tagName=strtolower($htmlParser->getFirstTagName($v));
04086                                         $cfg=$conf['externalBlocks.'][$tagName.'.'];
04087                                         if ($cfg['callRecursive'])      {
04088                                                 $parts[$k]=$this->parseFunc($htmlParser->removeFirstAndLastTag($v), $conf);
04089                                                 if (!$cfg['callRecursive.']['dontWrapSelf'])    {
04090                                                         if ($cfg['callRecursive.']['alternativeWrap'])  {
04091                                                                 $parts[$k] = $this->wrap($parts[$k], $cfg['callRecursive.']['alternativeWrap']);
04092                                                         } else {
04093                                                                 if (is_array($cfg['callRecursive.']['tagStdWrap.']))    {
04094                                                                         $tag = $this->stdWrap($tag,$cfg['callRecursive.']['tagStdWrap.']);
04095                                                                 }
04096                                                                 $parts[$k]=$tag.$parts[$k].'</'.$tagName.'>';
04097                                                         }
04098                                                 }
04099                                         } elseif($cfg['HTMLtableCells']) {
04100                                                 $rowParts = $htmlParser->splitIntoBlock('tr',$parts[$k]);
04101                                                 reset($rowParts);
04102                                                 while(list($kk,$vv)=each($rowParts))    {
04103                                                         if ($kk%2)      {
04104                                                                 $colParts = $htmlParser->splitIntoBlock('td',$vv);
04105                                                                 reset($colParts);
04106                                                                 $cc=0;
04107                                                                 while(list($kkk,$vvv)=each($colParts))  {
04108                                                                         if ($kkk%2)     {
04109                                                                                 $cc++;
04110                                                                                 $tag=$htmlParser->getFirstTag($vvv);
04111                                                                                 $tagName=strtolower($htmlParser->getFirstTagName($vvv));
04112                                                                                 $colParts[$kkk] = $htmlParser->removeFirstAndLastTag($vvv);
04113 
04114                                                                                 if ($cfg['HTMLtableCells.'][$cc.'.']['callRecursive'] || (!isset($cfg['HTMLtableCells.'][$cc.'.']['callRecursive']) && $cfg['HTMLtableCells.']['default.']['callRecursive']))   {
04115                                                                                         if ($cfg['HTMLtableCells.']['addChr10BetweenParagraphs'])       $colParts[$kkk]=str_replace('</p><p>','</p>'.chr(10).'<p>',$colParts[$kkk]);
04116                                                                                         $colParts[$kkk] = $this->parseFunc($colParts[$kkk], $conf);
04117                                                                                 }
04118 
04119                                                                                 $tagStdWrap = is_array($cfg['HTMLtableCells.'][$cc.'.']['tagStdWrap.'])?$cfg['HTMLtableCells.'][$cc.'.']['tagStdWrap.']:$cfg['HTMLtableCells.']['default.']['tagStdWrap.'];
04120                                                                                 if (is_array($tagStdWrap))      {
04121                                                                                         $tag = $this->stdWrap($tag,$tagStdWrap);
04122                                                                                 }
04123 
04124                                                                                 $stdWrap = is_array($cfg['HTMLtableCells.'][$cc.'.']['stdWrap.'])?$cfg['HTMLtableCells.'][$cc.'.']['stdWrap.']:$cfg['HTMLtableCells.']['default.']['stdWrap.'];
04125                                                                                 if (is_array($stdWrap)) {
04126                                                                                         $colParts[$kkk] = $this->stdWrap($colParts[$kkk],$stdWrap);
04127                                                                                 }
04128 
04129                                                                                 $colParts[$kkk]=$tag.$colParts[$kkk].'</'.$tagName.'>';
04130                                                                         }
04131                                                                 }
04132                                                                 $rowParts[$kk] = implode('',$colParts);
04133                                                         }
04134                                                 }
04135                                                 $parts[$k] = implode('',$rowParts);
04136                                         }
04137 
04138                                         if (is_array($cfg['stdWrap.'])) {
04139                                                 $parts[$k] = $this->stdWrap($parts[$k],$cfg['stdWrap.']);
04140                                         }
04141                                 } else {
04142                                         $parts[$k]=$this->_parseFunc($parts[$k], $conf);
04143                                 }
04144                         }
04145 
04146                         return implode('',$parts);
04147                 } else return $this->_parseFunc($theValue, $conf);
04148         }
04149 
04159         function _parseFunc ($theValue, $conf) {
04160                 if (!$this->checkIf($conf['if.']))      {
04161                         return $theValue;
04162                 }
04163                 $inside=0;      // Indicates that the data is from within a tag.
04164                 $pointer=0;     // Pointer to the total string position
04165                 $currentTag=''; // Loaded with the current typo-tag if any.
04166                 $stripNL=0;
04167                 $contentAccum=array();
04168                 $contentAccumP=0;
04169 
04170                 $allowTags=strtolower(str_replace(' ','',$conf['allowTags']));
04171                 $denyTags=strtolower(str_replace(' ','',$conf['denyTags']));
04172 
04173                 $totalLen = strlen($theValue);
04174                 do      {
04175                         if (!$inside)   {
04176                                 if (!is_array($currentTag))     {                       // These operations should only be performed on code outside the typotags...
04177                                                 // data: this checks that we enter tags ONLY if the first char in the tag is alphanumeric OR '/'
04178                                         $len_p=0;
04179                                         $c=100;
04180                                         do      {
04181                                                 $len = strcspn(substr($theValue,$pointer+$len_p),'<');
04182                                                 $len_p+=$len+1;
04183                                                 $endChar = ord(strtolower(substr($theValue,$pointer+$len_p,1)));
04184                                                 $c--;
04185                                         } while ($c>0 && $endChar && ($endChar<97 || $endChar>122) && $endChar!=47);
04186                                         $len = $len_p-1;
04187                                 } else {
04188                                                 // If we're inside a currentTag, just take it to the end of that tag!
04189                                         $tempContent = strtolower(substr($theValue,$pointer));
04190                                         $len = strpos ($tempContent, '</'.$currentTag[0]);
04191                                         if (is_string ($len) && !$len) {
04192                                                 $len = strlen($tempContent);
04193                                         }
04194                                 }
04195 
04196                                 $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
04197                                 if ($data!='')  {
04198                                         if ($stripNL)   {               // If the previous tag was set to strip NewLines in the beginning of the next data-chunk.
04199                                                 $data = ereg_replace('^[ ]*'.chr(13).'?'.chr(10), '', $data);
04200                                         }
04201 
04202                                         if (!is_array($currentTag))     {                       // These operations should only be performed on code outside the tags...
04203                                                         // Constants
04204                                                 if ($conf['constants'] && is_array($GLOBALS['TSFE']->tmpl->setup['constants.']))        {
04205                                                         reset($GLOBALS['TSFE']->tmpl->setup['constants.']);
04206                                                         while(list($key,$val)=each($GLOBALS['TSFE']->tmpl->setup['constants.']))        {
04207                                                                 if (is_string($val))    {
04208                                                                         $data = str_replace('###'.$key.'###', $val, $data);
04209                                                                 }
04210                                                         }
04211                                                 }
04212                                                         // Short
04213                                                 if (is_array($conf['short.']))  {
04214                                                         $shortWords = $conf['short.'];
04215                                                         krsort($shortWords);
04216                                                         reset($shortWords);
04217                                                         while(list($key,$val)=each($shortWords))        {
04218                                                                 if (is_string($val))    {
04219                                                                         $data = str_replace($key, $val, $data);
04220                                                                 }
04221                                                         }
04222                                                 }
04223 
04224                                                         // stdWrap
04225                                                 if (is_array($conf['plainTextStdWrap.']))       {$data = $this->stdWrap($data,$conf['plainTextStdWrap.']);}
04226                                                         // userFunc
04227                                                 if ($conf['userFunc'])  {$data = $this->callUserFunction($conf['userFunc'], $conf['userFunc.'], $data);}
04228 
04229                                                         // Makelinks: (Before search-words as we need the links to be generated when searchwords go on...!)
04230                                                 if ($conf['makelinks']) {
04231                                                         $data = $this->http_makelinks($data,$conf['makelinks.']['http.']);
04232                                                         $data = $this->mailto_makelinks($data,$conf['makelinks.']['mailto.']);
04233                                                 }
04234 
04235                                                         // Search Words:
04236                                                 if ($GLOBALS['TSFE']->no_cache && $conf['sword'] && is_array($GLOBALS['TSFE']->sWordList) && $GLOBALS['TSFE']->sWordRegEx)      {
04237                                                         $newstring = '';
04238                                                         do {
04239                                                                 $pieces = split($GLOBALS['TSFE']->sWordRegEx,$data,2);
04240                                                                 $newstring.=$pieces[0];
04241                                                                 $match_len = strlen($data)-(strlen($pieces[0])+strlen($pieces[1]));
04242                                                                 if (strstr($pieces[0],'<') || strstr($pieces[0],'>'))   {
04243                                                                         $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.
04244                                                                 }
04245                                                                         // The searchword:
04246                                                                 $match = substr($data,strlen($pieces[0]),$match_len);
04247 
04248                                                                 if (trim($match) && strlen($match)>1 && !$inTag)        {
04249                                                                         $match = $this->wrap($match, $conf['sword']);
04250                                                                 }
04251                                                                         // Concatenate the Search Word again.
04252                                                                 $newstring.= $match;
04253                                                                 $data=$pieces[1];
04254                                                         } while ($pieces[1]);
04255                                                         $data = $newstring;
04256                                                 }
04257                                         }
04258                                         $contentAccum[$contentAccumP].=$data;
04259                                 }
04260                                 $inside = 1;
04261                         } else {
04262                                         // tags
04263                                 $len = strcspn(substr($theValue,$pointer),'>')+1;
04264                                 $data = substr($theValue,$pointer,$len);
04265 
04266                                 $tag = explode(' ',trim(substr($data,1,-1)),2);
04267                                 $tag[0]=strtolower($tag[0]);
04268                                 if (substr($tag[0],0,1)=='/')   {
04269                                         $tag[0]=substr($tag[0],1);
04270                                         $tag['out']=1;
04271                                 }
04272                                 if($conf['tags.'][$tag[0]])     {
04273                                         $treated=0;
04274                                         $stripNL = 0;
04275                                                 // in-tag
04276                                         if (!$currentTag && !$tag['out'])       {
04277                                                 $currentTag = $tag;             // $currentTag er lig med det tag (array!), man er igang med!
04278                                                 $contentAccumP++;
04279                                                 $treated=1;
04280                                         }
04281                                                 // out-tag
04282                                         if ($currentTag[0]==$tag[0] && $tag['out'])     {
04283                                                 $theName = $conf['tags.'][$tag[0]];
04284                                                 $theConf = $conf['tags.'][$tag[0].'.'];
04285                                                 $stripNL = ($theConf['stripNL'] ? 1 : 0);       // This flag indicates, that NL- (13-10-chars) should be stripped first and last.
04286                                                 $breakOut = ($theConf['breakoutTypoTagContent'] ? 1 : 0);       // This flag indicates, that this TypoTag section should NOT be included in the nonTypoTag content.
04287 
04288                                                 $this->parameters=Array();
04289                                                 if ($currentTag[1])     {
04290                                                         $params=t3lib_div::get_tag_attributes($currentTag[1]);
04291                                                         if (is_array($params))  {
04292                                                                 reset($params);
04293                                                                 while(list($option,$val)=each($params)) {
04294                                                                         $this->parameters[strtolower($option)]=$val;
04295                                                                 }
04296                                                         }
04297                                                 }
04298                                                 $this->parameters['allParams']=trim($currentTag[1]);
04299                                                 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
04300                                                         $contentAccum[$contentAccumP-1] = ereg_replace(chr(13).'?'.chr(10).'[ ]*$', '', $contentAccum[$contentAccumP-1]);
04301                                                         $contentAccum[$contentAccumP] = ereg_replace('^[ ]*'.chr(13).'?'.chr(10), '', $contentAccum[$contentAccumP]);
04302                                                         $contentAccum[$contentAccumP] = ereg_replace(chr(13).'?'.chr(10).'[ ]*$', '', $contentAccum[$contentAccumP]);
04303                                                 }
04304                                                 $this->data[$this->currentValKey] = $contentAccum[$contentAccumP];
04305                                                 $newInput=$this->cObjGetSingle($theName,$theConf,'/parseFunc/.tags.'.$tag[0]);  // fetch the content object
04306 
04307                                                 $contentAccum[$contentAccumP]=$newInput;
04308                                                 $contentAccumP++;
04309 
04310                                                         // If the TypoTag section
04311                                                 if (!$breakOut) {
04312                                                         $contentAccum[$contentAccumP-2].=$contentAccum[$contentAccumP-1].$contentAccum[$contentAccumP];
04313                                                         unset($contentAccum[$contentAccumP]);
04314                                                         unset($contentAccum[$contentAccumP-1]);
04315                                                         $contentAccumP-=2;
04316                                                 }
04317 
04318                                                 unset($currentTag);
04319                                                 $treated=1;
04320                                         }
04321                                                 // other tags...
04322                                         if (!$treated)  {
04323                                                 $contentAccum[$contentAccumP].=$data;
04324                                         }
04325                                 } else {
04326                                                 // If a tag was not a typo tag, then it is just added to the content
04327                                         $stripNL = 0;
04328                                         if (t3lib_div::inList($allowTags,$tag[0]) || ($denyTags!='*' && !t3lib_div::inList($denyTags,$tag[0]))) {
04329                                                 $contentAccum[$contentAccumP].=$data;
04330                                         } else {
04331                                                 $contentAccum[$contentAccumP].=HTMLSpecialChars($data);
04332                                         }
04333                                 }
04334                                 $inside = 0;
04335                         }
04336                         $pointer+=$len;
04337                 } while($pointer<$totalLen);
04338 
04339                         // Parsing nonTypoTag content (all even keys):
04340                 reset($contentAccum);
04341                 for ($a=0;$a<count($contentAccum);$a++) {
04342                         if ($a%2 != 1)  {
04343                                         // stdWrap
04344                                 if (is_array($conf['nonTypoTagStdWrap.']))      {$contentAccum[$a] = $this->stdWrap($contentAccum[$a],$conf['nonTypoTagStdWrap.']);}
04345                                         // userFunc
04346                                 if ($conf['nonTypoTagUserFunc'])        {$contentAccum[$a] = $this->callUserFunction($conf['nonTypoTagUserFunc'], $conf['nonTypoTagUserFunc.'], $contentAccum[$a]);}
04347                         }
04348                 }
04349                 return implode('',$contentAccum);
04350         }
04351 
04361         function encaps_lineSplit($theValue, $conf)     {
04362                 $lParts = explode(chr(10),$theValue);
04363 
04364                 $encapTags = t3lib_div::trimExplode(',',strtolower($conf['encapsTagList']),1);
04365                 $nonWrappedTag = $conf['nonWrappedTag'];
04366                 $defaultAlign=trim($this->stdWrap($conf['defaultAlign'],$conf['defaultAlign.']));
04367 
04368                 if (!strcmp('',$theValue))      return '';
04369 
04370                 while(list($k,$l)=each($lParts))        {
04371                         $sameBeginEnd=0;
04372                         $l=trim($l);
04373                         $attrib=array();
04374                         $nWrapped=0;
04375                         $byPass=0;
04376                         if (substr($l,0,1)=='<' && substr($l,-1)=='>')  {
04377                                 $fwParts = explode('>',substr($l,1),2);
04378                                 $backParts = t3lib_div::revExplode('<', substr($fwParts[1],0,-1), 2);
04379                                 $attrib = t3lib_div::get_tag_attributes('<'.$fwParts[0].'>');
04380                                 list($tagName) = explode(' ',$fwParts[0]);
04381                                 $str_content = $backParts[0];
04382                                 $sameBeginEnd = (substr(strtolower($backParts[1]),1,strlen($tagName))==strtolower($tagName));
04383                         }
04384 
04385                         if ($sameBeginEnd && in_array(strtolower($tagName),$encapTags)) {
04386                                 $uTagName = strtoupper($tagName);
04387                                 $uTagName = strtoupper($conf['remapTag.'][$uTagName]?$conf['remapTag.'][$uTagName]:$uTagName);
04388                         } else {
04389                                 $uTagName = strtoupper($nonWrappedTag);
04390                                 $str_content = $lParts[$k];
04391                                 $nWrapped=1;
04392                                 $attrib=array();
04393                         }
04394 
04395                                 // Wrapping all inner-content:
04396                         if (is_array($conf['innerStdWrap_all.']))       {$str_content = $this->stdWrap($str_content,$conf['innerStdWrap_all.']);}
04397 
04398                         if ($uTagName)  {
04399                                         // Setting common attributes
04400                                 if (is_array($conf['addAttributes.'][$uTagName.'.']))   {
04401                                         reset($conf['addAttributes.'][$uTagName.'.']);
04402                                         while(list($kk,$vv)=each($conf['addAttributes.'][$uTagName.'.']))       {
04403                                                 if (!is_array($vv))     {
04404                                                         if ((string)$conf['addAttributes.'][$uTagName.'.'][$kk.'.']['setOnly']=='blank')        {
04405                                                                 if (!strcmp($attrib[$kk],''))   $attrib[$kk]=$vv;
04406                                                         } elseif ((string)$conf['addAttributes.'][$uTagName.'.'][$kk.'.']['setOnly']=='exists') {
04407                                                                 if (!isset($attrib[$kk]))       $attrib[$kk]=$vv;
04408                                                         } else {
04409                                                                 $attrib[$kk]=$vv;
04410                                                         }
04411                                                 }
04412                                         }
04413                                 }
04414                                         // Wrapping all inner-content:
04415                                 if (is_array($conf['encapsLinesStdWrap.'][$uTagName.'.']))      {$str_content = $this->stdWrap($str_content,$conf['encapsLinesStdWrap.'][$uTagName.'.']);}
04416                                         // Default align
04417                                 if (!$attrib['align'] && $defaultAlign) $attrib['align']=$defaultAlign;
04418 
04419                                 $params = t3lib_div::implodeAttributes($attrib,1);
04420                                 if ($conf['removeWrapping'])    {
04421                                         $str_content=$str_content;
04422                                 } else {
04423                                         $str_content='<'.strtolower($uTagName).(trim($params)?' '.trim($params):'').'>'.$str_content.'</'.strtolower($uTagName).'>';
04424                                 }
04425                         }
04426 
04427                         if ($nWrapped && $conf['wrapNonWrappedLines'])  {$str_content = $this->wrap($str_content,$conf['wrapNonWrappedLines']);}
04428                         $lParts[$k] = $str_content;
04429                 }
04430 
04431                 return implode(chr(10),$lParts);
04432         }
04433 
04444         function http_makelinks($data,$conf)    {
04445                 $aTagParams = $this->getATagParams($conf);
04446                 $textpieces = explode('http://', $data);
04447                 $pieces = count($textpieces);
04448                 $textstr = $textpieces[0];
04449                 $initP = '?id='.$GLOBALS['TSFE']->id.'&type='.$GLOBALS['TSFE']->type;
04450                 for($i=1; $i<$pieces; $i++)     {
04451                         $len=strcspn($textpieces[$i],chr(32).chr(9).chr(13).chr(10));
04452                         if (trim(substr($textstr,-1))=='' && $len)      {
04453 
04454                                 $lastChar=substr($textpieces[$i],$len-1,1);
04455                                 if (!ereg('[A-Za-z0-9\/#_-]',$lastChar)) {$len--;}              // Included '\/' 3/12
04456 
04457                                 $parts[0]=substr($textpieces[$i],0,$len);
04458                                 $parts[1]=substr($textpieces[$i],$len);
04459 
04460                                 $keep=$conf['keep'];
04461                                 $linkParts=parse_url('http://'.$parts[0]);
04462                                 $linktxt='';
04463                                 if (strstr($keep,'scheme'))     {
04464                                         $linktxt='http://';
04465                                 }
04466                                 $linktxt.= $linkParts['host'];
04467                                 if (strstr($keep,'path'))       {
04468                                         $linktxt.= $linkParts['path'];
04469                                         if (strstr($keep,'query') && $linkParts['query'])       {               // added $linkParts['query'] 3/12
04470                                                 $linktxt.= '?'.$linkParts['query'];
04471                                         } elseif ($linkParts['path']=='/')      {  // If query is NOT added and the path is '/' then remove the slash ('/')   (added 3/12)
04472                                                 $linktxt=substr($linktxt,0,-1);
04473                                         }
04474                                 }
04475                                 $target = isset($conf['extTarget']) ? $conf['extTarget'] : $GLOBALS['TSFE']->extTarget;
04476                                 if ($GLOBALS['TSFE']->config['config']['jumpurl_enable'])       {
04477                                         $res = '<a'.
04478                                                         ' href="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.$GLOBALS['TSFE']->config['mainScript'].$initP.'&jumpurl='.rawurlencode('http://'.$parts[0]).$GLOBALS['TSFE']->getMethodUrlIdToken).'"'.
04479                                                         ($target ? ' target="'.$target.'"' : '').
04480                                                         $aTagParams.
04481                                                         '>';
04482                                 } else {
04483                                         $res = '<a'.
04484                                                         ' href="http://'.htmlspecialchars($parts[0]).'"'.
04485                                                         ($target ? ' target="'.$target.'"' : '').
04486                                                         $aTagParams.
04487                                                         '>';
04488                                 }
04489                                 if ($conf['ATagBeforeWrap'])    {
04490                                         $res= $res.$this->wrap($linktxt, $conf['wrap']).'</a>';
04491                                 } else {
04492                                         $res= $this->wrap($res.$linktxt.'</a>', $conf['wrap']);
04493                                 }
04494                                 $textstr.=$res.$parts[1];
04495                         } else {
04496                                 $textstr.='http://'.$textpieces[$i];
04497                         }
04498                 }
04499                 return $textstr;
04500         }
04501 
04511         function mailto_makelinks($data,$conf)  {
04512                 // http-split
04513                 $aTagParams = $this->getATagParams($conf);
04514                 $textpieces = explode('mailto:', $data);
04515                 $pieces = count($textpieces);
04516                 $textstr = $textpieces[0];
04517                 $initP = '?id='.$GLOBALS['TSFE']->id.'&type='.$GLOBALS['TSFE']->type;
04518                 for($i=1; $i<$pieces; $i++)     {
04519                         $len = strcspn($textpieces[$i],chr(32).chr(9).chr(13).chr(10));
04520                         if (trim(substr($textstr,-1))=='' && $len)      {
04521                                 $lastChar = substr($textpieces[$i],$len-1,1);
04522                                 if (!ereg('[A-Za-z0-9]',$lastChar)) {$len--;}
04523 
04524                                 $parts[0] = substr($textpieces[$i],0,$len);
04525                                 $parts[1] = substr($textpieces[$i],$len);
04526                                 $linktxt = ereg_replace('\?.*','',$parts[0]);
04527                                 list($mailToUrl,$linktxt) = $this->getMailTo($parts[0],$linktxt,$initP);
04528                                 $mailToUrl = $GLOBALS['TSFE']->spamProtectEmailAddresses === 'ascii'?$mailToUrl:htmlspecialchars($mailToUrl);
04529                                 $res = '<a href="'.$mailToUrl.'"'.$aTagParams.'>';
04530                                 if ($conf['ATagBeforeWrap'])    {
04531                                         $res= $res.$this->wrap($linktxt, $conf['wrap']).'</a>';
04532                                 } else {
04533                                         $res= $this->wrap($res.$linktxt.'</a>', $conf['wrap']);
04534                                 }
04535                                 $textstr.=$res.$parts[1];
04536                         } else {
04537                                 $textstr.='mailto:'.$textpieces[$i];
04538                         }
04539                 }
04540                 return $textstr;
04541         }
04542 
04554         function getImgResource($file,$fileArray)       {
04555                 if (is_array($fileArray))       {
04556                         switch($file)   {
04557                                 case 'GIFBUILDER':
04558                                         $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
04559                                         $gifCreator->init();
04560                                         $theImage='';
04561                                         if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib'])        {
04562                                                 $gifCreator->start($fileArray,$this->data);
04563                                                 $theImage = $gifCreator->gifBuild();
04564                                         }
04565                                         return $gifCreator->getImageDimensions($theImage);
04566                                 break;
04567                                 default:
04568                                         if ($fileArray['import.'])      {
04569                                                 $ifile = $this->stdWrap('',$fileArray['import.']);
04570                                                 if ($ifile)     {$file = $fileArray['import'].$ifile;}
04571                                         }
04572                                         $theImage = $GLOBALS['TSFE']->tmpl->getFileName($file);
04573                                         if ($theImage)  {
04574                                                 $fileArray['width']= $this->stdWrap($fileArray['width'],$fileArray['width.']);
04575                                                 $fileArray['height']= $this->stdWrap($fileArray['height'],$fileArray['height.']);
04576                                                 $fileArray['ext']= $this->stdWrap($fileArray['ext'],$fileArray['ext.']);
04577                                                 $fileArray['maxW']= intval($this->stdWrap($fileArray['maxW'],$fileArray['maxW.']));
04578                                                 $fileArray['maxH']= intval($this->stdWrap($fileArray['maxH'],$fileArray['maxH.']));
04579                                                 $fileArray['minW']= intval($fileArray['minW']);
04580                                                 $fileArray['minH']= intval($fileArray['minH']);
04581                                                 $maskArray=     $fileArray['m.'];
04582                                                 $maskImages=array();
04583                                                 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!
04584                                                         $maskImages['m_mask'] = $this->getImgResource($maskArray['mask'],$maskArray['mask.']);
04585                                                         $maskImages['m_bgImg'] = $this->getImgResource($maskArray['bgImg'],$maskArray['bgImg.']);
04586                                                         $maskImages['m_bottomImg'] = $this->getImgResource($maskArray['bottomImg'],$maskArray['bottomImg.']);
04587                                                         $maskImages['m_bottomImg_mask'] = $this->getImgResource($maskArray['bottomImg_mask'],$maskArray['bottomImg_mask.']);
04588                                                 }
04589                                                 $hash = t3lib_div::shortMD5($theImage.serialize($fileArray).serialize($maskImages));
04590                                                 if (!isset($GLOBALS['TSFE']->tmpl->fileCache[$hash]))   {
04591                                                         $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
04592                                                         $gifCreator->init();
04593 
04594                                                         if ($GLOBALS['TSFE']->config['config']['meaningfulTempFilePrefix'])     {
04595                                                                 $gifCreator->filenamePrefix = $GLOBALS['TSFE']->fileNameASCIIPrefix(ereg_replace('\.[[:alnum:]]+$','',basename($theImage)),intval($GLOBALS['TSFE']->config['config']['meaningfulTempFilePrefix']),'_');
04596                                                         }
04597 
04598                                                         if ($fileArray['sample'])       {
04599                                                                 $gifCreator->scalecmd = '-sample';
04600                                                                 $GLOBALS['TT']->setTSlogMessage('Sample option: Images are scaled with -sample.');
04601                                                         }
04602                                                         if ($fileArray['alternativeTempPath'] && t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['FE']['allowedTempPaths'],$fileArray['alternativeTempPath']))    {
04603                                                                 $gifCreator->tempPath = $fileArray['alternativeTempPath'];
04604                                                                 $GLOBALS['TT']->setTSlogMessage('Set alternativeTempPath: '.$fileArray['alternativeTempPath']);
04605                                                         }
04606 
04607                                                         if (!trim($fileArray['ext'])){$fileArray['ext']='web';}
04608                                                         $options = Array();
04609                                                         if ($fileArray['maxW']) {$options['maxW']=$fileArray['maxW'];}
04610                                                         if ($fileArray['maxH']) {$options['maxH']=$fileArray['maxH'];}
04611                                                         if ($fileArray['minW']) {$options['minW']=$fileArray['minW'];}
04612                                                         if ($fileArray['minH']) {$options['minH']=$fileArray['minH'];}
04613 
04614                                                                 // checks to see if m (the mask array) is defined
04615                                                         if (is_array($maskArray) && $GLOBALS['TYPO3_CONF_VARS']['GFX']['im'])   {
04616                                                                         // Filename:
04617                                                                 $fI = t3lib_div::split_fileref($theImage);
04618                                                                 $imgExt = (strtolower($fI['fileext'])==$gifCreator->gifExtension ? $gifCreator->gifExtension : 'jpg');
04619                                                                 $dest = $gifCreator->tempPath.$hash.'.'.$imgExt;
04620                                                                 if (!@file_exists($dest))       {               // Generate!
04621                                                                         $m_mask= $maskImages['m_mask'];
04622                                                                         $m_bgImg = $maskImages['m_bgImg'];
04623                                                                         if ($m_mask && $m_bgImg)        {
04624                                                                                 $negate = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_negate_mask'] ? ' -negate' : '';
04625 
04626                                                                                 $temp_ext='png';
04627                                                                                 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_mask_temp_ext_gif']) {               // If ImageMagick version 5+
04628                                                                                         $temp_ext=$gifCreator->gifExtension;
04629                                                                                 }
04630 
04631                                                                                 $tempFileInfo = $gifCreator->imageMagickConvert($theImage,$temp_ext,$fileArray['width'],$fileArray['height'],$fileArray['params'],$fileArray['frame'],$options);
04632                                                                                 if (is_array($tempFileInfo))    {
04633                                                                                         $m_bottomImg = $maskImages['m_bottomImg'];
04634                                                                                         if ($m_bottomImg)       {
04635                                                                                                 $m_bottomImg_mask = $maskImages['m_bottomImg_mask'];
04636                                                                                         }
04637                                                                                                 //      Scaling:        ****
04638                                                                                         $tempScale=array();
04639                                                                                         $command = '-geometry '.$tempFileInfo[0].'x'.$tempFileInfo[1].'!';
04640                                                                                         $tmpStr = $gifCreator->randomName();
04641 
04642                                                                                                 //      m_mask
04643                                                                                         $tempScale['m_mask']=$tmpStr.'_mask.'.$temp_ext;
04644                                                                                         $gifCreator->imageMagickExec($m_mask[3],$tempScale['m_mask'],$command.$negate);
04645                                                                                                 //      m_bgImg
04646                                                                                         $tempScale['m_bgImg']=$tmpStr.'_bgImg.'.trim($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_mask_temp_ext_noloss']);
04647                                                                                         $gifCreator->imageMagickExec($m_bgImg[3],$tempScale['m_bgImg'],$command);
04648 
04649                                                                                                 //      m_bottomImg / m_bottomImg_mask
04650                                                                                         if ($m_bottomImg && $m_bottomImg_mask)  {
04651                                                                                                 $tempScale['m_bottomImg']=$tmpStr.'_bottomImg.'.$temp_ext;
04652                                                                                                 $gifCreator->imageMagickExec($m_bottomImg[3],$tempScale['m_bottomImg'],$command);
04653                                                                                                 $tempScale['m_bottomImg_mask']=$tmpStr.'_bottomImg_mask.'.$temp_ext;
04654                                                                                                 $gifCreator->imageMagickExec($m_bottomImg_mask[3],$tempScale['m_bottomImg_mask'],$command.$negate);
04655 
04656                                                                                                         // BEGIN combining:
04657                                                                                                         // The image onto the background
04658                                                                                                 $gifCreator->combineExec($tempScale['m_bgImg'],$tempScale['m_bottomImg'],$tempScale['m_bottomImg_mask'],$tempScale['m_bgImg']);
04659                                                                                         }
04660                                                                                                 // The image onto the background
04661                                                                                         $gifCreator->combineExec($tempScale['m_bgImg'],$tempFileInfo[3],$tempScale['m_mask'],$dest);
04662                                                                                                 // Unlink the temp-images...
04663                                                                                         reset($tempScale);
04664                                                                                         while(list(,$file)=each($tempScale))    {
04665                                                                                                 if (@is_file($file))    {
04666                                                                                                         unlink($file);
04667                                                                                                 }
04668                                                                                         }
04669                                                                                                 //      t3lib_div::print_array($GLOBALS['TSFE']->tmpl->fileCache[$hash]);
04670                                                                                 }
04671                                                                         }
04672                                                                 }
04673                                                                         // Finish off
04674                                                                 if (($fileArray['reduceColors'] || ($imgExt=='png' && !$gifCreateor->png_truecolor)) && is_file($dest)) {
04675                                                                         $reduced = $gifCreator->IMreduceColors($dest, t3lib_div::intInRange($fileArray['reduceColors'], 256, $gifCreator->truecolorColors, 256));
04676                                                                         if (is_file($reduced))  {
04677                                                                                 unlink($dest);
04678                                                                                 rename($reduced, $dest);
04679                                                                         }
04680                                                                 }
04681                                                                 $GLOBALS['TSFE']->tmpl->fileCache[$hash]= $gifCreator->getImageDimensions($dest);
04682                                                         } else {                // Normal situation:
04683                                                                 $GLOBALS['TSFE']->tmpl->fileCache[$hash]= $gifCreator->imageMagickConvert($theImage,$fileArray['ext'],$fileArray['width'],$fileArray['height'],$fileArray['params'],$fileArray['frame'],$options);
04684                                                                 if (($fileArray['reduceColors'] || ($imgExt=='png' && !$gifCreateor->png_truecolor)) && is_file($GLOBALS['TSFE']->tmpl->fileCache[$hash][3]))   {
04685                                                                         $reduced = $gifCreator->IMreduceColors($GLOBALS['TSFE']->tmpl->fileCache[$hash][3], t3lib_div::intInRange($fileArray['reduceColors'], 256, $gifCreator->truecolorColors, 256));
04686                                                                         if (is_file($reduced))  {
04687                                                                                 unlink($GLOBALS['TSFE']->tmpl->fileCache[$hash][3]);
04688                                                                                 rename($reduced, $GLOBALS['TSFE']->tmpl->fileCache[$hash][3]);
04689                                                                         }
04690                                                                 }
04691                                                         }
04692                                                         $GLOBALS['TSFE']->tmpl->fileCache[$hash]['origFile'] = $theImage;
04693                                                         $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.
04694                                                 }
04695                                                 return $GLOBALS['TSFE']->tmpl->fileCache[$hash];
04696                                         }
04697 
04698                                 break;
04699                         }
04700                 }
04701                 $theImage = $GLOBALS['TSFE']->tmpl->getFileName($file);
04702                 if ($theImage)  {
04703                         $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder');
04704                         $gifCreator->init();
04705                         $info= $gifCreator->imageMagickConvert($theImage,'WEB','','','','','');
04706                         $info['origFile'] = $theImage;
04707                         $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.
04708                         return $info;
04709                 }
04710         }
04711 
04712 
04713 
04714 
04715 
04716 
04717 
04718 
04719 
04720 
04721 
04722 
04723 
04724 
04725 
04726 
04727 
04728 
04729 
04730 
04731 
04732 
04733         /***********************************************
04734          *
04735          * Data retrieval etc.
04736          *
04737          ***********************************************/
04738 
04739 
04746         function getFieldVal($field)    {
04747                 if (!strstr($field,'//'))       {
04748                         return $this->data[trim($field)];
04749                 } else {
04750                         $sections = t3lib_div::trimExplode('//',$field,1);
04751                         while (list(,$k)=each($sections)) {
04752                                 if (strcmp($this->data[$k],'')) return $this->data[$k];
04753                         }
04754                 }
04755         }
04756 
04766         function getData($string,$fieldArray)   {
04767                 if (!is_array($fieldArray))     {
04768                         $fieldArray=$GLOBALS['TSFE']->page;
04769                 }
04770                 $retVal = '';
04771                 $sections = explode('//',$string);
04772 
04773                 while (!$retVal AND list($secKey, $secVal)=each($sections)) {
04774                         $parts = explode(':',$secVal,2);
04775                         $key = trim($parts[1]);
04776                         if ((string)$key!='')   {
04777                                 switch(strtolower(trim($parts[0])))     {
04778                                         case 'gpvar':
04779                                                 list($firstKey, $rest) = explode('|', $key, 2);
04780                                                 if (strlen(trim($firstKey)))    {
04781                                                         $retVal = t3lib_div::_GP(trim($firstKey));
04782                                                                 // Look for deeper levels:
04783                                                         if (strlen(trim($rest)))        {
04784                                                                 $retVal = is_array($retVal) ? $this->getGlobal($rest, $retVal) : '';
04785                                                         }
04786                                                                 // Check that output is not an array:
04787                                                         if (is_array($retVal))  $retVal = '';
04788                                                 }
04789                                         break;
04790                                         case 'tsfe':
04791                                                 $retVal = $this->getGlobal ('TSFE|'.$key);
04792                                         break;
04793                                         case 'getenv':
04794                                                 $retVal = getenv($key);
04795                                         break;
04796                                         case 'getindpenv':
04797                                                 $retVal = t3lib_div::getIndpEnv($key);
04798                                         break;
04799                                         case 'field':
04800                                                 $retVal = $fieldArray[$key];
04801                                         break;
04802                                         case 'parameters':
04803                                                 $retVal = $this->parameters[$key];
04804                                         break;
04805                                         case 'register':
04806                                                 $retVal = $GLOBALS['TSFE']->register[$key];
04807                                         break;
04808                                         case 'global':
04809                                                 $retVal = $this->getGlobal($key);
04810                                         break;
04811                                         case 'leveltitle':
04812                                                 $nkey = $this->getKey($key,$GLOBALS['TSFE']->tmpl->rootLine);
04813                                                 $retVal = $this->rootLineValue($nkey,'title',stristr($key,'slide'));
04814                                         break;
04815                                         case 'levelmedia':
04816                                                 $nkey = $this->getKey($key,$GLOBALS['TSFE']->tmpl->rootLine);
04817                                                 $retVal = $this->rootLineValue($nkey,'media',stristr($key,'slide'));
04818                                         break;
04819                                         case 'leveluid':
04820                                                 $nkey = $this->getKey($key,$GLOBALS['TSFE']->tmpl->rootLine);
04821                                                 $retVal = $this->rootLineValue($nkey,'uid',stristr($key,'slide'));
04822                                         break;
04823                                         case 'levelfield':
04824                                                 $keyP = t3lib_div::trimExplode(',',$key);
04825                                                 $nkey = $this->getKey($keyP[0],$GLOBALS['TSFE']->tmpl->rootLine);
04826                                                 $retVal = $this->rootLineValue($nkey,$keyP[1],strtolower($keyP[2])=='slide');
04827                                         break;
04828                                         case 'fullrootline':
04829                                                 $keyP = t3lib_div::trimExplode(',',$key);
04830                                                 $fullKey = intval($keyP[0])-count($GLOBALS['TSFE']->tmpl->rootLine)+count($GLOBALS['TSFE']->rootLine);
04831                                                 if ($fullKey>=0)        {
04832                                                         $retVal = $this->rootLineValue($fullKey,$keyP[1],stristr($keyP[2],'slide'),$GLOBALS['TSFE']->rootLine);
04833                                                 }
04834                                         break;
04835                                         case 'date':
04836                                                 if (!$key) {$key = 'd/m Y';}
04837                                                 $retVal = date($key, time());
04838                                         break;
04839                                         case 'page':
04840                                                 $retVal = $GLOBALS['TSFE']->page[$key];
04841                                         break;
04842                                         case 'current':
04843                                                 $retVal = $this->data[$this->currentValKey];
04844                                         break;
04845                                         case 'level':
04846                                                 $retVal = count($GLOBALS['TSFE']->tmpl->rootLine)-1;
04847                                         break;
04848                                         case 'db':
04849                                                 $selectParts = t3lib_div::trimExplode(':',$key);
04850                                                 $db_rec = $GLOBALS['TSFE']->sys_page->getRawRecord($selectParts[0],$selectParts[1]);
04851                                                 if (is_array($db_rec) && $selectParts[2])       {$retVal = $db_rec[$selectParts[2]];}
04852                                         break;
04853                                         case 'lll':
04854                                                 $retVal = $GLOBALS['TSFE']->sL('LLL:'.$key);
04855                                         break;
04856                                         case 'path':
04857                                                 $retVal = $GLOBALS['TSFE']->tmpl->getFileName($key);
04858                                         break;
04859                                         case 'cobj':
04860                                                 switch((string)$key)    {
04861                                                         case 'parentRecordNumber':
04862                                                                 $retVal = $this->parentRecordNumber;
04863                                                         break;
04864                                                 }
04865                                         break;
04866                                         case 'debug':
04867                                                 switch((string)$key)    {
04868                                                         case 'rootLine':
04869                                                                 $retVal = t3lib_div::view_array($GLOBALS['TSFE']->tmpl->rootLine);
04870                                                         break;
04871                                                         case 'fullRootLine':
04872                                                                 $retVal = t3lib_div::view_array($GLOBALS['TSFE']->rootLine);
04873                                                         break;
04874                                                         case 'data':
04875                                                                 $retVal = t3lib_div::view_array($this->data);
04876                                                         break;
04877                                                 }
04878                                         break;
04879                                 }
04880                         }
04881                 }
04882                 return $retVal;
04883         }
04884 
04896         function rootLineValue($key,$field,$slideBack=0,$altRootLine='')        {
04897                 $rootLine = is_array($altRootLine) ? $altRootLine : $GLOBALS['TSFE']->tmpl->rootLine;
04898                 if (!$slideBack)        {
04899                         return $rootLine[$key][$field];
04900                 } else {
04901                         for ($a=$key;$a>=0;$a--)        {
04902                                 $val = $rootLine[$a][$field];
04903                                 if ($val)       {return $val;}
04904                         }
04905                 }
04906         }
04907 
04918         function getGlobal($var, $source=NULL)  {
04919                 $vars = explode('|', $var);
04920                 $c = count($vars);
04921                 $k = trim($vars[0]);
04922                 $theVar = isset($source) ? $source[$k] : $GLOBALS[$k];
04923 
04924                 for ($a=1;$a<$c;$a++)   {
04925                         if (!isset($theVar))    { break; }
04926 
04927                         $key = trim($vars[$a]);
04928                         if (is_object($theVar)) {
04929                                 $theVar = $theVar->$key;
04930                         } elseif (is_array($theVar))    {
04931                                 $theVar = $theVar[$key];
04932                         } else {
04933                                 return '';
04934                         }
04935                 }
04936 
04937                 if (!is_array($theVar) && !is_object($theVar))  {
04938                         return $theVar;
04939                 } else {
04940                         return '';
04941                 }
04942         }
04943 
04954         function getKey($key,$arr)      {
04955                 $key = intval($key);
04956                 if (is_array($arr))     {
04957                         if ($key < 0)   {
04958                                 $key = count($arr)+$key;
04959                         }
04960                         if ($key < 0)   {
04961                                 $key=0;
04962                         }
04963                 }
04964                 return $key;
04965         }
04966 
04967 
04977         function TCAlookup($inputValue,$conf)   {
04978                 global $TCA;
04979 
04980                 $table = $conf['table'];
04981                 $field = $conf['field'];
04982                 $delimiter = $conf['delimiter']?$conf['delimiter']:' ,';
04983 
04984                 $GLOBALS['TSFE']->includeTCA();
04985 
04986                 if (is_array($TCA[$table]) && is_array($TCA[$table]['columns'][$field]) && is_array($TCA[$table]['columns'][$field]['config']['items'])) {
04987                         $values = t3lib_div::trimExplode(',',$inputValue);
04988                         foreach ($values as $value)     {
04989                                         // Traverse the items-array...
04990                                 reset($TCA[$table]['columns'][$field]['config']['items']);
04991                                 while(list($key,$item)=each($TCA[$table]['columns'][$field]['config']['items']))        {
04992                                                 // ... and return the first found label where the value was equal to $key
04993                                         if (!strcmp($item[1],trim($value)))     $output[] = $GLOBALS['TSFE']->sL($item[0]);
04994                                 }
04995                         }
04996                         $returnValue = implode($delimiter,$output);
04997                 } else {
04998                         $returnValue = $inputValue;
04999                 }
05000                 return $returnValue;
05001         }
05002 
05003 
05004 
05005 
05006 
05007 
05008 
05009 
05010 
05011 
05012 
05013 
05014 
05015 
05016 
05017         /***********************************************
05018          *
05019          * Link functions (typolink)
05020          *
05021          ***********************************************/
05022 
05023 
05037         function typoLink($linktxt, $conf)      {
05038                 $finalTagParts = array();
05039                 $finalTagParts['aTagParams'] = $this->getATagParams($conf);
05040 
05041                 $link_param = trim($this->stdWrap($conf['parameter'],$conf['parameter.']));
05042 
05043                 $sectionMark = trim($this->stdWrap($conf['section'],$conf['section.']));
05044                 $sectionMark = $sectionMark ? (t3lib_div::testInt($sectionMark)?'#c':'#').$sectionMark : '';
05045                 $initP = '?id='.$GLOBALS['TSFE']->id.'&type='.$GLOBALS['TSFE']->type;
05046                 $this->lastTypoLinkUrl = '';
05047                 $this->lastTypoLinkTarget = '';
05048                 if ($link_param)        {
05049                         $link_paramA = t3lib_div::unQuoteFilenames($link_param,true);
05050 
05051                                 // Check for link-handler keyword:
05052                         list($linkHandlerKeyword,$linkHandlerValue) = explode(':',trim($link_paramA[0]),2);
05053                         if ($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['typolinkLinkHandler'][$linkHandlerKeyword] && strcmp($linkHandlerValue,"")) {
05054                                 $linkHandlerObj = &t3lib_div::getUserObj($TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_content.php']['typolinkLinkHandler'][$linkHandlerKeyword]);
05055                                 return $linkHandlerObj->main($linktxt, $conf, $linkHandlerKeyword, $linkHandlerValue, $link_param, $this);
05056                         }
05057 
05058                         $link_param = trim($link_paramA[0]);    // Link parameter value
05059                         $linkClass = trim($link_paramA[2]);             // Link class
05060                         if ($linkClass=='-')    $linkClass = '';        // The '-' character means 'no class'. Necessary in order to specify a title as fourth parameter without setting the target or class!
05061                         $forceTarget = trim($link_paramA[1]);   // Target value
05062                         $forceTitle = trim($link_paramA[3]);    // Title value
05063                         if ($forceTarget=='-')  $forceTarget = '';      // The '-' character means 'no target'. Necessary in order to specify a class as third parameter without setting the target!
05064                                 // Check, if the target is coded as a JS open window link:
05065                         $JSwindowParts = array();
05066                         $JSwindowParams = '';
05067                         $onClick = '';
05068                         if ($forceTarget && ereg('^([0-9]+)x([0-9]+)(:(.*)|.*)$',$forceTarget,$JSwindowParts))  {
05069                                         // Take all pre-configured and inserted parameters and compile parameter list, including width+height:
05070                                 $JSwindow_tempParamsArr = t3lib_div::trimExplode(',',strtolower($conf['JSwindow_params'].','.$JSwindowParts[4]),1);
05071                                 $JSwindow_paramsArr=array();
05072                                 foreach($JSwindow_tempParamsArr as $JSv)        {
05073                                         list($JSp,$JSv) = explode('=',$JSv);
05074                                         $JSwindow_paramsArr[$JSp]=$JSp.'='.$JSv;
05075                                 }
05076                                         // Add width/height:
05077                                 $JSwindow_paramsArr['width']='width='.$JSwindowParts[1];
05078                                 $JSwindow_paramsArr['height']='height='.$JSwindowParts[2];
05079                                         // Imploding into string:
05080                                 $JSwindowParams = implode(',',$JSwindow_paramsArr);
05081                                 $forceTarget = '';      // Resetting the target since we will use onClick.
05082                         }
05083 
05084                                 // Internal target:
05085                         $target = isset($conf['target']) ? $conf['target'] : $GLOBALS['TSFE']->intTarget;
05086                         if ($conf['target.'])   {$target=$this->stdWrap($target, $conf['target.']);}
05087 
05088                                 // Title tag
05089                         $title = $conf['title'];
05090                         if ($conf['title.'])    {$title=$this->stdWrap($title, $conf['title.']);}
05091 
05092                                 // Parse URL:
05093                         $pU = parse_url($link_param);
05094 
05095                                 // Detecting kind of link:
05096                         if(strstr($link_param,'@') && (!$pU['scheme'] || $pU['scheme']=='mailto'))      {               // If it's a mail address:
05097                                 $link_param = eregi_replace('^mailto:','',$link_param);
05098                                 list($this->lastTypoLinkUrl,$linktxt) = $this->getMailTo($link_param,$linktxt,$initP);
05099                                 $finalTagParts['url']=$this->lastTypoLinkUrl;
05100                                 $finalTagParts['TYPE']='mailto';
05101                         } else {
05102                                 $isLocalFile=0;
05103                                 $fileChar=intval(strpos($link_param, '/'));
05104                                 $urlChar=intval(strpos($link_param, '.'));
05105 
05106                                         // 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.
05107                                 list($rootFileDat) = explode('?',rawurldecode($link_param));
05108                                 $containsSlash = strstr($rootFileDat,'/');
05109                                 $rFD_fI = pathinfo($rootFileDat);
05110                                 if (trim($rootFileDat) && !$containsSlash && (@is_file(PATH_site.$rootFileDat) || t3lib_div::inList('php,html,htm',strtolower($rFD_fI['extension']))))  {
05111                                         $isLocalFile = 1;
05112                                 } elseif ($containsSlash)       {
05113                                         $isLocalFile = 2;               // Adding this so realurl directories are linked right (non-existing).
05114                                 }
05115 
05116                                 if($pU['scheme'] || ($isLocalFile!=1 && $urlChar && (!$containsSlash || $urlChar<$fileChar)))   {       // url (external): If doubleSlash or if a '.' comes before a '/'.
05117                                         $target = isset($conf['extTarget']) ? $conf['extTarget'] : $GLOBALS['TSFE']->extTarget;
05118                                         if ($conf['extTarget.'])        {$target = $this->stdWrap($target, $conf['extTarget.']);}
05119                                         if ($forceTarget)       {$target=$forceTarget;}
05120                                         if ($linktxt=='') $linktxt = $link_param;
05121                                         if (!$pU['scheme'])     {$scheme='http://';} else {$scheme='';}
05122                                         if ($GLOBALS['TSFE']->config['config']['jumpurl_enable'])       {
05123                                                 $this->lastTypoLinkUrl = $GLOBALS['TSFE']->absRefPrefix.$GLOBALS['TSFE']->config['mainScript'].$initP.'&jumpurl='.rawurlencode($scheme.$link_param).$GLOBALS['TSFE']->getMethodUrlIdToken;
05124                                         } else {
05125                                                 $this->lastTypoLinkUrl = $scheme.$link_param;
05126                                         }
05127                                         $this->lastTypoLinkTarget = $target;
05128                                         $finalTagParts['url']=$this->lastTypoLinkUrl;
05129                                         $finalTagParts['targetParams'] = $target ? ' target="'.$target.'"' : '';
05130                                         $finalTagParts['TYPE']='url';
05131                                 } elseif ($containsSlash || $isLocalFile)       {       // file (internal)
05132                                         $splitLinkParam = explode('?', $link_param);
05133                                         if (@file_exists(rawurldecode($splitLinkParam[0])) || $isLocalFile)     {
05134                                                 if ($linktxt=='') $linktxt = rawurldecode($link_param);
05135                                                 if ($GLOBALS['TSFE']->config['config']['jumpurl_enable'])       {
05136                                                         $this->lastTypoLinkUrl = $GLOBALS['TSFE']->absRefPrefix.$GLOBALS['TSFE']->config['mainScript'].$initP.'&jumpurl='.rawurlencode($link_param).$GLOBALS['TSFE']->getMethodUrlIdToken;
05137                                                 } else {
05138                                                         $this->lastTypoLinkUrl = $GLOBALS['TSFE']->absRefPrefix.$link_param;
05139                                                 }
05140                                                 if ($forceTarget)       {$target=$forceTarget;}
05141                                                 $this->lastTypoLinkTarget = $target;
05142 
05143                                                 $finalTagParts['url'] = $this->lastTypoLinkUrl;
05144                                                 $finalTagParts['targetParams'] = $target ? ' target="'.$target.'"' : '';
05145                                                 $finalTagParts['TYPE'] = 'file';
05146                                         } else {
05147                                                 $GLOBALS['TT']->setTSlogMessage("typolink(): File '".$splitLinkParam[0]."' did not exist, so '".$linktxt."' was not linked.",1);
05148                                                 return $linktxt;
05149                                         }
05150                                 } else {        // integer or alias (alias is without slashes or periods or commas, that is 'nospace,alphanum_x,lower,unique' according to definition in $TCA!)
05151                                         if ($conf['no_cache.']) $conf['no_cache']=$this->stdWrap($conf['no_cache'], $conf['no_cache.']);
05152                                         $link_params_parts=explode('#',$link_param);
05153                                         $link_param = trim($link_params_parts[0]);              // Link-data del
05154                                         if (!strcmp($link_param,''))    {$link_param=$GLOBALS['TSFE']->id;}     // If no id or alias is given
05155                                         if ($link_params_parts[1] && !$sectionMark)     {
05156                                                 $sectionMark = trim($link_params_parts[1]);
05157                                                 $sectionMark = (t3lib_div::testInt($sectionMark)?'#c':'#').$sectionMark;
05158                                         }
05159                                                 // Splitting the parameter by ',' and if the array counts more than 1 element it's a id/type/? pair
05160                                         unset($theTypeP);
05161                                         $pairParts = t3lib_div::trimExplode(',',$link_param);
05162                                         if (count($pairParts)>1)        {
05163                                                 $link_param = $pairParts[0];
05164                                                 $theTypeP = $pairParts[1];              // Overruling 'type'
05165                                         }
05166                                                 // Checking if the id-parameter is an alias.
05167                                         if (!t3lib_div::testInt($link_param))   {
05168                                                 $link_param = $GLOBALS['TSFE']->sys_page->getPageIdFromAlias($link_param);
05169                                         }
05170 
05171                                                 // Looking up the page record to verify its existence:
05172                                         $disableGroupAccessCheck = $GLOBALS['TSFE']->config['config']['typolinkLinkAccessRestrictedPages'] ? TRUE : FALSE;
05173                                         $page = $GLOBALS['TSFE']->sys_page->getPage($link_param,$disableGroupAccessCheck);
05174 
05175                                         if (count($page))       {
05176                                                         // MointPoints, look for closest MPvar:
05177                                                 $MPvarAcc = array();
05178                                                 if (!$GLOBALS['TSFE']->config['config']['MP_disableTypolinkClosestMPvalue'])    {
05179                                                         $temp_MP = $this->getClosestMPvalueForPage($page['uid'],TRUE);
05180                                                         if ($temp_MP)   $MPvarAcc['closest'] = $temp_MP;
05181                                                 }
05182                                                         // Look for overlay Mount Point:
05183                                                 $mount_info = $GLOBALS['TSFE']->sys_page->getMountPointInfo($page['uid'], $page);
05184                                                 if (is_array($mount_info) && $mount_info['overlay'])    {
05185                                                         $page = $GLOBALS['TSFE']->sys_page->getPage($mount_info['mount_pid'],$disableGroupAccessCheck);
05186                                                         if (!count($page))      {
05187                                                                 $GLOBALS['TT']->setTSlogMessage("typolink(): Mount point '".$mount_info['mount_pid']."' was not available, so '".$linktxt."' was not linked.",1);
05188                                                                 return $linktxt;
05189                                                         }
05190                                                         $MPvarAcc['re-map'] = $mount_info['MPvar'];
05191                                                 }
05192 
05193                                                         // Setting title if blank value to link:
05194                                                 if ($linktxt=='') $linktxt = $page['title'];
05195 
05196                                                         // Query Params:
05197                                                 $addQueryParams = $conf['addQueryString'] ? $this->getQueryArguments($conf['addQueryString.']) : '';
05198                                                 $addQueryParams .= trim($this->stdWrap($conf['additionalParams'],$conf['additionalParams.']));
05199                                                 if (substr($addQueryParams,0,1)!='&')           {
05200                                                         $addQueryParams = '';
05201                                                 } elseif ($conf['useCacheHash']) {      // cache hashing:
05202                                                         $pA = t3lib_div::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)
05203                                                         $addQueryParams.= '&cHash='.t3lib_div::shortMD5(serialize($pA));
05204                                                 }
05205 
05206                                                 $tCR_domain = '';
05207                                                 // Mount pages are always local and never link to another domain
05208                                                 if (count($MPvarAcc))   {
05209                                                         // Add "&MP" var:
05210                                                         $addQueryParams.= '&MP='.rawurlencode(implode(',',$MPvarAcc));
05211                                                 }
05212                                                 elseif ($GLOBALS['TSFE']->config['config']['typolinkCheckRootline'])    {
05213                                                         // 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:
05214                                                         $tCR_rootline = $GLOBALS['TSFE']->sys_page->getRootLine($page['uid']);  // Gets rootline of linked-to page
05215                                                         $tCR_flag = 0;
05216                                                         foreach ($tCR_rootline as $tCR_data)    {
05217                                                                 if ($tCR_data['uid']==$GLOBALS['TSFE']->tmpl->rootLine[0]['uid'])       {
05218                                                                         $tCR_flag = 1;  // OK, it was in rootline!
05219                                                                         break;
05220                                                                 }
05221                                                         }
05222                                                         if (!$tCR_flag) {
05223                                                                 foreach ($tCR_rootline as $tCR_data)    {
05224                                                                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_domain', 'pid='.intval($tCR_data['uid']).' AND redirectTo=\'\''.$this->enableFields('sys_domain'), '', 'sorting');
05225                                                                         if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
05226                                                                                 $tCR_domain = preg_replace('/\/$/','',$row['domainName']);
05227                                                                                 break;
05228                                                                         }
05229                                                                 }
05230                                                         }
05231                                                 }
05232                                                         // If other domain, overwrite
05233                                                 if (strlen($tCR_domain))        {
05234                                                         $target = isset($conf['extTarget']) ? $conf['extTarget'] : $GLOBALS['TSFE']->extTarget;
05235                                                         if ($conf['extTarget.'])        {$target = $this->stdWrap($target, $conf['extTarget.']);}
05236                                                         if ($forceTarget)       {$target=$forceTarget;}
05237                                                         $LD['target'] = $target;
05238                                                         $this->lastTypoLinkUrl = $this->URLqMark('http://'.$tCR_domain.'/index.php?id='.$page['uid'],$addQueryParams).$sectionMark;
05239                                                 } else {        // Internal link:
05240                                                         if ($forceTarget)       {$target=$forceTarget;}
05241                                                         $LD = $GLOBALS['TSFE']->tmpl->linkData($page,$target,$conf['no_cache'],'','',$addQueryParams,$theTypeP);
05242                                                         $this->lastTypoLinkUrl = $this->URLqMark($LD['totalURL'],'').$sectionMark;
05243                                                 }
05244 
05245                                                 $this->lastTypoLinkTarget = $LD['target'];
05246                                                 $targetPart = $LD['target'] ? ' target="'.$LD['target'].'"' : '';
05247 
05248                                                         // If sectionMark is set, there is no baseURL AND the current page is the page the link is to, check if there are any additional parameters and is not, drop the url.
05249                                                 if ($sectionMark && !trim($addQueryParams) && $page['uid']==$GLOBALS['TSFE']->id && !$GLOBALS['TSFE']->config['config']['baseURL'])     {
05250                                                         list(,$URLparams) = explode('?',$this->lastTypoLinkUrl);
05251                                                         list($URLparams) = explode('#',$URLparams);
05252                                                         parse_str ($URLparams.$LD['orig_type'], $URLparamsArray);
05253                                                         if (intval($URLparamsArray['type'])==$GLOBALS['TSFE']->type)    {       // type nums must match as well as page ids
05254                                                                 unset($URLparamsArray['id']);
05255                                                                 unset($URLparamsArray['type']);
05256                                                                 if (!count($URLparamsArray))    {       // If there are no parameters left.... set the new url.
05257                                                                         $this->lastTypoLinkUrl = $sectionMark;
05258                                                                 }
05259                                                         }
05260                                                 }
05261 
05262                                                         // If link is to a access restricted page which should be redirected, then find new URL:
05263                                                 if ($GLOBALS['TSFE']->config['config']['typolinkLinkAccessRestrictedPages'] &&
05264                                                                 $GLOBALS['TSFE']->config['config']['typolinkLinkAccessRestrictedPages']!=='NONE' &&
05265                                                                 !$GLOBALS['TSFE']->checkPageGroupAccess($page)) {
05266                                                                         $thePage = $GLOBALS['TSFE']->sys_page->getPage($GLOBALS['TSFE']->config['config']['typolinkLinkAccessRestrictedPages']);
05267 
05268                                                                         $addParams = $GLOBALS['TSFE']->config['config']['typolinkLinkAccessRestrictedPages_addParams'];
05269                                                                         $addParams = str_replace('###RETURN_URL###',rawurlencode($this->lastTypoLinkUrl),$addParams);
05270                                                                         $addParams = str_replace('###PAGE_ID###',$page['uid'],$addParams);
05271                                                                         $LD = $GLOBALS['TSFE']->tmpl->linkData($thePage,$target,'','','',$addParams,$theTypeP);
05272                                                                         $this->lastTypoLinkUrl = $this->URLqMark($LD['totalURL'],'');
05273                                                 }
05274 
05275                                                         // Rendering the tag.
05276                                                 $finalTagParts['url']=$this->lastTypoLinkUrl;
05277                                                 $finalTagParts['targetParams']=$targetPart;
05278                                                 $finalTagParts['TYPE']='page';
05279                                         } else {
05280                                                 $GLOBALS['TT']->setTSlogMessage("typolink(): Page id '".$link_param."' was not found, so '".$linktxt."' was not linked.",1);
05281                                                 return $linktxt;
05282                                         }
05283                                 }
05284                         }
05285 
05286                         if ($forceTitle)        {$title=$forceTitle;}
05287 
05288                         if ($JSwindowParams)    {
05289 
05290                                         // Create TARGET-attribute only if the right doctype is used
05291                                 if (!t3lib_div::inList('xhtml_strict,xhtml_11,xhtml_2', $GLOBALS['TSFE']->xhtmlDoctype))        {
05292                                         $target = ' target="FEopenLink"';
05293                                 } else {
05294                                         $target = '';
05295                                 }
05296 
05297                                 $onClick="vHWin=window.open('".$GLOBALS['TSFE']->baseUrlWrap($finalTagParts['url'])."','FEopenLink','".$JSwindowParams."');vHWin.focus();return false;";
05298                                 $res = '<a href="'.htmlspecialchars($finalTagParts['url']).'"'. $target .' onclick="'.htmlspecialchars($onClick).'"'.($title?' title="'.$title.'"':'').($linkClass?' class="'.$linkClass.'"':'').$finalTagParts['aTagParams'].'>';
05299                         } else {
05300                                 if ($GLOBALS['TSFE']->spamProtectEmailAddresses === 'ascii' && $finalTagParts['TYPE'] === 'mailto') {
05301                                         $res = '<a href="'.$finalTagParts['url'].'"'.($title?' title="'.$title.'"':'').$finalTagParts['targetParams'].($linkClass?' class="'.$linkClass.'"':'').$finalTagParts['aTagParams'].'>';
05302                                 } else {
05303                                         $res = '<a href="'.htmlspecialchars($finalTagParts['url']).'"'.($title?' title="'.$title.'"':'').$finalTagParts['targetParams'].($linkClass?' class="'.$linkClass.'"':'').$finalTagParts['aTagParams'].'>';
05304                                 }
05305                         }
05306 
05307                                 // Call user function:
05308                         if ($conf['userFunc'])  {
05309                                 $finalTagParts['TAG']=$res;
05310                                 $res = $this->callUserFunction($conf['userFunc'],$conf['userFunc.'],$finalTagParts);
05311                         }
05312 
05313                                 // If flag "returnLastTypoLinkUrl" set, then just return the latest URL made:
05314                         if ($conf['returnLast'])        {
05315                                 switch($conf['returnLast'])     {
05316                                         case 'url':
05317                                                 return $this->lastTypoLinkUrl;
05318                                         break;
05319                                         case 'target':
05320                                                 return $this->lastTypoLinkTarget;
05321                                         break;
05322                                 }
05323                         }
05324 
05325                         if ($conf['ATagBeforeWrap'])    {
05326                                 return $res.$this->wrap($linktxt, $conf['wrap']).'</a>';
05327                         } else {
05328                                 return $this->wrap($res.$linktxt.'</a>', $conf['wrap']);
05329                         }
05330                 } else {
05331                         return $linktxt;
05332                 }
05333         }
05334 
05342         function typoLink_URL($conf)    {
05343                 $this->typolink('|',$conf);
05344                 return $this->lastTypoLinkUrl;
05345         }
05346 
05360         function getTypoLink($label,$params,$urlParameters=array(),$target='')  {
05361                 $conf=array();
05362                 $conf['parameter'] = $params;
05363                 if ($target)    {
05364                         $conf['target']=$target;
05365                         $conf['extTarget']=$target;
05366                 }
05367                 if (is_array($urlParameters))   {
05368                         if (count($urlParameters))      {
05369                                 $conf['additionalParams'].= t3lib_div::implodeArrayForUrl('',$urlParameters);
05370                         }
05371                 } else {
05372                         $conf['additionalParams'].=$urlParameters;
05373                 }
05374                 $out = $this->typolink($label,$conf);
05375                 return $out;
05376         }
05377 
05387         function getTypoLink_URL($params,$urlParameters=array(),$target='')     {
05388                 $this->getTypoLink('',$params,$urlParameters,$target);
05389                 return $this->lastTypoLinkUrl;
05390         }
05391 
05399         function typolinkWrap($conf)    {
05400                 $k=md5(microtime());
05401                 return explode($k,$this->typolink($k,$conf));
05402         }
05403 
05412         function currentPageUrl($urlParameters=array(),$id=0)   {
05413                 return $this->getTypoLink_URL($id?$id:$GLOBALS['TSFE']->id,$urlParameters,$GLOBALS['TSFE']->sPre);
05414         }
05415 
05425         function getClosestMPvalueForPage($pageId, $raw=FALSE)  {
05426                         // MointPoints:
05427                 if ($GLOBALS['TYPO3_CONF_VARS']['FE']['enable_mount_pids'] && $GLOBALS['TSFE']->MP)     {
05428 
05429                         if (!strcmp($GLOBALS['TSFE']->id, $pageId))     {       // same page as current.
05430                                 $MP = $GLOBALS['TSFE']->MP;
05431                         } else { // ... otherwise find closest meeting point:
05432                                 $tCR_rootline = $GLOBALS['TSFE']->sys_page->getRootLine($pageId, '', TRUE);     // Gets rootline of linked-to page
05433                                 $inverseTmplRootline = array_reverse($GLOBALS['TSFE']->tmpl->rootLine);
05434 
05435                                 $rl_mpArray = array();
05436                                 $startMPaccu = FALSE;
05437 
05438                                         // Traverse root line of link uid and inside of that the REAL root line of current position.
05439                                 foreach($tCR_rootline as $tCR_data)     {
05440                                         foreach($inverseTmplRootline as $rlKey => $invTmplRLRec)        {
05441 
05442                                                         // Force accumulating when in overlay mode: Links to this page have to stay within the current branch
05443                                                 if ($invTmplRLRec['_MOUNT_OL'] && ($tCR_data['uid']==$invTmplRLRec['uid']))     {
05444                                                         $startMPaccu = TRUE;
05445                                                 }
05446 
05447                                                         // Accumulate MP data:
05448                                                 if ($startMPaccu && $invTmplRLRec['_MP_PARAM']) {
05449                                                         $rl_mpArray[] = $invTmplRLRec['_MP_PARAM'];
05450                                                 }
05451 
05452                                                         // If two PIDs matches and this is NOT the site root, start accumulation of MP data (on the next level):
05453                                                         // (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!)
05454                                                 if ($tCR_data['pid']==$invTmplRLRec['pid'] && count($inverseTmplRootline)!=$rlKey+1)    {
05455                                                         $startMPaccu = TRUE;
05456                                                 }
05457                                         }
05458                                         if ($startMPaccu)       break;  // Good enough...
05459                                 }
05460 
05461                                 if (count($rl_mpArray)) {
05462                                         $MP = implode(',', array_reverse($rl_mpArray));
05463                                 }
05464                         }
05465                 }
05466 
05467                 return !$raw  ? ($MP ? '&MP='.rawurlencode($MP) : '') : $MP;
05468         }
05469 
05480         function getMailTo($mailAddress,$linktxt,$initP='?') {
05481                 if(!strcmp($linktxt,''))        { $linktxt = $mailAddress; }
05482                 $linktxtIsMailAddress = ($linktxt == $mailAddress ? true : false);
05483 
05484                 $mailToUrl = 'mailto:'.$mailAddress;
05485 
05486                 if (!$GLOBALS['TSFE']->config['config']['jumpurl_enable'] || $GLOBALS['TSFE']->config['config']['jumpurl_mailto_disable']) {
05487                         if ($GLOBALS['TSFE']->spamProtectEmailAddresses) {
05488                                 if ($GLOBALS['TSFE']->spamProtectEmailAddresses === 'ascii')    {
05489                                         $mailToUrl = $GLOBALS['TSFE']->encryptEmail($mailToUrl);
05490                                 } else {
05491                                         $mailToUrl = "javascript:linkTo_UnCryptMailto('".$GLOBALS['TSFE']->encryptEmail($mailToUrl)."');";
05492                                 }
05493                                 if ($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses_atSubst']) {
05494                                         $atLabel = trim($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses_atSubst']);
05495                                 }
05496                                 if ($linktxtIsMailAddress) {
05497                                         $linktxt = str_replace('@',$atLabel?$atLabel:'(at)',$linktxt);
05498                                 }
05499 
05500                                 if ($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses_lastDotSubst']) {
05501                                         $lastDotLabel = trim($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses_lastDotSubst']);
05502                                         $lastDotLabel = $lastDotLabel ? $lastDotLabel : '(dot)';
05503                                         if ($linktxtIsMailAddress) {
05504                                                 $linktxt = preg_replace('/\.([^\.]+)$/', $lastDotLabel.'$1', $linktxt);
05505                                         }
05506                                 }
05507                         }
05508                 } else {
05509                         $mailToUrl = $GLOBALS['TSFE']->absRefPrefix.$GLOBALS['TSFE']->config['mainScript'].$initP.'&jumpurl='.rawurlencode($mailToUrl).$GLOBALS['TSFE']->getMethodUrlIdToken;
05510                 }
05511                 return array($mailToUrl,$linktxt);
05512         }
05513 
05523         function getQueryArguments($conf,$overruleQueryArgs=array(),$forceArgs=FALSE) {
05524                 $rawValues = FALSE;
05525                 switch((string)$conf['method']) {
05526                         case 'GET':
05527                                 $q_in = t3lib_div::_GET();
05528                         break;
05529                         case 'POST':
05530                                 $q_in = t3lib_div::_POST();
05531                         break;
05532                         case 'GET,POST':
05533                                 $q_in = array_merge(t3lib_div::_GET(), t3lib_div::_POST());
05534                         break;
05535                         case 'POST,GET':
05536                                 $q_in = array_merge(t3lib_div::_POST(), t3lib_div::_GET());
05537                         break;
05538                         default:
05539                                         // shortcut (no further processing necessary)
05540                                 if (!$conf['exclude'])  return '&'.t3lib_div::getIndpEnv('QUERY_STRING');
05541 
05542                                 $q_in = array();
05543                                 foreach (explode('&',t3lib_div::getIndpEnv('QUERY_STRING')) as $arg)    {
05544                                         list($k,$v) = explode('=',$arg);
05545                                         $q_in[$k] = $v;
05546                                 }
05547                                 $rawValues = TRUE;
05548                 }
05549 
05550                 if ($conf['exclude'])   {
05551                         $q_out = array();
05552                         $exclude = t3lib_div::trimExplode(',', $conf['exclude']);
05553                         $exclude[] = 'id';      // never repeat id
05554                         foreach ($q_in as $k => $v)   {
05555                                 if (!in_array($k, $exclude)) {
05556                                         if (isset($overruleQueryArgs[$k]))      {
05557                                                 $v = $overruleQueryArgs[$k];
05558                                                 unset($overruleQueryArgs[$k]);
05559                                         }
05560                                         $q_out[$k] = $v;
05561                                 }
05562                         }
05563                                 // any remaining overrule arguments?
05564                         if ($forceArgs) {
05565                                 foreach ($overruleQueryArgs as $k => $v)        {
05566                                         $q_out[$k] = $v;
05567                                 }
05568                         }
05569                 } else {
05570                         $q_out = &$q_in;
05571                 }
05572 
05573                 $content = '';
05574                 if ($rawValues) {
05575                         foreach ($q_out as $k => $v)    {
05576                                 $content .= '&'.$k.'='.$v;
05577                         }
05578                 } else {
05579                         $content = t3lib_div::implodeArrayForUrl('',$q_out);
05580                 }
05581 
05582                 return $content;
05583         }
05584 
05585 
05586 
05587 
05588 
05589 
05590 
05591 
05592 
05593 
05594 
05595 
05596 
05597 
05598 
05599 
05600 
05601 
05602         /***********************************************
05603          *
05604          * Miscellaneous functions, stand alone
05605          *
05606          ***********************************************/
05607 
05619         function wrap($content,$wrap,$char='|') {
05620                 if ($wrap)      {
05621                         $wrapArr = explode($char, $wrap);
05622                         return trim($wrapArr[0]).$content.trim($wrapArr[1]);
05623                 } else return $content;
05624         }
05625 
05635         function noTrimWrap($content,$wrap)     {
05636                 if ($wrap)      {
05637                         $wrapArr = explode('|', $wrap);
05638                         return $wrapArr[1].$content.$wrapArr[2];
05639                 } else return $content;
05640         }
05641 
05649         function wrapSpace($content, $wrap)     {
05650                 $result = $content;
05651                 if (trim($wrap))        {
05652                         $wrapArray = explode('|',$wrap);
05653                         $wrapBefore = intval($wrapArray[0]);
05654                         $wrapAfter = intval($wrapArray[1]);
05655                         if ($wrapBefore)        {
05656                                 $result = '<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$wrapBefore.'"'.$this->getBorderAttr(' border="0"').' class="spacer-gif" alt="" title="" /><br />'.$result;
05657                         }
05658                         if ($wrapAfter) {
05659                                 $result.='<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$wrapAfter.'"'.$this->getBorderAttr(' border="0"').' class="spacer-gif" alt="" title="" /><br />';
05660                         }
05661                 }
05662                 return $result;
05663         }
05664 
05675         function callUserFunction($funcName,$conf,$content)     {
05676                 $pre = $GLOBALS['TSFE']->TYPO3_CONF_VARS['FE']['userFuncClassPrefix'];
05677                 if ($pre &&
05678                         !t3lib_div::isFirstPartOfStr(trim($funcName),$pre) &&
05679                         !t3lib_div::isFirstPartOfStr(trim($funcName),'tx_')
05680                         )       {
05681                         $GLOBALS['TT']->setTSlogMessage('Function "'.$funcName.'" was not prepended with "'.$pre.'"',3);
05682                         return $content;
05683                 }
05684                         // Split parts
05685                 $parts = explode('->',$funcName);
05686                 if (count($parts)==2)   {       // Class
05687                         $cls = t3lib_div::makeInstanceClassName($parts[0]);
05688                         if (class_exists ($cls))        {
05689                                 $classObj = new $cls;
05690                                 if (method_exists($classObj, $parts[1]))        {
05691                                         $classObj->cObj = &$this;
05692                                         $content = call_user_method($parts[1], $classObj, $content, $conf);
05693                                 } else {
05694                                         $GLOBALS['TT']->setTSlogMessage('Method "'.$parts[1].'" did not exist in class "'.$cls.'"',3);
05695                                 }
05696                         } else {
05697                                 $GLOBALS['TT']->setTSlogMessage('Class "'.$cls.'" did not exist',3);
05698                         }
05699                 } else {        // Function
05700                         if (function_exists($funcName)) {
05701                                 $content = call_user_func($funcName, $content, $conf);
05702                         } else {
05703                                 $GLOBALS['TT']->setTSlogMessage('Function "'.$funcName.'" did not exist',3);
05704                         }
05705                 }
05706                 return $content;
05707         }
05708 
05716         function processParams($params) {
05717                 $paramArr=array();
05718                 $lines=t3lib_div::trimExplode(chr(10),$params,1);
05719                 foreach($lines as $val) {
05720                         $pair = explode('=',$val,2);
05721                         if (!t3lib_div::inList('#,/',substr(trim($pair[0]),0,1)))       {
05722                                 $paramArr[trim($pair[0])] = trim($pair[1]);
05723                         }
05724                 }
05725                 return $paramArr;
05726         }
05727 
05734         function keywords($content)     {
05735                 $listArr = split(',|;|'.chr(10),$content);
05736                 reset($listArr);
05737                 while(list($k,$v)=each($listArr))       {
05738                         $listArr[$k]=trim($v);
05739                 }
05740                 return implode(',',$listArr);
05741         }
05742 
05751         function caseshift($theValue, $case)    {
05752                 $case = strtolower($case);
05753                 switch($case)   {
05754                         case 'upper':
05755                                 $theValue = $GLOBALS['TSFE']->csConvObj->conv_case($GLOBALS['TSFE']->renderCharset,$theValue,'toUpper');
05756                                 #$theValue = strtoupper($theValue);
05757                                 #$theValue = strtr($theValue, $this->caseConvStrings[0], $this->caseConvStrings[1]);
05758                         break;
05759                         case 'lower':
05760                                 $theValue = $GLOBALS['TSFE']->csConvObj->conv_case($GLOBALS['TSFE']->renderCharset,$theValue,'toLower');
05761                                 #$theValue = strtolower($theValue);
05762                                 #$theValue = strtr($theValue, $this->caseConvStrings[1], $this->caseConvStrings[0]);
05763                         break;
05764                 }
05765                 return $theValue;
05766         }
05767 
05776         function HTMLcaseshift($theValue, $case)        {
05777                 $inside = 0;
05778                 $newVal = '';
05779                 $pointer = 0;
05780                 $totalLen = strlen($theValue);
05781                 do      {
05782                         if (!$inside)   {
05783                                 $len = strcspn(substr($theValue,$pointer),'<');
05784                                 $newVal.= $this->caseshift(substr($theValue,$pointer,$len),$case);
05785                                 $inside = 1;
05786                         } else {
05787                                 $len = strcspn(substr($theValue,$pointer),'>')+1;
05788                                 $newVal.= substr($theValue,$pointer,$len);
05789                                 $inside = 0;
05790                         }
05791                         $pointer+=$len;
05792                 } while($pointer<$totalLen);
05793                 return $newVal;
05794         }
05795 
05805         function bytes($sizeInBytes,$labels)    {
05806                 return t3lib_div::formatSize($sizeInBytes,$labels);
05807         }
05808 
05816         function calcAge($seconds,$labels)      {
05817                 if (t3lib_div::testInt($labels)) {
05818                         $labels = ' min| hrs| days| yrs';
05819                 } else {
05820                         $labels=str_replace('"','',$labels);
05821                 }
05822 
05823                 $labelArr = explode('|',$labels);
05824                 $absSeconds = abs($seconds);
05825                 if ($absSeconds<3600)   {
05826                         $seconds = round ($seconds/60).$labelArr[0];
05827                 } elseif ($absSeconds<24*3600)  {
05828                         $seconds = round ($seconds/3600).$labelArr[1];
05829                 } elseif ($absSeconds<365*24*3600)      {
05830                         $seconds = round ($seconds/(24*3600)).$labelArr[2];
05831                 } else {
05832                         $seconds = round ($seconds/(365*24*3600)).$labelArr[3];
05833                 }
05834                 return $seconds;
05835         }
05836 
05848         function sendNotifyEmail($msg, $recipients, $cc, $email_from, $email_fromName='', $replyTo='')  {
05849                         // Sends order emails:
05850                 $headers=array();
05851                 if ($email_from)        {$headers[]='From: '.$email_fromName.' <'.$email_from.'>';}
05852                 if ($replyTo)           {$headers[]='Reply-To: '.$replyTo;}
05853 
05854                 $recipients=implode(',',t3lib_div::trimExplode(',',$recipients,1));
05855 
05856                 $emailContent = trim($msg);
05857                 if ($emailContent)      {
05858                         $parts = split(chr(10),$emailContent,2);                // First line is subject
05859                         $subject=trim($parts[0]);
05860                         $plain_message=trim($parts[1]);
05861 
05862                         if ($recipients)        $GLOBALS['TSFE']->plainMailEncoded($recipients, $subject, $plain_message, implode(chr(10),$headers));
05863                         if ($cc)        $GLOBALS['TSFE']->plainMailEncoded($cc, $subject, $plain_message, implode(chr(10),$headers));
05864                         return true;
05865                 }
05866         }
05867 
05875         function URLqMark($url,$params) {
05876                 if ($params && !strstr($url,'?'))       {
05877                         return $url.'?'.$params;
05878                 } else {
05879                         return $url.$params;
05880                 }
05881         }
05882 
05891         function checkEmail($email)     {
05892                 return t3lib_div::validEmail($email);
05893         }
05894 
05903         function clearTSProperties($TSArr,$propList)    {
05904                 $list = explode(',',$propList);
05905                 while(list(,$prop)=each($list)) {
05906                         $prop = trim($prop);
05907                         unset($TSArr[$prop]);
05908                         unset($TSArr[$prop.'.']);
05909                 }
05910                 return $TSArr;
05911         }
05912 
05922         function mergeTSRef($confArr,$prop)     {
05923                 if (substr($confArr[$prop],0,1)=='<')   {
05924                         $key = trim(substr($confArr[$prop],1));
05925                         $cF = t3lib_div::makeInstance('t3lib_TSparser');
05926                                 // $name and $conf is loaded with the referenced values.
05927                         $old_conf=$confArr[$prop.'.'];
05928                         list($name, $conf) = $cF->getVal($key,$GLOBALS['TSFE']->tmpl->setup);
05929                         if (is_array($old_conf) && count($old_conf))    {
05930                                 $conf = $this->joinTSarrays($conf,$old_conf);
05931                         }
05932                         $confArr[$prop.'.']=$conf;
05933                 }
05934                 return $confArr;
05935         }
05936 
05945         function joinTSarrays($conf,$old_conf)  {
05946                 if (is_array($old_conf))        {
05947                         reset($old_conf);
05948                         while(list($key,$val)=each($old_conf))  {
05949                                 if (is_array($val))     {
05950                                         $conf[$key] = $this->joinTSarrays($conf[$key],$val);
05951                                 } else {
05952                                         $conf[$key] = $val;
05953                                 }
05954                         }
05955                 }
05956                 return $conf;
05957         }
05958 
05968         function gifBuilderTextBox($gifbuilderConf, $conf, $text)       {
05969                 $chars = intval($conf['chars']) ? intval($conf['chars']) : 20;
05970                 $lineDist = intval($conf['lineDist']) ? intval($conf['lineDist']) : 20;
05971                 $Valign = strtolower(trim($conf['Valign']));
05972                 $tmplObjNumber = intval($conf['tmplObjNumber']);
05973                 $maxLines = intval($conf['maxLines']);
05974 
05975                 if ($tmplObjNumber && $gifbuilderConf[$tmplObjNumber]=='TEXT')  {
05976                         $textArr = $this->linebreaks($text,$chars,$maxLines);
05977                         $angle = intval($gifbuilderConf[$tmplObjNumber.'.']['angle']);
05978                         reset($textArr);
05979                         while(list($c,$textChunk)=each($textArr))       {
05980                                 $index = $tmplObjNumber+1+($c*2);
05981                                         // Workarea
05982                                 $gifbuilderConf = $this->clearTSProperties($gifbuilderConf,$index);
05983                                 $rad_angle = 2*pi()/360*$angle;
05984                                 $x_d = sin($rad_angle)*$lineDist;
05985                                 $y_d = cos($rad_angle)*$lineDist;
05986 
05987                                 $diff_x_d=0;
05988                                 $diff_y_d=0;
05989                                 if ($Valign=='center')  {
05990                                         $diff_x_d = $x_d*count($textArr);
05991                                         $diff_x_d = $diff_x_d/2;
05992                                         $diff_y_d = $y_d*count($textArr);
05993                                         $diff_y_d = $diff_y_d/2;
05994                                 }
05995 
05996 
05997                                 $x_d = round($x_d*$c - $diff_x_d);
05998                                 $y_d = round($y_d*$c - $diff_y_d);
05999 
06000                                 $gifbuilderConf[$index] = 'WORKAREA';
06001                                 $gifbuilderConf[$index.'.']['set'] = $x_d.','.$y_d;
06002                                         // Text
06003                                 $index++;
06004                                 $gifbuilderConf = $this->clearTSProperties($gifbuilderConf,$index);
06005                                 $gifbuilderConf[$index] = 'TEXT';
06006                                 $gifbuilderConf[$index.'.'] = $this->clearTSProperties($gifbuilderConf[$tmplObjNumber.'.'],'text');
06007                                 $gifbuilderConf[$index.'.']['text'] = $textChunk;
06008                         }
06009                         $gifbuilderConf = $this->clearTSProperties($gifbuilderConf,$tmplObjNumber);
06010                 }
06011                 return $gifbuilderConf;
06012         }
06013 
06024         function linebreaks($string,$chars,$maxLines=0) {
06025                 $lines = explode(chr(10),$string);
06026                 $lineArr=Array();
06027                 $c=0;
06028                 while(list(,$paragraph)=each($lines))   {
06029                         $words = explode(' ',$paragraph);
06030                         while(list(,$word)=each($words))        {
06031                                 if (strlen($lineArr[$c].$word)>$chars)  {
06032                                         $c++;
06033                                 }
06034                                 if (!$maxLines || $c<$maxLines) {
06035                                         $lineArr[$c].= $word.' ';
06036                                 }
06037                         }
06038                         $c++;
06039                 }
06040                 return $lineArr;
06041         }
06042 
06055         function getUpdateJS($dataArray, $formName, $arrPrefix, $fieldList)     {
06056                 $JSPart='';
06057                 $updateValues=t3lib_div::trimExplode(',',$fieldList);
06058                 while(list(,$fKey)=each($updateValues)) {
06059                         $value = $dataArray[$fKey];
06060                         if (is_array($value))   {
06061                                 reset($value);
06062                                 while(list(,$Nvalue)=each($value))      {
06063                                         $JSPart.="
06064         updateForm('".$formName."','".$arrPrefix."[".$fKey."][]',".t3lib_div::quoteJSvalue($Nvalue, true).")";
06065                                 }
06066 
06067                         } else {
06068                                 $JSPart.="
06069         updateForm('".$formName."','".$arrPrefix."[".$fKey."]',".t3lib_div::quoteJSvalue($value, true).")";
06070                         }
06071                 }
06072                 $JSPart='<script type="text/javascript">
06073         /*<![CDATA[*/ '.$JSPart.'
06074         /*]]>*/
06075 </script>
06076 ';
06077                 $GLOBALS['TSFE']->additionalHeaderData['JSincludeFormupdate']='<script type="text/javascript" src="'.$GLOBALS['TSFE']->absRefPrefix.'t3lib/jsfunc.updateform.js"></script>';
06078                 return $JSPart;
06079         }
06080 
06081 
06082 
06083 
06084 
06085 
06086 
06087 
06088 
06089 
06090 
06091 
06092 
06093 
06094 
06095 
06096 
06097 
06098 
06099 
06100 
06101 
06102 
06103 
06104 
06105 
06106 
06107 
06108         /***********************************************
06109          *
06110          * Database functions, making of queries
06111          *
06112          ***********************************************/
06113 
06124         function DBgetDelete($table, $uid, $doExec=FALSE)       {
06125                 if (intval($uid))       {
06126                         if ($GLOBALS['TCA'][$table]['ctrl']['delete'])  {
06127                                 if ($doExec)    {
06128                                         return $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid='.intval($uid), array($GLOBALS['TCA'][$table]['ctrl']['delete'] => 1));
06129                                 } else {
06130                                         return $GLOBALS['TYPO3_DB']->UPDATEquery($table, 'uid='.intval($uid), array($GLOBALS['TCA'][$table]['ctrl']['delete'] => 1));
06131                                 }
06132                         } else {
06133                                 if ($doExec)    {
06134                                         return $GLOBALS['TYPO3_DB']->exec_DELETEquery($table, 'uid='.intval($uid));
06135                                 } else {
06136                                         return $GLOBALS['TYPO3_DB']->DELETEquery($table, 'uid='.intval($uid));
06137                                 }
06138                         }
06139                 }
06140         }
06141 
06156         function DBgetUpdate($table, $uid, $dataArr, $fieldList, $doExec=FALSE) {
06157                 unset($dataArr['uid']); // uid can never be set
06158                 $uid=intval($uid);
06159 
06160                 if ($uid)       {
06161                         $fieldList = implode(',',t3lib_div::trimExplode(',',$fieldList,1));
06162                         $updateFields=array();
06163 
06164                         foreach($dataArr as $f => $v)   {
06165                                 if (t3lib_div::inList($fieldList,$f))   {
06166                                         $updateFields[$f] = $v;
06167                                 }
06168                         }
06169 
06170                         if ($GLOBALS['TCA'][$table]['ctrl']['tstamp'])  {
06171                                 $updateFields[$GLOBALS['TCA'][$table]['ctrl']['tstamp']] = time();
06172                         }
06173 
06174                         if (count($updateFields))       {
06175                                 if ($doExec)    {
06176                                         return $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid='.intval($uid), $updateFields);
06177                                 } else {
06178                                         return $GLOBALS['TYPO3_DB']->UPDATEquery($table, 'uid='.intval($uid), $updateFields);
06179                                 }
06180                         }
06181                 }
06182         }
06183 
06198         function DBgetInsert($table, $pid, $dataArr, $fieldList, $doExec=FALSE) {
06199                 $extraList='pid';
06200                 if ($GLOBALS['TCA'][$table]['ctrl']['tstamp'])  {$field=$GLOBALS['TCA'][$table]['ctrl']['tstamp']; $dataArr[$field]=time(); $extraList.=','.$field;}
06201                 if ($GLOBALS['TCA'][$table]['ctrl']['crdate'])  {$field=$GLOBALS['TCA'][$table]['ctrl']['crdate']; $dataArr[$field]=time(); $extraList.=','.$field;}
06202                 if ($GLOBALS['TCA'][$table]['ctrl']['cruser_id'])       {$field=$GLOBALS['TCA'][$table]['ctrl']['cruser_id']; $dataArr[$field]=0; $extraList.=','.$field;}
06203                 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;}
06204                 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;}
06205 
06206                 unset($dataArr['uid']); // uid can never be set
06207                 if ($pid>=0)    { $dataArr['pid'] = $pid; }             // Set pid < 0 and the dataarr-pid will be used!
06208                 $fieldList = implode(',',t3lib_div::trimExplode(',',$fieldList.','.$extraList,1));
06209 
06210                 $insertFields = array();
06211                 foreach($dataArr as $f => $v)   {
06212                         if (t3lib_div::inList($fieldList,$f))   {
06213                                 $insertFields[$f] = $v;
06214                         }
06215                 }
06216 
06217                 if ($doExec)    {
06218                         return $GLOBALS['TYPO3_DB']->exec_INSERTquery($table, $insertFields);
06219                 } else {
06220                         return $GLOBALS['TYPO3_DB']->INSERTquery($table, $insertFields);
06221                 }
06222         }
06223 
06235         function DBmayFEUserEdit($table,$row, $feUserRow, $allowedGroups='',$feEditSelf=0)      {
06236                 $groupList = $allowedGroups ? implode(',',array_intersect(t3lib_div::trimExplode(',',$feUserRow['usergroup'],1),t3lib_div::trimExplode(',',$allowedGroups,1))) : $feUserRow['usergroup'];
06237                 $ok=0;
06238                         // points to the field that allows further editing from frontend if not set. If set the record is locked.
06239                 if (!$GLOBALS['TCA'][$table]['ctrl']['fe_admin_lock'] || !$row[$GLOBALS['TCA'][$table]['ctrl']['fe_admin_lock']])       {
06240                                 // points to the field (integer) that holds the fe_users-id of the creator fe_user
06241                         if ($GLOBALS['TCA'][$table]['ctrl']['fe_cruser_id'])    {
06242                                 $rowFEUser = intval($row[$GLOBALS['TCA'][$table]['ctrl']['fe_cruser_id']]);
06243                                 if ($rowFEUser && $rowFEUser==$feUserRow['uid'])        {
06244                                         $ok=1;
06245                                 }
06246                         }
06247                                 // If $feEditSelf is set, fe_users may always edit them selves...
06248                         if ($feEditSelf && $table=='fe_users' && !strcmp($feUserRow['uid'],$row['uid']))        {
06249                                 $ok=1;
06250                         }
06251                                 // points to the field (integer) that holds the fe_group-id of the creator fe_user's first group
06252                         if ($GLOBALS['TCA'][$table]['ctrl']['fe_crgroup_id'])   {
06253                                 $rowFEUser = intval($row[$GLOBALS['TCA'][$table]['ctrl']['fe_crgroup_id']]);
06254                                 if ($rowFEUser) {
06255                                         if (t3lib_div::inList($groupList, $rowFEUser))  {
06256                                                 $ok=1;
06257                                         }
06258                                 }
06259                         }
06260                 }
06261                 return $ok;
06262         }
06263 
06275         function DBmayFEUserEditSelect($table,$feUserRow,$allowedGroups='',$feEditSelf=0)       {
06276                         // Returns where-definition that selects user-editable records.
06277                 $groupList = $allowedGroups ? implode(',',array_intersect(t3lib_div::trimExplode(',',$feUserRow['usergroup'],1),t3lib_div::trimExplode(',',$allowedGroups,1))) : $feUserRow['usergroup'];
06278                 $OR_arr=array();
06279                         // points to the field (integer) that holds the fe_users-id of the creator fe_user
06280                 if ($GLOBALS['TCA'][$table]['ctrl']['fe_cruser_id'])    {
06281                         $OR_arr[]=$GLOBALS['TCA'][$table]['ctrl']['fe_cruser_id'].'='.$feUserRow['uid'];
06282                 }
06283                         // points to the field (integer) that holds the fe_group-id of the creator fe_user's first group
06284                 if ($GLOBALS['TCA'][$table]['ctrl']['fe_crgroup_id'])   {
06285                         $values = t3lib_div::intExplode(',',$groupList);
06286                         while(list(,$theGroupUid)=each($values))        {
06287                                 if ($theGroupUid)       {$OR_arr[]=$GLOBALS['TCA'][$table]['ctrl']['fe_crgroup_id'].'='.$theGroupUid;}
06288                         }
06289                 }
06290                         // If $feEditSelf is set, fe_users may always edit them selves...
06291                 if ($feEditSelf && $table=='fe_users')  {
06292                         $OR_arr[]='uid='.intval($feUserRow['uid']);
06293                 }
06294 
06295                 $whereDef=' AND 1=0';
06296                 if (count($OR_arr))     {
06297                         $whereDef=' AND ('.implode(' OR ',$OR_arr).')';
06298                         if ($GLOBALS['TCA'][$table]['ctrl']['fe_admin_lock'])   {
06299                                 $whereDef.=' AND '.$GLOBALS['TCA'][$table]['ctrl']['fe_admin_lock'].'=0';
06300                         }
06301                 }
06302                 return $whereDef;
06303         }
06304 
06315         function enableFields($table,$show_hidden=0)    {
06316                 return $GLOBALS['TSFE']->sys_page->enableFields($table,$show_hidden?$show_hidden:($table=='pages' ? $GLOBALS['TSFE']->showHiddenPage : $GLOBALS['TSFE']->showHiddenRecords));
06317         }
06318 
06339         function getTreeList($id,$depth,$begin=0,$dontCheckEnableFields=FALSE,$addSelectFields='',$moreWhereClauses='', $prevId_array=array(), $recursionLevel=0)       {
06340 
06341                         // Init vars:
06342                 $allFields = 'uid,hidden,starttime,endtime,fe_group,extendToSubpages,doktype,php_tree_stop,mount_pid,mount_pid_ol,t3ver_state'.$addSelectFields;
06343                 $depth = intval($depth);
06344                 $begin = intval($begin);
06345                 $id = intval($id);
06346                 $theList = '';
06347                 $addId = 0;
06348 
06349                 if ($id)        {
06350 
06351                                 // First level, check id (second level, this is done BEFORE the recursive call)
06352                         if (!$recursionLevel)   {
06353                                         // If Id less than zero it means we should add the real id to list:
06354                                 if ($id < 0)    {
06355                                         $addId = $id = abs($id);
06356                                 }
06357                                         // Check start page:
06358                                 if ($GLOBALS['TSFE']->sys_page->getRawRecord('pages',$id,'uid'))        {
06359 
06360                                                 // Find mount point if any:
06361                                         $mount_info = $GLOBALS['TSFE']->sys_page->getMountPointInfo($id);
06362                                         if (is_array($mount_info))      {
06363                                                 $id = $mount_info['mount_pid'];
06364                                                         // In Overlay mode, use the mounted page uid as added ID!:
06365                                                 if ($addId && $mount_info['overlay'])   {
06366                                                         $addId = $id;
06367                                                 }
06368                                         }
06369                                 } else return '';       // Return blank if the start page was NOT found at all!
06370                         }
06371 
06372                                 // Add this ID to the array of IDs
06373                         if ($begin<=0)  {
06374                                 $prevId_array[] = $id;
06375                         }
06376 
06377                                 // Select sublevel:
06378                         if ($depth>0)   {
06379                                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($allFields, 'pages', 'pid='.intval($id).' AND deleted=0 '.$moreWhereClauses, '' ,'sorting');
06380                                 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))      {
06381                                         $GLOBALS['TSFE']->sys_page->versionOL('pages',$row);
06382 
06383                                         if ($row['doktype']==255 || $row['doktype']==6 || $row['t3ver_state']==1)       { unset($row); }        // Doing this after the overlay to make sure changes in the overlay are respected.
06384 
06385                                         if (is_array($row))     {
06386                                                         // Find mount point if any:
06387                                                 $next_id = $row['uid'];
06388                                                 $mount_info = $GLOBALS['TSFE']->sys_page->getMountPointInfo($next_id, $row);
06389                                                         // Overlay mode:
06390                                                 if (is_array($mount_info) && $mount_info['overlay'])    {
06391                                                         $next_id = $mount_info['mount_pid'];
06392                                                         $res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery($allFields, 'pages', 'uid='.intval($next_id).' AND deleted=0 '.$moreWhereClauses, '' ,'sorting');
06393                                                         $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res2);
06394                                                         $GLOBALS['TSFE']->sys_page->versionOL('pages',$row);
06395 
06396                                                         if ($row['doktype']==255 || $row['doktype']==6 || $row['t3ver_state']==1)       { unset($row); }        // Doing this after the overlay to make sure changes in the overlay are respected.
06397                                                 }
06398                                                         // Add record:
06399                                                 if (is_array($row) && ($dontCheckEnableFields || $GLOBALS['TSFE']->checkPagerecordForIncludeSection($row)))     {
06400                                                                 // Add ID to list:
06401                                                         if ($begin<=0)  {
06402                                                                 if ($dontCheckEnableFields || $GLOBALS['TSFE']->checkEnableFields($row))        {
06403                                                                         $theList.= $next_id.',';
06404                                                                 }
06405                                                         }
06406                                                                 // Next level:
06407                                                         if ($depth>1 && !$row['php_tree_stop']) {
06408                                                                         // Normal mode:
06409                                                                 if (is_array($mount_info) && !$mount_info['overlay'])   {
06410                                                                         $next_id = $mount_info['mount_pid'];
06411                                                                 }
06412                                                                         // Call recursively, if the id is not in prevID_array:
06413                                                                 if (!in_array($next_id,$prevId_array))  {
06414                                                                         $theList.= tslib_cObj::getTreeList($next_id, $depth-1, $begin-1, $dontCheckEnableFields, $addSelectFields, $moreWhereClauses, $prevId_array, $recursionLevel+1);
06415                                                                 }
06416                                                         }
06417                                                 }
06418                                         }
06419                                 }
06420                         }
06421                 }
06422                         // If first run, check if the ID should be returned:
06423                 if (!$recursionLevel)   {
06424                         if ($addId)     {
06425                                 if ($begin>0)   {
06426                                         $theList.= 0;
06427                                 } else {
06428                                         $theList.= $addId;
06429                                 }
06430                         }
06431                 }
06432                         // Return list:
06433                 return $theList;
06434         }
06435 
06445         function whereSelectFromList($field,$value)     {
06446                 return $GLOBALS['TYPO3_DB']->listQuery($field,$value,'');
06447         }
06448 
06463         function exec_mm_query($select,$local_table,$mm_table,$foreign_table,$whereClause='',$groupBy='',$orderBy='',$limit='') {
06464                 return $GLOBALS['TYPO3_DB']->exec_SELECTquery(
06465                                         $select,
06466                                         $local_table.','.$mm_table.($foreign_table?','.$foreign_table:''),
06467                                         $local_table.'.uid='.$mm_table.'.uid_local'.($foreign_table?' AND '.$foreign_table.'.uid='.$mm_table.'.uid_foreign':'').
06468                                                 $whereClause,   // whereClauseMightContainGroupOrderBy
06469                                         $groupBy,
06470                                         $orderBy,
06471                                         $limit
06472                                 );
06473         }
06474 
06490         function exec_mm_query_uidList($select,$local_table_uidlist,$mm_table,$foreign_table='',$whereClause='',$groupBy='',$orderBy='',$limit='')      {
06491                 return $GLOBALS['TYPO3_DB']->exec_SELECTquery(
06492                                         $select,
06493                                         $mm_table.($foreign_table?','.$foreign_table:''),
06494                                         $mm_table.'.uid_local IN ('.$local_table_uidlist.')'.($foreign_table?' AND '.$foreign_table.'.uid='.$mm_table.'.uid_foreign':'').
06495                                                 $whereClause,   // whereClauseMightContainGroupOrderBy
06496                                         $groupBy,
06497                                         $orderBy,
06498                                         $limit
06499                                 );
06500         }
06501 
06511         function searchWhere($sw,$searchFieldList,$searchTable='')      {
06512                 global $TYPO3_DB;
06513 
06514                 $prefixTableName = $searchTable ? $searchTable.'.' : '';
06515                 $where = '';
06516                 if ($sw)        {
06517                         $searchFields = explode(',',$searchFieldList);
06518                         $kw = split('[ ,]',$sw);
06519 
06520                         while(list(,$val)=each($kw))    {
06521                                 $val = trim($val);
06522                                 $where_p = array();
06523                                 if (strlen($val)>=2)    {
06524                                         $val = $TYPO3_DB->escapeStrForLike($TYPO3_DB->quoteStr($val,$searchTable),$searchTable);
06525                                         reset($searchFields);
06526                                         while(list(,$field)=each($searchFields))        {
06527                                                 $where_p[] = $prefixTableName.$field.' LIKE \'%'.$val.'%\'';
06528                                         }
06529                                 }
06530                                 if (count($where_p))    {
06531                                         $where.=' AND ('.implode(' OR ',$where_p).')';
06532                                 }
06533                         }
06534                 }
06535                 return $where;
06536         }
06537 
06547         function exec_getQuery($table, $conf)   {
06548                 $queryParts = $this->getQuery($table, $conf, TRUE);
06549 
06550                 return $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
06551         }
06552 
06565         function getQuery($table, $conf, $returnQueryArray=FALSE)       {
06566 
06567                         // Construct WHERE clause:
06568                 $conf['pidInList'] = trim($this->stdWrap($conf['pidInList'],$conf['pidInList.']));
06569                 if (!strcmp($conf['pidInList'],''))     {
06570                         $conf['pidInList'] = 'this';
06571                 }
06572                 $queryParts = $this->getWhere($table,$conf,TRUE);
06573 
06574                         // Fields:
06575                 $queryParts['SELECT'] = $conf['selectFields'] ? $conf['selectFields'] : '*';
06576 
06577                         // Setting LIMIT:
06578                 if ($conf['max'] || $conf['begin']) {
06579                         $error=0;
06580 
06581                                 // Finding the total number of records, if used:
06582                         if (strstr(strtolower($conf['begin'].$conf['max']),'total'))    {
06583                                 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', $table, $queryParts['WHERE'], $queryParts['GROUPBY']);
06584                                 if ($error = $GLOBALS['TYPO3_DB']->sql_error()) {
06585                                         $GLOBALS['TT']->setTSlogMessage($error);
06586                                 } else {
06587                                         $total = $GLOBALS['TYPO3_DB']->sql_num_rows($res);
06588                                         $conf['max'] = eregi_replace('total', (string)$total, $conf['max']);
06589                                         $conf['begin'] = eregi_replace('total', (string)$total, $conf['begin']);
06590                                 }
06591                         }
06592                         if (!$error)    {
06593                                 $conf['begin'] = t3lib_div::intInRange(ceil($this->calc($conf['begin'])),0);
06594                                 $conf['max'] = t3lib_div::intInRange(ceil($this->calc($conf['max'])),0);
06595                                 if ($conf['begin'] && !$conf['max'])    {
06596                                         $conf['max'] = 100000;
06597                                 }
06598 
06599                                 if ($conf['begin'] && $conf['max'])     {
06600                                         $queryParts['LIMIT'] = $conf['begin'].','.$conf['max'];
06601                                 } elseif (!$conf['begin'] && $conf['max'])      {
06602                                         $queryParts['LIMIT'] = $conf['max'];
06603                                 }
06604                         }
06605                 }
06606 
06607                 if (!$error)    {
06608 
06609                                 // Setting up tablejoins:
06610                         $joinPart='';
06611                         if ($conf['join'])      {
06612                                 $joinPart = 'JOIN ' .trim($conf['join']);
06613                         } elseif ($conf['leftjoin'])    {
06614                                 $joinPart = 'LEFT OUTER JOIN ' .trim($conf['leftjoin']);
06615                         } elseif ($conf['rightjoin'])   {
06616                                 $joinPart = 'RIGHT OUTER JOIN ' .trim($conf['rightjoin']);
06617                         }
06618 
06619                                 // Compile and return query:
06620                         $queryParts['FROM'] = trim($table.' '.$joinPart);
06621                         $query = $GLOBALS['TYPO3_DB']->SELECTquery(
06622                                                 $queryParts['SELECT'],
06623                                                 $queryParts['FROM'],
06624                                                 $queryParts['WHERE'],
06625                                                 $queryParts['GROUPBY'],
06626                                                 $queryParts['ORDERBY'],
06627                                                 $queryParts['LIMIT']
06628                                         );
06629                         return $returnQueryArray ? $queryParts : $query;
06630                 }
06631         }
06632 
06644         function getWhere($table,$conf, $returnQueryArray=FALSE)        {
06645                 global $TCA;
06646 
06647                         // Init:
06648                 $query = '';
06649                 $pid_uid_flag=0;
06650                 $queryParts = array(
06651                         'SELECT' => '',
06652                         'FROM' => '',
06653                         'WHERE' => '',
06654                         'GROUPBY' => '',
06655                         'ORDERBY' => '',
06656                         'LIMIT' => ''
06657                 );
06658 
06659                 if (trim($conf['uidInList']))   {
06660                         $listArr = t3lib_div::intExplode(',',str_replace('this',$GLOBALS['TSFE']->contentPid,$conf['uidInList']));  // str_replace instead of ereg_replace 020800
06661                         if (count($listArr)==1) {
06662                                 $query.=' AND '.$table.'.uid='.intval($listArr[0]);
06663                         } else {
06664                                 $query.=' AND '.$table.'.uid IN ('.implode(',',$GLOBALS['TYPO3_DB']->cleanIntArray($listArr)).')';
06665                         }
06666                         $pid_uid_flag++;
06667                 }
06668                 if (trim($conf['pidInList']))   {
06669                         $listArr = t3lib_div::intExplode(',',str_replace('this',$GLOBALS['TSFE']->contentPid,$conf['pidInList']));      // str_replace instead of ereg_replace 020800
06670                                 // removes all pages which are not visible for the user!
06671                         $listArr = $this->checkPidArray($listArr);
06672                         if (count($listArr))    {
06673                                 $query.=' AND '.$table.'.pid IN ('.implode(',',$GLOBALS['TYPO3_DB']->cleanIntArray($listArr)).')';
06674                                 $pid_uid_flag++;
06675                         } else {
06676                                 $pid_uid_flag=0;                // If not uid and not pid then uid is set to 0 - which results in nothing!!
06677                         }
06678                 }
06679                 if (!$pid_uid_flag)     {               // If not uid and not pid then uid is set to 0 - which results in nothing!!
06680                         $query.=' AND '.$table.'.uid=0';
06681                 }
06682                 if ($where = trim($conf['where']))      {
06683                         $query.=' AND '.$where;
06684                 }
06685 
06686                 if ($conf['languageField'])     {
06687                         if ($GLOBALS['TSFE']->sys_language_contentOL && $TCA[$table] && $TCA[$table]['ctrl']['languageField'] && $TCA[$table]['ctrl']['transOrigPointerField']) {
06688                                         // 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!
06689                                 $sys_language_content = '0,-1';
06690                         } else {
06691                                 $sys_language_content = intval($GLOBALS['TSFE']->sys_language_content);
06692                         }
06693                         $query.=' AND '.$conf['languageField'].' IN ('.$sys_language_content.')';
06694                 }
06695 
06696                 $andWhere = trim($this->stdWrap($conf['andWhere'],$conf['andWhere.']));
06697                 if ($andWhere)  {
06698                         $query.=' AND '.$andWhere;
06699                 }
06700 
06701                         // enablefields
06702                 if ($table=='pages')    {
06703                         $query.=' '.$GLOBALS['TSFE']->sys_page->where_hid_del.
06704                                                 $GLOBALS['TSFE']->sys_page->where_groupAccess;
06705                 } else {
06706                         $query.=$this->enableFields($table);
06707                 }
06708 
06709                         // MAKE WHERE:
06710                 if ($query)     {
06711                         $queryParts['WHERE'] = trim(substr($query,4));  // Stripping of " AND"...
06712                         $query = 'WHERE '.$queryParts['WHERE'];
06713                 }
06714 
06715                         // GROUP BY
06716                 if (trim($conf['groupBy']))     {
06717                         $queryParts['GROUPBY'] = trim($conf['groupBy']);
06718                         $query.=' GROUP BY '.$queryParts['GROUPBY'];
06719                 }
06720 
06721                         // ORDER BY
06722                 if (trim($conf['orderBy']))     {
06723                         $queryParts['ORDERBY'] = trim($conf['orderBy']);
06724                         $query.=' ORDER BY '.$queryParts['ORDERBY'];
06725                 }
06726 
06727                         // Return result:
06728                 return $returnQueryArray ? $queryParts : $query;
06729         }
06730 
06739         function checkPidArray($listArr)        {
06740                 $outArr = Array();
06741                 if (is_array($listArr) && count($listArr))      {
06742                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'uid IN ('.implode(',',$listArr).')'.$this->enableFields('pages').' AND doktype NOT IN ('.$this->checkPid_badDoktypeList.')');
06743                         if ($error = $GLOBALS['TYPO3_DB']->sql_error()) {
06744                                 $GLOBALS['TT']->setTSlogMessage($error.': '.$query,3);
06745                         } else {
06746                                 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))       {
06747                                         $outArr[] = $row['uid'];
06748                                 }
06749                         }
06750                 }
06751                 return $outArr;
06752         }
06753 
06762         function checkPid($uid) {
06763                 $uid = intval($uid);
06764                 if (!isset($this->checkPid_cache[$uid]))        {
06765                         $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'uid='.intval($uid).$this->enableFields('pages').' AND doktype NOT IN ('.$this->checkPid_badDoktypeList.')');
06766                         if ($GLOBALS['TYPO3_DB']->sql_num_rows($res))   {
06767                                 $this->checkPid_cache[$uid] = 1;
06768                         } else {
06769                                 $this->checkPid_cache[$uid] = 0;
06770                         }
06771                 }
06772                 return $this->checkPid_cache[$uid];
06773         }
06774 
06775 
06776 
06777 
06778 
06779 
06780 
06781 
06782 
06783 
06784 
06785 
06786 
06787 
06788 
06789 
06790 
06791 
06792 
06793 
06794 
06795 
06796 
06797 
06798 
06799 
06800         /***********************************************
06801          *
06802          * Frontend editing functions
06803          *
06804          ***********************************************/
06805 
06818         function editPanel($content, $conf, $currentRecord='', $dataArr=array())        {
06819                 global $TCA,$BE_USER;
06820 
06821                         // If no backend user, return immediately
06822                 if (!$GLOBALS['TSFE']->beUserLogin)     { return $content; }
06823 
06824                         // If a backend user is logged in, then go on...
06825                 if ($conf['newRecordFromTable'])        {
06826                         $currentRecord = $conf['newRecordFromTable'].':NEW';
06827                         $conf['allow']='new';
06828                 }
06829 
06830                 if (!$currentRecord)    $currentRecord=$this->currentRecord;
06831                 if (!count($dataArr))   $dataArr=$this->data;
06832                 list($table,$uid) = explode(':',$currentRecord);
06833                 $mayEdit=0;
06834                 $nPid=intval($conf['newRecordInPid']);  // Page ID for new records, 0 if not specified
06835 
06836                         // If no access right to record languages, return immediately
06837                 if ($table === 'pages') {
06838                         $lang = $GLOBALS['TSFE']->sys_language_uid;
06839                 } elseif ($table === 'tt_content')      {
06840                         $lang = $GLOBALS['TSFE']->sys_language_content;
06841                 } elseif ($TCA[$table]['ctrl']['languageField'])        {
06842                         $lang = $currentRecord[$TCA[$table]['ctrl']['languageField']];
06843                 } else {
06844                         $lang = -1;
06845                 }
06846                 if (!$BE_USER->checkLanguageAccess($lang))      { return $content; }
06847 
06848                 if (!$conf['onlyCurrentPid'] || $dataArr['pid']==$GLOBALS['TSFE']->id)  {
06849                                 // Permissions:
06850                         $types = t3lib_div::trimExplode(',',strtolower($conf['allow']),1);
06851                         $allow = array_flip($types);
06852 
06853                         $perms = $GLOBALS['BE_USER']->calcPerms($GLOBALS['TSFE']->page);
06854                         if ($table=='pages')    {
06855                                 if (count($GLOBALS['TSFE']->config['rootLine'])==1)     {unset($allow['move']); unset($allow['hide']); unset($allow['delete']);}        // rootpage!
06856                                 if (!($perms&2))        {unset($allow['edit']);unset($allow['move']);unset($allow['hide']);}
06857                                 if (!($perms&4))        unset($allow['delete']);
06858                                 if (!($perms&8))        unset($allow['new']);
06859                                 if (count($allow))      $mayEdit=1;             // Can only display editbox if there are options in the menu
06860                                 $newUid = $uid;
06861                         } else {
06862                                 $mayEdit = count($allow)&&($perms&16);
06863                                 if ($conf['newRecordFromTable'])        {
06864                                         $newUid=$GLOBALS['TSFE']->id;
06865                                         if ($nPid) $newUid=$nPid;
06866                                 } else {
06867                                         $newUid = -1*$uid;
06868                                 }
06869                         }
06870                 }
06871 
06872                 if ($GLOBALS['TSFE']->displayEditIcons && $table && $mayEdit)   {
06873                         $GLOBALS['TSFE']->set_no_cache();               // Special content is about to be shown, so the cache must be disabled.
06874                         $formName = 'TSFE_EDIT_FORM_'.substr($GLOBALS['TSFE']->uniqueHash(),0,4);
06875                         $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;">';
06876                         $sortField = $TCA[$table]['ctrl']['sortby'];
06877                         $labelField = $TCA[$table]['ctrl']['label'];
06878                         $hideField = $TCA[$table]['ctrl']['enablecolumns']['disabled'];
06879                         $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 />':'';
06880 
06881                         $theCmd='';
06882                         $TSFE_EDIT = t3lib_div::_POST('TSFE_EDIT');
06883                         if (is_array($TSFE_EDIT) && $TSFE_EDIT['record']==$currentRecord && !$TSFE_EDIT['update_close'])        {
06884                                 $theCmd =$TSFE_EDIT['cmd'];
06885                         }
06886 
06887                         switch($theCmd) {
06888                                 case 'edit':
06889                                 case 'new':
06890                                         $tceforms = t3lib_div::makeInstance('t3lib_TCEforms_FE');
06891                                         $tceforms->prependFormFieldNames = 'TSFE_EDIT[data]';
06892                                         $tceforms->prependFormFieldNames_file = 'TSFE_EDIT_file';
06893                                         $tceforms->doSaveFieldName = 'TSFE_EDIT[doSave]';
06894                                         $tceforms->formName = $formName;
06895                                         $tceforms->backPath = TYPO3_mainDir;
06896                                         $tceforms->setFancyDesign();
06897                                         $tceforms->defStyle = 'font-family:Verdana;font-size:10px;';
06898                                         $tceforms->edit_showFieldHelp = $GLOBALS['BE_USER']->uc['edit_showFieldHelp'];
06899                                         $tceforms->helpTextFontTag='<font face="verdana,sans-serif" color="#333333" size="1">';
06900 
06901                                         $trData = t3lib_div::makeInstance('t3lib_transferData');
06902                                         $trData->addRawData = TRUE;
06903                                         $trData->defVals = t3lib_div::_GP('defVals');           // Added without testing - should provide ability to submit default values in frontend editing, in-page.
06904                                         $trData->fetchRecord($table,    ($theCmd=='new'?$newUid:$dataArr['uid']), ($theCmd=='new'?'new':'') );
06905                                         reset($trData->regTableItems_data);
06906                                         $processedDataArr = current($trData->regTableItems_data);
06907                                         $processedDataArr['uid']=$theCmd=='new'?'NEW':$dataArr['uid'];
06908                                         $processedDataArr['pid']=$theCmd=='new'?$newUid:$dataArr['pid'];
06909 
06910                                         $panel='';
06911                                         $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).'" />';
06912                                         $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).'" />';
06913                                         $buttons.= '<input type="image" border="0" name="TSFE_EDIT[cancel]" onclick="'.
06914                                                 htmlspecialchars('window.location.href=\''.t3lib_div::getIndpEnv('REQUEST_URI').'\';return false;').
06915                                                 '" 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).'" />';
06916                                         $panel.=$tceforms->intoTemplate(array('ITEM'=>$buttons));               // Buttons top
06917                                         $panel.=$tceforms->getMainFields($table,$processedDataArr);
06918 
06919                                         $hiddenF="";
06920                                         if ($theCmd=='new')     {
06921                                                 $hiddenF.='<input type="hidden" name="TSFE_EDIT[data]['.$table.'][NEW][pid]" value="'.$newUid.'" />';
06922                                                 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!
06923                                         } else {
06924                                                 $hiddenF.='<input type="hidden" name="TSFE_EDIT[record]" value="'.$currentRecord.'" />';
06925                                                 $hiddenF.='<input type="hidden" name="TSFE_EDIT[cmd]" value="edit" />';
06926                                         }
06927                                         $hiddenF.='<input type="hidden" name="TSFE_EDIT[doSave]" value="0" />';
06928                                         $panel.=$tceforms->intoTemplate(array('ITEM'=>$buttons.$hiddenF));      // Buttons AND hidden fields bottom.
06929 
06930                                         $panel=$formTag.$tceforms->wrapTotal($panel,$dataArr,$table).'</form>'.($theCmd!='new'?$blackLine:'');
06931                                         $finalOut = $tceforms->printNeededJSFunctions_top().($conf['edit.']['displayRecord']?$content:'').$panel.($theCmd=='new'?$blackLine:'').$tceforms->printNeededJSFunctions();
06932                                 break;
06933                                 default:
06934                                         $panel = '';
06935                                         if (isset($allow['toolbar']))           $panel.=$GLOBALS['BE_USER']->ext_makeToolBar().'<img src="clear.gif" width="2" height="1" alt="" title="" />';
06936                                         if (isset($allow['edit']))              $panel.=$this->editPanelLinkWrap('<img src="'.TYPO3_mainDir.'gfx/edit2.gif" width="11" height="12" hspace="2" border="0" title="'.$BE_USER->extGetLL('p_editRecord').'" align="top" alt="" title="" />',$formName,'edit',$dataArr['_LOCALIZED_UID'] ? $table.':'.$dataArr['_LOCALIZED_UID'] : $currentRecord);
06937                                         if (isset($allow['move']) && $sortField && $BE_USER->workspace===0)     {       // Hiding in workspaces because implementation is incomplete
06938                                                 $panel.=$this->editPanelLinkWrap('<img src="'.TYPO3_mainDir.'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');
06939                                                 $panel.=$this->editPanelLinkWrap('<img src="'.TYPO3_mainDir.'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');
06940                                         }
06941                                         if (isset($allow['hide']) && $hideField && $BE_USER->workspace===0 && !$dataArr['_LOCALIZED_UID'])      {       // Hiding in workspaces because implementation is incomplete, Hiding for localizations because it is unknown what should be the function in that case
06942                                                 if ($dataArr[$hideField])       {
06943                                                         $panel.=$this->editPanelLinkWrap('<img src="'.TYPO3_mainDir.'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');
06944                                                 } else {
06945                                                         $panel.=$this->editPanelLinkWrap('<img src="'.TYPO3_mainDir.'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'));
06946                                                 }
06947                                         }
06948                                         if (isset($allow['new']))       {
06949                                                 if ($table=='pages')    {
06950                                                         $panel.=$this->editPanelLinkWrap('<img src="'.TYPO3_mainDir.'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,'',$nPid);
06951                                                 } else {
06952                                                         $panel.=$this->editPanelLinkWrap('<img src="'.TYPO3_mainDir.'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,'',$nPid);
06953                                                 }
06954                                         }
06955                                         if (isset($allow['delete']) && $BE_USER->workspace===0 && !$dataArr['_LOCALIZED_UID'])          {       // Hiding in workspaces because implementation is incomplete, Hiding for localizations because it is unknown what should be the function in that case
06956                                                 $panel.=$this->editPanelLinkWrap('<img src="'.TYPO3_mainDir.'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'));
06957                                         }
06958 
06959                                                 //      Final
06960                                         $labelTxt = $this->stdWrap($conf['label'],$conf['label.']);
06961                                         $panel='
06962 
06963                                                                 <!-- BE_USER Edit Panel: -->
06964                                                                 '.$formTag.'
06965                                                                         <input type="hidden" name="TSFE_EDIT[cmd]" value="" />
06966                                                                         <input type="hidden" name="TSFE_EDIT[record]" value="'.$currentRecord.'" />
06967                                                                         <table border="0" cellpadding="0" cellspacing="0" border="1" bordercolor="black" class="typo3-editPanel">
06968                                                                                 <tr>
06969                                                                                         <td nowrap="nowrap" bgcolor="#ABBBB4" class="typo3-editPanel-controls">'.$panel.'</td>'.($labelTxt?'
06970                                                                                         <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>':'').'
06971                                                                                 </tr>
06972                                                                         </table>
06973                                                                 </form>';
06974                                                 // wrap the panel
06975                                         if ($conf['innerWrap']) $panel = $this->wrap($panel,$conf['innerWrap']);
06976                                         if ($conf['innerWrap.']) $panel = $this->stdWrap($panel,$conf['innerWrap.']);
06977                                                 // add black line:
06978                                         $panel.=$blackLine;
06979                                                 // wrap the complete panel
06980                                         if ($conf['outerWrap']) $panel = $this->wrap($panel,$conf['outerWrap']);
06981                                         if ($conf['outerWrap.']) $panel = $this->stdWrap($panel,$conf['outerWrap.']);
06982                                         $finalOut = $content.$panel;
06983                                 break;
06984                         }
06985 
06986                         if ($conf['previewBorder']) $finalOut = $this->editPanelPreviewBorder($table,$dataArr,$finalOut,$conf['previewBorder'],$conf['previewBorder.']);
06987                         return $finalOut;
06988                 } else {
06989                         return $content;
06990                 }
06991         }
06992 
07005         function editIcons($content,$params, $conf=array(), $currentRecord='', $dataArr=array(),$addUrlParamStr='')     {
07006                 global $BE_USER;
07007 
07008                         // If no backend user, return immediately
07009                 if (!$GLOBALS['TSFE']->beUserLogin)             {return $content;}
07010 
07011                         // Check incoming params:
07012                 $rParts = explode(':',$currentRecord?$currentRecord:$this->currentRecord);
07013 
07014                 list($table,$fieldList)=t3lib_div::trimExplode(':',$params,1);
07015                 if (!$fieldList)        {
07016                         $fieldList=$table;
07017                         $table=$rParts[0];
07018                 } else {
07019                         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.
07020                 }
07021 
07022                         // Check if allowed to edit content:
07023                 $mayEdit=0;
07024                 $dataArr=count($dataArr)?$dataArr:$this->data;  // If pages-record, should contain correct perms-field, if not, should contain correct pid value.
07025 
07026                 $editUid = $dataArr['_LOCALIZED_UID'] ? $dataArr['_LOCALIZED_UID'] : $rParts[1];
07027 
07028                 if ($table=='pages')    {
07029                         $mayEdit = $BE_USER->isAdmin()||$BE_USER->doesUserHaveAccess($dataArr,2)?1:0;
07030                 } else {
07031                         $mayEdit = $BE_USER->isAdmin()||$BE_USER->doesUserHaveAccess(t3lib_BEfunc::getRecord('pages',$dataArr['pid']),16)?1:0;
07032                 }
07033 
07034                         // Check if allowed to edit language
07035                 if ($mayEdit)   {
07036                         if ($table === 'pages') {
07037                                 $lang = $GLOBALS['TSFE']->sys_language_uid;
07038                         } elseif ($table === 'tt_content')      {
07039                                 $lang = $GLOBALS['TSFE']->sys_language_content;
07040                         } elseif ($TCA[$table]['ctrl']['languageField'])        {
07041                                 $lang = $currentRecord[$TCA[$table]['ctrl']['languageField']];
07042                         } else {
07043                                 $lang = -1;
07044                         }
07045                         if (!$BE_USER->checkLanguageAccess($lang))      { $mayEdit = 0; }
07046                 }
07047 
07048                 if ($GLOBALS['TSFE']->displayFieldEditIcons && $table && $mayEdit && $fieldList)        {
07049                         $GLOBALS['TSFE']->set_no_cache();               // Special content is about to be shown, so the cache must be disabled.
07050                         $style = $conf['styleAttribute'] ? ' style="'.htmlspecialchars($conf['styleAttribute']).'"' : '';
07051                         $iconTitle = $this->stdWrap($conf['iconTitle'],$conf['iconTitle.']);
07052                         $iconImg = $conf['iconImg'] ? $conf['iconImg'] : '<img src="'.TYPO3_mainDir.'gfx/edit_fe.gif" width="11" height="12" border="0" align="top" title="'.t3lib_div::deHSCentities(htmlspecialchars($iconTitle)).'"'.$style.' class="frontEndEditIcons" alt="" />';
07053                         $nV=t3lib_div::_GP('ADMCMD_view')?1:0;
07054                         $adminURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL').TYPO3_mainDir;
07055                         $icon = $this->editPanelLinkWrap_doWrap($iconImg, $adminURL.'alt_doc.php?edit['.$rParts[0].']['.$editUid.']=edit&columnsOnly='.rawurlencode($fieldList).'&noView='.$nV.$addUrlParamStr,implode(':',$rParts));
07056                         if ($conf['beforeLastTag']<0)   {
07057                                 $content=$icon.$content;
07058                         } elseif ($conf['beforeLastTag']>0)     {
07059                                 $cBuf = rtrim($content);
07060                                 $securCount=30;
07061                                 while($securCount && substr($cBuf,-1)=='>' && substr($cBuf,-4)!='</a>') {
07062                                         $cBuf = rtrim(ereg_replace('<[^<]*>$','',$cBuf));
07063                                         $securCount--;
07064                                 }
07065                                 $content = strlen($cBuf)&&$securCount ? substr($content,0,strlen($cBuf)).$icon.substr($content,strlen($cBuf)) : $content=$icon.$content;
07066                         } else {
07067                                 $content.=$icon;
07068                         }
07069                 }
07070                 return $content;
07071         }
07072 
07087         function editPanelLinkWrap($string,$formName,$cmd,$currentRecord='',$confirm='',$nPid='')       {
07088                 $eFONPage = $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_editFormsOnPage'] && $GLOBALS['BE_USER']->workspace===0;  // Editing forms on page only supported in Live workspace (because of incomplete implementation)
07089                 $nV=t3lib_div::_GP('ADMCMD_view')?1:0;
07090                 $adminURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL').TYPO3_mainDir;
07091 
07092                 if ($cmd=='edit' && !$eFONPage) {
07093                         $rParts = explode(':',$currentRecord);
07094                         $out=$this->editPanelLinkWrap_doWrap($string,$adminURL.'alt_doc.php?edit['.$rParts[0].']['.$rParts[1].']=edit&noView='.$nV,$currentRecord);
07095                 } elseif ($cmd=='new' && !$eFONPage)    {
07096                         $rParts = explode(':',$currentRecord);
07097                         if ($rParts[0]=='pages')        {
07098                                 $out=$this->editPanelLinkWrap_doWrap($string,$adminURL.'db_new.php?id='.$rParts[1].'&pagesOnly=1',$currentRecord);
07099                         } else {
07100                                 if (!intval($nPid))     {
07101                                         $nPid = t3lib_div::testInt($rParts[1]) ? -$rParts[1] : $GLOBALS['TSFE']->id;
07102                                 }
07103                                 $out=$this->editPanelLinkWrap_doWrap($string,$adminURL.'alt_doc.php?edit['.$rParts[0].']['.$nPid.']=new&noView='.$nV,$currentRecord);
07104                         }
07105                 } else {
07106                         if ($confirm && $GLOBALS['BE_USER']->jsConfirmation(8)) {
07107                                 $cf1="if (confirm(".t3lib_div::quoteJSvalue($confirm, true).")){";                      // Gets htmlspecialchared later
07108                                 $cf2='}';
07109                         } else {
07110                                 $cf1=$cf2='';
07111                         }
07112                         $out='<a href="#" onclick="'.
07113                                 htmlspecialchars($cf1.'document.'.$formName.'[\'TSFE_EDIT[cmd]\'].value=\''.$cmd.'\'; document.'.$formName.'.submit();'.$cf2.' return false;').
07114                                 '">'.$string.'</a>';
07115                 }
07116                 return $out;
07117         }
07118 
07129         function editPanelLinkWrap_doWrap($string,$url,$currentRecord)  {
07130                 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_editNoPopup'] || $GLOBALS['BE_USER']->extAdminConfig['module.']['edit.']['forceNoPopup']) {
07131                         $retUrl = t3lib_div::getIndpEnv('REQUEST_URI');
07132                         $rParts = explode(':',$currentRecord);
07133                         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.
07134                                 $retUrl.='#'.$rParts[1];
07135                         }
07136                         return '<a href="'.htmlspecialchars($url.'&returnUrl='.rawurlencode($retUrl)).'">'.$string.'</a>';
07137                 } else {
07138                         return '<a href="#" onclick="'.
07139                                 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;').
07140                                 '">'.$string.'</a>';
07141                 }
07142         }
07143 
07157         function editPanelPreviewBorder($table,$row,$content,$thick,$conf=array())      {
07158                 if ($this->isDisabled($table,$row))     {
07159                         $thick = t3lib_div::intInRange($thick,1,100);
07160                         $color = $conf['color'] ? $conf['color'] : '#cccccc';
07161                         if ($conf['innerWrap']) $content = $this->wrap($content,$conf['innerWrap']);
07162                         if ($conf['innerWrap.'])        $content = $this->stdWrap($content,$conf['innerWrap.']);
07163                         $content='<table class="typo3-editPanel-previewBorder" border="'.$thick.'" cellpadding="0" cellspacing="0" bordercolor="'.$color.'" width="100%"><tr><td>'.$content.'</td></tr></table>';
07164                         if ($conf['outerWrap']) $content = $this->wrap($content,$conf['outerWrap']);
07165                         if ($conf['outerWrap.'])        $content = $this->stdWrap($panel,$conf['outerWrap.']);
07166                 }
07167                 return $content;
07168         }
07169 
07179         function isDisabled($table,$row)        {
07180                 global $TCA;
07181                 if (
07182                         ($TCA[$table]['ctrl']['enablecolumns']['disabled'] && $row[$TCA[$table]['ctrl']['enablecolumns']['disabled']]) ||
07183                         ($TCA[$table]['ctrl']['enablecolumns']['fe_group'] && $GLOBALS['TSFE']->simUserGroup && $row[$TCA[$table]['ctrl']['enablecolumns']['fe_group']]==$GLOBALS['TSFE']->simUserGroup) ||
07184                         ($TCA[$table]['ctrl']['enablecolumns']['starttime'] && $row[$TCA[$table]['ctrl']['enablecolumns']['starttime']]>time() ) ||
07185                         ($TCA[$table]['ctrl']['enablecolumns']['endtime'] && $row[$TCA[$table]['ctrl']['enablecolumns']['endtime']] && $row[$TCA[$table]['ctrl']['enablecolumns']['endtime']]<time())
07186                 )       return true;
07187         }
07188 }
07189 
07190 
07191 
07192 
07193 
07194 
07195 
07196 
07197 
07198 
07199 
07200 
07201 
07202 
07210 class tslib_frameset {
07211 
07220         function make($setup)   {
07221                 $content = '';
07222                 if (is_array($setup))   {
07223                         $sKeyArray=t3lib_TStemplate::sortedKeyList($setup);
07224                         reset($sKeyArray);
07225                         while(list(,$theKey)=each($sKeyArray))  {
07226                                 $theValue=$setup[$theKey];
07227                                 if (intval($theKey) && $conf=$setup[$theKey.'.'])       {
07228                                         switch($theValue)       {
07229                                                 case 'FRAME':
07230                                                         $typeNum = intval($GLOBALS['TSFE']->tmpl->setup[$conf['obj'].'.']['typeNum']);
07231                                                         if (!$conf['src'] && !$typeNum)         {
07232                                                                 $typeNum = -1;
07233                                                         }
07234                                                         $content.='<frame'.$this->frameParams($conf,$typeNum).' />'.chr(10);
07235                                                 break;
07236                                                 case 'FRAMESET':
07237                                                         $frameset = t3lib_div::makeInstance('tslib_frameset');
07238                                                         $content.=$frameset->make($conf).chr(10);
07239                                                 break;
07240                                         }
07241                                 }
07242                         }
07243                         return '<frameset'.$this->framesetParams($setup).'>'.chr(10).$content.'</frameset>';
07244                 }
07245         }
07246 
07257         function frameParams($setup, $typeNum)  {
07258                 $paramStr = '';
07259                 $name = $setup['obj'];
07260 
07261                 /*
07262                 if ($GLOBALS['TSFE']->config['config']['simulateStaticDocuments'])      {
07263                         $theCompURL='';
07264                         $theCompURL.=$GLOBALS['TSFE']->makeSimulFileName($GLOBALS['TSFE']->page['title'],
07265                                 ($GLOBALS['TSFE']->page['alias'] ? $GLOBALS['TSFE']->page['alias'] : $GLOBALS['TSFE']->page['uid']),
07266                                 intval($typeNum));
07267                         if ($GLOBALS['TSFE']->config['config']['simulateStaticDocuments']=='PATH_INFO') {
07268                                 $theCompURL = str_replace('.','/',$theCompURL);
07269                                 $theCompURL = 'index.php/'.$theCompURL.'/?';
07270                         } else {
07271                                 $theCompURL.='.html?';
07272                         }
07273                 } else {
07274                         $theCompURL = $GLOBALS['TSFE']->config['mainScript'].'?id='.$GLOBALS['TSFE']->page['uid'].'&type='.intval($typeNum);
07275                 }
07276                         // Add absRefPrefix if exists.
07277                 $finalURL = $GLOBALS['TSFE']->absRefPrefix.$theCompURL.($setup['options']?'&'.$setup['options']:'').$GLOBALS['TSFE']->linkVars.$GLOBALS['TSFE']->getMethodUrlIdToken.($GLOBALS['TSFE']->no_cache?'&no_cache=1':'');
07278                 $finalURL = $GLOBALS['TSFE']->tmpl->removeQueryString($finalURL);
07279                 */
07280 
07281                         // From 3.6.0, use "linkData" for ALL links:
07282                 $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));
07283                 $finalURL = $LD['totalURL'];
07284 
07285 
07286                 if ($setup['src']) {$paramStr.=' src="'.htmlspecialchars($setup['src']).'"';} else {$paramStr.=' src="'.htmlspecialchars($finalURL).'"';}
07287                 if ($setup['name']) {$paramStr.=' name="'.$setup['name'].'"';} else {$paramStr.=' name="'.$name.'"';}
07288                 if ($setup['params']) {$paramStr.=' '.$setup['params'];}
07289                 return $paramStr;
07290         }
07291 
07300         function framesetParams($setup) {
07301                 $paramStr = '';
07302                 if ($setup['cols']) {           $paramStr.=' cols="'.$setup['cols'].'"';        }
07303                 if ($setup['rows']) {           $paramStr.=' rows="'.$setup['rows'].'"';        }
07304                 if ($setup['params']) { $paramStr.=' '.$setup['params'];        }
07305                 return $paramStr;
07306         }
07307 }
07308 
07309 
07310 
07311 
07312 
07313 
07314 
07315 
07316 
07317 
07318 
07319 
07320 
07321 
07322 
07323 
07324 
07333 class tslib_tableOffset {
07334         var $tableParams = 'border="0" cellspacing="0" cellpadding="0"';
07335         var $default_tableParams = 'border="0" cellspacing="0" cellpadding="0"';
07336         var $tdParams = ' width="99%" valign="top"';
07337 
07345         function start($content,$offset)        {
07346                 $valPairs = t3lib_div::intExplode(',',$offset.',,,,,');
07347 
07348                 if ($valPairs[0] || $valPairs[1] || $valPairs[2] || $valPairs[3] || $valPairs[4] || $valPairs[5])       {
07349                                 // If width is defined AND there has been no change to the default table params, then extend them to a tablewidth of 1
07350                         if ($valPairs[4] && $this->default_tableParams==$this->tableParams)     {$this->tableParams.=' width="1"';}
07351                                 // Init:
07352                         $this->begin = chr(10).'<table '.$this->tableParams.'>';
07353                         $this->end = '</table>';
07354                         $rows=array();
07355                         $widthImg = '';
07356                         $heightImg = '';
07357                                 // If width is required, set so bottom column will display for sure
07358                         if ($valPairs[4])       {
07359                                 if (!$valPairs[3])      $valPairs[3]=1;
07360                                 $widthImg='<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$valPairs[4].'" height="1" alt="" title="" />';
07361                         }
07362                                 // If height is required, set so right column will display for sure
07363                         if ($valPairs[5])       {
07364                                 if (!$valPairs[2])      $valPairs[2]=1;
07365                                 $valPairs[2]=1; $heightImg='<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$valPairs[5].'" alt="" title="" />';
07366                         }
07367 
07368                                 // First row:
07369                         if ($valPairs[1])       {       // top
07370                                 $rows[1].= '<tr>';
07371                                 $rows[1].= '<td><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.($valPairs[0]?$valPairs[0]:1).'" height="'.$valPairs[1].'" alt="" title="" /></td>';
07372                                 if ($valPairs[0])       $rows[1].= '<td></td>';
07373                                 if ($valPairs[2])       $rows[1].= '<td></td>';
07374                                 $rows[1].= '</tr>';
07375                         }
07376                                 // Middle row:
07377                         $rows[2].= '<tr>';
07378                         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>';}
07379                         $rows[2].= '<td'.$this->tdParams.'>'.$content.'</td>';
07380                         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>';}
07381                         $rows[2].= '</tr>';
07382                                 // Bottom row:
07383                         if ($valPairs[3])       {       // bottom
07384                                 $rows[3].= '<tr>';
07385                                 if ($valPairs[0])       $rows[3].= '<td></td>';
07386                                 if ($valPairs[2])       $rows[3].= '<td>'.$widthImg.'</td>';
07387                                 $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>';
07388                                 $rows[3].= '</tr>';
07389                         }
07390                         return $this->begin.implode('',$rows).$this->end;
07391                 } else return $content;
07392         }
07393 }
07394 
07395 
07396 
07397 
07398 
07399 
07400 
07401 
07402 
07403 
07404 
07405 
07406 
07407 
07408 
07409 
07410 
07411 
07412 
07413 
07414 
07423 class tslib_controlTable        {
07424         var $offX = 0;          // offset, x
07425         var $offY = 0;          // offset, y
07426 
07427         var $tm = '';           // top menu
07428         var $lm = '';           // left menu
07429         var $rm = '';           // right menu
07430         var $bm = '';           // bottom menu
07431         var $content = '';      // content
07432 
07433         var $tmTDparams = 'valign="top"';               // top menu TDparams
07434         var $lmTDparams = 'valign="top"';               // left menu TDparams
07435         var $rmTDparams = 'valign="top"';               // right menu TDparams
07436         var $bmTDparams = 'valign="top"';               // bottom menu TDparams
07437         var $contentTDparams = 'valign="top"';  // content TDparams
07438 
07439         var $cMl = 1;           // content margin, left
07440         var $cMr = 1;           // content margin, right
07441         var $cMt = 0;           // content margin, top
07442         var $cMb = 1;           // content margin, bottom
07443 
07444         var $contentW = 0;      // Places a little gif-spacer in the bottom of the content frame
07445 
07446         var $tableParams = 'border="0" cellspacing="0" cellpadding="0"';
07447 
07458         function start($offset,$cMargins)       {
07459                 $offArr = t3lib_div::intExplode(',',$offset);
07460                 $cMargArr = t3lib_div::intExplode(',',$cMargins);
07461 
07462                 $cols = 0;
07463                 $rows = 0;
07464 
07465                 if ($this->lm) $cols++;
07466                 if ($this->rm) $cols++;
07467                 if ($cMargArr[0]) $cols++;
07468                 if ($cMargArr[2]) $cols++;
07469                 if ($cMargArr[1]||$cMargArr[3]||$this->tm||$this->bm||$this->content||$this->contentW) $cols++;
07470 
07471                 if ($cMargArr[1]) $rows++;
07472                 if ($cMargArr[3]) $rows++;
07473                 if ($this->tm) $rows++;
07474                 if ($this->bm) $rows++;
07475                 if ($this->content) $rows++;
07476                 if ($this->contentW) $rows++;
07477                 if (!$rows && $cols) $rows=1;           // If there are no rows in the middle but still som columns...
07478 
07479                 if ($rows&&$cols)       {
07480                         $res = chr(10).'<table '.$this->tableParams.'>';
07481                                 // top offset:
07482                         if ($offArr[1]) {
07483                                 $xoff = $offArr[0] ? 1 : 0;
07484                                 if ($cols+$xoff > 1)    {$colspan =' colspan="'.($cols+$xoff).'"';}
07485                                 $res.= '<tr><td'.$colspan.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$offArr[1].'" alt="" title="" /></td></tr>';
07486                         }
07487                                 // The rows:
07488                         if ($rows>1)    {$rowspan =' rowspan="'.($rows).'"';}
07489                         $res.= '<tr>';
07490                         if ($offArr[0]) {       $res.='<td'.$rowspan.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" height="1" width="'.$offArr[0].'" alt="" title="" /></td>';       }
07491                         if ($this->lm)  {       $res.='<td'.$rowspan.' '.$this->lmTDparams.'>'.$this->lm.'</td>';               }
07492                         if ($cMargArr[0])       {       $res.='<td'.$rowspan.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" height="1" width="'.$cMargArr[0].'" alt="" title="" /></td>';             }
07493                                 // content...
07494 
07495                         $middle=Array();
07496                         if ($this->tm)  {       $middle[]='<td '.$this->tmTDparams.'>'.$this->tm.'</td>';}
07497                         if ($cMargArr[1])       {       $middle[]='<td><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$cMargArr[1].'" alt="" title="" /></td>';}
07498                         if ($this->content)     {       $middle[]='<td '.$this->contentTDparams.'>'.$this->content.'</td>';}
07499                         if ($cMargArr[3])       {       $middle[]='<td><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$cMargArr[3].'" alt="" title="" /></td>';}
07500                         if ($this->bm)  {       $middle[]='<td '.$this->bmTDparams.'>'.$this->bm.'</td>';}
07501                         if ($this->contentW)    {       $middle[]='<td><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" height="1" width="'.$this->contentW.'" alt="" title="" /></td>';}
07502                         if (isset($middle[0]))  {$res.=$middle[0];}
07503 
07504                                 // Left of content
07505                         if ($cMargArr[2])       {       $res.='<td'.$rowspan.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" height="1" width="'.$cMargArr[2].'" alt="" title="" /></td>';             }
07506                         if ($this->rm)  {       $res.='<td'.$rowspan.' '.$this->rmTDparams.'>'.$this->rm.'</td>';               }
07507                         $res.= '</tr>';
07508 
07509                                 // More than the two rows
07510                         $mCount = count($middle);
07511                         for($a=1;$a<$mCount;$a++)       {
07512                                 $res.='<tr>'.$middle[$a].'</tr>';
07513                         }
07514                         $res.='</table>';
07515                         return $res;
07516                 }
07517         }
07518 }
07519 
07520 
07521 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_content.php'])   {
07522         include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_content.php']);
07523 }
07524 ?>


Généré par Les spécialistes TYPO3 avec  doxygen 1.4.6