load() public method

Load the RDF from the given URI or URL. Return the number of triples loaded.
public load ( $uri, $aliases = [], $map = [] )
 public function getTree($node, $ontology)
 {
     $filename = getcwd() . "/cache/onto-" . urlencode($ontology->url) . ".json";
     if (is_readable($filename)) {
         return json_decode(file_get_contents($filename));
     }
     $count = new PrefixCounter($ontology->prefix);
     $graph = new Graphite();
     $xml = simplexml_load_file($ontology->url);
     foreach ($xml->getNamespaces(true) as $prefix => $uri) {
         $graph->ns($prefix, stripslashes($uri));
     }
     $graph->load($ontology->url);
     $classes = $graph->allOfType("owl:Class");
     $classes = $classes->append($graph->allOfType("rdfs:Class"));
     $toplevel = $classes->except($classes->all("-rdfs:subClassOf"));
     $json = array();
     foreach ($toplevel as $class) {
         $uri = $graph->shrinkUri($class);
         $children = Ontology::getChildren($graph, $class, $count);
         $count->step();
         $json[] = array("id" => $count->value(), "text" => $uri, "iconCls" => "class", "children" => $children, "leaf" => empty($children));
     }
     file_put_contents($filename, json_encode($json));
     return $json;
 }
<?php

include_once "arc/ARC2.php";
include_once "Graphite.php";
$graph = new Graphite();
$uri = "http://data.ordnancesurvey.co.uk/id/postcodeunit/SO171BJ";
$graph->load($uri);
print $graph->resource($uri)->dump();
//print $graph->resource( $uri )->dumpText();
示例#3
0
<?php

require_once "../arc/ARC2.php";
require_once "../Graphite.php";
$graph = new Graphite();
$graph->load("http://id.ecs.soton.ac.uk/person/1248");
$me = $graph->resource("http://id.ecs.soton.ac.uk/person/1248");
print "<h1>" . $me->prettyLink() . "</h1>";
print "<p>default, built-in icons.</p>";
print "<div>" . $me->get("foaf:mbox")->prettyLink() . "</div>";
print "<div>" . $me->get("foaf:phone")->prettyLink() . "</div>";
print "<h1>" . $me->prettyLink() . "</h1>";
print '<p>The following icons by <a href="http://p.yusukekamiyamane.com/">Yusuke Kamiyamane</a>. All rights reserved. Licensed under a <a href="http://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0 License</a>.</p>';
$graph->mailtoIcon("icons/mail.png");
$graph->telIcon("icons/telephone-handset.png");
print "<div>" . $me->get("foaf:mbox")->prettyLink() . "</div>";
print "<div>" . $me->get("foaf:phone")->prettyLink() . "</div>";
示例#4
0
<?php

include_once "arc/ARC2.php";
include_once "Graphite.php";
$graph = new Graphite();
$graph->ns("uosbuilding", "http://id.southampton.ac.uk/building/");
$graph->load("uosbuilding:32");
print $graph->resource("uosbuilding:32")->label();
示例#5
0
<?php

