Beispiel #1
0
 /**
  * Seed the themes
  *
  * return @void
  */
 private function seedThemes()
 {
     $this->info('---- Seeding new themes ----');
     $base_uri = $this->argument('uri');
     $taxonomy_uri = $this->argument('taxonomy_uri');
     if (empty($taxonomy_uri)) {
         $taxonomy_uri = $base_uri;
     }
     // Try to get the themes from the ns.thedatatank.com (semantic data)
     try {
         $this->info('Trying to fetch triples from the uri: ' . $base_uri);
         $themes_graph = \EasyRdf_Graph::newAndLoad($base_uri);
         if ($themes_graph->isEmpty()) {
             $this->info('We could not reach the online themes.');
         } else {
             $this->info('Found new themes online, removing the old ones.');
             // Empty the themes table
             \Theme::truncate();
         }
         // Fetch the resources with a skos:conceptScheme relationship
         $resources = $themes_graph->allOfType('skos:ConceptScheme');
         $taxonomy_uris = array();
         foreach ($resources as $r) {
             array_push($taxonomy_uris, $r->getUri());
         }
         if (!empty($taxonomy_uris)) {
             if (count($taxonomy_uris) == 1) {
                 $taxonomy_uri = $taxonomy_uris[0];
             } else {
                 // Check if one of the possible taxonomy uris compares to the uri of the document
                 foreach ($taxonomy_uris as $tax_uri) {
                     if ($base_uri == $tax_uri) {
                         $taxonomy_uri = $tax_uri;
                         break;
                     }
                     $this->error('None of the URIs that have the skos:ConceptScheme property matched the URI of the document, please specify the taxonomy URI as a second parameter.');
                 }
             }
         } else {
             $this->error('No resource has been found with a property of skos:ConceptScheme.');
         }
         // Fetch all of the themes
         foreach ($themes_graph->resourcesMatching('skos:inScheme') as $theme) {
             if ($theme->get('skos:inScheme')->getUri() == $taxonomy_uri) {
                 $uri = $theme->getUri();
                 $label = $theme->getLiteral('rdfs:label');
                 if (!empty($label) && !empty($uri)) {
                     $label = $label->getValue();
                     $this->info('Added ' . $uri . ' with label ' . $label);
                     \Theme::create(array('uri' => $uri, 'label' => $label));
                 }
             }
         }
         $this->info('Added new themes.');
     } catch (EasyRdf_Exception $ex) {
         $this->info('An error occurred when we tried to fetch online themes.');
     }
 }
 public function indexAction()
 {
     $foaf = \EasyRdf_Graph::newAndLoad('http://njh.me/foaf.rdf');
     $me = $foaf->primaryTopic();
     \EasyRdf_Namespace::set('category', 'http://dbpedia.org/resource/Category:');
     \EasyRdf_Namespace::set('dbpedia', 'http://dbpedia.org/resource/');
     \EasyRdf_Namespace::set('dbo', 'http://dbpedia.org/ontology/');
     \EasyRdf_Namespace::set('dbp', 'http://dbpedia.org/property/');
     $sparql = new \EasyRdf_Sparql_Client('http://dbpedia.org/sparql');
     $result = $sparql->query('SELECT * WHERE {' . '  ?country rdf:type dbo:Country .' . '  ?country rdfs:label ?label .' . '  ?country dc:subject category:Member_states_of_the_United_Nations .' . '  FILTER ( lang(?label) = "en" )' . '} ORDER BY ?label');
     return $this->render('MyAppBlogBundle:Default:index.html.twig', array('name' => $result, 'count' => $result->numRows()));
 }
