CorujaDebug Class Reference

List of all members.

Static Public Member Functions

static show ($strExpression, $boolExit=FALSE)
static debug ($mixExpression, $boolExit=FALSE)
static debugPhpCode ($strPhpExpression, $boolExit=FALSE)
static debugXmlCode ($strXmlExpression, $boolExit=FALSE)
static printXmlCode ($strXmlExpression, $boolCssInLine=FALSE, $boolExit=FALSE)
static debugHtmlCode ($strHtmlExpression, $boolExit=FALSE)
static display ($mixExpression, $boolExit=FALSE)
static prints ($mixExpression, $boolExit=FALSE)

Private Member Functions

 privateXMLEntities ($intNum)

Static Private Member Functions

static removeRecursiveProblem ($mixExpression)
static highlightXml ($strXmlContent, $booCssInLine=true)
static getBackTraceCaller ($intDeeper=0)


Detailed Description

Definition at line 3 of file CorujaDebug.class.php.


Member Function Documentation

static debug ( mixExpression,
boolExit = FALSE 
) [static]

Display the information and show the backtrace

Parameters:
mixer $mixExpression
boolean $boolExit

Definition at line 179 of file CorujaDebug.class.php.

References display().

Referenced by CorujaDebugTest::testDebugWithExitTrue().

00180     {
00181         self::display(  self::removeRecursiveProblem( $mixExpression ) ,$boolExit );
00182     }

static debugHtmlCode ( strHtmlExpression,
boolExit = FALSE 
) [static]

Display the html information and show the backtrace

Parameters:
string $strHtmlExpression
boolean $boolExit

Definition at line 231 of file CorujaDebug.class.php.

References display().

00232     {
00233         self::display( self::highlightXml( $strHtmlExpression ) , $boolExit );
00234     }

static debugPhpCode ( strPhpExpression,
boolExit = FALSE 
) [static]

Display a php code and show the backtrace

Parameters:
string $strPhpExpression
booelan $boolExit

Definition at line 190 of file CorujaDebug.class.php.

References display().

00191     {
00192         if( substr( $strPhpExpression , 0 , 2 ) != "<?" )
00193         {
00194             $strPhpExpression = "<?php \n" . $strPhpExpression;
00195         }
00196         $strPhpExpression = highlight_string( $strPhpExpression , true );
00197         self::display( $strPhpExpression, $boolExit );
00198 
00199     }

static debugXmlCode ( strXmlExpression,
boolExit = FALSE 
) [static]

Display the xml information and show the backtrace

Parameters:
string $strXmlExpression
boolean $boolExit

Definition at line 207 of file CorujaDebug.class.php.

References display().

00208     {
00209         $strXmlExpression = preg_replace('/[^\x09\x0A\x0D\x20-\x7F]/e', 'CorujaDebug::privateXMLEntities("$0")', $strXmlExpression);
00210         self::display( self::highlightXml( $strXmlExpression ) , $boolExit );
00211     }

static display ( mixExpression,
boolExit = FALSE 
) [static]

Display the received information, case the second parameter be true throw one fake exception.

Parameters:
mixer $mixExpression
boolean $boolExit

Definition at line 243 of file CorujaDebug.class.php.

References getBackTraceCaller(), and print.

Referenced by debug(), debugHtmlCode(), debugPhpCode(), and debugXmlCode().

00244         {
00245         $arrBacktraceCaller = self::getBackTraceCaller(2);
00246                 $strMessage = "/*";
00247                 $strMessage .= "<fieldset><legend><font color=\"#007000\">debug</font></legend><pre>" ;
00248                 foreach( $arrBacktraceCaller as $strAttribute => $mixValue )
00249                 {
00250                         $strMessage .= "<b>" . $strAttribute . "</b>: ". $mixValue ."\n";
00251                 }
00252 
00253         $strMessage .= "<div style='background-color: #F0F0F0; float:left'>";
00254                 $strMessage .= $mixExpression;
00255         $strMessage .= "</div>";
00256         
00257                 $strMessage .= "</pre>";
00258                 $strMessage .= "</fieldset> */";
00259 
00260         print $strMessage;
00261         
00262                 if( $boolExit )
00263                 {
00264                         print "<br /><font color=\"#700000\" size=\"4\"><b>D I E</b></font>";
00265                         //throw new CorujaException( var_export( $mixExpression , 1 )  );
00266                 }
00267         }

static getBackTraceCaller ( intDeeper = 0  )  [static, private]

Get the debug backtrace of the stack in the send deeper

Parameters:
integer $intDeeper
Returns:
array

