Return a human readable view of a resource and its properties
This method is intended to be a debugging aid and will print a resource and its properties.
mixed $resource The resource to dump:
boolean $html Set to true to format the dump using HTML:
string
public function dumpResource($resource, $html = true) {
$this
->checkResourceParam($resource, true);
if (isset($this->index[$resource])) {
$properties = $this->index[$resource];
}
else {
return '';
}
$plist = array();
foreach ($properties as $property => $values) {
$olist = array();
foreach ($values as $value) {
if ($value['type'] == 'literal') {
$olist[] = EasyRdf_Utils::dumpLiteralValue($value, $html, 'black');
}
else {
$olist[] = EasyRdf_Utils::dumpResourceValue($value['value'], $html, 'blue');
}
}
$pstr = EasyRdf_Namespace::shorten($property);
if ($pstr == null) {
$pstr = $property;
}
if ($html) {
$plist[] = "<span style='font-size:130%'>→</span> " . "<span style='text-decoration:none;color:green'>" . htmlentities($pstr) . "</span> " . "<span style='font-size:130%'>→</span> " . join(", ", $olist);
}
else {
$plist[] = " -> {$pstr} -> " . join(", ", $olist);
}
}
if ($html) {
return "<div id='" . htmlentities($resource) . "' " . "style='font-family:arial; padding:0.5em; " . "background-color:lightgrey;border:dashed 1px grey;'>\n" . "<div>" . EasyRdf_Utils::dumpResourceValue($resource, true, 'blue') . " " . "<span style='font-size: 0.8em'>(" . $this
->classForResource($resource) . ")</span></div>\n" . "<div style='padding-left: 3em'>\n" . "<div>" . join("</div>\n<div>", $plist) . "</div>" . "</div></div>\n";
}
else {
return $resource . " (" . $this
->classForResource($resource) . ")\n" . join("\n", $plist) . "\n\n";
}
}