Beispiel #3
0
 /**
  * Seed the themes
  *
  * return @void
  */
 private function seedThemes()
 {
     $this->command->info('---- DCAT Themes ----');
     $uri = 'http://ns.thedatatank.com/dcat/themes#Taxonomy';
     $themes_fetched = false;
     // Try to get the themes from the ns.thedatatank.com (semantic data)
     try {
         $this->command->info('Trying to fetch new themes online.');
         $themes_graph = \EasyRdf_Graph::newAndLoad($uri);
         if ($themes_graph->isEmpty()) {
             $this->command->info('We could not reach the online themes.');
         } else {
             $themes_fetched = true;
             $this->command->info('Found new themes online, removing the old ones.');
             // Empty the themes table
             \Theme::truncate();
         }
         // Fetch all of the themes
         foreach ($themes_graph->resourcesMatching('skos:inScheme') as $theme) {
             if ($theme->get('skos:inScheme')->getUri() == $uri) {
                 $theme_uri = $theme->getUri();
                 $label = $theme->getLiteral('rdfs:label');
                 if (!empty($label) && !empty($theme_uri)) {
                     $label = $label->getValue();
                     $this->command->info('Added ' . $uri . ' with label ' . $label);
                     \Theme::create(array('uri' => $theme_uri, 'label' => $label));
                 }
             }
         }
         $this->command->info('Added new themes.');
     } catch (EasyRdf_Exception $ex) {
         $this->command->info('An error occurred when we tried to fetch online themes.');
     }
     // If it's not available, get them from a file (json)
     if (!$themes_fetched) {
         $this->command->info('Trying to fetch the themes from the local json file containing a default set of themes.');
         $themes = json_decode(file_get_contents(app_path() . '/database/seeds/data/themes.json'));
         if (!empty($themes)) {
             $this->command->info('Found new themes, removing the old ones.');
             // Empty the themes table
             \Theme::truncate();
             foreach ($themes as $theme) {
                 \Theme::create(array('uri' => $theme->uri, 'label' => $theme->label));
             }
             if (!empty($themes)) {
                 $this->command->info('Added themes from the local json file.');
             }
         } else {
             $this->command->info('No themes were found in the local json file, the old ones will not be replaced.');
         }
     }
 }
Beispiel #4
0
 private function makeSemanticResponse($uri)
 {
     try {
         $graph = new \EasyRdf_Graph();
         if (substr($uri, 0, 4) == "http") {
             $graph = \EasyRdf_Graph::newAndLoad($uri);
         } else {
             $graph->parseFile($uri, 'jsonld');
         }
     } catch (\Exception $ex) {
         \App::abort(500, "The JSON-LD reader couldn't parse the document, the exception message we got is: " . $ex->getMessage());
     }
     // Return the data object with the graph
     $data = new Data();
     $data->data = $graph;
     $data->is_semantic = true;
     $data->preferred_formats = ['jsonld', 'ttl', 'rdf'];
     return $data;
 }
Beispiel #5
0
 public function readData($source_definition, $rest_parameters = array())
 {
     $uri = $source_definition['uri'];
     // If the parsing in the document fails, a JsonLdException is thrown
     try {
         $graph = new \EasyRdf_Graph();
         if (substr($uri, 0, 4) == "http") {
             $graph = \EasyRdf_Graph::newAndLoad($uri);
         } else {
             $graph->parseFile($uri, 'jsonld');
         }
     } catch (\Exception $ex) {
         \App::abort(500, "The JSON LD reader couldn't parse the document, the exception message we got is: " . $ex->getMessage());
     }
     // Return the data object with the graph
     $data = new Data();
     $data->data = $graph;
     $data->is_semantic = true;
     $data->preferred_formats = $this->getPreferredFormats();
     return $data;
 }
 public function indexAction()
 {
     $product = new Product();
     for ($i = 0; $i < 100; $i++) {
         $product->setName('Foo Bar  : ' . rand(0, 100));
         $product->setPrice(rand(0, 1000));
         $dm = $this->get('doctrine_mongodb')->getManager();
         $dm->persist($product);
         $dm->flush();
     }
     $foaf = \EasyRdf_Graph::newAndLoad('http://njh.me/foaf.rdf');
     $me = $foaf->primaryTopic();
     \EasyRdf_Namespace::set('category', 'http://dbpedia.org/resource/Category:');
     \EasyRdf_Namespace::set('dbpedia', 'http://dbpedia.org/resource/');
     \EasyRdf_Namespace::set('dbo', 'http://dbpedia.org/ontology/');
     \EasyRdf_Namespace::set('dbp', 'http://dbpedia.org/property/');
     $sparql = new \EasyRdf_Sparql_Client('http://dbpedia.org/sparql');
     $result = $sparql->query('SELECT * WHERE {' . '  ?country rdf:type dbo:Country .' . '  ?country rdfs:label ?label .' . '  ?country dc:subject category:Member_states_of_the_United_Nations .' . '  FILTER ( lang(?label) = "en" )' . '} ORDER BY ?label');
     $repository = $this->get('doctrine_mongodb')->getManager()->getRepository('MyAppBlogBundle:Product');
     return $this->render('MyAppBlogBundle:Default:index.html.twig', array('name' => $result, 'count' => $result->numRows(), 'products' => $repository->findAll()));
 }
