本文整理汇总了PHP中EasyRdf_Graph::allOfType方法的典型用法代码示例。如果您正苦于以下问题:PHP EasyRdf_Graph::allOfType方法的具体用法?PHP EasyRdf_Graph::allOfType怎么用?PHP EasyRdf_Graph::allOfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EasyRdf_Graph
的用法示例。
在下文中一共展示了EasyRdf_Graph::allOfType方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: text_field_tag
?>
<p>Please enter the URI of a page with a review on it (marked up with Google Review RDFa):</p>
<?php
echo text_field_tag('uri', 'http://www.bbc.co.uk/music/reviews/2n8c.html', array('size' => 50));
?>
<br />
<?php
echo submit_tag();
echo form_end_tag();
?>
<?php
if (isset($_REQUEST['uri'])) {
$graph = new EasyRdf_Graph($_REQUEST['uri']);
$graph->load();
$reviews = $graph->allOfType('gv:Review');
$review = $reviews[0];
}
if (isset($review)) {
echo "<dl>\n";
# FIXME: support gv:itemreviewed->gv:name ??
if ($review->get('gv:itemreviewed')) {
echo "<dt>Item Reviewed:</dt><dd>" . $review->get('gv:itemreviewed') . "</dd>\n";
}
if ($review->get('gv:rating')) {
echo "<dt>Rating:</dt><dd>" . $review->get('gv:rating') . "</dd>\n";
}
# FIXME: support gv:reviewer->gv:name ??
if ($review->get('gv:reviewer')) {
echo "<dt>Reviewer:</dt><dd>" . $review->get('gv:reviewer') . "</dd>\n";
}
示例2: testAllOfTypeUnknown
public function testAllOfTypeUnknown()
{
$graph = new EasyRdf_Graph();
$resources = $graph->allOfType('unknown:type');
$this->assertTrue(is_array($resources));
$this->assertEquals(0, count($resources));
}
示例3: foreach
<?
if (isset($ontology)) {
echo "<h2>".$ontology->label()."</h2>\n";
echo "<dl>\n";
echo "<dt>Namespace:</dt><dd>".link_to($ontology->getUri())."</dd>\n";
if ($ontology->get('dc:date')) echo "<dt>Date:</dt><dd>".$ontology->get('dc:date')."</dd>\n";
#if ($ontology->dc:creator) # FIXME: implement this
#if ($ontology->dc:contributor) # FIXME: implement this
echo "</dl>\n";
foreach ($ontology->all('rdfs:comment') as $comment) { echo "<p>$comment</p>\n"; }
foreach ($ontology->all('dc:description') as $description) { echo "<p>$description</p>\n"; }
echo "<h2>Classes</h2>\n";
foreach ($graph->allOfType('owl:Class') as $class) {
if ($class->prefix() != $_REQUEST['short']) continue;
echo "<div class='class' id='".$class->shorten()."'>";
echo "<h3>".$class->shorten()."</h3>\n";
foreach ($class->all('rdfs:comment') as $comment) { echo "<p>$comment</p>\n"; }
echo "<dl>\n";
if ($class->get('rdfs:subClassOf')) {
echo "<dt>SubClass of:</dt>\n";
foreach ($class->all('rdfs:subClassOf') as $subClass) {
if ($subClass->prefix() == $_REQUEST['short']) {
echo "<dd>".link_to($subClass->shorten(),'#'.$subClass->shorten())."</dd>\n";
} else {
echo "<dd>".link_to($subClass)."</dd>\n";
}
}
示例4: join
<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
echo $graph->get("http://example.com/joe", "unknown:property");
?>
<br />
</p>
<?php
echo $graph->dump();
?>
</body>
</html>
示例5: urlencode
echo "<li>" . link_to_self($label, 'uri=' . urlencode($friend)) . "</li>";
}
}
foreach ($me->toArray() as $type => $value) {
echo $type . ':' . $value;
}
print_r($me->propertyUris());
foreach ($me->propertyUris() as $p) {
echo "<p>" . $p . "</p>";
$pp = $graph->resource($p);
foreach ($me->all($pp) as $o) {
echo "<p>{$me}, {$p}, {$o}</p>";
}
}
echo "<li>";
foreach ($graph->allOfType('owl:ObjectProperty') 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('owl:Class') as $p) {
$label = $p->label('zh');
if (!$label) {
示例6: rebaseGraph
/**
* Rebase the graph on triples with the start fragment to our own base URI
*
* @param string $start_fragment
* @param EasyRdf_Graph $graph
*
* @return EasyRdf_Graph
*/
private function rebaseGraph($start_fragment, $graph)
{
// Filter out the #dataset meta-data (if present) and change the URI's to our base URI
$collections = $graph->allOfType('hydra:Collection');
// Fetch all of the subject URI's that bring forth hydra meta-data (and are thus irrelevant)
$ignore_subjects = array();
if (empty($collection)) {
$collections = $graph->allOfType('hydra:PagedCollection');
}
if (!empty($collections)) {
foreach ($collections as $collection) {
array_push($ignore_subjects, $collection->getUri());
}
}
// Fetch the bnode of the hydra mapping (property is hydra:search)
$hydra_mapping = $graph->getResource($start_fragment . '#dataset', 'hydra:search');
if (!empty($hydra_mapping)) {
// Hydra mapping's will be a bnode structure
array_push($ignore_subjects, '_:' . $hydra_mapping->getBNodeId());
$mapping_nodes = $hydra_mapping->all('hydra:mapping');
foreach ($mapping_nodes as $mapping_node) {
if ($mapping_node->isBNode()) {
array_push($ignore_subjects, '_:' . $mapping_node->getBNodeId());
}
}
$graph->deleteResource($start_fragment . '#dataset', 'hydra:search', '_:genid1');
$graph->deleteResource('_:genid1', 'hydra:mapping', '_:genid2');
// Delete all of the mapping related resources
$triples = $graph->toRdfPhp();
} else {
// Change all of the base (startfragment) URI's to our own base URI
$triples = $graph->toRdfPhp();
}
// Unset the #dataset
unset($triples[$start_fragment . '#dataset']);
foreach ($ignore_subjects as $ignore_subject) {
unset($triples[$ignore_subject]);
}
$adjusted_graph = new \EasyRdf_Graph();
foreach ($triples as $subject => $triple) {
foreach ($triple as $predicate => $objects) {
foreach ($objects as $object) {
$adjusted_graph->add($subject, $predicate, $object['value']);
}
}
}
return $adjusted_graph;
}