phpDocumentor PHP_Debug
[ class tree: PHP_Debug ] [ index: PHP_Debug ] [ all elements ]

Source for file HTML_Table.php

Documentation is available at HTML_Table.php

  1. <?php
  2.  
  3. /**
  4.  * Configuration class for HTML_Table
  5.  */
  6. require_once 'Debug/Renderer/HTML_Table_Config.php';
  7.  
  8.  
  9. /**
  10.  * A concrete renderer for Debug
  11.  *
  12.  * Returns a table-based representation of the debug infos in HTML 4
  13.  *
  14.  * @package PHP_Debug
  15.  * @category PHP
  16.  * @author Loic Vernet <qrf_coil at yahoo dot fr>
  17.  * @since 10 Apr 2006
  18.  * 
  19.  * @package PHP_Debug
  20.  * @filesource
  21.  */
  22.  
  23. {    
  24.     /**
  25.      * Debug_Renderer_HTML_Table class constructor
  26.      * 
  27.      * @since V2.0.0 - 13 apr 2006
  28.      */
  29.     function __construct($DebugObject, $options)
  30.     {
  31.         $this->DebugObject = $DebugObject;
  32.         $this->defaultOptions = Debug_Renderer_HTML_Table_Config::singleton()->getConfig();
  33.         $this->setOptions($options);
  34.         
  35.         //Debug::dumpVar($this->options, "Debug_Renderer_HTML_Table::options");
  36.  
  37.         // Now add in first the predefined debugline depending on the configuration
  38.         if ($this->options['HTML_TABLE_enable_search'] == true)
  39.             $this->DebugObject->addDebugFirst(STR_N, PHP_DEBUGLINE_SEARCH);
  40.  
  41.         if ($this->options['HTML_TABLE_disable_credits'] == false)
  42.             $this->DebugObject->addDebugFirst($this->options['HTML_TABLE_credits'], PHP_DEBUGLINE_CREDITS);
  43.  
  44.         // Now add in last positions the others predefined debuglines
  45.  
  46.         // Add execution time 
  47.         $this->DebugObject->addDebug(STR_N, PHP_DEBUGLINE_PROCESSPERF);
  48.         
  49.         // Add templates 
  50.         if ($this->options['HTML_TABLE_show_templates'] == true)
  51.             $this->DebugObject->addDebug(STR_N, PHP_DEBUGLINE_TEMPLATES);
  52.             
  53.         // Add env variables
  54.         $this->addSuperArray();
  55.  
  56.     }
  57.  
  58.     /**
  59.      * This is the function to display the debug information
  60.      *
  61.      * @since V2.0.0 - 07 Apr 2006
  62.      * @see Debug::Render()
  63.      */
  64.     public function display()
  65.     {
  66.         $buffer = '';
  67.            
  68.         // Header        
  69.         $buffer .= $this->displayHeader();
  70.            
  71.         // Body     
  72.         foreach ($this->DebugObject->getDebugBuffer() as $lvalue) {
  73.  
  74.             // Check if the debug must be displayed
  75.             if ($this->checkType($lvalue) == true) {
  76.  
  77.                 $tmpBuff = $this->displayDebugLine($lvalue);
  78.  
  79.                 // Check if we have a search criteria
  80.                 if ($this->checkSearch($tmpBuff)) {
  81.                 
  82.                     // Pre-row
  83.                     $buffer .= $this->options['HTML_TABLE_prerow'];
  84.  
  85.                     // Row body
  86.                     $buffer .= $this->highlight($tmpBuff);
  87.     
  88.                     // Post-row
  89.                     $buffer .= $this->options['HTML_TABLE_postrow'];
  90.                 
  91.                 }
  92.             }
  93.         }
  94.  
  95.         // Footer
  96.         $buffer .= $this->displayFooter();
  97.         
  98.         // Output Buffer
  99.         print($buffer);        
  100.     }
  101.  
  102.     /**
  103.      * This function highligth the searched keyword
  104.      *
  105.      * @param string $debugLineStr The formatted debug line object to check
  106.      * @return string Formatted string with keyword highligthed
  107.      * 
  108.      * @todo nice ereg replace call to avoid HTML & attribue breaking
  109.      * @since V2.0.0 - 2 May 2006
  110.      */
  111.     protected function highlight($debugLineStr)
  112.     {   
  113.         // Check if search is activated   
  114.         if (!empty($_GET['PHPDEBUG_SEARCH']) and trim($_GET['PHPDEBUG_SEARCH']) != '') {
  115.             if (!empty($_GET['PHPDEBUG_SEARCH_CS'])) {
  116.                 $replaceFunction = 'str_replace';
  117.             } else {
  118.                 $replaceFunction = 'str_ireplace';
  119.             }
  120.             return $replaceFunction($_GET['PHPDEBUG_SEARCH'], '<span class="pd-search-hl">'. $_GET['PHPDEBUG_SEARCH']. '</span>' , $debugLineStr);        
  121.         } else {
  122.             return $debugLineStr;
  123.         }
  124.     }
  125.  
  126.     /**
  127.      * This function check if the user has chosen a search criteria and
  128.      * make the search on the formatted debug info
  129.      *
  130.      * @param string $debugLineStr The formatted debug line object to check
  131.      * @return boolean Search criteria has been found of search is disabled
  132.      * 
  133.      * @since V2.0.0 - 2 May 2006
  134.      */
  135.     protected function checkSearch($debugLineStr)
  136.     {        
  137.         // Check if search is activated   
  138.         if (!empty($_GET['PHPDEBUG_SEARCH']) and trim($_GET['PHPDEBUG_SEARCH']) != '') {
  139.            
  140.             if (!empty($_GET['PHPDEBUG_SEARCH_CS'])) {
  141.                 $searchFunction = 'strstr';
  142.             } else {
  143.                 $searchFunction = 'stristr';
  144.             }
  145.             return $searchFunction($debugLineStr, trim($_GET['PHPDEBUG_SEARCH']));
  146.         } else {
  147.             return true;
  148.         }
  149.     }
  150.  
  151.     /**
  152.      * This function check if the user has chosen a filter in the debug type
  153.      * combobox and it returns of the debug line is allowed to be output or no
  154.      *
  155.      * @param Debug_Line $debugLine The debug line object to check
  156.      * @return boolean true type is allowed to be
  157.      * 
  158.      * @since V2.0.0 - 26 Apr 2006
  159.      */
  160.     protected function checkType($debugLine)
  161.     {
  162.         $properties = $debugLine->getProperties(); 
  163.         
  164.         // Check if we must only show debug information of a kind    
  165.           if ($this->options['HTML_TABLE_search_forced_type'][$properties['type']] == false) {
  166.             if (!empty($_GET['PHPDEBUG_SEARCH_TYPE'])) {
  167.                 if ($properties['type'] == $_GET['PHPDEBUG_SEARCH_TYPE']) {                    
  168.                     return true;
  169.                 } else {
  170.                     return false;
  171.                 }
  172.             } else {
  173.                 return true;
  174.             }
  175.         } else {
  176.             return true;
  177.         }
  178.     }
  179.  
  180.     /**
  181.      * Default render function for HTML_Table renderer
  182.      *
  183.      * @since 11 Apr 2006
  184.      * @see Renderer
  185.      */
  186.     public function render()
  187.     {
  188.         $this->display();
  189.     }
  190.  
  191.     /**
  192.      * Displays the header of the PHP_Debug object
  193.      *
  194.      * @since 08 Apr 2006
  195.      * @see PHP_Debug
  196.      */
  197.     protected function displayHeader()
  198.     {
  199.         return $this->options['HTML_TABLE_header'];
  200.     }        
  201.  
  202.     /**
  203.      * Diplays the footer of the PHP_Debug object
  204.      *
  205.      * @since 08 Apr 2006
  206.      * @see PHP_Debug
  207.      */
  208.     protected function displayFooter()
  209.     {
  210.         return $this->options['HTML_TABLE_footer'];
  211.     }        
  212.     
  213.     /**
  214.      * This is the function that displays a debug line, each step correspond
  215.      * to a new cell, actully there are 6 types :
  216.      * - File
  217.      * - Line
  218.      * - Function
  219.      * - Class
  220.      * - Debug main information
  221.      * - Execution time
  222.      * 
  223.      * @param Debug_Line DebugLine, the debug line to process
  224.      *
  225.      * @since V2.0.0 - 07 Apr 2006
  226.      */    
  227.     protected function displayDebugLine($DebugLine)    
  228.     {
  229.          // Debug_Line properties
  230.         $properties = $DebugLine->getProperties();
  231.  
  232.         // 1 - File
  233.         $buffer = $this->processFile($properties);
  234.         
  235.         // 2 - Line
  236.         $buffer .= $this->processLine($properties);
  237.  
  238.         // 3 - Function
  239.         $buffer .= $this->processFunction($properties);
  240.                 
  241.         // 4 - Class
  242.         $buffer .= $this->processClass($properties);
  243.  
  244.         // 5 - Type
  245.         $buffer .= $this->processType($properties);
  246.  
  247.         // 6 - Debug info
  248.         $buffer .= $this->processDebugInfo($properties);
  249.                         
  250.         // 7 - Execution time
  251.         $buffer .= $this->processExecTime($properties);
  252.  
  253.         // Output display buffer
  254.         return $buffer;        
  255.         
  256.     }
  257.  
  258.     /**
  259.      * process display of the execution time of debug information
  260.      * 
  261.      * @param array $properties Properties of the debug line
  262.      * @return string Formatted string containing the main debug info
  263.      * @since V2.0.0 - 28 Apr 2006
  264.      */ 
  265.     private function processExecTime($properties)
  266.     {   
  267.         // Lang
  268.         $txtPHP = 'PHP';
  269.         $txtSQL = 'SQL';
  270.         $txtSECOND = 's';
  271.  
  272.         $buffer = $this->options['HTML_TABLE_interrow_time'];
  273.         
  274.         if (!empty($properties['endTime'])) {
  275.             $buffer .=  $this->span(Debug::getElapsedTime($properties['startTime'], $properties['endTime']), 'time');
  276.         } else {
  277.             $buffer .= '&nbsp;';
  278.         }
  279.  
  280.         return $buffer; 
  281.     }
  282.     
  283.     /**
  284.      * process display of the main information of debug
  285.      * 
  286.      * @param array $properties Properties of the debug line
  287.      * @return string Formatted string containing the main debug info
  288.      * @since V2.0.0 - 28 Apr 2006
  289.      */ 
  290.     private function processDebugInfo($properties)
  291.     {   
  292.         
  293.         switch($properties['type'])
  294.         {
  295.             // Case for each of the debug lines types
  296.             // 1 : Standard
  297.             case PHP_DEBUGLINE_STD:
  298.                 $buffer = $this->options['HTML_TABLE_interrow_info'];
  299.                 $buffer .= $this->span($properties['info'], 'std');
  300.                 break;
  301.             
  302.             // 2 : Query
  303.             case PHP_DEBUGLINE_QUERY:
  304.                 $buffer = $this->options['HTML_TABLE_interrow_info'];
  305.                 $buffer .= $this->span($properties['info'], 'query');
  306.                 break;
  307.  
  308.             // 3 : Query related
  309.             case PHP_DEBUGLINE_QUERYREL:
  310.                 $buffer = $this->options['HTML_TABLE_interrow_info'];
  311.                 $buffer .= $this->span($properties['info'], 'query');
  312.                 break;
  313.                 
  314.             // 4 : Environment
  315.             case PHP_DEBUGLINE_ENV:
  316.                 $buffer = $this->options['HTML_TABLE_interrow_info'];
  317.                 $buffer .= $this->showSuperArray($properties['info']);
  318.                 break;
  319.  
  320.             // 6 : User app error
  321.             case PHP_DEBUGLINE_APPERROR:
  322.                 $buffer = $this->options['HTML_TABLE_interrow_info'];
  323.                 $buffer .= $this->span('/!\\ User error : '. $properties['info'] . ' /!\\', 'app-error');
  324.                 break;
  325.                 
  326.             // 7
  327.             case PHP_DEBUGLINE_CREDITS:
  328.                 $buffer = $this->options['HTML_TABLE_interrow_info'];
  329.                 $buffer .= $this->span($properties['info'], 'credits');            
  330.                 break;
  331.  
  332.             // 8
  333.             case PHP_DEBUGLINE_SEARCH:
  334.                 $buffer = $this->options['HTML_TABLE_interrow_info'];
  335.                 $buffer .= $this->showSearch();
  336.                 break;
  337.  
  338.             // 9
  339.             case PHP_DEBUGLINE_DUMP:
  340.                 $buffer = $this->options['HTML_TABLE_interrow_info'];
  341.                 $buffer .= $this->showDump($properties);
  342.                 break;
  343.  
  344.             // 10
  345.             case PHP_DEBUGLINE_PROCESSPERF:
  346.                 $buffer = $this->options['HTML_TABLE_interrow_file'];
  347.                 $buffer .= $this->showProcessTime();
  348.                 break;
  349.  
  350.             // 11
  351.             case PHP_DEBUGLINE_TEMPLATES:
  352.                 $buffer = $this->options['HTML_TABLE_interrow_info'];
  353.                 $buffer .= $this->showTemplates();
  354.                 break;
  355.  
  356.             // 12 : Main Page Action
  357.             case PHP_DEBUGLINE_PAGEACTION;
  358.                 $buffer = $this->options['HTML_TABLE_interrow_file'];
  359.                 $txtPageAction = 'Page Action';
  360.                 $buffer .= $this->span("[ $txtPageAction : ". $properties['info']. ' ]', 'pageaction');
  361.                 break;
  362.  
  363.             // 14 : SQL parse 
  364.             case PHP_DEBUGLINE_SQLPARSE:
  365.                 $buffer = $this->options['HTML_TABLE_interrow_info'];
  366.                 $buffer .= $properties['info'];
  367.                 break;
  368.  
  369.             // 15 : Watches
  370.             case PHP_DEBUGLINE_WATCH:
  371.                 $buffer = $this->options['HTML_TABLE_interrow_info'];
  372.                 $infos = $properties['info'];
  373.                 $buffer .= 'Variable '. $this->span($infos[0], 'watch').
  374.                            ' changed from value '. $this->span($infos[1], 'watch-val'). ' ('. gettype($infos[1]). 
  375.                                     ') to value '. $this->span($infos[2], 'watch-val'). ' ('. gettype($infos[2]). ')';
  376.                 break;
  377.  
  378.             // 16 : PHP errors
  379.             case PHP_DEBUGLINE_PHPERROR:                
  380.                 $buffer = $this->options['HTML_TABLE_interrow_info'];
  381.                 $buffer .= $this->showError($properties['info']);
  382.                 break;
  383.  
  384.             default:
  385.                 $buffer = $this->options['HTML_TABLE_interrow_info'];
  386.                 $buffer .= "<b>Default(". $properties['type'].  
  387.                            ")</b>: TO IMPLEMENT OR TO CORRECT : >". 
  388.                            $properties['info']. '<';            
  389.                 break;
  390.         }
  391.  
  392.         return $buffer;
  393.     }
  394.  
  395.     /**
  396.      * Return a string with applying a span style on it
  397.      * 
  398.      * @param string $info String to apply the style
  399.      * @param string $class CSS style to apply to the string
  400.      * @return string Formatted string with style applied
  401.      * @since V2.0.0 - 05 May 2006
  402.      */ 
  403.     private function span($info, $class)
  404.     {   
  405.         return '<span class="pd-'. $class .'">'. $info .'</span>'; 
  406.     }
  407.  
  408.     /**
  409.      * process display of the type of the debug information
  410.      * 
  411.      * @param array $properties Properties of the debug line
  412.      * @return string Formatted string containing the debug type
  413.      * @since V2.0.0 - 26 Apr 2006
  414.      */ 
  415.     private function processType($properties)
  416.     {   
  417.         $buffer = $this->options['HTML_TABLE_interrow_type'];
  418.         $buffer .= Debug_Line::$debugLineLabels[$properties['type']];
  419.         return $buffer;
  420.     }
  421.  
  422.     /**
  423.      * process display of Class
  424.      * 
  425.      * @param array $properties Properties of the debug line
  426.      * @return string Formatted string containing the class
  427.      * @since V2.0.0 - 26 Apr 2006
  428.      */ 
  429.     private function processClass($properties)
  430.     {
  431.         $buffer = '';
  432.  
  433.         switch ($properties['type'])
  434.         {
  435.             case PHP_DEBUGLINE_STD:
  436.             case PHP_DEBUGLINE_QUERY:
  437.             case PHP_DEBUGLINE_QUERYREL:
  438.             case PHP_DEBUGLINE_APPERROR:             
  439.             case PHP_DEBUGLINE_PAGEACTION:
  440.             case PHP_DEBUGLINE_PHPERROR:
  441.             case PHP_DEBUGLINE_SQLPARSE:
  442.             case PHP_DEBUGLINE_WATCH:
  443.             case PHP_DEBUGLINE_DUMP:
  444.                         
  445.                 $buffer .= $this->options['HTML_TABLE_interrow_class'];
  446.                 if (!empty($properties['class'])) {
  447.                     $buffer .= $properties['class'];
  448.                 } else {
  449.                     $buffer .= '&nbsp;';
  450.                 }
  451.  
  452.                 break;
  453.                         
  454.             case PHP_DEBUGLINE_CREDITS: 
  455.             case PHP_DEBUGLINE_SEARCH:
  456.             case PHP_DEBUGLINE_PROCESSPERF:
  457.             case PHP_DEBUGLINE_TEMPLATES:
  458.             case PHP_DEBUGLINE_ENV:
  459.  
  460.                 $buffer .= $this->options['HTML_TABLE_interrow_class'];
  461.                 $buffer .= '&nbsp;';
  462.  
  463.                 break;
  464.         
  465.             default:
  466.                 break;
  467.         }
  468.         
  469.         return $buffer;
  470.     }
  471.  
  472.     /**
  473.      * process display of function
  474.      * 
  475.      * @param array $properties Properties of the debug line
  476.      * @return string Formatted string containing the function
  477.      * @since V2.0.0 - 26 Apr 2006
  478.      */ 
  479.     private function processFunction($properties)
  480.     {
  481.         $buffer = '';
  482.  
  483.         switch ($properties['type'])
  484.         {
  485.             case PHP_DEBUGLINE_STD:
  486.             case PHP_DEBUGLINE_QUERY:
  487.             case PHP_DEBUGLINE_QUERYREL:
  488.             case PHP_DEBUGLINE_APPERROR:             
  489.             case PHP_DEBUGLINE_PAGEACTION:
  490.             case PHP_DEBUGLINE_PHPERROR:
  491.             case PHP_DEBUGLINE_SQLPARSE:
  492.             case PHP_DEBUGLINE_WATCH:
  493.             case PHP_DEBUGLINE_DUMP:
  494.                         
  495.                 $buffer .= $this->options['HTML_TABLE_interrow_function'];
  496.                 if (!empty($properties['function'])) {                    
  497.                     if ($properties['function'] != 'unknown') { 
  498.                         $buffer .= $properties['function']. '()';
  499.                     } else {
  500.                         $buffer .= '&nbsp;';
  501.                 }
  502.                 } else {
  503.                     $buffer .= '&nbsp;';
  504.                 }
  505.  
  506.                 break;
  507.                         
  508.             case PHP_DEBUGLINE_CREDITS: 
  509.             case PHP_DEBUGLINE_SEARCH:
  510.             case PHP_DEBUGLINE_PROCESSPERF:
  511.             case PHP_DEBUGLINE_TEMPLATES:
  512.             case PHP_DEBUGLINE_ENV:
  513.  
  514.                 $buffer .= $this->options['HTML_TABLE_interrow_function'];
  515.                 $buffer .= '&nbsp;';
  516.  
  517.                 break;
  518.         
  519.             default:
  520.                 break;
  521.         }
  522.         
  523.         return $buffer;
  524.     }
  525.  
  526.  
  527.     /**
  528.      * process display of line number
  529.      * 
  530.      * @param array $properties Properties of the debug line
  531.      * @return string Formatted string containing the line number
  532.      * @since V2.0.0 - 26 Apr 2006
  533.      */ 
  534.     private function processLine($properties)
  535.     {
  536.         $buffer = '';
  537.  
  538.         switch ($properties['type'])
  539.         {
  540.             case PHP_DEBUGLINE_STD:
  541.             case PHP_DEBUGLINE_QUERY:
  542.             case PHP_DEBUGLINE_QUERYREL:
  543.             case PHP_DEBUGLINE_APPERROR:             
  544.             case PHP_DEBUGLINE_PAGEACTION:
  545.             case PHP_DEBUGLINE_PHPERROR:
  546.             case PHP_DEBUGLINE_SQLPARSE:
  547.             case PHP_DEBUGLINE_WATCH:
  548.             case PHP_DEBUGLINE_DUMP:
  549.                         
  550.                 $buffer.= $this->options['HTML_TABLE_interrow_line'];
  551.                 if (!empty($properties['line'])) {
  552.                     $buffer.= '<span class="pd-line">'. $properties['line']. '</span>';
  553.                 } else {
  554.                     $buffer.= '&nbsp;';
  555.                 }        
  556.  
  557.                 break;
  558.                         
  559.             case PHP_DEBUGLINE_CREDITS: 
  560.             case PHP_DEBUGLINE_SEARCH:
  561.             case PHP_DEBUGLINE_PROCESSPERF:
  562.             case PHP_DEBUGLINE_TEMPLATES:
  563.             case PHP_DEBUGLINE_ENV:
  564.  
  565.                 $buffer.= $this->options['HTML_TABLE_interrow_line'];
  566.                 $buffer.= '&nbsp;';
  567.  
  568.                 break;
  569.         
  570.             default:
  571.                 break;
  572.         }
  573.         
  574.         return $buffer;
  575.     }
  576.  
  577.     /**
  578.      * process display of file name
  579.      * 
  580.      * @param array $properties Properties of the debug line
  581.      * @return string Formatted string containing the file
  582.      * @since V2.0.0 - 26 Apr 2006
  583.      */ 
  584.     private function processFile($properties)
  585.     {
  586.         $buffer = '';
  587.  
  588.         switch ($properties['type'])
  589.         {
  590.             case PHP_DEBUGLINE_STD:
  591.             case PHP_DEBUGLINE_QUERY:
  592.             case PHP_DEBUGLINE_QUERYREL:
  593.             case PHP_DEBUGLINE_APPERROR:             
  594.             case PHP_DEBUGLINE_PAGEACTION:
  595.             case PHP_DEBUGLINE_PHPERROR:
  596.             case PHP_DEBUGLINE_SQLPARSE:
  597.             case PHP_DEBUGLINE_WATCH:
  598.             case PHP_DEBUGLINE_DUMP:
  599.  
  600.                 $buffer .= $this->options['HTML_TABLE_interrow_file'];
  601.                         
  602.                 if (!empty($properties['file'])) {
  603.                     if (!empty($this->options['HTML_TABLE_view_source_script_path']) and !empty($this->options['HTML_TABLE_view_source_script_name'])) {
  604.                         $buffer .= '<a href="'. $this->options['HTML_TABLE_view_source_script_path']
  605.                                 . '/'. $this->options['HTML_TABLE_view_source_script_name']  
  606.                                 .'?file='. $properties['file'];
  607.  
  608.                         $buffer .= '">'. basename($properties['file']). '</a>'; 
  609.  
  610.                     } else {
  611.                         $buffer .= basename($properties['file']);                        
  612.                     }
  613.                 } else {
  614.                     $buffer .=  '&nbsp;';
  615.                 }        
  616.         
  617.                 break;
  618.                         
  619.             case PHP_DEBUGLINE_CREDITS: 
  620.             case PHP_DEBUGLINE_SEARCH:
  621.             case PHP_DEBUGLINE_PROCESSPERF:
  622.             case PHP_DEBUGLINE_TEMPLATES:
  623.             case PHP_DEBUGLINE_ENV:
  624.  
  625.                 $buffer .= $this->options['HTML_TABLE_interrow_file'];
  626.                 $buffer .=  '&nbsp;';
  627.  
  628.                 break;
  629.         
  630.             default:
  631.                 break;
  632.         }
  633.         
  634.         return $buffer;
  635.     }
  636.  
  637.     /**
  638.      * Print the dump of a variable
  639.      * 
  640.      * @since V2.0.0 - 26 Apr 2006
  641.      */ 
  642.     private function showDump($properties)
  643.     {
  644.         $buffer = '';
  645.  
  646.         // Check display with a <pre> design
  647.         if (is_array($properties['info'][1])) {
  648.             $preDisplay = true;                      
  649.         } elseif (is_object($properties['info'][1])) {
  650.             $preDisplay = true;                      
  651.         } else {
  652.             $preDisplay = false;                      
  653.         }
  654.  
  655.         // Check var name
  656.         if (empty($properties['info'][0])) {
  657.             if (is_array($properties['info'][1])) {
  658.                 $varName = 'Array';
  659.             } elseif (is_object($properties['info'][1])) {
  660.                 $varName = get_class($properties['info'][1]);
  661.             } else {
  662.                 $varName = 'Variable';                              
  663.             }
  664.         } else {
  665.             $varName = $properties['info'][0];
  666.         }
  667.         
  668.         // Output
  669.         if ($properties['type'] != PHP_DEBUGLINE_ENV) { 
  670.             $title = "dump of '";
  671.         } 
  672.         
  673.         $title .= $varName. "' (".  gettype($properties['info'][1]) .") : ";
  674.         
  675.         $buffer .= $this->span($title , 'dump-title');
  676.         
  677.         if ($preDisplay == true){
  678.             $buffer .= '<pre>';                   
  679.             $buffer .= Debug::dumpVar($properties['info'][1], '', PHP_DEBUG_DUMP_STR);
  680.         } else {
  681.             $buffer .= $this->span(Debug::dumpVar($properties['info'][1], '', PHP_DEBUG_DUMP_STR), 'dump-val');
  682.         }
  683.  
  684.         if ($preDisplay == true){
  685.             $buffer .= '</pre>';                  
  686.         }
  687.  
  688.         return $buffer;
  689.     }
  690.  
  691.     /**
  692.      * Print the search combo box
  693.      * 
  694.      * @since V2.0.0 - 26 Apr 2006
  695.      */ 
  696.     private function showSearch()
  697.     {
  698.         // Repost all posted data
  699.         $txtGo             = 'Go !';
  700.         $txtStringToSearch = 'Search for';
  701.         $txtCaseSensitive  = 'Case sensitive';
  702.         $txtSelectByType   = 'Select only info of type';        
  703.         $buffer = '';
  704.         
  705.         $debugSearchVal   = isset($_REQUEST["PHPDEBUG_SEARCH"])    ? trim($_REQUEST["PHPDEBUG_SEARCH"]) : '';
  706.         $debugSearchCSVal = isset($_REQUEST["PHPDEBUG_SEARCH_CS"]) ? ' checked="checked"' : '';
  707.         
  708.         $buffer .= '
  709.         <form id="phpDebugForm" action="'. $_SERVER['PHP_SELF']. '">
  710.         <table>
  711.         <tr>
  712.           <td class="pd-search">'. $txtStringToSearch .'</td>
  713.           <td class="pd-search">:</td>
  714.           <td class="pd-search">
  715.             <input class="pd-search" type="text" name="PHPDEBUG_SEARCH" value="'. $debugSearchVal. '" />
  716.           </td>
  717.           <td class="pd-search">'. $txtCaseSensitive .'</td>
  718.           <td class="pd-search">:</td>
  719.           <td class="pd-search">
  720.             <input class="pd-search" type="checkbox" name="PHPDEBUG_SEARCH_CS" '. $debugSearchCSVal .' />
  721.           </td>
  722.         </tr>
  723.         <tr>
  724.           <td class="pd-search">'. $txtSelectByType. '</td>
  725.           <td class="pd-search">:</td>
  726.           <td class="pd-search">
  727.             <select class="pd-search" name="PHPDEBUG_SEARCH_TYPE">';
  728.                     foreach (Debug_Line::$debugLineLabels as $lkey => $lvalue) {
  729.                         $debugSearchTypeVal = (!empty($_REQUEST["PHPDEBUG_SEARCH_TYPE"]) && $lkey == $_REQUEST["PHPDEBUG_SEARCH_TYPE"]) ? ' selected="selected"' : '';
  730.                         $buffer .= "              <option value=\"$lkey\"$debugSearchTypeVal>&raquo; $lvalue</option>". CR;
  731.                     }                                   
  732.                     $buffer .= '
  733.             </select>
  734.           </td>
  735.           <td class="pd-search">&nbsp;</td>
  736.           <td class="pd-search">&nbsp;</td>        
  737.           <td class="pd-search">
  738.             <input class="pd-search" type="submit" value="'. $txtGo. '" />
  739.           </td>
  740.         </tr>
  741.         </table>
  742.         </form>';
  743.             
  744.             return $buffer;
  745.     }
  746.  
  747.     /**
  748.      * Print the templates
  749.      * 
  750.      * @since V2.0.0 - 26 Apr 2006
  751.      */ 
  752.     private function showTemplates()
  753.     {
  754.         $txtMainFile = 'MAIN File';
  755.         $idx = 1;
  756.         $buffer = '<br />';
  757.  
  758.         foreach($this->DebugObject->getRequiredFiles() as $lvalue) {
  759.             
  760.             $isToDisplay = true;
  761.             
  762.             foreach ($this->options['HTML_TABLE_view_source_excluded_template'] as $template) {                
  763.                 if (stristr($lvalue, $template)) {
  764.                     $isToDisplay = false;
  765.                 }
  766.             }
  767.             
  768.             if ($isToDisplay == true) {
  769.             
  770.                 $buffer .= $this->span($lvalue, 'files');
  771.                 $buffer .= ' <a href="'. $this->options['HTML_TABLE_view_source_script_path']
  772.                              . '/'. $this->options['HTML_TABLE_view_source_script_name']  
  773.                              .'?file='. $lvalue. '">View source</a> ';
  774.                     
  775.                 // Mark main file    
  776.                 if ($idx == 1) {
  777.                     $buffer .= $this->span("&laquo; $txtMainFile", 'main-file');
  778.                 }                       
  779.                 $idx++;
  780.                 $buffer .= '<br />'. CR;
  781.             }            
  782.         }        
  783.  
  784.         $buffer .= '<br />'. CR;
  785.         return $buffer; 
  786.     }
  787.     
  788.     /**
  789.      * Print an error
  790.      * 
  791.      * @param array $info Array containing information about the error
  792.      * 
  793.      * @since V2.0.0 - 25 Apr 2006
  794.      * @see PHP_DEBUGLINE_PHPERROR
  795.      * @todo Implement the strict error level, add an option to display or not
  796.      *  the stricts errors
  797.      * 
  798.      */ 
  799.     private function showError($infos)    
  800.     {
  801.            
  802.         $buffer = '';
  803.         $infos[1] = str_replace("'", '"', $infos[1]);
  804.         $infos[1] = str_replace('href="function.', ' href="http://www.php.net/'. $this->options['DEBUG_lang']. '/', $infos[1]);
  805.  
  806.         switch ($infos[0])
  807.         {
  808.             case E_WARNING:
  809.                 $errorlevel = 'PHP WARNING : ';
  810.                 $buffer .= '<span class="pd-php-warning"> /!\\ '. $errorlevel. $infos[1] . ' /!\\ </span>';                
  811.                 break;
  812.  
  813.             case E_NOTICE:
  814.                 $errorlevel = 'PHP notice : ';
  815.                 $buffer .= '<span class="pd-php-notice">'. $errorlevel. $infos[1] . '</span>';
  816.                 break;
  817.  
  818.             case E_USER_ERROR:
  819.                 $errorlevel = 'PHP User error : ';
  820.                 $buffer .= '<span class="pd-php-user-error"> /!\\ '. $errorlevel. $infos[1] . ' /!\\ </span>';
  821.                 break;
  822.  
  823.             case E_STRICT:
  824.                 
  825.                 $errorlevel = 'PHP STRICT error : ';
  826.                 $buffer .= '<span class="pd-php-user-error"> /!\\ '. $errorlevel. $infos[1] . ' /!\\ </span>';
  827.                 break;
  828.  
  829.             default:
  830.                 $errorlevel = "PHP errorlevel = ". $infos[0]. " : ";
  831.                 $buffer .= $errorlevel. " is not implemented in PHP_Debug (". __FILE__. ",". __LINE__. ")";
  832.                 break;
  833.         }
  834.         
  835.         return $buffer;
  836.     }
  837.  
  838.     /**
  839.      * Show a super array
  840.      * 
  841.      * @param string $SuperArrayType Type of super en array to add
  842.      * @since V2.0.0 - 07 Apr 2006
  843.      */ 
  844.     private function showSuperArray($SuperArrayType)    
  845.     {
  846.         // Lang
  847.         $txtVariable   = "Var";
  848.         $txtNoVariable = "NO VARIABLE";
  849.         $NoVariable    =  " -- $txtNoVariable -- ";
  850.         $SuperArray    = null;
  851.         $buffer        = '';
  852.  
  853.         $ArrayTitle = Debug::$globalEnvConstantsCorresp[$SuperArrayType];
  854.         $SuperArray = $GLOBALS["$ArrayTitle"];
  855.         $Title = "$ArrayTitle $txtVariable";
  856.         $SectionBasetitle = "<b>$Title (". count($SuperArray). ') :';
  857.  
  858.         if (count($SuperArray)) {
  859.             $buffer .= $SectionBasetitle. '</b>';
  860.             $buffer .= '<pre>'. Debug::dumpVar($SuperArray, $ArrayTitle, PHP_DEBUG_DUMP_STR). '</pre>';
  861.         }
  862.         else {
  863.             $buffer .= $SectionBasetitle. "$NoVariable</b>";
  864.         }
  865.         
  866.         return $buffer;
  867.     }
  868.  
  869.     /**
  870.      * Add the environment display depending on the current configuration
  871.      *
  872.      * @since V2.0.0 - 18 apr 2006
  873.      */
  874.     private function addSuperArray()
  875.     {
  876.         if ($this->options['HTML_TABLE_show_super_array'] == true) {            
  877.             
  878.             // Divide Request tab
  879.             if ($this->options['HTML_TABLE_use_request_arr'] == false) {
  880.                 // Include Post Var
  881.                 $this->DebugObject->addDebug(PHP_DEBUG_GLOBAL_POST, PHP_DEBUGLINE_ENV);
  882.     
  883.                 // Include Get Var
  884.                 $this->DebugObject->addDebug(PHP_DEBUG_GLOBAL_GET, PHP_DEBUGLINE_ENV);
  885.     
  886.                 // Include File Var
  887.                 $this->DebugObject->addDebug(PHP_DEBUG_GLOBAL_FILES, PHP_DEBUGLINE_ENV);
  888.                 
  889.                 // Include Cookie Var
  890.                 $this->DebugObject->addDebug(PHP_DEBUG_GLOBAL_COOKIE, PHP_DEBUGLINE_ENV);
  891.             }
  892.             else {
  893.                 // Only display Request Tab
  894.                 $this->DebugObject->addDebug(PHP_DEBUG_GLOBAL_REQUEST, PHP_DEBUGLINE_ENV);
  895.             }
  896.     
  897.             // Include sessions variabmes, check if we have any
  898.             if (!empty($_SESSION)) {
  899.                 $this->DebugObject->addDebug(PHP_DEBUG_GLOBAL_SESSION, PHP_DEBUGLINE_ENV);
  900.             }
  901.         }
  902.     }
  903.  
  904.     /**
  905.      * Add the process time information to the debug information
  906.      * 
  907.      * @since V2.0.0 - 18 Apr 2006
  908.      */ 
  909.     private function showProcessTime()
  910.     {
  911.         // Lang
  912.         $txtExecutionTime = 'Global execution time ';
  913.         $txtPHP           = 'PHP';
  914.         $txtSQL           = 'SQL';              
  915.         $txtSECOND        = 's';
  916.         $txtOneQry        = ' query';
  917.         $txtMultQry       = ' queries';
  918.         $queryCount       = $this->DebugObject->getQueryCount();
  919.         $txtQuery         = $queryCount > 1 ? $txtMultQry : $txtOneQry;
  920.         $buffer           = '';
  921.  
  922.         // Performance Debug
  923.         $processTime = $this->DebugObject->getProcessTime();
  924.         $sqlTime    = $this->DebugObject->getQueryTime();
  925.         $phpTime    = $processTime - $sqlTime;
  926.     
  927.         $sqlPercent = round(($sqlTime / $processTime) * 100, 2);                              
  928.         $phpPercent = round(($phpTime / $processTime) * 100, 2);
  929.         
  930.         $buffer .= '<table class="pd-perf-table"><tr><td class="pd-perf" align="center">'. $txtExecutionTime;
  931.         $buffer .= '</td><td class="pd-perf" align="center">'. $processTime . $txtSECOND;
  932.         $buffer .= '</td><td class="pd-perf" align="center">100%';
  933.         $buffer .= '</td><td class="pd-perf" align="center">&nbsp;</td></tr>';
  934.  
  935.         $buffer .= '<td class="pd-perf" align="center">'. $txtPHP;
  936.         $buffer .= '</td><td class="pd-perf" align="center">'. $phpTime . $txtSECOND;
  937.         $buffer .= '</td><td class="pd-perf" align="center">'. $phpPercent .'%';
  938.         $buffer .= '</td><td class="pd-perf" align="center">&nbsp;</td></tr>';
  939.         
  940.         $buffer .= '<td class="pd-perf" align="center">'. $txtSQL;
  941.         $buffer .= '</td><td class="pd-perf" align="center">'. $sqlTime. $txtSECOND;
  942.         $buffer .= '</td><td class="pd-perf" align="center">'. $sqlPercent . '%';
  943.         $buffer .= '</td><td class="pd-perf" align="center">'. $queryCount. $txtQuery. '</td></tr>';
  944.         
  945.         $buffer .= '</table>';      
  946.                       
  947.         return $buffer;
  948.     }
  949.  
  950.     /**
  951.      * Return the style sheet of the HTML_TABLE debug object
  952.      * 
  953.      * @return string The stylesheet
  954.      *
  955.      * @since 13 Apr 2006
  956.      */    
  957.     public function getStyleSheet()
  958.     {
  959.         return $this->options['HTML_TABLE_stylesheet'];
  960.     }
  961. }
  962.  
  963. ?>

Documentation generated on Thu, 07 Sep 2006 00:36:29 +0200 by phpDocumentor 1.3.0