Beispiel #7
0
 * Script to update test cases from rdfa.info
 *
 * @package    EasyRdf
 * @copyright  Copyright (c) 2012-2013 Nicholas J Humfrey
 * @license    http://www.opensource.org/licenses/bsd-license.php
 */
set_include_path(get_include_path() . PATH_SEPARATOR . './lib/');
require_once "EasyRdf.php";
$RDFA_VERSION = 'rdfa1.1';
$HOST_LANGUAGE = 'xhtml5';
$REFERENCE_DISTILLER = 'http://www.w3.org/2012/pyRdfa/extract?format=nt&rdfagraph=output&uri=';
$FIXTURE_DIR = dirname(__FILE__);
EasyRdf_Namespace::set('test', 'http://www.w3.org/2006/03/test-description#');
EasyRdf_Namespace::set('rdfatest', 'http://rdfa.info/vocabs/rdfa-test#');
$client = new EasyRdf_Http_Client();
$manifest = EasyRdf_Graph::newAndLoad('http://rdfa.info/test-suite/manifest.ttl');
foreach ($manifest->allOfType('test:TestCase') as $test) {
    if (!in_array($RDFA_VERSION, $test->all('rdfatest:rdfaVersion'))) {
        continue;
    }
    if (!in_array($HOST_LANGUAGE, $test->all('rdfatest:hostLanguage'))) {
        continue;
    }
    if ($test->get('test:classification')->shorten() != 'test:required') {
        continue;
    }
    $id = $test->localName();
    $title = $test->get('dc:title');
    $escapedTitle = addcslashes($title, '\'');
    # Download the test input
    $inputUri = "http://rdfa.info/test-suite/test-cases/{$RDFA_VERSION}/{$HOST_LANGUAGE}/{$id}.xhtml";
Beispiel #8
0
 * A new EasyRdf_Graph object is created and then the contents
 * of my FOAF profile is loaded from the web. An EasyRdf_Resource for
 * the primary topic of the document (me, Nicholas Humfrey) is returned
 * and then used to display my name.
 *
 * @package    EasyRdf
 * @copyright  Copyright (c) 2009-2013 Nicholas J Humfrey
 * @license    http://unlicense.org/
 */
set_include_path(get_include_path() . PATH_SEPARATOR . '../lib/');
require_once "./lib/EasyRdf.php";
?>
<html>
<head>
  <title>Basic FOAF example</title>
</head>
<body>

<?php 
$foaf = EasyRdf_Graph::newAndLoad('http://njh.me/foaf.rdf');
$me = $foaf->primaryTopic();
?>

<p>
  My name is: <?php 
echo $me->get('foaf:name');
?>
</p>

</body>
</html>
Beispiel #9
0
 private function fetchResourceFromUri($uri)
 {
     try {
         // change the timeout setting for external requests
         $httpclient = EasyRdf_Http::getDefaultHttpClient();
         $httpclient->setConfig(array('timeout' => $this->getConfig()->getHttpTimeout()));
         EasyRdf_Http::setDefaultHttpClient($httpclient);
         $client = EasyRdf_Graph::newAndLoad(EasyRdf_Utils::removeFragmentFromUri($uri));
         return $client->resource($uri);
     } catch (Exception $e) {
         return null;
     }
 }
Beispiel #10
0
 /**
  * Fetch the default licenses
  *
  * @return \EasyRdf_Graph
  */
 private function fetchDefaultGraph()
 {
     $license_uri = $this->licenses_uri . $this->DEFAULT_LICENSE . '.json';
     return \EasyRdf_Graph::newAndLoad($license_uri, 'jsonld');
 }
Beispiel #11
0
<html>
<head>
  <title>EasyRdf RSS 1.0 Parsing example</title>
	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
</head>
<body>
<h1>EasyRdf RSS 1.0 Parsing example</h1>

<?php 
echo form_tag();
echo text_field_tag('uri', 'http://planetrdf.com/index.rdf', array('size' => 50));
echo submit_tag();
echo form_end_tag();
?>

<?php 
if (isset($_REQUEST['uri'])) {
    $graph = EasyRdf_Graph::newAndLoad($_REQUEST['uri'], 'rdfxml');
    $channel = $graph->get('rss:channel', '^rdf:type');
    print "<p>Channel: " . link_to($channel->label(), $channel->get('rss:link')) . "</p>\n";
    print "<p>Description: " . $channel->get('rss:description') . "</p>\n";
    print "<ol>\n";
    foreach ($channel->get('rss:items') as $item) {
        print "<li>" . link_to($item->get('rss:title'), $item) . "</li>\n";
    }
    print "</ol>\n";
}
?>
</body>
</html>
Beispiel #12
0
<hr/>

  <section class="content-box">
      <!-- metadata about the RDF document/record that describes the resource -->
      <h2>Provenance of record</h2>

      <?php 
$record = $graph->resource('http://jacobshelby.org/examples/linkedData/catalog_001.rdf');
$creator = $record->get('dcterms:creator');
?>

       <ul>
        <li><strong>Creator</strong></li>
        <?php 
$creatorResource = str_replace("/me", "/jacobShelby.rdf", $creator);
$creatorGraph = EasyRdf_Graph::newAndLoad($creatorResource);
$creatorRecord = $creatorGraph->resource($creator);
$creatorName = $creatorRecord->get('schema:name');
echo "<li><a href='" . "{$creator}" . "'>{$creatorName}</a>";
?>
         <details><ul>
             <?php 
$creatorEmployer = $creatorRecord->get('schema:worksFor');
$employerRecord = $creatorGraph->resource($creatorEmployer);
$employerName = $employerRecord->get('schema:name');
echo "<li><strong>Works for</strong></li>";
echo "<li><a href='" . "{$creatorEmployer}" . "'>{$employerName}</a></li>";
$creatorTitle = $creatorRecord->get('schema:jobTitle');
echo "<li><strong>Job title</strong></li>";
echo "<li>{$creatorTitle}</li>";
$creatorEmail = $creatorRecord->get('schema:email');
 * @package    EasyRdf
 * @copyright  Copyright (c) 2012-2013 Nicholas J Humfrey
 * @license    http://unlicense.org/
 */
set_include_path(get_include_path() . PATH_SEPARATOR . '../lib/');
require_once "EasyRdf.php";
EasyRdf_Namespace::setDefault('dc11');
?>
<html>
<head>
  <title>Open Graph Protocol example</title>
</head>
<body>

<?php 
$doc = EasyRdf_Graph::newAndLoad('http://www.rottentomatoes.com/m/10011268-oceans/');
?>

<p>
  Title: <?php 
echo $doc->title;
?>
<br />
  Creator: <?php 
echo $doc->creator;
?>
<br />
</p>

</body>
</html>
Beispiel #14
0
<?php

set_include_path(get_include_path() . PATH_SEPARATOR . '../lib/');
require_once "EasyRdf.php";
## Add namespaces
EasyRdf_Namespace::set('vitro', 'http://vitro.mannlib.cornell.edu/ns/vitro/public#');
EasyRdf_Namespace::set('vivo', 'http://vivoweb.org/ontology/core#');
$uri = 'http://54.235.146.115:8080/vivo/individual/n5642';
$graph = EasyRdf_Graph::newAndLoad($uri);
$person = $graph->resource($uri);
?>

<html>
<head><title>Vivo Reader</title></head>
<body>
<h1>Vivo Reader</h1>

<p>
  <b>First Name</b>: <?php 
echo $person->get('foaf:firstName');
?>
<br />
  <b>Last Name</b>: <?php 
echo $person->get('foaf:lastName');
?>
<br />
  <b>Title</b>: <?php 
echo $person->get('vivo:preferredTitle');
?>
<br />
</p>
Beispiel #15
0
<?php

require 'vendor/autoload.php';
$graph = EasyRdf_Graph::newAndLoad("http://localhost:8080/orbeon/nomisma/id/rome.rdf");
$objects = $graph->resources();
foreach ($objects as $object) {
    var_dump($object->types());
}
Beispiel #16
0
 /**
  * Retrieves an RDF Graph for the resource in Fedora.
  *
  * @param string    $uri    Fedora uri
  *
  * @return EasyRdf_Graph    The graph object for the resource in Fedora
  */
 public function fetchGraph($uri)
 {
     return \EasyRdf_Graph::newAndLoad($uri);
 }
Beispiel #17
0
      </ul>
    </nav>
  </header>


<?php 
## Add namespaces. At default easyRdf recognizes dcterms, dc, foaf, rdf, rdfs, and some others
EasyRdf_Namespace::set('madsrdf', 'http://www.loc.gov/mads/rdf/v1#');
EasyRdf_Namespace::set('bibframe', 'http://bibframe.org/vocab/');
EasyRdf_Namespace::set('gn', 'http://www.geonames.org/ontology#');
EasyRdf_Namespace::set('skos', 'http://www.w3.org/2008/05/skos#');
EasyRdf_Namespace::set('lexvo', 'http://lexvo.org/id/');
EasyRdf_Namespace::set('lexvont', 'http://lexvo.org/ontology#');
EasyRdf_Namespace::set('schema', 'http://schema.org/');
##Create preliminary resources
$graph = EasyRdf_Graph::newAndLoad('http://jacobshelby.org/examples/linkedData/Series_002.rdf');
$base = 'http://jacobshelby.org/examples/linkedData/';
// ____ = $graph->resource($base.'____');
/*$book = $graph->resource('http://jacobshelby.org/examples/linkedData/catalog_001');
  $language = $book->get('dcterms:language');
  $placeOfPublication = $book->get('bibframe:providerPlace');
  $placeOfPublicationResource = $placeOfPublication."about.rdf";
  $placeOfPublicationGraph = EasyRdf_Graph::newAndLoad($placeOfPublicationResource);
  $placeOfPublicationRecord = $placeOfPublicationGraph->resource($placeOfPublication);
  $type = $book->get('dcterms:type');
  $typeGraph = EasyRdf_Graph::newAndLoad('http://dublincore.org/2012/06/14/dctype.rdf');
  $typeRecord = $typeGraph->resource($type); */
?>


<main>
Beispiel #18
0
    exit;
}
$uri = 'http://d-nb.info/gnd/' . $gnd;
// setup namespaces
// standard
EasyRdf_Namespace::set('owl', 'http://www.w3.org/2002/07/owl#');
EasyRdf_Namespace::set('rdf', 'http://www.w3.org/1999/02/22-rdf-syntax-ns#');
EasyRdf_Namespace::set('rdfs', 'http://www.w3.org/2000/01/rdf-schema#');
// dnb
EasyRdf_Namespace::set('gnd', 'http://d-nb.info/standards/elementset/gnd#');
EasyRdf_Namespace::set('bibo', 'http://purl.org/ontology/bibo/');
EasyRdf_Namespace::set('dct', 'http://purl.org/dc/terms/');
EasyRdf_Namespace::set('dc', 'http://purl.org/dc/elements/1.1/');
EasyRdf_Namespace::set('skos', 'http://www.w3.org/2004/02/skos/core#');
EasyRdf_Namespace::set('isbd', 'http://iflastandards.info/ns/isbd/elements/');
$rdf = EasyRdf_Graph::newAndLoad($uri);
/** DNB returns error page if GND not found, no return code;
 * so we cannot catch an error
 * */
