本文整理汇总了PHP中ARC2::getRemoteStore方法的典型用法代码示例。如果您正苦于以下问题:PHP ARC2::getRemoteStore方法的具体用法?PHP ARC2::getRemoteStore怎么用?PHP ARC2::getRemoteStore使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ARC2
的用法示例。
在下文中一共展示了ARC2::getRemoteStore方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor of FourStore_StorePlus
* @param string $endpoint : url of endpoint, example : http://localhost:8080/sparql
* @param boolean $readOnly : true by default, put false to write in the triplestore
* @param boolean $debug : false by default, set debug to true in order to get usefull output
* @access public
*/
public function __construct($endpoint, $readOnly = true, $debug = false)
{
$this->_debug = $debug;
$this->_endpoint = $endpoint;
$this->_readOnly = $readOnly;
$this->_config = array('remote_store_endpoint' => $endpoint);
$this->_arc2_RemoteStore = @ARC2::getRemoteStore($this->_config);
}
示例2: query
public static function query($query)
{
$dbpconfig = array("remote_store_endpoint" => "http://localhost:8000/sparql/");
$store = ARC2::getRemoteStore($dbpconfig);
$query = $query;
$rows = $store->query($query, 'rows');
/* execute the query */
return $rows;
}
示例3: render
function render($context, $stream)
{
global $dbh;
global $class_path;
$query_stream = new StreamWriter();
$this->sparql_query->render($context, $query_stream);
$query = $query_stream->close();
require_once "{$class_path}/rdf/arc2/ARC2.php";
$config = array('remote_store_endpoint' => $this->endpoint, 'remote_store_timeout' => 10);
$store = ARC2::getRemoteStore($config);
$context->set($this->struct_name, $store->query($query, 'rows'));
}
示例4: get_datas
public function get_datas()
{
$datas = array();
$selector = $this->get_selected_selector();
$this->set_module_class_name("cms_module_sparql");
if ($selector->get_value()) {
//la config ARC2 varie en fonction de l'origine du server SPARL
$selector_config = new $this->managed_datas['stores'][$selector->get_value()]['selector']($this->managed_datas['stores'][$selector->get_value()]['selector_id']);
$config = array();
switch ($this->managed_datas['stores'][$selector->get_value()]['selector']) {
case "cms_module_sparql_selector_endpoint":
$config = array('remote_store_endpoint' => $selector_config->get_value(), 'remote_store_timeout' => 15);
$store = ARC2::getRemoteStore($config);
break;
}
if ($this->parameters['query']) {
$querydatas = array('get_vars' => $_GET, 'post_vars' => $_POST);
try {
$query = H2o::parseString($this->parameters['query'])->render($querydatas);
$rows = $store->query($query, 'rows');
if (!$rows) {
$this->debug("Execution failed : " . $query);
$errors = $store->getErrors();
foreach ($errors as $error) {
$this->debug(utf8_decode($error));
}
} else {
// $this->charset_normalize($rows, "utf-8");
}
} catch (Exception $e) {
$rows = array();
}
}
}
$this->debug($query);
$datas['result'] = $rows;
return $datas;
}
示例5: noticeInfos
function noticeInfos($notice_id, $sparql_end_point)
{
global $lang, $charset;
//On va rechercher l'isbn si il existe....
$requete = "select code from notices where notice_id={$notice_id}";
$resultat = mysql_query($requete);
if (mysql_num_rows($resultat)) {
$isbn = mysql_result($resultat, 0, 0);
} else {
$isbn = "";
}
if ($isbn) {
//On y va !
$config = array('remote_store_endpoint' => $sparql_end_point, 'remote_store_timeout' => 10);
$store = ARC2::getRemoteStore($config);
$sparql = "prefix bnf-onto: <http://data.bnf.fr/ontology/>\n\t\t\t\tprefix rdarelationships: <http://rdvocab.info/RDARelationshipsWEMI/>\n\t\t\t\tSELECT ?oeuvre WHERE {\n\t\t\t\t ?manifestation bnf-onto:ISBN '{$isbn}' .\n\t\t\t\t ?manifestation rdarelationships:workManifested ?oeuvre \n\t\t\t\t}";
try {
$rows = $store->query($sparql, 'rows');
} catch (Exception $e) {
$rows = array();
}
if ($rows[0]["oeuvre"]) {
$oeuvre = $rows[0]["oeuvre"];
$sparql = "prefix skos: <http://www.w3.org/2004/02/skos/core#>\n\t\t\t\t\tprefix foaf: <http://xmlns.com/foaf/0.1/>\n\t\t\t\t\tprefix dc: <http://purl.org/dc/terms/>\n\t\t\t\t\tprefix bnf-onto: <http://data.bnf.fr/ontology/>\n\t\t\t\t\tprefix rdarelationships: <http://rdvocab.info/RDARelationshipsWEMI/>\n\t\t\t\t\tprefix rdagroup1Elements: <http://RDVocab.info/Elements/>\n\t\t\t\t\tSELECT * WHERE {\n\t\t\t\t\t <{$oeuvre}> rdfs:label ?titre .\n\t\t\t\t\t OPTIONAL { <{$oeuvre}> dc:date ?date } .\n\t\t\t\t\t OPTIONAL { <{$oeuvre}> foaf:depiction ?vignette } .\n\t\t\t\t\t OPTIONAL { <{$oeuvre}> dc:description ?description } .\n\t\t\t\t\t OPTIONAL { <{$oeuvre}> bnf-onto:subject ?sujet } .\n\t\t\t\t\t OPTIONAL { <{$oeuvre}> dc:creator ?auteur .\n\t\t\t\t\t ?auteur_concept foaf:focus ?auteur .\n\t\t\t\t\t ?auteur_concept skos:prefLabel ?auteur_isbd .\n\t\t\t\t\t } .\n\t\t\t\t\t OPTIONAL { <{$oeuvre}> rdagroup1Elements:placeOfOriginOfTheWork ?lieu }\n\t\t\t\t\t}";
try {
$rows = $store->query($sparql, 'rows');
} catch (Exception $e) {
$rows = array();
}
$rows = array_uft8_decode($rows);
$template = "\n\t\t\t\t\t\t<h3>{{result.0.titre}}<div style='float:right'><a href='{$oeuvre}' target='_blank'><img src='http://data.bnf.fr/data/85bec01e1d53356985bccf3036a2bb49/logo-data.gif' style='max-height:20px'/></a></div></h3>\n\t\t\t\t\t\t\t\t\t<br />\n\t\t\t\t\t\t\t\t\t<h3>Détail de l'oeuvre (BNF)</h3>\n\t\t\t\t\t\t{% if result.0.vignette %}\n\t\t\t\t\t\t\t<table>\n\t\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t\t<td><img src='{{result.0.vignette}}' height='150px'/></td>\n\t\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t{% endif %}\n\t\t\t\t\t\t<table>\n\t\t\t\t\t\t\t<tr><td style='background:#EEEEEE'>Date</td><td>{{result.0.date}}</td></tr>\n\t\t\t\t\t\t\t<tr><td style='background:#EEEEEE'>Sujet</td><td>{{result.0.sujet}}</td></tr>\n\t\t\t\t\t\t\t<tr><td style='background:#EEEEEE'>Auteur</td><td><a href='index.php?uri={{result.0.auteur_concept}}&lvl=cmspage&pageid=12'>{{result.0.auteur_isbd}}</a></td></tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t\t{% if result.0.vignette %}\n\t\t\t\t\t\t\t\t</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t </table>\n\t\t\t\t\t\t{% endif %}\n\t\t\t\t\t\t<br/>\t\n\t\t\t\t\t\t<h4>{{result.0.description}}</h4>\t\t\t\n\t\t\t\t";
$html_to_return .= H2o::parseString($template)->render(array("result" => $rows));
//Récupération des exemplaires de Gallica
$sparql = "prefix skos: <http://www.w3.org/2004/02/skos/core#>\n\t\t\t\t\tprefix foaf: <http://xmlns.com/foaf/0.1/>\n\t\t\t\t\tprefix dc: <http://purl.org/dc/terms/>\n\t\t\t\t\tprefix bnf-onto: <http://data.bnf.fr/ontology/>\n\t\t\t\t\tprefix rdarelationships: <http://rdvocab.info/RDARelationshipsWEMI/>\n\t\t\t\t\tprefix rdagroup1Elements: <http://RDVocab.info/Elements/>\n\t\t\t\t\tSELECT * WHERE {\n\t\t\t\t\t\t?manifestation rdarelationships:workManifested <{$oeuvre}> .\n\t\t\t\t\t\tOPTIONAL { ?manifestation rdarelationships:electronicReproduction ?gallica } .\n\t\t\t\t\t\tOPTIONAL { ?manifestation bnf-onto:ISBN ?isbn } .\n\t\t\t\t\t\tOPTIONAL { <{$oeuvre}> foaf:depiction ?vignette } .\n\t\t\t\t\t\tOPTIONAL { ?manifestation dc:date ?date } .\n\t\t\t\t\t\tOPTIONAL { ?manifestation rdagroup1Elements:publishersName ?publisher } .\n\t\t\t\t\t\tOPTIONAL { ?manifestation rdagroup1Elements:note ?note } .\n\t\t\t\t\t\tOPTIONAL { ?manifestation rdagroup1Elements:placeOfPublication ?place } .\n\t\t\t\t\t\tOPTIONAL { ?manifestation rdagroup1Elements:dateOfCapture ?numerisele } .\n\t\t\t\t\t} group by ?manifestation order by ?date\n\t\t\t\t";
try {
$rows = $store->query($sparql, 'rows');
} catch (Exception $e) {
$rows = array();
}
$rows = array_uft8_decode($rows);
$template = "\n\t\t\t\t\t\t<h3>Editions numérisées dans Gallica</h3><br/>\n\t\t\t\t\t\t<table>\n\t\t\t\t\t\t{% for record in result %}\n\t\t\t\t\t\t\t{% if record.gallica %}\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td><a href='{{record.gallica}}' target='_blank'><img height='40px' src='http://gallica.bnf.fr/images/dynamic/perso/logo_gallica.png' /></a></td>\n\t\t\t\t\t\t\t\t<td><a href='{{record.gallica}}' target='_blank'>Edition : {{record.date}} par {{record.publisher}} à {{record.place}}</a></td>\n\t\t\t\t\t\t\t\t<td>{{record.note}}</td>\n\t\t\t\t\t\t\t\t<td>{{record.numerisele}}</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t{% endif %}\n\t\t\t\t\t\t{% endfor %}\n\t\t\t\t\t\t</table>\n\t\t\t\t";
$html_to_return .= H2o::parseString($template)->render(array("result" => $rows));
$template = "\n\t\t\t\t\t\t<h3>Editions dans la bibliothèque</h3><br/>\n\t\t\t\t\t\t<table>\n\t\t\t\t\t\t{% for record in result %}\n\t\t\t\t\t\t\t{% if record.isbn %}\n\t\t\t\t\t\t\t\t{% sqlvalue i_catalog %}\n\t\t\t\t\t\t\t\t\tselect count(expl_id) as nb,notice_id from exemplaires join notices on expl_notice=notice_id where code='{{record.isbn}}' group by notice_id\n\t\t\t\t\t\t\t\t{% endsqlvalue %}\n\t\t\t\t\t\t\t\t{% if i_catalog.0.nb %}\n\t\t\t\t\t\t\t\t\t<tr style='height:70px'>\n\t\t\t\t\t\t\t\t\t\t<td><a href='index.php?lvl=notice_display&id={{i_catalog.0.notice_id}}' target='_blank'>{% if record.vignette %}<img src='{{record.vignette}}' height='70px'/>{% else %} {% endif %}</a></td>\n\t\t\t\t\t\t\t\t\t\t<td><a href='index.php?lvl=notice_display&id={{i_catalog.0.notice_id}}' target='_blank'>Edition : {{record.date}} par {{record.publisher}} à {{record.place}}</a></td>\n\t\t\t\t\t\t\t\t\t\t<td>{{record.note}}</td>\n\t\t\t\t\t\t\t\t\t\t<td><a href='index.php?lvl=notice_display&id={{i_catalog.0.notice_id}}' target='_blank'>{{i_catalog.0.nb}} exemplaires disponible(s)</a></td>\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t{% endif %}\n\t\t\t\t\t\t\t{% endif %}\n\t\t\t\t\t\t{% endfor %}\n\t\t\t\t\t\t</table>\n\t\t\t\t";
try {
$html_to_return .= H2o::parseString($template)->render(array("result" => $rows));
} catch (Exception $e) {
$html_to_return .= highlight_string(print_r($e, true), true);
}
}
}
return $html_to_return;
}
示例6: array
@extends("layout")
@section("content")
<?php
include_once "../../arc2-master/ARC2.php";
$configLocal = array('db_name' => 'rdfdemo', 'db_user' => 'root', 'db_pwd' => '', 'store_name' => 'arc_rdf', 'max_errors' => 100);
$storeLocal = ARC2::getStore($configLocal);
if (!$storeLocal->isSetUp()) {
$storeLocal->setUp();
}
$config = array('remote_store_endpoint' => 'http://dbpedia.org/sparql');
$store = ARC2::getRemoteStore($config);
$query = '
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX : <http://dbpedia.org/resource/>
PREFIX dbpedia2: <http://dbpedia.org/property/>
PREFIX dbpedia: <http://dbpedia.org/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX category: <http://dbpedia.org/resource/Category:>
SELECT DISTINCT *
WHERE {{?x dcterms:subject category:Middle-earth_realms}
UNION {?x dcterms:subject category:Middle-earth_castles_and_fortresses}
UNION {?x dcterms:subject category:Middle-earth_races}
UNION {?x dcterms:subject category:Middle-earth_Orcs}
示例7: tu_enrichment
static function tu_enrichment($id)
{
global $dbh;
$requete = "select tu_databnf_uri from titres_uniformes where tu_id={$id}";
$resultat = pmb_mysql_query($requete, $dbh);
if ($resultat && pmb_mysql_num_rows($resultat, $dbh)) {
$uri = pmb_mysql_result($resultat, 0, 0, $dbh);
} else {
$uri = "";
}
if ($uri) {
$configbnf = array('remote_store_endpoint' => 'http://data.bnf.fr/sparql');
$storebnf = ARC2::getRemoteStore($configbnf);
$sparql = "\n\t\t\tPREFIX dc: <http://purl.org/dc/terms/>\n\t\t\tPREFIX rdarelationships: <http://rdvocab.info/RDARelationshipsWEMI/>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\tSELECT min(?gallica) as ?gallica2 ?title ?date ?editeur WHERE {\n\t\t\t ?manifestation rdarelationships:workManifested <" . $uri . ">.\n\t\t\t ?manifestation rdarelationships:electronicReproduction ?gallica.\n\t\t\t ?manifestation dc:title ?title.\n\t\t\t OPTIONAL { ?manifestation dc:date ?date.}\n\t\t\t OPTIONAL { ?manifestation dc:publisher ?editeur.}\n\t\t\t} group by ?title ?date ?editeur";
$ret = false;
$rows = $storebnf->query($sparql, 'rows');
// On vérifie qu'il n'y a pas d'erreur sinon on stoppe le programme et on renvoi une chaine vide
$err = $storebnf->getErrors();
$tr = array();
if (!$err) {
foreach ($rows as $row) {
$t = array();
$t["uri_gallica"] = $row["gallica2"];
$t["titre"] = $row["title"];
$t["date"] = $row["date"];
$t["editeur"] = $row["editeur"];
$t["uri_gallica"] = $row["gallica2"];
$tr[] = $t;
}
}
$tr = encoding_normalize::charset_normalize($tr, "utf-8");
//Stockage du tableau
$requete = "update titres_uniformes set tu_enrichment='" . addslashes(serialize($tr)) . "', tu_enrichment_last_update=now() where tu_id={$id}";
pmb_mysql_query($requete, $dbh);
}
}
示例8: getAutomaticTu
static function getAutomaticTu($notice)
{
global $dbh, $charset, $opac_enrichment_bnf_sparql;
if (!$opac_enrichment_bnf_sparql) {
return 0;
}
$requete = "select code, responsability_author from notices left join responsability on (responsability_notice={$notice} and responsability_type=0)\n\t\t\tleft join notices_titres_uniformes on notice_id=ntu_num_notice where notice_id={$notice} and ntu_num_notice is null";
$resultat = pmb_mysql_query($requete, $dbh);
if (pmb_mysql_num_rows($resultat, $dbh)) {
$code = pmb_mysql_result($resultat, 0, 0, $dbh);
$id_author = pmb_mysql_result($resultat, 0, 1, $dbh);
} else {
$code = "";
}
$id_tu = 0;
if (isISBN($code)) {
$uri = titre_uniforme::get_data_bnf_uri($code);
if ($uri) {
//Recherche du titre uniforme déjà existant ?
$requete = "select tu_id from titres_uniformes where tu_databnf_uri='" . addslashes($uri) . "'";
$resultat = pmb_mysql_query($requete, $dbh);
if (pmb_mysql_num_rows($resultat, $dbh)) {
$id_tu = pmb_mysql_result($resultat, 0, 0, $dbh);
} else {
//Interrogation de data.bnf pour obtenir les infos !
$configbnf = array('remote_store_endpoint' => 'http://data.bnf.fr/sparql');
$storebnf = ARC2::getRemoteStore($configbnf);
$sparql = "\n\t\t\t\t\t\tPREFIX dc: <http://purl.org/dc/terms/>\n\t\t\t\t\t\t\t\t\t\t\n\t\t\t\t\t\tSELECT ?title ?date ?description WHERE {\n\t\t\t\t\t\t <" . $uri . "> dc:title ?title.\n\t\t\t\t\t\t OPTIONAL { <" . $uri . "> dc:date ?date. }\n\t\t\t\t\t\t OPTIONAL { <" . $uri . "> dc:description ?description. }\n\t\t\t\t\t\t}";
$rows = $storebnf->query($sparql, 'rows');
// On vérifie qu'il n'y a pas d'erreur sinon on stoppe le programme et on renvoi une chaine vide
$err = $storebnf->getErrors();
if (!$err) {
$value = array("name" => encoding_normalize::charset_normalize($rows[0]['title'], "utf-8"), "num_author" => $id_author, "date" => encoding_normalize::charset_normalize($rows[0]['date'], "utf-8"), "comment" => encoding_normalize::charset_normalize($rows[0]['description'], "utf-8"), "databnf_uri" => $uri);
$id_tu = titre_uniforme::import($value);
}
}
}
}
if ($id_tu) {
$titres_uniformes = array(array("num_tu" => $id_tu));
$ntu = new tu_notice($notice);
$ntu->update($titres_uniformes);
}
return $id_tu;
}
示例9: author_enrichment
static function author_enrichment($id)
{
global $opac_enrichment_bnf_sparql;
global $lang;
global $charset;
if ($opac_enrichment_bnf_sparql) {
// definition des endpoints databnf et dbpedia
$configbnf = array('remote_store_endpoint' => 'http://data.bnf.fr/sparql');
$storebnf = ARC2::getRemoteStore($configbnf);
$configdbp = array('remote_store_endpoint' => 'http://dbpedia.org/sparql');
$storedbp = ARC2::getRemoteStore($configdbp);
// verifier la date de author_enrichment_last_update => if(self)
$aut_id_bnf = self::get_id_bnf($id);
// si l'auteur est dans la base on récupère son uri bnf...
if ($aut_id_bnf != "") {
$sparql = "\n\t\t\t\t\t\tPREFIX skos: <http://www.w3.org/2004/02/skos/core#>\n\t\t\t\t\t\tPREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n\t\t\t\t\t\tPREFIX bnf-onto: <http://data.bnf.fr/ontology/bnf-onto/>\n\t\t\t\t\t\tSELECT distinct ?author WHERE {\n\t\t\t\t\t\t?author rdf:type skos:Concept .\n\t\t\t\t\t\t?author bnf-onto:FRBNF {$aut_id_bnf}\n\t\t\t\t\t}";
$rows = $storebnf->query($sparql, 'rows');
// On vérifie qu'il n'y a pas d'erreur sinon on stoppe le programme et on renvoi une chaine vide
$err = $storebnf->getErrors();
if ($err) {
return;
}
}
// definition de l'uri bnf
if ($rows[0]["author"]) {
$uri_bnf = $rows[0]["author"];
$enrichment['links']['uri_bnf'] = $uri_bnf;
// ... ainsi que son uri dbpedia si elle existe
$sparql = "\n\t\t\t\t\t\tPREFIX rdagroup2elements: <http://rdvocab.info/ElementsGr2/>\n\t\t\t\t\t\tPREFIX owl:<http://www.w3.org/2002/07/owl#>\n\t\t\t\t\t\tPREFIX foaf: <http://xmlns.com/foaf/0.1/>\n\t\t\t\t\t\tSELECT ?dbpedia WHERE{\n\t\t\t\t\t\t<{$uri_bnf}> foaf:focus ?author.\n\t\t\t\t\t\tOPTIONAL {?author owl:sameAs ?dbpedia.\n\t\t\t\t\t\t\tFILTER regex(str(?dbpedia), 'http://dbpedia', 'i')}.\n\t\t\t\t\t}";
try {
$rows = $storebnf->query($sparql, 'rows');
} catch (Exception $e) {
$rows = array();
}
if ($rows[0]["dbpedia"]) {
$sub_dbp_uri = substr($rows[0]["dbpedia"], 28);
$uri_dbpedia = "http://dbpedia.org/resource/" . rawurlencode($sub_dbp_uri);
$enrichment['links']['uri_dbpedia'] = $uri_dbpedia;
}
}
// debut de la requete d'enrichissement
if ($uri_bnf != "") {
// recuperation des infos biographiques bnf
$sparql = "\n\t\t\t\t\t\tPREFIX foaf: <http://xmlns.com/foaf/0.1/>\n\t\t\t\t\t\tPREFIX rdagroup2elements: <http://rdvocab.info/ElementsGr2/>\n\t\t\t\t\t\tPREFIX skos: <http://www.w3.org/2004/02/skos/core#>\n\t\t\t\t\t\tPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\t\t\t\t\t\tPREFIX bnf-onto: <http://data.bnf.fr/ontology/bnf-onto/>\n\t\t\t\t\t\tSELECT * WHERE {\n\t\t\t\t\t\t\t<{$uri_bnf}> foaf:focus ?person .\n\t\t\t\t\t\t\t<{$uri_bnf}> skos:prefLabel ?isbd .\n\t\t\t\t\t\t\t?person foaf:page ?page .\n\t\t\t\t\t\t\tOPTIONAL {\n\t\t\t\t\t\t\t\t?person rdagroup2elements:biographicalInformation ?biography\n\t\t\t\t\t\t\t}.\n\t\t\t\t\t\t\tOPTIONAL {\n\t\t\t\t\t\t\t\t?person rdagroup2elements:dateOfBirth ?birthdate.\n\t\t\t\t\t\t\t\t?birthdate rdfs:label ?birth.\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tOPTIONAL {?person bnf-onto:firstYear ?birthfirst.}\n\t\t\t\t\t\t\tOPTIONAL {?person rdagroup2elements:placeOfBirth ?birthplace .}\n\t\t\t\t\t\t\tOPTIONAL {\n\t\t\t\t\t\t\t\t?person rdagroup2elements:dateOfDeath ?deathdate .\n\t\t\t\t\t\t\t\t?deathdate rdfs:label ?death.\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tOPTIONAL {?person rdagroup2elements:placeOfDeath ?deathplace .}\n\t\t\t\t\t\t}";
try {
$rows = $storebnf->query($sparql, 'rows');
} catch (Exception $e) {
$rows = array();
}
if ($rows[0]['birth']) {
$birthdate = $rows[0]['birth'];
} else {
if ($rows[0]['birthfirst']) {
$birthdate = $rows[0]['birthfirst'];
} else {
$birthdate = "";
}
}
$enrichment['bio'] = array('isbd' => $rows[0]['isbd'], 'biography_bnf' => $rows[0]['biography'], 'birthdate' => $birthdate, 'birthplace' => $rows[0]['birthplace'], 'deathdate' => $rows[0]['death'], 'deathplace' => $rows[0]['deathplace']);
// fin bio bnf
// vignettes bnf
$sparql = "\n\t\t\t\t\t\t\tPREFIX foaf: <http://xmlns.com/foaf/0.1/>\n\t\t\t\t\t\t\tPREFIX dc: <http://purl.org/dc/elements/1.1/>\n\t\t\t\t\t\t\tPREFIX dcterm: <http://purl.org/dc/terms/>\n\t\t\t\t\t\t\tSELECT * WHERE {\n\t\t\t\t\t\t\t\t<{$uri_bnf}> foaf:focus ?person .\n\t\t\t\t\t\t\t\t?person foaf:depiction ?url .\n\t\t\t\t\t\t\t}";
try {
$rows = $storebnf->query($sparql, 'rows');
} catch (Exception $e) {
$rows = array();
}
foreach ($rows as $row) {
$depictions[] = $row['url'];
}
$enrichment['depictions']['depictions_bnf'] = $depictions;
// biblio bnf
$sparql = "\n\t\t\t\t\t\t\tPREFIX foaf: <http://xmlns.com/foaf/0.1/>\n\t\t\t\t\t\t\tPREFIX dcterms: <http://purl.org/dc/terms/>\n\t\t\t\t\t\t\tPREFIX rdarelationships: <http://rdvocab.info/RDARelationshipsWEMI/>\n\t\t\t\t\t\t\tSELECT ?work ?date ?dates ?work_concept ?title MIN(?minUrl) AS ?url MIN(?minGallica) AS ?gallica WHERE {\n\t\t\t\t\t\t\t\t<{$uri_bnf}> foaf:focus ?person .\n\t\t\t\t\t\t\t\t?work dcterms:creator ?person .\n\t\t\t\t\t\t\t\tOPTIONAL { ?work dcterms:date ?date } .\n\t\t\t\t\t\t\t\tOPTIONAL { ?work <http://rdvocab.info/Elements/dateOfWork> ?dates } .\n\t\t\t\t\t\t\t\t?work_concept foaf:focus ?work .\n\t\t\t\t\t\t\t\t?work dcterms:title ?title .\n\t\t\t\t\t\t\t\tOPTIONAL{?work foaf:depiction ?minUrl .}\n\t\t\t\t\t\t\t\tOPTIONAL{\n\t\t\t\t\t\t\t\t\t?manifestation rdarelationships:workManifested ?work .\n\t\t\t\t\t\t\t\t\t?manifestation rdarelationships:electronicReproduction ?minGallica .\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} order by ?dates";
try {
$rows = $storebnf->query($sparql, 'rows');
} catch (Exception $e) {
$rows = array();
}
if ($rows[0]['work']) {
foreach ($rows as $row) {
$tab_isbn = array();
$sparql = "\n\t\t\t\t\t\t\t\tPREFIX rdarelationships: <http://rdvocab.info/RDARelationshipsWEMI/>\n\t\t\t\t\t\t\t\tPREFIX bnf-onto: <http://data.bnf.fr/ontology/bnf-onto/>\n\t\t\t\t\t\t\t\tSELECT distinct ?isbn WHERE {\n\t\t\t\t\t\t\t\t\t?manifestation rdarelationships:workManifested <" . $row['work'] . ">.\n\t\t\t\t\t\t\t\t\t?manifestation bnf-onto:isbn ?isbn\n\t\t\t\t\t\t\t\t}order by ?isbn";
try {
$isbns = $storebnf->query($sparql, 'rows');
} catch (Exception $e) {
$isbns = array();
}
foreach ($isbns as $isbn) {
$isbn['isbn'] = formatISBN($isbn['isbn']);
$tab_isbn[] = "'" . $isbn['isbn'] . "'";
}
$aut_works[] = array('title' => $row['title'], 'uri_work' => $row['work'], 'date' => $row['date'], 'work_concept' => $row['work_concept'], 'url' => $row['url'], 'gallica' => $row['gallica'], 'tab_isbn' => $tab_isbn);
}
$enrichment['biblio'] = $aut_works;
}
}
// si uri dbpedia on recherche la bio dbpedia et l'image
if ($uri_dbpedia != "") {
$langue = substr($lang, 0, 2);
$sparqldbp = "\n\t\t\t\t\t\tPREFIX dbpedia-owl:<http://dbpedia.org/ontology/>\n\t\t\t\t\t\tSELECT ?comment ?image WHERE{\n\t\t\t\t\t\t\t<{$uri_dbpedia}> dbpedia-owl:abstract ?comment FILTER langMatches( lang(?comment), '" . $langue . "' ).\n\t\t\t\t\t\t\tOPTIONAL {<{$uri_dbpedia}> dbpedia-owl:thumbnail ?image} .\n\t\t\t\t\t\t}";
//.........这里部分代码省略.........
示例10: array
<?php
/* Include ARC2 classes. */
include_once "arc/ARC2.php";
/* Configure the app to use DBPedia. */
$dbpconfig = array("remote_store_endpoint" => "http://dbpedia.org/sparql");
/* Create the 'remote store' */
$dbpedia = ARC2::getRemoteStore($dbpconfig);
/* Configure the app to use DBTune. */
$dbtconfig = array("remote_store_endpoint" => "http://dbtune.org/musicbrainz/sparql");
/* Create the 'remote store' */
$dbtune = ARC2::getRemoteStore($dbtconfig);
/* Let's start with some genre (Art rock). */
$genre = "Art_rock";
if ($_GET['genre']) {
$genre = $_GET['genre'];
}
$uri = "http://dbpedia.org/resource/{$genre}";
/* Let's query DBPedia for some genre info. */
$q = "\r\nPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\r\nPREFIX dbpedia-owl: <http://dbpedia.org/ontology/>\r\nPREFIX dbpprop: <http://dbpedia.org/property/>\r\nPREFIX foaf: <http://xmlns.com/foaf/0.1/>\r\nSELECT ?name ?popularity ?abstract ?wikipedia\r\nWHERE\r\n { <{$uri}> rdfs:label ?name ;\r\n rdfs:comment ?abstract ;\r\n foaf:page ?wikipedia .\r\n OPTIONAL { <{$uri}> dbpprop:popularity ?popularity . }\r\n FILTER ( langMatches(lang(?name), \"EN\") &&\r\n langMatches(lang(?abstract), \"EN\") ) }\r\n";
$genre = $dbpedia->query($q, 'row');
/* Let's also grab related genres. */
$q = "\r\nPREFIX dbpedia-owl-musicgenre: <http://dbpedia.org/ontology/MusicGenre/>\r\nPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\r\nSELECT DISTINCT ?genre ?genreuri\r\nWHERE\r\n { <{$uri}> dbpedia-owl-musicgenre:musicSubgenre ?genreuri .\r\n ?genreuri rdfs:label ?genre . \r\n FILTER ( langMatches(lang(?genre), \"EN\") ) }\r\n";
$subgenres = $dbpedia->query($q, 'rows');
$q = "\r\nPREFIX dbpedia-owl-musicgenre: <http://dbpedia.org/ontology/MusicGenre/>\r\nPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\r\nSELECT DISTINCT ?genre ?genreuri\r\nWHERE\r\n { <{$uri}> dbpedia-owl-musicgenre:stylisticOrigin ?genreuri .\r\n ?genreuri rdfs:label ?genre . \r\n FILTER ( langMatches(lang(?genre), \"EN\") ) }\r\n";
$stylisticOrigins = $dbpedia->query($q, 'rows');
$q = "\r\nPREFIX dbpedia-owl-musicgenre: <http://dbpedia.org/ontology/MusicGenre/>\r\nPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\r\nSELECT DISTINCT ?genre ?genreuri\r\nWHERE\r\n { ?genreuri dbpedia-owl-musicgenre:musicSubgenre <{$uri}> ;\r\n rdfs:label ?genre . \r\n FILTER ( langMatches(lang(?genre), \"EN\") ) }\r\n";
$parentGenres = $dbpedia->query($q, 'rows');
$q = "\r\nPREFIX dbpedia-owl-musicgenre: <http://dbpedia.org/ontology/MusicGenre/>\r\nPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\r\nSELECT DISTINCT ?genre ?genreuri\r\nWHERE\r\n { ?genreuri dbpedia-owl-musicgenre:stylisticOrigin <{$uri}> ;\r\n rdfs:label ?genre . \r\n FILTER ( langMatches(lang(?genre), \"EN\") ) }\r\n";
$stylisticChildren = $dbpedia->query($q, 'rows');
/* Now, we finally grab artists. */
示例11: readContent
private function readContent($endPointURI, $query)
{
if (!is_null($this->errorMSG)) {
//query already processed
return false;
}
if (is_array($this->queryResult)) {
//query already processed
return true;
}
$config = array('remote_store_endpoint' => $endPointURI);
$store = ARC2::getRemoteStore($config);
$result = $store->query($query);
if (!is_array($result['result'])) {
$this->errorMSG = DAL_SXML_RET_ERR_START . 'No results could be retrieved from the SPARQL endpoint.' . DAL_SXML_RET_ERR_END;
return false;
}
$this->queryResultColumns = array();
foreach ($result['result']['variables'] as $column) {
$this->queryResultColumns[htmlspecialchars(trim($column))] = $column;
}
$this->queryResult = array();
foreach ($result['result']['rows'] as $key => $row) {
foreach ($this->queryResultColumns as $column => $oColumn) {
@($this->queryResult[$key][$column] = htmlspecialchars(trim($row[$oColumn])));
}
}
//echo('<pre>'.print_r($this->queryResultColumns, true).'</pre>');
//echo('<pre>'.print_r($this->queryResult, true).'</pre>');
return true;
}
示例12: __construct
/**
* Constructor of Graph
* @param string $endpoint : url of endpoint, example : http://lod.bordercloud.com/sparql
* @param boolean $readOnly : true by default, if you allow the function query to write in the database
* @param boolean $debug : false by default, set debug to true in order to get usefull output
* @param string $proxy_host : null by default, IP of your proxy
* @param string $proxy_port : null by default, port of your proxy
* @access public
*/
public function __construct($endpoint, $readOnly = true, $debug = false, $proxy_host = null, $proxy_port = null)
{
$this->_debug = $debug;
$this->_endpoint = $endpoint;
$this->_readOnly = $readOnly;
$this->_proxy_host = $proxy_host;
$this->_proxy_port = $proxy_port;
if ($this->_proxy_host != null && $this->_proxy_port != null) {
$this->_config = array('remote_store_endpoint' => $this->_endpoint . "sparql/", 'proxy_host' => $this->_proxy_host, 'proxy_port' => $this->_proxy_port);
} else {
$this->_config = array('remote_store_endpoint' => $this->_endpoint . "sparql/");
}
$this->_arc2_RemoteStore = ARC2::getRemoteStore($this->_config);
}