Documentation TYPO3 par Ameos |
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com) 00006 * All rights reserved 00007 * 00008 * This script is part of the TYPO3 project. The TYPO3 project is 00009 * free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. 00013 * 00014 * The GNU General Public License can be found at 00015 * http://www.gnu.org/copyleft/gpl.html. 00016 * A copy is found in the textfile GPL.txt and important notices to the license 00017 * from the author is found in LICENSE.txt distributed with these scripts. 00018 * 00019 * 00020 * This script is distributed in the hope that it will be useful, 00021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00023 * GNU General Public License for more details. 00024 * 00025 * This copyright notice MUST APPEAR in all copies of the script! 00026 ***************************************************************/ 00212 // Includes this class since it is used for parsing HTML 00213 require_once(PATH_t3lib."class.t3lib_parsehtml.php"); 00214 00215 // Object TypoScript library included: 00216 if(t3lib_extMgm::isLoaded('obts')) { 00217 require_once(t3lib_extMgm::extPath('obts').'_tsobject/_tso.php'); 00218 } 00219 00220 00221 00222 00223 00224 00225 00226 00227 00228 00229 00230 00231 00232 00233 00234 00235 00250 class tslib_cObj { 00251 var $align = Array ('center', 'right', 'left'); 00252 00263 var $image_compression = Array( 00264 10 => Array('params'=>'', 'ext'=>'gif'), 00265 11 => Array('params'=>'-colors 128', 'ext'=>'gif'), 00266 12 => Array('params'=>'-colors 64', 'ext'=>'gif'), 00267 13 => Array('params'=>'-colors 32', 'ext'=>'gif'), 00268 14 => Array('params'=>'-colors 16', 'ext'=>'gif'), 00269 15 => Array('params'=>'-colors 8', 'ext'=>'gif'), 00270 00271 30 => Array('params'=>'-colors 256', 'ext'=>'png'), 00272 31 => Array('params'=>'-colors 128', 'ext'=>'png'), 00273 32 => Array('params'=>'-colors 64', 'ext'=>'png'), 00274 33 => Array('params'=>'-colors 32', 'ext'=>'png'), 00275 34 => Array('params'=>'-colors 16', 'ext'=>'png'), 00276 35 => Array('params'=>'-colors 8', 'ext'=>'png'), 00277 39 => Array('params'=>'', 'ext'=>'png'), 00278 00279 20 => Array('params'=>'-quality 100', 'ext'=>'jpg'), 00280 21 => Array('params'=>'-quality 90', 'ext'=>'jpg'), 00281 22 => Array('params'=>'-quality 80', 'ext'=>'jpg'), 00282 23 => Array('params'=>'-quality 70', 'ext'=>'jpg'), 00283 24 => Array('params'=>'-quality 60', 'ext'=>'jpg'), 00284 25 => Array('params'=>'-quality 50', 'ext'=>'jpg'), 00285 26 => Array('params'=>'-quality 40', 'ext'=>'jpg'), 00286 27 => Array('params'=>'-quality 30', 'ext'=>'jpg'), 00287 28 => Array('params'=>'-quality 20', 'ext'=>'jpg') 00288 ); 00289 00295 var $image_effects = Array( 00296 1 => '-rotate 90', 00297 2 => '-rotate 270', 00298 3 => '-rotate 180', 00299 10 => '-colorspace GRAY', 00300 11 => '-sharpen 70', 00301 20 => '-normalize', 00302 23 => '-contrast', 00303 25 => '-gamma 1.3', 00304 26 => '-gamma 0.8' 00305 ); 00306 00314 var $data = Array(); 00315 var $oldData = Array(); // Used for backup... 00316 var $alternativeData =''; // If this is set with an array before stdWrap, it's used instead of $this->data in the data-property in stdWrap 00317 var $parameters = Array(); // Used by the parseFunc function and is loaded with tag-parameters when parsing tags. 00318 var $currentValKey = 'currentValue_kidjls9dksoje'; 00319 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. 00320 var $currentRecordTotal = 0; // Set in cObj->RECORDS and cObj->CONTENT to the current number of records selected in a query. 00321 var $currentRecordNumber = 0; // Incremented in cObj->RECORDS and cObj->CONTENT before each record rendering. 00322 var $parentRecordNumber = 0; // Incremented in parent cObj->RECORDS and cObj->CONTENT before each record rendering. 00323 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. 00324 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. 00325 00326 // internal 00327 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) 00328 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. 00329 var $checkPid_badDoktypeList = '255'; 00330 var $lastTypoLinkUrl=''; // This will be set by typoLink() to the url of the most recent link created. 00331 var $lastTypoLinkTarget=''; // DO. link target. 00332 var $substMarkerCache=array(); // Caching substituteMarkerArrayCached function 00333 var $recordRegister=array(); // Array that registers rendered content elements (or any table) to make sure they are not rendered recursively! 00334 00344 function start($data,$table='') { 00345 $this->data = $data; 00346 $this->currentRecord = $table ? $table.':'.$this->data['uid'] : ''; 00347 $this->parameters = Array(); 00348 } 00349 00359 function setParent($data,$currentRecord) { 00360 $this->parentRecord=array('data'=>$data, 'currentRecord'=>$currentRecord); 00361 } 00362 00363 00364 00365 00366 00367 00368 00369 00370 /*********************************************** 00371 * 00372 * CONTENT_OBJ: 00373 * 00374 ***********************************************/ 00375 00384 function getCurrentVal() { 00385 return $this->data[$this->currentValKey]; 00386 } 00387 00395 function setCurrentVal($value) { 00396 $this->data[$this->currentValKey] = $value; 00397 } 00398 00408 function cObjGet($setup,$addKey='') { 00409 if (is_array($setup)) { 00410 $sKeyArray=t3lib_TStemplate::sortedKeyList($setup); 00411 $content =''; 00412 foreach($sKeyArray as $theKey) { 00413 $theValue=$setup[$theKey]; 00414 if (intval($theKey) && !strstr($theKey,'.')) { 00415 $conf=$setup[$theKey.'.']; 00416 $content.=$this->cObjGetSingle($theValue,$conf,$addKey.$theKey); // Get the contentObject 00417 } 00418 } 00419 return $content; 00420 } 00421 } 00422 00432 function cObjGetSingle($name,$conf,$TSkey='__') { 00433 $content=''; 00434 // Checking that the function is not called eternally. This is done by interrupting at a depth of 100 00435 $GLOBALS['TSFE']->cObjectDepthCounter--; 00436 if ($GLOBALS['TSFE']->cObjectDepthCounter>0) { 00437 $name = trim($name); 00438 if ($GLOBALS['TT']->LR) $GLOBALS['TT']->push($TSkey, $name); 00439 00440 // Checking if the COBJ is a reference to another object. (eg. name of 'blabla.blabla = < styles.something') 00441 if (substr($name,0,1)=='<') { 00442 $key = trim(substr($name,1)); 00443 $cF = t3lib_div::makeInstance('t3lib_TSparser'); 00444 // $name and $conf is loaded with the referenced values. 00445 $old_conf=$conf; 00446 list($name, $conf) = $cF->getVal($key,$GLOBALS['TSFE']->tmpl->setup); 00447 if (is_array($old_conf) && count($old_conf)) { 00448 $conf = $this->joinTSarrays($conf,$old_conf); 00449 // debug($conf); 00450 } 00451 // Getting the cObject 00452 $GLOBALS['TT']->incStackPointer(); 00453 $content.=$this->cObjGetSingle($name,$conf,$key); 00454 $GLOBALS['TT']->decStackPointer(); 00455 } else { 00456 00457 // Object TypoScript hook: 00458 if(t3lib_extMgm::isLoaded('obts') && isset($GLOBALS['OBTS']['tso_list'][$name])) { 00459 $content.= obts_dtutil::renderDatatypeContent($name, $GLOBALS['OBTS']['tso_list'][$name], $conf, $this); 00460 } else { 00461 // Traditional Content Object branching: 00462 switch($name) { 00463 case 'COBJ_ARRAY': 00464 case 'COA': 00465 $content.=$this->COBJ_ARRAY($conf); 00466 break; 00467 case 'COA_INT': 00468 $content.=$this->COBJ_ARRAY($conf,'INT'); 00469 break; 00470 case 'HTML': 00471 $content.=$this->HTML($conf); 00472 break; 00473 case 'TEXT': 00474 $content.=$this->TEXT($conf); 00475 break; 00476 case 'CLEARGIF': 00477 $content.=$this->CLEARGIF($conf); 00478 break; 00479 case 'FILE': 00480 $content.=$this->FILE($conf); 00481 break; 00482 case 'IMAGE': 00483 $content.=$this->IMAGE($conf); 00484 break; 00485 case 'IMG_RESOURCE': 00486 $content.=$this->IMG_RESOURCE($conf); 00487 break; 00488 case 'IMGTEXT': 00489 $content.=$this->IMGTEXT($conf); 00490 break; 00491 case 'CONTENT': 00492 $content.=$this->CONTENT($conf); 00493 break; 00494 case 'RECORDS': 00495 $content.=$this->RECORDS($conf); 00496 break; 00497 case 'HMENU': 00498 $content.=$this->HMENU($conf); 00499 break; 00500 case 'CTABLE': 00501 $content.=$this->CTABLE($conf); 00502 break; 00503 case 'OTABLE': 00504 $content.=$this->OTABLE($conf); 00505 break; 00506 case 'COLUMNS': 00507 $content.=$this->COLUMNS($conf); 00508 break; 00509 case 'HRULER': 00510 $content.=$this->HRULER($conf); 00511 break; 00512 case 'CASE': 00513 $content.=$this->CASEFUNC($conf); 00514 break; 00515 case 'LOAD_REGISTER': 00516 case 'RESTORE_REGISTER': 00517 $this->LOAD_REGISTER($conf,$name); 00518 break; 00519 case 'FORM': 00520 $content.=$this->FORM($conf); 00521 break; 00522 case 'SEARCHRESULT': 00523 $content.=$this->SEARCHRESULT($conf); 00524 break; 00525 case 'PHP_SCRIPT': 00526 $content.=$this->PHP_SCRIPT($conf); 00527 break; 00528 case 'PHP_SCRIPT_EXT': 00529 $content.=$this->PHP_SCRIPT($conf,'EXT'); 00530 break; 00531 case 'PHP_SCRIPT_INT': 00532 $content.=$this->PHP_SCRIPT($conf,'INT'); 00533 break; 00534 case 'USER': 00535 $content.=$this->USER($conf); 00536 break; 00537 case 'USER_INT': 00538 $content.=$this->USER($conf,'INT'); 00539 break; 00540 case 'TEMPLATE': 00541 $content.=$this->TEMPLATE($conf); 00542 break; 00543 case 'EDITPANEL': 00544 if ($GLOBALS['TSFE']->beUserLogin) {$content.=$this->editPanel($content, $conf);} 00545 break; 00546 case 'MULTIMEDIA': 00547 $content.=$this->MULTIMEDIA($conf); 00548 break; 00549 } 00550 } 00551 } 00552 if ($GLOBALS['TT']->LR) $GLOBALS['TT']->pull($content); 00553 } 00554 // Increasing on exit... 00555 $GLOBALS['TSFE']->cObjectDepthCounter++; 00556 return $content; 00557 } 00558 00559 00560 00561 00562 00563 00564 00565 /******************************************** 00566 * 00567 * Functions rendering content objects (cObjects) 00568 * 00569 ********************************************/ 00570 00578 function HTML($conf) { 00579 return $this->stdWrap($conf['value'],$conf['value.']); 00580 } 00581 00589 function TEXT($conf) { 00590 return $this->stdWrap($conf['value'],$conf); 00591 } 00592 00600 function CLEARGIF($conf) { 00601 $w = $this->stdWrap($conf['width'],$conf['width.']); 00602 $h = $this->stdWrap($conf['height'],$conf['height.']); 00603 $w = $w ? $w : 1; 00604 $h = $h ? $h : 1; 00605 $wrap = $conf['wrap'] ? $conf['wrap'] : '|<br />'; 00606 $theValue = $this->wrap('<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$w.'" height="'.$h.'"'.$this->getBorderAttr(' border="0"').' alt="" title="" />', $wrap); 00607 00608 return $this->stdWrap($theValue,$conf['stdWrap.']); 00609 } 00610 00619 function COBJ_ARRAY($conf,$ext='') { 00620 $content=''; 00621 switch($ext) { 00622 case 'INT': 00623 $substKey = $ext.'_SCRIPT.'.$GLOBALS['TSFE']->uniqueHash(); 00624 $content.='<!--'.$substKey.'-->'; 00625 $GLOBALS['TSFE']->config[$ext.'incScript'][$substKey] = array( 00626 'file'=>$incFile, 00627 'conf'=>$conf, 00628 'cObj'=>serialize($this), 00629 'type'=>'COA' 00630 ); 00631 break; 00632 default: 00633 if ($this->checkIf($conf['if.'])) { 00634 $content=$this->cObjGet($conf); 00635 if ($conf['wrap']) { 00636 $content=$this->wrap($content, $conf['wrap']); 00637 } 00638 if ($conf['stdWrap.']) { 00639 $content=$this->stdWrap($content, $conf['stdWrap.']); 00640 } 00641 } 00642 break; 00643 } 00644 return $content; 00645 } 00646 00655 function USER($conf,$ext='') { 00656 $content=''; 00657 switch($ext) { 00658 case 'INT': 00659 $substKey = $ext.'_SCRIPT.'.$GLOBALS['TSFE']->uniqueHash(); 00660 $content.='<!--'.$substKey.'-->'; 00661 $GLOBALS['TSFE']->config[$ext.'incScript'][$substKey] = array( 00662 'file' => $incFile, 00663 'conf' => $conf, 00664 'cObj' => serialize($this), 00665 'type' => 'FUNC' 00666 ); 00667 break; 00668 default: 00669 $content.=$this->callUserFunction($conf['userFunc'],$conf,''); 00670 break; 00671 } 00672 return $content; 00673 } 00674 00682 function FILE($conf) { 00683 $theValue = $this->fileResource($this->stdWrap($conf['file'],$conf['file.']), trim($this->getAltParam($conf))); 00684 if ($conf['linkWrap']) { 00685 $theValue = $this->linkWrap($theValue,$conf['linkWrap']); 00686 } 00687 return $this->wrap($theValue,$conf['wrap']); 00688 } 00689 00698 function IMAGE($conf) { 00699 $content=''; 00700 if ($this->checkIf($conf['if.'])) { 00701 $theValue = $this->cImage($conf['file'],$conf); 00702 if ($conf['stdWrap.']) { 00703 $theValue = $this->stdWrap($theValue,$conf['stdWrap.']); 00704 } 00705 return $theValue; 00706 } 00707 } 00708 00717 function IMG_RESOURCE($conf) { 00718 $imgArray = $this->getImgResource($conf['file'],$conf['file.']); 00719 return $this->stdWrap($imgArray[3],$conf['stdWrap.']); 00720 } 00721 00729 function IMGTEXT($conf) { 00730 $content=''; 00731 if (is_array($conf['text.'])) { 00732 $content.= $this->stdWrap($this->cObjGet($conf['text.'],'text.'),$conf['text.']); // this gets the surrounding content 00733 } 00734 $imgList=trim($this->stdWrap($conf['imgList'],$conf['imgList.'])); // gets images 00735 if ($imgList) { 00736 $imgs = t3lib_div::trimExplode(',',$imgList); 00737 $imgStart = intval($this->stdWrap($conf['imgStart'],$conf['imgStart.'])); 00738 00739 $imgCount= count($imgs)-$imgStart; 00740 00741 $imgMax = intval($this->stdWrap($conf['imgMax'],$conf['imgMax.'])); 00742 if ($imgMax) { 00743 $imgCount = t3lib_div::intInRange($imgCount,0,$conf['imgMax']); // reduces the number of images. 00744 } 00745 00746 $imgPath = $this->stdWrap($conf['imgPath'],$conf['imgPath.']); 00747 00748 // initialisation 00749 $caption=''; 00750 if (is_array($conf['caption.'])) { 00751 $caption= $this->stdWrap($this->cObjGet($conf['caption.'], 'caption.'),$conf['caption.']); 00752 } 00753 $captionArray=array(); 00754 if ($conf['captionSplit']) { 00755 $capSplit = $this->stdWrap($conf['captionSplit.']['token'],$conf['captionSplit.']['token.']); 00756 if (!$capSplit) {$capSplit=chr(10);} 00757 $caption2= $this->cObjGetSingle($conf['captionSplit.']['cObject'],$conf['captionSplit.']['cObject.'],'captionSplit.cObject'); 00758 $captionArray=explode($capSplit,$caption2); 00759 while(list($ca_key,$ca_val)=each($captionArray)) { 00760 $captionArray[$ca_key] = $this->stdWrap(trim($captionArray[$ca_key]), $conf['captionSplit.']['stdWrap.']); 00761 } 00762 } 00763 00764 $tablecode=''; 00765 $position=$this->stdWrap($conf['textPos'],$conf['textPos.']); 00766 00767 $tmppos = $position&7; 00768 $contentPosition = $position&24; 00769 $align = $this->align[$tmppos]; 00770 $cap = ($caption)?1:0; 00771 $txtMarg = intval($this->stdWrap($conf['textMargin'],$conf['textMargin.'])); 00772 if (!$conf['textMargin_outOfText'] && $contentPosition<16) { 00773 $txtMarg=0; 00774 } 00775 00776 $cols = intval($this->stdWrap($conf['cols'],$conf['cols.'])); 00777 $rows = intval($this->stdWrap($conf['rows'],$conf['rows.'])); 00778 $colspacing = intval($this->stdWrap($conf['colSpace'],$conf['colSpace.'])); 00779 $rowspacing = intval($this->stdWrap($conf['rowSpace'],$conf['rowSpace.'])); 00780 00781 $border = intval($this->stdWrap($conf['border'],$conf['border.'])) ? 1:0; 00782 $borderColor = $this->stdWrap($conf['borderCol'],$conf['borderCol.']); 00783 $borderThickness = intval($this->stdWrap($conf['borderThick'],$conf['borderThick.'])); 00784 00785 $borderColor=$borderColor?$borderColor:'black'; 00786 $borderThickness=$borderThickness?$borderThickness:1; 00787 00788 $caption_align = $this->stdWrap($conf['captionAlign'],$conf['captionAlign.']); 00789 if (!$caption_align) { 00790 $caption_align = $align; 00791 } 00792 // generate cols 00793 $colCount = ($cols > 1) ? $cols : 1; 00794 if ($colCount > $imgCount) {$colCount = $imgCount;} 00795 $rowCount = ($colCount > 1) ? ceil($imgCount / $colCount) : $imgCount; 00796 // generate rows 00797 if ($rows>1) { 00798 $rowCount = $rows; 00799 if ($rowCount > $imgCount) {$rowCount = $imgCount;} 00800 $colCount = ($rowCount>1) ? ceil($imgCount / $rowCount) : $imgCount; 00801 } 00802 00803 // max Width 00804 $colRelations = trim($this->stdWrap($conf['colRelations'],$conf['colRelations.'])); 00805 $maxW = intval($this->stdWrap($conf['maxW'],$conf['maxW.'])); 00806 00807 $maxWInText = intval($this->stdWrap($conf['maxWInText'],$conf['maxWInText.'])); 00808 if (!$maxWInText) { // If maxWInText is not set, it's calculated to the 70 % of the max... 00809 $maxWInText = round($maxW/100*50); 00810 } 00811 00812 if ($maxWInText && $contentPosition>=16) { // inText 00813 $maxW = $maxWInText; 00814 } 00815 00816 if ($maxW && $colCount > 0) { // If there is a max width and if colCount is greater than column 00817 /* debug($border*$borderThickness*2); 00818 debug($maxW); 00819 debug($colspacing); 00820 debug(($maxW-$colspacing*($colCount-1)-$colCount*$border*$borderThickness*2)); 00821 */ 00822 $maxW = ceil(($maxW-$colspacing*($colCount-1)-$colCount*$border*$borderThickness*2)/$colCount); 00823 } 00824 // create the relation between rows 00825 $colMaxW = Array(); 00826 if ($colRelations) { 00827 $rel_parts = explode(':',$colRelations); 00828 $rel_total = 0; 00829 for ($a=0;$a<$colCount;$a++) { 00830 $rel_parts[$a] = intval($rel_parts[$a]); 00831 $rel_total+= $rel_parts[$a]; 00832 } 00833 if ($rel_total) { 00834 for ($a=0;$a<$colCount;$a++) { 00835 $colMaxW[$a] = round(($maxW*$colCount)/$rel_total*$rel_parts[$a]); 00836 } 00837 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. 00838 $colMaxW = Array(); 00839 } 00840 } 00841 } 00842 $image_compression = intval($this->stdWrap($conf['image_compression'],$conf['image_compression.'])); 00843 $image_effects = intval($this->stdWrap($conf['image_effects'],$conf['image_effects.'])); 00844 $image_frames = intval($this->stdWrap($conf['image_frames.']['key'],$conf['image_frames.']['key.'])); 00845 00846 // fetches pictures 00847 $splitArr=array(); 00848 $splitArr['imgObjNum']=$conf['imgObjNum']; 00849 $splitArr = $GLOBALS['TSFE']->tmpl->splitConfArray($splitArr,$imgCount); 00850 00851 // EqualHeight 00852 $equalHeight = intval($this->stdWrap($conf['equalH'],$conf['equalH.'])); 00853 if ($equalHeight) { // Initiate gifbuilder object in order to get dimensions AND calculate the imageWidth's 00854 $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder'); 00855 $gifCreator->init(); 00856 $relations = Array(); 00857 $relations_cols = Array(); 00858 $totalMaxW = $maxW*$colCount; 00859 for($a=0;$a<$imgCount;$a++) { 00860 $imgKey = $a+$imgStart; 00861 $imgInfo = $gifCreator->getImageDimensions($imgPath.$imgs[$imgKey]); 00862 $relations[$a] = $imgInfo[1] / $equalHeight; // relationship between the original height and the wished height 00863 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. 00864 $relations_cols[floor($a/$colCount)] += $imgInfo[0]/$relations[$a]; // counts the total width of the row with the new height taken into consideration. 00865 } 00866 } 00867 } 00868 00869 $imageRowsFinalWidths = Array(); // contains the width of every image row 00870 $imageRowsMaxHeights = Array(); 00871 $imgsTag=array(); 00872 $origImages=array(); 00873 for($a=0;$a<$imgCount;$a++) { 00874 $GLOBALS['TSFE']->register['IMAGE_NUM'] = $a; 00875 00876 $imgKey = $a+$imgStart; 00877 $totalImagePath = $imgPath.$imgs[$imgKey]; 00878 $this->data[$this->currentValKey] = $totalImagePath; 00879 $imgObjNum = intval($splitArr[$a]['imgObjNum']); 00880 $imgConf = $conf[$imgObjNum.'.']; 00881 00882 if ($equalHeight) { 00883 $scale = 1; 00884 if ($totalMaxW) { 00885 $rowTotalMaxW = $relations_cols[floor($a/$colCount)]; 00886 if ($rowTotalMaxW > $totalMaxW) { 00887 $scale = $rowTotalMaxW / $totalMaxW; 00888 } 00889 } 00890 // transfer info to the imageObject. Please note, that 00891 $imgConf['file.']['height'] = round($equalHeight/$scale); 00892 00893 unset($imgConf['file.']['width']); 00894 unset($imgConf['file.']['maxW']); 00895 unset($imgConf['file.']['maxH']); 00896 unset($imgConf['file.']['minW']); 00897 unset($imgConf['file.']['minH']); 00898 unset($imgConf['file.']['width.']); 00899 unset($imgConf['file.']['maxW.']); 00900 unset($imgConf['file.']['maxH.']); 00901 unset($imgConf['file.']['minW.']); 00902 unset($imgConf['file.']['minH.']); 00903 $maxW = 0; // setting this to zero, so that it doesn't disturb 00904 } 00905 00906 if ($maxW) { 00907 if (count($colMaxW)) { 00908 $imgConf['file.']['maxW'] = $colMaxW[($a%$colCount)]; 00909 } else { 00910 $imgConf['file.']['maxW'] = $maxW; 00911 } 00912 } 00913 00914 // Image Object supplied: 00915 if (is_array($imgConf)) { 00916 if ($this->image_effects[$image_effects]) { 00917 $imgConf['file.']['params'].= ' '.$this->image_effects[$image_effects]; 00918 } 00919 if ($image_frames) { 00920 if (is_array($conf['image_frames.'][$image_frames.'.'])) { 00921 $imgConf['file.']['m.'] = $conf['image_frames.'][$image_frames.'.']; 00922 } 00923 } 00924 if ($image_compression && $imgConf['file']!='GIFBUILDER') { 00925 if ($image_compression==1) { 00926 $tempImport = $imgConf['file.']['import']; 00927 $tempImport_dot = $imgConf['file.']['import.']; 00928 unset($imgConf['file.']); 00929 $imgConf['file.']['import'] = $tempImport; 00930 $imgConf['file.']['import.'] = $tempImport_dot; 00931 } elseif (isset($this->image_compression[$image_compression])) { 00932 $imgConf['file.']['params'].= ' '.$this->image_compression[$image_compression]['params']; 00933 $imgConf['file.']['ext'] = $this->image_compression[$image_compression]['ext']; 00934 unset($imgConf['file.']['ext.']); 00935 } 00936 } 00937 00938 // "alt", "title" and "longdesc" attributes: 00939 if (!strlen($imgConf['altText']) && !is_array($imgConf['altText.'])) { 00940 $imgConf['altText'] = $conf['altText']; 00941 $imgConf['altText.'] = $conf['altText.']; 00942 } 00943 if (!strlen($imgConf['titleText']) && !is_array($imgConf['titleText.'])) { 00944 $imgConf['titleText'] = $conf['titleText']; 00945 $imgConf['titleText.'] = $conf['titleText.']; 00946 } 00947 if (!strlen($imgConf['longdescURL']) && !is_array($imgConf['longdescURL.'])) { 00948 $imgConf['longdescURL'] = $conf['longdescURL']; 00949 $imgConf['longdescURL.'] = $conf['longdescURL.']; 00950 } 00951 } else { 00952 $imgConf = array( 00953 'altText' => $conf['altText'], 00954 'titleText' => $conf['titleText'], 00955 'longdescURL' => $conf['longdescURL'], 00956 'file' => $totalImagePath 00957 ); 00958 } 00959 00960 $imgsTag[$imgKey] = $this->IMAGE($imgConf); 00961 00962 // Store the original filepath 00963 $origImages[$imgKey]=$GLOBALS['TSFE']->lastImageInfo; 00964 00965 $imageRowsFinalWidths[floor($a/$colCount)] += $GLOBALS['TSFE']->lastImageInfo[0]; 00966 if ($GLOBALS['TSFE']->lastImageInfo[1]>$imageRowsMaxHeights[floor($a/$colCount)]) { 00967 $imageRowsMaxHeights[floor($a/$colCount)] = $GLOBALS['TSFE']->lastImageInfo[1]; 00968 } 00969 } 00970 // calculating the tableWidth: 00971 // TableWidth problems: It creates problems if the pictures are NOT as wide as the tableWidth. 00972 $tableWidth = max($imageRowsFinalWidths)+ $colspacing*($colCount-1) + $colCount*$border*$borderThickness*2; 00973 00974 // make table for pictures 00975 $index=$imgStart; 00976 00977 $noRows = $this->stdWrap($conf['noRows'],$conf['noRows.']); 00978 $noCols = $this->stdWrap($conf['noCols'],$conf['noCols.']); 00979 if ($noRows) {$noCols=0;} // noRows overrides noCols. They cannot exist at the same time. 00980 if ($equalHeight) { 00981 $noCols=1; 00982 $noRows=0; 00983 } 00984 00985 $rowCount_temp=1; 00986 $colCount_temp=$colCount; 00987 if ($noRows) { 00988 $rowCount_temp = $rowCount; 00989 $rowCount=1; 00990 } 00991 if ($noCols) { 00992 $colCount=1; 00993 } 00994 // col- and rowspans calculated 00995 $colspan = (($colspacing) ? $colCount*2-1 : $colCount); 00996 $rowspan = (($rowspacing) ? $rowCount*2-1 : $rowCount) + $cap; 00997 00998 00999 // Edit icons: 01000 $editIconsHTML = $conf['editIcons']&&$GLOBALS['TSFE']->beUserLogin ? $this->editIcons('',$conf['editIcons'],$conf['editIcons.']) : ''; 01001 01002 // strech out table: 01003 $tablecode=''; 01004 $flag=0; 01005 if ($conf['noStretchAndMarginCells']!=1) { 01006 $tablecode.='<tr>'; 01007 if ($txtMarg && $align=='right') { // If right aligned, the textborder is added on the right side 01008 $tablecode.='<td rowspan="'.($rowspan+1).'" valign="top"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$txtMarg.'" height="1" alt="" title="" />'.($editIconsHTML?'<br />'.$editIconsHTML:'').'</td>'; 01009 $editIconsHTML=''; 01010 $flag=1; 01011 } 01012 $tablecode.='<td colspan="'.$colspan.'"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$tableWidth.'" height="1" alt="" /></td>'; 01013 if ($txtMarg && $align=='left') { // If left aligned, the textborder is added on the left side 01014 $tablecode.='<td rowspan="'.($rowspan+1).'" valign="top"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$txtMarg.'" height="1" alt="" title="" />'.($editIconsHTML?'<br />'.$editIconsHTML:'').'</td>'; 01015 $editIconsHTML=''; 01016 $flag=1; 01017 } 01018 if ($flag) $tableWidth+=$txtMarg+1; 01019 // $tableWidth=0; 01020 $tablecode.='</tr>'; 01021 } 01022 01023 // draw table 01024 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! 01025 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. 01026 $tablecode.='<tr><td colspan="'.$colspan.'"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$rowspacing.'"'.$this->getBorderAttr(' border="0"').' alt="" title="" /></td></tr>'; 01027 } 01028 $tablecode.='<tr>'; // starting row 01029 for ($b=0; $b<$colCount_temp; $b++) { // Looping through the columns 01030 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. 01031 if (!$noCols) { 01032 $tablecode.='<td><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$colspacing.'" height="1"'.$this->getBorderAttr(' border="0"').' alt="" title="" /></td>'; 01033 } else { 01034 $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="" />'; 01035 $colSpacer='<td valign="top">'.$colSpacer.'</td>'; // added 160301, needed for the new "noCols"-table... 01036 $tablecode.=$colSpacer; 01037 } 01038 } 01039 if (!$noCols || ($noCols && !$b)) { 01040 $tablecode.='<td valign="top">'; // starting the cell. If "noCols" this cell will hold all images in the row, otherwise only a single image. 01041 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. 01042 } 01043 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. 01044 $imgIndex = $index+$a*$colCount_temp; 01045 if ($imgsTag[$imgIndex]) { 01046 if ($rowspacing && $noRows && $a) { // Puts distance between the images IF "noRows" is set and this is the first iteration of the loop 01047 $tablecode.= '<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$rowspacing.'" alt="" title="" /><br />'; 01048 } 01049 01050 $imageHTML = $imgsTag[$imgIndex].'<br />'; 01051 $Talign = (!trim($captionArray[$imgIndex]) && !$noRows && !$conf['netprintApplicationLink']) ? ' align="left"' : ''; // this is necessary if the tablerows are supposed to space properly together! "noRows" is excluded because else the images "layer" together. 01052 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...) 01053 $imageHTML.=$editIconsHTML; $editIconsHTML=''; 01054 if ($conf['netprintApplicationLink']) {$imageHTML = $this->netprintApplication_offsiteLinkWrap($imageHTML,$origImages[$imgIndex],$conf['netprintApplicationLink.']);} 01055 $imageHTML.=$captionArray[$imgIndex]; // Adds caption. 01056 if ($noCols) {$imageHTML='<td valign="top">'.$imageHTML.'</td>';} // If noCols, put in table cell. 01057 $tablecode.=$imageHTML; 01058 } 01059 } 01060 $index++; 01061 if (!$noCols || ($noCols && $b+1==$colCount_temp)) { 01062 if ($noCols) {$tablecode.='</tr></table>';} // In case of "noCols" we must finish the table that surrounds the images in the row. 01063 $tablecode.='</td>'; // Ending the cell. In case of "noCols" the cell holds all pictures! 01064 } 01065 } 01066 $tablecode.='</tr>'; // ending row 01067 } 01068 if ($c) { 01069 switch ($contentPosition) { 01070 case '0': // above 01071 case '8': // below 01072 switch ($align) { // These settings are needed for Firefox 01073 case 'center': 01074 $table_align = 'margin-left: auto; margin-right: auto'; 01075 break; 01076 case 'right': 01077 $table_align = 'margin-left: auto; margin-right: 0px'; 01078 break; 01079 default: // Most of all: left 01080 $table_align = 'margin-left: 0px; margin-right: auto'; 01081 } 01082 $table_align = 'style="'.$table_align.'"'; 01083 break; 01084 case '16': // in text 01085 $table_align = 'align="'.$align.'"'; 01086 break; 01087 default: 01088 $table_align = ''; 01089 } 01090 01091 // Table-tag is inserted 01092 $tablecode = '<table'.($tableWidth?' width="'.$tableWidth.'"':'').' border="0" cellspacing="0" cellpadding="0" '.$table_align.' class="imgtext-table">'.$tablecode; 01093 if ($editIconsHTML) { // IF this value is not long since reset. 01094 $tablecode.='<tr><td colspan="'.$colspan.'">'.$editIconsHTML.'</td></tr>'; 01095 $editIconsHTML=''; 01096 } 01097 if ($cap) { 01098 $tablecode.='<tr><td colspan="'.$colspan.'" align="'.$caption_align.'">'.$caption.'</td></tr>'; 01099 } 01100 $tablecode.='</table>'; 01101 if ($conf['tableStdWrap.']) {$tablecode=$this->stdWrap($tablecode,$conf['tableStdWrap.']);} 01102 } 01103 01104 $spaceBelowAbove = intval($this->stdWrap($conf['spaceBelowAbove'],$conf['spaceBelowAbove.'])); 01105 switch ($contentPosition) { 01106 case '0': // above 01107 $output= '<div style="text-align:'.$align.';">'.$tablecode.'</div>'.$this->wrapSpace($content, $spaceBelowAbove.'|0'); 01108 break; 01109 case '8': // below 01110 $output= $this->wrapSpace($content, '0|'.$spaceBelowAbove).'<div style="text-align:'.$align.';">'.$tablecode.'</div>'; 01111 break; 01112 case '16': // in text 01113 $output= $tablecode.$content; 01114 break; 01115 case '24': // in text, no wrap 01116 $theResult = ''; 01117 $theResult.= '<table border="0" cellspacing="0" cellpadding="0" class="imgtext-nowrap"><tr>'; 01118 if ($align=='right') { 01119 $theResult.= '<td valign="top">'.$content.'</td><td valign="top">'.$tablecode.'</td>'; 01120 } else { 01121 $theResult.= '<td valign="top">'.$tablecode.'</td><td valign="top">'.$content.'</td>'; 01122 } 01123 $theResult.= '</tr></table>'; 01124 $output= $theResult; 01125 break; 01126 } 01127 } else { 01128 $output= $content; 01129 } 01130 01131 if ($conf['stdWrap.']) { 01132 $output = $this->stdWrap($output, $conf['stdWrap.']); 01133 } 01134 01135 return $output; 01136 } 01137 01145 function CONTENT($conf) { 01146 $theValue=''; 01147 01148 $originalRec = $GLOBALS['TSFE']->currentRecord; 01149 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!! 01150 $GLOBALS['TSFE']->recordRegister[$originalRec]++; 01151 } 01152 01153 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_') { 01154 01155 $renderObjName = $conf['renderObj'] ? $conf['renderObj'] : '<'.$conf['table']; 01156 $renderObjKey = $conf['renderObj'] ? 'renderObj' : ''; 01157 $renderObjConf = $conf['renderObj.']; 01158 01159 $res = $this->exec_getQuery($conf['table'],$conf['select.']); 01160 if ($error = $GLOBALS['TYPO3_DB']->sql_error()) { 01161 $GLOBALS['TT']->setTSlogMessage($error,3); 01162 } else { 01163 $this->currentRecordTotal = $GLOBALS['TYPO3_DB']->sql_num_rows($res); 01164 $GLOBALS['TT']->setTSlogMessage('NUMROWS: '.$GLOBALS['TYPO3_DB']->sql_num_rows($res)); 01165 $cObj =t3lib_div::makeInstance('tslib_cObj'); 01166 $cObj->setParent($this->data,$this->currentRecord); 01167 $this->currentRecordNumber=0; 01168 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 01169 01170 // Versioning preview: 01171 $GLOBALS['TSFE']->sys_page->versionOL($conf['table'],$row); 01172 01173 // Language Overlay: 01174 if ($GLOBALS['TSFE']->sys_language_contentOL) { 01175 $row = $GLOBALS['TSFE']->sys_page->getRecordOverlay($conf['table'],$row,$GLOBALS['TSFE']->sys_language_content,$GLOBALS['TSFE']->sys_language_contentOL); 01176 } 01177 01178 if (is_array($row)) { // Might be unset in the sys_language_contentOL 01179 if (!$GLOBALS['TSFE']->recordRegister[$conf['table'].':'.$row['uid']]) { 01180 $this->currentRecordNumber++; 01181 $cObj->parentRecordNumber = $this->currentRecordNumber; 01182 $GLOBALS['TSFE']->currentRecord = $conf['table'].':'.$row['uid']; 01183 $this->lastChanged($row['tstamp']); 01184 $cObj->start($row,$conf['table']); 01185 if ($GLOBALS['TSFE']->config['config']['insertDmailerBoundaries']) { $theValue.='<!--DMAILER_SECTION_BOUNDARY_'.intval($row['module_sys_dmail_category']).'-->'; } 01186 $theValue.= $cObj->cObjGetSingle($renderObjName, $renderObjConf, $renderObjKey); 01187 }# else debug($GLOBALS['TSFE']->recordRegister,'CONTENT'); 01188 } 01189 } 01190 if ($GLOBALS['TSFE']->config['config']['insertDmailerBoundaries']) { $theValue.='<!--DMAILER_SECTION_BOUNDARY_END-->'; } 01191 } 01192 } 01193 01194 $theValue = $this->wrap($theValue,$conf['wrap']); 01195 if ($conf['stdWrap.']) $theValue = $this->stdWrap($theValue,$conf['stdWrap.']); 01196 01197 $GLOBALS['TSFE']->currentRecord = $originalRec; // Restore 01198 return $theValue; 01199 } 01200 01208 function RECORDS($conf) { 01209 $theValue=''; 01210 01211 $originalRec = $GLOBALS['TSFE']->currentRecord; 01212 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!! 01213 $GLOBALS['TSFE']->recordRegister[$originalRec]++; 01214 } 01215 01216 $conf['source'] = $this->stdWrap($conf['source'],$conf['source.']); 01217 if ($conf['tables'] && $conf['source']) { 01218 $allowedTables = $conf['tables']; 01219 if (is_array($conf['conf.'])) { 01220 reset($conf['conf.']); 01221 while(list($k)=each($conf['conf.'])) { 01222 if (substr($k,-1)!='.') $allowedTables.=','.$k; 01223 } 01224 } 01225 01226 $loadDB = t3lib_div::makeInstance('FE_loadDBGroup'); 01227 $loadDB->start($conf['source'], $allowedTables); 01228 reset($loadDB->tableArray); 01229 while(list($table,)=each($loadDB->tableArray)) { 01230 if (is_array($GLOBALS['TCA'][$table])) { 01231 $loadDB->additionalWhere[$table]=$this->enableFields($table); 01232 } 01233 } 01234 $loadDB->getFromDB(); 01235 01236 reset($loadDB->itemArray); 01237 $data = $loadDB->results; 01238 01239 $cObj =t3lib_div::makeInstance('tslib_cObj'); 01240 $cObj->setParent($this->data,$this->currentRecord); 01241 $this->currentRecordNumber=0; 01242 $this->currentRecordTotal = count($loadDB->itemArray); 01243 reset($loadDB->itemArray); 01244 while(list(,$val)=each($loadDB->itemArray)) { 01245 $row = $data[$val['table']][$val['id']]; 01246 01247 // Versioning preview: 01248 $GLOBALS['TSFE']->sys_page->versionOL($val['table'],$row); 01249 01250 // Language Overlay: 01251 if ($GLOBALS['TSFE']->sys_language_contentOL) { 01252 $row = $GLOBALS['TSFE']->sys_page->getRecordOverlay($val['table'],$row,$GLOBALS['TSFE']->sys_language_content,$GLOBALS['TSFE']->sys_language_contentOL); 01253 } 01254 01255 if (is_array($row)) { // Might be unset in the content overlay things... 01256 if (!$conf['dontCheckPid']) { 01257 $row = $this->checkPid($row['pid']) ? $row : ''; 01258 } 01259 if ($row && !$GLOBALS['TSFE']->recordRegister[$val['table'].':'.$val['id']]) { 01260 $renderObjName = $conf['conf.'][$val['table']] ? $conf['conf.'][$val['table']] : '<'.$val['table']; 01261 $renderObjKey = $conf['conf.'][$val['table']] ? 'conf.'.$val['table'] : ''; 01262 $renderObjConf = $conf['conf.'][$val['table'].'.']; 01263 $this->currentRecordNumber++; 01264 $cObj->parentRecordNumber=$this->currentRecordNumber; 01265 $GLOBALS['TSFE']->currentRecord = $val['table'].':'.$val['id']; 01266 $this->lastChanged($row['tstamp']); 01267 $cObj->start($row,$val['table']); 01268 if ($GLOBALS['TSFE']->config['config']['insertDmailerBoundaries']) {$theValue.='<!--DMAILER_SECTION_BOUNDARY_'.intval($row['module_sys_dmail_category']).'-->';} 01269 $theValue.=$cObj->cObjGetSingle($renderObjName, $renderObjConf, $renderObjKey); 01270 if ($GLOBALS['TSFE']->config['config']['insertDmailerBoundaries']) {$theValue.='<!--DMAILER_SECTION_BOUNDARY_END-->';} 01271 }# else debug($GLOBALS['TSFE']->recordRegister,'RECORDS'); 01272 } 01273 } 01274 } 01275 $GLOBALS['TSFE']->currentRecord = $originalRec; // Restore 01276 return $this->wrap($theValue,$conf['wrap']); 01277 } 01278 01286 function HMENU($conf) { 01287 $content=''; 01288 if ($this->checkIf($conf['if.'])) { 01289 $cls = strtolower($conf[1]); 01290 if (t3lib_div::inList($GLOBALS['TSFE']->tmpl->menuclasses,$cls)) { 01291 if ($conf['special.']['value.']) { 01292 $conf['special.']['value'] = $this->stdWrap($conf['special.']['value'], $conf['special.']['value.']); 01293 } 01294 $GLOBALS['TSFE']->register['count_HMENU']++; 01295 $GLOBALS['TSFE']->register['count_HMENU_MENUOBJ']=0; 01296 $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid']=array(); 01297 $GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMparentId']=array(); 01298 01299 $menu = t3lib_div::makeInstance('tslib_'.$cls); 01300 $menu->parent_cObj = $this; 01301 $menu->start($GLOBALS['TSFE']->tmpl, $GLOBALS['TSFE']->sys_page, '', $conf, 1); 01302 $menu->makeMenu(); 01303 $content.=$menu->writeMenu(); 01304 } 01305 if ($conf['wrap']) $content=$this->wrap($content, $conf['wrap']); 01306 if ($conf['stdWrap.']) $content = $this->stdWrap($content, $conf['stdWrap.']); 01307 } 01308 return $content; 01309 } 01310 01318 function CTABLE ($conf) { 01319 $controlTable = t3lib_div::makeInstance('tslib_controlTable'); 01320 if ($conf['tableParams']) { 01321 $controlTable->tableParams = $conf['tableParams']; 01322 } 01323 // loads the pagecontent 01324 $controlTable->contentW = $conf['cWidth']; 01325 // loads the menues if any 01326 if (is_array($conf['c.'])) { 01327 $controlTable->content = $this->cObjGet($conf['c.'],'c.'); 01328 $controlTable->contentTDparams = isset($conf['c.']['TDParams']) ? $conf['c.']['TDParams'] : 'valign="top"'; 01329 } 01330 if (is_array($conf['lm.'])) { 01331 $controlTable->lm = $this->cObjGet($conf['lm.'],'lm.'); 01332 $controlTable->lmTDparams = isset($conf['lm.']['TDParams']) ? $conf['lm.']['TDParams'] : 'valign="top"'; 01333 } 01334 if (is_array($conf['tm.'])) { 01335 $controlTable->tm = $this->cObjGet($conf['tm.'],'tm.'); 01336 $controlTable->tmTDparams = isset($conf['tm.']['TDParams']) ? $conf['tm.']['TDParams'] : 'valign="top"'; 01337 } 01338 if (is_array($conf['rm.'])) { 01339 $controlTable->rm = $this->cObjGet($conf['rm.'],'rm.'); 01340 $controlTable->rmTDparams = isset($conf['rm.']['TDParams']) ? $conf['rm.']['TDParams'] : 'valign="top"'; 01341 } 01342 if (is_array($conf['bm.'])) { 01343 $controlTable->bm = $this->cObjGet($conf['bm.'],'bm.'); 01344 $controlTable->bmTDparams = isset($conf['bm.']['TDParams']) ? $conf['bm.']['TDParams'] : 'valign="top"'; 01345 } 01346 return $controlTable->start($conf['offset'],$conf['cMargins']); 01347 } 01348 01356 function OTABLE ($conf) { 01357 $controlTable = t3lib_div::makeInstance('tslib_tableOffset'); 01358 if ($conf['tableParams']) { 01359 $controlTable->tableParams = $conf['tableParams']; 01360 } 01361 return $controlTable->start($this->cObjGet($conf),$conf['offset']); 01362 } 01363 01371 function COLUMNS ($conf) { 01372 $content=''; 01373 if (is_array($conf) && $this->checkIf($conf['if.'])) { 01374 $tdRowCount=0; 01375 $tableParams = $conf['tableParams'] ? ' '.$conf['tableParams'] : ' border="0" cellspacing="0" cellpadding="0"'; 01376 $TDparams = $conf['TDparams'] ? ' '.$conf['TDparams']:' valign="top"'; 01377 $rows = t3lib_div::intInRange($conf['rows'],2,20); 01378 $totalWidth = intval($conf['totalWidth']); 01379 $columnWidth=0; 01380 01381 $totalGapWidth=0; 01382 $gapData = Array( 01383 'gapWidth' => $this->stdWrap($conf['gapWidth'],$conf['gapWidth.']), 01384 'gapBgCol' => $this->stdWrap($conf['gapBgCol'],$conf['gapBgCol.']), 01385 'gapLineThickness' => $this->stdWrap($conf['gapLineThickness'],$conf['gapLineThickness.']), 01386 'gapLineCol' => $this->stdWrap($conf['gapLineCol'],$conf['gapLineCol.']) 01387 ); 01388 $gapData = $GLOBALS['TSFE']->tmpl->splitConfArray($gapData,$rows-1); 01389 reset($gapData); 01390 while(list(,$val)=each($gapData)) { 01391 $totalGapWidth+=intval($val['gapWidth']); 01392 } 01393 01394 if ($totalWidth) { 01395 $columnWidth = ceil(($totalWidth-$totalGapWidth)/$rows); 01396 $TDparams.=' width="'.$columnWidth.'"'; 01397 $tableParams.=' width="'.$totalWidth.'"'; 01398 } else { 01399 $TDparams.=' width="'.floor(100/$rows).'%"'; 01400 $tableParams.=' width="100%"'; 01401 } 01402 01403 for ($a=1;$a<=$rows;$a++) { 01404 $tdRowCount++; 01405 $content.='<td'.$TDparams.'>'; 01406 $content.=$this->cObjGetSingle($conf[$a],$conf[$a.'.'], $a); 01407 $content.='</td>'; 01408 if ($a < $rows) { 01409 $gapConf = $gapData[($a-1)]; 01410 $gapWidth = intval($gapConf['gapWidth']); 01411 if ($gapWidth) { 01412 $tdPar = $gapConf['gapBgCol'] ? ' bgcolor="'.$gapConf['gapBgCol'].'"' : ''; 01413 $gapLine = intval($gapConf['gapLineThickness']); 01414 if ($gapLine) { 01415 $gapSurround = t3lib_div::intInRange(($gapWidth-$gapLine)/2, 1, 1000); 01416 // right gap 01417 $content.='<td'.$tdPar.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$gapSurround.'" height="1" alt="" title="" /></td>'; 01418 $tdRowCount++; 01419 // line: 01420 $GtdPar = $gapConf['gapLineCol'] ? ' bgcolor="'.$gapConf['gapLineCol'].'"' : ' bgcolor="black"'; 01421 $content.='<td'.$GtdPar.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$gapLine.'" height="1" alt="" title="" /></td>'; 01422 $tdRowCount++; 01423 // left gap 01424 $content.='<td'.$tdPar.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$gapSurround.'" height="1" alt="" title="" /></td>'; 01425 $tdRowCount++; 01426 } else { 01427 $content.='<td'.$tdPar.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$gapWidth.'" height="1" alt="" title="" /></td>'; 01428 $tdRowCount++; 01429 } 01430 } 01431 } 01432 } 01433 $content='<tr>'.$content.'</tr>'; 01434 $content='<table'.$tableParams.'>'.$content.'</table>'; 01435 $content.=$this->cObjGetSingle($conf['after'],$conf['after.'], 'after'); 01436 if ($conf['stdWrap.']) { 01437 $content = $this->stdWrap($content,$conf['stdWrap.']); 01438 } 01439 } 01440 return $content; 01441 } 01442 01450 function HRULER ($conf) { 01451 $lineThickness = t3lib_div::intInRange($this->stdWrap($conf['lineThickness'],$conf['lineThickness.']),1,50); 01452 $lineColor = $conf['lineColor'] ? $conf['lineColor'] : 'black'; 01453 $spaceBefore = intval($conf['spaceLeft']); 01454 $spaceAfter = intval($conf['spaceRight']); 01455 $tableWidth = $conf['tableWidth'] ? $conf['tableWidth'] : '99%'; 01456 $content=''; 01457 01458 $content.='<table border="0" cellspacing="0" cellpadding="0" width="'.htmlspecialchars($tableWidth).'"><tr>'; 01459 if ($spaceBefore) {$content.='<td width="1"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$spaceBefore.'" height="1" alt="" title="" /></td>'; } 01460 $content.='<td bgcolor="'.$lineColor.'"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$lineThickness.'" alt="" title="" /></td>'; 01461 if ($spaceAfter) {$content.='<td width="1"><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$spaceAfter.'" height="1" alt="" title="" /></td>'; } 01462 $content.='</tr></table>'; 01463 01464 $content = $this->stdWrap($content, $conf['stdWrap.']); 01465 return $content; 01466 } 01467 01475 function CASEFUNC ($conf){ 01476 $content=''; 01477 if ($this->checkIf($conf['if.'])) { 01478 if ($conf['setCurrent'] || $conf['setCurrent.']){$this->data[$this->currentValKey] = $this->stdWrap($conf['setCurrent'], $conf['setCurrent.']);} 01479 $key = $this->stdWrap($conf['key'],$conf['key.']); 01480 $key = $conf[$key] ? $key : 'default'; 01481 $name = $conf[$key]; 01482 $theValue = $this->cObjGetSingle($name,$conf[$key.'.'], $key); 01483 if ($conf['stdWrap.']) { 01484 $theValue = $this->stdWrap($theValue,$conf['stdWrap.']); 01485 } 01486 return $theValue; 01487 } 01488 } 01489 01500 function LOAD_REGISTER($conf,$name) { 01501 if ($name=='RESTORE_REGISTER') { 01502 $GLOBALS['TSFE']->register = array_pop($GLOBALS['TSFE']->registerStack); 01503 } else { 01504 array_push($GLOBALS['TSFE']->registerStack,$GLOBALS['TSFE']->register); 01505 if (is_array($conf)) { 01506 reset($conf); 01507 while(list($theKey,$theValue)=each($conf)) { 01508 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 01509 if (strstr($theKey,'.')) { 01510 $theKey = substr($theKey,0,-1); 01511 } 01512 $GLOBALS['TSFE']->register[$theKey] = $this->stdWrap($conf[$theKey],$conf[$theKey.'.']); 01513 } 01514 } 01515 } 01516 } 01517 return ''; 01518 } 01519 01540 function FORM($conf,$formData='') { 01541 $content=''; 01542 if (is_array($formData)) { 01543 $dataArr = $formData; 01544 } else { 01545 $data=$this->stdWrap($conf['data'],$conf['data.']); 01546 // Clearing dataArr 01547 $dataArr=array(); 01548 // Getting the original config 01549 if (trim($data)) { 01550 $data = ereg_replace(chr(10),'||',$data); 01551 $dataArr = explode('||',$data); 01552 } 01553 // Adding the new dataArray config form: 01554 if (is_array($conf['dataArray.'])) { // dataArray is supplied 01555 $sKeyArray = t3lib_TStemplate::sortedKeyList($conf['dataArray.'], TRUE); 01556 foreach($sKeyArray as $theKey) { 01557 $dAA = $conf['dataArray.'][$theKey.'.']; 01558 if (is_array($dAA)) { 01559 $temp=array(); 01560 list($temp[0])= explode('|',$dAA['label.'] ? $this->stdWrap($dAA['label'],$dAA['label.']) : $dAA['label']); 01561 list($temp[1])= explode('|',$dAA['type']); 01562 if ($dAA['required']) {$temp[1]='*'.$temp[1];} 01563 list($temp[2])= explode('|',$dAA['value.'] ? $this->stdWrap($dAA['value'],$dAA['value.']) : $dAA['value']); 01564 // If value Array is set, then implode those values. 01565 if (is_array($dAA['valueArray.'])) { 01566 reset($dAA['valueArray.']); 01567 $temp_accum = array(); 01568 while(list($dAKey_vA,$dAA_vA)=each($dAA['valueArray.'])) { 01569 if (is_array($dAA_vA) && !strcmp(intval($dAKey_vA).'.',$dAKey_vA)) { 01570 $temp_vA=array(); 01571 list($temp_vA[0])= explode('=',$dAA_vA['label.'] ? $this->stdWrap($dAA_vA['label'],$dAA_vA['label.']) : $dAA_vA['label']); 01572 if ($dAA_vA['selected']) {$temp_vA[0]='*'.$temp_vA[0];} 01573 list($temp_vA[1])= explode(',',$dAA_vA['value']); 01574 } 01575 $temp_accum[] = implode('=',$temp_vA); 01576 } 01577 $temp[2] = implode(',',$temp_accum); 01578 } 01579 list($temp[3])= explode('|',$dAA['specialEval.'] ? $this->stdWrap($dAA['specialEval'],$dAA['specialEval.']) : $dAA['specialEval']); 01580 01581 // adding the form entry to the dataArray 01582 $dataArr[] = implode('|',$temp); 01583 } 01584 } 01585 } 01586 } 01587 01588 $attachmentCounter = ''; 01589 $hiddenfields = ''; 01590 $fieldlist = Array(); 01591 $propertyOverride = Array(); 01592 $fieldname_hashArray = Array(); 01593 $cc = 0; 01594 01595 // Formname; 01596 $formname = $GLOBALS['TSFE']->uniqueHash(); 01597 if (ctype_digit($formname{0})) { // form name must start with a letter 01598 $formname = 'a'.$formname; 01599 } 01600 01601 foreach($dataArr as $val) { 01602 01603 $cc++; 01604 $confData=Array(); 01605 if (is_array($formData)) { 01606 $parts = $val; 01607 $val = 1; // true... 01608 } else { 01609 $val = trim($val); 01610 $parts = explode('|',$val); 01611 } 01612 if ($val && strcspn($val,'#/')) { 01613 // label: 01614 $confData['label'] = trim($parts[0]); 01615 // field: 01616 $fParts = explode(',',$parts[1]); 01617 $fParts[0]=trim($fParts[0]); 01618 if (substr($fParts[0],0,1)=='*') { 01619 $confData['required']=1; 01620 $fParts[0] = substr($fParts[0],1); 01621 } 01622 $typeParts = explode('=',$fParts[0]); 01623 $confData['type'] = trim(strtolower(end($typeParts))); 01624 if (count($typeParts)==1) { 01625 $confData['fieldname'] = substr(ereg_replace('[^a-zA-Z0-9_]','',str_replace(' ','_',trim($parts[0]))),0,30); 01626 if (strtolower(ereg_replace('[^[:alnum:]]','',$confData['fieldname']))=='email') {$confData['fieldname']='email';} 01627 // Duplicate fieldnames resolved 01628 if (isset($fieldname_hashArray[md5($confData['fieldname'])])) { 01629 $confData['fieldname'].='_'.$cc; 01630 } 01631 $fieldname_hashArray[md5($confData['fieldname'])]=$confData['fieldname']; 01632 // Attachment names... 01633 if ($confData['type']=='file') { 01634 $confData['fieldname']='attachment'.$attachmentCounter; 01635 $attachmentCounter=intval($attachmentCounter)+1; 01636 } 01637 } else { 01638 $confData['fieldname'] = str_replace(' ','_',trim($typeParts[0])); 01639 } 01640 $fieldCode=''; 01641 01642 if ($conf['wrapFieldName']) { 01643 $confData['fieldname'] = $this->wrap($confData['fieldname'],$conf['wrapFieldName']); 01644 } 01645 01646 // Set field name as current: 01647 $this->setCurrentVal($confData['fieldname']); 01648 01649 // Additional parameters 01650 if (trim($confData['type'])) { 01651 $addParams=trim($conf['params']); 01652 if (is_array($conf['params.']) && isset($conf['params.'][$confData['type']])) { 01653 $addParams=trim($conf['params.'][$confData['type']]); 01654 } 01655 if (strcmp('',$addParams)) $addParams=' '.$addParams; 01656 } else $addParams=''; 01657 01658 // Accessibility: Set id = fieldname attribute: 01659 if ($conf['accessibility']) { 01660 $elementIdAttribute = ' id="'.$formname.'_'.md5($confData['fieldname']).'"'; 01661 } else { 01662 $elementIdAttribute = ''; 01663 } 01664 01665 // Create form field based on configuration/type: 01666 switch($confData['type']) { 01667 case 'textarea': 01668 $cols=trim($fParts[1]) ? intval($fParts[1]) : 20; 01669 $compWidth = doubleval($conf['compensateFieldWidth'] ? $conf['compensateFieldWidth'] : $GLOBALS['TSFE']->compensateFieldWidth); 01670 $compWidth = $compWidth ? $compWidth : 1; 01671 $cols = t3lib_div::intInRange($cols*$compWidth, 1, 120); 01672 01673 $rows=trim($fParts[2]) ? t3lib_div::intInRange($fParts[2],1,30) : 5; 01674 $wrap=trim($fParts[3]); 01675 if ($conf['noWrapAttr'] || $wrap === 'disabled') { 01676 $wrap=''; 01677 } else { 01678 $wrap=$wrap ? ' wrap="'.trim($fParts[3]).'"' : ' wrap="virtual"'; 01679 } 01680 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], str_replace('\n',chr(10),trim($parts[2]))); 01681 $fieldCode=sprintf('<textarea name="%s"'.$elementIdAttribute.' cols="%s" rows="%s"%s'.$addParams.'>%s</textarea>', 01682 $confData['fieldname'], $cols, $rows, $wrap, t3lib_div::formatForTextarea($default)); 01683 break; 01684 case 'input': 01685 case 'password': 01686 $size=trim($fParts[1]) ? intval($fParts[1]) : 20; 01687 $compWidth = doubleval($conf['compensateFieldWidth'] ? $conf['compensateFieldWidth'] : $GLOBALS['TSFE']->compensateFieldWidth); 01688 $compWidth = $compWidth ? $compWidth : 1; 01689 $size = t3lib_div::intInRange($size*$compWidth, 1, 120); 01690 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], trim($parts[2])); 01691 01692 if ($confData['type']=='password') { 01693 $default=''; 01694 } 01695 01696 $max=trim($fParts[2]) ? ' maxlength="'.t3lib_div::intInRange($fParts[2],1,1000).'"' : ""; 01697 $theType = $confData['type']=='input' ? 'text' : 'password'; 01698 01699 $fieldCode=sprintf('<input type="'.$theType.'" name="%s"'.$elementIdAttribute.' size="%s"%s value="%s"'.$addParams.' />', 01700 $confData['fieldname'], $size, $max, htmlspecialchars($default)); 01701 01702 break; 01703 case 'file': 01704 $size=trim($fParts[1]) ? t3lib_div::intInRange($fParts[1],1,60) : 20; 01705 $fieldCode=sprintf('<input type="file" name="%s"'.$elementIdAttribute.' size="%s"'.$addParams.' />', 01706 $confData['fieldname'], $size); 01707 break; 01708 case 'check': 01709 // alternative default value: 01710 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], trim($parts[2])); 01711 $checked = $default ? ' checked="checked"' : ''; 01712 $fieldCode=sprintf('<input type="checkbox" value="%s" name="%s"'.$elementIdAttribute.'%s'.$addParams.' />', 01713 1, $confData['fieldname'], $checked); 01714 break; 01715 case 'select': 01716 $option=''; 01717 $valueParts = explode(',',$parts[2]); 01718 // size 01719 if (strtolower(trim($fParts[1]))=='auto') {$fParts[1]=count($valueParts);} // Auto size set here. Max 20 01720 $size=trim($fParts[1]) ? t3lib_div::intInRange($fParts[1],1,20) : 1; 01721 // multiple 01722 $multiple = strtolower(trim($fParts[2]))=='m' ? ' multiple="multiple"' : ''; 01723 01724 $items=array(); // Where the items will be 01725 $defaults=array(); //RTF 01726 for($a=0;$a<count($valueParts);$a++) { 01727 $valueParts[$a]=trim($valueParts[$a]); 01728 if (substr($valueParts[$a],0,1)=='*') { // Finding default value 01729 $sel='selected'; 01730 $valueParts[$a] = substr($valueParts[$a],1); 01731 } else $sel=''; 01732 // Get value/label 01733 $subParts=explode('=',$valueParts[$a]); 01734 $subParts[1] = (isset($subParts[1])?trim($subParts[1]):trim($subParts[0])); // Sets the value 01735 $items[] = $subParts; // Adds the value/label pair to the items-array 01736 if ($sel) {$defaults[]=$subParts[1];} // Sets the default value if value/label pair is marked as default. 01737 } 01738 // alternative default value: 01739 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], $defaults); 01740 if (!is_array($default)) { 01741 $defaults=array(); 01742 $defaults[] = $default; 01743 } else $defaults=$default; 01744 // Create the select-box: 01745 for($a=0;$a<count($items);$a++) { 01746 $option.='<option value="'.$items[$a][1].'"'.(in_array($items[$a][1],$defaults)?' selected="selected"':'').'>'.trim($items[$a][0]).'</option>'; //RTF 01747 } 01748 01749 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. 01750 $fieldCode=sprintf('<select name="%s"'.$elementIdAttribute.' size="%s"%s'.$addParams.'>%s</select>', 01751 $confData['fieldname'], $size, $multiple, $option); //RTF 01752 break; 01753 case 'radio': 01754 $option=''; 01755 $valueParts = explode(',',$parts[2]); 01756 $items=array(); // Where the items will be 01757 $default=''; 01758 for($a=0;$a<count($valueParts);$a++) { 01759 $valueParts[$a]=trim($valueParts[$a]); 01760 if (substr($valueParts[$a],0,1)=='*') { 01761 $sel='checked'; 01762 $valueParts[$a] = substr($valueParts[$a],1); 01763 } else $sel=''; 01764 // Get value/label 01765 $subParts=explode('=',$valueParts[$a]); 01766 $subParts[1] = (isset($subParts[1])?trim($subParts[1]):trim($subParts[0])); // Sets the value 01767 $items[] = $subParts; // Adds the value/label pair to the items-array 01768 if ($sel) {$default=$subParts[1];} // Sets the default value if value/label pair is marked as default. 01769 } 01770 // alternative default value: 01771 $default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], $default); 01772 // Create the select-box: 01773 for($a=0;$a<count($items);$a++) { 01774 $option.= '<input type="radio" name="'.$confData['fieldname'].'"'.$elementIdAttribute.' value="'.$items[$a][1].'"'.(!strcmp($items[$a][1],$default)?' checked="checked"':'').''.$addParams.' />'; 01775 $option.= $this->stdWrap(trim($items[$a][0]), $conf['radioWrap.']); 01776 $option.= '<br />'; 01777 } 01778 $fieldCode = $option; 01779 break; 01780 case 'hidden': 01781 $value = trim($parts[2]); 01782 if(strlen($value) && t3lib_div::inList('recipient_copy,recipient',$confData['fieldname']) && $GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail']) { 01783 break; 01784 } 01785 if (strlen($value) && t3lib_div::inList('recipient_copy,recipient',$confData['fieldname'])) { 01786 $value = $GLOBALS['TSFE']->codeString($value); 01787 } 01788 $hiddenfields.=sprintf('<input type="hidden" name="%s"'.$elementIdAttribute.' value="%s" />', 01789 $confData['fieldname'], htmlspecialchars($value)); 01790 break; 01791 case 'property': 01792 if (t3lib_div::inList('type,locationData,goodMess,badMess,emailMess',$confData['fieldname'])) { 01793 $value=trim($parts[2]); 01794 $propertyOverride[$confData['fieldname']] = $value; 01795 $conf[$confData['fieldname']] = $value; 01796 } 01797 break; 01798 case 'submit': 01799 $value=trim($parts[2]); 01800 if ($conf['image.']) { 01801 $this->data[$this->currentValKey]=$value; 01802 $image=$this->IMAGE($conf['image.']); 01803 } else $image=''; 01804 if($image) { 01805 $fieldCode = str_replace('<img','<input type="image"'.$addParams.' name="'.$confData['fieldname'].'"' ,$image); 01806 } else { 01807 $fieldCode=sprintf('<input type="submit" name="%s"'.$elementIdAttribute.' value="%s"'.$addParams.' />', 01808 $confData['fieldname'], t3lib_div::deHSCentities(htmlspecialchars($value))); 01809 } 01810 break; 01811 case 'reset': 01812 $value=trim($parts[2]); 01813 $fieldCode=sprintf('<input type="reset" name="%s"'.$elementIdAttribute.' value="%s"'.$addParams.' />', 01814 $confData['fieldname'], t3lib_div::deHSCentities(htmlspecialchars($value))); 01815 break; 01816 case 'label': 01817 $fieldCode = nl2br(htmlspecialchars(trim($parts[2]))); 01818 break; 01819 default: 01820 $confData['type'] = 'comment'; 01821 $fieldCode = trim($parts[2]).' '; 01822 break; 01823 } 01824 if ($fieldCode) { 01825 01826 // Checking for special evaluation modes: 01827 if (t3lib_div::inList('textarea,input,password',$confData['type']) && strlen(trim($parts[3]))) { 01828 $modeParameters = t3lib_div::trimExplode(':',$parts[3]); 01829 } else { 01830 $modeParameters = array(); 01831 } 01832 01833 // Adding evaluation based on settings: 01834 switch((string)$modeParameters[0]) { 01835 case 'EREG': 01836 $fieldlist[] = '_EREG'; 01837 $fieldlist[] = rawurlencode($modeParameters[1]); 01838 $fieldlist[] = rawurlencode($modeParameters[2]); 01839 $fieldlist[] = rawurlencode($confData['fieldname']); 01840 $fieldlist[] = rawurlencode($confData['label']); 01841 $confData['required'] = 1; // Setting this so "required" layout is used. 01842 break; 01843 case 'EMAIL': 01844 $fieldlist[] = '_EMAIL'; 01845 $fieldlist[] = rawurlencode($confData['fieldname']); 01846 $fieldlist[] = rawurlencode($confData['label']); 01847 $confData['required'] = 1; // Setting this so "required" layout is used. 01848 break; 01849 default: 01850 if ($confData['required'] && $confData['type']!='check') { 01851 $fieldlist[] = rawurlencode($confData['fieldname']); 01852 $fieldlist[] = rawurlencode($confData['label']); 01853 } 01854 break; 01855 } 01856 01857 // Field: 01858 $fieldLabel = $confData['label']; 01859 if ($conf['accessibility']) { 01860 $fieldLabel = '<label for="'.$formname.'_'.md5($confData['fieldname']).'">'.$fieldLabel.'</label>'; 01861 } 01862 01863 // Getting template code: 01864 $fieldCode = $this->stdWrap($fieldCode, $conf['fieldWrap.']); 01865 $labelCode = $this->stdWrap($fieldLabel, $conf['labelWrap.']); 01866 $commentCode = $this->stdWrap($confData['label'], $conf['commentWrap.']); // RTF 01867 $result = $conf['layout']; 01868 if ($conf['REQ'] && $confData['required']) { 01869 if (is_array($conf['REQ.']['fieldWrap.'])) 01870 $fieldCode = $this->stdWrap($fieldCode, $conf['REQ.']['fieldWrap.']); 01871 if (is_array($conf['REQ.']['labelWrap.'])) 01872 $labelCode = $this->stdWrap($fieldLabel, $conf['REQ.']['labelWrap.']); 01873 if ($conf['REQ.']['layout']) { 01874 $result = $conf['REQ.']['layout']; 01875 } 01876 } 01877 if ($confData['type']=='comment' && $conf['COMMENT.']['layout']) { 01878 $result = $conf['COMMENT.']['layout']; 01879 } 01880 if ($confData['type']=='check' && $conf['CHECK.']['layout']) { 01881 $result = $conf['CHECK.']['layout']; 01882 } 01883 if ($confData['type']=='radio' && $conf['RADIO.']['layout']) { 01884 $result = $conf['RADIO.']['layout']; 01885 } 01886 if ($confData['type']=='label' && $conf['LABEL.']['layout']) { 01887 $result = $conf['LABEL.']['layout']; 01888 } 01889 $result = str_replace('###FIELD###',$fieldCode,$result); 01890 $result = str_replace('###LABEL###',$labelCode,$result); 01891 $result = str_replace('###COMMENT###',$commentCode,$result); //RTF 01892 $content.= $result; 01893 } 01894 } 01895 } 01896 if ($conf['stdWrap.']) $content=$this->stdWrap($content, $conf['stdWrap.']); 01897 01898 01899 // redirect (external: where to go afterwards. internal: where to submit to) 01900 $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) 01901 $page = $GLOBALS['TSFE']->page; 01902 if (!$theRedirect) { // Internal: Just submit to current page 01903 $LD = $GLOBALS['TSFE']->tmpl->linkData($page, $conf['target'], $conf['no_cache'],'index.php', '', $this->getClosestMPvalueForPage($page['uid'])); 01904 } elseif (t3lib_div::testInt($theRedirect)) { // Internal: Submit to page with id $theRedirect 01905 $page = $GLOBALS['TSFE']->sys_page->getPage_noCheck($theRedirect); 01906 $LD = $GLOBALS['TSFE']->tmpl->linkData($page, $conf['target'], $conf['no_cache'],'index.php', '', $this->getClosestMPvalueForPage($page['uid'])); 01907 } else { // External url, redirect-hidden field is rendered! 01908 $LD = $GLOBALS['TSFE']->tmpl->linkData($page, $conf['target'], $conf['no_cache'],'', '', $this->getClosestMPvalueForPage($page['uid'])); 01909 $LD['totalURL'] = $theRedirect; 01910 $hiddenfields.= '<input type="hidden" name="redirect" value="'.htmlspecialchars($LD['totalURL']).'" />'; // 18-09-00 added 01911 } 01912 01913 // Formtype (where to submit to!): 01914 $formtype = $propertyOverride['type'] ? $propertyOverride['type'] : $this->stdWrap($conf['type'], $conf['type.']); 01915 if (t3lib_div::testInt($formtype)) { // Submit to a specific page 01916 $page = $GLOBALS['TSFE']->sys_page->getPage_noCheck($formtype); 01917 $LD_A = $GLOBALS['TSFE']->tmpl->linkData($page, $conf['target'], $conf['no_cache'], '', '', $this->getClosestMPvalueForPage($page['uid'])); 01918 $action = $LD_A['totalURL']; 01919 } elseif ($formtype){ // Submit to external script 01920 $LD_A = $LD; 01921 $action = $formtype; 01922 } elseif (t3lib_div::testInt($theRedirect)) { 01923 $LD_A = $LD; 01924 $action = $LD_A['totalURL']; 01925 } else { // Submit to 'nothing' - which is current page 01926 $LD_A = $GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page, $conf['target'], $conf['no_cache'], '', '', $this->getClosestMPvalueForPage($page['uid'])); 01927 $action = $LD_A['totalURL']; 01928 } 01929 01930 // Recipient: 01931 $theEmail = $this->stdWrap($conf['recipient'], $conf['recipient.']); 01932 if ($theEmail && !$GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail']) { 01933 $theEmail = $GLOBALS['TSFE']->codeString($theEmail); 01934 $hiddenfields.='<input type="hidden" name="recipient" value="'.htmlspecialchars($theEmail).'" />'; 01935 } 01936 01937 // location data: 01938 if ($conf['locationData']) { 01939 if ($conf['locationData']=='HTTP_POST_VARS' && isset($_POST['locationData'])) { 01940 $locationData = t3lib_div::_POST('locationData'); 01941 } else { 01942 $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. 01943 } 01944 $hiddenfields.='<input type="hidden" name="locationData" value="'.htmlspecialchars($locationData).'" />'; 01945 } 01946 01947 // hidden fields: 01948 if (is_array($conf['hiddenFields.'])) { 01949 reset($conf['hiddenFields.']); 01950 while(list($hF_key,$hF_conf) = each($conf['hiddenFields.'])) { 01951 if (substr($hF_key,-1)!='.') { 01952 $hF_value = $this->cObjGetSingle($hF_conf,$conf['hiddenFields.'][$hF_key.'.'],'hiddenfields'); 01953 if (strlen($hF_value) && t3lib_div::inList('recipient_copy,recipient',$hF_key)) { 01954 if($GLOBALS['TYPO3_CONF_VARS']['FE']['secureFormmail']) { 01955 continue; 01956 } 01957 $hF_value = $GLOBALS['TSFE']->codeString($hF_value); 01958 } 01959 $hiddenfields.='<input type="hidden" name="'.$hF_key.'" value="'.htmlspecialchars($hF_value).'" />'; 01960 } 01961 } 01962 } 01963 01964 // Wrap all hidden fields in a div tag (see http://bugs.typo3.org/view.php?id=678) 01965 $hiddenfields = '<div style="display:none;">'.$hiddenfields.'</div>'; 01966 01967 if ($conf['REQ']) { 01968 $validateForm=' onsubmit="return validateForm(\''.$formname.'\',\''.implode(',',$fieldlist).'\',\''.rawurlencode($conf['goodMess']).'\',\''.rawurlencode($conf['badMess']).'\',\''.rawurlencode($conf['emailMess']).'\')"'; 01969 $GLOBALS['TSFE']->additionalHeaderData['JSFormValidate'] = '<script type="text/javascript" src="'.$GLOBALS['TSFE']->absRefPrefix.'t3lib/jsfunc.validateform.js"></script>'; 01970 } else $validateForm=''; 01971 01972 // Create form tag: 01973 $theTarget = ($theRedirect?$LD['target']:$LD_A['target']); 01974 $content = Array( 01975 '<form'. 01976 ' action="'.htmlspecialchars($action).'"'. 01977 ' name="'.$formname.'"'. 01978 ' enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'"'. 01979 ' method="'.($conf['method']?$conf['method']:'post').'"'. 01980 ($theTarget ? ' target="'.$theTarget.'"' : ''). 01981 $validateForm. 01982 '>', 01983 $hiddenfields.$content, 01984 '</form>' 01985 ); 01986 if ($conf['arrayReturnMode']) { 01987 $content['validateForm']=$validateForm; 01988 $content['formname']=$formname; 01989 return $content; 01990 } else { 01991 return implode('',$content); 01992 } 01993 } 01994 02002 function SEARCHRESULT($conf) { 02003 if (t3lib_div::_GP('sword') && t3lib_div::_GP('scols')) { 02004 $search = t3lib_div::makeInstance('tslib_search'); 02005 $search->register_and_explode_search_string(t3lib_div::_GP('sword')); 02006 $search->register_tables_and_columns(t3lib_div::_GP('scols'),$conf['allowedCols']); 02007 // depth 02008 $depth=100; 02009 // the startId is found 02010 $theStartId=0; 02011 if (t3lib_div::testInt(t3lib_div::_GP('stype'))) { 02012 $temp_theStartId=t3lib_div::_GP('stype'); 02013 $rootLine = $GLOBALS['TSFE']->sys_page->getRootLine($temp_theStartId); 02014 // The page MUST have a rootline with the Level0-page of the current site inside!! 02015 while(list(,$val)=each($rootLine)) { 02016 if($val['uid']==$GLOBALS['TSFE']->tmpl->rootLine[0]['uid']) { 02017 $theStartId=$temp_theStartId; 02018 } 02019 } 02020 } else if (t3lib_div::_GP('stype')) { 02021 if (substr(t3lib_div::_GP('stype'),0,1)=='L') { 02022 $pointer = intval(substr(t3lib_div::_GP('stype'),1)); 02023 $theRootLine = $GLOBALS['TSFE']->tmpl->rootLine; 02024 // location Data: 02025 $locDat_arr = explode(':',t3lib_div::_POST('locationData')); 02026 $pId = intval($locDat_arr[0]); 02027 if ($pId) { 02028 $altRootLine = $GLOBALS['TSFE']->sys_page->getRootLine($pId); 02029 ksort($altRootLine); 02030 if (count($altRootLine)) { 02031 // check if the rootline has the real Level0 in it!! 02032 reset($altRootLine); 02033 $hitRoot=0; 02034 $theNewRoot=array(); 02035 while(list(,$val)=each($altRootLine)) { 02036 if($hitRoot || $val['uid']==$GLOBALS['TSFE']->tmpl->rootLine[0]['uid']) { 02037 $hitRoot=1; 02038 $theNewRoot[]=$val; 02039 } 02040 } 02041 if ($hitRoot) { 02042 $theRootLine = $theNewRoot; // Override the real rootline if any thing 02043 } 02044 } 02045 } 02046 $key = $this->getKey($pointer,$theRootLine); 02047 $theStartId = $theRootLine[$key]['uid']; 02048 } 02049 } 02050 if (!$theStartId) { 02051 // If not set, we use current page 02052 $theStartId = $GLOBALS['TSFE']->id; 02053 } 02054 // generate page-tree 02055 $search->pageIdList.= $this->getTreeList(-1*$theStartId,$depth); 02056 02057 $endClause = 'pages.uid IN ('.$search->pageIdList.') 02058 AND pages.doktype in ('.$GLOBALS['TYPO3_CONF_VARS']['FE']['content_doktypes'].($conf['addExtUrlsAndShortCuts']?',3,4':'').') 02059 AND pages.no_search=0'. 02060 $this->enableFields($search->fTable). 02061 $this->enableFields('pages'); 02062 02063 if ($conf['languageField.'][$search->fTable]) { 02064 $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!) 02065 } 02066 02067 // build query 02068 $search->build_search_query($endClause); 02069 02070 // count... 02071 if (t3lib_div::testInt(t3lib_div::_GP('scount'))) { 02072 $search->res_count = t3lib_div::_GP('scount'); 02073 } else { 02074 $search->count_query(); 02075 } 02076 02077 // range 02078 $spointer = intval(t3lib_div::_GP('spointer')); 02079 if (isset($conf['range'])) { 02080 $theRange = intval($conf['range']); 02081 } else { 02082 $theRange = 20; 02083 } 02084 02085 // Order By: 02086 if (!$conf['noOrderBy']) { 02087 $search->queryParts['ORDERBY'] = 'pages.lastUpdated, pages.tstamp'; 02088 } 02089 02090 $search->queryParts['LIMIT'] = $spointer.','.$theRange; 02091 02092 // search... 02093 $search->execute_query(); 02094 if ($GLOBALS['TYPO3_DB']->sql_num_rows($search->result)) { 02095 $GLOBALS['TSFE']->register['SWORD_PARAMS'] = $search->get_searchwords(); 02096 02097 $total = $search->res_count; 02098 $rangeLow = t3lib_div::intInRange($spointer+1,1,$total); 02099 $rangeHigh = t3lib_div::intInRange($spointer+$theRange,1,$total); 02100 // prev/next url: 02101 $LD = $GLOBALS['TSFE']->tmpl->linkData($GLOBALS['TSFE']->page,$conf['target'],1,'', '', $this->getClosestMPvalueForPage($GLOBALS['TSFE']->page['uid'])); 02102 $targetPart = $LD['target'] ? ' target="'.htmlspecialchars($LD['target']).'"' : ''; 02103 $urlParams = $this->URLqMark($LD['totalURL'], 02104 '&sword='.rawurlencode(t3lib_div::_GP('sword')). 02105 '&scols='.rawurlencode(t3lib_div::_GP('scols')). 02106 '&stype='.rawurlencode(t3lib_div::_GP('stype')). 02107 '&scount='.$total); 02108 // substitution: 02109 $result= $this->cObjGetSingle($conf['layout'],$conf['layout.'], 'layout'); 02110 $result = str_replace('###RANGELOW###',$rangeLow,$result); 02111 $result = str_replace('###RANGEHIGH###',$rangeHigh,$result); 02112 $result = str_replace('###TOTAL###',$total,$result); 02113 02114 if ($rangeHigh<$total) { 02115 $next = $this->cObjGetSingle($conf['next'], $conf['next.'], 'next'); 02116 $next = '<a href="'.htmlspecialchars($urlParams.'&spointer='.($spointer+$theRange)).'"'.$targetPart.$GLOBALS['TSFE']->ATagParams.'>'.$next.'</a>'; 02117 } else $next=''; 02118 $result = str_replace('###NEXT###',$next,$result); 02119 02120 if ($rangeLow>1) { 02121 $prev = $this->cObjGetSingle($conf['prev'], $conf['prev.'], 'prev'); 02122 $prev = '<a href="'.htmlspecialchars($urlParams.'&spointer='.($spointer-$theRange)).'"'.$targetPart.$GLOBALS['TSFE']->ATagParams.'>'.$prev.'</a>'; 02123 } else $prev=''; 02124 $result = str_replace('###PREV###',$prev,$result); 02125 02126 // searching result 02127 $theValue = $this->cObjGetSingle($conf['resultObj'], $conf['resultObj.'],'resultObj'); 02128 $cObj = t3lib_div::makeInstance('tslib_cObj'); 02129 $cObj->setParent($this->data,$this->currentRecord); 02130 $renderCode=''; 02131 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($search->result)) { 02132 $cObj->start($row); 02133 $renderCode.=$cObj->cObjGetSingle($conf['renderObj'], $conf['renderObj.'],'renderObj'); 02134 } 02135 $theValue.=$this->wrap($renderCode,$conf['renderWrap']); 02136 $theValue = str_replace('###RESULT###',$theValue,$result); 02137 } else { 02138 $theValue = $this->cObjGetSingle($conf['noResultObj'], $conf['noResultObj.'],'noResultObj'); 02139 } 02140 02141 $GLOBALS['TT']->setTSlogMessage('Search in fields: '.$search->listOfSearchFields); 02142 02143 // wrapping 02144 $content=$theValue; 02145 if ($conf['wrap']) { 02146 $content=$this->wrap($content, $conf['wrap']); 02147 } 02148 if ($conf['stdWrap.']) { 02149 $content=$this->stdWrap($content, $conf['stdWrap.']); 02150 } 02151 // returning 02152 $GLOBALS['TSFE']->set_no_cache(); 02153 return $content; 02154 } 02155 } 02156 02167 function PHP_SCRIPT($conf,$ext='') { 02168 $incFile = $GLOBALS['TSFE']->tmpl->getFileName($conf['file']); 02169 $content=''; 02170 if ($incFile && $GLOBALS['TSFE']->checkFileInclude($incFile)) { 02171 switch($ext) { 02172 case 'INT': 02173 case 'EXT': 02174 $substKey = $ext.'_SCRIPT.'.$GLOBALS['TSFE']->uniqueHash(); 02175 $content.='<!--'.$substKey.'-->'; 02176 $GLOBALS['TSFE']->config[$ext.'incScript'][$substKey] = array( 02177 'file'=>$incFile, 02178 'conf'=>$conf, 02179 'type'=>'SCRIPT' 02180 ); 02181 if ($ext=='INT') { 02182 $GLOBALS['TSFE']->config[$ext.'incScript'][$substKey]['cObj'] = serialize($this); 02183 } else { 02184 $GLOBALS['TSFE']->config[$ext.'incScript'][$substKey]['data'] = $this->data; 02185 } 02186 break; 02187 default: 02188 // Added 31-12-00: Make backup... 02189 $this->oldData = $this->data; 02190 // Include file.. 02191 include('./'.$incFile); 02192 // Added 31-12-00: restore... 02193 if ($RESTORE_OLD_DATA) { 02194 $this->data = $this->oldData; 02195 } 02196 break; 02197 } 02198 } 02199 return $content; 02200 } 02201 02210 function TEMPLATE($conf) { 02211 $subparts = Array(); 02212 $marks = Array(); 02213 $wraps = Array(); 02214 $content=''; 02215 02216 list($PRE,$POST) = explode('|',$conf['markerWrap'] ? $conf['markerWrap'] : '### | ###'); 02217 $POST = trim($POST); 02218 $PRE = trim($PRE); 02219 02220 // Getting the content 02221 $content = $this->cObjGetSingle($conf['template'],$conf['template.'],'template'); 02222 if ($conf['workOnSubpart']) { 02223 $content = $this->getSubpart($content, $PRE.$conf['workOnSubpart'].$POST); 02224 } 02225 02226 // Fixing all relative paths found: 02227 if ($conf['relPathPrefix']) { 02228 $htmlParser = t3lib_div::makeInstance('t3lib_parsehtml'); 02229 $content = $htmlParser->prefixResourcePath($conf['relPathPrefix'],$content,$conf['relPathPrefix.']); 02230 } 02231 02232 if ($content) { 02233 if ($conf['nonCachedSubst']) { // NON-CACHED: 02234 // Getting marks 02235 if (is_array($conf['marks.'])) { 02236 reset($conf['marks.']); 02237 while(list($theKey,$theValue)=each($conf['marks.'])) { 02238 if (!strstr($theKey,'.')) { 02239 $content = str_replace( 02240 $PRE.$theKey.$POST, 02241 $this->cObjGetSingle($theValue,$conf['marks.'][$theKey.'.'],'marks.'.$theKey), 02242 $content); 02243 } 02244 } 02245 } 02246 02247 // Getting subparts. 02248 if (is_array($conf['subparts.'])) { 02249 reset($conf['subparts.']); 02250 while(list($theKey,$theValue)=each($conf['subparts.'])) { 02251 if (!strstr($theKey,'.')) { 02252 $subpart = $this->getSubpart($content, $PRE.$theKey.$POST); 02253 if ($subpart) { 02254 $this->setCurrentVal($subpart); 02255 $content = $this->substituteSubpart( 02256 $content, 02257 $PRE.$theKey.$POST, 02258 $this->cObjGetSingle($theValue,$conf['subparts.'][$theKey.'.'],'subparts.'.$theKey), 02259 1 02260 ); 02261 } 02262 } 02263 } 02264 } 02265 // Getting subpart wraps 02266 if (is_array($conf['wraps.'])) { 02267 reset($conf['wraps.']); 02268 while(list($theKey,$theValue)=each($conf['wraps.'])) { 02269 if (!strstr($theKey,'.')) { 02270 $subpart = $this->getSubpart($content, $PRE.$theKey.$POST); 02271 if ($subpart) { 02272 $this->setCurrentVal($subpart); 02273 $content = $this->substituteSubpart( 02274 $content, 02275 $PRE.$theKey.$POST, 02276 explode('|',$this->cObjGetSingle($theValue,$conf['wraps.'][$theKey.'.'],'wraps.'.$theKey)), 02277 1 02278 ); 02279 } 02280 } 02281 } 02282 } 02283 } else { // CACHED 02284 // Getting subparts. 02285 if (is_array($conf['subparts.'])) { 02286 reset($conf['subparts.']); 02287 while(list($theKey,$theValue)=each($conf['subparts.'])) { 02288 if (!strstr($theKey,'.')) { 02289 $subpart = $this->getSubpart($content, $PRE.$theKey.$POST); 02290 if ($subpart) { 02291 $GLOBALS['TSFE']->register['SUBPART_'.$theKey] = $subpart; 02292 $subparts[$theKey]['name'] = $theValue; 02293 $subparts[$theKey]['conf'] = $conf['subparts.'][$theKey.'.']; 02294 } 02295 } 02296 } 02297 } 02298 // Getting marks 02299 if (is_array($conf['marks.'])) { 02300 reset($conf['marks.']); 02301 while(list($theKey,$theValue)=each($conf['marks.'])) { 02302 if (!strstr($theKey,'.')) { 02303 $marks[$theKey]['name'] = $theValue; 02304 $marks[$theKey]['conf'] = $conf['marks.'][$theKey.'.']; 02305 } 02306 } 02307 } 02308 // Getting subpart wraps 02309 if (is_array($conf['wraps.'])) { 02310 reset($conf['wraps.']); 02311 while(list($theKey,$theValue)=each($conf['wraps.'])) { 02312 if (!strstr($theKey,'.')) { 02313 $wraps[$theKey]['name'] = $theValue; 02314 $wraps[$theKey]['conf'] = $conf['wraps.'][$theKey.'.']; 02315 } 02316 } 02317 } 02318 // Getting subparts 02319 $subpartArray =array(); 02320 reset($subparts); 02321 while(list($theKey,$theValue)=each($subparts)) { 02322 // Set current with the content of the subpart... 02323 $this->data[$this->currentValKey] = $GLOBALS['TSFE']->register['SUBPART_'.$theKey]; 02324 // Get subpart cObject and substitute it! 02325 $subpartArray[$PRE.$theKey.$POST] = $this->cObjGetSingle($theValue['name'],$theValue['conf'],'subparts.'.$theKey); 02326 } 02327 $this->data[$this->currentValKey] = ''; // Reset current to empty 02328 02329 // Getting marks 02330 $markerArray =array(); 02331 reset($marks); 02332 while(list($theKey,$theValue)=each($marks)) { 02333 $markerArray[$PRE.$theKey.$POST] = $this->cObjGetSingle($theValue['name'],$theValue['conf'],'marks.'.$theKey); 02334 } 02335 // Getting wraps 02336 $subpartWraps =array(); 02337 reset($wraps); 02338 while(list($theKey,$theValue)=each($wraps)) { 02339 $subpartWraps[$PRE.$theKey.$POST] = explode('|',$this->cObjGetSingle($theValue['name'],$theValue['conf'],'wraps.'.$theKey)); 02340 } 02341 02342 // Substitution 02343 if ($conf['substMarksSeparately']) { 02344 $content = $this->substituteMarkerArrayCached($content,array(),$subpartArray,$subpartWraps); 02345 $content = $this->substituteMarkerArray($content, $markerArray); 02346 } else { 02347 $content = $this->substituteMarkerArrayCached($content,$markerArray,$subpartArray,$subpartWraps); 02348 } 02349 } 02350 } 02351 return $content; 02352 } 02353 02361 function MULTIMEDIA($conf) { 02362 $content=''; 02363 $filename=$this->stdWrap($conf['file'],$conf['file.']); 02364 $incFile = $GLOBALS['TSFE']->tmpl->getFileName($filename); 02365 if ($incFile) { 02366 $fileinfo = t3lib_div::split_fileref($incFile); 02367 if (t3lib_div::inList('txt,html,htm',$fileinfo['fileext'])) { 02368 $content = $GLOBALS['TSFE']->tmpl->fileContent($incFile); 02369 } else { 02370 // default params... 02371 $parArray=array(); 02372 // src is added 02373 $parArray['src']='src="'.$GLOBALS['TSFE']->absRefPrefix.$incFile.'"'; 02374 if (t3lib_div::inList('au,wav,mp3',$fileinfo['fileext'])) { 02375 } 02376 if (t3lib_div::inList('avi,mov,mpg,asf,wmv',$fileinfo['fileext'])) { 02377 $parArray['width'] = 'width="200"'; 02378 $parArray['height'] = 'height="200"'; 02379 } 02380 if (t3lib_div::inList('swf,swa,dcr',$fileinfo['fileext'])) { 02381 $parArray['quality'] = 'quality="high"'; 02382 } 02383 if (t3lib_div::inList('class',$fileinfo['fileext'])) { 02384 $parArray['width'] = 'width="200"'; 02385 $parArray['height'] = 'height="200"'; 02386 } 02387 02388 // fetching params 02389 $lines = explode(chr(10), $this->stdWrap($conf['params'],$conf['params.'])); 02390 while(list(,$l)=each($lines)) { 02391 $parts = explode('=', $l); 02392 $parameter = strtolower(trim($parts[0])); 02393 $value = trim($parts[1]); 02394 if ((string)$value!='') { 02395 $parArray[$parameter] = $parameter.'="'.htmlspecialchars($value).'"'; 02396 } else { 02397 unset($parArray[$parameter]); 02398 } 02399 } 02400 if ($fileinfo['fileext']=='class') { 02401 unset($parArray['src']); 02402 $parArray['code'] = 'code="'.htmlspecialchars($fileinfo['file']).'"'; 02403 $parArray['codebase'] = 'codebase="'.htmlspecialchars($fileinfo['path']).'"'; 02404 $content='<applet '.implode(' ',$parArray).'></applet>'; 02405 } else { 02406 $content='<embed '.implode(' ',$parArray).'></embed>'; 02407 } 02408 } 02409 } 02410 02411 if ($conf['stdWrap.']) { 02412 $content=$this->stdWrap($content, $conf['stdWrap.']); 02413 } 02414 02415 return $content; 02416 } 02417 02418 02419 02420 02421 02422 02423 02424 02425 02426 02427 02428 02429 02430 02431 02432 02433 02434 /************************************ 02435 * 02436 * Various helper functions for content objects: 02437 * 02438 ************************************/ 02439 02450 function netprintApplication_offsiteLinkWrap($str,$imgConf,$conf) { 02451 if ($conf['url'] && @is_file($imgConf['origFile'])) { 02452 $thisUrl = $conf['thisUrl'] ? $conf['thisUrl'] : t3lib_div::getIndpEnv('TYPO3_REQUEST_DIR'); 02453 $origFile=$thisUrl.$imgConf['origFile']; 02454 // Original file dimensions: 02455 $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder'); 02456 $gifCreator->init(); 02457 $origDim = $gifCreator->getImageDimensions($imgConf['origFile']); 02458 if (!$conf['linkOnlyPixelsAbove'] || $origDim[0]*$origDim[1]>$conf['linkOnlyPixelsAbove']) { 02459 // Set parameters 02460 $thumbFile=$thisUrl.$imgConf['3'].'|'.$imgConf[0].'x'.$imgConf[1].'|'.$origDim[0].'x'.$origDim[1].'|'.filesize($imgConf['origFile']).'|'.filemtime($imgConf['origFile']); 02461 // Set url: 02462 $url = $conf['url'] 02463 .'&NP[offsite][1]='.rawurlencode($origFile) 02464 .'&NP[offsite_thumb][1]='.rawurlencode($thumbFile); 02465 $linkCObject = $this->cObjGetSingle($conf['cObject'],$conf['cObject.']); 02466 if ($linkCObject) { 02467 $ATagParams = trim($conf['ATagParams']) ? ' '.trim($conf['ATagParams']) : ''; 02468 $linkCObject='<a href="'.htmlspecialchars($url).'"'.$ATagParams.'>'.$linkCObject.'</a>'; 02469 $linkCObject=$this->stdWrap($linkCObject,$conf['outerStdWrap.']); 02470 if ($conf['before']) { 02471 $str=$linkCObject.$str; 02472 } else { 02473 $str=$str.$linkCObject; 02474 } 02475 } 02476 } 02477 } 02478 return $str; 02479 } 02480 02491 function getFieldDefaultValue($noValueInsert, $fieldName, $defaultVal) { 02492 if (!$GLOBALS['TSFE']->no_cache || (!isset($_POST[$fieldName]) && !isset($_GET[$fieldName])) || $noValueInsert) { 02493 return $defaultVal; 02494 } else { 02495 return t3lib_div::_GP($fieldName); 02496 } 02497 } 02498 02509 function cImage($file,$conf) { 02510 $info = $this->getImgResource($file,$conf['file.']); 02511 $GLOBALS['TSFE']->lastImageInfo=$info; 02512 if (is_array($info)) { 02513 $info[3] = t3lib_div::png_to_gif_by_imagemagick($info[3]); 02514 $GLOBALS['TSFE']->imagesOnPage[]=$info[3]; // This array is used to collect the image-refs on the page... 02515 02516 if (!strlen($conf['altText']) && !is_array($conf['altText.'])) { // Backwards compatible: 02517 $conf['altText'] = $conf['alttext']; 02518 $conf['altText.'] = $conf['alttext.']; 02519 } 02520 $altParam = $this->getAltParam($conf); 02521 02522 $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).' />'; 02523 if ($conf['linkWrap']) { 02524 $theValue = $this->linkWrap($theValue,$conf['linkWrap']); 02525 } elseif ($conf['imageLinkWrap']) { 02526 $theValue = $this->imageLinkWrap($theValue,$info['origFile'],$conf['imageLinkWrap.']); 02527 } 02528 return $this->wrap($theValue,$conf['wrap']); 02529 } 02530 } 02537 function getBorderAttr($borderAttr) { 02538 if (!t3lib_div::inList('xhtml_strict,xhtml_11,xhtml_2',$GLOBALS['TSFE']->config['config']['doctype']) && !$GLOBALS['TSFE']->config['config']['disableImgBorderAttr']) { 02539 return $borderAttr; 02540 } 02541 } 02542 02553 function imageLinkWrap($string,$imageFile,$conf) { 02554 $a1=''; 02555 $a2=''; 02556 $content=$string; 02557 if ($this->stdWrap($conf['enable'],$conf['enable.'])) { 02558 $content=$this->typolink($string, $conf['typolink.']); 02559 // imageFileLink: 02560 if ($content==$string && @is_file($imageFile)) { 02561 $params = ''; 02562 if ($conf['width']) {$params.='&width='.rawurlencode($conf['width']);} 02563 if ($conf['height']) {$params.='&height='.rawurlencode($conf['height']);} 02564 if ($conf['effects']) {$params.='&effects='.rawurlencode($conf['effects']);} 02565 if ($conf['sample']) {$params.='&sample=1';} 02566 if ($conf['alternativeTempPath']) {$params.='&alternativeTempPath='.rawurlencode($conf['alternativeTempPath']);} 02567 02568 if ($conf['bodyTag']) {$params.='&bodyTag='.rawurlencode($conf['bodyTag']);} 02569 if ($conf['title']) {$params.='&title='.rawurlencode($conf['title']);} 02570 if ($conf['wrap']) {$params.='&wrap='.rawurlencode($conf['wrap']);} 02571 02572 $md5_value = md5( 02573 $imageFile.'|'. 02574 $conf['width'].'|'. 02575 $conf['height'].'|'. 02576 $conf['effects'].'|'. 02577 $conf['bodyTag'].'|'. 02578 $conf['title'].'|'. 02579 $conf['wrap'].'|'. 02580 $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'].'|'); 02581 02582 $params.= '&md5='.$md5_value; 02583 $url = $GLOBALS['TSFE']->absRefPrefix.'showpic.php?file='.rawurlencode($imageFile).$params; 02584 if ($conf['JSwindow.']['altUrl'] || $conf['JSwindow.']['altUrl.']) { 02585 $altUrl = $this->stdWrap($conf['JSwindow.']['altUrl'], $conf['JSwindow.']['altUrl.']); 02586 if ($altUrl) { 02587 $url=$altUrl; 02588 } 02589 } 02590 02591 if ($conf['JSwindow']) { 02592 $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder'); 02593 $gifCreator->init(); 02594 $gifCreator->mayScaleUp = 0; 02595 $dims = $gifCreator->getImageScale($gifCreator->getImageDimensions($imageFile),$conf['width'],$conf['height'],''); 02596 $offset = t3lib_div::intExplode(',',$conf['JSwindow.']['expand'].','); 02597 02598 $a1='<a href="#" onclick="'. 02599 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;'). 02600 '"'.$GLOBALS['TSFE']->ATagParams.'>'; 02601 $a2='</a>'; 02602 $GLOBALS['TSFE']->setJS('openPic'); 02603 } else { 02604 $target = ' target="thePicture"'; 02605 if (isset($conf['target'])) { 02606 $target= $conf['target'] ? ' target="'.$conf['target'].'"' : ''; 02607 } 02608 $a1='<a href="'.htmlspecialchars($url).'"'.$target.$GLOBALS['TSFE']->ATagParams.'>'; 02609 $a2='</a>'; 02610 } 02611 $content=$a1.$string.$a2; 02612 } 02613 } 02614 02615 return $content; 02616 } 02617 02626 function fileResource($fName, $addParams='alt="" title=""') { 02627 $incFile = $GLOBALS['TSFE']->tmpl->getFileName($fName); 02628 if ($incFile) { 02629 $fileinfo = t3lib_div::split_fileref($incFile); 02630 if (t3lib_div::inList('jpg,gif,jpeg,png',$fileinfo['fileext'])) { 02631 $imgFile = $incFile; 02632 $imgInfo = @getImageSize($imgFile); 02633 return '<img src="'.$GLOBALS['TSFE']->absRefPrefix.$imgFile.'" width="'.$imgInfo[0].'" height="'.$imgInfo[1].'"'.$this->getBorderAttr(' border="0"').' '.$addParams.' />'; 02634 } elseif (filesize($incFile)<1024*1024) { 02635 return $GLOBALS['TSFE']->tmpl->fileContent($incFile); 02636 } 02637 } 02638 } 02639 02649 function lastChanged($tstamp) { 02650 $tstamp = intval($tstamp); 02651 if ($tstamp>intval($GLOBALS['TSFE']->register['SYS_LASTCHANGED'])) { 02652 $GLOBALS['TSFE']->register['SYS_LASTCHANGED'] = $tstamp; 02653 } 02654 } 02655 02666 function linkWrap($content,$wrap) { 02667 $wrapArr = explode('|', $wrap); 02668 if (ereg("\{([0-9]*)\}",$wrapArr[0],$reg)) { 02669 if ($uid = $GLOBALS['TSFE']->tmpl->rootLine[$reg[1]]['uid']) { 02670 $wrapArr[0] = str_replace($reg[0],$uid,$wrapArr[0]); 02671 } 02672 } 02673 return trim($wrapArr[0]).$content.trim($wrapArr[1]); 02674 } 02675 02684 function getAltParam($conf) { 02685 $altText = trim($this->stdWrap($conf['altText'], $conf['altText.'])); 02686 $titleText = trim($this->stdWrap($conf['titleText'],$conf['titleText.'])); 02687 $longDesc = trim($this->stdWrap($conf['longdescURL'],$conf['longdescURL.'])); 02688 02689 // "alt": 02690 $altParam = ' alt="'.htmlspecialchars(strip_tags($altText)).'"'; 02691 02692 // "title": 02693 if ($titleText) { 02694 $altParam.= ' title="'.htmlspecialchars(strip_tags($titleText)).'"'; 02695 } else { 02696 $altParam.= ' title="'.htmlspecialchars(strip_tags($altText)).'"'; 02697 } 02698 02699 // "longDesc" URL 02700 if ($longDesc) { 02701 $altParam.= ' longdesc="'.htmlspecialchars($longDesc).'"'; 02702 } 02703 02704 return $altParam; 02705 } 02706 02707 02708 02709 02710 02711 02712 02713 02714 02715 02716 02717 02718 02719 02720 02721 02722 02723 02724 02725 /*********************************************** 02726 * 02727 * HTML template processing functions 02728 * 02729 ***********************************************/ 02730 02741 function getSubpart($content, $marker) { 02742 if ($marker && strstr($content,$marker)) { 02743 $start = strpos($content, $marker)+strlen($marker); 02744 $stop = @strpos($content, $marker, $start+1); 02745 $sub = substr($content, $start, $stop-$start); 02746 02747 $reg=Array(); 02748 ereg('^[^<]*-->',$sub,$reg); 02749 $start+=strlen($reg[0]); 02750 02751 $reg=Array(); 02752 ereg('<!--[^>]*$',$sub,$reg); 02753 $stop-=strlen($reg[0]); 02754 02755 return substr($content, $start, $stop-$start); 02756 } 02757 } 02758 02770 function substituteSubpart($content,$marker,$subpartContent,$recursive=1) { 02771 $start = strpos($content, $marker); 02772 $stop = @strpos($content, $marker, $start+1)+strlen($marker); 02773 if ($start && $stop>$start) { 02774 // code before 02775 $before = substr($content, 0, $start); 02776 $reg=Array(); 02777 ereg('<!--[^>]*$',$before,$reg); 02778 $start-=strlen($reg[0]); 02779 $before = substr($content, 0, $start); 02780 // code after 02781 $after = substr($content, $stop); 02782 $reg=Array(); 02783 ereg('^[^<]*-->',$after,$reg); 02784 $stop+=strlen($reg[0]); 02785 $after = substr($content, $stop); 02786 // replace? 02787 if (is_array($subpartContent)) { 02788 $substContent=$subpartContent[0].$this->getSubpart($content,$marker).$subpartContent[1]; 02789 } else { 02790 $substContent=$subpartContent; 02791 } 02792 02793 if ($recursive && strpos($after, $marker)) { 02794 return $before.$substContent.$this->substituteSubpart($after,$marker,$subpartContent); 02795 } else { 02796 return $before.$substContent.$after; 02797 } 02798 } else { 02799 return $content; 02800 } 02801 } 02802 02812 function substituteMarker($content,$marker,$markContent) { 02813 return str_replace($marker,$markContent,$content); 02814 } 02815 02832 function substituteMarkerArrayCached($content,$markContentArray=array(),$subpartContentArray=array(),$wrappedSubpartContentArray=array()) { 02833 $GLOBALS['TT']->push('/substituteMarkerArray/'); 02834 02835 // If not arrays then set them 02836 if (!is_array($markContentArray)) $markContentArray=array(); // Plain markers 02837 if (!is_array($subpartContentArray)) $subpartContentArray=array(); // Subparts being directly substituted 02838 if (!is_array($wrappedSubpartContentArray)) $wrappedSubpartContentArray=array(); // Subparts being wrapped 02839 // Finding keys and check hash: 02840 $sPkeys = array_keys($subpartContentArray); 02841 $wPkeys = array_keys($wrappedSubpartContentArray); 02842 $aKeys = array_merge(array_keys($markContentArray),$sPkeys,$wPkeys); 02843 if (!count($aKeys)) { 02844 $GLOBALS['TT']->pull(); 02845 return $content; 02846 } 02847 asort($aKeys); 02848 $storeKey = md5('substituteMarkerArrayCached_storeKey:'.serialize(array($content,$aKeys))); 02849 if ($this->substMarkerCache[$storeKey]) { 02850 $storeArr = $this->substMarkerCache[$storeKey]; 02851 $GLOBALS['TT']->setTSlogMessage('Cached',0); 02852 } else { 02853 $storeArrDat = $GLOBALS['TSFE']->sys_page->getHash($storeKey,0); 02854 if (!isset($storeArrDat)) { 02855 // Initialize storeArr 02856 $storeArr=array(); 02857 02858 // Finding subparts and substituting them with the subpart as a marker 02859 reset($sPkeys); 02860 while(list(,$sPK)=each($sPkeys)) { 02861 $content =$this->substituteSubpart($content,$sPK,$sPK); 02862 } 02863 02864 // Finding subparts and wrapping them with markers 02865 reset($wPkeys); 02866 while(list(,$wPK)=each($wPkeys)) { 02867 $content =$this->substituteSubpart($content,$wPK,array($wPK,$wPK)); 02868 } 02869 02870 // traverse keys and quote them for reg ex. 02871 reset($aKeys); 02872 while(list($tK,$tV)=each($aKeys)) { 02873 $aKeys[$tK]=quotemeta($tV); 02874 } 02875 $regex = implode('|',$aKeys); 02876 // Doing regex's 02877 $storeArr['c'] = split($regex,$content); 02878 preg_match_all('/'.$regex.'/',$content,$keyList); 02879 $storeArr['k']=$keyList[0]; 02880 // Setting cache: 02881 $this->substMarkerCache[$storeKey] = $storeArr; 02882 02883 // Storing the cached data: 02884 $GLOBALS['TSFE']->sys_page->storeHash($storeKey, serialize($storeArr), 'substMarkArrayCached'); 02885 02886 $GLOBALS['TT']->setTSlogMessage('Parsing',0); 02887 } else { 02888 // Unserializing 02889 $storeArr = unserialize($storeArrDat); 02890 // Setting cache: 02891 $this->substMarkerCache[$storeKey] = $storeArr; 02892 $GLOBALS['TT']->setTSlogMessage('Cached from DB',0); 02893 } 02894 } 02895 02896 // Substitution/Merging: 02897 // Merging content types together, resetting 02898 $valueArr = array_merge($markContentArray,$subpartContentArray,$wrappedSubpartContentArray); 02899 02900 $wSCA_reg=array(); 02901 reset($storeArr['k']); 02902 $content = ''; 02903 // traversin the keyList array and merging the static and dynamic content 02904 while(list($n,$keyN)=each($storeArr['k'])) { 02905 $content.=$storeArr['c'][$n]; 02906 if (!is_array($valueArr[$keyN])) { 02907 $content.=$valueArr[$keyN]; 02908 } else { 02909 $content.=$valueArr[$keyN][(intval($wSCA_reg[$keyN])%2)]; 02910 $wSCA_reg[$keyN]++; 02911 } 02912 } 02913 $content.=$storeArr['c'][count($storeArr['k'])]; 02914 02915 $GLOBALS['TT']->pull(); 02916 return $content; 02917 } 02918 02930 function substituteMarkerArray($content,$markContentArray,$wrap='',$uppercase=0) { 02931 if (is_array($markContentArray)) { 02932 reset($markContentArray); 02933 $wrapArr=t3lib_div::trimExplode('|',$wrap); 02934 while(list($marker,$markContent)=each($markContentArray)) { 02935 if($uppercase) $marker=strtoupper($marker); 02936 if(strcmp($wrap,'')) $marker=$wrapArr[0].$marker.$wrapArr[1]; 02937 $content=str_replace($marker,$markContent,$content); 02938 } 02939 } 02940 return $content; 02941 } 02942 02951 function substituteMarkerInObject(&$tree, $markContentArray) { 02952 if (is_array ($tree)) { 02953 reset($tree); 02954 while(list($key,$value)=each($tree)) { 02955 $this->substituteMarkerInObject ($tree[$key], $markContentArray); 02956 } 02957 } else { 02958 $tree = $this->substituteMarkerArray($tree,$markContentArray); 02959 } 02960 return $tree; 02961 } 02962 02974 function fillInMarkerArray($markContentArray, $row, $fieldList='', $nl2br=TRUE, $prefix='FIELD_', $HSC=FALSE) { 02975 if ($fieldList) { 02976 $fArr = t3lib_div::trimExplode(',',$fieldList,1); 02977 foreach($fArr as $field) { 02978 $markContentArray['###'.$prefix.$field.'###'] = $nl2br?nl2br($row[$field]):$row[$field]; 02979 } 02980 } else { 02981 if (is_array($row)) { 02982 foreach($row as $field => $value) { 02983 if (!t3lib_div::testInt($field)) { 02984 if ($HSC) $value = htmlspecialchars($value); 02985 $markContentArray['###'.$prefix.$field.'###'] = $nl2br ? nl2br($value) : $value; 02986 } 02987 } 02988 } 02989 } 02990 02991 return $markContentArray; 02992 } 02993 02994 02995 02996 02997 02998 02999 03000 03001 03002 03003 03004 03005 03006 03007 03008 03009 03010 03011 03012 03013 03014 03015 03016 03017 03018 /*********************************************** 03019 * 03020 * "stdWrap" + sub functions 03021 * 03022 ***********************************************/ 03023 03024 03037 function stdWrap($content,$conf) { 03038 if (is_array($conf)) { 03039 03040 // Setting current value, if so 03041 if ($conf['setContentToCurrent']){$this->data[$this->currentValKey]=$content;} 03042 if ($conf['setCurrent'] || $conf['setCurrent.']){$this->data[$this->currentValKey] = $this->stdWrap($conf['setCurrent'], $conf['setCurrent.']);} 03043 03044 // Getting data: 03045 if (isset($conf['lang.']) && $GLOBALS['TSFE']->config['config']['language'] && isset($conf['lang.'][$GLOBALS['TSFE']->config['config']['language']])) { 03046 $content = $conf['lang.'][$GLOBALS['TSFE']->config['config']['language']]; 03047 } 03048 if ($conf['data']){$content=$this->getData($conf['data'], is_array($this->alternativeData)?$this->alternativeData:$this->data);} 03049 $this->alternativeData=''; // This must be unset directly after 03050 if ($conf['field']) {$content=$this->getFieldVal($conf['field']);} 03051 if ($conf['current']) {$content=$this->data[$this->currentValKey];} 03052 if ($conf['cObject']) {$content=$this->cObjGetSingle($conf['cObject'],$conf['cObject.'],'/stdWrap/.cObject');} 03053 if ($conf['numRows.']) {$content=$this->numRows($conf['numRows.']);} 03054 if ($conf['filelist'] || $conf['filelist.']) {$content=$this->filelist($this->stdWrap($conf['filelist'], $conf['filelist.']));} 03055 if ($conf['preUserFunc']) {$content = $this->callUserFunction($conf['preUserFunc'], $conf['preUserFunc.'], $content);} 03056 03057 // Overriding values, evaluating conditions 03058 if ($conf['override'] || $conf['override.']){ 03059 $override = $this->stdWrap($conf['override'], $conf['override.']); 03060 if (trim($override)) {$content=$override;} 03061 } 03062 if (isset($conf['preIfEmptyListNum']) || isset($conf['preIfEmptyListNum.']['stdWrap.'])) { 03063 $preIfEmptyListNumber = isset($conf['preIfEmptyListNum.']['stdWrap.']) ? $this->stdWrap($conf['preIfEmptyListNum'], $conf['preIfEmptyListNum.']['stdWrap.']) : $conf['preIfEmptyListNum']; 03064 $content=$this->listNum($content,$preIfEmptyListNumber,$conf['preIfEmptyListNum.']['splitChar']); 03065 } 03066 if (!trim($content) && ($conf['ifEmpty'] || $conf['ifEmpty.'])){ $content = $this->stdWrap($conf['ifEmpty'], $conf['ifEmpty.']);} 03067 03068 03069 // values... 03070 if (isset($conf['listNum']) || isset($conf['listNum.']['stdWrap.'])) { 03071 $listNumber = isset($conf['listNum.']['stdWrap.']) ? $this->stdWrap($conf['listNum'], $conf['listNum.']['stdWrap.']) : $conf['listNum']; 03072 $content=$this->listNum($content,$listNumber,$conf['listNum.']['splitChar']); 03073 } 03074 03075 if ($conf['trim']) { $content=trim($content); } 03076 03077 // Call stdWrap recursively 03078 if ($conf['stdWrap']) { $content=$this->stdWrap($content,$conf['stdWrap.']); } 03079 03080 if ( ($conf['required'] && (string)$content=='') || ($conf['if.'] && !$this->checkIf($conf['if.'])) || ($conf['fieldRequired'] && !trim($this->data[$conf['fieldRequired']])) ){ 03081 $content = ''; 03082 } else { 03083 // Perform data processing: 03084 if ($conf['csConv']) { $content=$GLOBALS['TSFE']->csConv($content,$conf['csConv']); } 03085 if ($conf['parseFunc.'] || $conf['parseFunc']) {$content=$this->parseFunc($content,$conf['parseFunc.'],$conf['parseFunc']);} 03086 if ($conf['HTMLparser'] && is_array($conf['HTMLparser.'])) {$content=$this->HTMLparser_TSbridge($content,$conf['HTMLparser.']);} 03087 if ($conf['split.']){$content=$this->splitObj($content,$conf['split.']);} 03088 if ($conf['prioriCalc']){$content=t3lib_div::calcParenthesis($content); if ($conf['prioriCalc']=='intval') $content=intval($content);} 03089 if ((string)$conf['char']!=''){$content=chr(intval($conf['char']));} 03090 if ($conf['intval']){$content=intval($content);} 03091 if ($conf['date']){$content=date($conf['date'], $content);} 03092 if ($conf['strftime']){ 03093 $content = strftime($conf['strftime'], $content); 03094 $tmp_charset = $conf['strftime.']['charset'] ? $conf['strftime.']['charset'] : $GLOBALS['TSFE']->localeCharset; 03095 if ($tmp_charset) { 03096 $content = $GLOBALS['TSFE']->csConv($content,$tmp_charset); 03097 } 03098 } 03099 if ($conf['age']){$content=$this->calcAge(time()-$content,$conf['age']);} 03100 03101 if ($conf['case']){$content=$this->HTMLcaseshift($content, $conf['case']);} 03102 if ($conf['bytes']){$content=$this->bytes($content,$conf['bytes.']['labels']);} 03103 if ($conf['substring']){$content=$this->substring($content,$conf['substring']);} 03104 if ($conf['removeBadHTML']) {$content = $this->removeBadHTML($content, $conf['removeBadHTML.']);} 03105 if ($conf['stripHtml']){$content = strip_tags($content);} 03106 if ($conf['crop']){$content=$this->crop($content, $conf['crop']);} 03107 if ($conf['rawUrlEncode']){$content = rawurlencode($content);} 03108 if ($conf['htmlSpecialChars']){ 03109 $content=htmlSpecialChars($content); 03110 if ($conf['htmlSpecialChars.']['preserveEntities']) $content = t3lib_div::deHSCentities($content); 03111 } 03112 03113 if ($conf['doubleBrTag']) { 03114 $content=ereg_replace("\r?\n[\t ]*\r?\n",$conf['doubleBrTag'],$content); 03115 } 03116 if ($conf['br']) {$content=nl2br($content);} 03117 if ($conf['brTag']) {$content= ereg_replace(chr(10),$conf['brTag'],$content);} 03118 if ($conf['encapsLines.']) {$content=$this->encaps_lineSplit($content,$conf['encapsLines.']);} 03119 if ($conf['keywords']) {$content= $this->keywords($content);} 03120 if ($conf['innerWrap'] || $conf['innerWrap.']){$content=$this->wrap($content, $this->stdWrap($conf['innerWrap'], $conf['innerWrap.']));} 03121 if ($conf['innerWrap2'] || $conf['innerWrap2.']){$content=$this->wrap($content, $this->stdWrap($conf['innerWrap2'], $conf['innerWrap2.']));} 03122 if ($conf['fontTag']){$content=$this->wrap($content, $conf['fontTag']);} 03123 if ($conf['addParams.']) {$content=$this->addParams($content,$conf['addParams.']);} 03124 if ($conf['textStyle.']) {$content=$this->textStyle($content,$conf['textStyle.']);} 03125 if ($conf['tableStyle.']) {$content=$this->tableStyle($content,$conf['tableStyle.']);} 03126 if ($conf['filelink.']) {$content=$this->filelink($content,$conf['filelink.']);} 03127 if ($conf['preCObject']) {$content=$this->cObjGetSingle($conf['preCObject'],$conf['preCObject.'],'/stdWrap/.preCObject').$content;} 03128 if ($conf['postCObject']) {$content.=$this->cObjGetSingle($conf['postCObject'],$conf['postCObject.'],'/stdWrap/.postCObject');} 03129 03130 if ($conf['wrapAlign'] || $conf['wrapAlign.']){ 03131 $wrapAlign = trim($this->stdWrap($conf['wrapAlign'], $conf['wrapAlign.'])); 03132 if ($wrapAlign) {$content=$this->wrap($content, '<div style="text-align:'.$wrapAlign.';">|</div>');} 03133 } 03134 if ($conf['typolink.']){$content=$this->typolink($content, $conf['typolink.']);} 03135 03136 // Spacing 03137 if ($conf['space']){$content=$this->wrapSpace($content, $conf['space']);} 03138 $spaceBefore = ''; 03139 if ($conf['spaceBefore'] || $conf['spaceBefore.']) {$spaceBefore = trim($this->stdWrap($conf['spaceBefore'], $conf['spaceBefore.']));} 03140 $spaceAfter = ''; 03141 if ($conf['spaceAfter'] || $conf['spaceAfter.']) {$spaceAfter = trim($this->stdWrap($conf['spaceAfter'], $conf['spaceAfter.']));} 03142 if ($spaceBefore || $spaceAfter) {$content=$this->wrapSpace($content, $spaceBefore.'|'.$spaceAfter);} 03143 03144 // Wraps 03145 if ($conf['wrap']){$content=$this->wrap($content, $conf['wrap'], ($conf['wrap.']['splitChar']?$conf['wrap.']['splitChar']:'|'));} 03146 if ($conf['noTrimWrap']){$content=$this->noTrimWrap($content, $conf['noTrimWrap']);} 03147 if ($conf['wrap2']){$content=$this->wrap($content, $conf['wrap2'], ($conf['wrap.']['splitChar']?$conf['wrap.']['splitChar']:'|'));} 03148 if ($conf['dataWrap']){$content=$this->dataWrap($content, $conf['dataWrap']);} 03149 if ($conf['prepend']){$content=$this->cObjGetSingle($conf['prepend'],$conf['prepend.'],'/stdWrap/.prepend').$content;} 03150 if ($conf['append']){$content.=$this->cObjGetSingle($conf['append'],$conf['append.'],'/stdWrap/.append');} 03151 if ($conf['wrap3']){$content=$this->wrap($content, $conf['wrap3'], ($conf['wrap.']['splitChar']?$conf['wrap.']['splitChar']:'|'));} 03152 if ($conf['outerWrap'] || $conf['outerWrap.']){$content=$this->wrap($content, $this->stdWrap($conf['outerWrap'], $conf['outerWrap.']));} 03153 if ($conf['insertData']) {$content = $this->insertData($content);} 03154 if ($conf['offsetWrap']){ 03155 $controlTable = t3lib_div::makeInstance('tslib_tableOffset'); 03156 if ($conf['offsetWrap.']['tableParams'] || $conf['offsetWrap.']['tableParams.']) {$controlTable->tableParams = $this->stdWrap($conf['offsetWrap.']['tableParams'], $conf['offsetWrap.']['tableParams.']);} 03157 if ($conf['offsetWrap.']['tdParams'] || $conf['offsetWrap.']['tdParams.']) {$controlTable->tdParams = ' '.$this->stdWrap($conf['offsetWrap.']['tdParams'], $conf['offsetWrap.']['tdParams.']);} 03158 $content=$controlTable->start($content,$conf['offsetWrap']); 03159 if ($conf['offsetWrap.']['stdWrap.']) { $content=$this->stdWrap($content,$conf['offsetWrap.']['stdWrap.']); } 03160 } 03161 if ($conf['postUserFunc']) {$content = $this->callUserFunction($conf['postUserFunc'], $conf['postUserFunc.'], $content);} 03162 if ($conf['postUserFuncInt']) { 03163 $substKey = 'INT_SCRIPT.'.$GLOBALS['TSFE']->uniqueHash(); 03164 $GLOBALS['TSFE']->config['INTincScript'][$substKey] = array( 03165 'content' => $content, 03166 'postUserFunc' => $conf['postUserFuncInt'], 03167 'conf' => $conf['postUserFuncInt.'], 03168 'type' => 'POSTUSERFUNC', 03169 'cObj' => serialize($this), 03170 ); 03171 $content ='<!--'.$substKey.'-->'; 03172 } 03173 // Various: 03174 if ($conf['prefixComment'] && !$GLOBALS['TSFE']->config['config']['disablePrefixComment']) {$content = $this->prefixComment($conf['prefixComment'], $conf['prefixComment.'], $content);} 03175 03176 if ($conf['editIcons'] && $GLOBALS['TSFE']->beUserLogin){$content=$this->editIcons($content,$conf['editIcons'],$conf['editIcons.']);} 03177 if ($conf['editPanel'] && $GLOBALS['TSFE']->beUserLogin){$content=$this->editPanel($content, $conf['editPanel.']);} 03178 } 03179 03180 //Debug: 03181 if ($conf['debug']) {$content = '<pre>'.htmlspecialchars($content).'</pre>';} 03182 if ($conf['debugFunc']) {debug($conf['debugFunc']==2?array($content):$content);} 03183 if ($conf['debugData']) { 03184 echo '<b>$cObj->data:</b>'; 03185 debug($this->data,'$cObj->data:'); 03186 if (is_array($this->alternativeData)) { 03187 echo '<b>$cObj->alternativeData:</b>'; 03188 debug($this->alternativeData,'$this->alternativeData'); 03189 } 03190 } 03191 } 03192 return $content; 03193 } 03194 03206 function numRows($conf) { 03207 $conf['select.']['selectFields'] = 'count(*)'; 03208 03209 $res = $this->exec_getQuery($conf['table'],$conf['select.']); 03210 03211 if ($error = $GLOBALS['TYPO3_DB']->sql_error()) { 03212 $GLOBALS['TT']->setTSlogMessage($error,3); 03213 } else { 03214 $row = $GLOBALS['TYPO3_DB']->sql_fetch_row($res); 03215 return intval($row[0]); 03216 } 03217 } 03218 03227 function listNum($content,$listNum,$char) { 03228 $char = $char ? $char : ','; 03229 if (t3lib_div::testInt($char)) { 03230 $char = chr($char); 03231 } 03232 $temp = explode($char,$content); 03233 $last = ''.(count($temp)-1); 03234 $index=$this->calc(eregi_replace('last',$last,$listNum)); 03235 return $temp[$index]; 03236 } 03237 03247 function checkIf($conf) { 03248 if (!is_array($conf)) {return true;} 03249 if (isset($conf['directReturn'])) {return $conf['directReturn'] ? 1 : 0;} 03250 $flag = true; 03251 if (isset($conf['isTrue']) || isset($conf['isTrue.'])) { 03252 $isTrue = trim($this->stdWrap($conf['isTrue'],$conf['isTrue.'])); 03253 if (!$isTrue) { 03254 $flag=0; 03255 } 03256 } 03257 if (isset($conf['isFalse']) || isset($conf['isFalse.'])) { 03258 $isFalse = trim($this->stdWrap($conf['isFalse'],$conf['isFalse.'])); 03259 if ($isFalse) { 03260 $flag=0; 03261 } 03262 } 03263 if (isset($conf['isPositive']) || isset($conf['isPositive.'])) { 03264 $number = $this->calc($this->stdWrap($conf['isPositive'],$conf['isPositive.'])); 03265 if ($number<1) { 03266 $flag=0; 03267 } 03268 } 03269 if ($flag) { 03270 $value = trim($this->stdWrap($conf['value'],$conf['value.'])); 03271 03272 if (isset($conf['isGreaterThan']) || isset($conf['isGreaterThan.'])) { 03273 $number = trim($this->stdWrap($conf['isGreaterThan'],$conf['isGreaterThan.'])); 03274 if ($number<=$value) { 03275 $flag=0; 03276 } 03277 } 03278 if (isset($conf['isLessThan']) || isset($conf['isLessThan.'])) { 03279 $number = trim($this->stdWrap($conf['isLessThan'],$conf['isLessThan.'])); 03280 if ($number>=$value) { 03281 $flag=0; 03282 } 03283 } 03284 if (isset($conf['equals']) || isset($conf['equals.'])) { 03285 $number = trim($this->stdWrap($conf['equals'],$conf['equals.'])); 03286 if ($number!=$value) { 03287 $flag=0; 03288 } 03289 } 03290 if (isset($conf['isInList']) || isset($conf['isInList.'])) { 03291 $number = trim($this->stdWrap($conf['isInList'],$conf['isInList.'])); 03292 if (!t3lib_div::inList($value,$number)) { 03293 $flag=0; 03294 } 03295 } 03296 } 03297 if ($conf['negate']) {$flag = $flag ? 0 : 1;} 03298 return $flag; 03299 } 03300 03310 function filelist($data) { 03311 $data = trim($data); 03312 if ($data) { 03313 $data_arr = explode('|',$data); 03314 // read directory: 03315 if ($GLOBALS['TSFE']->lockFilePath) { // MUST exist! 03316 $path = $this->clean_directory($data_arr[0]); // Cleaning name..., only relative paths accepted. 03317 $path = substr($path,0,strlen($GLOBALS['TSFE']->lockFilePath))==$GLOBALS['TSFE']->lockFilePath ? $path : ''; 03318 } 03319 if ($path) { 03320 $items = Array('files'=>array(), 'sorting'=>array()); 03321 $ext_list = strtolower(t3lib_div::uniqueList($data_arr[1])); 03322 $sorting = trim($data_arr[2]); 03323 // read dir: 03324 $d = @dir($path); 03325 $tempArray=Array(); 03326 if (is_object($d)) { 03327 $count=0; 03328 while($entry=$d->read()) { 03329 if ($entry!='.' && $entry!='..') { 03330 $wholePath = $path.'/'.$entry; // Because of odd PHP-error where <br />-tag is sometimes placed after a filename!! 03331 if (@file_exists($wholePath) && filetype($wholePath)=='file') { 03332 $info = t3lib_div::split_fileref($wholePath); 03333 if (!$ext_list || t3lib_div::inList($ext_list,$info['fileext'])) { 03334 $items['files'][] = $info['file']; 03335 switch($sorting) { 03336 case 'name': 03337 $items['sorting'][] = strtolower($info['file']); 03338 break; 03339 case 'size': 03340 $items['sorting'][] = filesize($wholePath); 03341 break; 03342 case 'ext': 03343 $items['sorting'][] = $info['fileext']; 03344 break; 03345 case 'date': 03346 $items['sorting'][] = filectime($wholePath); 03347 break; 03348 default: 03349 $items['sorting'][] = $count; 03350 break; 03351 } 03352 $count++; 03353 } 03354 } 03355 } 03356 } 03357 $d->close(); 03358 } 03359 // Sort if required 03360 if (count($items['sorting'])) { 03361 if (strtolower(trim($data_arr[3]))!='r') { 03362 asort($items['sorting']); 03363 } else { 03364 arsort($items['sorting']); 03365 } 03366 } 03367 if (count($items['files'])) { 03368 // make list 03369 reset($items['sorting']); 03370 $fullPath = trim($data_arr[4]); 03371 $list_arr=Array(); 03372 while(list($key,)=each($items['sorting'])) { 03373 $list_arr[]= $fullPath ? $path.'/'.$items['files'][$key] : $items['files'][$key]; 03374 } 03375 return implode(',',$list_arr); 03376 } 03377 } 03378 } 03379 } 03380 03389 function clean_directory($theDir) { 03390 if (t3lib_div::validPathStr($theDir)) { // proceeds if no '//', '..' or '\' is in the $theFile 03391 $theDir = ereg_replace("[\/\. ]*$",'',$theDir); // Removes all dots, slashes and spaces after a path... 03392 if (!t3lib_div::isAbsPath($theDir) && @is_dir($theDir)) { 03393 return $theDir; 03394 } 03395 } 03396 } 03397 03407 function HTMLparser_TSbridge($theValue, $conf) { 03408 $htmlParser = t3lib_div::makeInstance('t3lib_parsehtml'); 03409 $htmlParserCfg = $htmlParser->HTMLparserConfig($conf); 03410 return $htmlParser->HTMLcleaner($theValue,$htmlParserCfg[0],$htmlParserCfg[1],$htmlParserCfg[2],$htmlParserCfg[3]); 03411 } 03412 03421 function dataWrap($content,$wrap) { 03422 return $this->wrap($content,$this->insertData($wrap)); 03423 } 03424 03434 function insertData($str) { 03435 $inside=0; 03436 $newVal=''; 03437 $pointer=0; 03438 $totalLen = strlen($str); 03439 do { 03440 if (!$inside) { 03441 $len = strcspn(substr($str,$pointer),'{'); 03442 $newVal.= substr($str,$pointer,$len); 03443 $inside = 1; 03444 } else { 03445 $len = strcspn(substr($str,$pointer),'}')+1; 03446 $newVal.= $this->getData(substr($str,$pointer+1,$len-2),$this->data); 03447 $inside = 0; 03448 } 03449 $pointer+=$len; 03450 } while($pointer<$totalLen); 03451 return $newVal; 03452 } 03453 03464 function prefixComment($str,$conf,$content) { 03465 $parts = explode('|',$str); 03466 03467 $output = 03468 chr(10).str_pad('',$parts[0],chr(9)). 03469 '<!-- '.htmlspecialchars($this->insertData($parts[1])).' [begin] -->'. 03470 chr(10).str_pad('',$parts[0]+1,chr(9)). 03471 $content. 03472 chr(10).str_pad('',$parts[0],chr(9)). 03473 '<!-- '.htmlspecialchars($this->insertData($parts[1])).' [end] -->'. 03474 chr(10).str_pad('',$parts[0]+1,chr(9)); 03475 03476 return $output; 03477 } 03478 03488 function substring($content,$options) { 03489 $options = t3lib_div::intExplode(',',$options.','); 03490 if ($options[1]) { 03491 return $GLOBALS['TSFE']->csConvObj->substr($GLOBALS['TSFE']->renderCharset,$content,$options[0],$options[1]); 03492 } else { 03493 return $GLOBALS['TSFE']->csConvObj->substr($GLOBALS['TSFE']->renderCharset,$content,$options[0]); 03494 } 03495 } 03496 03506 function crop($content,$options) { 03507 $options = explode('|',$options); 03508 $chars = intval($options[0]); 03509 $afterstring = trim($options[1]); 03510 $crop2space = trim($options[2]); 03511 if ($chars) { 03512 if (strlen($content)>abs($chars)) { 03513 if ($chars<0) { 03514 $content = $GLOBALS['TSFE']->csConvObj->substr($GLOBALS['TSFE']->renderCharset,$content,$chars); 03515 $trunc_at = strpos($content, ' '); 03516 $content = ($trunc_at&&$crop2space) ? $afterstring.substr($content,$trunc_at) : $afterstring.$content; 03517 } else { 03518 $content = $GLOBALS['TSFE']->csConvObj->substr($GLOBALS['TSFE']->renderCharset,$content,0,$chars); 03519 $trunc_at = strrpos($content, ' '); 03520 $content = ($trunc_at&&$crop2space) ? substr($content, 0, $trunc_at).$afterstring : $content.$afterstring; 03521 } 03522 } 03523 } 03524 return $content; 03525 } 03526 03538 function removeBadHTML($text, $conf) { 03539 03540 // Copyright 2002-2003 Thomas Bley 03541 $text = preg_replace( 03542 array( 03543 "'<script[^>]*?>.*?</script[^>]*?>'si", 03544 "'<applet[^>]*?>.*?</applet[^>]*?>'si", 03545 "'<object[^>]*?>.*?</object[^>]*?>'si", 03546 "'<iframe[^>]*?>.*?</iframe[^>]*?>'si", 03547 "'<frameset[^>]*?>.*?</frameset[^>]*?>'si", 03548 "'<style[^>]*?>.*?</style[^>]*?>'si", 03549 "'<marquee[^>]*?>.*?</marquee[^>]*?>'si", 03550 "'<script[^>]*?>'si", 03551 "'<meta[^>]*?>'si", 03552 "'<base[^>]*?>'si", 03553 "'<applet[^>]*?>'si", 03554 "'<object[^>]*?>'si", 03555 "'<link[^>]*?>'si", 03556 "'<iframe[^>]*?>'si", 03557 "'<frame[^>]*?>'si", 03558 "'<frameset[^>]*?>'si", 03559 "'<input[^>]*?>'si", 03560 "'<form[^>]*?>'si", 03561 "'<embed[^>]*?>'si", 03562 "'background-image:url'si", 03563 "'<\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", 03564 ), '', $text); 03565 03566 $text = eregi_replace('<a[^>]*href[[:space:]]*=[[:space:]]*["\']?[[:space:]]*javascript[^>]*','',$text); 03567 03568 // Return clean content 03569 return $text; 03570 } 03571 03582 function textStyle($theValue, $conf) { 03583 $conf['face.'][1] = 'Times New Roman'; 03584 $conf['face.'][2] = 'Verdana,Arial,Helvetica,Sans serif'; 03585 $conf['face.'][3] = 'Arial,Helvetica,Sans serif'; 03586 03587 $conf['size.'][1] = 1; 03588 $conf['size.'][2] = 2; 03589 $conf['size.'][3] = 3; 03590 $conf['size.'][4] = 4; 03591 $conf['size.'][5] = 5; 03592 $conf['size.'][10] = '+1'; 03593 $conf['size.'][11] = '-1'; 03594 03595 $conf['color.'][240] = 'black'; 03596 $conf['color.'][241] = 'white'; 03597 $conf['color.'][242] = '#333333'; 03598 $conf['color.'][243] = 'gray'; 03599 $conf['color.'][244] = 'silver'; 03600 $conf['color.'][245] = 'red'; 03601 $conf['color.'][246] = 'navy'; 03602 $conf['color.'][247] = 'yellow'; 03603 $conf['color.'][248] = 'green'; 03604 $conf['color.'][249] = 'olive'; 03605 $conf['color.'][250] = 'maroon'; 03606 03607 $face = $this->data[$conf['face.']['field']]; 03608 $size = $this->data[$conf['size.']['field']]; 03609 $color = $this->data[$conf['color.']['field']]; 03610 $align = $this->data[$conf['align.']['field']]; 03611 $properties = $this->data[$conf['properties.']['field']]; 03612 if (!$properties) { 03613 $properties=$this->stdWrap($conf['properties.']['default'],$conf['properties.']['default.']); 03614 } 03615 03616 // properties 03617 if (($properties&8)) {$theValue=$this->HTMLcaseshift($theValue, 'upper');} 03618 if (($properties&1)) {$theValue='<b>'.$theValue.'</b>';} 03619 if (($properties&2)) {$theValue='<i>'.$theValue.'</i>';} 03620 if (($properties&4)) {$theValue='<u>'.$theValue.'</u>';} 03621 03622 // Fonttag 03623 $theFace = $conf['face.'][$face] ? $conf['face.'][$face] : $this->stdWrap($conf['face.']['default'],$conf['face.']['default.']); 03624 $theSize = $conf['size.'][$size] ? $conf['size.'][$size] : $this->stdWrap($conf['size.']['default'],$conf['size.']['default.']); 03625 $theColor = $conf['color.'][$color] ? $conf['color.'][$color] : $this->stdWrap($conf['color.']['default'],$conf['color.']['default.']); 03626 03627 if ($conf['altWrap']) { 03628 $theValue=$this->wrap($theValue, $conf['altWrap']); 03629 } elseif ($theFace || $theSize || $theColor) { 03630 $fontWrap = '<font'.($theFace?' face="'.$theFace.'"':'').($theSize?' size="'.$theSize.'"':'').($theColor?' color="'.$theColor.'"':'').'>|</font>'; 03631 $theValue=$this->wrap($theValue, $fontWrap); 03632 } 03633 // align 03634 if ($align) {$theValue=$this->wrap($theValue, '<div style="text-align:'.$align.';">|</div>');} 03635 // return 03636 return $theValue; 03637 } 03638 03649 function tableStyle($theValue, $conf) { 03650 $conf['color.'][240] = 'black'; 03651 $conf['color.'][241] = 'white'; 03652 $conf['color.'][242] = '#333333'; 03653 $conf['color.'][243] = 'gray'; 03654 $conf['color.'][244] = 'silver'; 03655 03656 $align = $this->stdWrap($conf['align'],$conf['align.']); 03657 $border = intval($this->stdWrap($conf['border'],$conf['border.'])); 03658 $cellspacing = intval($this->stdWrap($conf['cellspacing'],$conf['cellspacing.'])); 03659 $cellpadding = intval($this->stdWrap($conf['cellpadding'],$conf['cellpadding.'])); 03660 03661 $color = $this->data[$conf['color.']['field']]; 03662 $theColor = $conf['color.'][$color] ? $conf['color.'][$color] : $conf['color.']['default']; 03663 // Assembling the table tag 03664 $tableTagArray = Array('<table'); 03665 $tableTagArray[]='border="'.$border.'"'; 03666 $tableTagArray[]='cellspacing="'.$cellspacing.'"'; 03667 $tableTagArray[]='cellpadding="'.$cellpadding.'"'; 03668 if ($align) {$tableTagArray[]='align="'.$align.'"';} 03669 if ($theColor) {$tableTagArray[]='bgcolor="'.$theColor.'"';} 03670 03671 if ($conf['params']) { 03672 $tableTagArray[] = $conf['params']; 03673 } 03674 03675 $tableWrap = implode(' ',$tableTagArray).'> | </table>'; 03676 $theValue=$this->wrap($theValue, $tableWrap); 03677 // return 03678 return $theValue; 03679 } 03680 03690 function addParams($content,$conf) { 03691 $lowerCaseAttributes = TRUE; // For XHTML compliance. 03692 03693 if (!is_array($conf)) { return $content; } 03694 03695 $key = 1; 03696 $parts = explode('<',$content); 03697 if (intval($conf['_offset'])) $key = intval($conf['_offset'])<0 ? count($parts)+intval($conf['_offset']) : intval($conf['_offset']); 03698 $subparts=explode('>',$parts[$key]); 03699 if (trim($subparts[0])) { 03700 // Get attributes and name 03701 $attribs = t3lib_div::get_tag_attributes('<'.$subparts[0].'>'); 03702 if (!is_array($attribs)) {$attribs=array();} 03703 list($tagName) = explode(' ',$subparts[0],2); 03704 // adds/overrides attributes 03705 reset($conf); 03706 while(list($pkey,$val)=each($conf)) { 03707 if (substr($pkey,-1)!='.' && substr($pkey,0,1)!='_') { 03708 $tmpVal=$this->stdWrap($conf[$pkey],$conf[$pkey.'.']); 03709 if ($lowerCaseAttributes) { $pkey = strtolower($pkey); } 03710 if (strcmp($tmpVal,'')) {$attribs[$pkey]=$tmpVal;} 03711 } 03712 } 03713 03714 // Re-assembles the tag and content 03715 $subparts[0]=trim($tagName.' '.t3lib_div::implodeAttributes($attribs)); 03716 $parts[$key] = implode('>',$subparts); 03717 $content = implode('<',$parts); 03718 } 03719 return $content; 03720 } 03721 03733 function filelink($theValue, $conf) { 03734 $output = ''; 03735 $aTagParams = $GLOBALS['TSFE']->ATagParams.($conf['ATagParams']?' '.$conf['ATagParams']:''); 03736 $initP = '?id='.$GLOBALS['TSFE']->id.'&type='.$GLOBALS['TSFE']->type; 03737 $conf['path'] = $this->stdWrap($conf['path'],$conf['path.']); 03738 $theFile = trim($conf['path']).$theValue; 03739 if (@is_file($theFile)) { 03740 $theFileEnc = str_replace('%2F', '/', rawurlencode($theFile)); 03741 $locDataAdd = $conf['jumpurl.']['secure'] ? $this->locDataJU($theFileEnc,$conf['jumpurl.']['secure.']) : ''; 03742 $url = ($conf['jumpurl']) ? $GLOBALS['TSFE']->config['mainScript'].$initP.'&jumpurl='.rawurlencode($theFileEnc).$locDataAdd.$GLOBALS['TSFE']->getMethodUrlIdToken : $theFileEnc; // && $GLOBALS['TSFE']->config['config']['jumpurl_enable'] 03743 $theLinkWrap = '<a href="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.$url).'"'.($conf['target']?' target="'.$conf['target'].'"':'').$aTagParams.'>|</a>'; 03744 03745 $theSize = filesize($theFile); 03746 $fI = t3lib_div::split_fileref($theFile); 03747 if ($conf['icon']) { 03748 $iconP = 't3lib/gfx/fileicons/'; 03749 $icon = @is_file($iconP.$fI['fileext'].'.gif') ? $iconP.$fI['fileext'].'.gif' : $iconP.'default.gif'; 03750 // Checking for images: If image, then return link to thumbnail. 03751 $IEList = $this->stdWrap($conf['icon_image_ext_list'],$conf['icon_image_ext_list.']); 03752 $image_ext_list = str_replace(' ','',strtolower($IEList)); 03753 if ($fI['fileext'] && t3lib_div::inList($image_ext_list, $fI['fileext'])) { 03754 if ($conf['iconCObject']) { 03755 $icon = $this->cObjGetSingle($conf['iconCObject'],$conf['iconCObject.'],'iconCObject'); 03756 } else { 03757 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails']) { 03758 $thumbSize = ''; 03759 if ($conf['icon_thumbSize'] || $conf['icon_thumbSize.']) { $thumbSize = '&size='.$this->stdWrap($conf['icon_thumbSize'], $conf['icon_thumbSize.']); } 03760 $icon = 't3lib/thumbs.php?&dummy='.$GLOBALS['EXEC_TIME'].'&file='.rawurlencode('../'.$theFile).$thumbSize; 03761 } else { 03762 $icon = 't3lib/gfx/notfound_thumb.gif'; 03763 } 03764 $icon = '<img src="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.$icon).'"'.$this->getBorderAttr(' border="0"').''.$this->getAltParam($conf).' />'; 03765 } 03766 } else { 03767 $icon = '<img src="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.$icon).'" width="18" height="16"'.$this->getBorderAttr(' border="0"').''.$this->getAltParam($conf).' />'; 03768 } 03769 if ($conf['icon_link']) {$icon = $this->wrap($icon, $theLinkWrap);} 03770 $icon = $this->stdWrap($icon,$conf['icon.']); 03771 } 03772 if ($conf['size']) { 03773 $size = $this->stdWrap($theSize,$conf['size.']); 03774 } 03775 03776 // Wrapping file label 03777 if ($conf['removePrependedNumbers']) $theValue=ereg_replace('_[0-9][0-9](\.[[:alnum:]]*)$','\1',$theValue); 03778 $theValue = $this->stdWrap($theValue,$conf['labelStdWrap.']); 03779 03780 // Wrapping file 03781 if ($conf['ATagBeforeWrap']) { 03782 $theValue = $this->wrap($this->wrap($theValue, $conf['wrap']), $theLinkWrap); 03783 } else { 03784 $theValue = $this->wrap($this->wrap($theValue, $theLinkWrap), $conf['wrap']); 03785 } 03786 $file = $this->stdWrap($theValue,$conf['file.']); 03787 // output 03788 return $this->stdWrap($icon.$file.$size, $conf['stdWrap.']); 03789 } 03790 } 03791 03802 function locDataJU($jumpUrl,$conf) { 03803 $fI = pathinfo($jumpUrl); 03804 $mimetype=''; 03805 if ($fI['extension']) { 03806 $mimeTypes = t3lib_div::trimExplode(',',$conf['mimeTypes'],1); 03807 reset($mimeTypes); 03808 while(list(,$v)=each($mimeTypes)) { 03809 $parts = explode('=',$v,2); 03810 if (strtolower($fI['extension']) == strtolower(trim($parts[0]))) { 03811 $mimetype = '&mimeType='.rawurlencode(trim($parts[1])); 03812 } 03813 } 03814 } 03815 $locationData = $GLOBALS['TSFE']->id.':'.$this->currentRecord; 03816 $rec='&locationData='.rawurlencode($locationData); 03817 $hArr = array( 03818 $jumpUrl, 03819 $locationData, 03820 $GLOBALS['TSFE']->TYPO3_CONF_VARS['SYS']['encryptionKey'] 03821 ); 03822 $juHash='&juHash='.t3lib_div::shortMD5(serialize($hArr)); 03823 return '&juSecure=1'.$mimetype.$rec.$juHash; 03824 } 03825 03833 function calc($val) { 03834 $parts= t3lib_div::splitCalc($val,'+-*/'); 03835 $value=0; 03836 reset($parts); 03837 while(list(,$part)=each($parts)) { 03838 $theVal = $part[1]; 03839 $sign = $part[0]; 03840 if ((string)intval($theVal)==(string)$theVal) { 03841 $theVal = intval($theVal); 03842 } else { 03843 $theVal =0; 03844 } 03845 if ($sign=='-') {$value-=$theVal;} 03846 if ($sign=='+') {$value+=$theVal;} 03847 if ($sign=='/') {if (intval($theVal)) $value/=intval($theVal);} 03848 if ($sign=='*') {$value*=$theVal;} 03849 } 03850 return $value; 03851 } 03852 03862 function calcIntExplode($delim, $string) { 03863 $temp = explode($delim,$string); 03864 while(list($key,$val)=each($temp)) { 03865 $temp[$key]=intval(tslib_cObj::calc($val)); 03866 } 03867 return $temp; 03868 } 03869 03882 function splitObj($value, $conf) { 03883 $conf['token']=$this->stdWrap($conf['token'],$conf['token.']); 03884 03885 if ($conf['token']) { 03886 $conf['max']=intval($this->stdWrap($conf['max'],$conf['max.'])); 03887 $conf['min']=intval($this->stdWrap($conf['min'],$conf['min.'])); 03888 03889 $valArr=explode($conf['token'],$value); 03890 // calculate splitCount 03891 $splitCount = count($valArr); 03892 if ($conf['max'] && $splitCount>$conf['max']) { 03893 $splitCount=$conf['max']; 03894 } 03895 if ($conf['min'] && $splitCount<$conf['min']) { 03896 $splitCount=$conf['min']; 03897 } 03898 03899 if ($conf['wrap'] || $conf['cObjNum']) { 03900 $splitArr=array(); 03901 $splitArr['wrap']=$conf['wrap']; 03902 $splitArr['cObjNum']=$conf['cObjNum']; 03903 $splitArr = $GLOBALS['TSFE']->tmpl->splitConfArray($splitArr,$splitCount); 03904 } 03905 03906 $content=''; 03907 for($a=0;$a<$splitCount;$a++) { 03908 $GLOBALS['TSFE']->register['SPLIT_COUNT']=$a; 03909 $value = ''.$valArr[$a]; 03910 $this->data[$this->currentValKey] = $value; 03911 if ($splitArr[$a]['cObjNum']) { 03912 $objName=intval($splitArr[$a]['cObjNum']); 03913 $value = $this->stdWrap($this->cObjGet($conf[$objName.'.'],$objName.'.'),$conf[$objName.'.']); 03914 } 03915 if ($splitArr[$a]['wrap']) { 03916 $value=$this->wrap($value,$splitArr[$a]['wrap']); 03917 } 03918 $content.=$value; 03919 } 03920 } 03921 return $content; 03922 } 03923 03938 function parseFunc($theValue, $conf, $ref='') { 03939 03940 // Fetch / merge reference, if any 03941 if ($ref) { 03942 $temp_conf = array( 03943 'parseFunc' => $ref, 03944 'parseFunc.' => $conf 03945 ); 03946 $temp_conf = $this->mergeTSRef($temp_conf, 'parseFunc'); 03947 $conf = $temp_conf['parseFunc.']; 03948 } 03949 03950 // Process: 03951 if (strcmp($conf['externalBlocks'],'')) { 03952 $tags = strtolower(implode(',',t3lib_div::trimExplode(',',$conf['externalBlocks']))); 03953 $htmlParser = t3lib_div::makeInstance('t3lib_parsehtml'); 03954 $parts = $htmlParser->splitIntoBlock($tags,$theValue); 03955 03956 reset($parts); 03957 while(list($k,$v)=each($parts)) { 03958 if ($k%2) { // font: 03959 $tagName=strtolower($htmlParser->getFirstTagName($v)); 03960 $cfg=$conf['externalBlocks.'][$tagName.'.']; 03961 if ($cfg['stripNLprev'] || $cfg['stripNL']) { 03962 $parts[$k-1]=ereg_replace(chr(13).'?'.chr(10).'[ ]*$', '', $parts[$k-1]); 03963 } 03964 if ($cfg['stripNLnext'] || $cfg['stripNL']) { 03965 $parts[$k+1]=ereg_replace('^[ ]*'.chr(13).'?'.chr(10), '', $parts[$k+1]); 03966 } 03967 } 03968 } 03969 03970 reset($parts); 03971 while(list($k,$v)=each($parts)) { 03972 if ($k%2) { 03973 $tag=$htmlParser->getFirstTag($v); 03974 $tagName=strtolower($htmlParser->getFirstTagName($v)); 03975 $cfg=$conf['externalBlocks.'][$tagName.'.']; 03976 if ($cfg['callRecursive']) { 03977 $parts[$k]=$this->parseFunc($htmlParser->removeFirstAndLastTag($v), $conf); 03978 if (!$cfg['callRecursive.']['dontWrapSelf']) { 03979 if ($cfg['callRecursive.']['alternativeWrap']) { 03980 $parts[$k] = $this->wrap($parts[$k], $cfg['callRecursive.']['alternativeWrap']); 03981 } else { 03982 if (is_array($cfg['callRecursive.']['tagStdWrap.'])) { 03983 $tag = $this->stdWrap($tag,$cfg['callRecursive.']['tagStdWrap.']); 03984 } 03985 $parts[$k]=$tag.$parts[$k].'</'.$tagName.'>'; 03986 } 03987 } 03988 } elseif($cfg['HTMLtableCells']) { 03989 $rowParts = $htmlParser->splitIntoBlock('tr',$parts[$k]); 03990 reset($rowParts); 03991 while(list($kk,$vv)=each($rowParts)) { 03992 if ($kk%2) { 03993 $colParts = $htmlParser->splitIntoBlock('td',$vv); 03994 reset($colParts); 03995 $cc=0; 03996 while(list($kkk,$vvv)=each($colParts)) { 03997 if ($kkk%2) { 03998 $cc++; 03999 $tag=$htmlParser->getFirstTag($vvv); 04000 $tagName=strtolower($htmlParser->getFirstTagName($vvv)); 04001 $colParts[$kkk] = $htmlParser->removeFirstAndLastTag($vvv); 04002 04003 if ($cfg['HTMLtableCells.'][$cc.'.']['callRecursive'] || (!isset($cfg['HTMLtableCells.'][$cc.'.']['callRecursive']) && $cfg['HTMLtableCells.']['default.']['callRecursive'])) { 04004 if ($cfg['HTMLtableCells.']['addChr10BetweenParagraphs']) $colParts[$kkk]=str_replace('</p><p>','</p>'.chr(10).'<p>',$colParts[$kkk]); 04005 $colParts[$kkk] = $this->parseFunc($colParts[$kkk], $conf); 04006 } 04007 04008 $tagStdWrap = is_array($cfg['HTMLtableCells.'][$cc.'.']['tagStdWrap.'])?$cfg['HTMLtableCells.'][$cc.'.']['tagStdWrap.']:$cfg['HTMLtableCells.']['default.']['tagStdWrap.']; 04009 if (is_array($tagStdWrap)) { 04010 $tag = $this->stdWrap($tag,$tagStdWrap); 04011 } 04012 04013 $stdWrap = is_array($cfg['HTMLtableCells.'][$cc.'.']['stdWrap.'])?$cfg['HTMLtableCells.'][$cc.'.']['stdWrap.']:$cfg['HTMLtableCells.']['default.']['stdWrap.']; 04014 if (is_array($stdWrap)) { 04015 $colParts[$kkk] = $this->stdWrap($colParts[$kkk],$stdWrap); 04016 } 04017 04018 $colParts[$kkk]=$tag.$colParts[$kkk].'</'.$tagName.'>'; 04019 } 04020 } 04021 $rowParts[$kk] = implode('',$colParts); 04022 } 04023 } 04024 $parts[$k] = implode('',$rowParts); 04025 } 04026 04027 if (is_array($cfg['stdWrap.'])) { 04028 $parts[$k] = $this->stdWrap($parts[$k],$cfg['stdWrap.']); 04029 } 04030 } else { 04031 $parts[$k]=$this->_parseFunc($parts[$k], $conf); 04032 } 04033 } 04034 04035 return implode('',$parts); 04036 } else return $this->_parseFunc($theValue, $conf); 04037 } 04038 04048 function _parseFunc ($theValue, $conf) { 04049 if (!$this->checkIf($conf['if.'])) { 04050 return $theValue; 04051 } 04052 $inside=0; // Indicates that the data is from within a tag. 04053 $pointer=0; // Pointer to the total string position 04054 $currentTag=''; // Loaded with the current typo-tag if any. 04055 $stripNL=0; 04056 $contentAccum=array(); 04057 $contentAccumP=0; 04058 04059 $allowTags=strtolower(str_replace(' ','',$conf['allowTags'])); 04060 $denyTags=strtolower(str_replace(' ','',$conf['denyTags'])); 04061 04062 $totalLen = strlen($theValue); 04063 do { 04064 if (!$inside) { 04065 if (!is_array($currentTag)) { // These operations should only be performed on code outside the typotags... 04066 // data: this checks that we enter tags ONLY if the first char in the tag is alphanumeric OR '/' 04067 $len_p=0; 04068 $c=100; 04069 do { 04070 $len = strcspn(substr($theValue,$pointer+$len_p),'<'); 04071 $len_p+=$len+1; 04072 $endChar = ord(strtolower(substr($theValue,$pointer+$len_p,1))); 04073 $c--; 04074 } while ($c>0 && $endChar && ($endChar<97 || $endChar>122) && $endChar!=47); 04075 $len = $len_p-1; 04076 } else { 04077 // If we're inside a currentTag, just take it to the end of that tag! 04078 $tempContent = strtolower(substr($theValue,$pointer)); 04079 $len = strpos ($tempContent, '</'.$currentTag[0]); 04080 if (is_string ($len) && !$len) { 04081 $len = strlen($tempContent); 04082 } 04083 } 04084 04085 $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 04086 if ($data!='') { 04087 if ($stripNL) { // If the previous tag was set to strip NewLines in the beginning of the next data-chunk. 04088 $data = ereg_replace('^[ ]*'.chr(13).'?'.chr(10), '', $data); 04089 } 04090 04091 if (!is_array($currentTag)) { // These operations should only be performed on code outside the tags... 04092 // Constants 04093 if ($conf['constants'] && is_array($GLOBALS['TSFE']->tmpl->setup['constants.'])) { 04094 reset($GLOBALS['TSFE']->tmpl->setup['constants.']); 04095 while(list($key,$val)=each($GLOBALS['TSFE']->tmpl->setup['constants.'])) { 04096 if (is_string($val)) { 04097 $data = str_replace('###'.$key.'###', $val, $data); 04098 } 04099 } 04100 } 04101 // Short 04102 if (is_array($conf['short.'])) { 04103 $shortWords = $conf['short.']; 04104 krsort($shortWords); 04105 reset($shortWords); 04106 while(list($key,$val)=each($shortWords)) { 04107 if (is_string($val)) { 04108 $data = str_replace($key, $val, $data); 04109 } 04110 } 04111 } 04112 04113 // stdWrap 04114 if (is_array($conf['plainTextStdWrap.'])) {$data = $this->stdWrap($data,$conf['plainTextStdWrap.']);} 04115 // userFunc 04116 if ($conf['userFunc']) {$data = $this->callUserFunction($conf['userFunc'], $conf['userFunc.'], $data);} 04117 04118 // Makelinks: (Before search-words as we need the links to be generated when searchwords go on...!) 04119 if ($conf['makelinks']) { 04120 $data = $this->http_makelinks($data,$conf['makelinks.']['http.']); 04121 $data = $this->mailto_makelinks($data,$conf['makelinks.']['mailto.']); 04122 } 04123 04124 // Search Words: 04125 if ($GLOBALS['TSFE']->no_cache && $conf['sword'] && is_array($GLOBALS['TSFE']->sWordList) && $GLOBALS['TSFE']->sWordRegEx) { 04126 $newstring = ''; 04127 do { 04128 $pieces = split($GLOBALS['TSFE']->sWordRegEx,$data,2); 04129 $newstring.=$pieces[0]; 04130 $match_len = strlen($data)-(strlen($pieces[0])+strlen($pieces[1])); 04131 if (strstr($pieces[0],'<') || strstr($pieces[0],'>')) { 04132 $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. 04133 } 04134 // The searchword: 04135 $match = substr($data,strlen($pieces[0]),$match_len); 04136 04137 if (trim($match) && strlen($match)>1 && !$inTag) { 04138 $match = $this->wrap($match, $conf['sword']); 04139 } 04140 // Concatenate the Search Word again. 04141 $newstring.= $match; 04142 $data=$pieces[1]; 04143 } while ($pieces[1]); 04144 $data = $newstring; 04145 } 04146 } 04147 $contentAccum[$contentAccumP].=$data; 04148 } 04149 $inside = 1; 04150 } else { 04151 // tags 04152 $len = strcspn(substr($theValue,$pointer),'>')+1; 04153 $data = substr($theValue,$pointer,$len); 04154 04155 $tag = explode(' ',trim(substr($data,1,-1)),2); 04156 $tag[0]=strtolower($tag[0]); 04157 if (substr($tag[0],0,1)=='/') { 04158 $tag[0]=substr($tag[0],1); 04159 $tag['out']=1; 04160 } 04161 if($conf['tags.'][$tag[0]]) { 04162 $treated=0; 04163 $stripNL = 0; 04164 // in-tag 04165 if (!$currentTag && !$tag['out']) { 04166 $currentTag = $tag; // $currentTag er lig med det tag (array!), man er igang med! 04167 $contentAccumP++; 04168 $treated=1; 04169 } 04170 // out-tag 04171 if ($currentTag[0]==$tag[0] && $tag['out']) { 04172 $theName = $conf['tags.'][$tag[0]]; 04173 $theConf = $conf['tags.'][$tag[0].'.']; 04174 $stripNL = ($theConf['stripNL'] ? 1 : 0); // This flag indicates, that NL- (13-10-chars) should be stripped first and last. 04175 $breakOut = ($theConf['breakoutTypoTagContent'] ? 1 : 0); // This flag indicates, that this TypoTag section should NOT be included in the nonTypoTag content. 04176 04177 $this->parameters=Array(); 04178 if ($currentTag[1]) { 04179 $params=t3lib_div::get_tag_attributes($currentTag[1]); 04180 if (is_array($params)) { 04181 reset($params); 04182 while(list($option,$val)=each($params)) { 04183 $this->parameters[strtolower($option)]=$val; 04184 } 04185 } 04186 } 04187 $this->parameters['allParams']=trim($currentTag[1]); 04188 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 04189 $contentAccum[$contentAccumP-1] = ereg_replace(chr(13).'?'.chr(10).'[ ]*$', '', $contentAccum[$contentAccumP-1]); 04190 $contentAccum[$contentAccumP] = ereg_replace('^[ ]*'.chr(13).'?'.chr(10), '', $contentAccum[$contentAccumP]); 04191 $contentAccum[$contentAccumP] = ereg_replace(chr(13).'?'.chr(10).'[ ]*$', '', $contentAccum[$contentAccumP]); 04192 } 04193 $this->data[$this->currentValKey] = $contentAccum[$contentAccumP]; 04194 $newInput=$this->cObjGetSingle($theName,$theConf,'/parseFunc/.tags.'.$tag[0]); // fetch the content object 04195 04196 $contentAccum[$contentAccumP]=$newInput; 04197 $contentAccumP++; 04198 04199 // If the TypoTag section 04200 if (!$breakOut) { 04201 $contentAccum[$contentAccumP-2].=$contentAccum[$contentAccumP-1].$contentAccum[$contentAccumP]; 04202 unset($contentAccum[$contentAccumP]); 04203 unset($contentAccum[$contentAccumP-1]); 04204 $contentAccumP-=2; 04205 } 04206 04207 unset($currentTag); 04208 $treated=1; 04209 } 04210 // other tags... 04211 if (!$treated) { 04212 $contentAccum[$contentAccumP].=$data; 04213 } 04214 } else { 04215 // If a tag was not a typo tag, then it is just added to the content 04216 $stripNL = 0; 04217 if (t3lib_div::inList($allowTags,$tag[0]) || ($denyTags!='*' && !t3lib_div::inList($denyTags,$tag[0]))) { 04218 $contentAccum[$contentAccumP].=$data; 04219 } else { 04220 $contentAccum[$contentAccumP].=HTMLSpecialChars($data); 04221 } 04222 } 04223 $inside = 0; 04224 } 04225 $pointer+=$len; 04226 } while($pointer<$totalLen); 04227 04228 // Parsing nonTypoTag content (all even keys): 04229 reset($contentAccum); 04230 for ($a=0;$a<count($contentAccum);$a++) { 04231 if ($a%2 != 1) { 04232 // stdWrap 04233 if (is_array($conf['nonTypoTagStdWrap.'])) {$contentAccum[$a] = $this->stdWrap($contentAccum[$a],$conf['nonTypoTagStdWrap.']);} 04234 // userFunc 04235 if ($conf['nonTypoTagUserFunc']) {$contentAccum[$a] = $this->callUserFunction($conf['nonTypoTagUserFunc'], $conf['nonTypoTagUserFunc.'], $contentAccum[$a]);} 04236 } 04237 } 04238 return implode('',$contentAccum); 04239 } 04240 04250 function encaps_lineSplit($theValue, $conf) { 04251 $lParts = explode(chr(10),$theValue); 04252 04253 $encapTags = t3lib_div::trimExplode(',',strtolower($conf['encapsTagList']),1); 04254 $nonWrappedTag = $conf['nonWrappedTag']; 04255 $defaultAlign=trim($this->stdWrap($conf['defaultAlign'],$conf['defaultAlign.'])); 04256 04257 if (!strcmp('',$theValue)) return ''; 04258 04259 while(list($k,$l)=each($lParts)) { 04260 $sameBeginEnd=0; 04261 $l=trim($l); 04262 $attrib=array(); 04263 $nWrapped=0; 04264 $byPass=0; 04265 if (substr($l,0,1)=='<' && substr($l,-1)=='>') { 04266 $fwParts = explode('>',substr($l,1),2); 04267 $backParts = t3lib_div::revExplode('<', substr($fwParts[1],0,-1), 2); 04268 $attrib = t3lib_div::get_tag_attributes('<'.$fwParts[0].'>'); 04269 list($tagName) = explode(' ',$fwParts[0]); 04270 $str_content = $backParts[0]; 04271 $sameBeginEnd = (substr(strtolower($backParts[1]),1,strlen($tagName))==strtolower($tagName)); 04272 } 04273 04274 if ($sameBeginEnd && in_array(strtolower($tagName),$encapTags)) { 04275 $uTagName = strtoupper($tagName); 04276 $uTagName = strtoupper($conf['remapTag.'][$uTagName]?$conf['remapTag.'][$uTagName]:$uTagName); 04277 } else { 04278 $uTagName = strtoupper($nonWrappedTag); 04279 $str_content = $lParts[$k]; 04280 $nWrapped=1; 04281 $attrib=array(); 04282 } 04283 04284 // Wrapping all inner-content: 04285 if (is_array($conf['innerStdWrap_all.'])) {$str_content = $this->stdWrap($str_content,$conf['innerStdWrap_all.']);} 04286 04287 if ($uTagName) { 04288 // Setting common attributes 04289 if (is_array($conf['addAttributes.'][$uTagName.'.'])) { 04290 reset($conf['addAttributes.'][$uTagName.'.']); 04291 while(list($kk,$vv)=each($conf['addAttributes.'][$uTagName.'.'])) { 04292 if (!is_array($vv)) { 04293 if ((string)$conf['addAttributes.'][$uTagName.'.'][$kk.'.']['setOnly']=='blank') { 04294 if (!strcmp($attrib[$kk],'')) $attrib[$kk]=$vv; 04295 } elseif ((string)$conf['addAttributes.'][$uTagName.'.'][$kk.'.']['setOnly']=='exists') { 04296 if (!isset($attrib[$kk])) $attrib[$kk]=$vv; 04297 } else { 04298 $attrib[$kk]=$vv; 04299 } 04300 } 04301 } 04302 } 04303 // Wrapping all inner-content: 04304 if (is_array($conf['encapsLinesStdWrap.'][$uTagName.'.'])) {$str_content = $this->stdWrap($str_content,$conf['encapsLinesStdWrap.'][$uTagName.'.']);} 04305 // Default align 04306 if (!$attrib['align'] && $defaultAlign) $attrib['align']=$defaultAlign; 04307 04308 $params = t3lib_div::implodeAttributes($attrib,1); 04309 if ($conf['removeWrapping']) { 04310 $str_content=$str_content; 04311 } else { 04312 $str_content='<'.strtolower($uTagName).(trim($params)?' '.trim($params):'').'>'.$str_content.'</'.strtolower($uTagName).'>'; 04313 } 04314 } 04315 04316 if ($nWrapped && $conf['wrapNonWrappedLines']) {$str_content = $this->wrap($str_content,$conf['wrapNonWrappedLines']);} 04317 $lParts[$k] = $str_content; 04318 } 04319 04320 return implode(chr(10),$lParts); 04321 } 04322 04333 function http_makelinks($data,$conf) { 04334 $aTagParams = $GLOBALS['TSFE']->ATagParams.($conf['ATagParams']?' '.$conf['ATagParams']:''); 04335 $textpieces = explode('http://', $data); 04336 $pieces = count($textpieces); 04337 $textstr = $textpieces[0]; 04338 $initP = '?id='.$GLOBALS['TSFE']->id.'&type='.$GLOBALS['TSFE']->type; 04339 for($i=1; $i<$pieces; $i++) { 04340 $len=strcspn($textpieces[$i],chr(32).chr(9).chr(13).chr(10)); 04341 if (trim(substr($textstr,-1))=='' && $len) { 04342 04343 $lastChar=substr($textpieces[$i],$len-1,1); 04344 if (!ereg('[A-Za-z0-9\/#_-]',$lastChar)) {$len--;} // Included '\/' 3/12 04345 04346 $parts[0]=substr($textpieces[$i],0,$len); 04347 $parts[1]=substr($textpieces[$i],$len); 04348 04349 $keep=$conf['keep']; 04350 $linkParts=parse_url('http://'.$parts[0]); 04351 $linktxt=''; 04352 if (strstr($keep,'scheme')) { 04353 $linktxt='http://'; 04354 } 04355 $linktxt.= $linkParts['host']; 04356 if (strstr($keep,'path')) { 04357 $linktxt.= $linkParts['path']; 04358 if (strstr($keep,'query') && $linkParts['query']) { // added $linkParts['query'] 3/12 04359 $linktxt.= '?'.$linkParts['query']; 04360 } elseif ($linkParts['path']=='/') { // If query is NOT added and the path is '/' then remove the slash ('/') (added 3/12) 04361 $linktxt=substr($linktxt,0,-1); 04362 } 04363 } 04364 $target = isset($conf['extTarget']) ? $conf['extTarget'] : $GLOBALS['TSFE']->extTarget; 04365 if ($GLOBALS['TSFE']->config['config']['jumpurl_enable']) { 04366 $res = '<a'. 04367 ' href="'.htmlspecialchars($GLOBALS['TSFE']->absRefPrefix.$GLOBALS['TSFE']->config['mainScript'].$initP.'&jumpurl='.rawurlencode('http://'.$parts[0]).$GLOBALS['TSFE']->getMethodUrlIdToken).'"'. 04368 ($target ? ' target="'.$target.'"' : ''). 04369 $aTagParams. 04370 '>'; 04371 } else { 04372 $res = '<a'. 04373 ' href="http://'.htmlspecialchars($parts[0]).'"'. 04374 ($target ? ' target="'.$target.'"' : ''). 04375 $aTagParams. 04376 '>'; 04377 } 04378 if ($conf['ATagBeforeWrap']) { 04379 $res= $res.$this->wrap($linktxt, $conf['wrap']).'</a>'; 04380 } else { 04381 $res= $this->wrap($res.$linktxt.'</a>', $conf['wrap']); 04382 } 04383 $textstr.=$res.$parts[1]; 04384 } else { 04385 $textstr.='http://'.$textpieces[$i]; 04386 } 04387 } 04388 return $textstr; 04389 } 04390 04400 function mailto_makelinks($data,$conf) { 04401 // http-split 04402 $aTagParams = $GLOBALS['TSFE']->ATagParams.($conf['ATagParams']?' '.$conf['ATagParams']:''); 04403 $textpieces = explode('mailto:', $data); 04404 $pieces = count($textpieces); 04405 $textstr = $textpieces[0]; 04406 $initP = '?id='.$GLOBALS['TSFE']->id.'&type='.$GLOBALS['TSFE']->type; 04407 for($i=1; $i<$pieces; $i++) { 04408 $len = strcspn($textpieces[$i],chr(32).chr(9).chr(13).chr(10)); 04409 if (trim(substr($textstr,-1))=='' && $len) { 04410 $lastChar = substr($textpieces[$i],$len-1,1); 04411 if (!ereg('[A-Za-z0-9]',$lastChar)) {$len--;} 04412 04413 $parts[0] = substr($textpieces[$i],0,$len); 04414 $parts[1] = substr($textpieces[$i],$len); 04415 $linktxt = ereg_replace('\?.*','',$parts[0]); 04416 list($mailToUrl,$linktxt) = $this->getMailTo($parts[0],$linktxt,$initP); 04417 $mailToUrl = $GLOBALS['TSFE']->spamProtectEmailAddresses === 'ascii'?$mailToUrl:htmlspecialchars($mailToUrl); 04418 $res = '<a href="'.$mailToUrl.'"'.$aTagParams.'>'; 04419 if ($conf['ATagBeforeWrap']) { 04420 $res= $res.$this->wrap($linktxt, $conf['wrap']).'</a>'; 04421 } else { 04422 $res= $this->wrap($res.$linktxt.'</a>', $conf['wrap']); 04423 } 04424 $textstr.=$res.$parts[1]; 04425 } else { 04426 $textstr.='mailto:'.$textpieces[$i]; 04427 } 04428 } 04429 return $textstr; 04430 } 04431 04443 function getImgResource($file,$fileArray) { 04444 if (is_array($fileArray)) { 04445 switch($file) { 04446 case 'GIFBUILDER': 04447 $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder'); 04448 $gifCreator->init(); 04449 $theImage=''; 04450 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib']) { 04451 $gifCreator->start($fileArray,$this->data); 04452 $theImage = $gifCreator->gifBuild(); 04453 } 04454 return $gifCreator->getImageDimensions($theImage); 04455 break; 04456 default: 04457 if ($fileArray['import.']) { 04458 $ifile = $this->stdWrap('',$fileArray['import.']); 04459 if ($ifile) {$file = $fileArray['import'].$ifile;} 04460 } 04461 $theImage = $GLOBALS['TSFE']->tmpl->getFileName($file); 04462 if ($theImage) { 04463 $fileArray['width']= $this->stdWrap($fileArray['width'],$fileArray['width.']); 04464 $fileArray['height']= $this->stdWrap($fileArray['height'],$fileArray['height.']); 04465 $fileArray['ext']= $this->stdWrap($fileArray['ext'],$fileArray['ext.']); 04466 $fileArray['maxW']= intval($this->stdWrap($fileArray['maxW'],$fileArray['maxW.'])); 04467 $fileArray['maxH']= intval($this->stdWrap($fileArray['maxH'],$fileArray['maxH.'])); 04468 $fileArray['minW']= intval($fileArray['minW']); 04469 $fileArray['minH']= intval($fileArray['minH']); 04470 $maskArray= $fileArray['m.']; 04471 $maskImages=array(); 04472 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! 04473 $maskImages['m_mask'] = $this->getImgResource($maskArray['mask'],$maskArray['mask.']); 04474 $maskImages['m_bgImg'] = $this->getImgResource($maskArray['bgImg'],$maskArray['bgImg.']); 04475 $maskImages['m_bottomImg'] = $this->getImgResource($maskArray['bottomImg'],$maskArray['bottomImg.']); 04476 $maskImages['m_bottomImg_mask'] = $this->getImgResource($maskArray['bottomImg_mask'],$maskArray['bottomImg_mask.']); 04477 } 04478 $hash = t3lib_div::shortMD5($theImage.serialize($fileArray).serialize($maskImages)); 04479 if (!isset($GLOBALS['TSFE']->tmpl->fileCache[$hash])) { 04480 $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder'); 04481 $gifCreator->init(); 04482 04483 if ($GLOBALS['TSFE']->config['config']['meaningfulTempFilePrefix']) { 04484 $gifCreator->filenamePrefix = $GLOBALS['TSFE']->fileNameASCIIPrefix(ereg_replace('\.[[:alnum:]]+$','',basename($theImage)),intval($GLOBALS['TSFE']->config['config']['meaningfulTempFilePrefix']),'_'); 04485 } 04486 04487 if ($fileArray['sample']) { 04488 $gifCreator->scalecmd = '-sample'; 04489 $GLOBALS['TT']->setTSlogMessage('Sample option: Images are scaled with -sample.'); 04490 } 04491 if ($fileArray['alternativeTempPath'] && t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['FE']['allowedTempPaths'],$fileArray['alternativeTempPath'])) { 04492 $gifCreator->tempPath = $fileArray['alternativeTempPath']; 04493 $GLOBALS['TT']->setTSlogMessage('Set alternativeTempPath: '.$fileArray['alternativeTempPath']); 04494 } 04495 04496 if (!trim($fileArray['ext'])){$fileArray['ext']='web';} 04497 $options = Array(); 04498 if ($fileArray['maxW']) {$options['maxW']=$fileArray['maxW'];} 04499 if ($fileArray['maxH']) {$options['maxH']=$fileArray['maxH'];} 04500 if ($fileArray['minW']) {$options['minW']=$fileArray['minW'];} 04501 if ($fileArray['minH']) {$options['minH']=$fileArray['minH'];} 04502 04503 // checks to see if m (the mask array) is defined 04504 if (is_array($maskArray) && $GLOBALS['TYPO3_CONF_VARS']['GFX']['im']) { 04505 // Filename: 04506 $fI = t3lib_div::split_fileref($theImage); 04507 $dest = $gifCreator->tempPath.$hash.'.'.($fI['fileext']==$gifCreator->gifExtension ? $gifCreator->gifExtension : 'jpg'); 04508 if (!@file_exists($dest)) { // Generate! 04509 $m_mask= $maskImages['m_mask']; 04510 $m_bgImg = $maskImages['m_bgImg']; 04511 if ($m_mask && $m_bgImg) { 04512 $negate = $GLOBALS['TYPO3_CONF_VARS']['GFX']['im_negate_mask'] ? ' -negate' : ''; 04513 04514 $temp_ext='png'; 04515 if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_mask_temp_ext_gif']) { // If ImageMagick version 5+ 04516 $temp_ext=$gifCreator->gifExtension; 04517 } 04518 04519 $tempFileInfo = $gifCreator->imageMagickConvert($theImage,$temp_ext,$fileArray['width'],$fileArray['height'],$fileArray['params'],$fileArray['frame'],$options); 04520 if (is_array($tempFileInfo)) { 04521 $m_bottomImg = $maskImages['m_bottomImg']; 04522 if ($m_bottomImg) { 04523 $m_bottomImg_mask = $maskImages['m_bottomImg_mask']; 04524 } 04525 // Scaling: **** 04526 $tempScale=array(); 04527 $command = '-geometry '.$tempFileInfo[0].'x'.$tempFileInfo[1].'!'; 04528 $tmpStr = $gifCreator->randomName(); 04529 04530 // m_mask 04531 $tempScale['m_mask']=$tmpStr.'_mask.'.$temp_ext; 04532 $gifCreator->imageMagickExec($m_mask[3],$tempScale['m_mask'],$command.$negate); 04533 // m_bgImg 04534 $tempScale['m_bgImg']=$tmpStr.'_bgImg.'.trim($GLOBALS['TYPO3_CONF_VARS']['GFX']['im_mask_temp_ext_noloss']); 04535 $gifCreator->imageMagickExec($m_bgImg[3],$tempScale['m_bgImg'],$command); 04536 04537 // m_bottomImg / m_bottomImg_mask 04538 if ($m_bottomImg && $m_bottomImg_mask) { 04539 $tempScale['m_bottomImg']=$tmpStr.'_bottomImg.'.$temp_ext; 04540 $gifCreator->imageMagickExec($m_bottomImg[3],$tempScale['m_bottomImg'],$command); 04541 $tempScale['m_bottomImg_mask']=$tmpStr.'_bottomImg_mask.'.$temp_ext; 04542 $gifCreator->imageMagickExec($m_bottomImg_mask[3],$tempScale['m_bottomImg_mask'],$command.$negate); 04543 04544 // BEGIN combining: 04545 // The image onto the background 04546 $gifCreator->combineExec($tempScale['m_bgImg'],$tempScale['m_bottomImg'],$tempScale['m_bottomImg_mask'],$tempScale['m_bgImg']); 04547 } 04548 // The image onto the background 04549 $gifCreator->combineExec($tempScale['m_bgImg'],$tempFileInfo[3],$tempScale['m_mask'],$dest); 04550 // Unlink the temp-images... 04551 reset($tempScale); 04552 while(list(,$file)=each($tempScale)) { 04553 if (@is_file($file)) { 04554 unlink($file); 04555 } 04556 } 04557 // t3lib_div::print_array($GLOBALS['TSFE']->tmpl->fileCache[$hash]); 04558 } 04559 } 04560 } 04561 // Finish off 04562 $GLOBALS['TSFE']->tmpl->fileCache[$hash]= $gifCreator->getImageDimensions($dest); 04563 } else { // Normal situation: 04564 $GLOBALS['TSFE']->tmpl->fileCache[$hash]= $gifCreator->imageMagickConvert($theImage,$fileArray['ext'],$fileArray['width'],$fileArray['height'],$fileArray['params'],$fileArray['frame'],$options); 04565 } 04566 $GLOBALS['TSFE']->tmpl->fileCache[$hash]['origFile'] = $theImage; 04567 $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. 04568 } 04569 return $GLOBALS['TSFE']->tmpl->fileCache[$hash]; 04570 } 04571 04572 break; 04573 } 04574 } 04575 $theImage = $GLOBALS['TSFE']->tmpl->getFileName($file); 04576 if ($theImage) { 04577 $gifCreator = t3lib_div::makeInstance('tslib_gifbuilder'); 04578 $gifCreator->init(); 04579 $info= $gifCreator->imageMagickConvert($theImage,'WEB','','','','',''); 04580 $info['origFile'] = $theImage; 04581 $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. 04582 return $info; 04583 } 04584 } 04585 04586 04587 04588 04589 04590 04591 04592 04593 04594 04595 04596 04597 04598 04599 04600 04601 04602 04603 04604 04605 04606 04607 /*********************************************** 04608 * 04609 * Data retrieval etc. 04610 * 04611 ***********************************************/ 04612 04613 04620 function getFieldVal($field) { 04621 if (!strstr($field,'//')) { 04622 return $this->data[trim($field)]; 04623 } else { 04624 $sections = t3lib_div::trimExplode('//',$field,1); 04625 while (list(,$k)=each($sections)) { 04626 if (strcmp($this->data[$k],'')) return $this->data[$k]; 04627 } 04628 } 04629 } 04630 04640 function getData($string,$fieldArray) { 04641 if (!is_array($fieldArray)) { 04642 $fieldArray=$GLOBALS['TSFE']->page; 04643 } 04644 $retVal = ''; 04645 $sections = explode('//',$string); 04646 04647 while (!$retVal AND list($secKey, $secVal)=each($sections)) { 04648 $parts = explode(':',$secVal,2); 04649 $key = trim($parts[1]); 04650 if ((string)$key!='') { 04651 switch(strtolower(trim($parts[0]))) { 04652 case 'gpvar': 04653 list($firstKey, $rest) = explode('|', $key, 2); 04654 if (strlen(trim($firstKey))) { 04655 $retVal = t3lib_div::_GP(trim($firstKey)); 04656 // Look for deeper levels: 04657 if (strlen(trim($rest))) { 04658 $retVal = is_array($retVal) ? $this->getGlobal($rest, $retVal) : ''; 04659 } 04660 // Check that output is not an array: 04661 if (is_array($retVal)) $retVal = ''; 04662 } 04663 break; 04664 case 'tsfe': 04665 $retVal = $GLOBALS['TSFE']->$key; 04666 break; 04667 case 'getenv': 04668 $retVal = getenv($key); 04669 break; 04670 case 'getindpenv': 04671 $retVal = t3lib_div::getIndpEnv($key); 04672 break; 04673 case 'field': 04674 $retVal = $fieldArray[$key]; 04675 break; 04676 case 'parameters': 04677 $retVal = $this->parameters[$key]; 04678 break; 04679 case 'register': 04680 $retVal = $GLOBALS['TSFE']->register[$key]; 04681 break; 04682 case 'global': 04683 $retVal = $this->getGlobal($key); 04684 break; 04685 case 'leveltitle': 04686 $nkey = $this->getKey($key,$GLOBALS['TSFE']->tmpl->rootLine); 04687 $retVal = $this->rootLineValue($nkey,'title',stristr($key,'slide')); 04688 break; 04689 case 'levelmedia': 04690 $nkey = $this->getKey($key,$GLOBALS['TSFE']->tmpl->rootLine); 04691 $retVal = $this->rootLineValue($nkey,'media',stristr($key,'slide')); 04692 break; 04693 case 'leveluid': 04694 $nkey = $this->getKey($key,$GLOBALS['TSFE']->tmpl->rootLine); 04695 $retVal = $this->rootLineValue($nkey,'uid',stristr($key,'slide')); 04696 break; 04697 case 'levelfield': 04698 $keyP = t3lib_div::trimExplode(',',$key); 04699 $nkey = $this->getKey($keyP[0],$GLOBALS['TSFE']->tmpl->rootLine); 04700 $retVal = $this->rootLineValue($nkey,$keyP[1],strtolower($keyP[2])=='slide'); 04701 break; 04702 case 'fullrootline': 04703 $keyP = t3lib_div::trimExplode(',',$key); 04704 $fullKey = intval($keyP[0])-count($GLOBALS['TSFE']->tmpl->rootLine)+count($GLOBALS['TSFE']->rootLine); 04705 if ($fullKey>=0) { 04706 $retVal = $this->rootLineValue($fullKey,$keyP[1],stristr($keyP[2],'slide'),$GLOBALS['TSFE']->rootLine); 04707 } 04708 break; 04709 case 'date': 04710 if (!$key) {$key = 'd/m Y';} 04711 $retVal = date($key, time()); 04712 break; 04713 case 'page': 04714 $retVal = $GLOBALS['TSFE']->page[$key]; 04715 break; 04716 case 'current': 04717 $retVal = $this->data[$this->currentValKey]; 04718 break; 04719 case 'level': 04720 $retVal = count($GLOBALS['TSFE']->tmpl->rootLine)-1; 04721 break; 04722 case 'db': 04723 $selectParts = t3lib_div::trimExplode(':',$key); 04724 $db_rec = $GLOBALS['TSFE']->sys_page->getRawRecord($selectParts[0],$selectParts[1]); 04725 if (is_array($db_rec) && $selectParts[2]) {$retVal = $db_rec[$selectParts[2]];} 04726 break; 04727 case 'lll': 04728 $retVal = $GLOBALS['TSFE']->sL('LLL:'.$key); 04729 break; 04730 case 'path': 04731 $retVal = $GLOBALS['TSFE']->tmpl->getFileName($key); 04732 break; 04733 case 'cobj': 04734 switch((string)$key) { 04735 case 'parentRecordNumber': 04736 $retVal = $this->parentRecordNumber; 04737 break; 04738 } 04739 break; 04740 case 'debug': 04741 switch((string)$key) { 04742 case 'rootLine': 04743 $retVal = t3lib_div::view_array($GLOBALS['TSFE']->tmpl->rootLine); 04744 break; 04745 case 'fullRootLine': 04746 $retVal = t3lib_div::view_array($GLOBALS['TSFE']->rootLine); 04747 break; 04748 case 'data': 04749 $retVal = t3lib_div::view_array($this->data); 04750 break; 04751 } 04752 break; 04753 } 04754 } 04755 } 04756 return $retVal; 04757 } 04758 04770 function rootLineValue($key,$field,$slideBack=0,$altRootLine='') { 04771 $rootLine = is_array($altRootLine) ? $altRootLine : $GLOBALS['TSFE']->tmpl->rootLine; 04772 if (!$slideBack) { 04773 return $rootLine[$key][$field]; 04774 } else { 04775 for ($a=$key;$a>=0;$a--) { 04776 $val = $rootLine[$a][$field]; 04777 if ($val) {return $val;} 04778 } 04779 } 04780 } 04781 04792 function getGlobal($var, $source=NULL) { 04793 $vars = explode('|', $var); 04794 $c = count($vars); 04795 $theVar = isset($source) ? $source[trim($vars[0])] : $GLOBALS[trim($vars[0])]; 04796 for ($a=1;$a<$c;$a++) { 04797 if (!isset($theVar)) {break;} 04798 $theVar = $theVar[trim($vars[$a])]; 04799 } 04800 if (!is_array($theVar)) { 04801 return $theVar; 04802 } else { 04803 return ''; 04804 } 04805 } 04806 04817 function getKey($key,$arr) { 04818 $key = intval($key); 04819 if (is_array($arr)) { 04820 if ($key < 0) { 04821 $key = count($arr)+$key; 04822 } 04823 if ($key < 0) { 04824 $key=0; 04825 } 04826 } 04827 return $key; 04828 } 04829 04830 04831 04832 04833 04834 04835 04836 04837 04838 04839 04840 04841 04842 04843 04844 04845 04846 04847 04848 04849 /*********************************************** 04850 * 04851 * Link functions (typolink) 04852 * 04853 ***********************************************/ 04854 04855 04869 function typoLink($linktxt, $conf) { 04870 $finalTagParts = array(); 04871 $finalTagParts['aTagParams'] = $GLOBALS['TSFE']->ATagParams.($conf['ATagParams']?' '.$conf['ATagParams']:''); 04872 04873 $link_param = trim($this->stdWrap($conf['parameter'],$conf['parameter.'])); 04874 $sectionMark = trim($this->stdWrap($conf['section'],$conf['section.'])); 04875 $sectionMark = $sectionMark ? '#'.$sectionMark : ''; 04876 $initP = '?id='.$GLOBALS['TSFE']->id.'&type='.$GLOBALS['TSFE']->type; 04877 $this->lastTypoLinkUrl = ''; 04878 $this->lastTypoLinkTarget = ''; 04879 if ($link_param) { 04880 $link_paramA = t3lib_div::trimExplode(' ',$link_param,1); 04881 $link_param = trim($link_paramA[0]); // Link parameter value 04882 $linkClass = trim($link_paramA[2]); // Link class 04883 $forceTarget = trim($link_paramA[1]); // Target value 04884 if ($forceTarget=='-') $forceTarget = ''; // The '-' character means 'no target'. Necessary in order to specify a class as third parameter without setting the target! 04885 // Check, if the target is coded as a JS open window link: 04886 $JSwindowParts = array(); 04887 $JSwindowParams = ''; 04888 $onClick = ''; 04889 if ($forceTarget && ereg('^([0-9]+)x([0-9]+)(:(.*)|.*)$',$forceTarget,$JSwindowParts)) { 04890 // Take all pre-configured and inserted parameters and compile parameter list, including width+height: 04891 $JSwindow_tempParamsArr = t3lib_div::trimExplode(',',strtolower($conf['JSwindow_params'].','.$JSwindowParts[4]),1); 04892 $JSwindow_paramsArr=array(); 04893 foreach($JSwindow_tempParamsArr as $JSv) { 04894 list($JSp,$JSv) = explode('=',$JSv); 04895 $JSwindow_paramsArr[$JSp]=$JSp.'='.$JSv; 04896 } 04897 // Add width/height: 04898 $JSwindow_paramsArr['width']='width='.$JSwindowParts[1]; 04899 $JSwindow_paramsArr['height']='height='.$JSwindowParts[2]; 04900 // Imploding into string: 04901 $JSwindowParams = implode(',',$JSwindow_paramsArr); 04902 $forceTarget = ''; // Resetting the target since we will use onClick. 04903 } 04904 04905 // Internal target: 04906 $target = isset($conf['target']) ? $conf['target'] : $GLOBALS['TSFE']->intTarget; 04907 if ($conf['target.']) {$target=$this->stdWrap($target, $conf['target.']);} 04908 04909 // Parse URL: 04910 $pU = parse_url($link_param); 04911 04912 // Detecting kind of link: 04913 if(strstr($link_param,'@') && !$pU['scheme']) { // If it's a mail address: 04914 $link_param = eregi_replace('^mailto:','',$link_param); 04915 list($this->lastTypoLinkUrl,$linktxt) = $this->getMailTo($link_param,$linktxt,$initP); 04916 $finalTagParts['url']=$this->lastTypoLinkUrl; 04917 $finalTagParts['TYPE']='mailto'; 04918 } else { 04919 $isLocalFile=0; 04920 $fileChar=intval(strpos($link_param, '/')); 04921 $urlChar=intval(strpos($link_param, '.')); 04922 04923 // 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. 04924 list($rootFileDat) = explode('?',rawurldecode($link_param)); 04925 $containsSlash = strstr($rootFileDat,'/'); 04926 $rFD_fI = pathinfo($rootFileDat); 04927 if (trim($rootFileDat) && !$containsSlash && (@is_file(PATH_site.$rootFileDat) || t3lib_div::inList('php,html,htm',strtolower($rFD_fI['extension'])))) { 04928 $isLocalFile = 1; 04929 } elseif ($containsSlash) { 04930 $isLocalFile = 2; // Adding this so realurl directories are linked right (non-existing). 04931 } 04932 04933 if($pU['scheme'] || ($isLocalFile!=1 && $urlChar && (!$containsSlash || $urlChar<$fileChar))) { // url (external): If doubleSlash or if a '.' comes before a '/'. 04934 $target = isset($conf['extTarget']) ? $conf['extTarget'] : $GLOBALS['TSFE']->extTarget; 04935 if ($conf['extTarget.']) {$target = $this->stdWrap($target, $conf['extTarget.']);} 04936 if ($forceTarget) {$target=$forceTarget;} 04937 if ($linktxt=='') $linktxt = $link_param; 04938 if (!$pU['scheme']) {$scheme='http://';} else {$scheme='';} 04939 if ($GLOBALS['TSFE']->config['config']['jumpurl_enable']) { 04940 $this->lastTypoLinkUrl = $GLOBALS['TSFE']->absRefPrefix.$GLOBALS['TSFE']->config['mainScript'].$initP.'&jumpurl='.rawurlencode($scheme.$link_param).$GLOBALS['TSFE']->getMethodUrlIdToken; 04941 } else { 04942 $this->lastTypoLinkUrl = $scheme.$link_param; 04943 } 04944 $this->lastTypoLinkTarget = $target; 04945 $finalTagParts['url']=$this->lastTypoLinkUrl; 04946 $finalTagParts['targetParams'] = $target ? ' target="'.$target.'"' : ''; 04947 $finalTagParts['TYPE']='url'; 04948 } elseif ($containsSlash || $isLocalFile) { // file (internal) 04949 $splitLinkParam = explode('?', $link_param); 04950 if (@file_exists(rawurldecode($splitLinkParam[0])) || $isLocalFile) { 04951 if ($linktxt=='') $linktxt = rawurldecode($link_param); 04952 if ($GLOBALS['TSFE']->config['config']['jumpurl_enable']) { 04953 $this->lastTypoLinkUrl = $GLOBALS['TSFE']->absRefPrefix.$GLOBALS['TSFE']->config['mainScript'].$initP.'&jumpurl='.rawurlencode($link_param).$GLOBALS['TSFE']->getMethodUrlIdToken; 04954 } else { 04955 $this->lastTypoLinkUrl = $GLOBALS['TSFE']->absRefPrefix.$link_param; 04956 } 04957 if ($forceTarget) {$target=$forceTarget;} 04958 $this->lastTypoLinkTarget = $target; 04959 04960 $finalTagParts['url'] = $this->lastTypoLinkUrl; 04961 $finalTagParts['targetParams'] = $target ? ' target="'.$target.'"' : ''; 04962 $finalTagParts['TYPE'] = 'file'; 04963 } else { 04964 $GLOBALS['TT']->setTSlogMessage("typolink(): File '".$splitLinkParam[0]."' did not exist, so '".$linktxt."' was not linked.",1); 04965 return $linktxt; 04966 } 04967 } else { // integer or alias (alias is without slashes or periods or commas, that is 'nospace,alphanum_x,lower,unique' according to definition in $TCA!) 04968 if ($conf['no_cache.']) $conf['no_cache']=$this->stdWrap($conf['no_cache'], $conf['no_cache.']); 04969 $link_params_parts=explode('#',$link_param); 04970 $link_param = trim($link_params_parts[0]); // Link-data del 04971 if (!strcmp($link_param,'')) {$link_param=$GLOBALS['TSFE']->id;} // If no id or alias is given 04972 if ($link_params_parts[1] && !$sectionMark) { 04973 $sectionMark='#'.trim($link_params_parts[1]); 04974 } 04975 // Splitting the parameter by ',' and if the array counts more than 1 element it's a id/type/? pair 04976 unset($theTypeP); 04977 $pairParts = t3lib_div::trimExplode(',',$link_param); 04978 if (count($pairParts)>1) { 04979 $link_param = $pairParts[0]; 04980 $theTypeP = $pairParts[1]; // Overruling 'type' 04981 } 04982 // Checking if the id-parameter is an alias. 04983 if (!t3lib_div::testInt($link_param)) { 04984 $link_param = $GLOBALS['TSFE']->sys_page->getPageIdFromAlias($link_param); 04985 } 04986 04987 // Looking up the page record to verify its existence: 04988 $disableGroupAccessCheck = $GLOBALS['TSFE']->config['config']['typolinkLinkAccessRestrictedPages'] ? TRUE : FALSE; 04989 $page = $GLOBALS['TSFE']->sys_page->getPage($link_param,$disableGroupAccessCheck); 04990 04991 if (count($page)) { 04992 // 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: 04993 $tCR_domain=''; 04994 if ($GLOBALS['TSFE']->config['config']['typolinkCheckRootline']) { 04995 $tCR_rootline = $GLOBALS['TSFE']->sys_page->getRootLine($page['uid']); // Gets rootline of linked-to page 04996 $tCR_flag = 0; 04997 foreach($tCR_rootline as $tCR_data) { 04998 if ($tCR_data['uid']==$GLOBALS['TSFE']->tmpl->rootLine[0]['uid']) { 04999 $tCR_flag = 1; // OK, it was in rootline! 05000 break; 05001 } 05002 } 05003 if (!$tCR_flag) { 05004 foreach($tCR_rootline as $tCR_data) { 05005 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('*', 'sys_domain', 'pid='.intval($tCR_data['uid']).' AND redirectTo=\'\''.$this->enableFields('sys_domain'), '', 'sorting'); 05006 if ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 05007 $tCR_domain = ereg_replace('\/$','',$row['domainName']); 05008 break; 05009 } 05010 } 05011 } 05012 } 05013 // MointPoints, look for closest MPvar: 05014 $MPvarAcc = array(); 05015 if (!$GLOBALS['TSFE']->config['config']['MP_disableTypolinkClosestMPvalue']) { 05016 $temp_MP = $this->getClosestMPvalueForPage($page['uid'],TRUE); 05017 if ($temp_MP) $MPvarAcc['closest'] = $temp_MP; 05018 } 05019 // Look for overlay Mount Point: 05020 $mount_info = $GLOBALS['TSFE']->sys_page->getMountPointInfo($page['uid'], $page); 05021 if (is_array($mount_info) && $mount_info['overlay']) { 05022 $page = $GLOBALS['TSFE']->sys_page->getPage($mount_info['mount_pid'],$disableGroupAccessCheck); 05023 if (!count($page)) { 05024 $GLOBALS['TT']->setTSlogMessage("typolink(): Mount point '".$mount_info['mount_pid']."' was not available, so '".$linktxt."' was not linked.",1); 05025 return $linktxt; 05026 } 05027 $MPvarAcc['re-map'] = $mount_info['MPvar']; 05028 } 05029 05030 // Setting title if blank value to link: 05031 if ($linktxt=='') $linktxt = $page['title']; 05032 05033 // Query Params: 05034 $addQueryParams = $conf['addQueryString'] ? '&'.t3lib_div::getIndpEnv('QUERY_STRING') : ''; 05035 $addQueryParams .= trim($this->stdWrap($conf['additionalParams'],$conf['additionalParams.'])); 05036 if (substr($addQueryParams,0,1)!='&') { 05037 $addQueryParams = ''; 05038 } elseif ($conf['useCacheHash']) { // cache hashing: 05039 $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) 05040 $addQueryParams.= '&cHash='.t3lib_div::shortMD5(serialize($pA)); 05041 } 05042 // Add "&MP" var: 05043 if (count($MPvarAcc)) { 05044 $addQueryParams.= '&MP='.rawurlencode(implode(',',$MPvarAcc)); 05045 } 05046 // If other domain, overwrite 05047 if ($tCR_domain) { 05048 $target = isset($conf['extTarget']) ? $conf['extTarget'] : $GLOBALS['TSFE']->extTarget; 05049 if ($conf['extTarget.']) {$target = $this->stdWrap($target, $conf['extTarget.']);} 05050 if ($forceTarget) {$target=$forceTarget;} 05051 $LD['target'] = $target; 05052 $this->lastTypoLinkUrl = $this->URLqMark('http://'.$tCR_domain.'/?id='.$page['uid'],$addQueryParams).$sectionMark; 05053 } else { // Internal link: 05054 if ($forceTarget) {$target=$forceTarget;} 05055 $LD = $GLOBALS['TSFE']->tmpl->linkData($page,$target,$conf['no_cache'],'','',$addQueryParams,$theTypeP); 05056 $this->lastTypoLinkUrl = $this->URLqMark($LD['totalURL'],'').$sectionMark; 05057 } 05058 05059 $this->lastTypoLinkTarget = $LD['target']; 05060 $targetPart = $LD['target'] ? ' target="'.$LD['target'].'"' : ''; 05061 05062 // If sectionMark is set AND the current page is the page the link is to, check if there are any additional parameters and is not, drop the url. 05063 if ($sectionMark && !trim($addQueryParams) && $page['uid']==$GLOBALS['TSFE']->id) { 05064 list(,$URLparams) = explode('?',$this->lastTypoLinkUrl); 05065 list($URLparams) = explode('#',$URLparams); 05066 parse_str ($URLparams.$LD['orig_type'], $URLparamsArray); 05067 if (intval($URLparamsArray['type'])==$GLOBALS['TSFE']->type) { // type nums must match as well as page ids 05068 unset($URLparamsArray['id']); 05069 unset($URLparamsArray['type']); 05070 if (!count($URLparamsArray)) { // If there are no parameters left.... set the new url. 05071 $this->lastTypoLinkUrl = $sectionMark; 05072 } 05073 } 05074 } 05075 05076 // If link is to a access restricted page which should be redirected, then find new URL: 05077 if ($GLOBALS['TSFE']->config['config']['typolinkLinkAccessRestrictedPages'] && 05078 $GLOBALS['TSFE']->config['config']['typolinkLinkAccessRestrictedPages']!=='NONE' && 05079 !$GLOBALS['TSFE']->checkPageGroupAccess($page)) { 05080 $thePage = $GLOBALS['TSFE']->sys_page->getPage($GLOBALS['TSFE']->config['config']['typolinkLinkAccessRestrictedPages']); 05081 05082 $addParams = $GLOBALS['TSFE']->config['config']['typolinkLinkAccessRestrictedPages_addParams']; 05083 $addParams = str_replace('###RETURN_URL###',rawurlencode($this->lastTypoLinkUrl),$addParams); 05084 $addParams = str_replace('###PAGE_ID###',$page['uid'],$addParams); 05085 $LD = $GLOBALS['TSFE']->tmpl->linkData($thePage,$target,'','','',$addParams,$theTypeP); 05086 $this->lastTypoLinkUrl = $this->URLqMark($LD['totalURL'],''); 05087 } 05088 05089 // Rendering the tag. 05090 $finalTagParts['url']=$this->lastTypoLinkUrl; 05091 $finalTagParts['targetParams']=$targetPart; 05092 $finalTagParts['TYPE']='page'; 05093 } else { 05094 $GLOBALS['TT']->setTSlogMessage("typolink(): Page id '".$link_param."' was not found, so '".$linktxt."' was not linked.",1); 05095 return $linktxt; 05096 } 05097 } 05098 } 05099 05100 if ($JSwindowParams) { 05101 $onClick="vHWin=window.open('".$GLOBALS['TSFE']->baseUrlWrap($finalTagParts['url'])."','FEopenLink','".$JSwindowParams."');vHWin.focus();return false;"; 05102 $res = '<a href="#" onclick="'.htmlspecialchars($onClick).'"'.($linkClass?' class="'.$linkClass.'"':'').$finalTagParts['aTagParams'].'>'; 05103 } else { 05104 if ($GLOBALS['TSFE']->spamProtectEmailAddresses === 'ascii' && $finalTagParts['TYPE'] === 'mailto') { 05105 $res = '<a href="'.$finalTagParts['url'].'"'.$finalTagParts['targetParams'].($linkClass?' class="'.$linkClass.'"':'').$finalTagParts['aTagParams'].'>'; 05106 } else { 05107 $res = '<a href="'.htmlspecialchars($finalTagParts['url']).'"'.$finalTagParts['targetParams'].($linkClass?' class="'.$linkClass.'"':'').$finalTagParts['aTagParams'].'>'; 05108 } 05109 } 05110 05111 // Call user function: 05112 if ($conf['userFunc']) { 05113 $finalTagParts['TAG']=$res; 05114 $res = $this->callUserFunction($conf['userFunc'],$conf['userFunc.'],$finalTagParts); 05115 } 05116 05117 // If flag "returnLastTypoLinkUrl" set, then just return the latest URL made: 05118 if ($conf['returnLast']) { 05119 switch($conf['returnLast']) { 05120 case 'url': 05121 return $this->lastTypoLinkUrl; 05122 break; 05123 case 'target': 05124 return $this->lastTypoLinkTarget; 05125 break; 05126 } 05127 } 05128 05129 if ($conf['ATagBeforeWrap']) { 05130 return $res.$this->wrap($linktxt, $conf['wrap']).'</a>'; 05131 } else { 05132 return $this->wrap($res.$linktxt.'</a>', $conf['wrap']); 05133 } 05134 } else { 05135 return $linktxt; 05136 } 05137 } 05138 05147 function typoLink_URL($conf) { 05148 $this->typolink('|',$conf); 05149 return $this->lastTypoLinkUrl; 05150 } 05151 05165 function getTypoLink($label,$params,$urlParameters=array(),$target='') { 05166 $conf=array(); 05167 $conf['parameter'] = $params; 05168 if ($target) { 05169 $conf['target']=$target; 05170 $conf['extTarget']=$target; 05171 } 05172 if (is_array($urlParameters)) { 05173 if (count($urlParameters)) { 05174 $conf['additionalParams'].= t3lib_div::implodeArrayForUrl('',$urlParameters); 05175 } 05176 } else { 05177 $conf['additionalParams'].=$urlParameters; 05178 } 05179 $out = $this->typolink($label,$conf); 05180 return $out; 05181 } 05182 05192 function getTypoLink_URL($params,$urlParameters=array(),$target='') { 05193 $this->getTypoLink('',$params,$urlParameters,$target); 05194 return $this->lastTypoLinkUrl; 05195 } 05196 05204 function typolinkWrap($conf) { 05205 $k=md5(microtime()); 05206 return explode($k,$this->typolink($k,$conf)); 05207 } 05208 05217 function currentPageUrl($urlParameters=array(),$id=0) { 05218 return $this->getTypoLink_URL($id?$id:$GLOBALS['TSFE']->id,$urlParameters,$GLOBALS['TSFE']->sPre); 05219 } 05220 05230 function getClosestMPvalueForPage($pageId, $raw=FALSE) { 05231 // MointPoints: 05232 if ($GLOBALS['TYPO3_CONF_VARS']['FE']['enable_mount_pids'] && $GLOBALS['TSFE']->MP) { 05233 05234 if (!strcmp($GLOBALS['TSFE']->id, $pageId)) { // same page as current. 05235 $MP = $GLOBALS['TSFE']->MP; 05236 } else { // ... otherwise find closest meeting point: 05237 $tCR_rootline = $GLOBALS['TSFE']->sys_page->getRootLine($pageId, '', TRUE); // Gets rootline of linked-to page 05238 $inverseTmplRootline = array_reverse($GLOBALS['TSFE']->tmpl->rootLine); 05239 05240 $rl_mpArray = array(); 05241 $startMPaccu = FALSE; 05242 05243 // Traverse root line of link uid and inside of that the REAL root line of current position. 05244 foreach($tCR_rootline as $tCR_data) { 05245 foreach($inverseTmplRootline as $rlKey => $invTmplRLRec) { 05246 05247 // Accumulate MP data: 05248 if ($startMPaccu && $invTmplRLRec['_MP_PARAM']) { 05249 $rl_mpArray[] = $invTmplRLRec['_MP_PARAM']; 05250 } 05251 05252 // If two PIDs matches and this is NOT the site root, start accumulation of MP data (on the next level): 05253 // (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!) 05254 if ($tCR_data['pid']==$invTmplRLRec['pid'] && count($inverseTmplRootline)!=$rlKey+1) { 05255 $startMPaccu = TRUE; 05256 } 05257 } 05258 if ($startMPaccu) break; // Good enough... 05259 } 05260 05261 if (count($rl_mpArray)) { 05262 $MP = implode(',', array_reverse($rl_mpArray)); 05263 } 05264 } 05265 } 05266 05267 return !$raw ? ($MP ? '&MP='.rawurlencode($MP) : '') : $MP; 05268 } 05269 05279 function getMailTo($mailAddress,$linktxt,$initP='?') { 05280 if(!strcmp($linktxt,'')) { $linktxt = $mailAddress; } 05281 05282 $mailToUrl = 'mailto:'.$mailAddress; 05283 05284 if (!$GLOBALS['TSFE']->config['config']['jumpurl_enable'] || $GLOBALS['TSFE']->config['config']['jumpurl_mailto_disable']) { 05285 if ($GLOBALS['TSFE']->spamProtectEmailAddresses) { 05286 if ($GLOBALS['TSFE']->spamProtectEmailAddresses === 'ascii') { 05287 $mailToUrl = $GLOBALS['TSFE']->encryptEmail($mailToUrl); 05288 } else { 05289 $mailToUrl = "javascript:linkTo_UnCryptMailto('".$GLOBALS['TSFE']->encryptEmail($mailToUrl)."');"; 05290 } 05291 if ($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses_atSubst']) { 05292 $atLabel = trim($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses_atSubst']); 05293 } 05294 $linktxt = str_replace('@',$atLabel?$atLabel:'(at)',$linktxt); 05295 05296 if ($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses_lastDotSubst']) { 05297 $lastDotLabel = trim($GLOBALS['TSFE']->config['config']['spamProtectEmailAddresses_lastDotSubst']); 05298 $lastDotLabel = $lastDotLabel ? $lastDotLabel : '(dot)'; 05299 $linktxt = preg_replace('/\.([^\.]+)$/', $lastDotLabel.'$1', $linktxt); 05300 } 05301 } 05302 } else { 05303 $mailToUrl = $GLOBALS['TSFE']->absRefPrefix.$GLOBALS['TSFE']->config['mainScript'].$initP.'&jumpurl='.rawurlencode($mailToUrl).$GLOBALS['TSFE']->getMethodUrlIdToken; 05304 } 05305 return array($mailToUrl,$linktxt); 05306 } 05307 05308 05309 05310 05311 05312 05313 05314 05315 05316 05317 05318 05319 05320 05321 05322 05323 05324 05325 /*********************************************** 05326 * 05327 * Miscellaneous functions, stand alone 05328 * 05329 ***********************************************/ 05330 05342 function wrap($content,$wrap,$char='|') { 05343 if ($wrap) { 05344 $wrapArr = explode($char, $wrap); 05345 return trim($wrapArr[0]).$content.trim($wrapArr[1]); 05346 } else return $content; 05347 } 05348 05358 function noTrimWrap($content,$wrap) { 05359 if ($wrap) { 05360 $wrapArr = explode('|', $wrap); 05361 return $wrapArr[1].$content.$wrapArr[2]; 05362 } else return $content; 05363 } 05364 05372 function wrapSpace($content, $wrap) { 05373 $result = $content; 05374 if (trim($wrap)) { 05375 $wrapArray = explode('|',$wrap); 05376 $wrapBefore = intval($wrapArray[0]); 05377 $wrapAfter = intval($wrapArray[1]); 05378 if ($wrapBefore) { 05379 $result = '<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$wrapBefore.'"'.$this->getBorderAttr(' border="0"').' class="spacer-gif" alt="" title="" /><br />'.$result; 05380 } 05381 if ($wrapAfter) { 05382 $result.='<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$wrapAfter.'"'.$this->getBorderAttr(' border="0"').' class="spacer-gif" alt="" title="" /><br />'; 05383 } 05384 } 05385 return $result; 05386 } 05387 05398 function callUserFunction($funcName,$conf,$content) { 05399 $pre = $GLOBALS['TSFE']->TYPO3_CONF_VARS['FE']['userFuncClassPrefix']; 05400 if ($pre && 05401 !t3lib_div::isFirstPartOfStr(trim($funcName),$pre) && 05402 !t3lib_div::isFirstPartOfStr(trim($funcName),'tx_') 05403 ) { 05404 $GLOBALS['TT']->setTSlogMessage('Function "'.$funcName.'" was not prepended with "'.$pre.'"',3); 05405 return $content; 05406 } 05407 // Split parts 05408 $parts = explode('->',$funcName); 05409 if (count($parts)==2) { // Class 05410 $cls = t3lib_div::makeInstanceClassName($parts[0]); 05411 if (class_exists ($cls)) { 05412 $classObj = new $cls; 05413 if (method_exists($classObj, $parts[1])) { 05414 $classObj->cObj = &$this; 05415 $content = call_user_method($parts[1], $classObj, $content, $conf); 05416 } else { 05417 $GLOBALS['TT']->setTSlogMessage('Method "'.$parts[1].'" did not exist in class "'.$cls.'"',3); 05418 } 05419 } else { 05420 $GLOBALS['TT']->setTSlogMessage('Class "'.$cls.'" did not exist',3); 05421 } 05422 } else { // Function 05423 if (function_exists($funcName)) { 05424 $content = call_user_func($funcName, $content, $conf); 05425 } else { 05426 $GLOBALS['TT']->setTSlogMessage('Function "'.$funcName.'" did not exist',3); 05427 } 05428 } 05429 return $content; 05430 } 05431 05439 function processParams($params) { 05440 $paramArr=array(); 05441 $lines=t3lib_div::trimExplode(chr(10),$params,1); 05442 foreach($lines as $val) { 05443 $pair = explode('=',$val,2); 05444 if (!t3lib_div::inList('#,/',substr(trim($pair[0]),0,1))) { 05445 $paramArr[trim($pair[0])] = trim($pair[1]); 05446 } 05447 } 05448 return $paramArr; 05449 } 05450 05457 function keywords($content) { 05458 $listArr = split(',|;|'.chr(10),$content); 05459 reset($listArr); 05460 while(list($k,$v)=each($listArr)) { 05461 $listArr[$k]=trim($v); 05462 } 05463 return implode(',',$listArr); 05464 } 05465 05474 function caseshift($theValue, $case) { 05475 $case = strtolower($case); 05476 switch($case) { 05477 case 'upper': 05478 $theValue = $GLOBALS['TSFE']->csConvObj->conv_case($GLOBALS['TSFE']->renderCharset,$theValue,'toUpper'); 05479 #$theValue = strtoupper($theValue); 05480 #$theValue = strtr($theValue, $this->caseConvStrings[0], $this->caseConvStrings[1]); 05481 break; 05482 case 'lower': 05483 $theValue = $GLOBALS['TSFE']->csConvObj->conv_case($GLOBALS['TSFE']->renderCharset,$theValue,'toLower'); 05484 #$theValue = strtolower($theValue); 05485 #$theValue = strtr($theValue, $this->caseConvStrings[1], $this->caseConvStrings[0]); 05486 break; 05487 } 05488 return $theValue; 05489 } 05490 05499 function HTMLcaseshift($theValue, $case) { 05500 $inside = 0; 05501 $newVal = ''; 05502 $pointer = 0; 05503 $totalLen = strlen($theValue); 05504 do { 05505 if (!$inside) { 05506 $len = strcspn(substr($theValue,$pointer),'<'); 05507 $newVal.= $this->caseshift(substr($theValue,$pointer,$len),$case); 05508 $inside = 1; 05509 } else { 05510 $len = strcspn(substr($theValue,$pointer),'>')+1; 05511 $newVal.= substr($theValue,$pointer,$len); 05512 $inside = 0; 05513 } 05514 $pointer+=$len; 05515 } while($pointer<$totalLen); 05516 return $newVal; 05517 } 05518 05528 function bytes($sizeInBytes,$labels) { 05529 return t3lib_div::formatSize($sizeInBytes,$labels); 05530 } 05531 05539 function calcAge($seconds,$labels) { 05540 if (t3lib_div::testInt($labels)) { 05541 $labels = ' min| hrs| days| yrs'; 05542 } else { 05543 $labels=str_replace('"','',$labels); 05544 } 05545 05546 $labelArr = explode('|',$labels); 05547 if ($seconds<3600) { 05548 $seconds = round ($seconds/60).$labelArr[0]; 05549 } elseif ($seconds<24*3600) { 05550 $seconds = round ($seconds/3600).$labelArr[1]; 05551 } elseif ($seconds<365*24*3600) { 05552 $seconds = round ($seconds/(24*3600)).$labelArr[2]; 05553 } else { 05554 $seconds = round ($seconds/(365*24*3600)).$labelArr[3]; 05555 } 05556 return $seconds; 05557 } 05558 05570 function sendNotifyEmail($msg, $recipients, $cc, $email_from, $email_fromName='', $replyTo='') { 05571 // Sends order emails: 05572 $headers=array(); 05573 if ($email_from) {$headers[]='From: '.$email_fromName.' <'.$email_from.'>';} 05574 if ($replyTo) {$headers[]='Reply-To: '.$replyTo;} 05575 05576 $recipients=implode(',',t3lib_div::trimExplode(',',$recipients,1)); 05577 05578 $emailContent = trim($msg); 05579 if ($emailContent) { 05580 $parts = split(chr(10),$emailContent,2); // First line is subject 05581 $subject=trim($parts[0]); 05582 $plain_message=trim($parts[1]); 05583 05584 if ($recipients) $GLOBALS['TSFE']->plainMailEncoded($recipients, $subject, $plain_message, implode(chr(10),$headers)); 05585 if ($cc) $GLOBALS['TSFE']->plainMailEncoded($cc, $subject, $plain_message, implode(chr(10),$headers)); 05586 return true; 05587 } 05588 } 05589 05597 function URLqMark($url,$params) { 05598 if ($params && !strstr($url,'?')) { 05599 return $url.'?'.$params; 05600 } else { 05601 return $url.$params; 05602 } 05603 } 05604 05613 function checkEmail($email) { 05614 return t3lib_div::validEmail($email); 05615 } 05616 05625 function clearTSProperties($TSArr,$propList) { 05626 $list = explode(',',$propList); 05627 while(list(,$prop)=each($list)) { 05628 $prop = trim($prop); 05629 unset($TSArr[$prop]); 05630 unset($TSArr[$prop.'.']); 05631 } 05632 return $TSArr; 05633 } 05634 05644 function mergeTSRef($confArr,$prop) { 05645 if (substr($confArr[$prop],0,1)=='<') { 05646 $key = trim(substr($confArr[$prop],1)); 05647 $cF = t3lib_div::makeInstance('t3lib_TSparser'); 05648 // $name and $conf is loaded with the referenced values. 05649 $old_conf=$confArr[$prop.'.']; 05650 list($name, $conf) = $cF->getVal($key,$GLOBALS['TSFE']->tmpl->setup); 05651 if (is_array($old_conf) && count($old_conf)) { 05652 $conf = $this->joinTSarrays($conf,$old_conf); 05653 } 05654 $confArr[$prop.'.']=$conf; 05655 } 05656 return $confArr; 05657 } 05658 05667 function joinTSarrays($conf,$old_conf) { 05668 if (is_array($old_conf)) { 05669 reset($old_conf); 05670 while(list($key,$val)=each($old_conf)) { 05671 if (is_array($val)) { 05672 $conf[$key] = $this->joinTSarrays($conf[$key],$val); 05673 } else { 05674 $conf[$key] = $val; 05675 } 05676 } 05677 } 05678 return $conf; 05679 } 05680 05690 function gifBuilderTextBox($gifbuilderConf, $conf, $text) { 05691 $chars = intval($conf['chars']) ? intval($conf['chars']) : 20; 05692 $lineDist = intval($conf['lineDist']) ? intval($conf['lineDist']) : 20; 05693 $Valign = strtolower(trim($conf['Valign'])); 05694 $tmplObjNumber = intval($conf['tmplObjNumber']); 05695 $maxLines = intval($conf['maxLines']); 05696 05697 if ($tmplObjNumber && $gifbuilderConf[$tmplObjNumber]=='TEXT') { 05698 $textArr = $this->linebreaks($text,$chars,$maxLines); 05699 $angle = intval($gifbuilderConf[$tmplObjNumber.'.']['angle']); 05700 reset($textArr); 05701 while(list($c,$textChunk)=each($textArr)) { 05702 $index = $tmplObjNumber+1+($c*2); 05703 // Workarea 05704 $gifbuilderConf = $this->clearTSProperties($gifbuilderConf,$index); 05705 $rad_angle = 2*pi()/360*$angle; 05706 $x_d = sin($rad_angle)*$lineDist; 05707 $y_d = cos($rad_angle)*$lineDist; 05708 05709 $diff_x_d=0; 05710 $diff_y_d=0; 05711 if ($Valign=='center') { 05712 $diff_x_d = $x_d*count($textArr); 05713 $diff_x_d = $diff_x_d/2; 05714 $diff_y_d = $y_d*count($textArr); 05715 $diff_y_d = $diff_y_d/2; 05716 } 05717 05718 05719 $x_d = round($x_d*$c - $diff_x_d); 05720 $y_d = round($y_d*$c - $diff_y_d); 05721 05722 $gifbuilderConf[$index] = 'WORKAREA'; 05723 $gifbuilderConf[$index.'.']['set'] = $x_d.','.$y_d; 05724 // Text 05725 $index++; 05726 $gifbuilderConf = $this->clearTSProperties($gifbuilderConf,$index); 05727 $gifbuilderConf[$index] = 'TEXT'; 05728 $gifbuilderConf[$index.'.'] = $this->clearTSProperties($gifbuilderConf[$tmplObjNumber.'.'],'text'); 05729 $gifbuilderConf[$index.'.']['text'] = $textChunk; 05730 } 05731 $gifbuilderConf = $this->clearTSProperties($gifbuilderConf,$tmplObjNumber); 05732 } 05733 return $gifbuilderConf; 05734 } 05735 05746 function linebreaks($string,$chars,$maxLines=0) { 05747 $lines = explode(chr(10),$string); 05748 $lineArr=Array(); 05749 $c=0; 05750 while(list(,$paragraph)=each($lines)) { 05751 $words = explode(' ',$paragraph); 05752 while(list(,$word)=each($words)) { 05753 if (strlen($lineArr[$c].$word)>$chars) { 05754 $c++; 05755 } 05756 if (!$maxLines || $c<$maxLines) { 05757 $lineArr[$c].= $word.' '; 05758 } 05759 } 05760 $c++; 05761 } 05762 return $lineArr; 05763 } 05764 05777 function getUpdateJS($dataArray, $formName, $arrPrefix, $fieldList) { 05778 $JSPart=''; 05779 $updateValues=t3lib_div::trimExplode(',',$fieldList); 05780 while(list(,$fKey)=each($updateValues)) { 05781 $value = $dataArray[$fKey]; 05782 if (is_array($value)) { 05783 reset($value); 05784 while(list(,$Nvalue)=each($value)) { 05785 $JSPart.=" 05786 updateForm('".$formName."','".$arrPrefix."[".$fKey."][]',unescape('".rawurlencode($Nvalue)."'))"; 05787 } 05788 05789 } else { 05790 $JSPart.=" 05791 updateForm('".$formName."','".$arrPrefix."[".$fKey."]',unescape('".rawurlencode($value)."'))"; 05792 } 05793 } 05794 $JSPart='<script type="text/javascript"> 05795 /*<![CDATA[*/ '.$JSPart.' 05796 /*]]>*/ 05797 </script> 05798 '; 05799 $GLOBALS['TSFE']->additionalHeaderData['JSincludeFormupdate']='<script type="text/javascript" src="'.$GLOBALS['TSFE']->absRefPrefix.'t3lib/jsfunc.updateform.js"></script>'; 05800 return $JSPart; 05801 } 05802 05803 05804 05805 05806 05807 05808 05809 05810 05811 05812 05813 05814 05815 05816 05817 05818 05819 05820 05821 05822 05823 05824 05825 05826 05827 05828 05829 05830 /*********************************************** 05831 * 05832 * Database functions, making of queries 05833 * 05834 ***********************************************/ 05835 05846 function DBgetDelete($table, $uid, $doExec=FALSE) { 05847 if (intval($uid)) { 05848 if ($GLOBALS['TCA'][$table]['ctrl']['delete']) { 05849 if ($doExec) { 05850 return $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid='.intval($uid), array($GLOBALS['TCA'][$table]['ctrl']['delete'] => 1)); 05851 } else { 05852 return $GLOBALS['TYPO3_DB']->UPDATEquery($table, 'uid='.intval($uid), array($GLOBALS['TCA'][$table]['ctrl']['delete'] => 1)); 05853 } 05854 } else { 05855 if ($doExec) { 05856 return $GLOBALS['TYPO3_DB']->exec_DELETEquery($table, 'uid='.intval($uid)); 05857 } else { 05858 return $GLOBALS['TYPO3_DB']->DELETEquery($table, 'uid='.intval($uid)); 05859 } 05860 } 05861 } 05862 } 05863 05878 function DBgetUpdate($table, $uid, $dataArr, $fieldList, $doExec=FALSE) { 05879 unset($dataArr['uid']); // uid can never be set 05880 $uid=intval($uid); 05881 05882 if ($uid) { 05883 $fieldList = implode(',',t3lib_div::trimExplode(',',$fieldList,1)); 05884 $updateFields=array(); 05885 05886 foreach($dataArr as $f => $v) { 05887 if (t3lib_div::inList($fieldList,$f)) { 05888 $updateFields[$f] = $v; 05889 } 05890 } 05891 05892 if ($GLOBALS['TCA'][$table]['ctrl']['tstamp']) { 05893 $updateFields[$GLOBALS['TCA'][$table]['ctrl']['tstamp']] = time(); 05894 } 05895 05896 if (count($updateFields)) { 05897 if ($doExec) { 05898 return $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid='.intval($uid), $updateFields); 05899 } else { 05900 return $GLOBALS['TYPO3_DB']->UPDATEquery($table, 'uid='.intval($uid), $updateFields); 05901 } 05902 } 05903 } 05904 } 05905 05920 function DBgetInsert($table, $pid, $dataArr, $fieldList, $doExec=FALSE) { 05921 $extraList='pid'; 05922 if ($GLOBALS['TCA'][$table]['ctrl']['tstamp']) {$field=$GLOBALS['TCA'][$table]['ctrl']['tstamp']; $dataArr[$field]=time(); $extraList.=','.$field;} 05923 if ($GLOBALS['TCA'][$table]['ctrl']['crdate']) {$field=$GLOBALS['TCA'][$table]['ctrl']['crdate']; $dataArr[$field]=time(); $extraList.=','.$field;} 05924 if ($GLOBALS['TCA'][$table]['ctrl']['cruser_id']) {$field=$GLOBALS['TCA'][$table]['ctrl']['cruser_id']; $dataArr[$field]=0; $extraList.=','.$field;} 05925 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;} 05926 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;} 05927 05928 unset($dataArr['uid']); // uid can never be set 05929 if ($pid>=0) { $dataArr['pid'] = $pid; } // Set pid < 0 and the dataarr-pid will be used! 05930 $fieldList = implode(',',t3lib_div::trimExplode(',',$fieldList.','.$extraList,1)); 05931 05932 $insertFields = array(); 05933 foreach($dataArr as $f => $v) { 05934 if (t3lib_div::inList($fieldList,$f)) { 05935 $insertFields[$f] = $v; 05936 } 05937 } 05938 05939 if ($doExec) { 05940 return $GLOBALS['TYPO3_DB']->exec_INSERTquery($table, $insertFields); 05941 } else { 05942 return $GLOBALS['TYPO3_DB']->INSERTquery($table, $insertFields); 05943 } 05944 } 05945 05957 function DBmayFEUserEdit($table,$row, $feUserRow, $allowedGroups='',$feEditSelf=0) { 05958 $groupList = $allowedGroups ? implode(',',array_intersect(t3lib_div::trimExplode(',',$feUserRow['usergroup'],1),t3lib_div::trimExplode(',',$allowedGroups,1))) : $feUserRow['usergroup']; 05959 $ok=0; 05960 // points to the field that allows further editing from frontend if not set. If set the record is locked. 05961 if (!$GLOBALS['TCA'][$table]['ctrl']['fe_admin_lock'] || !$row[$GLOBALS['TCA'][$table]['ctrl']['fe_admin_lock']]) { 05962 // points to the field (integer) that holds the fe_users-id of the creator fe_user 05963 if ($GLOBALS['TCA'][$table]['ctrl']['fe_cruser_id']) { 05964 $rowFEUser = intval($row[$GLOBALS['TCA'][$table]['ctrl']['fe_cruser_id']]); 05965 if ($rowFEUser && $rowFEUser==$feUserRow['uid']) { 05966 $ok=1; 05967 } 05968 } 05969 // If $feEditSelf is set, fe_users may always edit them selves... 05970 if ($feEditSelf && $table=='fe_users' && !strcmp($feUserRow['uid'],$row['uid'])) { 05971 $ok=1; 05972 } 05973 // points to the field (integer) that holds the fe_group-id of the creator fe_user's first group 05974 if ($GLOBALS['TCA'][$table]['ctrl']['fe_crgroup_id']) { 05975 $rowFEUser = intval($row[$GLOBALS['TCA'][$table]['ctrl']['fe_crgroup_id']]); 05976 if ($rowFEUser) { 05977 if (t3lib_div::inList($groupList, $rowFEUser)) { 05978 $ok=1; 05979 } 05980 } 05981 } 05982 } 05983 return $ok; 05984 } 05985 05997 function DBmayFEUserEditSelect($table,$feUserRow,$allowedGroups='',$feEditSelf=0) { 05998 // Returns where-definition that selects user-editable records. 05999 $groupList = $allowedGroups ? implode(',',array_intersect(t3lib_div::trimExplode(',',$feUserRow['usergroup'],1),t3lib_div::trimExplode(',',$allowedGroups,1))) : $feUserRow['usergroup']; 06000 $OR_arr=array(); 06001 // points to the field (integer) that holds the fe_users-id of the creator fe_user 06002 if ($GLOBALS['TCA'][$table]['ctrl']['fe_cruser_id']) { 06003 $OR_arr[]=$GLOBALS['TCA'][$table]['ctrl']['fe_cruser_id'].'='.$feUserRow['uid']; 06004 } 06005 // points to the field (integer) that holds the fe_group-id of the creator fe_user's first group 06006 if ($GLOBALS['TCA'][$table]['ctrl']['fe_crgroup_id']) { 06007 $values = t3lib_div::intExplode(',',$groupList); 06008 while(list(,$theGroupUid)=each($values)) { 06009 if ($theGroupUid) {$OR_arr[]=$GLOBALS['TCA'][$table]['ctrl']['fe_crgroup_id'].'='.$theGroupUid;} 06010 } 06011 } 06012 // If $feEditSelf is set, fe_users may always edit them selves... 06013 if ($feEditSelf && $table=='fe_users') { 06014 $OR_arr[]='uid='.intval($feUserRow['uid']); 06015 } 06016 06017 $whereDef=' AND 1=0'; 06018 if (count($OR_arr)) { 06019 $whereDef=' AND ('.implode(' OR ',$OR_arr).')'; 06020 if ($GLOBALS['TCA'][$table]['ctrl']['fe_admin_lock']) { 06021 $whereDef.=' AND '.$GLOBALS['TCA'][$table]['ctrl']['fe_admin_lock'].'=0'; 06022 } 06023 } 06024 return $whereDef; 06025 } 06026 06037 function enableFields($table,$show_hidden=0) { 06038 return $GLOBALS['TSFE']->sys_page->enableFields($table,$show_hidden?$show_hidden:($table=='pages' ? $GLOBALS['TSFE']->showHiddenPage : $GLOBALS['TSFE']->showHiddenRecords)); 06039 } 06040 06061 function getTreeList($id,$depth,$begin=0,$dontCheckEnableFields=FALSE,$addSelectFields='',$moreWhereClauses='', $prevId_array=array(), $recursionLevel=0) { 06062 06063 // Init vars: 06064 $allFields = 'uid,hidden,starttime,endtime,fe_group,extendToSubpages,doktype,php_tree_stop,mount_pid,mount_pid_ol'.$addSelectFields; 06065 $depth = intval($depth); 06066 $begin = intval($begin); 06067 $id = intval($id); 06068 $theList = ''; 06069 $addId = 0; 06070 06071 if ($id) { 06072 06073 // First level, check id (second level, this is done BEFORE the recursive call) 06074 if (!$recursionLevel) { 06075 // If Id less than zero it means we should add the real id to list: 06076 if ($id < 0) { 06077 $addId = $id = abs($id); 06078 } 06079 // Check start page: 06080 if ($GLOBALS['TSFE']->sys_page->getRawRecord('pages',$id,'uid')) { 06081 06082 // Find mount point if any: 06083 $mount_info = $GLOBALS['TSFE']->sys_page->getMountPointInfo($id); 06084 if (is_array($mount_info)) { 06085 $id = $mount_info['mount_pid']; 06086 // In Overlay mode, use the mounted page uid as added ID!: 06087 if ($addId && $mount_info['overlay']) { 06088 $addId = $id; 06089 } 06090 } 06091 } else return ''; // Return blank if the start page was NOT found at all! 06092 } 06093 06094 // Add this ID to the array of IDs 06095 if ($begin<=0) { 06096 $prevId_array[] = $id; 06097 } 06098 06099 // Select sublevel: 06100 if ($depth>0) { 06101 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($allFields, 'pages', 'pid='.intval($id).' AND deleted=0 AND doktype!=255 AND doktype!=6'.$moreWhereClauses, '' ,'sorting'); 06102 while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 06103 #?? $GLOBALS['TSFE']->sys_page->versionOL('pages',$row); 06104 06105 // Find mount point if any: 06106 $next_id = $row['uid']; 06107 $mount_info = $GLOBALS['TSFE']->sys_page->getMountPointInfo($next_id, $row); 06108 // Overlay mode: 06109 if (is_array($mount_info) && $mount_info['overlay']) { 06110 $next_id = $mount_info['mount_pid']; 06111 $res2 = $GLOBALS['TYPO3_DB']->exec_SELECTquery($allFields, 'pages', 'uid='.intval($next_id).' AND deleted=0 AND doktype!=255 AND doktype!=6'.$moreWhereClauses, '' ,'sorting'); 06112 $row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res2); 06113 #?? $GLOBALS['TSFE']->sys_page->versionOL('pages',$row); 06114 } 06115 // Add record: 06116 if (is_array($row) && ($dontCheckEnableFields || $GLOBALS['TSFE']->checkPagerecordForIncludeSection($row))) { 06117 // Add ID to list: 06118 if ($begin<=0) { 06119 if ($dontCheckEnableFields || $GLOBALS['TSFE']->checkEnableFields($row)) { 06120 $theList.= $next_id.','; 06121 } 06122 } 06123 // Next level: 06124 if ($depth>1 && !$row['php_tree_stop']) { 06125 // Normal mode: 06126 if (is_array($mount_info) && !$mount_info['overlay']) { 06127 $next_id = $mount_info['mount_pid']; 06128 } 06129 // Call recursively, if the id is not in prevID_array: 06130 if (!in_array($next_id,$prevId_array)) { 06131 $theList.= tslib_cObj::getTreeList($next_id, $depth-1, $begin-1, $dontCheckEnableFields, $addSelectFields, $moreWhereClauses, $prevId_array, $recursionLevel+1); 06132 } 06133 } 06134 } 06135 } 06136 } 06137 } 06138 // If first run, check if the ID should be returned: 06139 if (!$recursionLevel) { 06140 if ($addId) { 06141 if ($begin>0) { 06142 $theList.= 0; 06143 } else { 06144 $theList.= $addId; 06145 } 06146 } 06147 } 06148 // Return list: 06149 return $theList; 06150 } 06151 06161 function whereSelectFromList($field,$value) { 06162 return $GLOBALS['TYPO3_DB']->listQuery($field,$value,''); 06163 } 06164 06179 function exec_mm_query($select,$local_table,$mm_table,$foreign_table,$whereClause='',$groupBy='',$orderBy='',$limit='') { 06180 return $GLOBALS['TYPO3_DB']->exec_SELECTquery( 06181 $select, 06182 $local_table.','.$mm_table.($foreign_table?','.$foreign_table:''), 06183 $local_table.'.uid='.$mm_table.'.uid_local'.($foreign_table?' AND '.$foreign_table.'.uid='.$mm_table.'.uid_foreign':''). 06184 $whereClause, // whereClauseMightContainGroupOrderBy 06185 $groupBy, 06186 $orderBy, 06187 $limit 06188 ); 06189 } 06190 06206 function exec_mm_query_uidList($select,$local_table_uidlist,$mm_table,$foreign_table='',$whereClause='',$groupBy='',$orderBy='',$limit='') { 06207 return $GLOBALS['TYPO3_DB']->exec_SELECTquery( 06208 $select, 06209 $mm_table.($foreign_table?','.$foreign_table:''), 06210 $mm_table.'.uid_local IN ('.$local_table_uidlist.')'.($foreign_table?' AND '.$foreign_table.'.uid='.$mm_table.'.uid_foreign':''). 06211 $whereClause, // whereClauseMightContainGroupOrderBy 06212 $groupBy, 06213 $orderBy, 06214 $limit 06215 ); 06216 } 06217 06227 function searchWhere($sw,$searchFieldList,$searchTable='') { 06228 $prefixTableName = $searchTable ? $searchTable.'.' : ''; 06229 $where = ''; 06230 if ($sw) { 06231 $searchFields = explode(',',$searchFieldList); 06232 $kw = split('[ ,]',$sw); 06233 06234 while(list(,$val)=each($kw)) { 06235 $val = trim($val); 06236 $where_p = array(); 06237 if (strlen($val)>=2) { 06238 reset($searchFields); 06239 while(list(,$field)=each($searchFields)) { 06240 $where_p[] = $prefixTableName.$field.' LIKE \'%'.$GLOBALS['TYPO3_DB']->quoteStr($val, $searchTable).'%\''; 06241 } 06242 } 06243 if (count($where_p)) { 06244 $where.=' AND ('.implode(' OR ',$where_p).')'; 06245 } 06246 } 06247 } 06248 return $where; 06249 } 06250 06260 function exec_getQuery($table, $conf) { 06261 $queryParts = $this->getQuery($table, $conf, TRUE); 06262 06263 return $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts); 06264 } 06265 06278 function getQuery($table, $conf, $returnQueryArray=FALSE) { 06279 06280 // Construct WHERE clause: 06281 $conf['pidInList'] = trim($this->stdWrap($conf['pidInList'],$conf['pidInList.'])); 06282 if (!strcmp($conf['pidInList'],'')) { 06283 $conf['pidInList'] = 'this'; 06284 } 06285 $queryParts = $this->getWhere($table,$conf,TRUE); 06286 06287 // Fields: 06288 $queryParts['SELECT'] = $conf['selectFields'] ? $conf['selectFields'] : '*'; 06289 06290 // Setting LIMIT: 06291 if ($conf['max'] || $conf['begin']) { 06292 $error=0; 06293 06294 // Finding the total number of records, if used: 06295 if (strstr(strtolower($conf['begin'].$conf['max']),'total')) { 06296 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', $table, $queryParts['WHERE'], $queryParts['GROUPBY']); 06297 if ($error = $GLOBALS['TYPO3_DB']->sql_error()) { 06298 $GLOBALS['TT']->setTSlogMessage($error); 06299 } else { 06300 $total = $GLOBALS['TYPO3_DB']->sql_num_rows($res); 06301 $conf['max'] = eregi_replace('total', (string)$total, $conf['max']); 06302 $conf['begin'] = eregi_replace('total', (string)$total, $conf['begin']); 06303 } 06304 } 06305 if (!$error) { 06306 $conf['begin'] = t3lib_div::intInRange(ceil($this->calc($conf['begin'])),0); 06307 $conf['max'] = t3lib_div::intInRange(ceil($this->calc($conf['max'])),0); 06308 if ($conf['begin'] && !$conf['max']) { 06309 $conf['max'] = 100000; 06310 } 06311 06312 if ($conf['begin'] && $conf['max']) { 06313 $queryParts['LIMIT'] = $conf['begin'].','.$conf['max']; 06314 } elseif (!$conf['begin'] && $conf['max']) { 06315 $queryParts['LIMIT'] = $conf['max']; 06316 } 06317 } 06318 } 06319 06320 if (!$error) { 06321 06322 // Setting up tablejoins: 06323 $joinPart=''; 06324 if ($conf['join']) { 06325 $joinPart = 'JOIN ' .trim($conf['join']); 06326 } elseif ($conf['leftjoin']) { 06327 $joinPart = 'LEFT OUTER JOIN ' .trim($conf['leftjoin']); 06328 } elseif ($conf['rightjoin']) { 06329 $joinPart = 'RIGHT OUTER JOIN ' .trim($conf['rightjoin']); 06330 } 06331 06332 // Compile and return query: 06333 $queryParts['FROM'] = trim($table.' '.$joinPart); 06334 $query = $GLOBALS['TYPO3_DB']->SELECTquery( 06335 $queryParts['SELECT'], 06336 $queryParts['FROM'], 06337 $queryParts['WHERE'], 06338 $queryParts['GROUPBY'], 06339 $queryParts['ORDERBY'], 06340 $queryParts['LIMIT'] 06341 ); 06342 return $returnQueryArray ? $queryParts : $query; 06343 } 06344 } 06345 06357 function getWhere($table,$conf, $returnQueryArray=FALSE) { 06358 global $TCA; 06359 06360 // Init: 06361 $query = ''; 06362 $pid_uid_flag=0; 06363 $queryParts = array( 06364 'SELECT' => '', 06365 'FROM' => '', 06366 'WHERE' => '', 06367 'GROUPBY' => '', 06368 'ORDERBY' => '', 06369 'LIMIT' => '' 06370 ); 06371 06372 if (trim($conf['uidInList'])) { 06373 $listArr = t3lib_div::intExplode(',',str_replace('this',$GLOBALS['TSFE']->contentPid,$conf['uidInList'])); // str_replace instead of ereg_replace 020800 06374 if (count($listArr)==1) { 06375 $query.=' AND '.$table.'.uid='.intval($listArr[0]); 06376 } else { 06377 $query.=' AND '.$table.'.uid IN ('.implode(',',$GLOBALS['TYPO3_DB']->cleanIntArray($listArr)).')'; 06378 } 06379 $pid_uid_flag++; 06380 } 06381 if (trim($conf['pidInList'])) { 06382 $listArr = t3lib_div::intExplode(',',str_replace('this',$GLOBALS['TSFE']->contentPid,$conf['pidInList'])); // str_replace instead of ereg_replace 020800 06383 // removes all pages which are not visible for the user! 06384 $listArr = $this->checkPidArray($listArr); 06385 if (count($listArr)) { 06386 $query.=' AND '.$table.'.pid IN ('.implode(',',$GLOBALS['TYPO3_DB']->cleanIntArray($listArr)).')'; 06387 $pid_uid_flag++; 06388 } else { 06389 $pid_uid_flag=0; // If not uid and not pid then uid is set to 0 - which results in nothing!! 06390 } 06391 } 06392 if (!$pid_uid_flag) { // If not uid and not pid then uid is set to 0 - which results in nothing!! 06393 $query.=' AND '.$table.'.uid=0'; 06394 } 06395 if ($where = trim($conf['where'])) { 06396 $query.=' AND '.$where; 06397 } 06398 06399 if ($conf['languageField']) { 06400 if ($GLOBALS['TSFE']->sys_language_contentOL && $TCA[$table] && $TCA[$table]['ctrl']['languageField'] && $TCA[$table]['ctrl']['transOrigPointerField']) { 06401 // 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! 06402 $sys_language_content = '0,-1'; 06403 } else { 06404 $sys_language_content = intval($GLOBALS['TSFE']->sys_language_content); 06405 } 06406 $query.=' AND '.$conf['languageField'].' IN ('.$sys_language_content.')'; 06407 } 06408 06409 $andWhere = trim($this->stdWrap($conf['andWhere'],$conf['andWhere.'])); 06410 if ($andWhere) { 06411 $query.=' AND '.$andWhere; 06412 } 06413 06414 // enablefields 06415 if ($table=='pages') { 06416 $query.=' '.$GLOBALS['TSFE']->sys_page->where_hid_del. 06417 $GLOBALS['TSFE']->sys_page->where_groupAccess; 06418 } else { 06419 $query.=$this->enableFields($table); 06420 } 06421 06422 // MAKE WHERE: 06423 if ($query) { 06424 $queryParts['WHERE'] = trim(substr($query,4)); // Stripping of " AND"... 06425 $query = 'WHERE '.$queryParts['WHERE']; 06426 } 06427 06428 // GROUP BY 06429 if (trim($conf['groupBy'])) { 06430 $queryParts['GROUPBY'] = trim($conf['groupBy']); 06431 $query.=' GROUP BY '.$queryParts['GROUPBY']; 06432 } 06433 06434 // ORDER BY 06435 if (trim($conf['orderBy'])) { 06436 $queryParts['ORDERBY'] = trim($conf['orderBy']); 06437 $query.=' ORDER BY '.$queryParts['ORDERBY']; 06438 } 06439 06440 // Return result: 06441 return $returnQueryArray ? $queryParts : $query; 06442 } 06443 06452 function checkPidArray($listArr) { 06453 $outArr = Array(); 06454 if (is_array($listArr) && count($listArr)) { 06455 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'uid IN ('.implode(',',$listArr).')'.$this->enableFields('pages').' AND doktype NOT IN ('.$this->checkPid_badDoktypeList.')'); 06456 if ($error = $GLOBALS['TYPO3_DB']->sql_error()) { 06457 $GLOBALS['TT']->setTSlogMessage($error.': '.$query,3); 06458 } else { 06459 while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) { 06460 $outArr[] = $row['uid']; 06461 } 06462 } 06463 } 06464 return $outArr; 06465 } 06466 06475 function checkPid($uid) { 06476 $uid = intval($uid); 06477 if (!isset($this->checkPid_cache[$uid])) { 06478 $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery('uid', 'pages', 'uid='.intval($uid).$this->enableFields('pages').' AND doktype NOT IN ('.$this->checkPid_badDoktypeList.')'); 06479 if ($GLOBALS['TYPO3_DB']->sql_num_rows($res)) { 06480 $this->checkPid_cache[$uid] = 1; 06481 } else { 06482 $this->checkPid_cache[$uid] = 0; 06483 } 06484 } 06485 return $this->checkPid_cache[$uid]; 06486 } 06487 06488 06489 06490 06491 06492 06493 06494 06495 06496 06497 06498 06499 06500 06501 06502 06503 06504 06505 06506 06507 06508 06509 06510 06511 06512 06513 /*********************************************** 06514 * 06515 * Frontend editing functions 06516 * 06517 ***********************************************/ 06518 06531 function editPanel($content, $conf, $currentRecord='', $dataArr=array()) { 06532 global $TCA,$BE_USER; 06533 06534 // If no backend user, return immediately 06535 if (!$GLOBALS['TSFE']->beUserLogin) {return $content;} 06536 06537 // If a backend user is logged in, then go on... 06538 if ($conf['newRecordFromTable']) { 06539 $currentRecord = $conf['newRecordFromTable'].':NEW'; 06540 $conf['allow']='new'; 06541 } 06542 06543 if (!$currentRecord) $currentRecord=$this->currentRecord; 06544 if (!count($dataArr)) $dataArr=$this->data; 06545 list($table,$uid) = explode(':',$currentRecord); 06546 $mayEdit=0; 06547 06548 if (!$conf['onlyCurrentPid'] || $dataArr['pid']==$GLOBALS['TSFE']->id) { 06549 // Permissions: 06550 $types = t3lib_div::trimExplode(',',strtolower($conf['allow']),1); 06551 $allow = array_flip($types); 06552 06553 $perms = $GLOBALS['BE_USER']->calcPerms($GLOBALS['TSFE']->page); 06554 if ($table=='pages') { 06555 if (count($GLOBALS['TSFE']->config['rootLine'])==1) {unset($allow['move']); unset($allow['hide']); unset($allow['delete']);} // rootpage! 06556 if (!($perms&2)) {unset($allow['edit']);unset($allow['move']);unset($allow['hide']);} 06557 if (!($perms&4)) unset($allow['delete']); 06558 if (!($perms&8)) unset($allow['new']); 06559 if (count($allow)) $mayEdit=1; // Can only display editbox if there are options in the menu 06560 $newUid = $uid; 06561 } else { 06562 $mayEdit = count($allow)&&($perms&16); 06563 if ($conf['newRecordFromTable']) { 06564 $newUid=$GLOBALS['TSFE']->id; 06565 } else { 06566 $newUid = -1*$uid; 06567 } 06568 } 06569 } 06570 06571 if ($GLOBALS['TSFE']->displayEditIcons && $table && $mayEdit) { 06572 $GLOBALS['TSFE']->set_no_cache(); // Special content is about to be shown, so the cache must be disabled. 06573 $formName = 'TSFE_EDIT_FORM_'.substr($GLOBALS['TSFE']->uniqueHash(),0,4); 06574 $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;">'; 06575 $sortField = $TCA[$table]['ctrl']['sortby']; 06576 $labelField = $TCA[$table]['ctrl']['label']; 06577 $hideField = $TCA[$table]['ctrl']['enablecolumns']['disabled']; 06578 $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 />':''; 06579 06580 $theCmd=''; 06581 $TSFE_EDIT = t3lib_div::_POST('TSFE_EDIT'); 06582 if (is_array($TSFE_EDIT) && $TSFE_EDIT['record']==$currentRecord && !$TSFE_EDIT['update_close']) { 06583 $theCmd =$TSFE_EDIT['cmd']; 06584 } 06585 06586 switch($theCmd) { 06587 case 'edit': 06588 case 'new': 06589 $tceforms = t3lib_div::makeInstance('t3lib_TCEforms_FE'); 06590 $tceforms->prependFormFieldNames = 'TSFE_EDIT[data]'; 06591 $tceforms->prependFormFieldNames_file = 'TSFE_EDIT_file'; 06592 $tceforms->doSaveFieldName = 'TSFE_EDIT[doSave]'; 06593 $tceforms->formName = $formName; 06594 $tceforms->backPath = TYPO3_mainDir; 06595 $tceforms->setFancyDesign(); 06596 $tceforms->defStyle = 'font-family:Verdana;font-size:10px;'; 06597 $tceforms->edit_showFieldHelp = $GLOBALS['BE_USER']->uc['edit_showFieldHelp']; 06598 $tceforms->helpTextFontTag='<font face="verdana,sans-serif" color="#333333" size="1">'; 06599 06600 $trData = t3lib_div::makeInstance('t3lib_transferData'); 06601 $trData->addRawData = TRUE; 06602 $trData->defVals = t3lib_div::_GP('defVals'); // Added without testing - should provide ability to submit default values in frontend editing, in-page. 06603 $trData->fetchRecord($table, ($theCmd=='new'?$newUid:$dataArr['uid']), ($theCmd=='new'?'new':'') ); 06604 reset($trData->regTableItems_data); 06605 $processedDataArr = current($trData->regTableItems_data); 06606 $processedDataArr['uid']=$theCmd=='new'?'NEW':$dataArr['uid']; 06607 $processedDataArr['pid']=$theCmd=='new'?$newUid:$dataArr['pid']; 06608 06609 $panel=''; 06610 $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).'" />'; 06611 $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).'" />'; 06612 $buttons.= '<input type="image" border="0" name="TSFE_EDIT[cancel]" onclick="'. 06613 htmlspecialchars('document.location=\''.t3lib_div::getIndpEnv('REQUEST_URI').'\';return false;'). 06614 '" 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).'" />'; 06615 $panel.=$tceforms->intoTemplate(array('ITEM'=>$buttons)); // Buttons top 06616 $panel.=$tceforms->getMainFields($table,$processedDataArr); 06617 06618 $hiddenF=""; 06619 if ($theCmd=='new') { 06620 $hiddenF.='<input type="hidden" name="TSFE_EDIT[data]['.$table.'][NEW][pid]" value="'.$newUid.'" />'; 06621 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! 06622 } else { 06623 $hiddenF.='<input type="hidden" name="TSFE_EDIT[record]" value="'.$currentRecord.'" />'; 06624 $hiddenF.='<input type="hidden" name="TSFE_EDIT[cmd]" value="edit" />'; 06625 } 06626 $hiddenF.='<input type="hidden" name="TSFE_EDIT[doSave]" value="0" />'; 06627 $panel.=$tceforms->intoTemplate(array('ITEM'=>$buttons.$hiddenF)); // Buttons AND hidden fields bottom. 06628 06629 $panel=$formTag.$tceforms->wrapTotal($panel,$dataArr,$table).'</form>'.($theCmd!='new'?$blackLine:''); 06630 $finalOut = $tceforms->printNeededJSFunctions_top().($conf['edit.']['displayRecord']?$content:'').$panel.($theCmd=='new'?$blackLine:'').$tceforms->printNeededJSFunctions(); 06631 break; 06632 default: 06633 $panel = ''; 06634 if (isset($allow['toolbar'])) $panel.=$GLOBALS['BE_USER']->ext_makeToolBar().'<img src="clear.gif" width="2" height="1" alt="" title="" />'; 06635 if (isset($allow['edit'])) $panel.=$this->editPanelLinkWrap('<img src="t3lib/gfx/edit2.gif" width="11" height="12" hspace="2" border="0" title="'.$BE_USER->extGetLL('p_editRecord').'" align="top" alt="" title="" />',$formName,'edit',$currentRecord); 06636 if (isset($allow['move']) && $sortField) { 06637 $panel.=$this->editPanelLinkWrap('<img src="t3lib/gfx/button_up.gif" width="11" height="10" vspace="1" hspace="2" border="0" title="'.$BE_USER->extGetLL('p_moveUp').'" align="top" alt="" title="" />',$formName,'up'); 06638 $panel.=$this->editPanelLinkWrap('<img src="t3lib/gfx/button_down.gif" width="11" height="10" vspace="1" hspace="2" border="0" title="'.$BE_USER->extGetLL('p_moveDown').'" align="top" alt="" title="" />',$formName,'down'); 06639 } 06640 if (isset($allow['hide']) && $hideField) { 06641 if ($dataArr[$hideField]) { 06642 $panel.=$this->editPanelLinkWrap('<img src="t3lib/gfx/button_unhide.gif" width="11" height="10" vspace="1" hspace="2" border="0" title="'.$BE_USER->extGetLL('p_unhide').'" align="top" alt="" title="" />',$formName,'unhide'); 06643 } else { 06644 $panel.=$this->editPanelLinkWrap('<img src="t3lib/gfx/button_hide.gif" width="11" height="10" vspace="1" hspace="2" border="0" title="'.$BE_USER->extGetLL('p_hide').'" align="top" alt="" title="" />',$formName,'hide','',$BE_USER->extGetLL('p_hideConfirm')); 06645 } 06646 } 06647 if (isset($allow['new'])) { 06648 if ($table=='pages') { 06649 $panel.=$this->editPanelLinkWrap('<img src="t3lib/gfx/new_page.gif" width="13" height="12" vspace="1" hspace="2" border="0" title="'.$BE_USER->extGetLL('p_newSubpage').'" align="top" alt="" title="" />',$formName,'new',$currentRecord); 06650 } else { 06651 $panel.=$this->editPanelLinkWrap('<img src="t3lib/gfx/new_record.gif" width="16" height="12" vspace="1" hspace="2" border="0" title="'.$BE_USER->extGetLL('p_newRecordAfter').'" align="top" alt="" title="" />',$formName,'new',$currentRecord); 06652 } 06653 } 06654 if (isset($allow['delete'])) {$panel.=$this->editPanelLinkWrap('<img src="t3lib/gfx/delete_record.gif" width="12" height="12" vspace="1" hspace="2" border="0" title="'.$BE_USER->extGetLL('p_delete').'" align="top" alt="" title="" />',$formName,'delete','',$BE_USER->extGetLL('p_deleteConfirm')); } 06655 06656 // Final 06657 $labelTxt = $this->stdWrap($conf['label'],$conf['label.']); 06658 $panel=' 06659 06660 <!-- BE_USER Edit Panel: --> 06661 '.$formTag.' 06662 <input type="hidden" name="TSFE_EDIT[cmd]" value="" /> 06663 <input type="hidden" name="TSFE_EDIT[record]" value="'.$currentRecord.'" /> 06664 <table border="0" cellpadding="0" cellspacing="0" border="1" bordercolor="black" class="typo3-editPanel"> 06665 <tr> 06666 <td nowrap="nowrap" bgcolor="#ABBBB4" class="typo3-editPanel-controls">'.$panel.'</td>'.($labelTxt?' 06667 <td nowrap="nowrap" bgcolor="#F6F2E6" class="typo3-editPanel-label"><font face="verdana" size="1" color="black"> '.sprintf($labelTxt,htmlspecialchars(t3lib_div::fixed_lgd($dataArr[$labelField],50))).' </font></td>':'').' 06668 </tr> 06669 </table> 06670 </form>'; 06671 // wrap the panel 06672 if ($conf['innerWrap']) $panel = $this->wrap($panel,$conf['innerWrap']); 06673 if ($conf['innerWrap.']) $panel = $this->stdWrap($panel,$conf['innerWrap.']); 06674 // add black line: 06675 $panel.=$blackLine; 06676 // wrap the complete panel 06677 if ($conf['outerWrap']) $panel = $this->wrap($panel,$conf['outerWrap']); 06678 if ($conf['outerWrap.']) $panel = $this->stdWrap($panel,$conf['outerWrap.']); 06679 $finalOut = $content.$panel; 06680 break; 06681 } 06682 06683 if ($conf['previewBorder']) $finalOut = $this->editPanelPreviewBorder($table,$dataArr,$finalOut,$conf['previewBorder'],$conf['previewBorder.']); 06684 return $finalOut; 06685 } else { 06686 return $content; 06687 } 06688 } 06689 06702 function editIcons($content,$params, $conf=array(), $currentRecord='', $dataArr=array(),$addUrlParamStr='') { 06703 global $BE_USER; 06704 06705 // If no backend user, return immediately 06706 if (!$GLOBALS['TSFE']->beUserLogin) {return $content;} 06707 06708 // Check incoming params: 06709 $rParts = explode(':',$currentRecord?$currentRecord:$this->currentRecord); 06710 06711 list($table,$fieldList)=t3lib_div::trimExplode(':',$params,1); 06712 if (!$fieldList) { 06713 $fieldList=$table; 06714 $table=$rParts[0]; 06715 } else { 06716 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. 06717 } 06718 06719 // Check if allowed to edit content: 06720 $mayEdit=0; 06721 $dataArr=count($dataArr)?$dataArr:$this->data; // If pages-record, should contain correct perms-field, if not, should contain correct pid value. 06722 06723 if ($table=='pages') { 06724 $mayEdit = $BE_USER->isAdmin()||$BE_USER->doesUserHaveAccess($dataArr,2)?1:0; 06725 } else { 06726 $mayEdit = $BE_USER->isAdmin()||$BE_USER->doesUserHaveAccess(t3lib_BEfunc::getRecord('pages',$dataArr['pid']),16)?1:0; 06727 } 06728 06729 if ($GLOBALS['TSFE']->displayFieldEditIcons && $table && $mayEdit && $fieldList) { 06730 $GLOBALS['TSFE']->set_no_cache(); // Special content is about to be shown, so the cache must be disabled. 06731 $style = $conf['styleAttribute'] ? ' style="'.htmlspecialchars($conf['styleAttribute']).'"' : ''; 06732 $iconTitle = $this->stdWrap($conf['iconTitle'],$conf['iconTitle.']); 06733 $iconImg = $conf['iconImg'] ? $conf['iconImg'] : '<img src="t3lib/gfx/edit_fe.gif" width="11" height="12" border="0" align="top" title="'.t3lib_div::deHSCentities(htmlspecialchars($iconTitle)).'"'.$style.' class="frontEndEditIcons" alt="" title="" />'; 06734 $nV=t3lib_div::_GP('ADMCMD_view')?1:0; 06735 $adminURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL').TYPO3_mainDir; 06736 $icon = $this->editPanelLinkWrap_doWrap($iconImg, $adminURL.'alt_doc.php?edit['.$rParts[0].']['.$rParts[1].']=edit&columnsOnly='.rawurlencode($fieldList).'&noView='.$nV.$addUrlParamStr,implode(':',$rParts)); 06737 if ($conf['beforeLastTag']<0) { 06738 $content=$icon.$content; 06739 } elseif ($conf['beforeLastTag']>0) { 06740 $cBuf = rtrim($content); 06741 $securCount=30; 06742 while($securCount && substr($cBuf,-1)=='>' && substr($cBuf,-4)!='</a>') { 06743 $cBuf = rtrim(ereg_replace('<[^<]*>$','',$cBuf)); 06744 $securCount--; 06745 } 06746 $content = strlen($cBuf)&&$securCount ? substr($content,0,strlen($cBuf)).$icon.substr($content,strlen($cBuf)) : $content=$icon.$content; 06747 } else { 06748 $content.=$icon; 06749 } 06750 } 06751 return $content; 06752 } 06753 06767 function editPanelLinkWrap($string,$formName,$cmd,$currentRecord='',$confirm='') { 06768 $eFONPage = $GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_editFormsOnPage']; 06769 $nV=t3lib_div::_GP('ADMCMD_view')?1:0; 06770 $adminURL = t3lib_div::getIndpEnv('TYPO3_SITE_URL').TYPO3_mainDir; 06771 06772 if ($cmd=='edit' && !$eFONPage) { 06773 $rParts = explode(':',$currentRecord); 06774 $out=$this->editPanelLinkWrap_doWrap($string,$adminURL.'alt_doc.php?edit['.$rParts[0].']['.$rParts[1].']=edit&noView='.$nV,$currentRecord); 06775 } elseif ($cmd=='new' && !$eFONPage) { 06776 $rParts = explode(':',$currentRecord); 06777 if ($rParts[0]=='pages') { 06778 $out=$this->editPanelLinkWrap_doWrap($string,$adminURL.'db_new.php?id='.$rParts[1].'&pagesOnly=1',$currentRecord); 06779 } else { 06780 $nPid = t3lib_div::testInt($rParts[1]) ? -$rParts[1] : $GLOBALS['TSFE']->id; 06781 $out=$this->editPanelLinkWrap_doWrap($string,$adminURL.'alt_doc.php?edit['.$rParts[0].']['.$nPid.']=new&noView='.$nV,$currentRecord); 06782 } 06783 } else { 06784 if ($confirm) { 06785 $cf1="if (confirm(unescape('".t3lib_div::rawurlencodeJS($confirm)."'))){"; 06786 $cf2='}'; 06787 } else { 06788 $cf1=$cf2=''; 06789 } 06790 $out='<a href="#" onclick="'. 06791 htmlspecialchars($cf1.'document.'.$formName.'[\'TSFE_EDIT[cmd]\'].value=\''.$cmd.'\'; document.'.$formName.'.submit();'.$cf2.' return false;'). 06792 '">'.$string.'</a>'; 06793 } 06794 return $out; 06795 } 06796 06807 function editPanelLinkWrap_doWrap($string,$url,$currentRecord) { 06808 if ($GLOBALS['BE_USER']->uc['TSFE_adminConfig']['edit_editNoPopup'] || $GLOBALS['BE_USER']->extAdminConfig['module.']['edit.']['forceNoPopup']) { 06809 $retUrl = t3lib_div::getIndpEnv('REQUEST_URI'); 06810 $rParts = explode(':',$currentRecord); 06811 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. 06812 $retUrl.='#'.$rParts[1]; 06813 } 06814 return '<a href="'.htmlspecialchars($url.'&returnUrl='.rawurlencode($retUrl)).'">'.$string.'</a>'; 06815 } else { 06816 return '<a href="#" onclick="'. 06817 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;'). 06818 '">'.$string.'</a>'; 06819 } 06820 } 06821 06835 function editPanelPreviewBorder($table,$row,$content,$thick,$conf=array()) { 06836 if ($this->isDisabled($table,$row)) { 06837 $thick = t3lib_div::intInRange($thick,1,100); 06838 $color = $conf['color'] ? $conf['color'] : '#cccccc'; 06839 if ($conf['innerWrap']) $content = $this->wrap($content,$conf['innerWrap']); 06840 if ($conf['innerWrap.']) $content = $this->stdWrap($content,$conf['innerWrap.']); 06841 $content='<table class="typo3-editPanel-previewBorder" border="'.$thick.'" cellpadding="0" cellspacing="0" bordercolor="'.$color.'" width="100%"><tr><td>'.$content.'</td></tr></table>'; 06842 if ($conf['outerWrap']) $content = $this->wrap($content,$conf['outerWrap']); 06843 if ($conf['outerWrap.']) $content = $this->stdWrap($panel,$conf['outerWrap.']); 06844 } 06845 return $content; 06846 } 06847 06857 function isDisabled($table,$row) { 06858 global $TCA; 06859 if ( 06860 ($TCA[$table]['ctrl']['enablecolumns']['disabled'] && $row[$TCA[$table]['ctrl']['enablecolumns']['disabled']]) || 06861 ($TCA[$table]['ctrl']['enablecolumns']['fe_group'] && $GLOBALS['TSFE']->simUserGroup && $row[$TCA[$table]['ctrl']['enablecolumns']['fe_group']]==$GLOBALS['TSFE']->simUserGroup) || 06862 ($TCA[$table]['ctrl']['enablecolumns']['starttime'] && $row[$TCA[$table]['ctrl']['enablecolumns']['starttime']]>time() ) || 06863 ($TCA[$table]['ctrl']['enablecolumns']['endtime'] && $row[$TCA[$table]['ctrl']['enablecolumns']['endtime']] && $row[$TCA[$table]['ctrl']['enablecolumns']['endtime']]<time()) 06864 ) return true; 06865 } 06866 } 06867 06868 06869 06870 06871 06872 06873 06874 06875 06876 06877 06878 06879 06880 06888 class tslib_frameset { 06889 06898 function make($setup) { 06899 $content = ''; 06900 if (is_array($setup)) { 06901 $sKeyArray=t3lib_TStemplate::sortedKeyList($setup); 06902 reset($sKeyArray); 06903 while(list(,$theKey)=each($sKeyArray)) { 06904 $theValue=$setup[$theKey]; 06905 if (intval($theKey) && $conf=$setup[$theKey.'.']) { 06906 switch($theValue) { 06907 case 'FRAME': 06908 $typeNum = intval($GLOBALS['TSFE']->tmpl->setup[$conf['obj'].'.']['typeNum']); 06909 if (!$conf['src'] && !$typeNum) { 06910 $typeNum = -1; 06911 } 06912 $content.='<frame'.$this->frameParams($conf,$typeNum).' />'.chr(10); 06913 break; 06914 case 'FRAMESET': 06915 $frameset = t3lib_div::makeInstance('tslib_frameset'); 06916 $content.=$frameset->make($conf).chr(10); 06917 break; 06918 } 06919 } 06920 } 06921 return '<frameset'.$this->framesetParams($setup).'>'.chr(10).$content.'</frameset>'; 06922 } 06923 } 06924 06935 function frameParams($setup, $typeNum) { 06936 $paramStr = ''; 06937 $name = $setup['obj']; 06938 06939 /* 06940 if ($GLOBALS['TSFE']->config['config']['simulateStaticDocuments']) { 06941 $theCompURL=''; 06942 $theCompURL.=$GLOBALS['TSFE']->makeSimulFileName($GLOBALS['TSFE']->page['title'], 06943 ($GLOBALS['TSFE']->page['alias'] ? $GLOBALS['TSFE']->page['alias'] : $GLOBALS['TSFE']->page['uid']), 06944 intval($typeNum)); 06945 if ($GLOBALS['TSFE']->config['config']['simulateStaticDocuments']=='PATH_INFO') { 06946 $theCompURL = str_replace('.','/',$theCompURL); 06947 $theCompURL = 'index.php/'.$theCompURL.'/?'; 06948 } else { 06949 $theCompURL.='.html?'; 06950 } 06951 } else { 06952 $theCompURL = $GLOBALS['TSFE']->config['mainScript'].'?id='.$GLOBALS['TSFE']->page['uid'].'&type='.intval($typeNum); 06953 } 06954 // Add absRefPrefix if exists. 06955 $finalURL = $GLOBALS['TSFE']->absRefPrefix.$theCompURL.($setup['options']?'&'.$setup['options']:'').$GLOBALS['TSFE']->linkVars.$GLOBALS['TSFE']->getMethodUrlIdToken.($GLOBALS['TSFE']->no_cache?'&no_cache=1':''); 06956 $finalURL = $GLOBALS['TSFE']->tmpl->removeQueryString($finalURL); 06957 */ 06958 06959 // From 3.6.0, use "linkData" for ALL links: 06960 $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)); 06961 $finalURL = $LD['totalURL']; 06962 06963 06964 if ($setup['src']) {$paramStr.=' src="'.htmlspecialchars($setup['src']).'"';} else {$paramStr.=' src="'.htmlspecialchars($finalURL).'"';} 06965 if ($setup['name']) {$paramStr.=' name="'.$setup['name'].'"';} else {$paramStr.=' name="'.$name.'"';} 06966 if ($setup['params']) {$paramStr.=' '.$setup['params'];} 06967 return $paramStr; 06968 } 06969 06978 function framesetParams($setup) { 06979 $paramStr = ''; 06980 if ($setup['cols']) { $paramStr.=' cols="'.$setup['cols'].'"'; } 06981 if ($setup['rows']) { $paramStr.=' rows="'.$setup['rows'].'"'; } 06982 if ($setup['params']) { $paramStr.=' '.$setup['params']; } 06983 return $paramStr; 06984 } 06985 } 06986 06987 06988 06989 06990 06991 06992 06993 06994 06995 06996 06997 06998 06999 07000 07001 07002 07011 class tslib_tableOffset { 07012 var $tableParams = 'border="0" cellspacing="0" cellpadding="0"'; 07013 var $default_tableParams = 'border="0" cellspacing="0" cellpadding="0"'; 07014 var $tdParams = ' width="99%" valign="top"'; 07015 07023 function start($content,$offset) { 07024 $valPairs = t3lib_div::intExplode(',',$offset.',,,,,'); 07025 07026 if ($valPairs[0] || $valPairs[1] || $valPairs[2] || $valPairs[3] || $valPairs[4] || $valPairs[5]) { 07027 // If width is defined AND there has been no change to the default table params, then extend them to a tablewidth of 1 07028 if ($valPairs[4] && $this->default_tableParams==$this->tableParams) {$this->tableParams.=' width="1"';} 07029 // Init: 07030 $this->begin = chr(10).'<table '.$this->tableParams.'>'; 07031 $this->end = '</table>'; 07032 $rows=array(); 07033 $widthImg = ''; 07034 $heightImg = ''; 07035 // If width is required, set so bottom column will display for sure 07036 if ($valPairs[4]) { 07037 if (!$valPairs[3]) $valPairs[3]=1; 07038 $widthImg='<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.$valPairs[4].'" height="1" alt="" title="" />'; 07039 } 07040 // If height is required, set so right column will display for sure 07041 if ($valPairs[5]) { 07042 if (!$valPairs[2]) $valPairs[2]=1; 07043 $valPairs[2]=1; $heightImg='<img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$valPairs[5].'" alt="" title="" />'; 07044 } 07045 07046 // First row: 07047 if ($valPairs[1]) { // top 07048 $rows[1].= '<tr>'; 07049 $rows[1].= '<td><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="'.($valPairs[0]?$valPairs[0]:1).'" height="'.$valPairs[1].'" alt="" title="" /></td>'; 07050 if ($valPairs[0]) $rows[1].= '<td></td>'; 07051 if ($valPairs[2]) $rows[1].= '<td></td>'; 07052 $rows[1].= '</tr>'; 07053 } 07054 // Middle row: 07055 $rows[2].= '<tr>'; 07056 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>';} 07057 $rows[2].= '<td'.$this->tdParams.'>'.$content.'</td>'; 07058 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>';} 07059 $rows[2].= '</tr>'; 07060 // Bottom row: 07061 if ($valPairs[3]) { // bottom 07062 $rows[3].= '<tr>'; 07063 if ($valPairs[0]) $rows[3].= '<td></td>'; 07064 if ($valPairs[2]) $rows[3].= '<td>'.$widthImg.'</td>'; 07065 $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>'; 07066 $rows[3].= '</tr>'; 07067 } 07068 return $this->begin.implode('',$rows).$this->end; 07069 } else return $content; 07070 } 07071 } 07072 07073 07074 07075 07076 07077 07078 07079 07080 07081 07082 07083 07084 07085 07086 07087 07088 07089 07090 07091 07092 07101 class tslib_controlTable { 07102 var $offX = 0; // offset, x 07103 var $offY = 0; // offset, y 07104 07105 var $tm = ''; // top menu 07106 var $lm = ''; // left menu 07107 var $rm = ''; // right menu 07108 var $bm = ''; // bottom menu 07109 var $content = ''; // content 07110 07111 var $tmTDparams = 'valign="top"'; // top menu TDparams 07112 var $lmTDparams = 'valign="top"'; // left menu TDparams 07113 var $rmTDparams = 'valign="top"'; // right menu TDparams 07114 var $bmTDparams = 'valign="top"'; // bottom menu TDparams 07115 var $contentTDparams = 'valign="top"'; // content TDparams 07116 07117 var $cMl = 1; // content margin, left 07118 var $cMr = 1; // content margin, right 07119 var $cMt = 0; // content margin, top 07120 var $cMb = 1; // content margin, bottom 07121 07122 var $contentW = 0; // Places a little gif-spacer in the bottom of the content frame 07123 07124 var $tableParams = 'border="0" cellspacing="0" cellpadding="0"'; 07125 07136 function start($offset,$cMargins) { 07137 $offArr = t3lib_div::intExplode(',',$offset); 07138 $cMargArr = t3lib_div::intExplode(',',$cMargins); 07139 07140 $cols = 0; 07141 $rows = 0; 07142 07143 if ($this->lm) $cols++; 07144 if ($this->rm) $cols++; 07145 if ($cMargArr[0]) $cols++; 07146 if ($cMargArr[2]) $cols++; 07147 if ($cMargArr[1]||$cMargArr[3]||$this->tm||$this->bm||$this->content||$this->contentW) $cols++; 07148 07149 if ($cMargArr[1]) $rows++; 07150 if ($cMargArr[3]) $rows++; 07151 if ($this->tm) $rows++; 07152 if ($this->bm) $rows++; 07153 if ($this->content) $rows++; 07154 if ($this->contentW) $rows++; 07155 if (!$rows && $cols) $rows=1; // If there are no rows in the middle but still som columns... 07156 07157 if ($rows&&$cols) { 07158 $res = chr(10).'<table '.$this->tableParams.'>'; 07159 // top offset: 07160 if ($offArr[1]) { 07161 $xoff = $offArr[0] ? 1 : 0; 07162 if ($cols+$xoff > 1) {$colspan =' colspan="'.($cols+$xoff).'"';} 07163 $res.= '<tr><td'.$colspan.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$offArr[1].'" alt="" title="" /></td></tr>'; 07164 } 07165 // The rows: 07166 if ($rows>1) {$rowspan =' rowspan="'.($rows).'"';} 07167 $res.= '<tr>'; 07168 if ($offArr[0]) { $res.='<td'.$rowspan.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" height="1" width="'.$offArr[0].'" alt="" title="" /></td>'; } 07169 if ($this->lm) { $res.='<td'.$rowspan.' '.$this->lmTDparams.'>'.$this->lm.'</td>'; } 07170 if ($cMargArr[0]) { $res.='<td'.$rowspan.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" height="1" width="'.$cMargArr[0].'" alt="" title="" /></td>'; } 07171 // content... 07172 07173 $middle=Array(); 07174 if ($this->tm) { $middle[]='<td '.$this->tmTDparams.'>'.$this->tm.'</td>';} 07175 if ($cMargArr[1]) { $middle[]='<td><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$cMargArr[1].'" alt="" title="" /></td>';} 07176 if ($this->content) { $middle[]='<td '.$this->contentTDparams.'>'.$this->content.'</td>';} 07177 if ($cMargArr[3]) { $middle[]='<td><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" width="1" height="'.$cMargArr[3].'" alt="" title="" /></td>';} 07178 if ($this->bm) { $middle[]='<td '.$this->bmTDparams.'>'.$this->bm.'</td>';} 07179 if ($this->contentW) { $middle[]='<td><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" height="1" width="'.$this->contentW.'" alt="" title="" /></td>';} 07180 if (isset($middle[0])) {$res.=$middle[0];} 07181 07182 // Left of content 07183 if ($cMargArr[2]) { $res.='<td'.$rowspan.'><img src="'.$GLOBALS['TSFE']->absRefPrefix.'clear.gif" height="1" width="'.$cMargArr[2].'" alt="" title="" /></td>'; } 07184 if ($this->rm) { $res.='<td'.$rowspan.' '.$this->rmTDparams.'>'.$this->rm.'</td>'; } 07185 $res.= '</tr>'; 07186 07187 // More than the two rows 07188 $mCount = count($middle); 07189 for($a=1;$a<$mCount;$a++) { 07190 $res.='<tr>'.$middle[$a].'</tr>'; 07191 } 07192 $res.='</table>'; 07193 return $res; 07194 } 07195 } 07196 } 07197 07198 07199 07200 07201 07202 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_content.php']) { 07203 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['tslib/class.tslib_content.php']); 07204 } 07205 ?>