public static function formatData($Data, $Indent = '')
{
$Result = '';
if (is_array($Data)) {
foreach ($Data as $Key => $Value) {
if ($Key === null) {
$Key = 'NULL';
}
$Result .= "{$Indent}<b>{$Key}</b>: ";
if ($Value === null) {
$Result .= "NULL\n";
} elseif (is_numeric($Value) || is_string($Value) || is_bool($Value) || is_null($Value)) {
$Result .= htmlspecialchars(var_export($Value, true)) . "\n";
} else {
if (is_a($Value, 'Gdn_DataSet')) {
$Result .= "DataSet";
}
$Result .= "\n" . self::formatData($Value, $Indent . ' ');
}
}
} elseif (is_a($Data, 'Gdn_DataSet')) {
$Data = $Data->result();
if (count($Data) == 0) {
return $Result . 'EMPTY<br />';
}
$Fields = array_keys((array) reset($Data));
$Result .= $Indent . '<b>Count</b>: ' . count($Data) . "\n" . $Indent . '<b>Fields</b>: ' . htmlspecialchars(implode(", ", $Fields)) . "\n";
return $Result;
} elseif (is_a($Data, 'stdClass')) {
$Data = (array) $Data;
return self::formatData($Data, $Indent);
} elseif (is_object($Data)) {
$Result .= $Indent . get_class($Data);
} else {
return trim(var_export($Data, true));
}
return $Result;
}