[TASK] Remove deprecated usages of intInRange, intval_positive and int_from_ver
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_timetrack.php
old mode 100755 (executable)
new mode 100644 (file)
index d211384..e16dbdc
 <?php
 /***************************************************************
-*  Copyright notice
-*
-*  (c) 1999-2005 Kasper Skaarhoj (kasperYYYY@typo3.com)
-*  All rights reserved
-*
-*  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
-*  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
-*  GNU General Public License for more details.
-*
-*  This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
-/**
-* Contains class with time tracking functions
-*
-* $Id$
-* Revised for TYPO3 3.6 July/2003 by Kasper Skaarhoj
-* XHTML compliant
-*
-* @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
-*/
-/**
- * [CLASS/FUNCTION INDEX of SCRIPT]
+ *  Copyright notice
  *
+ *  (c) 1999-2011 Kasper Skårhøj (kasperYYYY@typo3.com)
+ *  All rights reserved
  *
+ *  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.
  *
- *   88: class t3lib_timeTrack
+ *  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
+ *  from the author is found in LICENSE.txt distributed with these scripts.
  *
- *              SECTION: Logging parsing times in the scripts
- *  144:     function start()
- *  157:     function push($tslabel, $value='')
- *  182:     function pull($content='')
- *  200:     function setTSlogMessage($content,$num=0)
- *  214:     function setTSselectQuery($query,$msg)
- *  227:     function incStackPointer()
- *  238:     function decStackPointer()
- *  248:     function mtime()
- *  258:     function convertMicrotime($microtime)
  *
- *              SECTION: Printing the parsing time information (for Admin Panel)
- *  291:     function printTSlog()
- *  436:     function fixContent(&$arr, $content, $depthData='', $first=0, $vKey='')
- *  500:     function fixCLen($c,$v)
- *  516:     function fw($str)
- *  530:     function createHierarchyArray(&$arr,$pointer,$uniqueId)
- *  550:     function debug_typo3PrintError($header,$text,$js,$baseUrl='')
+ *  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
+ *  GNU General Public License for more details.
+ *
+ *  This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
+/**
+ * Contains class with time tracking functions
  *
- * TOTAL FUNCTIONS: 15
- * (This index is automatically created/updated by the extension "extdeveval")
+ * Revised for TYPO3 3.6 July/2003 by Kasper Skårhøj
+ * XHTML compliant
  *
+ * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
  */
 
 
