* Added some file icons from Ben and Emile
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_timetrack.php
index 0c71e62..8031615 100755 (executable)
@@ -2,7 +2,7 @@
 /***************************************************************
 *  Copyright notice
 *  
-*  (c) 1999-2003 Kasper Skårhøj (kasper@typo3.com)
+*  (c) 1999-2004 Kasper Skaarhoj (kasper@typo3.com)
 *  All rights reserved
 *
 *  This script is part of the TYPO3 project. The TYPO3 project is 
 /**
  * Contains class with time tracking functions
  *
- * Revised for TYPO3 3.6 July/2003 by Kasper Skårhøj
+ * $Id$
+ * Revised for TYPO3 3.6 July/2003 by Kasper Skaarhoj
  * XHTML compliant
+ *
+ * @author     Kasper Skaarhoj <kasper@typo3.com>
  */
 /**
  * [CLASS/FUNCTION INDEX of SCRIPT]
  *
  *
  *
- *   85: class t3lib_timeTrack 
+ *   88: class t3lib_timeTrack 
  *
  *              SECTION: Logging parsing times in the scripts
- *  141:     function start()  
- *  154:     function push($tslabel, $value='')        
- *  179:     function pull($content='')        
- *  197:     function setTSlogMessage($content,$num=0) 
- *  212:     function setTSselectQuery($query,$msg)    
- *  225:     function incStackPointer()        
- *  236:     function decStackPointer()        
- *  246:     function mtime()  
- *  256:     function convertMicrotime($microtime)     
+ *  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)
- *  289:     function printTSlog()     
- *  434:     function fixContent(&$arr, $content, $depthData='', $first=0, $vKey='')   
- *  498:     function fixCLen($c,$v)   
- *  514:     function fw($str) 
- *  528:     function createHierarchyArray(&$arr,$pointer,$uniqueId)   
- *  547:     function debug_typo3PrintError($header,$text,$js) 
+ *  291:     function printTSlog()     
+ *  435:     function fixContent(&$arr, $content, $depthData='', $first=0, $vKey='')   
+ *  499:     function fixCLen($c,$v)   
+ *  515:     function fw($str) 
+ *  529:     function createHierarchyArray(&$arr,$pointer,$uniqueId)   
+ *  548:     function debug_typo3PrintError($header,$text,$js) 
  *
  * TOTAL FUNCTIONS: 15
  * (This index is automatically created/updated by the extension "extdeveval")
 
 /**
  * Frontend Timetracking functions
- * 
+ *
  * Is used to register how much time is used with operations in TypoScript
  * Used by index_ts
- * 
- * @author     Kasper Skårhøj <kasper@typo3.com>
+ *
+ * @author     Kasper Skaarhoj <kasper@typo3.com>
  * @package TYPO3
  * @subpackage t3lib
  * @see t3lib_tsfeBeUserAuth, tslib_fe, tslib_cObj, TSpagegen
@@ -135,8 +138,8 @@ class t3lib_timeTrack {
        /**
         * Constructor
         * Sets the starting time
-        * 
-        * @return      void            
+        *
+        * @return      void
         */
        function start()        {
                $this->starttime=0;
@@ -145,10 +148,10 @@ class t3lib_timeTrack {
 
        /**
         * Pushes an element to the TypoScript tracking array
-        * 
+        *
         * @param       string          Label string for the entry, eg. TypoScript property name
         * @param       string          Additional value(?)
-        * @return      void            
+        * @return      void
         * @see tslib_cObj::cObjGetSingle(), pull()
         */
        function push($tslabel, $value='')      {
@@ -171,9 +174,9 @@ class t3lib_timeTrack {
 
        /**
         * Pulls an element from the TypoScript tracking array
-        * 
+        *
         * @param       string          The content string generated within the push/pull part.
-        * @return      void            
+        * @return      void
         * @see tslib_cObj::cObjGetSingle(), push()
         */
        function pull($content='')      {
@@ -188,26 +191,25 @@ class t3lib_timeTrack {
        
        /**
         * Logs the TypoScript entry
-        * 
+        *
         * @param       string          The message string
         * @param       integer         Message type: 0: information, 1: message, 2: warning, 3: error
-        * @return      void            
+        * @return      void
         * @see tslib_cObj::CONTENT()
         */
        function setTSlogMessage($content,$num=0)       {
                end($this->currentHashPointer);
                $k = current($this->currentHashPointer);
 
-               $this->tsStackLog[$k]['message'][] = $this->wrapIcon[$num].$this->wrapError[$num][0].$content.$this->wrapError[$num][1];
+               $this->tsStackLog[$k]['message'][] = $this->wrapIcon[$num].$this->wrapError[$num][0].htmlspecialchars($content).$this->wrapError[$num][1];
        }
 
        /**
-        * Set TSselectQuery.
-        * Apparently not used anywhere?
-        * 
-        * @param       string          Query
-        * @param       string          Message
-        * @return      void            
+        * Set TSselectQuery - for messages in TypoScript debugger.
+        *
+        * @param       string          Query string
+        * @param       string          Message/Label to attach
+        * @return      void
         */
        function setTSselectQuery($query,$msg)  {
                end($this->currentHashPointer);
@@ -218,8 +220,8 @@ class t3lib_timeTrack {
 
        /**
         * Increases the stack pointer
-        * 
-        * @return      void            
+        *
+        * @return      void
         * @see decStackPointer(), TSpagegen::renderContent(), tslib_cObj::cObjGetSingle()
         */
        function incStackPointer()      {
@@ -229,8 +231,8 @@ class t3lib_timeTrack {
         
        /**
         * Decreases the stack pointer
-        * 
-        * @return      void            
+        *
+        * @return      void
         * @see incStackPointer(), TSpagegen::renderContent(), tslib_cObj::cObjGetSingle()
         */
        function decStackPointer()      {
@@ -240,8 +242,8 @@ class t3lib_timeTrack {
 
        /**
         * Returns the current time in milliseconds
-        * 
-        * @return      integer         
+        *
+        * @return      integer
         */
        function mtime()        {
                return $this->convertMicrotime(microtime())-$this->starttime;
@@ -249,9 +251,9 @@ class t3lib_timeTrack {
 
        /**
         * Returns microtime input to milliseconds
-        * 
+        *
         * @param       string          PHP microtime string
-        * @return      integer         
+        * @return      integer
         */
        function convertMicrotime($microtime)   {
                $parts = explode(' ',$microtime);
@@ -281,8 +283,8 @@ class t3lib_timeTrack {
         *******************************************/
 
        /**
-        * Print TSlog
-        * 
+        * Print TypoScript parsing log
+        *
         * @return      string          HTML table with the information about parsing times.
         * @see t3lib_tsfeBeUserAuth::extGetCategory_tsdebug()
         */
@@ -391,16 +393,15 @@ class t3lib_timeTrack {
                        if ($flag_messages && is_array($data['message']))       {
                                reset($data['message']);
                                while(list(,$v)=each($data['message'])) {
-                                       $msgArr[]=nl2br(htmlspecialchars($v));
+                                       $msgArr[]=nl2br($v);
                                }
                        }
                        if ($flag_queries && is_array($data['selectQuery']))    {
                                reset($data['selectQuery']);
                                while(list(,$v)=each($data['selectQuery']))     {
-                                       $res = mysql(TYPO3_db,'EXPLAIN '.$v['query']);
-                                       $v['mysql_error']=mysql_error();
-                                       if (!mysql_error())     {
-                                               while($row=mysql_fetch_assoc($res))     {
+                                       $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;
                                                }
                                        }
@@ -423,7 +424,7 @@ class t3lib_timeTrack {
 
        /**
         * Recursively generates the content to display
-        * 
+        *
         * @param       array           Array which is modified with content. Reference
         * @param       string          Current content string for the level
         * @param       string          Prefixed icons for new PM icons
@@ -490,10 +491,10 @@ 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"
-        * 
+        *
         * @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          
+        * @return      string
         */
        function fixCLen($c,$v) {
                $len = $v=='FILE'?$this->printConf['contentLength_FILE']:$this->printConf['contentLength'];
@@ -507,9 +508,9 @@ class t3lib_timeTrack {
        
        /**
         * Wraps input string in a <font> tag with verdana, black and size 1
-        * 
+        *
         * @param       string          The string to be wrapped
-        * @return      string          
+        * @return      string
         */
        function fw($str)       {
                return '<font face="verdana" color="black" size="1" style="color:black;">'.$str.'&nbsp;</font>';
@@ -517,11 +518,11 @@ class t3lib_timeTrack {
 
        /**
         * Helper function for internal data manipulation
-        * 
+        *
         * @param       array           Array (passed by reference) and modified
-        * @param       integer         
-        * @param       string          
-        * @return      void            
+        * @param       integer         Pointer value
+        * @param       string          Unique ID string
+        * @return      void
         * @access private
         * @see printTSlog()
         */
@@ -538,11 +539,11 @@ class t3lib_timeTrack {
 
        /**
         * This prints out a TYPO3 error message.
-        * 
+        *
         * @param       string          Header string
         * @param       string          Message string
         * @param       boolean         If set, then this will produce a alert() line for inclusion in JavaScript.
-        * @return      string          
+        * @return      string
         */
        function debug_typo3PrintError($header,$text,$js)       {
                if ($js)        {
@@ -553,9 +554,9 @@ class t3lib_timeTrack {
                                        <head>
                                                <title>Error!</title>
                                        </head>
-                                       <body bgcolor="#cccccc">
+                                       <body bgcolor="white">
                                                <div align="center">
-                                                       <table border="0" cellspacing="0" cellpadding="0" width="333" bgcolor="#cccccc">
+                                                       <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>