public function EasyRdf_Graph::dumpResource in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php \EasyRdf_Graph::dumpResource()
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.
Parameters
mixed $resource The resource to dump:
string $format Either 'html' or 'text':
Return value
string
1 call to EasyRdf_Graph::dumpResource()
- EasyRdf_Graph::dump in vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Graph.php - Return a human readable view of all the resources in the graph
File
- vendor/
easyrdf/ easyrdf/ lib/ EasyRdf/ Graph.php, line 1338
Class
- EasyRdf_Graph
- Container for collection of EasyRdf_Resources.
Code
public function dumpResource($resource, $format = 'html') {
$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, $format, 'black');
}
else {
$olist[] = EasyRdf_Utils::dumpResourceValue($value['value'], $format, 'blue');
}
}
$pstr = EasyRdf_Namespace::shorten($property);
if ($pstr == null) {
$pstr = $property;
}
if ($format == '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 ($format == 'html') {
return "<div id='" . htmlentities($resource, ENT_QUOTES) . "' " . "style='font-family:arial; padding:0.5em; " . "background-color:lightgrey;border:dashed 1px grey;'>\n" . "<div>" . EasyRdf_Utils::dumpResourceValue($resource, $format, '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";
}
}