Ejemplo n.º 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 literal
  *
  * @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 = 'black')
 {
     return EasyRdf_Utils::dumpLiteralValue($this, $html, $color);
 }
Ejemplo n.º 3
0
 /** Return pretty-print view of the literal
  *
  * @param  string $format Either 'html' or 'text'
  * @param  string $color  The colour of the text
  * @return string
  */
 public function dumpValue($format = 'html', $color = 'black')
 {
     return EasyRdf_Utils::dumpLiteralValue($this, $format, $color);
 }
 public function testDumpLiteralValueWithDatatype()
 {
     $literal = array('type' => 'literal', 'value' => '1', 'datatype' => 'http://www.w3.org/2001/XMLSchema#integer');
     $this->assertSame('"1"^^xsd:integer', EasyRdf_Utils::dumpLiteralValue($literal, false));
     $this->assertSame("<span style='color:black'>&quot;1&quot;^^xsd:integer</span>", EasyRdf_Utils::dumpLiteralValue($literal, true));
 }
Ejemplo n.º 5
0
 public function testDumpLiteralValueWithIllegalColor()
 {
     $this->setExpectedException('InvalidArgumentException', '$color must be a legal color code or name');
     EasyRdf_Utils::dumpLiteralValue('literal', 'html', "blue'><script>alert(1);</script><!--");
 }