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}"; try { $rows = $storedbp->query($sparqldbp, 'rows'); } catch (Exception $e) { $rows = array(); } $enrichment['bio']['biography_dbpedia'] = encoding_normalize::clean_cp1252($rows[0]['comment'], "utf-8"); if ($rows[0]['image']) { $enrichment['depictions']['depiction_dbpedia'] = $rows[0]['image']; } // recherche du mouvement litteraire ... $sparqldbp = "\n\t\t\t\t\t\tPREFIX dbpedia-owl:<http://dbpedia.org/ontology/>\n\t\t\t\t\t\tPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\t\t\t\t\t\tSELECT ?movement ?mov WHERE{\n\t\t\t\t\t\t\t<{$uri_dbpedia}> dbpedia-owl:movement ?mov.\n\t\t\t\t\t\t\t?mov rdfs:label ?movement\n\t\t\t\t\t\t\t\tFILTER langMatches( lang(?movement), '{$langue}').\n\t\t\t\t\t\t}"; try { $rows = $storedbp->query($sparqldbp, 'rows'); } catch (Exception $e) { $rows = array(); } foreach ($rows as $row) { $movement = array(); $list_aut = array(); $movement['title'] = $row['movement']; $sparqldbp = "\n\t\t\t\t\t\t\tPREFIX dbpedia-owl:<http://dbpedia.org/ontology/>\n\t\t\t\t\t\t\tPREFIX foaf: <http://xmlns.com/foaf/0.1/>\n\t\t\t\t\t\t\tSELECT distinct ?auts WHERE{\n\t\t\t\t\t\t\t\t?auts ?p <" . $row['mov'] . ">.\n\t\t\t\t\t\t\t\t\tFILTER( ?p = dbpedia-owl:genre || ?p = dbpedia-owl:movement)\n\t\t\t\t\t\t\t\t?auts rdf:type foaf:Person\n\t\t\t\t\t\t\t}"; try { $rows = $storedbp->query($sparqldbp, 'rows'); } catch (Exception $e) { $rows = array(); } foreach ($rows as $row) { if ($row['auts'] != $uri_dbpedia) { $list_aut[] = rawurldecode($row['auts']); } } $list_aut = array_unique($list_aut); foreach (array_chunk($list_aut, 10) as $chunk) { $sparql = "\n\t\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\t\tPREFIX foaf: <http://xmlns.com/foaf/0.1/>\n\t\t\t\t\t\t\t\t\tPREFIX skos: <http://www.w3.org/2004/02/skos/core#>\n\t\t\t\t\t\t\t\t\tPREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n\t\t\t\t\t\t\t\t\tSELECT ?numaut ?name WHERE{\n\t\t\t\t\t\t\t\t\t\t?aut rdf:type foaf:Person .\n\t\t\t\t\t\t\t \t\t?author foaf:focus ?aut.\n\t\t\t\t\t\t\t \t\t?author skos:exactMatch ?uri_dbpedia.\n\t\t\t\t\t\t\t\t\t\t\tFILTER (?uri_dbpedia = <" . implode("> || ?uri_dbpedia = <", $chunk) . ">) \n\t\t\t\t\t\t\t\t\t\t?author bnf-onto:FRBNF ?numaut.\n\t\t\t\t\t\t\t\t\t\t?aut foaf:name ?name.\n\t\t\t\t\t\t\t\t\t}"; try { $rows = $storebnf->query($sparql, 'rows'); } catch (Exception $e) { $rows = array(); } foreach ($rows as $row) { $aauthor = array("id_bnf" => $row['numaut'], "name" => $row['name']); $movement['authors'][] = $aauthor; } } $enrichment['movement'][] = $movement; } // ... et du genre $sparqldbp = "\n\t\t\t\t\t\tPREFIX dbpedia-owl:<http://dbpedia.org/ontology/>\n\t\t\t\t\t\tPREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>\n\t\t\t\t\t\tSELECT ?genre ?mov WHERE{\n\t\t\t\t\t\t\t<{$uri_dbpedia}> dbpedia-owl:genre ?mov.\n\t\t\t\t\t\t\t?mov rdfs:label ?genre\n\t\t\t\t\t\t\t\tFILTER langMatches( lang(?genre), '{$langue}').\n\t\t\t\t\t\t}"; try { $rows = $storedbp->query($sparqldbp, 'rows'); } catch (Exception $e) { $rows = array(); } foreach ($rows as $row) { $genre = array(); $list_aut = array(); $genre['title'] = $row['genre']; $sparqldbp = "\n\t\t\t\t\t\t\tPREFIX dbpedia-owl:<http://dbpedia.org/ontology/>\n\t\t\t\t\t\t\tPREFIX foaf: <http://xmlns.com/foaf/0.1/>\n\t\t\t\t\t\t\tSELECT distinct ?auts WHERE{\n\t\t\t\t\t\t\t\t?auts ?p <" . $row['mov'] . ">.\n\t\t\t\t\t\t\t\t\tFILTER( ?p = dbpedia-owl:genre || ?p = dbpedia-owl:genre)\n\t\t\t\t\t\t\t\t?auts rdf:type foaf:Person\n\t\t\t\t\t\t\t}"; try { $rows = $storedbp->query($sparqldbp, 'rows'); } catch (Exception $e) { $rows = array(); } foreach ($rows as $row) { if ($row['auts'] != $uri_dbpedia) { $list_aut[] = rawurldecode($row['auts']); } } $list_aut = array_unique($list_aut); foreach (array_chunk($list_aut, 10) as $chunk) { $sparql = "\n\t\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\t\tPREFIX foaf: <http://xmlns.com/foaf/0.1/>\n\t\t\t\t\t\t\t\t\tPREFIX skos: <http://www.w3.org/2004/02/skos/core#>\n\t\t\t\t\t\t\t\t\tPREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>\n\t\t\t\t\t\t\t\t\tSELECT ?numaut ?name WHERE{\n\t\t\t\t\t\t\t\t\t\t?aut rdf:type foaf:Person .\n\t\t\t\t\t\t\t \t\t?author foaf:focus ?aut.\n\t\t\t\t\t\t\t \t\t?author skos:exactMatch ?uri_dbpedia.\n\t\t\t\t\t\t\t\t\t\t\tFILTER (?uri_dbpedia = <" . implode("> || ?uri_dbpedia = <", $chunk) . ">) \n\t\t\t\t\t\t\t\t\t\t?author bnf-onto:FRBNF ?numaut.\n\t\t\t\t\t\t\t\t\t\t?aut foaf:name ?name.\n\t\t\t\t\t\t\t\t\t}"; try { $rows = $storebnf->query($sparql, 'rows'); } catch (Exception $e) { $rows = array(); } foreach ($rows as $row) { $aauthor = array("id_bnf" => $row['numaut'], "name" => $row['name']); $genre['authors'][] = $aauthor; } } $enrichment['genre'][] = $genre; } } if ($charset != 'utf-8') { $enrichment = pmb_utf8_array_decode($enrichment); } $enrichments = serialize($enrichment); $enrichments = addslashes($enrichments); $query = "UPDATE authors SET author_enrichment = '" . $enrichments . "', author_enrichment_last_update = NOW() WHERE author_id='" . $id . "'"; $result = @pmb_mysql_query($query, $dbh); // update } }
case 'see_more': $facette = new facettes(); if ($charset != "utf-8") { $sended_datas = utf8_encode($sended_datas); } $sended_datas = pmb_utf8_array_decode(json_decode(stripslashes($sended_datas), true)); ajax_http_send_response($facette->see_more($sended_datas['json_facette_plus'])); break; case 'compare_see_more': //les parametres nécéssaires global $pmb_compare_notice_template; global $pmb_compare_notice_nb; if ($charset != "utf-8") { $sended_datas = utf8_encode($sended_datas); } $sended_datas = pmb_utf8_array_decode(json_decode(stripslashes($sended_datas), true)); $sended_datas['json_notices_ids'] = implode(',', $sended_datas['json_notices_ids']); $tab_return = array(); if ($charset != "utf-8") { $tab_return['notices'] = utf8_encode(facette_search_compare::call_notice_display($sended_datas['json_notices_ids'], $pmb_compare_notice_nb, $pmb_compare_notice_template)); } else { $tab_return['notices'] = facette_search_compare::call_notice_display($sended_datas['json_notices_ids'], $pmb_compare_notice_nb, $pmb_compare_notice_template); } if ($sended_datas['json_notices_ids']) { if ($charset != "utf-8") { $tab_return['see_more'] = utf8_encode(facette_search_compare::get_compare_see_more($sended_datas['json_notices_ids'])); } else { $tab_return['see_more'] = facette_search_compare::get_compare_see_more($sended_datas['json_notices_ids']); } } ajax_http_send_response(json_encode($tab_return));
/** * Passage en session des valeurs du comparateur * Ou revalidation des variables de classe courrante à partir des variables de session * * @param facette_search_compare $facette_search_compare */ public static function session_facette_compare($facette_search_compare = null, $reinit_compare = false) { global $check_facette_compare; global $check_facette_groupby; global $charset; if ($facette_search_compare) { $facette_search_compare->facette_compare = $_SESSION['check_facette_compare']; $facette_search_compare->facette_groupby = $_SESSION['check_facette_groupby']; } elseif ($reinit_compare) { if ($facette_search_compare) { $facette_search_compare->facette_compare = array(); } $_SESSION['check_facette_compare'] = array(); } else { if (sizeof($check_facette_compare)) { $_SESSION['check_facette_compare'] = array(); foreach ($check_facette_compare as $key => $f_c) { $f_c = stripslashes($f_c); $f_c_tab = pmb_utf8_array_decode(json_decode(utf8_encode($f_c))); if ($f_c != '') { $_SESSION['check_facette_compare'][$f_c_tab[4]] = $f_c_tab; $_SESSION['check_facette_compare'][$f_c_tab[4]]['value'] = $f_c; } else { unset($_SESSION['check_facette_compare'][$f_c_tab[4]]); } } } else { unset($_SESSION['check_facette_compare']); } if (sizeof($check_facette_groupby)) { $_SESSION['check_facette_groupby'] = array(); foreach ($check_facette_groupby as $key => $f_gb) { $f_gb = stripslashes($f_gb); if ($charset != 'utf-8') { $f_gb = utf8_encode($f_gb); } $f_gb_tab = pmb_utf8_array_decode(json_decode($f_gb)); if ($f_gb != '') { $_SESSION['check_facette_groupby'][$f_gb_tab[3]] = $f_gb_tab; $_SESSION['check_facette_groupby'][$f_gb_tab[3]]['value'] = $f_gb; } else { unset($_SESSION['check_facette_groupby'][$f_gb_tab[3]]); } } } else { unset($_SESSION['check_facette_groupby']); } } }