本文整理汇总了PHP中EasyRdf_Graph::deleteResource方法的典型用法代码示例。如果您正苦于以下问题:PHP EasyRdf_Graph::deleteResource方法的具体用法?PHP EasyRdf_Graph::deleteResource怎么用?PHP EasyRdf_Graph::deleteResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EasyRdf_Graph
的用法示例。
在下文中一共展示了EasyRdf_Graph::deleteResource方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: urldecode
function del_friend($uri, $format = 'rdfxml')
{
$uri = urldecode($uri);
$path = $this->get_local_path($this->webid);
// Create the new graph object in which we store data
$graph = new EasyRdf_Graph($this->webid);
$graph->load();
$person = $graph->resource($this->webid);
$graph->deleteResource($person, 'foaf:knows', $uri);
// write profile to file
$data = $graph->serialise($format);
if (!is_scalar($data)) {
$data = var_export($data, true);
} else {
$data = print_r($data, true);
}
$pf = fopen($path . '/foaf.rdf', 'w') or die('Cannot open profile RDF file!');
fwrite($pf, $data);
fclose($pf);
$pf = fopen($path . '/foaf.txt', 'w') or die('Cannot open profile TXT file!');
fwrite($pf, $data);
fclose($pf);
// get the user's name
$friend = new MyProfile($uri, $this->base_uri, SPARQL_ENDPOINT);
$friend->load();
// everything is fine
return success("You have just removed " . $friend->get_name() . " from your list of friends.");
}
示例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;
}