예제 #1
0
  /**
   * Gets label of the resource.
   *
   * @param string $uri
   *   URI of the resource (eg: schema:Person).
   *
   * @return string
   *   Label of the resource, if not shortened name.
   */
  public function label($uri) {
    if (empty($uri)) {
      drupal_set_message($this->t("Invalid uri"));
      return NULL;
    }
    $label = $this->graph->label($uri);
    if (!empty($label)) {
      return $label->getValue();
    }

    $names = explode(":", $uri);
    return $names[1];
  }
 public function testLabelForUnnamedGraph()
 {
     $graph = new EasyRdf_Graph();
     $this->assertNull($graph->label());
 }
예제 #3
0
$graph->addLiteral("http://njh.me/", "foaf:name", "Nicholas Humfrey");
$graph->addResource("http://njh.me/", "foaf:homepage", "http://www.aelius.com/njh/");
?>

<p>
  <b>Name:</b> <?php 
echo $graph->get("http://example.com/joe", "foaf:name");
?>
 <br />
  <b>Names:</b> <?php 
echo $graph->join("http://example.com/joe", "foaf:name");
?>
 <br />

  <b>Label:</b> <?php 
echo $graph->label("http://njh.me/");
?>
 <br />
  <b>Properties:</b> <?php 
echo join(', ', $graph->properties("http://example.com/joe"));
?>
 <br />
  <b>PropertyUris:</b> <?php 
echo join(', ', $graph->propertyUris("http://example.com/joe"));
?>
 <br />
  <b>People:</b> <?php 
echo join(', ', $graph->allOfType('foaf:Person'));
?>
 <br />
  <b>Unknown:</b> <?php 
예제 #4
0
 public function testMagicGet()
 {
     $data = readFixture('foaf.json');
     $graph = new EasyRdf_Graph('http://www.example.com/joe/foaf.rdf', $data);
     $this->assertStringEquals("Joe Bloggs' FOAF File", $graph->label());
     $this->assertStringEquals("Joe Bloggs' FOAF File", $graph->getRdfs_label());
 }
$graph->addLiteral("http://aelius.com/njh#me", "foaf:name", "Nicholas Humfrey");
$graph->addResource("http://aelius.com/njh#me", "foaf:homepage", "http://aelius.com/njh");
?>

<p>
  <b>Name:</b> <?php 
echo $graph->get("http://example.com/joe", "foaf:name");
?>
 <br />
  <b>Names:</b> <?php 
echo $graph->join("http://example.com/joe", "foaf:name");
?>
 <br />

  <b>Label:</b> <?php 
echo $graph->label("http://aelius.com/njh#me");
?>
 <br />
  <b>Properties:</b> <?php 
echo join(', ', $graph->properties("http://example.com/joe"));
?>
 <br />
  <b>PropertyUris:</b> <?php 
echo join(', ', $graph->propertyUris("http://example.com/joe"));
?>
 <br />
  <b>People:</b> <?php 
echo join(', ', $graph->allOfType('foaf:Person'));
?>
 <br />
  <b>Unknown:</b> <?php