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

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