if (!$rdf) {
    $error = array();
    $error['error'] = "DNB: could not create rdf object";
    echo json_encode($error);
    exit;
}
$typeUri = $rdf->get($uri, "rdf:type");
$typeArr = split("#", $typeUri);
$type = $typeArr[1];
$name = $rdf->join($uri, 'gnd:preferredNameForTheSubjectHeading|' . 'gnd:preferredNameForTheSubjectHeadingSensoStricto|' . 'gnd:preferredNameForTheCorporateBody|' . 'gnd:preferredNameForTheFamily|' . 'gnd:preferredNameForThePerson|' . 'gnd:preferredNameForThePlaceOrGeographicName|' . 'gnd:preferredNameForTheWork|' . 'gnd:preferredNameForTheConferenceOrEvent');
$altname = $rdf->join($uri, 'gnd:variantNameForTheSubjectHeading|' . 'gnd:variantNameForTheSubjectHeadingSensoStricto|' . 'gnd:variantNameForTheCorporateBody|' . 'gnd:variantNameForTheFamily|' . 'gnd:variantNameForThePerson|' . 'gnd:variantNameForThePlaceOrGeographicName|' . 'gnd:variantNameForTheWork|' . 'gnd:variantNameForTheConferenceOrEvent', ', ');
$synSearch = '("' . $name . '") OR (' . $gnd . ') OR ("' . $rdf->join($uri, 'gnd:variantNameForTheSubjectHeading|' . 'gnd:variantNameForTheSubjectHeadingSensoStricto|' . 'gnd:variantNameForTheCorporateBody|' . 'gnd:variantNameForTheFamily|' . 'gnd:variantNameForThePerson|' . 'gnd:variantNameForThePlaceOrGeographicName|' . 'gnd:variantNameForTheWork|' . 'gnd:variantNameForTheConferenceOrEvent', '") OR ("') . '")';
Beispiel #19
0
      </ul>
    </nav>
  </header>


