git.ntnlv.ca
Repositories
Help
Report an Issue
qdmtl-ts.git
Code
Commits
Branches
Tags
Search
Tree:
4f8aece
Branches
Tags
prod
qdmtl-ts.git
data.php
Afficher sérialisation XML
davvalent
commited
4f8aece
at 2022-05-18 14:44:17
data.php
Blame
History
Raw
<?php // URL rewriting // http://127.0.0.1/~david/dev-web/qdmtl-triple-store/Batiment/1373-1377-de-la-Gauchetiere-Est // http://127\.0\.0\.1/~david/dev\-web/qdmtl\-triple\-store/([A-Z][a-z]+/.+) if (!isset($_GET['path'])) { header('Location: ./'); header('HTTP/1.1 301 Moved Permanently'); exit(); } require 'parse-ini.php'; require 'vendor/autoload.php'; //Trois arguments : // requête, store, true pour var_dump() si debug nécessaire function use_path_to_query($q, $s, $vd = false) { $rs = $s->query($q); if (!$s->getErrors()) { $index_returned_query_type = [ 'construct', 'describe' ]; $result = (in_array($rs['query_type'], $index_returned_query_type)) ? $rs : $rs['result']['rows']; if ($vd) var_dump($result); return $result; } else { var_dump($s->getErrors()); exit(); } } $config = array( 'db_host' => 'localhost', 'db_name' => $infos['db_name'], 'db_user' => $infos['db_user'], 'db_pwd' => $infos['db_pwd'], 'store_name' => $infos['store_name'], 'max_errors' => 1, 'store_write_buffer' => 40000 ); /* namespace prefixes */ $ns = array( 'ecrm' => 'http://erlangen-crm.org/current/', 'geo' => 'http://www.opengis.net/ont/geosparql#', 'owl' => 'http://www.w3.org/2002/07/owl#', 'qdmtl' => 'http://onto.qdmtl.ca/', 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#', 'rico' => 'https://www.ica.org/standards/RiC/ontology#' ); $ns_config = array('ns' => $ns); /* instantiation */ $store = ARC2::getStore($config); $ser = ARC2::getRDFXMLSerializer($ns_config); // $store->createDBCon(); if (!$store->isSetUp()) { $store->setUp(); } $path = $_GET["path"]; // vérifier si objet de owl:sameAs pour traduction $q = ' PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX qdmtld: <http://data.qdmtl.ca/> SELECT ?s WHERE { ?s owl:sameAs qdmtld:' . $path . ' . } '; $has_sameAs = use_path_to_query($q, $store); preg_match('/[A-Z][a-z]+\/(.+)/', $path, $chunked_path); foreach ($has_sameAs as $sameAs) { preg_match('/http:\/\/data\.qdmtl\.ca\/([A-Z][a-z]+\/)(.+)/', $sameAs['s'], $chunked_uri_path); if ($chunked_path[1] == $chunked_uri_path[2]) $path = $chunked_uri_path[1] . $chunked_uri_path[2]; } $q = ' PREFIX qdmtld: <http://data.qdmtl.ca/> DESCRIBE qdmtld:' . $path ; $triples = use_path_to_query($q, $store); $doc = $ser->getSerializedIndex($triples['result']); header('Content-type: text/xml'); echo $doc; ?>