davvalent commited on 2023-06-08 19:20:14
Showing 1 changed files, with 89 additions and 0 deletions.
| ... | ... |
@@ -0,0 +1,89 @@ |
| 1 |
+<?php |
|
| 2 |
+ |
|
| 3 |
+/** |
|
| 4 |
+ * Négociation de contenu pour onto.qdmtl.ca : .htaccess + PHP |
|
| 5 |
+ */ |
|
| 6 |
+ |
|
| 7 |
+ require 'parse-ini.php'; |
|
| 8 |
+ require 'vendor/autoload.php'; |
|
| 9 |
+ |
|
| 10 |
+ /** |
|
| 11 |
+ * fonction use_path_to_query |
|
| 12 |
+ * Trois arguments : |
|
| 13 |
+ * requête, store, true pour var_dump() si debug nécessaire |
|
| 14 |
+ */ |
|
| 15 |
+ function use_path_to_query($q, $s, $vd = false) {
|
|
| 16 |
+ $rs = $s->query($q); |
|
| 17 |
+ |
|
| 18 |
+ if (!$s->getErrors()) {
|
|
| 19 |
+ |
|
| 20 |
+ $index_returned_query_type = [ |
|
| 21 |
+ 'construct', |
|
| 22 |
+ 'describe' |
|
| 23 |
+ ]; |
|
| 24 |
+ |
|
| 25 |
+ $result = (in_array($rs['query_type'], $index_returned_query_type)) |
|
| 26 |
+ ? $rs |
|
| 27 |
+ : $rs['result']['rows']; |
|
| 28 |
+ |
|
| 29 |
+ if ($vd) {
|
|
| 30 |
+ var_dump($result); |
|
| 31 |
+ exit(); |
|
| 32 |
+ } |
|
| 33 |
+ |
|
| 34 |
+ return $result; |
|
| 35 |
+ |
|
| 36 |
+ } else {
|
|
| 37 |
+ var_dump($s->getErrors()); |
|
| 38 |
+ exit(); |
|
| 39 |
+ } |
|
| 40 |
+ } |
|
| 41 |
+ |
|
| 42 |
+ $config = array( |
|
| 43 |
+ 'db_host' => 'localhost', |
|
| 44 |
+ 'db_name' => $infos['db_name'], |
|
| 45 |
+ 'db_user' => $infos['db_user'], |
|
| 46 |
+ 'db_pwd' => $infos['db_pwd'], |
|
| 47 |
+ 'store_name' => $infos['store_name'], |
|
| 48 |
+ 'max_errors' => 1, |
|
| 49 |
+ 'store_write_buffer' => 40000 |
|
| 50 |
+ ); |
|
| 51 |
+ |
|
| 52 |
+ /** namespace prefixes */ |
|
| 53 |
+ $ns = array( |
|
| 54 |
+ 'dcterms' => 'http://purl.org/dc/terms/', |
|
| 55 |
+ 'ecrm' => 'http://erlangen-crm.org/current/', |
|
| 56 |
+ 'geo' => 'http://www.opengis.net/ont/geosparql#', |
|
| 57 |
+ 'owl' => 'http://www.w3.org/2002/07/owl#', |
|
| 58 |
+ 'qdmtl' => 'http://onto.qdmtl.ca/', |
|
| 59 |
+ 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#', |
|
| 60 |
+ 'rico' => 'https://www.ica.org/standards/RiC/ontology#', |
|
| 61 |
+ 'schema' => 'https://schema.org/' |
|
| 62 |
+ ); |
|
| 63 |
+ $ns_config = array('ns' => $ns);
|
|
| 64 |
+ |
|
| 65 |
+ /** instantiation */ |
|
| 66 |
+ $store = ARC2::getStore($config); |
|
| 67 |
+ $rdf_xml_serializer = ARC2::getRDFXMLSerializer($ns_config); |
|
| 68 |
+ |
|
| 69 |
+// $store->createDBCon(); |
|
| 70 |
+ |
|
| 71 |
+ if (!$store->isSetUp()) {
|
|
| 72 |
+ $store->setUp(); |
|
| 73 |
+ } |
|
| 74 |
+ |
|
| 75 |
+ $q = 'DESCRIBE <http://onto.qdmtl.ca>'; |
|
| 76 |
+ |
|
| 77 |
+ $triples = use_path_to_query($q, $store); |
|
| 78 |
+ |
|
| 79 |
+ if (!$triples['result']) {
|
|
| 80 |
+ echo "SPARQL query returned 0 result"; |
|
| 81 |
+ exit(); |
|
| 82 |
+ } |
|
| 83 |
+ |
|
| 84 |
+ /** RDF/XML */ |
|
| 85 |
+ $rdf_xml_serialization = $rdf_xml_serializer->getSerializedIndex($triples['result']); |
|
| 86 |
+ header('Content-type: text/xml');
|
|
| 87 |
+ echo $rdf_xml_serialization; |
|
| 88 |
+ |
|
| 89 |
+?> |
|
| 0 | 90 |
\ No newline at end of file |
| 1 | 91 |