Definition at line 148 of file CorujaDebug.class.php.

References $arrBackTrace, and CorujaArrayManipulation::getArrayField().

Referenced by display(), and show().

00149     {
00150         $arrBackTrace = CorujaArrayManipulation::getArrayField( debug_backtrace() , $intDeeper );
00151         unset( $arrBackTrace[ "object" ] );
00152         return $arrBackTrace;
00153     }

static highlightXml ( strXmlContent,
booCssInLine = true 
) [static, private]

Definition at line 70 of file CorujaDebug.class.php.

00071     {
00072         $booHasHeader = ( ( strpos( $strXmlContent , "<" . "?" . "xml" ) ) !== false );
00073         $strXmlContent = htmlentities( $strXmlContent , true );
00074 
00075         // the css must be on style attribute to not be lose into the //
00076         // e-mail send or something like                              //
00077 
00078         if( $booCssInLine )
00079         {
00080             $strStartTagStyle   = "color:olive;";
00081             $strNameTagStyle    = "color:olive";
00082             $strOutTagStyle     = "";
00083             $strInsideTagStyle  = "color:black";
00084             $strNextStyle       = "color:navy";
00085             $strValueTagStyle   = "color:red";
00086             $strNone            = "display:none";
00087             $strAttribute       = "span style=";
00088         }
00089         else
00090         {
00091             $strStartTagStyle   = "start_tag";
00092             $strNameTagStyle    = "name_tag";
00093             $strOutTagStyle     = "out_tag";
00094             $strInsideTagStyle  = "inside_tag";
00095             $strNextStyle       = "next_tag";
00096             $strValueTagStyle   = "value_tag";
00097             $strNone            = "none_tag";
00098             $strAttribute       = "span class=";
00099         }
00100 
00101         $strXmlContent = str_replace(
00102                 Array(
00103                     "&gt;?" ,       //  < ?  start xml tag
00104                     "?&gt;" ,       //  ? >  out xml tag
00105                     "&lt;" ,        //  <   start tag
00106                     "/&gt;" ,       //  />  out tag
00107                     "&gt;" ,        //   >   content tag
00108                     " ",            //  change of word
00109                     "=",            //  attribute
00110                     "span_style",
00111                ),
00112                 Array(
00113                     "</span></span><span_style'$strStartTagStyle'\n>&lt;<span_style'$strNameTagStyle'><span_style'$strNone'>&nbsp;</span>" ,
00114                     "</span>?&gt;</span><span_style'$strOutTagStyle'\n><span_style'$strNone'>&nbsp;</span>",
00115                     // -2 +3 = +1 //
00116                     "</span></span><span_style'$strStartTagStyle'\n>&lt;<span_style'$strNameTagStyle'><span_style'$strNone'>&nbsp;</span><span><span_style'$strNone'>&nbsp;</span>" ,
00117                     // -2 +1 = -1 //
00118                     "</span>/&gt;</span></span></span\n><span_style'$strOutTagStyle'\n><span_style'$strNone'>&nbsp;</span>",
00119                     // -1 +1 = 0//
00120                     "</span>&gt;<span_style'$strInsideTagStyle'><span_style'$strNone'>&nbsp;</span>",
00121                     // -1 +1 = 0//
00122                     "</span> <span_style'$strNextStyle'><span_style'$strNone'>&nbsp;</span>",
00123                     // -1 +1 = 0//
00124                     "</span>=<span_style'$strValueTagStyle'><span_style'$strNone'>&nbsp;</span>",
00125                     $strAttribute,
00126                 ),
00127             $strXmlContent
00128         );
00129 
00130         $strXmlContent = "<div class='xml'><span><$strAttribute'$strNone'>&nbsp;</span><span><$strAttribute'$strNone'>&nbsp;</span>" . $strXmlContent;
00131 
00132         if( $booHasHeader )
00133         {
00134             $strXmlContent .= '</span></span>';
00135         }
00136         $strXmlContent .= "</span></span></div>";
00137 
00138         return $strXmlContent;
00139         
00140     }

static prints ( mixExpression,
boolExit = FALSE 
) [static]

Display the received information, case the second parameter be true throw one fake exception.

Parameters:
mixer $mixExpression
boolean $boolExit

Definition at line 276 of file CorujaDebug.class.php.

References print.

Referenced by printXmlCode().

00277         {
00278                 $strMessage = "";
00279                 $strMessage .= $mixExpression;
00280 
00281                 $strMessage .= "";
00282 
00283         print $strMessage;
00284 
00285                 if( $boolExit )
00286                 {
00287                         print "<br /><font color=\"#700000\" size=\"4\"><b>D I E</b></font>";
00288                         throw new Exception( var_export( $mixExpression , 1 )  );
00289                 }
00290         }

