public static function EasyRdf_Utils::dumpResourceValue

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.

Parameters

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:

Return value

string

2 calls to EasyRdf_Utils::dumpResourceValue()
EasyRdf_Graph::dumpResource in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Return a human readable view of a resource and its properties
EasyRdf_Resource::dumpValue in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Resource.php
Return pretty-print view of the resource

File

drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Utils.php, line 120

Class

EasyRdf_Utils
Class containing static utility functions

Code

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;
    }
  }
}