<?php 
## Add namespaces. At default easyRdf recognizes dcterms, dc, foaf, rdf, rdfs, and some others
EasyRdf_Namespace::set('madsrdf', 'http://www.loc.gov/mads/rdf/v1#');
EasyRdf_Namespace::set('bibframe', 'http://bibframe.org/vocab/');
EasyRdf_Namespace::set('gn', 'http://www.geonames.org/ontology#');
EasyRdf_Namespace::set('skos', 'http://www.w3.org/2008/05/skos#');
EasyRdf_Namespace::set('lexvo', 'http://lexvo.org/id/');
EasyRdf_Namespace::set('lexvont', 'http://lexvo.org/ontology#');
EasyRdf_Namespace::set('schema', 'http://schema.org/');
##Create preliminary resources
$graph = EasyRdf_Graph::newAndLoad('http://jacobshelby.org/examples/linkedData/Collection_001.rdf');
$base = 'http://jacobshelby.org/examples/linkedData/';
// ____ = $graph->resource($base.'____');
$collection = $graph->resource('http://jacobshelby.org/examples/linkedData/Collect_001');
?>


<main>
  <h1>Linked data catalog example</h1>
  <section class="content-box">
    <!-- metadata about the "resouce", in this case, the original book "Moby Dick, or, the Whale"-->
    <h2>Catalog record 001</h2>

  <?php 