static printXmlCode ( strXmlExpression,
boolCssInLine = FALSE,
boolExit = FALSE 
) [static]

Show the xml information and show the backtrace

Parameters:
string $strXmlExpression
boolean $boolExit

Definition at line 219 of file CorujaDebug.class.php.

References prints().

00220     {
00221         $strXmlExpression = preg_replace('/[^\x09\x0A\x0D\x20-\x7F]/e', 'CorujaDebug::privateXMLEntities("$0")', $strXmlExpression);
00222         self::prints( self::highlightXml( $strXmlExpression , $boolCssInLine ) , $boolExit );
00223     }

privateXMLEntities ( intNum  )  [private]

Char conversor to the xml debug

Parameters:
integer $num
Returns:
char

Definition at line 11 of file CorujaDebug.class.php.

00012     {
00013         $chars = array(
00014         128 => '&#8364;',   130 => '&#8218;',   131 => '&#402;',    132 => '&#8222;',
00015         133 => '&#8230;',   134 => '&#8224;',   135 => '&#8225;',   136 => '&#710;',
00016         137 => '&#8240;',   138 => '&#352;',    139 => '&#8249;',   140 => '&#338;',
00017         142 => '&#381;',    145 => '&#8216;',   146 => '&#8217;',   147 => '&#8220;',
00018         148 => '&#8221;',   149 => '&#8226;',   150 => '&#8211;',   151 => '&#8212;',
00019         152 => '&#732;',    153 => '&#8482;',   154 => '&#353;',    155 => '&#8250;',
00020         156 => '&#339;',    158 => '&#382;',    159 => '&#376;'
00021         );
00022         $num = ord($intNum);
00023         return (($intNum > 127 && $intNum < 160) ? $chars[$intNum] : "&#".$intNum.";" );
00024     }

static removeRecursiveProblem ( mixExpression  )  [static, private]

When objects with recursive are export to string one error happen. This code it is a work around to recusive object can be see. They recursive call are replace to string with the "recursive" value

Parameters:
object $mixExpression

Definition at line 33 of file CorujaDebug.class.php.

00034     {
00035         $mixExpression = serialize( $mixExpression );
00036         $arrExpression = explode( ";" , $mixExpression );
00037         foreach( $arrExpression as $intKey => $strExpression )
00038         {
00039             $arrElement = explode( ":" , $strExpression );
00040             if( $arrElement[0] == "r" )
00041             {
00042                 $arrElement[0] = "s";
00043                 $arrElement[2] = '"<b>*recursive*</b>"';
00044                 $arrElement[1] = strlen( $arrElement[2] ) - 2;
00045             }
00046             $arrExpression[ $intKey ] = implode( ":" , $arrElement );
00047         }
00048 
00049         $mixExpression = implode( ";" , $arrExpression );
00050         $mixExpression = unserialize( $mixExpression );
00051 
00052         $mixExpression = ( var_export( $mixExpression , 1 ) );
00053         $arrClasses = explode( "::" , $mixExpression );
00054 
00055         foreach( $arrClasses as $intKey => $strClass )
00056         {
00057             $arrClass = explode( " " , $strClass );
00058             $intLast =  sizeof( $arrClass ) - 1;
00059             $arrClass[ $intLast ] = '<b>'. $arrClass[ $intLast ] . '</b>';
00060             $strClass = implode( " " , $arrClass );
00061             $arrClasses[ $intKey ] = $strClass;
00062         }
00063 
00064         $mixExpression = implode( "::" , $arrClasses );
00065 
00066         return $mixExpression;
00067 
00068     }

static show ( strExpression,
boolExit = FALSE 
) [static]

Show the content and create the backtrace information into the html comment

Parameters:
mixer $mExpression
boolean $boolExit

Definition at line 161 of file CorujaDebug.class.php.

References getBackTraceCaller(), and print.

00162     {
00163         $arrBacktraceCaller = self::getBackTraceCaller(2);
00164         print $strExpression;
00165         print "\n<!--";
00166         foreach( $arrBacktraceCaller as $strKey => $mixValue )
00167         {
00168             print $strKey . " = " . serialize($mixValue) . "\n";
00169         }
00170         print "--><br/>\n";
00171     }


The documentation for this class was generated from the following file:

Generated on Thu Feb 3 03:55:03 2011 for CodeToDiagram by  doxygen 1.5.9