-
-
-
-
-
-
-
-
-
 /**
  * Frontend Timetracking functions
  *
  * Is used to register how much time is used with operations in TypoScript
  * Used by index_ts
  *
- * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
+ * @author  Kasper Skårhøj <kasperYYYY@typo3.com>
  * @package TYPO3
  * @subpackage t3lib
  * @see t3lib_tsfeBeUserAuth, tslib_fe, tslib_cObj, TSpagegen
  */
 class t3lib_timeTrack {
-       var $starttime = 0;             // Is loaded with the millisecond time when this object is created
+       var $starttime = 0; // Is loaded with the millisecond time when this object is created
 
-       var $LR = 1;                    // Log Rendering flag. If set, ->push() and ->pull() is called from the cObj->cObjGetSingle(). This determines whether or not the TypoScript parsing activity is logged. But it also slows down the rendering
-       var $printConf=array(
+       var $LR = 1; // Log Rendering flag. If set, ->push() and ->pull() is called from the cObj->cObjGetSingle(). This determines whether or not the TypoScript parsing activity is logged. But it also slows down the rendering
+       var $printConf = array(
                'showParentKeys' => 1,
-               'contentLength' => 10000,       // Determines max lenght of displayed content before it gets cropped.
-               'contentLength_FILE' => 400,    // Determines max lenght of displayed content FROM FILE cObjects before it gets cropped. Reason is that most FILE cObjects are huge and often used as template-code.
+               'contentLength' => 10000, // Determines max lenght of displayed content before it gets cropped.
+               'contentLength_FILE' => 400, // Determines max lenght of displayed content FROM FILE cObjects before it gets cropped. Reason is that most FILE cObjects are huge and often used as template-code.
                'flag_tree' => 1,
                'flag_messages' => 1,
                'flag_queries' => 0,
                'flag_content' => 0,
                'allTime' => 0,
                'keyLgd' => 40,
-               'factor' => 10,
-               'col' => '#D9D5C9'
-       );
-
-       var $wrapError =array(
-               0 => array('',''),
-               1 => array('<b>','</b>'),
-               2 => array('<b><font color="#ff6600">','</font></b>'),
-               3 => array('<b><font color="#ff0000">','</font></b>')
-       );
-       var $wrapIcon =array(
-               0 => '',
-               1 => '<img src="t3lib/gfx/icon_note.gif" width="18" height="16" align="absmiddle" alt="" />',
-               2 => '<img src="t3lib/gfx/icon_warning.gif" width="18" height="16" align="absmiddle" alt="" />',
-               3 => '<img src="t3lib/gfx/icon_fatalerror.gif" width="18" height="16" align="absmiddle" alt="" />'
        );
 
-       var $uniqueCounter=0;
+       var $wrapError = array();
+       var $wrapIcon = array();
+       var $uniqueCounter = 0;
        var $tsStack = array(array());
        var $tsStackLevel = 0;
-       var $tsStackLevelMax=array();
+       var $tsStackLevelMax = array();
        var $tsStackLog = array();
-       var $tsStackPointer=0;
-       var $currentHashPointer=array();
-
-
-
+       var $tsStackPointer = 0;
+       var $currentHashPointer = array();
 
+       var $highlightLongerThan = 0; // Log entries that take than this number of milliseconds (own time) will be highlighted during log display. Set 0 to disable highlighting.
 
 
        /*******************************************
-       *
-       * Logging parsing times in the scripts
-       *
-       *******************************************/
+        *
+        * Logging parsing times in the scripts
+        *
+        *******************************************/
 
        /**
         * Constructor
@@ -141,9 +86,22 @@ class t3lib_timeTrack {
         *
         * @return      void
         */
-       function start()    {
-               $this->starttime=0;
-               $this->starttime=$this->mtime();
+       public function start() {
+               $this->wrapError = array(
+                       0 => array('', ''),
+                       1 => array('<strong>', '</strong>'),
+                       2 => array('<strong style="color:#ff6600;">', '</strong>'),
+                       3 => array('<strong style="color:#ff0000;">', '</strong>')
+               );
+
+               $this->wrapIcon = array(
+                       0 => '',
+                       1 => '<img src="' . TYPO3_mainDir . 'gfx/icon_note.gif" width="18" height="16" align="absmiddle" alt="" />',
+                       2 => '<img src="' . TYPO3_mainDir . 'gfx/icon_warning.gif" width="18" height="16" align="absmiddle" alt="" />',
+                       3 => '<img src="' . TYPO3_mainDir . 'gfx/icon_fatalerror.gif" width="18" height="16" align="absmiddle" alt="" />'
+               );
+
+               $this->starttime = $this->getMilliseconds();
        }
 
        /**
@@ -154,9 +112,9 @@ class t3lib_timeTrack {
         * @return      void
         * @see tslib_cObj::cObjGetSingle(), pull()
         */
-       function push($tslabel, $value='')  {
+       public function push($tslabel, $value = '') {
                array_push($this->tsStack[$this->tsStackPointer], $tslabel);
-               array_push($this->currentHashPointer, 'timetracker_'.$this->uniqueCounter++);
+               array_push($this->currentHashPointer, 'timetracker_' . $this->uniqueCounter++);
 
                $this->tsStackLevel++;
                $this->tsStackLevelMax[] = $this->tsStackLevel;
@@ -167,7 +125,7 @@ class t3lib_timeTrack {
                        'level' => $this->tsStackLevel,
                        'tsStack' => $this->tsStack,
                        'value' => $value,
-                       'starttime' => microtime(),
+                       'starttime' => microtime(TRUE),
                        'stackPointer' => $this->tsStackPointer
                );
        }
@@ -179,9 +137,9 @@ class t3lib_timeTrack {
         * @return      void
         * @see tslib_cObj::cObjGetSingle(), push()
         */
-       function pull($content='')  {
+       public function pull($content = '') {
                $k = end($this->currentHashPointer);
-               $this->tsStackLog[$k]['endtime'] =  microtime();
+               $this->tsStackLog[$k]['endtime'] = microtime(TRUE);
                $this->tsStackLog[$k]['content'] = $content;
 
                $this->tsStackLevel--;
@@ -197,25 +155,32 @@ class t3lib_timeTrack {
         * @return      void
         * @see tslib_cObj::CONTENT()
         */
-       function setTSlogMessage($content,$num=0)   {
+       public function setTSlogMessage($content, $num = 0) {
                end($this->currentHashPointer);
                $k = current($this->currentHashPointer);
 
-               $this->tsStackLog[$k]['message'][] = $this->wrapIcon[$num].$this->wrapError[$num][0].htmlspecialchars($content).$this->wrapError[$num][1];
+               if (strlen($content) > 30) { // Enlarge the "details" column by adding a wide clear.gif
+                       $placeholder = '<br /><img src="' . TYPO3_mainDir . 'clear.gif" width="300" height="1" alt="" />';
+               }
+               $this->tsStackLog[$k]['message'][] = $this->wrapIcon[$num] . $this->wrapError[$num][0] . htmlspecialchars($content) . $this->wrapError[$num][1] . $placeholder;
        }
 
        /**
         * Set TSselectQuery - for messages in TypoScript debugger.
         *
-        * @param       string          Query string
+        * @param       array           Query array
         * @param       string          Message/Label to attach
         * @return      void
         */
-       function setTSselectQuery($query,$msg)  {
+       public function setTSselectQuery(array $data, $msg = '') {
                end($this->currentHashPointer);
                $k = current($this->currentHashPointer);
 
-               $this->tsStackLog[$k]['selectQuery'][] = array('query'=>$query,'msg'=>$msg);
+               if (strlen($msg)) {
+                       $data['msg'] = $msg;
+               }
+
+               $this->tsStackLog[$k]['selectQuery'][] = $data;
        }
 
        /**
@@ -224,9 +189,9 @@ class t3lib_timeTrack {
         * @return      void
         * @see decStackPointer(), TSpagegen::renderContent(), tslib_cObj::cObjGetSingle()
         */
-       function incStackPointer()  {
+       public function incStackPointer() {
                $this->tsStackPointer++;
-               $this->tsStack[$this->tsStackPointer]=array();
+               $this->tsStack[$this->tsStackPointer] = array();
        }
 
        /**
@@ -235,52 +200,40 @@ class t3lib_timeTrack {
         * @return      void
         * @see incStackPointer(), TSpagegen::renderContent(), tslib_cObj::cObjGetSingle()
         */
-       function decStackPointer()  {
+       public function decStackPointer() {
                unset($this->tsStack[$this->tsStackPointer]);
                $this->tsStackPointer--;
        }
 
        /**
-        * Returns the current time in milliseconds
+        * Gets a microtime value as milliseconds value.
         *
-        * @return      integer
+        * @param       float           $microtime: The microtime value - if not set the current time is used
+        * @return      integer         The microtime value as milliseconds value
         */
-       function mtime()    {
-               return $this->convertMicrotime(microtime())-$this->starttime;
+       public function getMilliseconds($microtime = NULL) {
+               if (!isset($microtime)) {
+                       $microtime = microtime(TRUE);
+               }
+               return round($microtime * 1000);
        }
 
        /**
-        * Returns microtime input to milliseconds
+        * Gets the difference between a given microtime value and the starting time as milliseconds.
         *
-        * @param       string          PHP microtime string
-        * @return      integer
+        * @param       float           $microtime: The microtime value - if not set the current time is used
+        * @return      integer         The difference between a given microtime value and starting time as milliseconds
         */
-       function convertMicrotime($microtime)   {
-               $parts = explode(' ',$microtime);
-               return round(($parts[0]+$parts[1])*1000);
+       public function getDifferenceToStarttime($microtime = NULL) {
+               return ($this->getMilliseconds($microtime) - $this->starttime);
        }
 
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
        /*******************************************
-       *
-       * Printing the parsing time information (for Admin Panel)
-       *
-       *******************************************/
+        *
+        * Printing the parsing time information (for Admin Panel)
+        *
+        *******************************************/
 
        /**
         * Print TypoScript parsing log
@@ -288,138 +241,142 @@ class t3lib_timeTrack {
         * @return      string          HTML table with the information about parsing times.
         * @see t3lib_tsfeBeUserAuth::extGetCategory_tsdebug()
         */
-       function printTSlog()   {
+       public function printTSlog() {
                        // Calculate times and keys for the tsStackLog
-               reset($this->tsStackLog);
-               $preEndtime=0;
-               while(list($uniqueId,$data)=each($this->tsStackLog))    {
-                       $this->tsStackLog[$uniqueId]['endtime'] = $this->convertMicrotime($this->tsStackLog[$uniqueId]['endtime'])-$this->starttime;
-                       $this->tsStackLog[$uniqueId]['starttime'] = $this->convertMicrotime($this->tsStackLog[$uniqueId]['starttime'])-$this->starttime;
-                       $this->tsStackLog[$uniqueId]['deltatime'] = $this->tsStackLog[$uniqueId]['endtime']-$this->tsStackLog[$uniqueId]['starttime'];
-                       $this->tsStackLog[$uniqueId]['key'] = implode(end($data['tsStack']),$this->tsStackLog[$uniqueId]['stackPointer']?'.':'/');
-                       $preEndtime = $this->tsStackLog[$uniqueId]['endtime'];
+               foreach ($this->tsStackLog as $uniqueId => &$data) {
+                       $data['endtime'] = $this->getDifferenceToStarttime($data['endtime']);
+                       $data['starttime'] = $this->getDifferenceToStarttime($data['starttime']);
+                       $data['deltatime'] = $data['endtime'] - $data['starttime'];
+                       if (is_array($data['tsStack'])) {
+                               $data['key'] = implode($data['stackPointer'] ? '.' : '/', end($data['tsStack']));
+                       }
                }
+               unset($data);
 
                        // Create hierarchical array of keys pointing to the stack
                $arr = array();
-               reset($this->tsStackLog);
-               while(list($uniqueId,$data)=each($this->tsStackLog))    {
-                       $this->createHierarchyArray($arr,$data['level'], $uniqueId);
+               foreach ($this->tsStackLog as $uniqueId => $data) {
+                       $this->createHierarchyArray($arr, $data['level'], $uniqueId);
                }
                        // Parsing the registeret content and create icon-html for the tree
                $this->tsStackLog[$arr['0.'][0]]['content'] = $this->fixContent($arr['0.']['0.'], $this->tsStackLog[$arr['0.'][0]]['content'], '', 0, $arr['0.'][0]);
 
                        // Displaying the tree:
-               reset($this->tsStackLog);
-               $out='<tr>
-                       <td bgcolor="#ABBBB4" align="center"><b>'.$this->fw('TypoScript Key').'</b></td>
-                       <td bgcolor="#ABBBB4" align="center"><b>'.$this->fw('Value').'</b></td>';
-               if ($this->printConf['allTime'])    {
-                       $out.='
-                       <td bgcolor="#ABBBB4" align="center"><b>'.$this->fw('Time').'</b></td>
-                       <td bgcolor="#ABBBB4" align="center"><b>'.$this->fw('Own').'</b></td>
-                       <td bgcolor="#ABBBB4" align="center"><b>'.$this->fw('Sub').'</b></td>
-                       <td bgcolor="#ABBBB4" align="center"><b>'.$this->fw('Total').'</b></td>';
+               $outputArr = array();
+               $outputArr[] = $this->fw('TypoScript Key');
+               $outputArr[] = $this->fw('Value');
+
+               if ($this->printConf['allTime']) {
+                       $outputArr[] = $this->fw('Time');
+                       $outputArr[] = $this->fw('Own');
+                       $outputArr[] = $this->fw('Sub');
+                       $outputArr[] = $this->fw('Total');
                } else {
-                       $out.='
-                       <td bgcolor="#ABBBB4" align="center"><b>'.$this->fw('Own').'</b></td>';
+                       $outputArr[] = $this->fw('Own');
                }
 
-               $out.='
-                       <td bgcolor="#ABBBB4" align="center"><b>'.$this->fw('Details').'</b></td>
-                       </tr>';
-
+               $outputArr[] = $this->fw('Details');
 
+               $out = '';
+               foreach ($outputArr as $row) {
+                       $out .= '
+                               <th><strong>' . $row . '</strong></th>';
+               }
+               $out = '<tr>' . $out . '</tr>';
+
+               $flag_tree = $this->printConf['flag_tree'];
+               $flag_messages = $this->printConf['flag_messages'];
+               $flag_content = $this->printConf['flag_content'];
+               $flag_queries = $this->printConf['flag_queries'];
+               $keyLgd = $this->printConf['keyLgd'];
+               $factor = $this->printConf['factor'];
+               $col = $this->printConf['col'];
+               $highlight_col = $this->printConf['highlight_col'];
+
+               $c = 0;
+               foreach ($this->tsStackLog as $uniqueId => $data) {
+                       if ($this->highlightLongerThan && intval($data['owntime']) > intval($this->highlightLongerThan)) {
+                               $logRowClass = 'typo3-adminPanel-logRow-highlight';
+                       } else {
+                               $logRowClass = ($c % 2) ? 'typo3-adminPanel-logRow-odd' : 'typo3-adminPanel-logRow-even';
+                       }
 
-               $flag_tree=$this->printConf['flag_tree'];
-               $flag_messages=$this->printConf['flag_messages'];
-               $flag_content=$this->printConf['flag_content'];
-               $flag_queries=$this->printConf['flag_queries'];
-               $keyLgd=$this->printConf['keyLgd'];
-               $factor=$this->printConf['factor'];
-               $col=$this->printConf['col'];
-
-               $c=0;
-               while(list($uniqueId,$data)=each($this->tsStackLog))    {
-                       $bgColor = ' bgcolor="'.($c%2 ? t3lib_div::modifyHTMLColor($col,$factor,$factor,$factor) : $col).'"';
-                       $item='';
-                       if (!$c)    {   // If first...
-                               $data['icons']='';
-                               $data['key']= 'Script Start';
+                       $item = '';
+                       if (!$c) { // If first...
+                               $data['icons'] = '';
+                               $data['key'] = 'Script Start';
                                $data['value'] = '';
                        }
 
 
                                // key label:
-                       $keyLabel='';
-                       if (!$flag_tree && $data['stackPointer'])   {
-                               $temp=array();
-                               reset($data['tsStack']);
-                               while(list($k,$v)=each($data['tsStack']))   {
-                                       $temp[]=t3lib_div::fixed_lgd_pre(implode($v,$k?'.':'/'),$keyLgd);
+                       $keyLabel = '';
+                       if (!$flag_tree && $data['stackPointer']) {
+                               $temp = array();
+                               foreach ($data['tsStack'] as $k => $v) {
+                                       $temp[] = t3lib_div::fixed_lgd_cs(implode($v, $k ? '.' : '/'), -$keyLgd);
                                }
                                array_pop($temp);
                                $temp = array_reverse($temp);
                                array_pop($temp);
-                               if (count($temp))   {
-                                       $keyLabel='<br /><font color="#999999">'.implode($temp,'<br />').'</font>';
+                               if (count($temp)) {
+                                       $keyLabel = '<br /><span style="color:#999999;">' . implode($temp, '<br />') . '</span>';
                                }
                        }
-                       $theLabel = $flag_tree ? end(t3lib_div::trimExplode('.',$data['key'],1)) : $data['key'];
-                       $theLabel = t3lib_div::fixed_lgd_pre($theLabel, $keyLgd);
-                       $theLabel = $data['stackPointer'] ? '<font color="maroon">'.$theLabel.'</font>' : $theLabel;
-                       $keyLabel=$theLabel.$keyLabel;
-                       $item.='<td valign="top" nowrap="nowrap"'.$bgColor.'>'.($flag_tree?$data['icons']:'').$this->fw($keyLabel).'</td>';
+                       if ($flag_tree) {
+                               $tmp = t3lib_div::trimExplode('.', $data['key'], 1);
+                               $theLabel = end($tmp);
+                       } else {
+                               $theLabel = $data['key'];
+                       }
+                       $theLabel = t3lib_div::fixed_lgd_cs($theLabel, -$keyLgd);
+                       $theLabel = $data['stackPointer'] ? '<span class="stackPointer">' . $theLabel . '</span>' : $theLabel;
+                       $keyLabel = $theLabel . $keyLabel;
+                       $item .= '<td class="' . $logRowClass . '" style="padding-left:2px;">' . ($flag_tree ? $data['icons'] : '') . $this->fw($keyLabel) . '</td>';
 
                                // key value:
-                       $keyValue=$data['value'];
-                       $item.='<td valign="top" nowrap="nowrap"'.$bgColor.'>'.$this->fw(htmlspecialchars($keyValue)).'</td>';
-
-                       if ($this->printConf['allTime'])    {
-                                       // deltatime:
-                               $item.='<td valign="top" align="right" nowrap="nowrap"'.$bgColor.'>'.$this->fw($data['starttime']).'</td>';
-                               $item.='<td valign="top" align="right" nowrap="nowrap"'.$bgColor.'>'.$this->fw($data['owntime']).'</td>';
-                               $item.='<td valign="top" align="right" nowrap="nowrap"'.$bgColor.'>'.$this->fw($data['subtime'] ? '+'.$data['subtime'] : '').'</td>';
-                               $item.='<td valign="top" align="right" nowrap="nowrap"'.$bgColor.'>'.$this->fw($data['subtime'] ? '='.$data['deltatime'] : '').'</td>';
+                       $keyValue = $data['value'];
+                       $item .= '<td class="' . $logRowClass . ' typo3-adminPanel-tsLogTime">' . $this->fw(htmlspecialchars($keyValue)) . '</td>';
+
+                       if ($this->printConf['allTime']) {
+                               $item .= '<td class="' . $logRowClass . ' typo3-adminPanel-tsLogTime"> ' . $this->fw($data['starttime']) . '</td>';
+                               $item .= '<td class="' . $logRowClass . ' typo3-adminPanel-tsLogTime"> ' . $this->fw($data['owntime']) . '</td>';
+                               $item .= '<td class="' . $logRowClass . ' typo3-adminPanel-tsLogTime"> ' . $this->fw($data['subtime'] ? '+' . $data['subtime'] : '') . '</td>';
+                               $item .= '<td class="' . $logRowClass . ' typo3-adminPanel-tsLogTime"> ' . $this->fw($data['subtime'] ? '=' . $data['deltatime'] : '') . '</td>';
                        } else {
-                                       // deltatime:
-                               $item.='<td valign="top" align="right" nowrap="nowrap"'.$bgColor.'>'.$this->fw($data['owntime']).'</td>';
+                               $item .= '<td class="' . $logRowClass . ' typo3-adminPanel-tsLogTime"> ' . $this->fw($data['owntime']) . '</td>';
                        }
 
 
                                // messages:
-                       $msgArr=array();
-                       $msg='';
-                       if ($flag_messages && is_array($data['message']))   {
-                               reset($data['message']);
-                               while(list(,$v)=each($data['message'])) {
-                                       $msgArr[]=nl2br($v);
+                       $msgArr = array();
+                       $msg = '';
+                       if ($flag_messages && is_array($data['message'])) {
+                               foreach ($data['message'] as $v) {
+                                       $msgArr[] = nl2br($v);
                                }
                        }
-                       if ($flag_queries && is_array($data['selectQuery']))    {
-                               reset($data['selectQuery']);
-                               while(list(,$v)=each($data['selectQuery'])) {
-                                       $res = $GLOBALS['TYPO3_DB']->sql_query('EXPLAIN '.$v['query']);
-                                       $v['mysql_error'] = $GLOBALS['TYPO3_DB']->sql_error();
-                                       if (!$GLOBALS['TYPO3_DB']->sql_error()) {
-                                               while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res))   {
-                                                       $v['explain'][]=$row;
-                                               }
+                       if ($flag_queries && is_array($data['selectQuery'])) {
+                               $msgArr[] = t3lib_utility_Debug::viewArray($data['selectQuery']);
+                       }
+                       if ($flag_content && strcmp($data['content'], '')) {
+                               $maxlen = 120;
+                               if (preg_match_all('/(\S{' . $maxlen . ',})/', $data['content'], $reg)) { // Break lines which are too longer than $maxlen chars (can happen if content contains long paths...)
+                                       foreach ($reg[1] as $key => $match) {
+                                               $match = preg_replace('/(.{' . $maxlen . '})/', '$1 ', $match);
+                                               $data['content'] = str_replace($reg[0][$key], $match, $data['content']);
                                        }
-                                       $msgArr[]=t3lib_div::view_array($v);
                                }
-                       }
-                       if ($flag_content && strcmp($data['content'],''))   {
-                               $msgArr[]='<font color="#000066">'.nl2br($data['content']).'</font>';
+                               $msgArr[] = '<span style="color:#000066;">' . nl2br($data['content']) . '</span>';
                        }
                        if (count($msgArr)) {
-                               $msg=implode($msgArr,'<hr />');
+                               $msg = implode($msgArr, '<hr />');
                        }
-                       $item.='<td valign="top"'.$bgColor.'>'.$this->fw($msg).'</td>';
-                       $out.='<tr>'.$item.'</tr>';
+                       $item .= '<td valign="top" class="' . $logRowClass . '" style="text-align:left;">' . $this->fw($msg) . '</td>';
+                       $out .= '<tr>' . $item . '</tr>';
                        $c++;
                }
-               $out='<table border="0" cellpadding="0" cellspacing="0">'.$out.'</table>';
+               $out = '<table id="typo3-adminPanel-tsLog">' . $out . '</table>';
                return $out;
        }
 
@@ -433,56 +390,53 @@ class t3lib_timeTrack {
         * @param       string          Seems to be the previous tsStackLog key
         * @return      string          Returns the $content string generated/modified. Also the $arr array is modified!
         */
-       function fixContent(&$arr, $content, $depthData='', $first=0, $vKey='') {
-               $ac=0;
-               $c=0;
+       protected function fixContent(&$arr, $content, $depthData = '', $first = 0, $vKey = '') {
+               $ac = 0;
+               $c = 0;
                        // First, find number of entries
-               reset($arr);
-               while(list($k,$v)=each($arr))   {
+               foreach ($arr as $k => $v) {
                        if (t3lib_div::testInt($k)) {
                                $ac++;
                        }
                }
                        // Traverse through entries
-               $subtime=0;
-               reset($arr);
-               while(list($k,$v)=each($arr))   {
+               $subtime = 0;
+               foreach ($arr as $k => $v) {
                        if (t3lib_div::testInt($k)) {
                                $c++;
 
-                               $deeper = is_array($arr[$k.'.']) ? 1 : 0;
+                               $deeper = is_array($arr[$k . '.']) ? 1 : 0;
                                $PM = 'join';
-                               $LN = ($ac==$c)?'blank':'line';
-                               $BTM = ($ac==$c)?'bottom':'';
-                               $PM = is_array($arr[$k.'.']) ? ($deeper ? 'minus':'plus') : 'join';
-                               $this->tsStackLog[$v]['icons']=$depthData.($first?'':'<img src="t3lib/gfx/ol/'.$PM.$BTM.'.gif" width="18" height="16" align="top" border="0" alt="" />');
+                               $LN = ($ac == $c) ? 'blank' : 'line';
+                               $BTM = ($ac == $c) ? 'bottom' : '';
+                               $PM = is_array($arr[$k . '.']) ? ($deeper ? 'minus' : 'plus') : 'join';
+                               $this->tsStackLog[$v]['icons'] = $depthData . ($first ? '' : '<img src="' . TYPO3_mainDir . 'gfx/ol/' . $PM . $BTM . '.gif" width="18" height="16" align="top" border="0" alt="" />');
 
-                               if (strlen($this->tsStackLog[$v]['content']))   {
-                                       $content = str_replace($this->tsStackLog[$v]['content'],$v, $content);
+                               if (strlen($this->tsStackLog[$v]['content'])) {
+                                       $content = str_replace($this->tsStackLog[$v]['content'], $v, $content);
                                }
-                               if (is_array($arr[$k.'.'])) {
-                                       $this->tsStackLog[$v]['content'] = $this->fixContent($arr[$k.'.'], $this->tsStackLog[$v]['content'], $depthData.($first?'':'<img src="t3lib/gfx/ol/'.$LN.'.gif" width="18" height="16" align="top" border="0" alt="" />'), 0, $v);
+                               if (is_array($arr[$k . '.'])) {
+                                       $this->tsStackLog[$v]['content'] = $this->fixContent($arr[$k . '.'], $this->tsStackLog[$v]['content'], $depthData . ($first ? '' : '<img src="' . TYPO3_mainDir . 'gfx/ol/' . $LN . '.gif" width="18" height="16" align="top" border="0" alt="" />'), 0, $v);
                                } else {
                                        $this->tsStackLog[$v]['content'] = $this->fixCLen($this->tsStackLog[$v]['content'], $this->tsStackLog[$v]['value']);
-                                       $this->tsStackLog[$v]['subtime']='';
-                                       $this->tsStackLog[$v]['owntime']=$this->tsStackLog[$v]['deltatime'];
+                                       $this->tsStackLog[$v]['subtime'] = '';
+                                       $this->tsStackLog[$v]['owntime'] = $this->tsStackLog[$v]['deltatime'];
                                }
-                               $subtime+=$this->tsStackLog[$v]['deltatime'];
+                               $subtime += $this->tsStackLog[$v]['deltatime'];
                        }
                }
                        // Set content with special chars
-               if (isset($this->tsStackLog[$vKey]))    {
-                       $this->tsStackLog[$vKey]['subtime']=$subtime;
-                       $this->tsStackLog[$vKey]['owntime']=$this->tsStackLog[$vKey]['deltatime']-$subtime;
+               if (isset($this->tsStackLog[$vKey])) {
+                       $this->tsStackLog[$vKey]['subtime'] = $subtime;
+                       $this->tsStackLog[$vKey]['owntime'] = $this->tsStackLog[$vKey]['deltatime'] - $subtime;
                }
-               $content=$this->fixCLen($content, $this->tsStackLog[$vKey]['value']);
+               $content = $this->fixCLen($content, $this->tsStackLog[$vKey]['value']);
 
                        // Traverse array again, this time substitute the unique hash with the red key
-               reset($arr);
-               while(list($k,$v)=each($arr))   {
+               foreach ($arr as $k => $v) {
                        if (t3lib_div::testInt($k)) {
-                               if (strlen($this->tsStackLog[$v]['content']))   {
-                                       $content = str_replace($v, '<font color="red"><b>['.$this->tsStackLog[$v]['key'].']</b></font>', $content);
+                               if (strlen($this->tsStackLog[$v]['content'])) {
+                                       $content = str_replace($v, '<strong style="color:red;">[' . $this->tsStackLog[$v]['key'] . ']</strong>', $content);
                                }
                        }
                }
@@ -491,30 +445,30 @@ class t3lib_timeTrack {
        }
 
        /**
-        * Wraps the input content string in green colored font-tags IF the length o fthe input string exceeds $this->printConf['contentLength'] (or $this->printConf['contentLength_FILE'] if $v == "FILE"
+        * Wraps the input content string in green colored span-tags IF the length o fthe input string exceeds $this->printConf['contentLength'] (or $this->printConf['contentLength_FILE'] if $v == "FILE"
         *
         * @param       string          The content string
         * @param       string          Command: If "FILE" then $this->printConf['contentLength_FILE'] is used for content length comparison, otherwise $this->printConf['contentLength']
         * @return      string
         */
-       function fixCLen($c,$v) {
-               $len = $v=='FILE'?$this->printConf['contentLength_FILE']:$this->printConf['contentLength'];
-               if (strlen($c)>$len)    {
-                       $c='<font color="green">'.htmlspecialchars(t3lib_div::fixed_lgd($c,$len)).'</font>';
+       protected function fixCLen($c, $v) {
+               $len = $v == 'FILE' ? $this->printConf['contentLength_FILE'] : $this->printConf['contentLength'];
+               if (strlen($c) > $len) {
+                       $c = '<span style="color:green;">' . htmlspecialchars(t3lib_div::fixed_lgd_cs($c, $len)) . '</span>';
                } else {
-                       $c=htmlspecialchars($c);
+                       $c = htmlspecialchars($c);
                }
                return $c;
        }
 
        /**
-        * Wraps input string in a <font> tag with verdana, black and size 1
+        * Wraps input string in a <span> tag with black verdana font
         *
         * @param       string          The string to be wrapped
         * @return      string
         */
-       function fw($str)   {
-               return '<font face="verdana" color="black" size="1" style="color:black;">'.$str.'&nbsp;</font>';
+       protected function fw($str) {
+               return '<span style="font-family:Verdana,Arial,Helvetica,sans-serif; font-size:10px; color:black; vertical-align:top;">' . $str . '&nbsp;</span>';
        }
 
        /**
@@ -527,12 +481,14 @@ class t3lib_timeTrack {
         * @access private
         * @see printTSlog()
         */
-       function createHierarchyArray(&$arr,$pointer,$uniqueId) {
-               if (!is_array($arr))    $arr=array();
-               if ($pointer>0) {
+       protected function createHierarchyArray(&$arr, $pointer, $uniqueId) {
+               if (!is_array($arr)) {
+                       $arr = array();
+               }
+               if ($pointer > 0) {
                        end($arr);
-                       $k=key($arr);
-                       $this->createHierarchyArray($arr[intval($k).'.'],$pointer-1,$uniqueId);
+                       $k = key($arr);
+                       $this->createHierarchyArray($arr[intval($k) . '.'], $pointer - 1, $uniqueId);
                } else {
                        $arr[] = $uniqueId;
                }
@@ -546,41 +502,36 @@ class t3lib_timeTrack {
         * @param       boolean         If set, then this will produce a alert() line for inclusion in JavaScript.
         * @param       string          URL for the <base> tag (if you want it)
         * @return      string
+        * @deprecated since TYPO3 4.5, will be removed in TYPO3 4.7 - use RuntimeException from now on
         */
-       function debug_typo3PrintError($header,$text,$js,$baseUrl='')   {
-               if ($js)    {
-                       echo"alert('".t3lib_div::slashJS($header."\n".$text)."');";
+       public function debug_typo3PrintError($header, $text, $js, $baseUrl = '') {
+               if ($js) {
+                       $errorMessage = 'alert(\'' . t3lib_div::slashJS($header . '\n' . $text) . '\');';
                } else {
-                       echo '
-                               <html>
-                                       <head>
-                                               '.($baseUrl ? '<base href="'.htmlspecialchars($baseUrl).'" />' : '').'
-                                               <title>Error!</title>
-                                       </head>
-                                       <body bgcolor="white">
-                                               <div align="center">
-                                                       <table border="0" cellspacing="0" cellpadding="0" width="333" bgcolor="#ffffff">
-                                                               <tr>
-                                                                       <td><img src="t3lib/gfx/typo3logo.gif" width="333" height="43" vspace="10" border="0" alt="" /></td>
-                                                               </tr>
-                                                               <tr>
-                                                                       <td bgcolor="black">
-                                                                               <table width="100%" border="0" cellspacing="1" cellpadding="10">
-                                                                                       <tr>
-                                                                                               <td bgcolor="#F4F0E8">
-                                                                                                       <font face="verdana,arial,helvetica" size="2">';
-                       echo '<b><center><font size="+1">'.$header.'</font></center></b><br />'.$text;
-                       echo '                                  </font>
-                                                                                               </td>
-                                                                                       </tr>
-                                                                               </table>
-                                                                       </td>
-                                                               </tr>
-                                                       </table>
-                                               </div>
-                                       </body>
-                               </html>';
+                       t3lib_div::logDeprecatedFunction();
+                       $messageObj = t3lib_div::makeInstance('t3lib_message_ErrorPageMessage', $text, $header);
+                       $errorMessage = $messageObj->render();
+               }
+
+                       // Hook to modify error message
+               if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_timetrack.php']['debug_typo3PrintError'])) {
+                       $params = array(
+                               'header' => $header,
+                               'text' => $text,
+                               'js' => $js,
+                               'baseUrl' => $baseUrl,
+                               'errorMessage' => &$errorMessage
+                       );
+                       $null = NULL;
+                       foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_timetrack.php']['debug_typo3PrintError'] as $hookMethod) {
+                               t3lib_div::callUserFunction($hookMethod, $params, $null);
+                       }
                }
+
+               echo $errorMessage;
        }
 }
+
+// XCLASSing is not possible for this class
+
 ?>
\ No newline at end of file