本文整理汇总了PHP中EasyRdf_Graph::getResource方法的典型用法代码示例。如果您正苦于以下问题:PHP EasyRdf_Graph::getResource方法的具体用法?PHP EasyRdf_Graph::getResource怎么用?PHP EasyRdf_Graph::getResource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EasyRdf_Graph
的用法示例。
在下文中一共展示了EasyRdf_Graph::getResource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: foreach
foreach ($cpss as $prop) {
echo '<tr>';
echo '<td>' . $prop->display_name . '</td>';
echo '<td>' . ($prop->required ? 'Yes' : 'No') . '</td>';
// work out which uri we will use
echo '<td>';
$is_first = true;
$is_resource = false;
foreach ($prop->qnames as $uri) {
if ($is_first) {
$prefered_class = "herbal-prefered-uri";
} else {
$prefered_class = "herbal-not-prefered-uri";
}
if ($prop->resource_expected) {
$r = $doc->getResource($specimen_uri, '<' . $uri . '>');
if ($r) {
$val = $r->getUri();
$is_resource = true;
} else {
$val = $doc->getLiteral($specimen_uri, '<' . $uri . '>');
}
} else {
$val = $doc->getLiteral($specimen_uri, '<' . $uri . '>');
}
if ($val) {
echo '<span class="herbal-used-uri ' . $prefered_class . '">' . $uri . "</span><br/>";
break;
} else {
echo '<span class="herbal-not-used-uri ' . $prefered_class . '" >' . $uri . "</span><br/>";
$is_first = false;
示例2: 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;
}