include_once "../arc/ARC2.php";
include_once "../Graphite.php";
//error_reporting(E_ALL);
//ini_set('display_errors', '1');
$map = array("http://purl.org/dc/terms/creator" => "Creator", "http://purl.org/dc/terms/created" => "Date created", "http://purl.org/dc/terms/visits" => "Visits", "http://purl.org/dc/terms/established" => "Established", "http://purl.org/dc/terms/version" => "Version", "http://purl.org/ontology/bibo/presentedAt" => "Presented at", "http://purl.org/ontology/bibo/contributor" => "Contributor", "http://purl.org/dc/terms/analyser" => "Analyser", "http://eprints.org/ontology/downloads" => "Downloads", "http://purl.org/dc/terms/sampleSize" => "Sample size");
$uri = "http://id.ecs.soton.ac.uk/project/644";
$rdfuri = "../results.rdf";
$graph = new Graphite();
$graph->ns("eprel", "http://eprints.org/relation/");
$graph->ns("ecs", "http://rdf.ecs.soton.ac.uk/ontology/ecs#");
$graph->load($rdfuri);
// attempt to get a value from a resource
// it will return the first non-null valued element from the array, or if none can be found return the placeholder
function get_from_rdf($resource, $element_order_array, $placeholder)
{
    global $graph;
    foreach ($element_order_array as $element) {
        $value = $graph->resource($resource)->get($element);
        if ($value != "[NULL]") {
            return htmlspecialchars_decode($value);
        }
    }
    return $placeholder;
}
// get the text for the head title
function main_head()
{
    global $uri;
    global $graph;
示例#6
0
<?php

include_once "arc/ARC2.php";
include_once "Graphite.php";
$graph = new Graphite();
$graph->load("http://id.southampton.ac.uk/");
print $graph->resource("http://id.southampton.ac.uk/")->get("foaf:name");
示例#7
0
//}
$types = array('person' => array('sr' => 'Person', 'srp' => "People", 'tags' => array(0 => 'foaf:Person', 'ecs:Person')), 'paper' => array('sr' => 'Article', 'srp' => "Articles", 'tags' => array(0 => 'bibo:Article', 'bibo:AcademicArticle')), 'project' => array('sr' => 'Project', 'srp' => "Projects", 'tags' => array(0 => 'foaf:Project')), 'avdoc' => array('sr' => 'AV Document', 'srp' => "AV documents", 'tags' => array(0 => '')), 'conference' => array('sr' => 'Conference', 'srp' => "Conferences", 'tags' => array(0 => 'bibo:Conference')));
// }
$strings = array('person' => array('short' => '', 'long' => ''), 'article' => array('short' => '', 'long' => ''), 'project' => array('short' => '', 'long' => ''));
//}
require_once "Graphite.php";
require_once "arc/ARC2.php";
$g = new Graphite($nsArr);
// 	if (!is_null($url = $_GET['url'])) $g->load($url);
// 	elseif (!is_null($_REQUEST['rdf'])) foreach ($_REQUEST['rdf'] as $rdf) $g->loadRDFXML($rdf);
//  	else {
// 		echo 'document.write("Not RDF");';
// 	}
$source = "file:///var/www/d-ROC/results2.rdf";
// 	$source = "http://id.ecs.soton.ac.uk/person/1615";
$g->load($source);
echo '<ul class="floatingLinks">';
$struct = array();
$html = "";
foreach ($types as $intype => $array) {
    foreach ($array['tags'] as $type) {
        if (is_null($reslist)) {
            $reslist = $g->allOfType($type);
        } else {
            $reslist = $reslist->union($g->allOfType($type));
        }
    }
    $count = 0;
    $str = "";
    foreach ($reslist as $res) {
        $str .= renderResource($res, $intype);
header("Content-Type:application/json");
include_once "arc2/ARC2.php";
include_once "arc2/Graphite.php";
$URL = $_GET['url'];
$CLASS = $_GET['class'];
$filename = getcwd() . "/cache/inst-" . urlencode($CLASS) . "-" . urlencode($URL) . ".json";
if (is_readable($filename)) {
    print file_get_contents($filename);
    return;
}
$graph = new Graphite();
$xml = simplexml_load_file($URL);
foreach ($xml->getNamespaces(true) as $prefix => $uri) {
    $graph->ns($prefix, stripslashes($uri));
}
$graph->load($URL);
$properties = array();
if (array_key_exists('properties', $_REQUEST)) {
    $PROPS = $_GET['properties'];
    $properties = explode(",", $PROPS);
}
// Here, we grab a List of all of this type of class
$resources = $graph->allOfType($CLASS);
$json = array();
foreach ($resources as $instance) {
    $suri = $graph->shrinkURI(trim($instance));
    $add = array("id" => $suri);
    foreach ($properties as $prop) {
        $propname = trim($prop);
        $value = trim($instance->get($prop));
        $split = ARC2::splitUri($value);
示例#9
0
 static function processSouthamptonURI($uri)
 {
     $graph = new Graphite();
     $graph->load('file:/home/opendatamap/isleofwight.rdf');
     $res = $graph->resource($uri);
     echo "<div id='content'>";
     $name = $res->getString('rdfs:label');
     $icon = $res->getString('http://purl.org/openorg/mapIcon');
     echo "<h2><img class='icon' src='" . ($icon != "" ? $icon : "img/blackness.png") . "' />" . $name;
     echo "</h2>";
     if ($res->has('foaf:phone')) {
         $phone = $res->getString('foaf:phone');
         if (substr($phone, 0, 8) == 'tel:+442') {
             echo '(0' . substr($phone, 7, 2) . ') ' . substr($phone, 9, 4) . ' ' . substr($phone, 13);
         } elseif (substr($phone, 0, 7) == 'tel:+44') {
             echo '(0' . substr($phone, 7, 4) . ') ' . substr($phone, 11, 3) . ' ' . substr($phone, 14);
         } else {
             echo substr($phone, 4);
         }
         //foreach($res->all('foaf:phone') as $phone)
         //	echo $phone.'<br/>';
     }
     $allpos = array();
     foreach ($res->all('-http://purl.org/goodrelations/v1#availableAtOrFrom') as $offering) {
         foreach ($offering->all('http://purl.org/goodrelations/v1#includes') as $include) {
             if ($include->isType('http://purl.org/goodrelations/v1#ProductOrServicesSomeInstancesPlaceholder')) {
                 $p['label'] = $include->getString('rdfs:label');
                 $allpos[] = $p;
             }
         }
     }
     if (count($allpos) == 0) {
         foreach ($res->all('-http://purl.org/goodrelations/v1#availableAtOrFrom') as $offering) {
             foreach ($offering->all('http://purl.org/goodrelations/v1#includes') as $include) {
                 if ($include->isType('http://purl.org/goodrelations/v1#ProductOrService')) {
                     $p['label'] = $include->getString('rdfs:label');
                     $allpos[] = $p;
                 }
             }
         }
     }
     /*
     $allpos = sparql_get(self::$endpoint, "
     PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
     PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
     PREFIX spacerel: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>
     PREFIX org: <http://www.w3.org/ns/org#>
     PREFIX gr: <http://purl.org/goodrelations/v1#>
     
     SELECT DISTINCT ?label WHERE {
     	?o gr:availableAtOrFrom <$uri> .
     	?o gr:includes ?ps .
     	?ps a gr:ProductOrServicesSomeInstancesPlaceholder .
     	?ps rdfs:label ?label .
     } ORDER BY ?label 
     ");
     
     if(count($allpos) == 0)
     {
     	$allpos = sparql_get(self::$endpoint, "
     	PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
     	PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
     	PREFIX spacerel: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>
     	PREFIX org: <http://www.w3.org/ns/org#>
     	PREFIX gr: <http://purl.org/goodrelations/v1#>
     
     	SELECT DISTINCT ?label WHERE {
     		?o gr:availableAtOrFrom <$uri> .
     		?o gr:includes ?ps .
     		?ps a gr:ProductOrService .
     		?ps rdfs:label ?label .
     	} ORDER BY ?label 
     	");
     }
     */
     self::processOffers($allpos);
     $allopen = array();
     foreach ($res->all('http://purl.org/goodrelations/v1#hasOpeningHoursSpecification') as $time) {
         if ($time->has('http://purl.org/goodrelations/v1#validFrom')) {
             $open['start'] = $time->getString('http://purl.org/goodrelations/v1#validFrom');
         } else {
             $open['start'] = null;
         }
         if ($time->has('http://purl.org/goodrelations/v1#validThrough')) {
             $open['end'] = $time->getString('http://purl.org/goodrelations/v1#validThrough');
         } else {
             $open['end'] = null;
         }
         $open['day'] = $time->getString('http://purl.org/goodrelations/v1#hasOpeningHoursDayOfWeek');
         $open['opens'] = $time->getString('http://purl.org/goodrelations/v1#opens');
         $open['closes'] = $time->getString('http://purl.org/goodrelations/v1#closes');
         $allopen[] = $open;
     }
     /*
     $allopen = sparql_get(self::$endpoint, "
     PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#>
     PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
     PREFIX spacerel: <http://data.ordnancesurvey.co.uk/ontology/spatialrelations/>
     PREFIX org: <http://www.w3.org/ns/org#>
     PREFIX gr: <http://purl.org/goodrelations/v1#>
     
     SELECT DISTINCT * WHERE {
     	<$uri> gr:hasOpeningHoursSpecification ?time .
     	OPTIONAL { ?time gr:validFrom ?start . }
     	OPTIONAL { ?time gr:validThrough ?end . }
     	?time gr:hasOpeningHoursDayOfWeek ?day .
     	?time gr:opens ?opens .
     	?time gr:closes ?closes .
     } ORDER BY ?start ?end ?day ?opens ?closes
     ");
     */
     self::processOpeningTimes($allopen);
     if (substr($uri, 0, strlen('http://id.sown.org.uk/')) == 'http://id.sown.org.uk/') {
         self::processSownURI($uri);
     }
     echo "</div>";
     return true;
 }
示例#10
0
#!/usr/bin/php
<?php 
# this is intended to be run on the command-line, but you could run it
# via the web if you wanted.
# you'll need to change all the paths.
require_once "../arc/ARC2.php";
require_once "../Graphite.php";
$graph = new Graphite();
$graph->ns("foo", "http://example.org/foons/");
$graph->load("mydata.rdf");
$graph->freeze("mydata.rdf.graphite");
# to use this graph from a script, use
# $graph = Graphite::thaw( "mydata.rdf.graphite" );
示例#11
0
<?php

include_once "arc/ARC2.php";
include_once "Graphite.php";
$person_uri = "http://eprints.ecs.soton.ac.uk/id/person/ext-1248";
$graph = new Graphite();
# this must be a directory the webserver can write to.
//$graph->cacheDir( "/usr/local/apache/sites/ecs.soton.ac.uk/graphite/htdocs/cache" );
$graph->cacheDir("/tmp/");
$graph->load($person_uri);
$person = $graph->resource($person_uri);
print "<h3>" . $person->link() . "</h3>";
# Show sameAs properties
foreach ($person->all("owl:sameAs") as $sameas) {
    print "<div>sameAs: " . $sameas->link() . "</div>";
}
showPersonInfo("Before", $person);
# follow the sameAs links and load them into our graph
$person->loadSameAs();
showPersonInfo("After", $person);
function showPersonInfo($title, $person)
{
    print "<h4>{$title}</h4>";
    print "<div><b>name:</b> " . $person->all("foaf:name")->join(", ") . "</div>";
    print "<div><b>phone:</b> " . $person->all("foaf:phone")->prettyLink()->join(", ") . "</div>";
    print "<div><b>homepage:</b> " . $person->all("foaf:homepage")->link()->join(", ") . "</div>";
}