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

Source for file Div.php

Documentation is available at Div.php

  1. <?php
  2.  
  3. /**
  4.  * Class of the HTML_Div renderer
  5.  * 
  6.  * Idea from the debug system of the symfony PHP framework
  7.  * @see http://www.symfony-project.org
  8.  * @author Fabien Potencier
  9.  * @author François Zaninotto
  10.  * 
  11.  * @author  Vernet Loïc
  12.  * 
  13.  * @version CVS: $Id: Div.php,v 1.3 2008/10/05 14:41:37 c0il Exp $
  14.  */
  15.  
  16. require_once 'PHP/Debug/Renderer/HTML/DivConfig.php';
  17.  
  18.  
  19. /**
  20.  * A floating div renderer for PHP_Debug
  21.  *
  22.  * Returns a floating based representation of the debug infos in XHTML sctrict
  23.  * format
  24.  *
  25.  * @package PHP_Debug
  26.  * @category PHP
  27.  * @author Loïc Vernet <qrf_coil at yahoo dot fr>
  28.  * @since V2.1.0 - 30 march 2007
  29.  * 
  30.  * @package PHP_Debug
  31.  * @filesource
  32.  */
  33.  
  34. {    
  35.     // debug types for Vars & Config
  36.     protected static $settingsType = array(
  37.         PHP_DebugLine::TYPE_ENV,
  38.     );
  39.  
  40.     // debug types for Log & Message tab
  41.     protected static $msgTypes = array(
  42.         PHP_DebugLine::TYPE_STD,
  43.         PHP_DebugLine::TYPE_PAGEACTION,
  44.         PHP_DebugLine::TYPE_APPERROR,
  45.         PHP_DebugLine::TYPE_CREDITS,
  46.         PHP_DebugLine::TYPE_DUMP,
  47.         PHP_DebugLine::TYPE_WATCH,
  48.         PHP_DebugLine::TYPE_PHPERROR
  49.     );
  50.  
  51.     // debug types for Database tab
  52.     protected static $databaseTypes = array(
  53.         PHP_DebugLine::TYPE_QUERY,
  54.         PHP_DebugLine::TYPE_QUERYREL,
  55.         PHP_DebugLine::TYPE_SQLPARSE,
  56.     );
  57.  
  58.     /**
  59.      * Debug_Renderer_HTML_Div class constructor
  60.      * 
  61.      * @since V2.1.0 - 3 apr 2007
  62.      */
  63.     function __construct($DebugObject$options)
  64.     {
  65.         $this->DebugObject = $DebugObject;
  66.         $this->defaultOptions = PHP_Debug_Renderer_HTML_DivConfig::singleton()->getConfig();
  67.         $this->setOptions($options);
  68.         
  69.         if ($this->options['HTML_DIV_disable_credits'== false{
  70.             $this->DebugObject->addDebugFirst($this->options['HTML_DIV_credits']
  71.                 PHP_DebugLine::TYPE_CREDITS);
  72.         }
  73.  
  74.         // Add execution time
  75.         $this->DebugObject->addProcessPerf();
  76.     }
  77.  
  78.     /**
  79.      * This is the function to display the debug informations
  80.      *
  81.      * @since V2.0.0 - 07 Apr 2006
  82.      * @see PHP_Debug::Render()
  83.      */
  84.     public function display()
  85.     {
  86.         $buffer '';
  87.  
  88.         // Header        
  89.         $buffer .= $this->displayHeader();
  90.  
  91.         // Infos
  92.         $debugInfos $this->DebugObject->getDebugBuffer()
  93.              
  94.         // Vars & config
  95.         $buffer .= $this->showVarsAndConfig($debugInfos);
  96.  
  97.         // Logs & msg
  98.         $buffer .= $this->showLogsAndMsg($debugInfos);
  99.  
  100.         // Database
  101.         $buffer .= $this->showDatabaseInfos($debugInfos);
  102.  
  103.         // W3C Validation
  104.         $buffer .= $this->showW3cValidation($debugInfos);
  105.  
  106.         // Process time
  107.         $buffer .= $this->showProcessTime($debugInfos);
  108.         
  109.         // Footer
  110.         $buffer .= $this->displayFooter();
  111.         
  112.         return $buffer;        
  113.     }
  114.  
  115.     /**
  116.      * Show W3C validator tab
  117.      * 
  118.      * @author COil
  119.      * @since V2.1.1 - 23 apr 2007
  120.      */
  121.     protected function showW3cValidation()
  122.     {
  123.         return str_replace(
  124.             array(
  125.                 '{$imagesPath}',
  126.             ),
  127.             array(
  128.                 $this->options['HTML_DIV_images_path']
  129.             ),
  130.             $this->options['HTML_DIV_sfWebDebugW3CDetails']
  131.         );
  132.     }
  133.  
  134.     /**
  135.      * Add the debug informations of the W3C validation process
  136.      * 
  137.      * @author Vernet Loïc
  138.      * @since 2.1.0 - 23 avr. 2007
  139.      */
  140.     protected function addW3CErrorInfos($res$key)
  141.     {
  142.         $title ucwords($key);  
  143.         $type 'sfW3C'$title;
  144.         $errorCpt = 1;
  145.         $results str_replace(
  146.           '{$title}'
  147.           $title
  148.           $this->options['HTML_DIV_sfWebDebugW3CTableHeader']
  149.         );
  150.  
  151.         foreach ($res->$key as $error{
  152.             $id $errorCpt($error->messageid ? ' ('$error->messageid. ')' '');
  153.             $results .= str_replace(
  154.                 array(
  155.                     '{$type}'
  156.                     '{$cpt}'
  157.                     '{$line}'
  158.                     '{$col}'
  159.                     '{$message}',
  160.                     '{$source}',
  161.                 ),
  162.                 array(
  163.                     $type,
  164.                     $id,
  165.                     $error->line,
  166.                     $error->col,
  167.                     $error->message,
  168.                     '&nbsp',
  169.                 ),
  170.                 $this->options['HTML_DIV_sfWebDebugW3CErrorRow']
  171.             );                        
  172.             $errorCpt++;        
  173.         }
  174.         $results .= '</table>';
  175.         
  176.         return $results;
  177.     }
  178.  
  179.     /**
  180.      * Shows vars & config
  181.      * 
  182.      * @param array debug row
  183.      * 
  184.      * @author COil
  185.      * @since V2.1.0 - 30 march 2007
  186.      */
  187.     protected function showDatabaseInfos($debugInfos)
  188.     {
  189.         $idx = 1;
  190.         $buffer '';
  191.  
  192.         foreach ($debugInfos as $debugInfo{
  193.             $properties $debugInfo->getProperties();
  194.             if (in_array($properties['type']self::$databaseTypes)) {                
  195.                 $buffer.= '<li>['$this->processExecTime($properties)'] '
  196.                     $this->processDebugInfo($properties.'</li>'. CR;
  197.             }
  198.         }
  199.  
  200.         return str_replace(
  201.             array('{$buffer}'),
  202.             array($buffer $buffer '<li>No database debug available</li>'),
  203.             $this->options['HTML_DIV_sfWebDebugDatabaseDetails']
  204.         );
  205.     }
  206.  
  207.     /**
  208.      * Shows vars & config
  209.      * 
  210.      * @author COil
  211.      * @since V2.1.0 - 30 march 2007
  212.      */
  213.     protected function showLogsAndMsg($debugInfos)
  214.     {
  215.         $idx = 1;
  216.         $buffer '';
  217.  
  218.         foreach($debugInfos as $debugInfo{
  219.             $properties $debugInfo->getProperties();
  220.             if (in_array($properties['type']self::$msgTypes)) {
  221.             
  222.                 // Error level of debug information
  223.                 $level $this->getLogInfoLevel($properties);   
  224.                 $infoImg $this->getImageInfo($level);
  225.             
  226.                 $buffer .= '<tr class=\'sfWebDebugLogLine '$this->getDebugLevelClass($level)'\'>
  227.                     <td class="sfWebDebugLogNumber"># '$idx'</td>
  228.                     <td class="sfWebDebugLogType">
  229.                         <img src="'$this->options['HTML_DIV_images_path']'/'$infoImg .'" alt="" />&nbsp;'$this->processType($properties).
  230.                     '</td>
  231.                     <td class="sfWebDebugLogFile">'$this->processFile($properties)'</td>
  232.                     <td class="sfWebDebugLogLine">'$this->processLine($properties)'</td>
  233.                     <td class="sfWebDebugLogClass">'$this->processClass($properties)'</td>
  234.                     <td class="sfWebDebugLogFunction">'$this->processFunction($properties)'</td>
  235.                     <td class="sfWebDebugLogTime">'$this->processExecTime($properties)'</td>
  236.                     <td class="sfWebDebugLogMessage">'$this->processDebugInfo($properties)'</td>
  237.                 </tr>'. CR;
  238.                 $idx++;
  239.             }
  240.         }
  241.  
  242.         return str_replace(
  243.             array(
  244.                 '{$buffer}',
  245.                 '{$imagesPath}',
  246.             ),
  247.             array(
  248.                 $buffer,
  249.                 $this->options['HTML_DIV_images_path']
  250.             ),
  251.             $this->options['HTML_DIV_sfWebDebugLog']
  252.         );
  253.     }
  254.  
  255.     /**
  256.      * Get the log level of the debug info
  257.      * 
  258.      * @author COil
  259.      * @since V2.1.0 - 2 avr. 2007
  260.      * 
  261.      * @param array debug row
  262.      */
  263.     protected function getLogInfoLevel($properties)
  264.     {
  265.         $level PHP_DebugLine::INFO_LEVEL;
  266.  
  267.         switch ($properties['type']{
  268.             case PHP_DebugLine::TYPE_PAGEACTION:
  269.             case PHP_DebugLine::TYPE_CREDITS:
  270.             case PHP_DebugLine::TYPE_DUMP:
  271.             case PHP_DebugLine::TYPE_WATCH:
  272.             break;
  273.  
  274.             case PHP_DebugLine::TYPE_APPERROR:
  275.                 $level PHP_DebugLine::ERROR_LEVEL;
  276.             break;
  277.  
  278.             case PHP_DebugLine::TYPE_PHPERROR:
  279.                 $level $this->getPhpErrorLevel($properties);
  280.             break;
  281.         }
  282.         
  283.         return $level;        
  284.     }
  285.  
  286.     /**
  287.      * Return the global error level corresponding to the related php error
  288.      * level
  289.      * 
  290.      * @param array debug row
  291.      * 
  292.      * @author COil
  293.      * @since 2.1.0 - 3 apr 2007
  294.      */
  295.     protected function getPhpErrorLevel($properties)
  296.     {
  297.         $infos $properties['info'];
  298.  
  299.         switch ($infos[0]{
  300.             case E_ERROR:
  301.             case E_PARSE:
  302.             case E_CORE_ERROR:
  303.             case E_COMPILE_ERROR:
  304.             case E_USER_ERROR:
  305.                 return PHP_DebugLine::ERROR_LEVEL;
  306.             break;                
  307.             
  308.             case E_WARNING:
  309.             case E_CORE_WARNING:
  310.             case E_NOTICE:
  311.             case E_COMPILE_WARNING:
  312.             case E_USER_WARNING:
  313.             case E_USER_NOTICE:
  314.             case E_ALL:
  315.             case E_STRICT:
  316.             case E_RECOVERABLE_ERROR:
  317.                 return PHP_DebugLine::WARNING_LEVEL;
  318.             break;                
  319.  
  320.             default:
  321.                 return PHP_DebugLine::ERROR_LEVEL;
  322.             break;                
  323.         }
  324.     }
  325.  
  326.     /**
  327.      * Get the image info for the current debug type
  328.      * 
  329.      * @author COil
  330.      * @since V2.1.0 - 2 avp 2007
  331.      */
  332.     protected function getDebugLevelClass($debug_level)
  333.     {
  334.         return $this->options['HTML_DIV_debug_level_classes'][$debug_level];
  335.     }
  336.  
  337.     /**
  338.      * Get the image info for the current debug type
  339.      * 
  340.      * @author COil
  341.      * @since V2.1.0 - 2 avp 2007
  342.      */
  343.     protected function getImageInfo($debug_level)
  344.     {
  345.         $info $this->options['HTML_DIV_image_info'];
  346.         $warning $this->options['HTML_DIV_image_warning'];
  347.         $error   $this->options['HTML_DIV_image_error'];
  348.  
  349.         switch ($debug_level{
  350.             case PHP_DebugLine::INFO_LEVEL:
  351.                 $level $info;
  352.             break;
  353.  
  354.             case PHP_DebugLine::WARNING_LEVEL:
  355.                 $level $warning;
  356.             break;
  357.  
  358.             case PHP_DebugLine::ERROR_LEVEL:
  359.                 $level $error;
  360.             break;
  361.         }
  362.         
  363.         return $level;
  364.     }
  365.  
  366.     /**
  367.      * Shows vars & config
  368.      * 
  369.      * @author COil
  370.      * @since V2.1.0 - 30 march 2007
  371.      */
  372.     protected function showVarsAndConfig($debugInfos)
  373.     {
  374.         return str_replace(
  375.             array(
  376.                 '{$sfWebDebugRequest}',
  377.                 '{$sfWebDebugResponse}',
  378.                 '{$sfWebDebugSettings}',
  379.                 '{$sfWebDebugConstants}',
  380.                 '{$sfWebDebugGlobals}',
  381.                 '{$sfWebDebugPhp}',
  382.                 '{$sfWebDebugFiles}',
  383.                 '{$imagesPath}',
  384.             ),
  385.             array(
  386.                 $this->showSuperArray(PHP_Debug::GLOBAL_REQUEST),
  387.                 $this->showSuperArray(PHP_Debug::GLOBAL_COOKIE),
  388.                 $this->showArray($this->settingsAsArray($debugInfos)'Settings'),
  389.                 $this->showArray(get_defined_constants(true)),
  390.                 $this->showArray($this->globalsAsArray()'Globals'),
  391.                 $this->showArray($this->phpInfoAsArray()'PHP Infos'),
  392.                 $this->showTemplates(),
  393.                 $this->options['HTML_DIV_images_path'],
  394.             ),
  395.             $this->options['HTML_DIV_sfWebDebugConfig']
  396.         );
  397.     }
  398.  
  399.     /**
  400.      * Return all settings of application
  401.      * 
  402.      * @author COil
  403.      * @since V2.1.0 - 2 apr 2007
  404.      */
  405.     public function settingsAsArray($debugInfos)
  406.     {
  407.         $settings = array();
  408.         foreach($debugInfos as $debugInfo{
  409.             $infos $debugInfo->getProperties();
  410.             if (in_array($infos['type']self::$settingsType)) {
  411.                 $settings[$infos['info']
  412.             }
  413.         }    
  414.     
  415.         return $settings;
  416.     }
  417.  
  418.    /**
  419.     * Returns PHP globals variables as a sorted array.
  420.     *
  421.     * @return array PHP globals
  422.     * @since V2.1.0 - 2 apr 2007
  423.     */
  424.     public static function globalsAsArray()
  425.     {
  426.         $values = array();
  427.         foreach (array('cookie''server''get''post''files''env''session'as $name{
  428.  
  429.             if (!isset($GLOBALS['_'.strtoupper($name)])) {
  430.                 continue;
  431.             }
  432.     
  433.             $values[$name= array();
  434.             foreach ($GLOBALS['_'strtoupper($name)as $key => $value{
  435.                 $values[$name][$key$value;
  436.             }
  437.             ksort($values[$name]);
  438.         }   
  439.  
  440.         ksort($values);
  441.  
  442.         return $values;
  443.     }
  444.  
  445.     /**
  446.      * Returns PHP information as an array.
  447.      * 
  448.      * @return  array An array of php information
  449.      * @since V2.1.0 - 2 apr 2007
  450.      */
  451.     public static function phpInfoAsArray()
  452.     {
  453.         $values = array(
  454.             'php'        => phpversion(),
  455.             'os'         => php_uname(),
  456.             'extensions' => get_loaded_extensions(),
  457.         );
  458.  
  459.         // assign extension version if available
  460.         if ($values['extensions']{
  461.             foreach ($values['extensions'as $lkey => $extension{
  462.                 $values['extensions'][$lkeyphpversion($extension$extension
  463.                     ' ('phpversion($extension)')' $extension;
  464.             }
  465.         }
  466.  
  467.         return $values;
  468.     }
  469.  
  470.     /**
  471.      * Add the process time information to the debug information
  472.      * 
  473.      * @since V2.0.0 - 18 Apr 2006
  474.      */ 
  475.     protected function showProcessTime($debugInfos)
  476.     {
  477.         // Lang
  478.         $txtExecutionTime 'Global execution time ';
  479.         $txtPHP           'PHP';
  480.         $txtSQL           'SQL';              
  481.         $txtSECOND        's';
  482.         $txtOneQry        ' query';
  483.         $txtMultQry       ' queries';
  484.         $queryCount       $this->DebugObject->getQueryCount();
  485.         $txtQuery         $queryCount > 1 ? $txtMultQry $txtOneQry;
  486.         $buffer           '';
  487.  
  488.         // Performance Debug
  489.         $processTime $this->DebugObject->getProcessTime();
  490.         $sqlTime    $this->DebugObject->getQueryTime();
  491.         $phpTime    $processTime $sqlTime;
  492.     
  493.         $sqlPercent round(($sqlTime $processTime* 1002);                              
  494.         $phpPercent round(($phpTime $processTime* 1002);
  495.  
  496.         $processTime $processTime*1000;
  497.         $sqlTime    $sqlTime*1000;
  498.         $phpTime    $phpTime*1000;
  499.         
  500.         if ($debugInfos{
  501.             $buffer .= '
  502.             <tr>
  503.                 <th>message</th>
  504.                 <th>time (ms)</th>
  505.                 <th>percent</th>
  506.             </tr>'CR;
  507.  
  508.             foreach($debugInfos as $debugInfo{
  509.                 $properties $debugInfo->getProperties();
  510.                 if ($properties['startTime'&& $properties['endTime']{
  511.  
  512.                     $localPercent round((($properties['endTime'
  513.                         $properties['startTime'])*1000 / $processTime* 1002);
  514.                     $buffer .= '
  515.                     <tr>
  516.                         <td class="sfWebDebugLogMessagePerf">'$this->ProcessDebugInfo($properties)'</td>
  517.                         <td style="text-align: right">'$this->ProcessExecTime($properties)'</td>
  518.                         <td style="text-align: right">'$localPercent'%</td>
  519.                     </tr>'CR;
  520.                 }
  521.             }
  522.         }
  523.  
  524.         return str_replace(
  525.             array(
  526.                 '{$txtExecutionTime}',
  527.                 '{$processTime}',
  528.                 '{$txtPHP}',
  529.                 '{$phpTime}',
  530.                 '{$phpPercent}',
  531.                 '{$txtSQL}',
  532.                 '{$sqlTime}',
  533.                 '{$sqlPercent}',
  534.                 '{$queryCount}',
  535.                 '{$txtQuery}',
  536.                 '{$buffer}'
  537.                 
  538.             ),
  539.             array(
  540.                 $txtExecutionTime,
  541.                 $processTime,
  542.                 $txtPHP,
  543.                 $phpTime,
  544.                 $phpPercent,
  545.                 $txtSQL,
  546.                 $sqlTime,
  547.                 $sqlPercent,
  548.                 $queryCount,
  549.                 $txtQuery,
  550.                 $buffer
  551.             ),
  552.             $this->options['HTML_DIV_sfWebDebugTimeDetails']       
  553.         );
  554.     }
  555.  
  556.     /**
  557.      * Default render function for HTML_Div renderer
  558.      *
  559.      * @since V2.0.0 - 11 Apr 2006
  560.      * @see Renderer
  561.      */
  562.     public function render()
  563.     {
  564.         return $this->display();
  565.     }
  566.  
  567.     /**
  568.      * Displays the header of the PHP_Debug object
  569.      *
  570.      * @since V2.0.0 - 08 Apr 2006
  571.      * @see PHP_Debug
  572.      */
  573.     protected function displayHeader()
  574.     {
  575.         return str_replace(
  576.             array(
  577.                 '{$nb_queries}'
  578.                 '{$exec_time}',
  579.                 '{$imagesPath}',
  580.                 '{$phpDebugVersion}'
  581.             ),
  582.             array(
  583.                 $this->DebugObject->getQueryCount()
  584.                 $this->DebugObject->getProcessTime(* 1000,
  585.                 $this->options['HTML_DIV_images_path'],
  586.                 PHP_Debug::PEAR_RELEASE
  587.             ),        
  588.             $this->options['HTML_DIV_header']);  
  589.     }        
  590.  
  591.     /**
  592.      * Diplays the footer of the PHP_Debug object
  593.      *
  594.      * @since V2.0.0 - 08 Apr 2006
  595.      * @see PHP_Debug
  596.      */
  597.     protected function displayFooter()
  598.     {
  599.         return $this->options['HTML_DIV_footer'];
  600.     }        
  601.     
  602.     /**
  603.      * process display of the execution time of debug information
  604.      * 
  605.      * @param array $properties Properties of the debug line
  606.      * @return string Formatted string containing the main debug info
  607.      * @since V2.0.0 - 28 Apr 2006
  608.      */ 
  609.     protected function processExecTime($properties)
  610.     {   
  611.         // Lang
  612.         $txtPHP 'PHP';
  613.         $txtSQL 'SQL';
  614.         $txtSECOND 's';
  615.  
  616.         if (!empty($properties['endTime'])) {
  617.  
  618.             $time round(PHP_Debug::getElapsedTime(
  619.                 $properties['startTime']
  620.                 $properties['endTime']
  621.             * 1000);
  622.  
  623.             $buffer $this->span($time > 1 ? $time' ms' '&lt; 1 ms''time');
  624.  
  625.         else {
  626.             $buffer '&nbsp;';
  627.         }
  628.  
  629.         return $buffer
  630.     }
  631.     
  632.     /**
  633.      * process display of the main information of debug
  634.      * 
  635.      * @param array $properties Properties of the debug line
  636.      * @return string Formatted string containing the main debug info
  637.      * @since V2.0.0 - 28 Apr 2006
  638.      */ 
  639.     protected function processDebugInfo($properties)
  640.     {   
  641.         $buffer '';
  642.  
  643.         switch($properties['type']{
  644.  
  645.             // Case for each of the debug lines types
  646.             // 1 : Standard
  647.             case PHP_DebugLine::TYPE_STD:
  648.                 $buffer .= $this->span($properties['info']'std');
  649.                 break;
  650.             
  651.             // 2 : Query
  652.             case PHP_DebugLine::TYPE_QUERY:
  653.                 $buffer .= preg_replace('/\b(SELECT|FROM|AS|LIMIT|ASC|COUNT|DESC|WHERE|LEFT JOIN|INNER JOIN|RIGHT JOIN|ORDER BY|GROUP BY|IN|LIKE|DISTINCT|DELETE|INSERT|INTO|VALUES)\b/'
  654.                     '<span class="sfWebDebugLogInfo">\\1</span>'
  655.                     $properties['info']);
  656.                 break;
  657.  
  658.             // 3 : Query related
  659.             case PHP_DebugLine::TYPE_QUERYREL:
  660.                 $buffer .= $this->span($properties['info']'query');
  661.                 break;
  662.                 
  663.             // 4 : Environment
  664.             case PHP_DebugLine::TYPE_ENV:
  665.                 $buffer .= $this->showSuperArray($properties['info']);
  666.                 break;
  667.  
  668.             // 6 : User app error
  669.             case PHP_DebugLine::TYPE_APPERROR:
  670.                 $buffer .= $this->span('/!\\ User error : '
  671.                     $properties['info']' /!\\''app-error');
  672.                 break;
  673.                 
  674.             // 7
  675.             case PHP_DebugLine::TYPE_CREDITS:
  676.                 $buffer .= $this->span($properties['info']'credits');            
  677.                 break;
  678.  
  679.             // 9
  680.             case PHP_DebugLine::TYPE_DUMP:
  681.                 $buffer .= $this->showDump($properties);
  682.                 break;
  683.  
  684.             // 10
  685.             case PHP_DebugLine::TYPE_PROCESSPERF:
  686.                 $buffer .= $this->showProcessTime();
  687.                 break;
  688.  
  689.             // 12 : Main Page Action
  690.             case PHP_DebugLine::TYPE_PAGEACTION;
  691.                 $buffer .= $this->span('[Action : '
  692.                     $properties['info']']''pageaction');
  693.                 break;
  694.  
  695.             // 14 : SQL parse 
  696.             case PHP_DebugLine::TYPE_SQLPARSE:
  697.                 $buffer .= $properties['info'];
  698.                 break;
  699.  
  700.             // 15 : Watches
  701.             case PHP_DebugLine::TYPE_WATCH:
  702.                 $infos $properties['info'];
  703.                 $buffer .= 'Variable '$this->span($infos[0]'watch').
  704.                            ' changed from value '
  705.                             $this->span($infos[1]'watch-val')' ('gettype($infos[1])
  706.                             ') to value '$this->span($infos[2]'watch-val')
  707.                             ' ('gettype($infos[2])')';
  708.                 break;
  709.  
  710.             // 16 : PHP errors
  711.             case PHP_DebugLine::TYPE_PHPERROR:                
  712.                 $buffer .= $this->showError($properties['info']);
  713.                 break;
  714.  
  715.             default:
  716.                 $buffer .= '<b>Default('$properties['type'].
  717.                            ')</b>: TO IMPLEMENT OR TO CORRECT : &gt;'
  718.                            $properties['info']'&lt;';
  719.                 break;
  720.         }
  721.  
  722.         return $buffer;
  723.     }
  724.  
  725.     /**
  726.      * Return a string with applying a span style on it
  727.      * 
  728.      * @param string $info String to apply the style
  729.      * @param string $class CSS style to apply to the string
  730.      * @return string Formatted string with style applied
  731.      * @since V2.0.0 - 05 May 2006
  732.      */ 
  733.     protected function span($info$class)
  734.     {   
  735.         return '<span class="'$class .'">'$info .'</span>'
  736.     }
  737.  
  738.     /**
  739.      * process display of the type of the debug information
  740.      * 
  741.      * @param array $properties Properties of the debug line
  742.      * @return string Formatted string containing the debug type
  743.      * @since V2.0.0 - 26 Apr 2006
  744.      */ 
  745.     protected function processType($properties)
  746.     {   
  747.         $buffer PHP_DebugLine::$debugLineLabels[$properties['type']];
  748.         return $buffer;
  749.     }
  750.  
  751.     /**
  752.      * process display of Class
  753.      * 
  754.      * @param array $properties Properties of the debug line
  755.      * @return string Formatted string containing the class
  756.      * @since V2.0.0 - 26 Apr 2006
  757.      */ 
  758.     protected function processClass($properties)
  759.     {
  760.         $buffer '';
  761.  
  762.         switch ($properties['type'])
  763.         {
  764.             case PHP_DebugLine::TYPE_STD:
  765.             case PHP_DebugLine::TYPE_QUERY:
  766.             case PHP_DebugLine::TYPE_QUERYREL:
  767.             case PHP_DebugLine::TYPE_APPERROR:             
  768.             case PHP_DebugLine::TYPE_PAGEACTION:
  769.             case PHP_DebugLine::TYPE_PHPERROR:
  770.             case PHP_DebugLine::TYPE_SQLPARSE:
  771.             case PHP_DebugLine::TYPE_WATCH:
  772.             case PHP_DebugLine::TYPE_DUMP:
  773.                         
  774.                 if (!empty($properties['class'])) {
  775.                     $buffer .= $properties['class'];
  776.                 else {
  777.                     $buffer .= '&nbsp;';
  778.                 }
  779.  
  780.                 break;
  781.                         
  782.             case PHP_DebugLine::TYPE_CREDITS: 
  783.             case PHP_DebugLine::TYPE_SEARCH:
  784.             case PHP_DebugLine::TYPE_PROCESSPERF:
  785.             case PHP_DebugLine::TYPE_TEMPLATES:
  786.             case PHP_DebugLine::TYPE_ENV:
  787.  
  788.                 $buffer .= '&nbsp;';
  789.  
  790.                 break;
  791.         
  792.             default:
  793.                 break;
  794.         }
  795.         
  796.         return $buffer;
  797.     }
  798.  
  799.     /**
  800.      * process display of function
  801.      * 
  802.      * @param array $properties Properties of the debug line
  803.      * @return string Formatted string containing the function
  804.      * @since V2.0.0 - 26 Apr 2006
  805.      */ 
  806.     protected function processFunction($properties)
  807.     {
  808.         $buffer '';
  809.  
  810.         switch ($properties['type'])
  811.         {
  812.             case PHP_DebugLine::TYPE_STD:
  813.             case PHP_DebugLine::TYPE_QUERY:
  814.             case PHP_DebugLine::TYPE_QUERYREL:
  815.             case PHP_DebugLine::TYPE_APPERROR:             
  816.             case PHP_DebugLine::TYPE_PAGEACTION:
  817.             case PHP_DebugLine::TYPE_PHPERROR:
  818.             case PHP_DebugLine::TYPE_SQLPARSE:
  819.             case PHP_DebugLine::TYPE_WATCH:
  820.             case PHP_DebugLine::TYPE_DUMP:
  821.                         
  822.                 if (!empty($properties['function'])) {                    
  823.                     if ($properties['function'!= 'unknown'
  824.                         $buffer .= $properties['function']'()';
  825.                     else {
  826.                         $buffer .= '&nbsp;';
  827.                 }
  828.                 else {
  829.                     $buffer .= '&nbsp;';
  830.                 }
  831.  
  832.                 break;
  833.                         
  834.             case PHP_DebugLine::TYPE_CREDITS: 
  835.             case PHP_DebugLine::TYPE_SEARCH:
  836.             case PHP_DebugLine::TYPE_PROCESSPERF:
  837.             case PHP_DebugLine::TYPE_TEMPLATES:
  838.             case PHP_DebugLine::TYPE_ENV:
  839.  
  840.                 $buffer .= '&nbsp;';
  841.                 break;
  842.         
  843.             default:
  844.                 break;
  845.         }
  846.         
  847.         return $buffer;
  848.     }
  849.  
  850.  
  851.     /**
  852.      * process display of line number
  853.      * 
  854.      * @param array $properties Properties of the debug line
  855.      * @return string Formatted string containing the line number
  856.      * @since V2.0.0 - 26 Apr 2006
  857.      */ 
  858.     protected function processLine($properties)
  859.     {
  860.         $buffer '';
  861.  
  862.         switch ($properties['type'])
  863.         {
  864.             case PHP_DebugLine::TYPE_STD:
  865.             case PHP_DebugLine::TYPE_QUERY:
  866.             case PHP_DebugLine::TYPE_QUERYREL:
  867.             case PHP_DebugLine::TYPE_APPERROR:             
  868.             case PHP_DebugLine::TYPE_PAGEACTION:
  869.             case PHP_DebugLine::TYPE_PHPERROR:
  870.             case PHP_DebugLine::TYPE_SQLPARSE:
  871.             case PHP_DebugLine::TYPE_WATCH:
  872.             case PHP_DebugLine::TYPE_DUMP:
  873.                         
  874.                 if (!empty($properties['line'])) {
  875.                     $buffer.= '<span class="line">'
  876.                         $properties['line']'</span>';
  877.                 else {
  878.                     $buffer.= '&nbsp;';
  879.                 }        
  880.  
  881.                 break;
  882.                         
  883.             case PHP_DebugLine::TYPE_CREDITS: 
  884.             case PHP_DebugLine::TYPE_SEARCH:
  885.             case PHP_DebugLine::TYPE_PROCESSPERF:
  886.             case PHP_DebugLine::TYPE_TEMPLATES:
  887.             case PHP_DebugLine::TYPE_ENV:
  888.  
  889.                 $buffer.= '&nbsp;';
  890.  
  891.                 break;
  892.         
  893.             default:
  894.                 break;
  895.         }
  896.         
  897.         return $buffer;
  898.     }
  899.  
  900.     /**
  901.      * process display of file name
  902.      * 
  903.      * @param array $properties Properties of the debug line
  904.      * @return string Formatted string containing the file
  905.      * @since V2.0.0 - 26 Apr 2006
  906.      */ 
  907.     protected function processFile($properties)
  908.     {
  909.         $buffer '';
  910.  
  911.         switch ($properties['type'])
  912.         {
  913.             case PHP_DebugLine::TYPE_STD:
  914.             case PHP_DebugLine::TYPE_QUERY:
  915.             case PHP_DebugLine::TYPE_QUERYREL:
  916.             case PHP_DebugLine::TYPE_APPERROR:             
  917.             case PHP_DebugLine::TYPE_PAGEACTION:
  918.             case PHP_DebugLine::TYPE_PHPERROR:
  919.             case PHP_DebugLine::TYPE_SQLPARSE:
  920.             case PHP_DebugLine::TYPE_WATCH:
  921.             case PHP_DebugLine::TYPE_DUMP:
  922.  
  923.                 if (!empty($properties['file'])) {
  924.                     if (!empty($this->options['HTML_DIV_view_source_script_path']&& 
  925.                         !empty($this->options['HTML_DIV_view_source_script_name'])) {
  926.                         $buffer .= '<a href="'
  927.                                 $this->options['HTML_DIV_view_source_script_path'].
  928.                                 '/'
  929.                                 $this->options['HTML_DIV_view_source_script_name'].  
  930.                                 '?file='urlencode($properties['file']);
  931.  
  932.                         $buffer .= '">'basename($properties['file'])'</a>'
  933.  
  934.                     else {
  935.                         $buffer .= basename($properties['file']);                        
  936.                     }
  937.                 else {
  938.                     $buffer .=  '&nbsp;';
  939.                 }        
  940.         
  941.                 break;
  942.                         
  943.             case PHP_DebugLine::TYPE_CREDITS: 
  944.             case PHP_DebugLine::TYPE_SEARCH:
  945.             case PHP_DebugLine::TYPE_PROCESSPERF:
  946.             case PHP_DebugLine::TYPE_TEMPLATES:
  947.             case PHP_DebugLine::TYPE_ENV:
  948.  
  949.                 $buffer .=  '&nbsp;';
  950.  
  951.                 break;
  952.         
  953.             default:
  954.                 break;
  955.         }
  956.         
  957.         return $buffer;
  958.     }
  959.  
  960.     /**
  961.      * Dump of a variable
  962.      * 
  963.      * @since V2.0.0 - 26 Apr 2006
  964.      */ 
  965.     protected function showDump($properties)
  966.     {
  967.         $buffer '';
  968.  
  969.         // Check display with a <pre> design
  970.         if (is_array($properties['info'][1])) {
  971.             $preDisplay = true;                      
  972.         elseif (is_object($properties['info'][1])) {
  973.             $preDisplay = true;                      
  974.         else {
  975.             $preDisplay = false;                      
  976.         }
  977.  
  978.         // Check var name
  979.         if (empty($properties['info'][0])) {
  980.             if (is_array($properties['info'][1])) {
  981.                 $varName 'Array';
  982.             elseif (is_object($properties['info'][1])) {
  983.                 $varName get_class($properties['info'][1]);
  984.             else {
  985.                 $varName 'Variable';                              
  986.             }
  987.         else {
  988.             $varName $properties['info'][0];
  989.         }
  990.         
  991.         // Output
  992.         if ($properties['type'!= PHP_DebugLine::TYPE_ENV
  993.             $title 'dump of \'';
  994.         
  995.         
  996.         $title .= $varName'\' ('.  gettype($properties['info'][1].') : ';
  997.         
  998.         $buffer .= $this->span($title 'dump-title');
  999.         
  1000.         if ($preDisplay == true){
  1001.             $buffer .= '<pre>';                   
  1002.             $buffer .= PHP_Debug::dumpVar(
  1003.                 $properties['info'][1]
  1004.                 ''
  1005.                 false
  1006.                 PHP_Debug::DUMP_STR);
  1007.         else {
  1008.             $buffer .= $this->span(
  1009.                 PHP_Debug::dumpVar(
  1010.                     $properties['info'][1]
  1011.                     ''
  1012.                     false
  1013.                     PHP_Debug::DUMP_STR
  1014.                 )'dump-val');
  1015.         }
  1016.  
  1017.         if ($preDisplay == true{
  1018.             $buffer .= '</pre>';                  
  1019.         }
  1020.  
  1021.         return $buffer;
  1022.     }
  1023.  
  1024.     /**
  1025.      * Get the templates info
  1026.      * 
  1027.      * @since V2.0.0 - 26 Apr 2006
  1028.      */ 
  1029.     protected function showTemplates()
  1030.     {
  1031.         $txtMainFile 'MAIN File';
  1032.         $idx = 1;
  1033.         $buffer '<br />';
  1034.  
  1035.         foreach($this->DebugObject->getRequiredFiles(as $lvalue{
  1036.             
  1037.             $isToDisplay = true;
  1038.  
  1039.             if ($this->options['HTML_DIV_view_source_excluded_template']{            
  1040.                 foreach ($this->options['HTML_DIV_view_source_excluded_template'as $template{                
  1041.                     if (stristr($lvalue$template)) {
  1042.                         $isToDisplay = false;
  1043.                     }
  1044.                 }
  1045.             }
  1046.  
  1047.             if ($isToDisplay == true{
  1048.  
  1049.                 $buffer .= '<div class="source">';
  1050.                 $buffer .= $this->span($this->truncate($lvalue)'files');
  1051.                 $buffer .= ' <a href="'
  1052.                              $this->options['HTML_DIV_view_source_script_path'].
  1053.                              '/'$this->options['HTML_DIV_view_source_script_name'].  
  1054.                              '?file='urlencode($lvalue)'">View source</a> ';
  1055.                     
  1056.                 // main file    
  1057.                 if ($idx == 1{
  1058.                     $buffer .= $this->span('&laquo; '$txtMainFile'main-file');
  1059.                 }                       
  1060.                 $idx++;
  1061.                 $buffer .= '</div><br />'CR;
  1062.             }            
  1063.         }        
  1064.  
  1065.         $buffer .= '<br />'CR;
  1066.         return $buffer
  1067.     }
  1068.     
  1069.     
  1070.     /**
  1071.      * Truncate/replace a pattern from the file path
  1072.      * 
  1073.      * @param string full file path
  1074.      * 
  1075.      * @author COil
  1076.      * @since V2.1.0 - 3 apr 2007
  1077.      * 
  1078.      * @see
  1079.      *  - HTML_DIV_remove_templates_pattern
  1080.      *  - HTML_DIV_templates_pattern
  1081.      */
  1082.     protected function truncate($file)
  1083.     {
  1084.         if ($this->options['HTML_DIV_remove_templates_pattern'&& 
  1085.             $this->options['HTML_DIV_templates_pattern']{
  1086.             return strtr($file$this->options['HTML_DIV_templates_pattern']);
  1087.         
  1088.  
  1089.         return $file;
  1090.     }
  1091.     
  1092.     /**
  1093.      * Process an error info
  1094.      * 
  1095.      * @param array $info Array containing information about the error
  1096.      * 
  1097.      * @since V2.0.0 - 25 Apr 2006
  1098.      * @see PHP_DebugLine::TYPE_PHPERROR
  1099.      */ 
  1100.     protected function showError($infos)    
  1101.     {
  1102.         $buffer '';
  1103.         $infos[1str_replace("'"'"'$infos[1]);
  1104.         $infos[1str_replace(
  1105.             'href="function.'
  1106.             ' href="http://www.php.net/'
  1107.             $this->options['lang']'/'$infos[1]);
  1108.  
  1109.         switch ($infos[0])
  1110.         {
  1111.             case E_WARNING:
  1112.                 $errorlevel 'PHP WARNING : ';
  1113.                 $buffer .= '<span class="pd-php-warning"> /!\\ '
  1114.                     $errorlevel$infos[1' /!\\ </span>';                
  1115.                 break;
  1116.  
  1117.             case E_NOTICE:
  1118.                 $errorlevel 'PHP notice : ';
  1119.                 $buffer .= '<span class="pd-php-notice">'
  1120.                     $errorlevel$infos[1'</span>';
  1121.                 break;
  1122.  
  1123.             case E_USER_ERROR:
  1124.                 $errorlevel 'PHP User error : ';
  1125.                 $buffer .= '<span class="pd-php-user-error"> /!\\ '
  1126.                     $errorlevel$infos[1' /!\\ </span>';
  1127.                 break;
  1128.  
  1129.             case E_STRICT:
  1130.                 
  1131.                 $errorlevel 'PHP STRICT error : ';
  1132.                 $buffer .= '<span class="pd-php-user-error"> /!\\ '
  1133.                     $errorlevel$infos[1' /!\\ </span>';
  1134.                 break;
  1135.  
  1136.             default:
  1137.                 $errorlevel 'PHP errorlevel = '$infos[0]' : ';
  1138.                 $buffer .= $errorlevel
  1139.                     ' is not implemented in PHP_Debug ('. __FILE__. ','. __LINE__. ')';
  1140.                 break;
  1141.         }
  1142.         
  1143.         return $buffer;
  1144.     }
  1145.  
  1146.     /**
  1147.      * Show a super array
  1148.      * 
  1149.      * @param string $SuperArrayType Type of super en array to add
  1150.      * @since V2.0.0 - 07 Apr 2006
  1151.      */ 
  1152.     protected function showSuperArray($SuperArrayType)    
  1153.     {
  1154.         // Lang
  1155.         $txtVariable   'Var';
  1156.         $txtNoVariable 'NO VARIABLE';
  1157.         $NoVariable    ' -- '$txtNoVariable' -- ';
  1158.         $SuperArray    = null;
  1159.         $buffer        '';
  1160.  
  1161.         $ArrayTitle = PHP_Debug::$globalEnvConstantsCorresp[$SuperArrayType];
  1162.         $SuperArray $GLOBALS[$ArrayTitle];
  1163.         $Title $ArrayTitle' '$txtVariable;
  1164.         $SectionBasetitle '<b>'$Title'('. count($SuperArray)') :';
  1165.  
  1166.         if (count($SuperArray)) {
  1167.             $buffer .= $SectionBasetitle'</b>';
  1168.             $buffer .= '<pre>'
  1169.                 PHP_Debug::dumpVar(
  1170.                     $SuperArray
  1171.                     $ArrayTitle
  1172.                     false
  1173.                     PHP_Debug::DUMP_STR
  1174.                     )'</pre>';
  1175.         else {
  1176.             $buffer .= $SectionBasetitle$NoVariable'</b>';
  1177.         }
  1178.         
  1179.         return $buffer;
  1180.     }
  1181.  
  1182.     /**
  1183.      * Displays an array.
  1184.      * 
  1185.      * @param string $SuperArrayType Type of super en array to add
  1186.      * @since V2.0.0 - 07 Apr 2006
  1187.      */ 
  1188.     protected function showArray($array$name)    
  1189.     {
  1190.         // Lang
  1191.         $txtNoVariable 'NO VARIABLE';
  1192.         $NoVariable    ' -- '$txtNoVariable' -- ';
  1193.         $buffer        '';
  1194.         $SectionBasetitle '<b>'$name'('count($array)') :';
  1195.  
  1196.         if (count($array)) {
  1197.             $buffer .= $SectionBasetitle'</b>';
  1198.             $buffer .= '<pre>'. PHP_Debug::dumpVar(
  1199.                 $array
  1200.                 $name
  1201.                 false
  1202.                 PHP_Debug::DUMP_STR)'</pre>';
  1203.         else {
  1204.             $buffer .= $SectionBasetitle$NoVariable'</b>';
  1205.         }
  1206.         
  1207.         return $buffer;
  1208.     }
  1209. }

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