get_source_params($source_id);
if ($params["PARAMETERS"]) {
//Affichage du formulaire avec $params["PARAMETERS"]
$vars=unserialize($params["PARAMETERS"]);
foreach ($vars as $key=>$val) {
global ${$key};
${$key}=$val;
}
}
$form="
";
return $form;
}
public function make_serialized_source_properties($source_id) {
global $sparql_endpoint_url;
$t["sparql_endpoint_url"]=$sparql_endpoint_url;
$this->sources[$source_id]["PARAMETERS"]=serialize($t);
}
public function enrichment_is_allow(){
return true;
}
public function getEnrichmentHeader(){
global $lang;
$header= array();
return $header;
}
public function getTypeOfEnrichment($source_id){
$type['type'] = array(
array(
'code' => "databnf_oeuvre",
'label' => $this->msg["databnf_oeuvre_label"]
),
array(
'code' => "databnf_bio",
'label' => $this->msg["databnf_bio_label"]
)
);
$type['source_id'] = $source_id;
return $type;
}
public function getEnrichment($notice_id,$source_id,$type="",$enrich_params=array()){
$enrichment= array();
$params=$this->unserialize_source_params($source_id);
$sparql_end_point=$params["PARAMETERS"]["sparql_endpoint_url"];
//on renvoi ce qui est demandé... si on demande rien, on renvoi tout..
switch ($type){
case "databnf_bio" :
$enrichment['databnf_bio']['content'] = $this->get_author_page($notice_id,$sparql_end_point);
break;
case "databnf_oeuvre" :
default :
$enrichment['databnf_oeuvre']['content'] = $this->noticeInfos($notice_id,$sparql_end_point);
break;
}
$enrichment['source_label']=$this->msg['databnf_enrichment_source'];
return $enrichment;
}
public function get_author_page($notice_id,$sparql_end_point){
global $lang;
global $charset;
if($enrich_params['label']!=""){
$author = $enrich_params['label'];
}else{
//on va chercher l'auteur principal...
$query = "select responsability_author, authority_number from responsability join authorities_sources on (authority_type='author' and num_authority=responsability_author) where responsability_notice =".$notice_id." and responsability_type=0";
$result = pmb_mysql_query($query);
if(pmb_mysql_num_rows($result)){
$author_id = pmb_mysql_result($result,0,0);
$author_number = pmb_mysql_result($result,0,1);
$author_class = new auteur($author_id);
$author = $author_class->get_isbd();
//On y va !
$config = array(
'remote_store_endpoint' => $sparql_end_point,
'remote_store_timeout' => 15
);
$store = ARC2::getRemoteStore($config);
//Recherche de l'URI de l'auteur !
$sparql="prefix skos:
SELECT * WHERE {
?auteur rdf:type skos:Concept .
FILTER regex(?auteur, \"^http://data\.bnf\.fr:8080/ark:/12148/cb".$author_number."\") .
}";
$rows=$store->query($sparql,'rows');
if ($rows[0]["auteur"]) {
$uri_auteur=$rows[0]["auteur"];
//Biographie...
$sparql="prefix foaf:
prefix dc:
prefix dcterm:
prefix bnf-onto:
prefix rdagroup2elements:
prefix skos:
SELECT * WHERE {
<$uri_auteur> foaf:focus ?person .
<$uri_auteur> skos:prefLabel ?isbd .
?person foaf:page ?page .
OPTIONAL {
?person rdagroup2elements:biographicalInformation ?biographie .
}
OPTIONAL {
?person rdagroup2elements:dateOfBirth ?naissance .
}
OPTIONAL {
?person rdagroup2elements:placeOfBirth ?lieunaissance .
}
OPTIONAL {
?person rdagroup2elements:dateOfDeath ?mort .
}
OPTIONAL {
?person rdagroup2elements:placeOfDeath ?lieumort .
}
}";
try {
$rows=$store->query($sparql,'rows');
} catch(Exception $e) {
$rows=array();
}
$rows=array_uft8_decode($rows);
$template="{% for record in result %}
{{record.isbd}}
Biographie (BNF)
Date de naissance | {{record.naissance}} |
Lieu de naissance | {{record.lieunaissance}} |
Date de décès | {{record.mort}} |
Lieu de décès | {{record.lieumort}} |
{{record.biographie}}
{% endfor %}";
$html_to_return = H2o::parseString($template)->render(array("result"=>$rows));
//Vignettes
$sparql="prefix foaf:
prefix dc:
prefix dcterm:
SELECT * WHERE {
<$uri_auteur> foaf:focus ?person .
?person foaf:depiction ?url .
} LIMIT 5";
try {
$rows=$store->query($sparql,'rows');
} catch(Exception $e) {
$rows=array();
}
$rows=array_uft8_decode($rows);
$template="Vignettes (BnF)
{% for record in result %}
|
{% endfor %}
";
$html_to_return .= H2o::parseString($template)->render(array("result"=>$rows));
//Bibliographie
$sparql="prefix foaf:
prefix dc:
prefix dcterm:
prefix frbr-rda:
prefix rdarelationships:
SELECT ?oeuvre ?oeuvre_concept ?date ?title ?url ?gallica WHERE {
<$uri_auteur> foaf:focus ?person .
?oeuvre dc:creator ?person .
?oeuvre_concept foaf:focus ?oeuvre .
OPTIONAL {
?oeuvre dc:date ?date
} .
?oeuvre dc:title ?title .
OPTIONAL { ?oeuvre foaf:depiction ?url } .
OPTIONAL {
?manifestation rdarelationships:workManifested ?oeuvre .
?manifestation rdarelationships:electronicReproduction ?gallica .
} .
} group by ?oeuvre order by ?date";
try {
$rows=$store->query($sparql,'rows');
} catch(Exception $e) {
$rows=array();
}
$rows=array_uft8_decode($rows);
$template="Bibliographie (BNF)
{% for record in result %}
{% if record.date %}{{record.date}}{% else %} {% endif %} |
{% endfor %}
{% for record in result %}
{% if loop.odd %}
{% if record.url %}
{% else %}
{% endif %}
{% if record.gallica %}
{% endif %}
{{record.title}}
{% else %} {% endif %}
|
{% endfor %}
{% for record in result %}
{% if loop.even %}{% if record.url %}
{% else %}
{% endif %}
{% if record.gallica %}
{% endif %}
{{record.title}}{% else %} {% endif %}
|
{% endfor %}
";
$html_to_return .= H2o::parseString($template)->render(array("result"=>$rows));
}
}
}
// print $html_to_return;
return $html_to_return;
}
public 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=pmb_mysql_query($requete);
if (pmb_mysql_num_rows($resultat)) {
$isbn=pmb_mysql_result($resultat,0,0);
} else $isbn="";
if ($isbn) {
//On y va !
$config = array(
'remote_store_endpoint' => $sparql_end_point,
'remote_store_timeout' => 15
);
$store = ARC2::getRemoteStore($config);
if (isISBN($isbn)) {
$isbn=formatISBN($isbn,10);
$isbn13=formatISBN($isbn,13);
}
$sparql="prefix bnf-onto:
prefix rdarelationships:
SELECT ?oeuvre WHERE {
?manifestation bnf-onto:ISBN '$isbn' .
?manifestation rdarelationships:workManifested ?oeuvre
}";
try {
$rows=$store->query($sparql,'rows');
if ((!$rows[0]["oeuvre"])&&($isbn13)) {
$sparql="prefix bnf-onto:
prefix rdarelationships:
SELECT ?oeuvre WHERE {
?manifestation bnf-onto:ISBN '$isbn13' .
?manifestation rdarelationships:workManifested ?oeuvre
}";
try {
$rows=$store->query($sparql,'rows');
} catch(Exception $e) {
$rows=array();
}
}
} catch(Exception $e) {
$rows=array();
}
if ($rows[0]["oeuvre"]) {
$oeuvre=$rows[0]["oeuvre"];
$sparql="prefix skos:
prefix foaf:
prefix dc:
prefix bnf-onto:
prefix rdarelationships:
prefix rdagroup1Elements:
SELECT * WHERE {
<$oeuvre> rdfs:label ?titre .
OPTIONAL { <$oeuvre> dc:date ?date } .
OPTIONAL { <$oeuvre> foaf:depiction ?vignette } .
OPTIONAL { <$oeuvre> dc:description ?description } .
OPTIONAL { <$oeuvre> bnf-onto:subject ?sujet } .
OPTIONAL { <$oeuvre> dc:creator ?auteur .
?auteur_concept foaf:focus ?auteur .
?auteur_concept skos:prefLabel ?auteur_isbd .
} .
OPTIONAL { <$oeuvre> rdagroup1Elements:placeOfOriginOfTheWork ?lieu }
}";
try {
$rows=$store->query($sparql,'rows');
} catch(Exception $e) {
$rows=array();
}
$rows=array_uft8_decode($rows);
$template="
{{result.0.titre}}
Détail de l'oeuvre (BNF)
{% if result.0.vignette %}
|
{% endif %}
{% if result.0.vignette %}
|
{% endif %}
{{result.0.description}}
";
$html_to_return .= H2o::parseString($template)->render(array("result"=>$rows));
//Récupération des exemplaires de Gallica
$sparql="prefix skos:
prefix foaf:
prefix dc:
prefix bnf-onto:
prefix rdarelationships:
prefix rdagroup1Elements:
SELECT * WHERE {
?manifestation rdarelationships:workManifested <$oeuvre> .
OPTIONAL { ?manifestation rdarelationships:electronicReproduction ?gallica } .
OPTIONAL { ?manifestation bnf-onto:ISBN ?isbn } .
OPTIONAL { <$oeuvre> foaf:depiction ?vignette } .
OPTIONAL { ?manifestation dc:date ?date } .
OPTIONAL { ?manifestation rdagroup1Elements:publishersName ?publisher } .
OPTIONAL { ?manifestation rdagroup1Elements:note ?note } .
OPTIONAL { ?manifestation rdagroup1Elements:placeOfPublication ?place } .
OPTIONAL { ?manifestation rdagroup1Elements:dateOfCapture ?numerisele } .
} group by ?manifestation order by ?date
";
try {
$rows=$store->query($sparql,'rows');
} catch(Exception $e) {
$rows=array();
}
$rows=array_uft8_decode($rows);
$template="
Editions numérisées dans Gallica
";
$html_to_return .= H2o::parseString($template)->render(array("result"=>$rows));
$template="
Editions dans la bibliothèque
";
try {
$html_to_return .= H2o::parseString($template)->render(array("result"=>$rows));
} catch (Exception $e) {
$html_to_return.= $this->msg["error_template"];
}
}
}
return $html_to_return;
}
}
?>