Fixed bug #10086: Core uses deprecated function t3lib_db->sql()
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_parsehtml_proc.php
index ae25fce..0d8d5a0 100755 (executable)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 1999-2006 Kasper Skaarhoj (kasperYYYY@typo3.com)
+*  (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is
@@ -103,13 +103,14 @@ require_once (PATH_t3lib.'class.t3lib_parsehtml.php');
 class t3lib_parsehtml_proc extends t3lib_parsehtml {
 
                // Static:
-       var $headListTags = 'PRE,UL,OL,H1,H2,H3,H4,H5,H6,HR,ADDRESS,DL';        // List of tags for these elements
+       var $blockElementList = 'PRE,UL,OL,H1,H2,H3,H4,H5,H6,HR,ADDRESS,DL,DD'; // List of tags for these elements
 
                // Internal, static:
        var $recPid = 0;                                // Set this to the pid of the record manipulated by the class.
        var $elRef = '';                                // Element reference [table]:[field], eg. "tt_content:bodytext"
        var $relPath='';                                // Relative path
        var $relBackPath='';                    // Relative back-path
+       public $tsConfig = array();             // Current Page TSConfig
        var $procOptions = '';                  // Set to the TSconfig options coming from Page TSconfig
 
                // Internal, dynamic
@@ -232,9 +233,15 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
        function RTE_transform($value,$specConf,$direction='rte',$thisConfig=array())   {
 
                        // Init:
+               $this->tsConfig = $thisConfig;
                $this->procOptions = $thisConfig['proc.'];
                $this->preserveTags = strtoupper(implode(',',t3lib_div::trimExplode(',',$this->procOptions['preserveTags'])));
 
+                       // dynamic configuration of blockElementList
+               if ($this->procOptions['blockElementList']) {
+                       $this->blockElementList = $this->procOptions['blockElementList'];
+               }
+
                        // Get parameters for rte_transformation:
                $p = $this->rte_p = t3lib_BEfunc::getSpecConfParametersFromArray($specConf['rte_transform']['parameters']);
 
@@ -493,7 +500,7 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
 
                                                                // Removing width and heigth form style attribute
                                                        $attribArray['style'] = preg_replace('/((?:^|)\s*(?:width|height)\s*:[^;]*(?:$|;))/si', '', $attribArray['style']);
-                                                       
+
                                                                // Finding dimensions of image file:
                                                        $fI = @getimagesize($filepath);
 
@@ -643,7 +650,7 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
                                }
                                if (!count($attribArray_copy))  {       // Only if href, target and class are the only attributes, we can alter the link!
                                                // Creating the TYPO3 pseudo-tag "<LINK>" for the link (includes href/url, target and class attributes):
-                                       $bTag='<link '.$info['url'].($attribArray['target']?' '.$attribArray['target']:(($attribArray['class'] || $attribArray['title'])?' -':'')).($attribArray['class']?' '.$attribArray['class']:($attribArray['title']?' -':'')).($attribArray['title']?' "'.$attribArray['title'].'"':'').'>';
+                                       $bTag='<link '.$info['url'].($info['query']?',0,'.$info['query']:'').($attribArray['target']?' '.$attribArray['target']:(($attribArray['class'] || $attribArray['title'])?' -':'')).($attribArray['class']?' '.$attribArray['class']:($attribArray['title']?' -':'')).($attribArray['title']?' "'.$attribArray['title'].'"':'').'>';
                                        $eTag='</link>';
                                        $blockSplit[$k] = $bTag.$this->TS_links_db($this->removeFirstAndLastTag($blockSplit[$k])).$eTag;
                                } else {        // ... otherwise store the link as a-tag.
@@ -725,7 +732,8 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
                                                }
                                                $page = t3lib_BEfunc::getRecord('pages', $idPart);
                                                if (is_array($page))    {       // Page must exist...
-                                                       $href = $siteUrl.'?id='.$link_param;
+                                                       $pairParts = t3lib_div::trimExplode(',',$link_param);
+                                                       $href = $siteUrl.'?id='.$pairParts[0].($pairParts[2]?$pairParts[2]:'');
                                                } else if(strtolower(substr($link_param, 0, 7)) == 'record:') {
                                                                // linkHandler - allowing links to start with "record:"
                                                        $href = $link_param;
@@ -811,7 +819,7 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
                if ($this->TS_transform_db_safecounter<0)       return $value;
 
                        // Split the content from RTE by the occurence of these blocks:
-               $blockSplit = $this->splitIntoBlock('TABLE,BLOCKQUOTE,'.($this->procOptions['preserveDIVSections']?'DIV,':'').$this->headListTags,$value);
+               $blockSplit = $this->splitIntoBlock('TABLE,BLOCKQUOTE,'.($this->procOptions['preserveDIVSections']?'DIV,':'').$this->blockElementList,$value);
 
                $cc=0;
                $aC = count($blockSplit);
@@ -836,6 +844,7 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
                                        // Process based on the tag:
                                switch($tagName)        {
                                        case 'blockquote':      // Keep blockquotes, but clean the inside recursively in the same manner as the main code
+                                       case 'dd' :             // Do the same on dd elements
                                        case 'div':             // Do the same on div sections, if they were splitted
                                                $blockSplit[$k]=$tag.$this->TS_transform_db($this->removeFirstAndLastTag($blockSplit[$k]),$css).'</'.$tagName.'>'.$lastBR;
                                        break;
@@ -951,7 +960,7 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
        function TS_transform_rte($value,$css=0)        {
 
                        // Split the content from Database by the occurence of these blocks:
-               $blockSplit = $this->splitIntoBlock('TABLE,BLOCKQUOTE,TYPOLIST,TYPOHEAD,'.($this->procOptions['preserveDIVSections']?'DIV,':'').$this->headListTags,$value);
+               $blockSplit = $this->splitIntoBlock('TABLE,BLOCKQUOTE,TYPOLIST,TYPOHEAD,'.($this->procOptions['preserveDIVSections']?'DIV,':'').$this->blockElementList,$value);
 
                        // Traverse the blocks
                foreach($blockSplit as $k => $v)        {
@@ -964,7 +973,8 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
 
                                        // Based on tagname, we do transformations:
                                switch($tagName)        {
-                                       case 'blockquote':      // Keep blockquotes:
+                                       case 'blockquote':      // Keep blockquotes
+                                       case 'dd':              // Keep definitions
                                        case 'div':             // Keep div sections, if they were splitted
                                                $blockSplit[$k] = $tag.
                                                                        $this->TS_transform_rte($this->removeFirstAndLastTag($blockSplit[$k]),$css).
@@ -999,7 +1009,7 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
                        } else {        // NON-block:
                                $nextFTN = $this->getFirstTagName($blockSplit[$k+1]);
                                $singleLineBreak = $blockSplit[$k]==chr(10);
-                               if (t3lib_div::inList('TABLE,BLOCKQUOTE,TYPOLIST,TYPOHEAD,'.($this->procOptions['preserveDIVSections']?'DIV,':'').$this->headListTags,$nextFTN))        {       // Removing linebreak if typolist/typohead
+                               if (t3lib_div::inList('TABLE,BLOCKQUOTE,TYPOLIST,TYPOHEAD,'.($this->procOptions['preserveDIVSections']?'DIV,':'').$this->blockElementList,$nextFTN))    {       // Removing linebreak if typolist/typohead
                                        $blockSplit[$k] = ereg_replace(chr(10).'[ ]*$','',$blockSplit[$k]);
                                }
                                        // If $blockSplit[$k] is blank then unset the line. UNLESS the line happend to be a single line break.
@@ -1115,7 +1125,7 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
 
                                        // GOING from database to Rich Text Editor:
                                case 'rte':
-                                       
+
                                        if (!isset($this->procOptions['transformBoldAndItalicTags']) || $this->procOptions['transformBoldAndItalicTags']) {
                                                        // Transform bold/italics tags to strong/em
                                                if (isset($keepTags['b']))      {$keepTags['b']=array('remap'=>'STRONG');}
@@ -1128,7 +1138,7 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
 
                                        // GOING from RTE to database:
                                case 'db':
-                                       
+
                                        if (!isset($this->procOptions['transformBoldAndItalicTags']) || $this->procOptions['transformBoldAndItalicTags']) {
                                                        // Transform strong/em back to bold/italics:
                                                if (isset($keepTags['strong'])) { $keepTags['strong']=array('remap'=>'b'); }
@@ -1139,12 +1149,12 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
                                        if (isset($keepTags['span']))           {
                                                $classes=array_merge(array(''),$this->allowedClasses);
                                                $keepTags['span']=array(
-                                                       'allowedAttribs' => 'class,style,xml:lang',
+                                                       'allowedAttribs' => 'id,class,style,title,lang,xml:lang,dir',
                                                        'fixAttrib' => Array(
                                                                'class' => Array (
                                                                        'list' => $classes,
                                                                        'removeIfFalse' => 1
-                                                               )
+                                                               ),
                                                        ),
                                                        'rmTagIfNoAttrib' => 1
                                                );
@@ -1533,12 +1543,14 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
                                        $info['type']='anchor';
                                } elseif (!trim($uP['path']) || !strcmp($uP['path'],'index.php'))       {
                                        $pp = explode('id=',$uP['query']);
-                                       $id = trim($pp[1]);
+                                       $parameters = explode('&', $pp[1]);
+                                       $id = array_shift($parameters);
                                        if ($id)        {
                                                $info['pageid']=$id;
                                                $info['cElement']=$uP['fragment'];
                                                $info['url']=$id.($info['cElement']?'#'.$info['cElement']:'');
                                                $info['type']='page';
+                                               $info['query'] = $parameters[0]?'&'.implode('&', $parameters):'';
                                        }
                                } else {
                                        $info['url']=$info['relUrl'];
@@ -1590,4 +1602,5 @@ class t3lib_parsehtml_proc extends t3lib_parsehtml {
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_parsehtml_proc.php'])   {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_parsehtml_proc.php']);
 }
-?>
+
+?>
\ No newline at end of file