Return pretty-print view of a resource URI
This method is mainly intended for internal use and is used by EasyRdf_Graph and EasyRdf_Sparql_Result to format a resource for display.
mixed $resource An EasyRdf_Resource object or an associative array:
bool $html Set to true to format the dump using HTML:
string $color The colour of the text:
string
public static function dumpResourceValue($resource, $html = true, $color = 'blue') {
if (is_object($resource)) {
$resource = strval($resource);
}
elseif (is_array($resource)) {
$resource = $resource['value'];
}
$short = EasyRdf_Namespace::shorten($resource);
if ($html) {
$escaped = htmlentities($resource);
if (substr($resource, 0, 2) == '_:') {
$href = '#' . $escaped;
}
else {
$href = $escaped;
}
if ($short) {
return "<a href='{$href}' style='text-decoration:none;color:{$color}'>{$short}</a>";
}
else {
return "<a href='{$href}' style='text-decoration:none;color:{$color}'>{$escaped}</a>";
}
}
else {
if ($short) {
return $short;
}
else {
return $resource;
}
}
}