* Fixed bug #8009: Wrong TS-Code because appendString cannot handle multiline strings
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_tsparser.php
index 7570a13..cb41644 100755 (executable)
@@ -1,22 +1,22 @@
 <?php
 /***************************************************************
 *  Copyright notice
-*  
-*  (c) 1999-2003 Kasper Skårhøj (kasper@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 
+*  This script is part of the TYPO3 project. The TYPO3 project is
 *  free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
-* 
+*
 *  The GNU General Public License can be found at
 *  http://www.gnu.org/copyleft/gpl.html.
-*  A copy is found in the textfile GPL.txt and important notices to the license 
+*  A copy is found in the textfile GPL.txt and important notices to the license
 *  from the author is found in LICENSE.txt distributed with these scripts.
 *
-* 
+*
 *  This script is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *
 *  This copyright notice MUST APPEAR in all copies of the script!
 ***************************************************************/
-/** 
+/**
  * Contains the TypoScript parser class
  *
- * Revised for TYPO3 3.6 July/2003 by Kasper Skårhøj
+ * $Id$
+ * Revised for TYPO3 3.6 July/2003 by Kasper Skaarhoj
  *
- * @author     Kasper Skårhøj <kasper@typo3.com>
- * @package TYPO3
- * @subpackage t3lib
+ * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
  */
 /**
  * [CLASS/FUNCTION INDEX of SCRIPT]
  *
  *
  *
- *   79: class t3lib_TSparser 
- *  129:     function parse($string,$matchObj='')      
- *  165:     function nextDivider()    
- *  181:     function parseSub(&$setup)        
- *  327:     function rollParseSub($string,&$setup)    
- *  351:     function getVal($string,$setup)   
- *  377:     function setVal($string,&$setup,$value,$wipeOut=0)        
- *  412:     function error($err,$num=2)       
- *  424:     function checkIncludeLines($string)       
- *  468:     function checkIncludeLines_array($array)  
+ *   80: class t3lib_TSparser
+ *  133:     function parse($string,$matchObj='')
+ *  169:     function nextDivider()
+ *  185:     function parseSub(&$setup)
+ *  389:     function rollParseSub($string,&$setup)
+ *  413:     function getVal($string,$setup)
+ *  439:     function setVal($string,&$setup,$value,$wipeOut=0)
+ *  485:     function error($err,$num=2)
+ *  497:     function checkIncludeLines($string)
+ *  541:     function checkIncludeLines_array($array)
  *
  *              SECTION: Syntax highlighting
- *  511:     function doSyntaxHighlight($string,$lineNum='',$highlightBlockMode=0)     
- *  532:     function regHighLight($code,$pointer,$strlen=-1)  
- *  550:     function syntaxHighlight_print($lineNumDat,$highlightBlockMode)   
+ *  584:     function doSyntaxHighlight($string,$lineNum='',$highlightBlockMode=0)
+ *  605:     function regHighLight($code,$pointer,$strlen=-1)
+ *  623:     function syntaxHighlight_print($lineNumDat,$highlightBlockMode)
  *
  * TOTAL FUNCTIONS: 12
  * (This index is automatically created/updated by the extension "extdeveval")
  *
  */
 