$dump = $graph->dump('html');
print $dump;
 public function testNewAndLoad()
 {
     $this->_client->addMockOnce('GET', 'http://www.example.com/', readFixture('foaf.json'));
     $graph = EasyRdf_Graph::newAndLoad('http://www.example.com/', 'json');
     $this->assertClass('EasyRdf_Graph', $graph);
     $this->assertStringEquals('Joe Bloggs', $graph->get('http://www.example.com/joe#me', 'foaf:name'));
 }
?>
<html>
<head><title>EasyRdf Artist Info Example</title></head>
<body>
<h1>EasyRdf Artist Info Example</h1>

<?php 
echo form_tag();
echo text_field_tag('uri', 'http://www.bbc.co.uk/music/artists/70248960-cb53-4ea4-943a-edb18f7d336f.rdf', array('size' => 50));
echo submit_tag();
echo form_end_tag();
?>

<?php 
if (isset($_REQUEST['uri'])) {
    $graph = EasyRdf_Graph::newAndLoad($_REQUEST['uri']);
    $artist = $graph->primaryTopic();
}
if (isset($artist)) {
    ?>

<dl>
    <dt>Artist Name:</dt><dd><?php 
    echo $artist->get('foaf:name');
    ?>
</dd>
    <dt>Type:</dt><dd><?php 
    echo join(', ', $artist->types());
    ?>
</dd>
    <dt>Homepage:</dt><dd><?php 
Beispiel #22
0
      </ul>
    </nav>
  </header>


<?php 
## Add namespaces. At default easyRdf recognizes dcterms, dc, foaf, rdf, rdfs, and some others
EasyRdf_Namespace::set('madsrdf', 'http://www.loc.gov/mads/rdf/v1#');
EasyRdf_Namespace::set('bibframe', 'http://bibframe.org/vocab/');
EasyRdf_Namespace::set('gn', 'http://www.geonames.org/ontology#');
EasyRdf_Namespace::set('skos', 'http://www.w3.org/2008/05/skos#');
EasyRdf_Namespace::set('lexvo', 'http://lexvo.org/id/');
EasyRdf_Namespace::set('lexvont', 'http://lexvo.org/ontology#');
EasyRdf_Namespace::set('schema', 'http://schema.org/');
##Create preliminary resources
$graph = EasyRdf_Graph::newAndLoad('http://jacobshelby.org/examples/linkedData/Item_003.rdf');
$base = 'http://jacobshelby.org/examples/linkedData/';
// ____ = $graph->resource($base.'____');
/*$book = $graph->resource('http://jacobshelby.org/examples/linkedData/catalog_001');
  $language = $book->get('dcterms:language');
  $placeOfPublication = $book->get('bibframe:providerPlace');
  $placeOfPublicationResource = $placeOfPublication."about.rdf";
  $placeOfPublicationGraph = EasyRdf_Graph::newAndLoad($placeOfPublicationResource);
  $placeOfPublicationRecord = $placeOfPublicationGraph->resource($placeOfPublication);
  $type = $book->get('dcterms:type');
  $typeGraph = EasyRdf_Graph::newAndLoad('http://dublincore.org/2012/06/14/dctype.rdf');
  $typeRecord = $typeGraph->resource($type); */
?>


<main>
Beispiel #23
0
<?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&amp;ll={$ll}&amp;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>
Beispiel #24
0
      </ul>
    </nav>
  </header>


<?php 
## Add namespaces. At default easyRdf recognizes dcterms, dc, foaf, rdf, rdfs, and some others
EasyRdf_Namespace::set('madsrdf', 'http://www.loc.gov/mads/rdf/v1#');
EasyRdf_Namespace::set('bibframe', 'http://bibframe.org/vocab/');
EasyRdf_Namespace::set('gn', 'http://www.geonames.org/ontology#');
EasyRdf_Namespace::set('skos', 'http://www.w3.org/2008/05/skos#');
EasyRdf_Namespace::set('lexvo', 'http://lexvo.org/id/');
EasyRdf_Namespace::set('lexvont', 'http://lexvo.org/ontology#');
EasyRdf_Namespace::set('schema', 'http://schema.org/');
##Create preliminary resources
$graph = EasyRdf_Graph::newAndLoad('http://jacobshelby.org/examples/linkedData/FindingAid_001.rdf');
$base = 'http://jacobshelby.org/examples/linkedData/';
// ____ = $graph->resource($base.'____');
/*$book = $graph->resource('http://jacobshelby.org/examples/linkedData/catalog_001');
  $language = $book->get('dcterms:language');
  $placeOfPublication = $book->get('bibframe:providerPlace');
  $placeOfPublicationResource = $placeOfPublication."about.rdf";
  $placeOfPublicationGraph = EasyRdf_Graph::newAndLoad($placeOfPublicationResource);
  $placeOfPublicationRecord = $placeOfPublicationGraph->resource($placeOfPublication);
  $type = $book->get('dcterms:type');
  $typeGraph = EasyRdf_Graph::newAndLoad('http://dublincore.org/2012/06/14/dctype.rdf');
  $typeRecord = $typeGraph->resource($type); */
?>


<main>
 /**
  * Fetches and parses RDF from Fedora based on Drupal id.
  *
  * @param string            $id Drupal id
  *
  * @return EasyRdf_Graph    RDF from Fedora
  */
 public function findGraph($id)
 {
     // Get the uri in fedora based on drupal id.
     $resource_uri = $this->getResourceUri($id);
     if (empty($resource_uri)) {
         throw new \Exception("No resource exists associated with id: {$id}.", 404);
     }
     // Retrieve the RDF from fedora.
     $fedora_response = $this->fedora->get($resource_uri, ['headers' => ['Accept' => 'text/turtle']]);
     return \EasyRdf_Graph::newAndLoad($fedora_response->getBody(), 'text/turtle');
 }
 public function testNewAndLoadError()
 {
     $this->client->addMockOnce('GET', 'http://www.example.com/missing', 'Error text', array('status' => 404));
     try {
         $graph = EasyRdf_Graph::newAndLoad('http://www.example.com/missing', 'turtle');
         $this->fail('404 should lead to exception');
     } catch (EasyRdf_Http_Exception $e) {
         $this->assertEquals(404, $e->getCode());
         $this->assertEquals('Error text', $e->getBody());
     }
 }