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

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