00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00083 require_once (PATH_t3lib.'class.t3lib_parsehtml.php');
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00103 class t3lib_parsehtml_proc extends t3lib_parsehtml {
00104
00105
00106 var $headListTags = 'PRE,UL,OL,H1,H2,H3,H4,H5,H6,HR,ADDRESS,DL';
00107
00108
00109 var $recPid = 0;
00110 var $elRef = '';
00111 var $relPath='';
00112 var $relBackPath='';
00113 var $procOptions = '';
00114
00115
00116 var $TS_transform_db_safecounter=100;
00117 var $rte_p='';
00118 var $getKeepTags_cache=array();
00119 var $allowedClasses=array();
00120 var $preserveTags = '';
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00138 function init($elRef='',$recPid=0) {
00139 $this->recPid = $recPid;
00140 $this->elRef = $elRef;
00141 }
00142
00150 function setRelPath($path) {
00151 $path = trim($path);
00152 $path = ereg_replace('^/','',$path);
00153 $path = ereg_replace('/$','',$path);
00154 if ($path) {
00155 $this->relPath = $path;
00156 $this->relBackPath = '';
00157 $partsC=count(explode('/',$this->relPath));
00158 for ($a=0;$a<$partsC;$a++) {
00159 $this->relBackPath.='../';
00160 }
00161 $this->relPath.='/';
00162 }
00163 }
00164
00174 function evalWriteFile($pArr,$currentRecord) {
00175
00176
00177 if (is_array($pArr)) {
00178 if ($GLOBALS['TYPO3_CONF_VARS']['BE']['staticFileEditPath']
00179 && substr($GLOBALS['TYPO3_CONF_VARS']['BE']['staticFileEditPath'],-1)=='/'
00180 && @is_dir(PATH_site.$GLOBALS['TYPO3_CONF_VARS']['BE']['staticFileEditPath'])) {
00181
00182 $SW_p = $pArr['parameters'];
00183 $SW_editFileField = trim($SW_p[0]);
00184 $SW_editFile = $currentRecord[$SW_editFileField];
00185 if ($SW_editFileField && $SW_editFile && t3lib_div::validPathStr($SW_editFile)) {
00186 $SW_relpath = $GLOBALS['TYPO3_CONF_VARS']['BE']['staticFileEditPath'].$SW_editFile;
00187 $SW_editFile = PATH_site.$SW_relpath;
00188 if (@is_file($SW_editFile)) {
00189 return array(
00190 'editFile' => $SW_editFile,
00191 'relEditFile' => $SW_relpath,
00192 'contentField' => trim($SW_p[1]),
00193 'markerField' => trim($SW_p[2]),
00194 'loadFromFileField' => trim($SW_p[3]),
00195 'statusField' => trim($SW_p[4])
00196 );
00197 } else return "ERROR: Editfile '".$SW_relpath."' did not exist";
00198 } else return "ERROR: Edit file name could not be found or was bad.";
00199 } else return "ERROR: staticFileEditPath was not set, not set correctly or did not exist!";
00200 }
00201 }
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00232 function RTE_transform($value,$specConf,$direction='rte',$thisConfig=array()) {
00233
00234
00235 $this->procOptions = $thisConfig['proc.'];
00236 $this->preserveTags = strtoupper(implode(',',t3lib_div::trimExplode(',',$this->procOptions['preserveTags'])));
00237
00238
00239 $p = $this->rte_p = t3lib_BEfunc::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
00240
00241
00242 if (strcmp($this->procOptions['overruleMode'],'')) {
00243 $modes = array_unique(t3lib_div::trimExplode(',',$this->procOptions['overruleMode']));
00244 } else {
00245 $modes = array_unique(t3lib_div::trimExplode('-',$p['mode']));
00246 }
00247 $revmodes = array_flip($modes);
00248
00249
00250 if (isset($revmodes['ts'])) {
00251 $modes[$revmodes['ts']] = 'ts_transform,ts_preserve,ts_images,ts_links';
00252 }
00253
00254 if (isset($revmodes['ts_css'])) {
00255 $modes[$revmodes['ts_css']] = 'css_transform,ts_images,ts_links';
00256 }
00257
00258
00259 $modes = array_unique(t3lib_div::trimExplode(',',implode(',',$modes),1));
00260
00261
00262 if ($direction=='rte') {
00263 $modes = array_reverse($modes);
00264 }
00265
00266
00267 $entry_HTMLparser = $this->procOptions['entryHTMLparser_'.$direction] ? $this->HTMLparserConfig($this->procOptions['entryHTMLparser_'.$direction.'.']) : '';
00268 $exit_HTMLparser = $this->procOptions['exitHTMLparser_'.$direction] ? $this->HTMLparserConfig($this->procOptions['exitHTMLparser_'.$direction.'.']) : '';
00269
00270
00271 if (!$this->procOptions['disableUnifyLineBreaks']) {
00272 $value = str_replace(chr(13).chr(10),chr(10),$value);
00273 }
00274
00275
00276 if (is_array($entry_HTMLparser)) {
00277 $value = $this->HTMLcleaner($value,$entry_HTMLparser[0],$entry_HTMLparser[1],$entry_HTMLparser[2],$entry_HTMLparser[3]);
00278 }
00279
00280
00281 foreach($modes as $cmd) {
00282
00283 if ($direction=='db') {
00284
00285 if ($_classRef = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_parsehtml_proc.php']['transformation'][$cmd]) {
00286 $_procObj = &t3lib_div::getUserObj($_classRef);
00287 $_procObj->pObj = &$this;
00288 $_procObj->transformationKey = $cmd;
00289 $value = $_procObj->transform_db($value,$this);
00290 } else {
00291 switch($cmd) {
00292 case 'ts_images':
00293 $value = $this->TS_images_db($value);
00294 break;
00295 case 'ts_reglinks':
00296 $value = $this->TS_reglinks($value,'db');
00297 break;
00298 case 'ts_links':
00299 $value = $this->TS_links_db($value);
00300 break;
00301 case 'ts_preserve':
00302 $value = $this->TS_preserve_db($value);
00303 break;
00304 case 'ts_transform':
00305 case 'css_transform':
00306 $value = str_replace(chr(13),'',$value);
00307 $this->allowedClasses = t3lib_div::trimExplode(',',strtoupper($this->procOptions['allowedClasses']),1);
00308 $value = $this->TS_transform_db($value,$cmd=='css_transform');
00309 break;
00310 case 'ts_strip':
00311 $value = $this->TS_strip_db($value);
00312 break;
00313 default:
00314 break;
00315 }
00316 }
00317 }
00318
00319 if ($direction=='rte') {
00320
00321 if ($_classRef = $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_parsehtml_proc.php']['transformation'][$cmd]) {
00322 $_procObj = &t3lib_div::getUserObj($_classRef);
00323 $_procObj->pObj = &$this;
00324 $value = $_procObj->transform_rte($value,$this);
00325 } else {
00326 switch($cmd) {
00327 case 'ts_images':
00328 $value = $this->TS_images_rte($value);
00329 break;
00330 case 'ts_reglinks':
00331 $value = $this->TS_reglinks($value,'rte');
00332 break;
00333 case 'ts_links':
00334 $value = $this->TS_links_rte($value);
00335 break;
00336 case 'ts_preserve':
00337 $value = $this->TS_preserve_rte($value);
00338 break;
00339 case 'ts_transform':
00340 case 'css_transform':
00341 $value = str_replace(chr(13),'',$value);
00342 $value = $this->TS_transform_rte($value,$cmd=='css_transform');
00343 break;
00344 default:
00345 break;
00346 }
00347 }
00348 }
00349 }
00350
00351
00352 if (is_array($exit_HTMLparser)) {
00353 $value = $this->HTMLcleaner($value,$exit_HTMLparser[0],$exit_HTMLparser[1],$exit_HTMLparser[2],$exit_HTMLparser[3]);
00354 }
00355
00356
00357 if (!$this->procOptions['disableUnifyLineBreaks']) {
00358 $value = str_replace(chr(13).chr(10),chr(10),$value);
00359 $value = str_replace(chr(10),chr(13).chr(10),$value);
00360 }
00361
00362
00363 return $value;
00364 }
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00398 function TS_images_db($value) {
00399
00400
00401 $imgSplit = $this->splitTags('img',$value);
00402 foreach($imgSplit as $k => $v) {
00403 if ($k%2) {
00404
00405
00406 $attribArray = $this->get_tag_attributes_classic($v,1);
00407 $siteUrl = $this->siteUrl();
00408 $sitePath = str_replace (t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST'), '', $siteUrl);
00409
00410 $absRef = trim($attribArray['src']);
00411
00412
00413 $pI=pathinfo($absRef);
00414 if($sitePath AND !$pI['scheme'] && t3lib_div::isFirstPartOfStr($absRef,$sitePath)) {
00415
00416 $absRef = substr($absRef,strlen($sitePath));
00417 $absRef = $siteUrl.$absRef;
00418 }
00419
00420
00421 if (!t3lib_div::isFirstPartOfStr($absRef,$siteUrl) && !$this->procOptions['dontFetchExtPictures']) {
00422 $externalFile = $this->getUrl($absRef);
00423 if ($externalFile) {
00424 $pU = parse_url($absRef);
00425 $pI=pathinfo($pU['path']);
00426
00427 if (t3lib_div::inList('gif,png,jpeg,jpg',strtolower($pI['extension']))) {
00428 $filename = t3lib_div::shortMD5($absRef).'.'.$pI['extension'];
00429 $origFilePath = PATH_site.$this->rteImageStorageDir().'RTEmagicP_'.$filename;
00430 $C_origFilePath = PATH_site.$this->rteImageStorageDir().'RTEmagicC_'.$filename.'.'.$pI['extension'];
00431 if (!@is_file($origFilePath)) {
00432 t3lib_div::writeFile($origFilePath,$externalFile);
00433 t3lib_div::writeFile($C_origFilePath,$externalFile);
00434 }
00435 $absRef = $siteUrl.$this->rteImageStorageDir().'RTEmagicC_'.$filename.'.'.$pI['extension'];
00436
00437 $attribArray['src']=$absRef;
00438 $params = t3lib_div::implodeAttributes($attribArray,1);
00439 $imgSplit[$k] = '<img '.$params.' />';
00440 }
00441 }
00442 }
00443
00444
00445 if (t3lib_div::isFirstPartOfStr($absRef,$siteUrl)) {
00446 $path = rawurldecode(substr($absRef,strlen($siteUrl)));
00447 $filepath = t3lib_div::getFileAbsFileName($path);
00448
00449
00450 if ($filepath && @is_file($filepath)) {
00451
00452
00453 $pathPre=$this->rteImageStorageDir().'RTEmagicC_';
00454 if (t3lib_div::isFirstPartOfStr($path,$pathPre)) {
00455
00456 $pI=pathinfo(substr($path,strlen($pathPre)));
00457 $filename = substr($pI['basename'],0,-strlen('.'.$pI['extension']));
00458 $origFilePath = PATH_site.$this->rteImageStorageDir().'RTEmagicP_'.$filename;
00459 if (@is_file($origFilePath)) {
00460 $imgObj = t3lib_div::makeInstance('t3lib_stdGraphic');
00461 $imgObj->init();
00462 $imgObj->mayScaleUp=0;
00463 $imgObj->tempPath=PATH_site.$imgObj->tempPath;
00464
00465 $curInfo = $imgObj->getImageDimensions($filepath);
00466 $curWH = $this->getWHFromAttribs($attribArray);
00467
00468 if ($curWH[0]!=$curInfo[0] || $curWH[1]!=$curInfo[1]) {
00469 $origImgInfo = $imgObj->getImageDimensions($origFilePath);
00470 $cW = $curWH[0];
00471 $cH = $curWH[1];
00472 $cH = 1000;
00473 $imgI = $imgObj->imageMagickConvert($origFilePath,$pI['extension'],$cW.'m',$cH.'m');
00474 if ($imgI[3]) {
00475 $fI=pathinfo($imgI[3]);
00476 @copy($imgI[3],$filepath);
00477 unset($attribArray['style']);
00478 $attribArray['width']=$imgI[0];
00479 $attribArray['height']=$imgI[1];
00480 if (!$attribArray['border']) $attribArray['border']=0;
00481 $params = t3lib_div::implodeAttributes($attribArray,1);
00482 $imgSplit[$k]='<img '.$params.' />';
00483 }
00484 }
00485 }
00486
00487 } elseif ($this->procOptions['plainImageMode']) {
00488
00489
00490 $curWH = $this->getWHFromAttribs($attribArray);
00491 $attribArray['width'] = $curWH[0];
00492 $attribArray['height'] = $curWH[1];
00493
00494
00495 unset($attribArray['style']);
00496 if (!$attribArray['border']) $attribArray['border'] = 0;
00497
00498
00499 $fI = @getimagesize($filepath);
00500
00501
00502 switch((string)$this->procOptions['plainImageMode']) {
00503 case 'lockDimensions':
00504 $attribArray['width']=$fI[0];
00505 $attribArray['height']=$fI[1];
00506 break;
00507 case 'lockRatioWhenSmaller':
00508 if ($attribArray['width']>$fI[0]) $attribArray['width'] = $fI[0];
00509 case 'lockRatio':
00510 if ($fI[0]>0) {
00511 $attribArray['height']=round($attribArray['width']*($fI[1]/$fI[0]));
00512 }
00513 break;
00514 }
00515
00516
00517 $params = t3lib_div::implodeAttributes($attribArray,1);
00518 $imgSplit[$k]='<img '.$params.' />';
00519 }
00520 } else {
00521
00522
00523 #$imgSplit[$k]='';
00524 }
00525 }
00526
00527
00528 if ($imgSplit[$k]) {
00529 $attribArray=$this->get_tag_attributes_classic($imgSplit[$k],1);
00530 $absRef = trim($attribArray['src']);
00531 if (t3lib_div::isFirstPartOfStr($absRef,$siteUrl)) {
00532 $attribArray['src'] = $this->relBackPath.substr($absRef,strlen($siteUrl));
00533 if (!isset($attribArray['alt'])) $attribArray['alt']='';
00534 $imgSplit[$k]='<img '.t3lib_div::implodeAttributes($attribArray,1,1).' />';
00535 }
00536 }
00537 }
00538 }
00539 return implode('',$imgSplit);
00540 }
00541
00550 function TS_images_rte($value) {
00551
00552 $siteUrl = $this->siteUrl();
00553 $sitePath = str_replace (t3lib_div::getIndpEnv('TYPO3_REQUEST_HOST'), '', $siteUrl);
00554
00555
00556 $imgSplit = $this->splitTags('img',$value);
00557 foreach($imgSplit as $k => $v) {
00558 if ($k%2) {
00559
00560
00561 $attribArray=$this->get_tag_attributes_classic($v,1);
00562 $absRef = trim($attribArray['src']);
00563
00564
00565 if (strtolower(substr($absRef,0,4))!='http') {
00566 $attribArray['src'] = substr($attribArray['src'],strlen($this->relBackPath));
00567
00568 $attribArray['src'] = preg_replace('#^'.preg_quote($sitePath,'#').'#','',$attribArray['src']);
00569 $attribArray['src'] = $siteUrl.$attribArray['src'];
00570 if (!isset($attribArray['alt'])) $attribArray['alt']='';
00571 $params = t3lib_div::implodeAttributes($attribArray);
00572 $imgSplit[$k]='<img '.$params.' />';
00573 }
00574 }
00575 }
00576
00577
00578 return implode('',$imgSplit);
00579 }
00580
00589 function TS_reglinks($value,$direction) {
00590 $retVal = '';
00591
00592 switch($direction) {
00593 case 'rte':
00594 $retVal = $this->TS_AtagToAbs($value,1);
00595 break;
00596 case 'db':
00597 $siteURL = $this->siteUrl();
00598 $blockSplit = $this->splitIntoBlock('A',$value);
00599 reset($blockSplit);
00600 while(list($k,$v)=each($blockSplit)) {
00601 if ($k%2) {
00602 $attribArray=$this->get_tag_attributes_classic($this->getFirstTag($v),1);
00603
00604 if ($siteURL && substr($attribArray['href'],0,strlen($siteURL))==$siteURL) {
00605 $attribArray['href']=$this->relBackPath.substr($attribArray['href'],strlen($siteURL));
00606 }
00607 $bTag='<a '.t3lib_div::implodeAttributes($attribArray,1).'>';
00608 $eTag='</a>';
00609 $blockSplit[$k] = $bTag.$this->TS_reglinks($this->removeFirstAndLastTag($blockSplit[$k]),$direction).$eTag;
00610 }
00611 }
00612 $retVal = implode('',$blockSplit);
00613 break;
00614 }
00615 return $retVal;
00616 }
00617
00626 function TS_links_db($value) {
00627
00628
00629 $blockSplit = $this->splitIntoBlock('A',$value);
00630 foreach($blockSplit as $k => $v) {
00631 if ($k%2) {
00632 $attribArray = $this->get_tag_attributes_classic($this->getFirstTag($v),1);
00633 $info = $this->urlInfoForLinkTags($attribArray['href']);
00634
00635
00636 $attribArray_copy = $attribArray;
00637 unset($attribArray_copy['href']);
00638 unset($attribArray_copy['target']);
00639 unset($attribArray_copy['class']);
00640 unset($attribArray_copy['title']);
00641 if ($attribArray_copy['rteerror']) {
00642 unset($attribArray_copy['style']);
00643 unset($attribArray_copy['rteerror']);
00644 }
00645 if (!count($attribArray_copy)) {
00646
00647 $bTag='<link '.$info['url'].($attribArray['target']?' '.$attribArray['target']:(($attribArray['class'] || $attribArray['title'])?' -':'')).($attribArray['class']?' '.$attribArray['class']:($attribArray['title']?' -':'')).($attribArray['title']?' "'.$attribArray['title'].'"':'').'>';
00648 $eTag='</link>';
00649 $blockSplit[$k] = $bTag.$this->TS_links_db($this->removeFirstAndLastTag($blockSplit[$k])).$eTag;
00650 } else {
00651
00652 unset($attribArray['rtekeep']);
00653
00654 $siteURL = $this->siteUrl();
00655 if ($siteURL && substr($attribArray['href'],0,strlen($siteURL))==$siteURL) {
00656 $attribArray['href']=$this->relBackPath.substr($attribArray['href'],strlen($siteURL));
00657 }
00658 $bTag='<a '.t3lib_div::implodeAttributes($attribArray,1).'>';
00659 $eTag='</a>';
00660 $blockSplit[$k] = $bTag.$this->TS_links_db($this->removeFirstAndLastTag($blockSplit[$k])).$eTag;
00661 }
00662 }
00663 }
00664 return implode('',$blockSplit);
00665 }
00666
00675 function TS_links_rte($value) {
00676 $value = $this->TS_AtagToAbs($value);
00677
00678
00679 $blockSplit = $this->splitIntoBlock('link',$value,1);
00680 foreach($blockSplit as $k => $v) {
00681 $error = '';
00682 if ($k%2) {
00683 $tagCode = t3lib_div::unQuoteFilenames(trim(substr($this->getFirstTag($v),0,-1)),true);
00684 $link_param = $tagCode[1];
00685 $href = '';
00686 $siteUrl = $this->siteUrl();
00687
00688 if(strstr($link_param,'@')) {
00689 $href = 'mailto:'.eregi_replace('^mailto:','',$link_param);
00690 } elseif (substr($link_param,0,1)=='#') {
00691 $href = $siteUrl.$link_param;
00692 } else {
00693 $fileChar=intval(strpos($link_param, '/'));
00694 $urlChar=intval(strpos($link_param, '.'));
00695
00696
00697 list($rootFileDat) = explode('?',$link_param);
00698 $rFD_fI = pathinfo($rootFileDat);
00699 if (trim($rootFileDat) && !strstr($link_param,'/') && (@is_file(PATH_site.$rootFileDat) || t3lib_div::inList('php,html,htm',strtolower($rFD_fI['extension'])))) {
00700 $href = $siteUrl.$link_param;
00701 } elseif($urlChar && (strstr($link_param,'
00702 if (!ereg('^[a-z]*:
00703 $href = $scheme.$link_param;
00704 } elseif($fileChar) {
00705 $href = $siteUrl.$link_param;
00706 } else {
00707 $link_params_parts = explode('#',$link_param);
00708 $idPart = trim($link_params_parts[0]);
00709 if (!strcmp($idPart,'')) { $idPart=$this->recPid; }
00710
00711
00712
00713
00714
00715
00716
00717 $pairParts = t3lib_div::trimExplode(',',$idPart);
00718 if (count($pairParts)>1) {
00719 $idPart = $pairParts[0];
00720
00721 }
00722
00723 if (!t3lib_div::testInt($idPart)) {
00724 list($idPartR) = t3lib_BEfunc::getRecordsByField('pages','alias',$idPart);
00725 $idPart = intval($idPartR['uid']);
00726 }
00727 $page = t3lib_BEfunc::getRecord('pages', $idPart);
00728 if (is_array($page)) {
00729 $href = $siteUrl.'?id='.$link_param;
00730 } else {
00731 #$href = '';
00732 $href = $siteUrl.'?id='.$link_param;
00733 $error = 'No page found: '.$idPart;
00734 }
00735 }
00736 }
00737
00738
00739 $bTag = '<a href="'.htmlspecialchars($href).'"'.
00740 ($tagCode[2]&&$tagCode[2]!='-' ? ' target="'.htmlspecialchars($tagCode[2]).'"' : '').
00741 ($tagCode[3]&&$tagCode[3]!='-' ? ' class="'.htmlspecialchars($tagCode[3]).'"' : '').
00742 ($tagCode[4] ? ' title="'.htmlspecialchars($tagCode[4]).'"' : '').
00743 ($error ? ' rteerror="'.htmlspecialchars($error).'" style="background-color: yellow; border:2px red solid; color: black;"' : '').
00744 '>';
00745 $eTag = '</a>';
00746 $blockSplit[$k] = $bTag.$this->TS_links_rte($this->removeFirstAndLastTag($blockSplit[$k])).$eTag;
00747 }
00748 }
00749
00750
00751 return implode('',$blockSplit);
00752 }
00753
00760 function TS_preserve_db($value) {
00761 if (!$this->preserveTags) return $value;
00762
00763
00764 $blockSplit = $this->splitIntoBlock('span',$value);
00765 foreach($blockSplit as $k => $v) {
00766 if ($k%2) {
00767 $attribArray=$this->get_tag_attributes_classic($this->getFirstTag($v));
00768 if ($attribArray['specialtag']) {
00769 $theTag = rawurldecode($attribArray['specialtag']);
00770 $theTagName = $this->getFirstTagName($theTag);
00771 $blockSplit[$k] = $theTag.$this->removeFirstAndLastTag($blockSplit[$k]).'</'.$theTagName.'>';
00772 }
00773 }
00774 }
00775 return implode('',$blockSplit);
00776 }
00777
00784 function TS_preserve_rte($value) {
00785 if (!$this->preserveTags) return $value;
00786
00787 $blockSplit = $this->splitIntoBlock($this->preserveTags,$value);
00788 foreach($blockSplit as $k => $v) {
00789 if ($k%2) {
00790 $blockSplit[$k] = '<span specialtag="'.rawurlencode($this->getFirstTag($v)).'">'.$this->removeFirstAndLastTag($blockSplit[$k]).'</span>';
00791 }
00792 }
00793 return implode('',$blockSplit);
00794 }
00795
00805 function TS_transform_db($value,$css=FALSE) {
00806
00807
00808 $this->TS_transform_db_safecounter--;
00809 if ($this->TS_transform_db_safecounter<0) return $value;
00810
00811
00812 $blockSplit = $this->splitIntoBlock('TABLE,BLOCKQUOTE,'.$this->headListTags,$value);
00813
00814 $cc=0;
00815 $aC = count($blockSplit);
00816
00817
00818 while($aC && !strcmp(trim($blockSplit[$aC-1]),'')) {
00819 unset($blockSplit[$aC-1]);
00820 $aC = count($blockSplit);
00821 }
00822
00823
00824 foreach($blockSplit as $k => $v) {
00825 $cc++;
00826 $lastBR = $cc==$aC ? '' : chr(10);
00827
00828 if ($k%2) {
00829
00830
00831 $tag=$this->getFirstTag($v);
00832 $tagName=strtolower($this->getFirstTagName($v));
00833
00834
00835 switch($tagName) {
00836 case 'blockquote':
00837 $blockSplit[$k]='<'.$tagName.'>'.$this->TS_transform_db($this->removeFirstAndLastTag($blockSplit[$k]),$css).'</'.$tagName.'>'.$lastBR;
00838 break;
00839 case 'ol':
00840 case 'ul':
00841 if (!$css) {
00842 if (!isset($this->procOptions['typolist']) || $this->procOptions['typolist']) {
00843 $parts = $this->getAllParts($this->splitIntoBlock('LI',$this->removeFirstAndLastTag($blockSplit[$k])),1,0);
00844 while(list($k2)=each($parts)) {
00845 $parts[$k2]=preg_replace('/['.preg_quote(chr(10).chr(13)).']+/','',$parts[$k2]);
00846 $parts[$k2]=$this->defaultTStagMapping($parts[$k2],'db');
00847 $parts[$k2]=$this->cleanFontTags($parts[$k2],0,0,0);
00848 $parts[$k2] = $this->HTMLcleaner_db($parts[$k2],strtolower($this->procOptions['allowTagsInTypolists']?$this->procOptions['allowTagsInTypolists']:'br,font,b,i,u,a,img,span,strong,em'));
00849 }
00850 if ($tagName=='ol') { $params=' type="1"'; } else { $params=''; }
00851 $blockSplit[$k]='<typolist'.$params.'>'.chr(10).implode(chr(10),$parts).chr(10).'</typolist>'.$lastBR;
00852 }
00853 } else {
00854 $blockSplit[$k]=preg_replace('/['.preg_quote(chr(10).chr(13)).']+/',' ',$this->transformStyledATags($blockSplit[$k])).$lastBR;
00855 }
00856 break;
00857 case 'table':
00858 if (!$this->procOptions['preserveTables'] && !$css) {
00859 $blockSplit[$k]=$this->TS_transform_db($this->removeTables($blockSplit[$k]));
00860 } else {
00861 $blockSplit[$k]=preg_replace('/['.preg_quote(chr(10).chr(13)).']+/',' ',$this->transformStyledATags($blockSplit[$k])).$lastBR;
00862 }
00863 break;
00864 case 'h1':
00865 case 'h2':
00866 case 'h3':
00867 case 'h4':
00868 case 'h5':
00869 case 'h6':
00870 if (!$css) {
00871 $attribArray=$this->get_tag_attributes_classic($tag);
00872
00873 $innerContent = $this->HTMLcleaner_db($this->removeFirstAndLastTag($blockSplit[$k]));
00874
00875 if (!isset($this->procOptions['typohead']) || $this->procOptions['typohead']) {
00876 $type = intval(substr($tagName,1));
00877 $blockSplit[$k]='<typohead'.
00878 ($type!=6?' type="'.$type.'"':'').
00879 ($attribArray['align']?' align="'.$attribArray['align'].'"':'').
00880 ($attribArray['class']?' class="'.$attribArray['class'].'"':'').
00881 '>'.
00882 $innerContent.
00883 '</typohead>'.
00884 $lastBR;
00885 } else {
00886 $blockSplit[$k]='<'.$tagName.
00887 ($attribArray['align']?' align="'.htmlspecialchars($attribArray['align']).'"':'').
00888 ($attribArray['class']?' class="'.htmlspecialchars($attribArray['class']).'"':'').
00889 '>'.
00890 $innerContent.
00891 '</'.$tagName.'>'.
00892 $lastBR;
00893 }
00894 } else {
00895
00896 $blockSplit[$k]=preg_replace('/['.preg_quote(chr(10).chr(13)).']+/',' ',$this->transformStyledATags($blockSplit[$k])).$lastBR;
00897 }
00898 break;
00899 default:
00900
00901 $blockSplit[$k]=preg_replace('/['.preg_quote(chr(10).chr(13)).']+/',' ',$this->transformStyledATags($blockSplit[$k])).$lastBR;
00902 break;
00903 }
00904 } else {
00905 if (strcmp(trim($blockSplit[$k]),'')) {
00906 $blockSplit[$k]=$this->divideIntoLines(preg_replace('/['.preg_quote(chr(10).chr(13)).']+/',' ',$blockSplit[$k])).$lastBR;
00907 $blockSplit[$k]=$this->transformStyledATags($blockSplit[$k]);
00908 } else unset($blockSplit[$k]);
00909 }
00910 }
00911 $this->TS_transform_db_safecounter++;
00912
00913 return implode('',$blockSplit);
00914 }
00915
00922 function transformStyledATags($value) {
00923 $blockSplit = $this->splitIntoBlock('A',$value);
00924 foreach($blockSplit as $k => $v) {
00925 if ($k%2) {
00926 $attribArray = $this->get_tag_attributes_classic($this->getFirstTag($v),1);
00927 if ($attribArray['style']) {
00928 $attribArray_copy['style'] = $attribArray['style'];
00929 unset($attribArray['style']);
00930 $bTag='<span '.t3lib_div::implodeAttributes($attribArray_copy,1).'><a '.t3lib_div::implodeAttributes($attribArray,1).'>';
00931 $eTag='</a></span>';
00932 $blockSplit[$k] = $bTag.$this->removeFirstAndLastTag($blockSplit[$k]).$eTag;
00933 }
00934 }
00935 }
00936 return implode('',$blockSplit);
00937 }
00938
00948 function TS_transform_rte($value,$css=0) {
00949
00950
00951 $blockSplit = $this->splitIntoBlock('TABLE,BLOCKQUOTE,TYPOLIST,TYPOHEAD,'.$this->headListTags,$value);
00952
00953
00954 foreach($blockSplit as $k => $v) {
00955 if ($k%2) {
00956
00957
00958 $tag = $this->getFirstTag($v);
00959 $tagName = strtolower($this->getFirstTagName($v));
00960 $attribArray = $this->get_tag_attributes_classic($tag);
00961
00962
00963 switch($tagName) {
00964 case 'blockquote':
00965 $blockSplit[$k] = $tag.
00966 $this->TS_transform_rte($this->removeFirstAndLastTag($blockSplit[$k]),$css).
00967 '</'.$tagName.'>';
00968 break;
00969 case 'typolist':
00970 if (!isset($this->procOptions['typolist']) || $this->procOptions['typolist']) {
00971 $tListContent = $this->removeFirstAndLastTag($blockSplit[$k]);
00972 $tListContent = ereg_replace('^[ ]*'.chr(10),'',$tListContent);
00973 $tListContent = ereg_replace(chr(10).'[ ]*$','',$tListContent);
00974 $lines = explode(chr(10),$tListContent);
00975 $typ = $attribArray['type']==1 ? 'ol' : 'ul';
00976 $blockSplit[$k] = '<'.$typ.'>'.chr(10).
00977 '<li>'.implode('</li>'.chr(10).'<li>',$lines).'</li>'.
00978 '</'.$typ.'>';
00979 }
00980 break;
00981 case 'typohead':
00982 if (!isset($this->procOptions['typohead']) || $this->procOptions['typohead']) {
00983 $tC = $this->removeFirstAndLastTag($blockSplit[$k]);
00984 $typ = t3lib_div::intInRange($attribArray['type'],0,6);
00985 if (!$typ) $typ=6;
00986 $align = $attribArray['align']?' align="'.$attribArray['align'].'"': '';
00987 $class = $attribArray['class']?' class="'.$attribArray['class'].'"': '';
00988 $blockSplit[$k] = '<h'.$typ.$align.$class.'>'.
00989 $tC.
00990 '</h'.$typ.'>';
00991 }
00992 break;
00993 }
00994 $blockSplit[$k+1] = ereg_replace('^[ ]*'.chr(10),'',$blockSplit[$k+1]);
00995 } else {
00996 $nextFTN = $this->getFirstTagName($blockSplit[$k+1]);
00997 $singleLineBreak = $blockSplit[$k]==chr(10);
00998 if (t3lib_div::inList('TABLE,BLOCKQUOTE,TYPOLIST,TYPOHEAD,'.$this->headListTags,$nextFTN)) {
00999 $blockSplit[$k] = ereg_replace(chr(10).'[ ]*$','',$blockSplit[$k]);
01000 }
01001
01002 if (!strcmp($blockSplit[$k],'') && !$singleLineBreak) {
01003 unset($blockSplit[$k]);
01004 } else {
01005 $blockSplit[$k] = $this->setDivTags($blockSplit[$k],($this->procOptions['useDIVasParagraphTagForRTE']?'div':'p'));
01006 }
01007 }
01008 }
01009 return implode(chr(10),$blockSplit);
01010 }
01011
01019 function TS_strip_db($value) {
01020 $value = strip_tags($value,'<'.implode('><',explode(',','b,i,u,a,img,br,div,center,pre,font,hr,sub,sup,p,strong,em,li,ul,ol,blockquote')).'>');
01021 return $value;
01022 }
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038
01039
01040
01041
01042
01050 function getURL($url) {
01051 return t3lib_div::getURL($url);
01052 }
01053
01064 function HTMLcleaner_db($content,$tagList='') {
01065 if (!$tagList) {
01066 $keepTags = $this->getKeepTags('db');
01067 } else {
01068 $keepTags = $this->getKeepTags('db',$tagList);
01069 }
01070 $kUknown = $this->procOptions['dontRemoveUnknownTags_db'] ? 1 : 0;
01071 $hSC = $this->procOptions['dontUndoHSC_db'] ? 0 : -1;
01072
01073
01074 $addConfig=array();
01075 if ((is_array($this->procOptions['HTMLparser_db.']) && $this->procOptions['HTMLparser_db.']['xhtml_cleaning']) || (is_array($this->procOptions['entryHTMLparser_db.']) && $this->procOptions['entryHTMLparser_db.']['xhtml_cleaning']) || (is_array($this->procOptions['exitHTMLparser_db.']) && $this->procOptions['exitHTMLparser_db.']['xhtml_cleaning'])) {
01076 $addConfig['xhtml']=1;
01077 }
01078
01079 return $this->HTMLcleaner($content,$keepTags,$kUknown,$hSC,$addConfig);
01080 }
01081
01091 function getKeepTags($direction='rte',$tagList='') {
01092 if (!is_array($this->getKeepTags_cache[$direction]) || $tagList) {
01093
01094
01095 if (strcmp($tagList,'')) {
01096 $keepTags = array_flip(t3lib_div::trimExplode(',',$tagList,1));
01097 } else {
01098
01099 $typoScript_list = 'b,i,u,a,img,br,div,center,pre,font,hr,sub,sup,p,strong,em,li,ul,ol,blockquote,strike,span';
01100 $keepTags = array_flip(t3lib_div::trimExplode(',',$typoScript_list.','.strtolower($this->procOptions['allowTags']),1));
01101
01102
01103 $denyTags = t3lib_div::trimExplode(',',$this->procOptions['denyTags'],1);
01104 foreach($denyTags as $dKe) {
01105 unset($keepTags[$dKe]);
01106 }
01107 }
01108
01109
01110 switch ($direction) {
01111
01112
01113 case 'rte':
01114
01115 if (isset($keepTags['b'])) {$keepTags['b']=array('remap'=>'STRONG');}
01116 if (isset($keepTags['i'])) {$keepTags['i']=array('remap'=>'EM');}
01117
01118
01119 list($keepTags) = $this->HTMLparserConfig($this->procOptions['HTMLparser_rte.'],$keepTags);
01120 break;
01121
01122
01123 case 'db':
01124
01125 if (isset($keepTags['strong'])) { $keepTags['strong']=array('remap'=>'b'); }
01126 if (isset($keepTags['em'])) { $keepTags['em']=array('remap'=>'i'); }
01127
01128
01129 if (isset($keepTags['span'])) {
01130 $classes=array_merge(array(''),$this->allowedClasses);
01131 $keepTags['span']=array(
01132 'allowedAttribs' => 'class,style,xml:lang',
01133 'fixAttrib' => Array(
01134 'class' => Array (
01135 'list' => $classes,
01136 'removeIfFalse' => 1
01137 )
01138 ),
01139 'rmTagIfNoAttrib' => 1
01140 );
01141 if (!$this->procOptions['allowedClasses']) unset($keepTags['span']['fixAttrib']['class']['list']);
01142 }
01143
01144
01145 if (isset($keepTags['font'])) {
01146 $colors=array_merge(array(''),t3lib_div::trimExplode(',',$this->procOptions['allowedFontColors'],1));
01147 $keepTags['font']=array(
01148 'allowedAttribs'=>'face,color,size',
01149 'fixAttrib' => Array(
01150 'face' => Array (
01151 'removeIfFalse' => 1
01152 ),
01153 'color' => Array (
01154 'removeIfFalse' => 1,
01155 'list'=>$colors
01156 ),
01157 'size' => Array (
01158 'removeIfFalse' => 1,
01159 )
01160 ),
01161 'rmTagIfNoAttrib' => 1
01162 );
01163 if (!$this->procOptions['allowedFontColors']) unset($keepTags['font']['fixAttrib']['color']['list']);
01164 }
01165
01166
01167 $TSc = $this->procOptions['HTMLparser_db.'];
01168 if (!$TSc['globalNesting']) $TSc['globalNesting']='b,i,u,a,center,font,sub,sup,strong,em,strike,span';
01169 if (!$TSc['noAttrib']) $TSc['noAttrib']='b,i,u,br,center,hr,sub,sup,strong,em,li,ul,ol,blockquote,strike';
01170
01171
01172 list($keepTags) = $this->HTMLparserConfig($TSc,$keepTags);
01173 break;
01174 }
01175
01176
01177 if (!$tagList) {
01178 $this->getKeepTags_cache[$direction] = $keepTags;
01179 } else {
01180 return $keepTags;
01181 }
01182 }
01183
01184
01185 return $this->getKeepTags_cache[$direction];
01186 }
01187
01200 function divideIntoLines($value,$count=5,$returnArray=FALSE) {
01201
01202
01203 if ($this->procOptions['internalizeFontTags']) {$value = $this->internalizeFontTags($value);}
01204
01205
01206 $allowTagsOutside = t3lib_div::trimExplode(',',strtolower($this->procOptions['allowTagsOutside']?$this->procOptions['allowTagsOutside']:'img'),1);
01207 $remapParagraphTag = strtoupper($this->procOptions['remapParagraphTag']);
01208 $divSplit = $this->splitIntoBlock('div,p',$value,1);
01209
01210 if ($this->procOptions['keepPDIVattribs']) {
01211 $keepAttribListArr = t3lib_div::trimExplode(',',strtolower($this->procOptions['keepPDIVattribs']),1);
01212 } else {
01213 $keepAttribListArr = array();
01214 }
01215
01216
01217 if (count($divSplit)<=1 || $count<=0) {
01218 return $value;
01219 }
01220
01221
01222 foreach($divSplit as $k => $v) {
01223 if ($k%2) {
01224 $v=$this->removeFirstAndLastTag($v);
01225
01226
01227 $subLines = $this->divideIntoLines($v,$count-1,1);
01228 if (is_array($subLines)) {
01229
01230 } else {
01231 $subLines = array($subLines);
01232 if (!$this->procOptions['dontConvBRtoParagraph']) {
01233 $subLines = spliti('<br[[:space:]]*[\/]?>',$v);
01234 }
01235
01236
01237 reset($subLines);
01238 while(list($sk)=each($subLines)) {
01239
01240
01241 $subLines[$sk]=$this->HTMLcleaner_db($subLines[$sk]);
01242
01243
01244 $fTag = $this->getFirstTag($divSplit[$k]);
01245 $tagName=strtolower($this->getFirstTagName($divSplit[$k]));
01246 $attribs=$this->get_tag_attributes($fTag);
01247
01248
01249 $newAttribs=array();
01250 if (count($keepAttribListArr)) {
01251 foreach($keepAttribListArr as $keepA) {
01252 if (isset($attribs[0][$keepA])) { $newAttribs[$keepA] = $attribs[0][$keepA]; }
01253 }
01254 }
01255
01256
01257 if (!$this->procOptions['skipAlign'] && strcmp(trim($attribs[0]['align']),'') && strtolower($attribs[0]['align'])!='left') {
01258 $newAttribs['align']=strtolower($attribs[0]['align']);
01259 }
01260
01261
01262 if (!$this->procOptions['skipClass'] && strcmp(trim($attribs[0]['class']),'')) {
01263 if (!count($this->allowedClasses) || in_array(strtoupper($attribs[0]['class']),$this->allowedClasses)) {
01264 $newAttribs['class']=$attribs[0]['class'];
01265 }
01266 }
01267
01268
01269 $subLines[$sk]=ereg_replace(chr(10).'|'.chr(13),'',$subLines[$sk]);
01270
01271
01272 if (count($newAttribs) && strcmp($remapParagraphTag,'1')) {
01273 if ($remapParagraphTag=='P') $tagName='p';
01274 if ($remapParagraphTag=='DIV') $tagName='div';
01275 $subLines[$sk]='<'.trim($tagName.' '.$this->compileTagAttribs($newAttribs)).'>'.$subLines[$sk].'</'.$tagName.'>';
01276 }
01277 }
01278 }
01279
01280 $divSplit[$k] = implode(chr(10),$subLines);
01281
01282
01283 if (trim(strip_tags($divSplit[$k]))==' ' && !preg_match('/\<(img)(\s[^>]*)?\/?>/si', $divSplit[$k])) {
01284 $divSplit[$k]='';
01285 }
01286 } else {
01287
01288 $divSplit[$k]=trim(strip_tags($divSplit[$k],'<'.implode('><',$allowTagsOutside).'>'));
01289 if (!strcmp($divSplit[$k],'')) unset($divSplit[$k]);
01290 }
01291 }
01292
01293
01294 return $returnArray ? $divSplit : implode(chr(10),$divSplit);
01295 }
01296
01306 function setDivTags($value,$dT='p') {
01307
01308
01309 $keepTags = $this->getKeepTags('rte');
01310 $kUknown = $this->procOptions['dontProtectUnknownTags_rte'] ? 0 : 'protect';
01311 $hSC = $this->procOptions['dontHSC_rte'] ? 0 : 1;
01312 $convNBSP = !$this->procOptions['dontConvAmpInNBSP_rte']?1:0;
01313
01314
01315 $parts = explode(chr(10),$value);
01316 foreach($parts as $k => $v) {
01317
01318
01319 if (!strcmp(trim($parts[$k]),'')) {
01320 $parts[$k]=' ';
01321 } else {
01322 $parts[$k]=$this->HTMLcleaner($parts[$k],$keepTags,$kUknown,$hSC);
01323 if ($convNBSP) $parts[$k]=str_replace('&nbsp;',' ',$parts[$k]);
01324 }
01325
01326
01327 $testStr = strtolower(trim($parts[$k]));
01328 if (substr($testStr,0,4)!='<div' || substr($testStr,-6)!='</div>') {
01329 if (substr($testStr,0,2)!='<p' || substr($testStr,-4)!='</p>') {
01330
01331 $parts[$k]='<'.$dT.'>'.$parts[$k].'</'.$dT.'>';
01332 }
01333 }
01334 }
01335
01336
01337 return implode(chr(10),$parts);
01338 }
01339
01351 function internalizeFontTags($value) {
01352
01353
01354 $fontSplit = $this->splitIntoBlock('font',$value);
01355
01356 foreach($fontSplit as $k => $v) {
01357 if ($k%2) {
01358 $fTag = $this->getFirstTag($v);
01359
01360 $divSplit_sub = $this->splitIntoBlock('div,p',$this->removeFirstAndLastTag($v),1);
01361 if (count($divSplit_sub)>1) {
01362
01363 foreach($divSplit_sub as $k2 => $v2) {
01364 if ($k2%2) {
01365 $div_p = $this->getFirstTag($v2);
01366 $div_p_tagname = $this->getFirstTagName($v2);
01367 $v2=$this->removeFirstAndLastTag($v2);
01368 $divSplit_sub[$k2]=$div_p.$fTag.$v2.'</font>'.'</'.$div_p_tagname.'>';
01369 } elseif (trim(strip_tags($v2))) {
01370 $divSplit_sub[$k2]=$fTag.$v2.'</font>';
01371 }
01372 }
01373 $fontSplit[$k]=implode('',$divSplit_sub);
01374 }
01375 }
01376 }
01377
01378 return implode('',$fontSplit);
01379 }
01380
01387 function siteUrl() {
01388 return t3lib_div::getIndpEnv('TYPO3_SITE_URL');
01389 }
01390
01397 function rteImageStorageDir() {
01398 return $this->rte_p['imgpath'] ? $this->rte_p['imgpath'] : $GLOBALS['TYPO3_CONF_VARS']['BE']['RTE_imageStorageDir'];
01399 }
01400
01409 function removeTables($value,$breakChar='<br />') {
01410
01411
01412 $tableSplit = $this->splitIntoBlock('table',$value);
01413
01414
01415 foreach($tableSplit as $k => $v) {
01416 if ($k%2) {
01417 $tableSplit[$k]='';
01418 $rowSplit = $this->splitIntoBlock('tr',$v);
01419 foreach($rowSplit as $k2 => $v2) {
01420 if ($k2%2) {
01421 $cellSplit = $this->getAllParts($this->splitIntoBlock('td',$v2),1,0);
01422 foreach($cellSplit as $k3 => $v3) {
01423 $tableSplit[$k].=$v3.$breakChar;
01424 }
01425 }
01426 }
01427 }
01428 }
01429
01430
01431 return implode($breakChar,$tableSplit);
01432 }
01433
01441 function defaultTStagMapping($code,$direction='rte') {
01442 if ($direction=='db') {
01443 $code=$this->mapTags($code,array(
01444 'strong' => 'b',
01445 'em' => 'i'
01446 ));
01447 }
01448 if ($direction=='rte') {
01449 $code=$this->mapTags($code,array(
01450 'b' => 'strong',
01451 'i' => 'em'
01452 ));
01453 }
01454 return $code;
01455 }
01456
01464 function getWHFromAttribs($attribArray) {
01465 $style =trim($attribArray['style']);
01466 if ($style) {
01467 $regex='[[:space:]]*:[[:space:]]*([0-9]*)[[:space:]]*px';
01468
01469 $reg = array();
01470 eregi('width'.$regex,$style,$reg);
01471 $w = intval($reg[1]);
01472
01473 eregi('height'.$regex,$style,$reg);
01474 $h = intval($reg[1]);
01475 }
01476 if (!$w) {
01477 $w = $attribArray['width'];
01478 }
01479 if (!$h) {
01480 $h = $attribArray['height'];
01481 }
01482 return array(intval($w),intval($h));
01483 }
01484
01491 function urlInfoForLinkTags($url) {
01492 $info = array();
01493 $url = trim($url);
01494 if (substr(strtolower($url),0,7)=='mailto:') {
01495 $info['url']=trim(substr($url,7));
01496 $info['type']='email';
01497 } else {
01498 $curURL = $this->siteUrl();
01499 for($a=0;$a<strlen($url);$a++) {
01500 if ($url{$a}!=$curURL{$a}) {
01501 break;
01502 }
01503 }
01504
01505 $info['relScriptPath']=substr($curURL,$a);
01506 $info['relUrl']=substr($url,$a);
01507 $info['url']=$url;
01508 $info['type']='ext';
01509
01510 $siteUrl_parts = parse_url($url);
01511 $curUrl_parts = parse_url($curURL);
01512
01513 if ($siteUrl_parts['host']==$curUrl_parts['host']
01514 && (!$info['relScriptPath'] || (defined('TYPO3_mainDir') && substr($info['relScriptPath'],0,strlen(TYPO3_mainDir))==TYPO3_mainDir))) {
01515
01516
01517 $uP=parse_url($info['relUrl']);
01518
01519 if (!strcmp('#'.$siteUrl_parts['fragment'],$info['relUrl'])) {
01520 $info['url']=$info['relUrl'];
01521 $info['type']='anchor';
01522 } elseif (!trim($uP['path']) || !strcmp($uP['path'],'index.php')) {
01523 $pp = explode('id=',$uP['query']);
01524 $id = trim($pp[1]);
01525 if ($id) {
01526 $info['pageid']=$id;
01527 $info['cElement']=$uP['fragment'];
01528 $info['url']=$id.($info['cElement']?'#'.$info['cElement']:'');
01529 $info['type']='page';
01530 }
01531 } else {
01532 $info['url']=$info['relUrl'];
01533 $info['type']='file';
01534 }
01535 } else {
01536 unset($info['relScriptPath']);
01537 unset($info['relUrl']);
01538 }
01539 }
01540 return $info;
01541 }
01542
01550 function TS_AtagToAbs($value,$dontSetRTEKEEP=FALSE) {
01551 $blockSplit = $this->splitIntoBlock('A',$value);
01552 reset($blockSplit);
01553 while(list($k,$v)=each($blockSplit)) {
01554 if ($k%2) {
01555 $attribArray = $this->get_tag_attributes_classic($this->getFirstTag($v),1);
01556
01557
01558 if (strlen($attribArray['href'])) {
01559 $uP = parse_url(strtolower($attribArray['href']));
01560 if (!$uP['scheme']) {
01561 $attribArray['href'] = $this->siteUrl().substr($attribArray['href'],strlen($this->relBackPath));
01562 }
01563 } else {
01564 $attribArray['rtekeep'] = 1;
01565 }
01566 if (!$dontSetRTEKEEP) $attribArray['rtekeep'] = 1;
01567
01568 $bTag='<a '.t3lib_div::implodeAttributes($attribArray,1).'>';
01569 $eTag='</a>';
01570 $blockSplit[$k] = $bTag.$this->TS_AtagToAbs($this->removeFirstAndLastTag($blockSplit[$k])).$eTag;
01571 }
01572 }
01573 return implode('',$blockSplit);
01574 }
01575 }
01576
01577
01578 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_parsehtml_proc.php']) {
01579 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_parsehtml_proc.php']);
01580 }
01581 ?>