当前位置: 首页>>代码示例>>PHP>>正文


PHP EasyRdf_Graph::deleteResource方法代码示例

本文整理汇总了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.");
 }
开发者ID:ASDAFF,项目名称:myprofile,代码行数:28,代码来源:MyProfile.class.php

示例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;
 }
开发者ID:tdt,项目名称:triples,代码行数:56,代码来源:LDFHandler.php


注:本文中的EasyRdf_Graph::deleteResource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。