function render_thing($o, $onto_file) { if ($o instanceof EasyRdf_Resource) { $label = get_label($o); if ($o->isBnode()) { echo " \"{$label}\" "; } else { echo " " . link_to_self($label, 'onto_file=' . $onto_file . '&localname=' . $o->localName()) . " "; } } else { echo " \"" . $o . "\" "; } }
function list_instances($graph, $type) { foreach ($graph->allOfType($type) as $p) { $label = $p->label('zh'); if (!$label) { $label = $p->getUri(); } if ($p->isBnode()) { //echo " $label "; } else { echo " " . link_to_self($label, 'uri=' . urlencode($p)) . " |"; } } }
function render_property($graph, $me, $p) { $property = $graph->resource($p); //echo "<p>" . $property->label('zh') . ": "; echo "<p>" . get_label($property) . ": "; foreach ($me->all($property) as $o) { $label = $o->label(); if (!$label) { $label = $o->getUri(); } if ($o->isBnode()) { //echo " $label "; } else { echo " " . link_to_self($label, 'uri=' . urlencode($o)) . " "; } } echo "</p>"; }
<?php if (isset($_REQUEST['id'])) { $graph = EasyRdf_Graph::newAndLoad("http://www.dbpedialite.org/things/" . $_REQUEST['id']); $village = $graph->primaryTopic(); print content_tag('h2', $village->label()); if ($village->get('foaf:depiction')) { print image_tag($village->get('foaf:depiction'), array('style' => 'max-width:400px;max-height:250px;')); } print content_tag('p', $village->get('rdfs:comment')); if ($village->get('geo:long')) { $ll = $village->get('geo:lat') . ',' . $village->get('geo:long'); print "<iframe width='425' height='350' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='http://maps.google.com/maps?f=q&ll={$ll}&output=embed'></iframe>"; } echo "<br /><br />"; echo $graph->dump(); } else { $graph = EasyRdf_Graph::newAndLoad("http://www.dbpedialite.org/categories/" . $CATEGORY_ID); $category = $graph->primaryTopic(); print "<ul>\n"; foreach ($category->all('^rdf:type') as $resource) { if (preg_match("|http://www.dbpedialite.org/things/(\\d+)#id|", $resource, $matches)) { print '<li>' . link_to_self($resource->label(), "id=" . $matches[1]) . "</li>\n"; } } print "</ul>\n"; } ?> </body> </html>
<?php if (isset($_REQUEST['term'])) { $uri = "http://dbpedia.org/resource/" . $_REQUEST['term']; $graph = new EasyRdf_Graph($uri); $village = $graph->resource($uri); print content_tag('h2', $village->label($LANG)); if ($village->get('foaf:depiction')) { print image_tag($village->get('foaf:depiction'), array('style' => 'max-width:400px;max-height:250px;')); } print content_tag('p', $village->get('rdfs:comment', $LANG)); if ($village->get('geo:long')) { $ll = $village->get('geo:lat') . ',' . $village->get('geo:long'); print "<iframe width='425' height='350' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='http://maps.google.com/maps?f=q&sll={$ll}&output=embed'></iframe>"; } echo "<br /><br />"; echo $graph->dump(); } else { $uri = "http://dbpedia.org/resource/Category:Villages_in_Fife"; $graph = new EasyRdf_Graph($uri); $category = $graph->resource($uri); foreach ($graph->resourcesMatching('skos:subject', $category) as $resource) { $term = str_replace('http://dbpedia.org/resource/', '', $resource); $label = urldecode(str_replace('_', ' ', $term)); print '<li>' . link_to_self($label, 'term=' . $term) . "</li>\n"; } } ?> </body> </html>
?> </dd> </dl> <?php echo "<h2>Known Persons</h2>\n"; echo "<ul>\n"; foreach ($person->all('foaf:knows') as $friend) { $label = $friend->label(); if (!$label) { $label = $friend->getUri(); } if ($friend->isBnode()) { echo "<li>{$label}</li>"; } else { echo "<li>" . link_to_self($label, 'uri=' . urlencode($friend)) . "</li>"; } } echo "</ul>\n"; echo "<h2>Interests</h2>\n"; echo "<ul>\n"; foreach ($person->all('foaf:interest') as $interest) { $label = $interest->label(); if ($label) { if ($interest->isBnode()) { echo "<li>{$label}</li>"; } else { echo "<li>" . $interest->htmlLink($label) . "</li>"; } } }
echo " " . link_to_self($label, 'uri=' . urlencode($p)) . " "; } } echo "</li>"; echo "<li>"; foreach ($graph->allOfType('owl:Class') as $p) { $label = $p->label('zh'); if (!$label) { $label = $p->getUri(); } if ($p->isBnode()) { echo " {$label} "; } else { echo " " . link_to_self($label, 'uri=' . urlencode($p)) . " "; } } echo "</li>"; echo "<li>"; foreach ($graph->allOfType('http://www.example.com/Herb') as $p) { $label = $p->label('zh'); if (!$label) { $label = $p->getUri(); } if ($p->isBnode()) { echo " {$label} "; } else { echo " " . link_to_self($label, 'uri=' . urlencode($p)) . " "; } } echo "</li>"; include_once "./foot.php";