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

Source for file Table.php

Documentation is available at Table.php

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

Documentation generated on Mon, 11 Mar 2019 15:14:17 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.