7 public static function newFunction($sHeading)
9 echo "<pre><h2>Debug output for $sHeading</h2></pre>\n";
12 public static function newSection($sHeading)
14 echo "<hr><pre><h3>$sHeading</h3></pre>\n";
17 public static function printVar($sHeading, $mVar)
19 echo '<pre><b>'.$sHeading. ':</b> ';
20 Debug::outputVar($mVar, str_repeat(' ', strlen($sHeading) + 3));
24 public static function fmtArrayVals($aArr)
26 return array('__debug_format' => 'array_vals', 'data' => $aArr);
29 public static function printDebugArray($sHeading, $oVar)
33 Debug::printVar($sHeading, 'null');
35 Debug::printVar($sHeading, $oVar->debugInfo());
39 public static function printDebugTable($sHeading, $aVar)
41 echo '<b>'.$sHeading.":</b>\n";
42 echo "<table border='1'>\n";
46 $aInfo = reset($aVar);
47 if (!is_array($aInfo)) {
48 $aInfo = $aInfo->debugInfo();
50 foreach ($aInfo as $sKey => $mVal) {
51 echo ' <th><small>'.$sKey.'</small></th>'."\n";
55 foreach ($aVar as $oRow) {
57 if (!is_array($oRow)) {
58 $aInfo = $oRow->debugInfo();
61 foreach ($aKeys as $sKey) {
63 if (isset($aInfo[$sKey])) {
64 Debug::outputVar($aInfo[$sKey], '');
66 echo '</pre></td>'."\n";
74 public static function printGroupTable($sHeading, $aVar)
76 echo '<b>'.$sHeading.":</b>\n";
77 echo "<table border='1'>\n";
80 echo ' <th><small>Group</small></th>'."\n";
82 $aInfo = reset($aVar)[0];
83 if (!is_array($aInfo)) {
84 $aInfo = $aInfo->debugInfo();
86 foreach ($aInfo as $sKey => $mVal) {
87 echo ' <th><small>'.$sKey.'</small></th>'."\n";
91 foreach ($aVar as $sGrpKey => $aGroup) {
92 foreach ($aGroup as $oRow) {
94 if (!is_array($oRow)) {
95 $aInfo = $oRow->debugInfo();
98 echo ' <td><pre>'.$sGrpKey.'</pre></td>'."\n";
99 foreach ($aKeys as $sKey) {
101 if (!empty($aInfo[$sKey])) {
102 Debug::outputVar($aInfo[$sKey], '');
104 echo '</pre></td>'."\n";
113 public static function printSQL($sSQL)
115 echo '<p><tt><font color="#aaa">'.$sSQL.'</font></tt></p>'."\n";
118 private static function outputVar($mVar, $sPreNL)
120 if (is_array($mVar) && !isset($mVar['__debug_format'])) {
122 foreach ($mVar as $mKey => $aValue) {
124 $iKeyLen = Debug::outputSimpleVar($mKey);
128 $sPreNL.str_repeat(' ', $iKeyLen + 4)
130 $sPre = "\n".$sPreNL;
132 } elseif (is_array($mVar) && isset($mVar['__debug_format'])) {
133 if (!empty($mVar['data'])) {
135 foreach ($mVar['data'] as $mValue) {
137 Debug::outputSimpleVar($mValue);
142 Debug::outputSimpleVar($mVar);
146 private static function outputSimpleVar($mVar)
148 if (is_bool($mVar)) {
149 echo '<i>'.($mVar ? 'True' : 'False').'</i>';
150 return $mVar ? 4 : 5;
153 if (is_string($mVar)) {
155 return strlen($mVar) + 2;
159 return strlen((string)$mVar);