Source for file Table.php
Documentation is available at Table.php
* Class of the HTML_Table renderer
require_once 'PHP/Debug/Renderer/HTML/TableConfig.php';
* A concrete renderer for Debug
* Returns a table-based representation of the debug infos in HTML 4
* @package linea21.externals
* @author Vernet Loïc <qrf_coil[at]yahoo.fr>, Fabien Potencier, François Zaninotto
* @since V2.0.0 - 10 Apr 2006
* @version CVS: $Id: Table.php,v 1.2 2009/01/12 21:13:00 c0il Exp $
* Debug_Renderer_HTML_Table class constructor
* @since V2.0.0 - 13 apr 2006
// Now add in first the predefined debugline depending on the configuration
if ($this->options['HTML_TABLE_enable_search'] == true)
if ($this->options['HTML_TABLE_disable_credits'] == false)
$this->options['HTML_TABLE_credits'],
// Now add in last positions the others predefined debuglines
if ($this->options['HTML_TABLE_show_templates'] == true)
* This is the function to display the debug information
* @since V2.0.0 - 07 Apr 2006
* @see PHP_Debug::Render()
foreach ($this->DebugObject->getDebugBuffer() as $lvalue) {
// Check if the debug must be displayed
// Check if we have a search criteria
$buffer .= $this->options['HTML_TABLE_prerow'];
$buffer .= $this->options['HTML_TABLE_postrow'];
* This function highligth the searched keyword
* @param string $debugLineStr The formatted debug line object to check
* @return string Formatted string with keyword highligthed
* @since V2.0.0 - 2 May 2006
// Check if search is activated
if (!empty($_GET['PHPDEBUG_SEARCH']) &&
trim($_GET['PHPDEBUG_SEARCH']) != '') {
if (!empty($_GET['PHPDEBUG_SEARCH_CS'])) {
$replaceFunction = 'str_replace';
$replaceFunction = 'str_ireplace';
return $replaceFunction($_GET['PHPDEBUG_SEARCH'],
'<span class="pd-search-hl">'. $_GET['PHPDEBUG_SEARCH'].
'</span>' , $debugLineStr);
* This function check if the user has chosen a search criteria and
* make the search on the formatted debug info
* @param string $debugLineStr The formatted debug line object to check
* @return boolean Search criteria has been found of search is disabled
* @since V2.0.0 - 2 May 2006
// Check if search is activated
if (!empty($_GET['PHPDEBUG_SEARCH']) &&
trim($_GET['PHPDEBUG_SEARCH']) != '') {
if (!empty($_GET['PHPDEBUG_SEARCH_CS'])) {
$searchFunction = 'strstr';
$searchFunction = 'stristr';
return $searchFunction($debugLineStr, trim($_GET['PHPDEBUG_SEARCH']));
* This function check if the user has chosen a filter in the debug type
* combobox and it returns of the debug line is allowed to be output or no
* @param DebugLine $debugLine The debug line object to check
* @return boolean true type is allowed to be
* @since V2.0.0 - 26 Apr 2006
$properties = $debugLine->getProperties();
// Check if we must only show debug information of a kind
if ($this->options['HTML_TABLE_search_forced_type'][$properties['type']] == false) {
if (!empty($_GET['PHPDEBUG_SEARCH_TYPE'])) {
if ($properties['type'] == $_GET['PHPDEBUG_SEARCH_TYPE']) {
* Default render function for HTML_Table renderer
* @since V2.0.0 - 11 Apr 2006
* Displays the header of the PHP_Debug object
* @since V2.0.0 - 08 Apr 2006
return $this->options['HTML_TABLE_header'];
* Diplays the footer of the PHP_Debug object
* @since V2.0.0 - 08 Apr 2006
return $this->options['HTML_TABLE_footer'];
* This is the function that displays a debug line, each step correspond
* to a new cell, actully there are 6 types :
* - Debug main information
* @param DebugLine DebugLine, the debug line to process
* @since V2.0.0 - 07 Apr 2006
$properties = $DebugLine->getProperties();
* process display of the execution time of debug information
* @param array $properties Properties of the debug line
* @return string Formatted string containing the main debug info
* @since V2.0.0 - 28 Apr 2006
$buffer = $this->options['HTML_TABLE_interrow_time'];
if (!empty($properties['endTime'])) {
$properties['startTime'],
* process display of the main information of debug
* @param array $properties Properties of the debug line
* @return string Formatted string containing the main debug info
* @since V2.0.0 - 28 Apr 2006
switch($properties['type'])
// Case for each of the debug lines types
$buffer = $this->options['HTML_TABLE_interrow_info'];
$buffer .= $this->span($properties['info'], 'std');
$buffer = $this->options['HTML_TABLE_interrow_info'];
$buffer .= $this->span($properties['info'], 'query');
$buffer = $this->options['HTML_TABLE_interrow_info'];
$buffer .= $this->span($properties['info'], 'query');
$buffer = $this->options['HTML_TABLE_interrow_info'];
$buffer = $this->options['HTML_TABLE_interrow_info'];
$buffer .= $this->span('/!\\ User error : '.
$properties['info'] . ' /!\\', 'app-error');
$buffer = $this->options['HTML_TABLE_interrow_info'];
$buffer .= $this->span($properties['info'], 'credits');
$buffer = $this->options['HTML_TABLE_interrow_info'];
$buffer = $this->options['HTML_TABLE_interrow_info'];
$buffer .= $this->showDump($properties);
$buffer = $this->options['HTML_TABLE_interrow_info'];
$buffer = $this->options['HTML_TABLE_interrow_info'];
$buffer = $this->options['HTML_TABLE_interrow_info'];
$txtPageAction = 'Page Action';
$buffer .= $this->span("[ $txtPageAction : ".
$properties['info']. ' ]', 'pageaction');
$buffer = $this->options['HTML_TABLE_interrow_info'];
$buffer .= $properties['info'];
$buffer = $this->options['HTML_TABLE_interrow_info'];
$infos = $properties['info'];
$buffer .= 'Variable '. $this->span($infos[0], 'watch').
' changed from value '. $this->span($infos[1], 'watch-val').
') to value '. $this->span($infos[2], 'watch-val').
$buffer = $this->options['HTML_TABLE_interrow_info'];
$buffer .= $this->showError($properties['info']);
$buffer = $this->options['HTML_TABLE_interrow_info'];
$buffer .= "<b>Default(". $properties['type'].
")</b>: TO IMPLEMENT OR TO CORRECT : >".
$properties['info']. '<';
* Return a string with applying a span style on it
* @param string $info String to apply the style
* @param string $class CSS style to apply to the string
* @return string Formatted string with style applied
* @since V2.0.0 - 05 May 2006
protected function span($info, $class)
return '<span class="pd-'. $class . '">'. $info . '</span>';
* process display of the type of the debug information
* @param array $properties Properties of the debug line
* @return string Formatted string containing the debug type
* @since V2.0.0 - 26 Apr 2006
$buffer = $this->options['HTML_TABLE_interrow_type'];
* process display of Class
* @param array $properties Properties of the debug line
* @return string Formatted string containing the class
* @since V2.0.0 - 26 Apr 2006
switch ($properties['type'])
case PHP_DebugLine::TYPE_STD:
$buffer .= $this->options['HTML_TABLE_interrow_class'];
if (!empty($properties['class'])) {
$buffer .= $properties['class'];
$buffer .= $this->options['HTML_TABLE_interrow_class'];
* process display of function
* @param array $properties Properties of the debug line
* @return string Formatted string containing the function
* @since V2.0.0 - 26 Apr 2006
switch ($properties['type'])
$buffer .= $this->options['HTML_TABLE_interrow_function'];
if (!empty($properties['function'])) {
if ($properties['function'] != 'unknown') {
$buffer .= $properties['function']. '()';
$buffer .= $this->options['HTML_TABLE_interrow_function'];
* process display of line number
* @param array $properties Properties of the debug line
* @return string Formatted string containing the line number
* @since V2.0.0 - 26 Apr 2006
switch ($properties['type'])
$buffer.= $this->options['HTML_TABLE_interrow_line'];
if (!empty($properties['line'])) {
$buffer.= '<span class="pd-line">'. $properties['line']. '</span>';
$buffer.= $this->options['HTML_TABLE_interrow_line'];
* process display of file name
* @param array $properties Properties of the debug line
* @return string Formatted string containing the file
* @since V2.0.0 - 26 Apr 2006
switch ($properties['type'])
$buffer .= $this->options['HTML_TABLE_interrow_file'];
if (!empty($properties['file'])) {
if (!empty($this->options['HTML_TABLE_view_source_script_path']) &&
!empty($this->options['HTML_TABLE_view_source_script_name'])) {
$buffer .= '<a href="'. $this->options['HTML_TABLE_view_source_script_path']
. '/'. $this->options['HTML_TABLE_view_source_script_name']
$buffer .= '">'. basename($properties['file']). '</a>';
$buffer .= basename($properties['file']);
$buffer .= $this->options['HTML_TABLE_interrow_file'];
* @since V2.0.0 - 26 Apr 2006
protected function showDump($properties)
// Check display with a <pre> design
} elseif (is_object($properties['info'][1])) {
if (empty($properties['info'][0])) {
} elseif (is_object($properties['info'][1])) {
$varName = get_class($properties['info'][1]);
$varName = $properties['info'][0];
$title .= $varName. "' (". gettype($properties['info'][1]) . ") : ";
$buffer .= $this->span($title , 'dump-title');
if ($preDisplay == true){
if ($preDisplay == true){
* Process the search combo box
* @since V2.0.0 - 26 Apr 2006
// Repost all posted data
$txtStringToSearch = 'Search for';
$txtCaseSensitive = 'Case sensitive';
$txtSelectByType = 'Select only info of type';
$debugSearchVal = isset ($_REQUEST["PHPDEBUG_SEARCH"]) ? trim($_REQUEST["PHPDEBUG_SEARCH"]) : '';
$debugSearchCSVal = isset ($_REQUEST["PHPDEBUG_SEARCH_CS"]) ? ' checked="checked"' : '';
<form id="phpDebugForm" action="'. $_SERVER['PHP_SELF']. '">
<td class="pd-search">'. $txtStringToSearch . '</td>
<td class="pd-search">:</td>
<input class="pd-search" type="text" name="PHPDEBUG_SEARCH" value="'. $debugSearchVal. '" />
<td class="pd-search">'. $txtCaseSensitive . '</td>
<td class="pd-search">:</td>
<input class="pd-search" type="checkbox" name="PHPDEBUG_SEARCH_CS" '. $debugSearchCSVal . ' />
<td class="pd-search">'. $txtSelectByType. '</td>
<td class="pd-search">:</td>
<select class="pd-search" name="PHPDEBUG_SEARCH_TYPE">';
$debugSearchTypeVal = (!empty($_REQUEST["PHPDEBUG_SEARCH_TYPE"])
& $lkey == $_REQUEST["PHPDEBUG_SEARCH_TYPE"]) ? ' selected="selected"' : '';
$buffer .= " <option value=\"$lkey\"$debugSearchTypeVal>» $lvalue</option>". CR;
<td class="pd-search"> </td>
<td class="pd-search"> </td>
<input class="pd-search" type="submit" value="'. $txtGo. '" />
* @since V2.0.0 - 26 Apr 2006
$txtMainFile = 'MAIN File';
foreach($this->DebugObject->getRequiredFiles() as $lvalue) {
if ($this->options['HTML_TABLE_view_source_excluded_template']) {
foreach ($this->options['HTML_TABLE_view_source_excluded_template'] as $template) {
if ($isToDisplay == true) {
$buffer .= $this->span($lvalue, 'files');
$buffer .= ' <a href="'. $this->options['HTML_TABLE_view_source_script_path']
. '/'. $this->options['HTML_TABLE_view_source_script_name']
. '?file='. urlencode($lvalue). '">View source</a> ';
$buffer .= $this->span('« '. $txtMainFile, 'main-file');
* @param array $info Array containing information about the error
* @since V2.0.0 - 25 Apr 2006
* @see PHP_DEBUGLINE_PHPERROR
$infos[1] = str_replace('href="function.', ' href="http://www.php.net/'. $this->options['lang']. '/', $infos[1]);
$errorlevel = 'PHP WARNING : ';
$buffer .= '<span class="pd-php-warning"> /!\\ '.
$errorlevel. $infos[1] . ' /!\\ </span>';
$errorlevel = 'PHP notice : ';
$buffer .= '<span class="pd-php-notice">'.
$errorlevel. $infos[1] . '</span>';
$errorlevel = 'PHP User error : ';
$buffer .= '<span class="pd-php-user-error"> /!\\ '.
$errorlevel. $infos[1] . ' /!\\ </span>';
$errorlevel = 'PHP STRICT error : ';
$buffer .= '<span class="pd-php-user-error"> /!\\ '.
$errorlevel. $infos[1] . ' /!\\ </span>';
$errorlevel = 'PHP errorlevel = '. $infos[0]. ' : ';
$buffer .= $errorlevel. ' is not implemented in PHP_Debug ('.
__FILE__. ','. __LINE__. ')';
* @param string $SuperArrayType Type of super en array to add
* @since V2.0.0 - 07 Apr 2006
$txtNoVariable = 'NO VARIABLE';
$NoVariable = ' -- '. $txtNoVariable. ' -- ';
$ArrayTitle = PHP_Debug::$globalEnvConstantsCorresp[$SuperArrayType];
$SuperArray = $GLOBALS[$ArrayTitle];
$Title = $ArrayTitle. ' '. $txtVariable;
$SectionBasetitle = '<b>$Title ('. count($SuperArray). ') :';
if (count($SuperArray)) {
$buffer .= $SectionBasetitle. '</b>';
$buffer .= $SectionBasetitle. "$NoVariable</b>";
* Add the environment display depending on the current configuration
* @since V2.0.0 - 18 apr 2006
if ($this->options['HTML_TABLE_show_super_array'] == true) {
if ($this->options['HTML_TABLE_use_request_arr'] == false) {
// Only display Request Tab
// Include sessions variabmes, check if we have any
* Add the process time information to the debug information
* @since V2.0.0 - 18 Apr 2006
$txtExecutionTime = 'Global execution time ';
$txtMultQry = ' queries';
$txtQuery = $queryCount > 1 ? $txtMultQry : $txtOneQry;
$phpTime = $processTime - $sqlTime;
$sqlPercent = round(($sqlTime / $processTime) * 100, 2);
$phpPercent = round(($phpTime / $processTime) * 100, 2);
$buffer .= '<div><table class="pd-perf-table"><tr><td class="pd-perf" align="center">'. $txtExecutionTime;
$buffer .= '</td><td class="pd-perf" align="center">'. $processTime . $txtSECOND;
$buffer .= '</td><td class="pd-perf" align="center">100%';
$buffer .= '</td><td class="pd-perf" align="center"> </td></tr>';
$buffer .= '<tr><td class="pd-perf" align="center">'. $txtPHP;
$buffer .= '</td><td class="pd-perf" align="center">'. $phpTime . $txtSECOND;
$buffer .= '</td><td class="pd-perf" align="center">'. $phpPercent . '%';
$buffer .= '</td><td class="pd-perf" align="center"> </td></tr>';
$buffer .= '<tr><td class="pd-perf" align="center">'. $txtSQL;
$buffer .= '</td><td class="pd-perf" align="center">'. $sqlTime. $txtSECOND;
$buffer .= '</td><td class="pd-perf" align="center">'. $sqlPercent . '%';
$buffer .= '</td><td class="pd-perf" align="center">'. $queryCount. $txtQuery. '</td></tr>';
$buffer .= '</table></div>';
|