Beispiel #1
0
 /** Return a human readable view of the resource and its properties
  *
  * This method is intended to be a debugging aid and will
  * print a resource and its properties.
  *
  * @param  bool  $html  Set to true to format the dump using HTML
  * @return 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%'>&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";
     }
 }
 /** Return pretty-print view of the resource
  *
  * @param  bool   $html  Set to true to format the dump using HTML
  * @param  string $color The colour of the text
  * @return string
  */
 public function dumpValue($html = true, $color = 'blue')
 {
     return EasyRdf_Utils::dumpResourceValue($this, $html, $color);
 }
 public function testDumpResourceValueFromArray()
 {
     $res = array('type' => 'uri', 'value' => 'http://www.example.com/');
     $this->assertSame("http://www.example.com/", EasyRdf_Utils::dumpResourceValue($res, false));
     $this->assertSame("<a href='http://www.example.com/' " . "style='text-decoration:none;color:blue'>" . "http://www.example.com/</a>", EasyRdf_Utils::dumpResourceValue($res, true));
 }
Beispiel #4
0
 /** Return pretty-print view of the resource
  *
  * @param  string $format Either 'html' or 'text'
  * @param  string $color The colour of the text
  * @return string
  */
 public function dumpValue($format = 'html', $color = 'blue')
 {
     return EasyRdf_Utils::dumpResourceValue($this, $format, $color);
 }
Beispiel #5
0
 public function testDumpResourceValueWithIllegalColor()
 {
     $this->setExpectedException('InvalidArgumentException', '$color must be a legal color code or name');
     EasyRdf_Utils::dumpResourceValue('http://example.com/', 'html', "blue'><script>alert(1);</script><!--");
 }