Something went wrong on our end
-
alangrafu authored
* Back to "first" instead of "f" to increase readability * default views and models are now rdfs:Resource * 'use_external_uris' renamed to 'mirror_external_uris' to increase readability * When mirroring URIs, LODSPeaKr will include two triples using (owl:sameAs and con:prerredUri) from mirrored URI to original one
alangrafu authored* Back to "first" instead of "f" to increase readability * default views and models are now rdfs:Resource * 'use_external_uris' renamed to 'mirror_external_uris' to increase readability * When mirroring URIs, LODSPeaKr will include two triples using (owl:sameAs and con:prerredUri) from mirrored URI to original one
Queries.php 1.87 KiB
<?
class Queries{
public static function uriExist($uri, $e){
$q = "SELECT * WHERE{
{<$uri> ?p1 ?o1}
UNION
{?s1 <$uri> ?o2}
UNION
{?s2 ?p2 <$uri>}
}LIMIT 1";
$r = $e->query($q);
if(sizeof($r['results']['bindings'])>0){
return true;
}
return false;
}
public static function getClass($uri, $e){
$q = "SELECT DISTINCT ?class ?inst WHERE{
{
<$uri> a ?class .
}UNION{
?inst a <$uri> .
}
}";
try{
$r = $e->query($q);
}catch (Exception $ex){
echo $ex->getMessage();
}
$result = array();
if(sizeof($r['results']['bindings']) == 0){
return 'http://www.w3.org/2000/01/rdf-schema#Resource'; //default value if no type is present
}
foreach($r['results']['bindings'] as $v){
$result[]= $v['class']['value'];
}
return $result;
}
public static function getMetadata($uri, $format, $e){
global $conf;
$q = <<<QUERY
SELECT uri, doc, format FROM document WHERE
(uri = "$uri" AND format = "$format") OR doc = "$uri"
LIMIT 1
QUERY;
$r = $e->query($q);
if(sizeof($r) > 0){
$u = $r[0]['uri'];
$p = $r[0]['doc'];
$f = $r[0]['format'];
return array($u, $p, $f);
}else{
return NULL;
}
}
public static function createPage($uri, $localUri, $contentType, $e){
global $conf;
$ext = 'html';
$inserts = "";
foreach($conf['http_accept'] as $extension => $f){
$page = $localUri.$conf['extension_connector'].$extension;
foreach($f as $v){
if($contentType == $v){
$returnPage = $localUri.$conf['extension_connector'].$extension;
}
if($inserts != ""){
$inserts .= "UNION ";
}
$inserts .= "SELECT '$uri', '$page', '$v' \n";
if($v == $contentType){
$ext = $extension;
}
}
}
$q = <<<QUERY
INSERT INTO document (uri, doc, format) $inserts
QUERY;
$r = $e->write($q);
return $returnPage;
}
}
?>