Debug output for $sHeading
\n";
}
public static function newSection($sHeading)
{
echo "
$sHeading
\n";
}
public static function printVar($sHeading, $mVar)
{
echo ''.$sHeading. ': ';
Debug::outputVar($mVar, str_repeat(' ', strlen($sHeading) + 3));
echo "
\n";
}
public static function fmtArrayVals($aArr)
{
return array('__debug_format' => 'array_vals', 'data' => $aArr);
}
public static function printDebugArray($sHeading, $oVar)
{
if ($oVar === null) {
Debug::printVar($sHeading, 'null');
} else {
Debug::printVar($sHeading, $oVar->debugInfo());
}
}
public static function printDebugTable($sHeading, $aVar)
{
echo ''.$sHeading.":\n";
echo "\n";
if (!empty($aVar)) {
echo " \n";
$aKeys = array();
$aInfo = reset($aVar);
if (!is_array($aInfo)) {
$aInfo = $aInfo->debugInfo();
}
foreach ($aInfo as $sKey => $mVal) {
echo ' '.$sKey.' | '."\n";
$aKeys[] = $sKey;
}
echo "
\n";
foreach ($aVar as $oRow) {
$aInfo = $oRow;
if (!is_array($oRow)) {
$aInfo = $oRow->debugInfo();
}
echo " \n";
foreach ($aKeys as $sKey) {
echo ' ';
if (isset($aInfo[$sKey])) {
Debug::outputVar($aInfo[$sKey], '');
}
echo ' | '."\n";
}
echo "
\n";
}
}
echo "
\n";
}
public static function printGroupedSearch($aSearches, $aWordsIDs)
{
echo '';
echo 'rank | Name Tokens | Name Not | ';
echo 'Address Tokens | Address Not | ';
echo 'country | operator | ';
echo 'class | type | postcode | housenumber |
';
foreach ($aSearches as $aRankedSet) {
foreach ($aRankedSet as $aRow) {
$aRow->dumpAsHtmlTableRow($aWordsIDs);
}
}
echo '
';
}
public static function printGroupTable($sHeading, $aVar)
{
echo ''.$sHeading.":\n";
echo "\n";
if (!empty($aVar)) {
echo " \n";
echo ' Group | '."\n";
$aKeys = array();
$aInfo = reset($aVar)[0];
if (!is_array($aInfo)) {
$aInfo = $aInfo->debugInfo();
}
foreach ($aInfo as $sKey => $mVal) {
echo ' '.$sKey.' | '."\n";
$aKeys[] = $sKey;
}
echo "
\n";
foreach ($aVar as $sGrpKey => $aGroup) {
foreach ($aGroup as $oRow) {
$aInfo = $oRow;
if (!is_array($oRow)) {
$aInfo = $oRow->debugInfo();
}
echo " \n";
echo ' '.$sGrpKey.' | '."\n";
foreach ($aKeys as $sKey) {
echo ' ';
if (!empty($aInfo[$sKey])) {
Debug::outputVar($aInfo[$sKey], '');
}
echo ' | '."\n";
}
echo "
\n";
}
}
}
echo "
\n";
}
public static function printSQL($sSQL)
{
echo ''.date('c').' '.htmlspecialchars($sSQL, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401).'
'."\n";
}
private static function outputVar($mVar, $sPreNL)
{
if (is_array($mVar) && !isset($mVar['__debug_format'])) {
$sPre = '';
foreach ($mVar as $mKey => $aValue) {
echo $sPre;
$iKeyLen = Debug::outputSimpleVar($mKey);
echo ' => ';
Debug::outputVar(
$aValue,
$sPreNL.str_repeat(' ', $iKeyLen + 4)
);
$sPre = "\n".$sPreNL;
}
} elseif (is_array($mVar) && isset($mVar['__debug_format'])) {
if (!empty($mVar['data'])) {
$sPre = '';
foreach ($mVar['data'] as $mValue) {
echo $sPre;
Debug::outputSimpleVar($mValue);
$sPre = ', ';
}
}
} elseif (is_object($mVar) && method_exists($mVar, 'debugInfo')) {
Debug::outputVar($mVar->debugInfo(), $sPreNL);
} elseif (is_a($mVar, 'stdClass')) {
Debug::outputVar(json_decode(json_encode($mVar), true), $sPreNL);
} else {
Debug::outputSimpleVar($mVar);
}
}
private static function outputSimpleVar($mVar)
{
if (is_bool($mVar)) {
echo ''.($mVar ? 'True' : 'False').'';
return $mVar ? 4 : 5;
}
if (is_string($mVar)) {
$sOut = "'$mVar'";
} else {
$sOut = (string)$mVar;
}
echo htmlspecialchars($sOut, ENT_QUOTES | ENT_SUBSTITUTE | ENT_HTML401);
return strlen($sOut);
}
}