allOfType() public method

Return a list of all resources loaded, with the rdf:type given. eg. $graph->allOfType( "foaf:Person" )
public allOfType ( $uri )
 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;
 }
Esempio n. 2
0
 static function getPointsOfService($q)
 {
     //if($q == '')
     //	$filter = '';
     //else
     //	$filter = "FILTER ( REGEX( ?label, '$q', 'i') || REGEX( ?poslabel, '$q', 'i') )";
     $graph = new Graphite();
     $graph->load('file:/home/opendatamap/isleofwight.rdf');
     $points = array();
     foreach ($graph->allOfType('http://purl.org/goodrelations/v1#LocationOfSalesOrServiceProvisioning') as $point) {
         if ($point->has('-http://purl.org/goodrelations/v1#availableAtOrFrom')) {
             foreach ($point->all('-http://purl.org/goodrelations/v1#availableAtOrFrom') as $offering) {
                 foreach ($offering->all('http://purl.org/goodrelations/v1#includes') as $include) {
                     $p['label'] = $include->getString('rdfs:label');
                     $p['pos'] = $point->toString();
                     $p['poslabel'] = $point->getString('rdfs:label');
                     $p['icon'] = $point->getString('http://purl.org/openorg/mapIcon');
                     if ($q == '' || preg_match(strtolower('/' . $q . '/'), strtolower($p['label'])) || preg_match(strtolower('/' . $q . '/'), strtolower($p['poslabel']))) {
                         $points[] = $p;
                     }
                 }
             }
         } else {
             $p['label'] = null;
             $p['pos'] = $point->toString();
             $p['poslabel'] = $point->getString('rdfs:label');
             $p['icon'] = $point->getString('http://purl.org/openorg/mapIcon');
             if ($q == '' || preg_match(strtolower('/' . $q . '/'), strtolower($p['poslabel']))) {
                 $points[] = $p;
             }
         }
     }
     return $points;
 }
Esempio n. 3
0
$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);
        $count++;
    }
    if (preg_match("/^\\s*\$/", $str) == 0) {
        $html .= '<span class="header" id="' . $intype . '">' . $types[$intype]['srp'] . '</span>';
        echo '<li><a href="#' . $intype . '">' . $types[$intype]['srp'] . '</a></li>';
        $html .= $str;
    }
    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);
        if ($split[1]) {
            $add[$propname] = $split[1];
        } else {
            $add[$propname] = $value;
        }
    }
    $json[] = $add;
Esempio n. 5
0
    $rdfuri = $matches[1];
    $uri = preg_replace("/rdf/", "id", $rdfuri);
    $rdf = file_get_contents($rdfuri);
    $g->addRDFXML("", $rdf);
} else {
    //	// unrecognised type - die
    //	die ("Unrecognised object");
    // OR Assume RDFXML 'till i work out how to do this properly >__<
    $g->addRDFXML("", $objsrc);
    $rdf = $objsrc;
}
// general stuff
$gres = $g->resource($uri);
$gres->loadSameAs();
$label = $gres->get("dct:title")->toString();
if ($label == "") {
    $label = "No name found";
}
foreach ($g->allOfType("foaf:Person") as $gauth) {
    $otherlinks[] = array('uri' => $gauth->uri, 'type' => 'person', 'rel' => 'http://rdf.ecs.soton.ac.uk/ontology/ecs#memberOf', 'inv' => true, 'shim' => "shims/Person.php");
}
$gsameaslist = $gres->all("owl:sameAs");
$sameas = array();
foreach ($gsameaslist as $gsameas) {
    $sameas[] = $gsameas->toString();
}
$sameas[] = $uri;
$rdfarr = array();
$rdfarr[] = $rdf;
$output = json_encode(array('label' => $label, 'type' => 'project', 'uri' => $uri, 'rdf' => $rdfarr, 'otherlinks' => $otherlinks, 'sameas' => $sameas));
echo $output;