Beispiel #1
0
function array_uft8_decode($tab)
{
    foreach ($tab as $key => $val) {
        if (is_array($val)) {
            $tab[$key] = array_uft8_decode($val);
        } else {
            $tab[$key] = utf8_decode($val);
        }
    }
    return $tab;
}
Beispiel #2
0
 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 %}&nbsp;{% 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;
 }