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 printGroupedSearch($aSearches, $aWordsIDs)
76 echo '<table border="1">';
77 echo '<tr><th>rank</th><th>Name Tokens</th><th>Name Not</th>';
78 echo '<th>Address Tokens</th><th>Address Not</th>';
79 echo '<th>country</th><th>operator</th>';
80 echo '<th>class</th><th>type</th><th>postcode</th><th>housenumber</th></tr>';
81 foreach ($aSearches as $aRankedSet) {
82 foreach ($aRankedSet as $aRow) {
83 $aRow->dumpAsHtmlTableRow($aWordsIDs);
89 public static function printGroupTable($sHeading, $aVar)
91 echo '<b>'.$sHeading.":</b>\n";
92 echo "<table border='1'>\n";
95 echo ' <th><small>Group</small></th>'."\n";
97 $aInfo = reset($aVar)[0];
98 if (!is_array($aInfo)) {
99 $aInfo = $aInfo->debugInfo();
101 foreach ($aInfo as $sKey => $mVal) {
102 echo ' <th><small>'.$sKey.'</small></th>'."\n";
106 foreach ($aVar as $sGrpKey => $aGroup) {
107 foreach ($aGroup as $oRow) {
109 if (!is_array($oRow)) {
110 $aInfo = $oRow->debugInfo();
113 echo ' <td><pre>'.$sGrpKey.'</pre></td>'."\n";
114 foreach ($aKeys as $sKey) {
116 if (!empty($aInfo[$sKey])) {
117 Debug::outputVar($aInfo[$sKey], '');
119 echo '</pre></td>'."\n";
128 public static function printSQL($sSQL)
130 echo '<p><tt><font color="#aaa">'.$sSQL.'</font></tt></p>'."\n";
133 private static function outputVar($mVar, $sPreNL)
135 if (is_array($mVar) && !isset($mVar['__debug_format'])) {
137 foreach ($mVar as $mKey => $aValue) {
139 $iKeyLen = Debug::outputSimpleVar($mKey);
143 $sPreNL.str_repeat(' ', $iKeyLen + 4)
145 $sPre = "\n".$sPreNL;
147 } elseif (is_array($mVar) && isset($mVar['__debug_format'])) {
148 if (!empty($mVar['data'])) {
150 foreach ($mVar['data'] as $mValue) {
152 Debug::outputSimpleVar($mValue);
156 } elseif (is_object($mVar) && method_exists($mVar, 'debugInfo')) {
157 Debug::outputVar($mVar->debugInfo(), $sPreNL);
158 } elseif (is_a($mVar, 'stdClass')) {
159 Debug::outputVar(json_decode(json_encode($mVar), true), $sPreNL);
161 Debug::outputSimpleVar($mVar);
165 private static function outputSimpleVar($mVar)
167 if (is_bool($mVar)) {
168 echo '<i>'.($mVar ? 'True' : 'False').'</i>';
169 return $mVar ? 4 : 5;
172 if (is_string($mVar)) {
174 return strlen($mVar) + 2;
178 return strlen((string)$mVar);