public function 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:

boolean $html Set to true to format the dump using HTML:

Return value

string

1 call to EasyRdf_Graph::dumpResource()
EasyRdf_Graph::dump in drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php
Return a human readable view of all the resources in the graph

File

drupal/core/vendor/easyrdf/easyrdf/lib/EasyRdf/Graph.php, line 1313

Class

EasyRdf_Graph
Container for collection of EasyRdf_Resources.

Code

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%'>&rarr;</span> " . "<span style='text-decoration:none;color:green'>" . htmlentities($pstr) . "</span> " . "<span style='font-size:130%'>&rarr;</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";
  }
}