+
+
+
+
+
+
+
+
+
+
+
 /**
  * The TypoScript parser
- * 
- * @author     Kasper Skårhøj <kasper@typo3.com>
+ *
+ * @author     Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @package TYPO3
+ * @subpackage t3lib
  * @see t3lib_tstemplate, t3lib_matchcondition, t3lib_BEfunc::getPagesTSconfig(), t3lib_userAuthGroup::fetchGroupData(), t3lib_TStemplate::generateConfig()
  */
 class t3lib_TSparser {
@@ -98,6 +99,7 @@ class t3lib_TSparser {
 
                // Debugging, analysis:
        var $regComments = 0;                   // DO NOT register the comments. This is default for the ordinary sitetemplate!
+       var $regLinenumbers = 0;                // DO NOT register the linenumbers. This is default for the ordinary sitetemplate!
        var $errors=array();                    // Error accumulation array.
        var $lineNumberOffset=0;                // Used for the error messages line number reporting. Set externally.
        var $breakPointLN=0;                    // Line for break point.
@@ -110,7 +112,7 @@ class t3lib_TSparser {
                'objstr'                        => array('<span class="ts-objstr">','</span>'), // The object string of a line
                'value_copy'            => array('<span class="ts-value_copy">','</span>'),     // The value when the copy syntax (<) is used; that means the object reference
                'value_unset'           => array('<span class="ts-value_unset">','</span>'),    // The value when an object is unset. Should not exist.
-               'ignored'                       => array('<span class="ts-ignored">','</span>'),        // The "rest" of a line which will be ignored. 
+               'ignored'                       => array('<span class="ts-ignored">','</span>'),        // The "rest" of a line which will be ignored.
                'default'                       => array('<span class="ts-default">','</span>'),        // The default style if none other is applied.
                'comment'                       => array('<span class="ts-comment">','</span>'),        // Comment lines
                'condition'                     => array('<span class="ts-condition">','</span>'),      // Conditions
@@ -120,22 +122,21 @@ class t3lib_TSparser {
        var $highLightBlockStyles = '';         // Additional attributes for the <span> tags for a blockmode line
        var $highLightBlockStyles_basecolor = '#cccccc';                // The hex-HTML color for the blockmode
 
-       
+
        /**
         * Start parsing the input TypoScript text piece. The result is stored in $this->setup
-        * 
+        *
         * @param       string          The TypoScript text
         * @param       object          If is object (instance of t3lib_matchcondition), then this is used to match conditions found in the TypoScript code. If matchObj not specified, then no conditions will work! (Except [GLOBAL])
-        * @return      void            
+        * @return      void
         */
        function parse($string,$matchObj='')    {
                $this->raw = explode(chr(10),$string);
                $this->rawP = 0;
-               
                $pre = '[GLOBAL]';
                while($pre)     {
                        if ($this->breakPointLN && $pre=='[_BREAK]')    {
-                               $this->error('Breakpoint at '.($this->lineNumberOffset+$this->rawP-2).': Line content was "'.$this->raw[$this->rawP-2].'"',1);  
+                               $this->error('Breakpoint at '.($this->lineNumberOffset+$this->rawP-2).': Line content was "'.$this->raw[$this->rawP-2].'"',1);
                                break;
                        }
 
@@ -161,7 +162,7 @@ class t3lib_TSparser {
 
        /**
         * Will search for the next condition. When found it will return the line content (the condition value) and have advanced the internal $this->rawP pointer to point to the next line after the condition.
-        * 
+        *
         * @return      string          The condition value
         * @see parse()
         */
@@ -177,11 +178,13 @@ class t3lib_TSparser {
 
        /**
         * Parsing the $this->raw TypoScript lines from pointer, $this->rawP
-        * 
+        *
         * @param       array           Reference to the setup array in which to accumulate the values.
         * @return      string          Returns the string of the condition found, the exit signal or possible nothing (if it completed parsing with no interruptions)
         */
        function parseSub(&$setup)      {
+               global $TYPO3_CONF_VARS;
+
                while (isset($this->raw[$this->rawP]))  {
                        $line = ltrim($this->raw[$this->rawP]);
                        $lineP = $this->rawP;
@@ -197,22 +200,25 @@ class t3lib_TSparser {
                        if (!$this->multiLineEnabled && substr($line,0,2)=='/*')        {
                                $this->commentSet=1;
                        }
-                               
+
                        if (!$this->commentSet && ($line || $this->multiLineEnabled))   {       // If $this->multiLineEnabled we will go and get the line values here because we know, the first if() will be true.
                                if ($this->multiLineEnabled) {  // If multiline is enabled. Escape by ')'
                                        if (substr($line,0,1)==')')     {       // Multiline ends...
                                                if ($this->syntaxHighLight)     $this->regHighLight("operator",$lineP,strlen($line)-1);
                                                $this->multiLineEnabled=0;      // Disable multiline
                                                $theValue = implode($this->multiLineValue,chr(10));
-                                               if (strstr($this->multiLineObject,'.')) {       
+                                               if (strstr($this->multiLineObject,'.')) {
                                                        $this->setVal($this->multiLineObject,$setup,array($theValue));  // Set the value deeper.
                                                } else {
                                                        $setup[$this->multiLineObject] = $theValue;     // Set value regularly
                                                        if ($this->lastComment && $this->regComments)   {
                                                                $setup[$this->multiLineObject.'..'].=$this->lastComment;
                                                        }
+                                                       if ($this->regLinenumbers)      {
+                                                               $setup[$this->multiLineObject.'.ln..'][]=($this->lineNumberOffset+$this->rawP-1);
+                                                       }
                                                }
-                                       } else{
+                                       } else {
                                                if ($this->syntaxHighLight)     $this->regHighLight("value",$lineP);
                                                $this->multiLineValue[]=$this->raw[($this->rawP-1)];
                                        }
@@ -226,12 +232,13 @@ class t3lib_TSparser {
                                                $this->inBrace=0;
                                                return $line;
                                        } elseif (strcspn($line,'}#/')!=0)      {       // If not brace-end or comment
-                                               $varL = strcspn($line,' {=<>(');                // Find object name string until we meet an operator    VER2: Added '>'!!
+                                               $varL = strcspn($line,' {=<>:(');       // Find object name string until we meet an operator
                                                $objStrName=trim(substr($line,0,$varL));
                                                if ($this->syntaxHighLight)     $this->regHighLight("objstr",$lineP,strlen(substr($line,$varL)));
-                                               if ($objStrName)        {
-                                                       if ($this->strict && eregi('[^[:alnum:]_\.-]',$objStrName,$r))  {
-                                                               $this->error('Line '.($this->lineNumberOffset+$this->rawP-1).': Object Name String, "'.htmlspecialchars($objStrName).'" contains invalid character "'.$r[0].'". Must be alphanumeric or one of: "_-."'); 
+                                               if (strlen($objStrName)) {
+                                                       $r = array();
+                                                       if ($this->strict && preg_match('/[^[:alnum:]_\.-]/i',$objStrName,$r))  {
+                                                               $this->error('Line '.($this->lineNumberOffset+$this->rawP-1).': Object Name String, "'.htmlspecialchars($objStrName).'" contains invalid character "'.$r[0].'". Must be alphanumeric or one of: "_-."');
                                                        } else {
                                                                $line = ltrim(substr($line,$varL));
                                                                if ($this->syntaxHighLight)     {
@@ -241,9 +248,64 @@ class t3lib_TSparser {
                                                                                $this->regHighLight("operator_postspace", $lineP, strlen(ltrim(substr($line,1))));
                                                                        }
                                                                }
+
+                                                                       // Checking for special TSparser properties (to change TS values at parsetime)
+                                                               $match = array();
+                                                               if (preg_match('/^:=([^\(]+)\((.+)\).*/', $line, $match))       {
+                                                                       $tsFunc = trim($match[1]);
+                                                                       $tsFuncArg = $match[2];
+                                                                       list ($currentValue) = $this->getVal($objStrName,$setup);
+
+                                                                       $tsFuncArg = str_replace(
+                                                                               array('\\\\', '\n','\t'),
+                                                                               array('\\', chr(10),chr(9)),
+                                                                               $tsFuncArg
+                                                                       );
+
+                                                                       switch ($tsFunc)        {
+                                                                               case 'prependString':
+                                                                                       $newValue = $tsFuncArg . $currentValue;
+                                                                               break;
+                                                                               case 'appendString':
+                                                                                       $newValue = $currentValue . $tsFuncArg;
+                                                                               break;
+                                                                               case 'removeString':
+                                                                                       $newValue = str_replace($tsFuncArg, '', $currentValue);
+                                                                               break;
+                                                                               case 'replaceString':
+                                                                                       list($fromStr,$toStr) = explode('|', $tsFuncArg, 2);
+                                                                                       $newValue = str_replace($fromStr, $toStr, $currentValue);
+                                                                               break;
+                                                                               case 'addToList':
+                                                                                       $newValue = (strcmp('',$currentValue) ? $currentValue.',' : '') . trim($tsFuncArg);
+                                                                               break;
+                                                                               case 'removeFromList':
+                                                                                       $existingElements = t3lib_div::trimExplode(',',$currentValue);
+                                                                                       $removeElements = t3lib_div::trimExplode(',',$tsFuncArg);
+                                                                                       if (count($removeElements))     {
+                                                                                               $newValue = implode(',', array_diff($existingElements, $removeElements));
+                                                                                       }
+                                                                               break;
+                                                                               default:
+                                                                                       if (isset($TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tsparser.php']['preParseFunc'][$tsFunc]))   {
+                                                                                               $hookMethod = $TYPO3_CONF_VARS['SC_OPTIONS']['t3lib/class.t3lib_tsparser.php']['preParseFunc'][$tsFunc];
+                                                                                               $params = array('currentValue'=>$currentValue, 'functionArgument'=>$tsFuncArg);
+                                                                                               $fakeThis = FALSE;
+                                                                                               $newValue = t3lib_div::callUserFunction($hookMethod,$params,$fakeThis);
+                                                                                       } else {
+                                                                                               t3lib_div::sysLog('Missing function definition for '.$tsFunc.' on TypoScript line '.$lineP,'Core',2);
+                                                                                       }
+                                                                       }
+
+                                                                       if (isset($newValue))   {
+                                                                               $line = '= '.$newValue;
+                                                                       }
+                                                               }
+
                                                                switch(substr($line,0,1))       {
                                                                        case '=':
-                                                                               if ($this->syntaxHighLight)     $this->regHighLight("value", $lineP, strlen(ltrim(substr($line,1)))-strlen(trim(substr($line,1))));
+                                                                               if ($this->syntaxHighLight)     $this->regHighLight('value', $lineP, strlen(ltrim(substr($line,1)))-strlen(trim(substr($line,1))));
+
                                                                                if (strstr($objStrName,'.'))    {
                                                                                        $value = Array();
                                                                                        $value[0] = trim(substr($line,1));
@@ -253,6 +315,9 @@ class t3lib_TSparser {
                                                                                        if ($this->lastComment && $this->regComments)   {       // Setting comment..
                                                                                                $setup[$objStrName.'..'].=$this->lastComment;
                                                                                        }
+                                                                                       if ($this->regLinenumbers)      {
+                                                                                               $setup[$objStrName.'.ln..'][]=($this->lineNumberOffset+$this->rawP-1);
+                                                                                       }
                                                                                }
                                                                        break;
                                                                        case '{':
@@ -279,14 +344,14 @@ class t3lib_TSparser {
                                                                                } else {
                                                                                        $res = $this->getVal($theVal,$this->setup);
                                                                                }
-                                                                               $this->setVal($objStrName,$setup,unserialize(serialize($res)),1);
+                                                                               $this->setVal($objStrName,$setup,unserialize(serialize($res)),1);       // unserialize(serialize(...)) may look stupid but is needed because of some reference issues. See Kaspers reply to "[TYPO3-core] good question" from December 15 2005.
                                                                        break;
                                                                        case '>':
                                                                                if ($this->syntaxHighLight)     $this->regHighLight("value_unset", $lineP, strlen(ltrim(substr($line,1)))-strlen(trim(substr($line,1))));
                                                                                $this->setVal($objStrName,$setup,'UNSET');
                                                                        break;
                                                                        default:
-                                                                               $this->error('Line '.($this->lineNumberOffset+$this->rawP-1).': Object Name String, "'.htmlspecialchars($objStrName).'" was not preceeded by any operator, =<>({');
+                                                                               $this->error('Line '.($this->lineNumberOffset+$this->rawP-1).': Object Name String, "'.htmlspecialchars($objStrName).'" was not preceded by any operator, =<>({');
                                                                        break;
                                                                }
                                                        }
@@ -310,7 +375,7 @@ class t3lib_TSparser {
                                        }
                                }
                        }
-                       
+
                                // Unset comment
                        if ($this->commentSet)  {
                                if ($this->syntaxHighLight)     $this->regHighLight("comment",  $lineP);
@@ -321,7 +386,7 @@ class t3lib_TSparser {
 
        /**
         * Parsing of TypoScript keys inside a curly brace where the key is composite of at least two keys, thus having to recursively call itself to get the value
-        * 
+        *
         * @param       string          The object sub-path, eg "thisprop.another_prot"
         * @param       array           The local setup array from the function calling this function
         * @return      string          Returns the exitSignal
@@ -346,7 +411,7 @@ class t3lib_TSparser {
 
        /**
         * Get a value/property pair for an object path in TypoScript, eg. "myobject.myvalue.mysubproperty". Here: Used by the "copy" operator, <
-        * 
+        *
         * @param       string          Object path for which to get the value
         * @param       array           Global setup code if $string points to a global object path. But if string is prefixed with "." then its the local setup array.
         * @return      array           An array with keys 0/1 being value/property respectively
@@ -370,12 +435,12 @@ class t3lib_TSparser {
 
        /**
         * Setting a value/property of an object string in the setup array.
-        * 
+        *
         * @param       string          The object sub-path, eg "thisprop.another_prot"
         * @param       array           The local setup array from the function calling this function.
         * @param       array           The value/property pair array to set. If only one of them is set, then the other is not touched (unless $wipeOut is set, which it is when copies are made which must include both value and property)
         * @param       boolean         If set, then both value and property is wiped out when a copy is made of another value.
-        * @return      void            
+        * @return      void
         */
        function setVal($string,&$setup,$value,$wipeOut=0)      {
                if ((string)$string!='')        {
@@ -384,17 +449,28 @@ class t3lib_TSparser {
                                if ($value=='UNSET')    {
                                        unset($setup[$string]);
                                        unset($setup[$string.'.']);
+                                       if ($this->regLinenumbers)      {
+                                               $setup[$string.'.ln..'][]=($this->lineNumberOffset+$this->rawP-1).'>';
+                                       }
                                } else {
+                                       $lnRegisDone=0;
                                        if ($wipeOut && $this->strict)  {
                                                if ((isset($setup[$string]) && !isset($value[0])) || (isset($setup[$string.'.']) && !isset($value[1]))) {$this->error('Line '.($this->lineNumberOffset+$this->rawP-1).': Object copied in this line "'.trim($this->raw[($this->rawP-1)]).'" would leave either the value or properties untouched in TypoScript Version 1. Please check that this is not a problem for you.',1);}
                                                unset($setup[$string]);
                                                unset($setup[$string.'.']);
+                                               if ($this->regLinenumbers)      {
+                                                       $setup[$string.'.ln..'][]=($this->lineNumberOffset+$this->rawP-1).'<';
+                                                       $lnRegisDone=1;
+                                               }
                                        }
                                        if (isset($value[0])) {$setup[$string] = $value[0];}
                                        if (isset($value[1])) {$setup[$string.'.'] = $value[1];}
                                        if ($this->lastComment && $this->regComments)   {
                                                $setup[$string.'..'].=$this->lastComment;
                                        }
+                                       if ($this->regLinenumbers && !$lnRegisDone)     {
+                                               $setup[$string.'.ln..'][]=($this->lineNumberOffset+$this->rawP-1);
+                                       }
                                }
                        } else {
                                $key = substr($string,0,$keyLen).'.';
@@ -407,10 +483,10 @@ class t3lib_TSparser {
        /**
         * Stacks errors/messages from the TypoScript parser into an internal array, $this->error
         * If "TT" is a global object (as it is in the frontend when backend users are logged in) the message will be registered here as well.
-        * 
+        *
         * @param       string          The error message string
         * @param       integer         The error severity (in the scale of $GLOBALS['TT']->setTSlogMessage: Approx: 2=warning, 1=info, 0=nothing, 3=fatal.)
-        * @return      void            
+        * @return      void
         */
        function error($err,$num=2)     {
                if (is_object($GLOBALS['TT']))  $GLOBALS['TT']->setTSlogMessage($err,$num);
@@ -420,11 +496,17 @@ class t3lib_TSparser {
        /**
         * Checks the input string (un-parsed TypoScript) for include-commands ("<INCLUDE_TYPOSCRIPT: ....")
         * Use: t3lib_TSparser::checkIncludeLines()
-        * 
+        *
         * @param       string          Unparsed TypoScript
+        * @param       integer         Counter for detecting endless loops
         * @return      string          Complete TypoScript with includes added.
+        * @static
         */
-       function checkIncludeLines($string)     {
+       function checkIncludeLines($string, $cycle_counter=1)   {
+               if ($cycle_counter>100) {
+                       t3lib_div::sysLog('It appears like TypoScript code is looping over itself. Check your templates for "&lt;INCLUDE_TYPOSCRIPT: ..." tags','Core',2);
+                       return '';
+               }
                $splitStr='<INCLUDE_TYPOSCRIPT:';
                if (strstr($string,$splitStr))  {
                        $newString='';
@@ -433,9 +515,9 @@ class t3lib_TSparser {
                        while(list($c,$v)=each($allParts))      {
                                if (!$c)        {        // first goes through
                                        $newString.=$v;
-                               } elseif (ereg("\r?\n[ ]*$",$allParts[$c-1]))   {       // There must be a line-break char before.
+                               } elseif (preg_match('/\r?\n\s*$/',$allParts[$c-1]))    {       // There must be a line-break char before.
                                        $subparts=explode('>',$v,2);
-                                       if (ereg("^[ ]*\r?\n",$subparts[1]))    {       // There must be a line-break char after
+                                       if (preg_match('/^\s*\r?\n/',$subparts[1]))     {       // There must be a line-break char after
                                                        // SO, the include was positively recognized:
                                                $newString.='### '.$splitStr.$subparts[0].'> BEGIN:'.chr(10);
                                                $params = t3lib_div::get_tag_attributes($subparts[0]);
@@ -446,7 +528,9 @@ class t3lib_TSparser {
                                                                        $filename = t3lib_div::getFileAbsFileName(trim($sourceParts[1]));
                                                                        if (strcmp($filename,''))       {       // Must exist and must not contain '..' and must be relative
                                                                                if (@is_file($filename) && filesize($filename)<100000)  {       // Max. 100 KB include files!
-                                                                                       $newString.=t3lib_div::getUrl($filename).chr(10);
+                                                                                               // check for includes in included text
+                                                                                       $included_text = self::checkIncludeLines(t3lib_div::getUrl($filename),$cycle_counter+1);
+                                                                                       $newString.= $included_text.chr(10);
                                                                                }
                                                                        }
                                                                break;
@@ -464,7 +548,7 @@ class t3lib_TSparser {
 
        /**
         * Parses the string in each value of the input array for include-commands
-        * 
+        *
         * @param       array           Array with TypoScript in each value
         * @return      array           Same array but where the values has been parsed for include-commands
         */
@@ -477,7 +561,7 @@ class t3lib_TSparser {
        }
 
 
-       
+
 
 
 
@@ -504,8 +588,8 @@ class t3lib_TSparser {
 
        /**
         * Syntax highlight a TypoScript text
-        * Will parse the content. Remember, the internal setup array may contain INvalid parsed content since conditions are ignored!
-        * 
+        * Will parse the content. Remember, the internal setup array may contain invalid parsed content since conditions are ignored!
+        *
         * @param       string          The TypoScript text
         * @param       mixed           If blank, linenumbers are NOT printed. If array then the first key is the linenumber offset to add to the internal counter.
         * @param       boolean         If set, then the highlighted output will be formatted in blocks based on the brace levels. prespace will be ignored and empty lines represented with a single no-break-space.
@@ -516,7 +600,7 @@ class t3lib_TSparser {
                $this->highLightData=array();
                $this->error=array();
                $string = str_replace(chr(13),'',$string);              // This is done in order to prevent empty <span>..</span> sections around chr(13) content. Should not do anything but help lessen the amount of HTML code.
-               
+
                $this->parse($string);
 
                return $this->syntaxHighlight_print($lineNum,$highlightBlockMode);
@@ -524,11 +608,11 @@ class t3lib_TSparser {
 
        /**
         * Registers a part of a TypoScript line for syntax highlighting.
-        * 
+        *
         * @param       string          Key from the internal array $this->highLightStyles
         * @param       integer         Pointer to the line in $this->raw which this is about
         * @param       integer         The number of chars LEFT on this line before the end is reached.
-        * @return      void            
+        * @return      void
         * @access private
         * @see parse()
         */
@@ -543,7 +627,7 @@ class t3lib_TSparser {
 
        /**
         * Formatting the TypoScript code in $this->raw based on the data collected by $this->regHighLight in $this->highLightData
-        * 
+        *
         * @param       mixed           If blank, linenumbers are NOT printed. If array then the first key is the linenumber offset to add to the internal counter.
         * @param       boolean         If set, then the highlighted output will be formatted in blocks based on the brace levels. prespace will be ignored and empty lines represented with a single no-break-space.
         * @return      string          HTML content
@@ -578,11 +662,9 @@ class t3lib_TSparser {
                        if (strlen(substr($value,$start)))      $lineC.=$this->highLightStyles['ignored'][0].htmlspecialchars(substr($value,$start)).$this->highLightStyles['ignored'][1];
 
                        if ($errA[$rawP])       {
-#                              $lineC.=$this->highLightStyles['error'][0].htmlspecialchars(trim(substr($value,$start))).$this->highLightStyles['error'][1].
-#                              $start=strlen($value);
                                $lineC.=$this->highLightStyles['error'][0].'<strong> - ERROR:</strong> '.htmlspecialchars(implode(';',$errA[$rawP])).$this->highLightStyles['error'][1];
                        }
-                       
+
                        if ($highlightBlockMode && $this->highLightData_bracelevel[$rawP])      {
                                $lineC = str_pad('',$this->highLightData_bracelevel[$rawP]*2,' ',STR_PAD_LEFT).'<span style="'.$this->highLightBlockStyles.($this->highLightBlockStyles_basecolor?'background-color: '.t3lib_div::modifyHTMLColorAll($this->highLightBlockStyles_basecolor,-$this->highLightData_bracelevel[$rawP]*16):'').'">'.(strcmp($lineC,'')?$lineC:'&nbsp;').'</span>';
                        }
@@ -591,27 +673,17 @@ class t3lib_TSparser {
                                $lineNum = $rawP+$lineNumDat[0];
                                $lineC = $this->highLightStyles['linenum'][0].str_pad($lineNum,4,' ',STR_PAD_LEFT).':'.$this->highLightStyles['linenum'][1].' '.$lineC;
                        }
-                       
+
 
                        $lines[] = $lineC;
                }
-               
+
                return '<pre class="ts-hl">'.implode(chr(10),$lines).'</pre>';
        }
-       
-       
-/*     
-       function xmlToTypoScriptStruct($xmlInput)       {
-               $res = t3lib_div::xml2tree($xmlInput);
-               if (is_array($res))     {
-                       $this->xmlToTypoScriptSetup($res);
-               } else return 'XML parser error: '.$res;
-       }
-*/
 }
 
 
 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tsparser.php']) {
        include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_tsparser.php']);
 }
-?>
\ No newline at end of file
+?>