public function get_notice_id() { global $pmb_keyword_sep; $notice_id = 0; $this->data = array(); $this->data['tit1'] = $this->data['tit4'] = $this->data['authors'] = $this->data['co_authors'] = $this->data['code'] = $this->data['npages'] = $this->data['year'] = $this->data['index_l'] = $this->data['url'] = $this->data['thumbnail_content'] = $this->data['publisher'] = $this->data['n_resume'] = ""; if ($this->mimetype == "application/epub+zip") { //pour les ebook, on gère ca directement ici ! $this->data['tit1'] = $this->metas['title'][0]; $this->data['authors'] = $this->metas['creator']; $this->data['co_authors'] = $this->metas['contributor']; if ($this->metas['identifier']['isbn']) { $this->data['code'] = \formatISBN($this->metas['identifier']['isbn'], 13); } else { if ($this->metas['identifier']['ean']) { $this->data['code'] = \EANtoISBN($this->metas['identifier']['ean']); $this->data['code'] = \formatISBN($code, 13); } } if ($this->metas['identifier']['uri']) { $this->data['url'] = \clean_string($this->metas['identifier']['uri']); } $this->data['publisher'] = $this->metas['publisher'][0]; $this->data['year'] = $this->metas['date'][0]['value']; if (strlen($this->data['year']) && strlen($this->data['year']) != 4) { $this->data['year'] = \formatdate(detectFormatDate($this->data['year'])); } $this->data['lang'] = $this->metas['language']; $this->data['n_resume'] = implode("\n", $this->metas['description']); $this->data['keywords'] = implode($pmb_keyword_sep, $this->metas['subject']); $this->data['thumbnail_content'] = $this->metas['thumbnail_content']; } else { foreach ($this->map['meta'] as $map_field => $map) { foreach ($this->metas as $meta_field => $meta_value) { if ($map_field == $meta_field) { if (method_exists($this, $map['function'])) { $this->data[$map['field']] = $this->{$map}['function']($this->data[$map['field']], $meta_value, $map['params']); } else { $this->data[$map['field']] = $meta_value; } break; } } } } if (!$this->data['tit1']) { $this->data['tit1'] = $this->name; } $notice_id = $this->create_notice(); $notice_id = $this->dedoublonne($notice_id); return $notice_id; }
/** * Listing for books * @param <type> $fisbn Book ISBN * @param <type> $ftitle Book title * @param <type> $fclist Array containing courses used for books */ function generateListing_B($fisbn, $ftitle, $fclist) { $formatted = formatISBN($fisbn); if (count($fclist) == 0) { $clabel = ""; } else { $clabel = "Courses "; } $return = "\n\t\t<div class='item-title'>{$ftitle}</div>\n\t\t{$formatted}"; if (!$clabel == "") { foreach ($fclist as $key => $val) { $return = $return . "<div class='item-course item-info'><p>{$val}</p></div>"; } } return $return; }
function traite_val($value, $idf) { switch ($idf) { case "22": if (isISBN($value)) { // si la saisie est un ISBN $code = formatISBN($value); // si échec, ISBN erroné on le prend sous cette forme if (!$code) { $code = $value; } } else { $code = $value; } $ret = $code; break; default: $ret = $value; break; } return $ret; }
$t_notice['year'] = trim($f_year); $f_nocoll && $t_notice['coll_id'] ? $t_notice['nocoll'] = trim($f_nocoll) : ($t_notice['nocoll'] = ''); $t_notice['mention_edition'] = trim($f_mention_edition); if ($f_cb) { // ce controle redondant est la pour le cas ou l'utilisateur aurait change le code if (isEAN($f_cb)) { // la saisie est un EAN -> on tente de le formater en ISBN $code = EANtoISBN($f_cb); // si echec, on prend l'EAN comme il vient if (!$code) { $code = $f_cb; } } else { if (isISBN($f_cb)) { // si la saisie est un ISBN $code = formatISBN($f_cb, 13); // si echec, ISBN errone on le prend sous cette forme if (!$code) { $code = $f_cb; } } else { // ce n'est rien de tout ca, on prend la saisie telle quelle $code = $f_cb; } } $t_notice['code'] = $code; } $t_notice['npages'] = $f_npages; $t_notice['ill'] = $f_ill; $t_notice['size'] = $f_size; $t_notice['prix'] = $f_prix;
$ex_query = clean_string($ex_query); $EAN = ''; $isbn = ''; $code = ''; // on teste si c'est un EAN if (isEAN($ex_query)) { // la chaine passée est un EAN pur (rappel : livres seulement) $isbn = EANtoISBN($ex_query); $EAN = $ex_query; $code10 = formatISBN($isbn, 10); } else { // apparement pas un EAN // l'utilisateur a peut-être saisi un isbn à la main if (isISBN($ex_query)) { $isbn = formatISBN($ex_query); $code13 = formatISBN($isbn, 13); } else { $code = $ex_query; } } if ($EAN && $isbn) { // cas des EAN purs : constitution de la requête $requete = "SELECT * FROM notices WHERE code='{$EAN}' OR code in ('{$isbn}','" . $code10 . "')"; $myQuery = mysql_query($requete, $dbh); } elseif ($isbn) { // recherche d'un isbn $requete = "SELECT * FROM notices WHERE code in ('{$isbn}','" . $code13 . "')"; $myQuery = mysql_query($requete, $dbh); } else { // recherche d'un exemplaire // note : le code est recherché aussi dans le champ code des notices
function traite_code_isbn($saisieISBN = "") { if ($saisieISBN) { if (isEAN($saisieISBN)) { // la saisie est un EAN -> on tente de le formater en ISBN $code = EANtoISBN($saisieISBN); // si échec, on prend l'EAN comme il vient if (!$code) { $code = $saisieISBN; } } else { if (isISBN($saisieISBN)) { // si la saisie est un ISBN $code = formatISBN($saisieISBN); // si échec, ISBN erroné on le prend sous cette forme if (!$code) { $code = $saisieISBN; } } else { // ce n'est rien de tout ça, on prend la saisie telle quelle $code = $saisieISBN; } } return $code; } return ""; }
function make_first_search() { global $msg, $dbh; global $elt_query; global $notice_statut_query, $doctype_query; global $nb_per_page, $nb_per_page_select; global $results_show_all; if (!$nb_per_page) { $nb_per_page = $nb_per_page_select; } $restrict = "niveau_biblio='m' "; if ($notice_statut_query != '-1') { $restrict .= "and statut='" . $notice_statut_query . "' "; } if ($doctype_query != '-1') { $restrict .= "and typdoc='" . $doctype_query . "' "; } $suite_rqt = "or code='" . $elt_query . "' "; $isbn_verif = traite_code_isbn(stripslashes($elt_query)); if (isISBN($isbn_verif)) { $suite_rqt .= "or code='" . formatISBN($isbn_verif, 13) . "' "; $suite_rqt .= "or code='" . formatISBN($isbn_verif, 10) . "' "; $q_count = "select count(*) from notices where " . $restrict . " and (0 " . $suite_rqt . ")"; $r_count = pmb_mysql_query($q_count, $dbh); $n_count = pmb_mysql_result($r_count, 0, 0); $this->nbresults = $n_count; $q_list = "select notice_id from notices where " . $restrict . " and (0 " . $suite_rqt . ")"; if (!$results_show_all) { $q_list .= " limit " . $this->page * $nb_per_page . ", " . $nb_per_page . " "; } $r_list = pmb_mysql_query($q_list, $dbh); $this->t_query = $r_list; if (!$results_show_all) { $this->nbepage = ceil($this->nbresults / $nb_per_page); } else { $this->nbepage = 1; } } else { $aq = new analyse_query(stripslashes($elt_query)); if ($aq->error) { $this->show_form(); error_message($msg["searcher_syntax_error"], sprintf($msg["searcher_syntax_error_desc"], $aq->current_car, $aq->input_html, $aq->error_message)); return; } else { $q_members = $aq->get_query_members("notices", "index_wew", "index_sew", "notice_id"); $q_count = "select count(*) from notices where " . $restrict . " and (" . $q_members["where"] . " " . $suite_rqt . ")"; $r_count = pmb_mysql_query($q_count, $dbh); $n_count = pmb_mysql_result($r_count, 0, 0); $this->nbresults = $n_count; $q_list = "select notice_id, " . $q_members['select'] . " as pert from notices where " . $restrict . " and (" . $q_members["where"] . " " . $suite_rqt . ") " . $q_members['post']; if (!$results_show_all) { $q_list .= " limit " . $this->page * $nb_per_page . ", " . $nb_per_page . " "; } $r_list = pmb_mysql_query($q_list, $dbh); $this->t_query = $r_list; if (!$results_show_all) { $this->nbepage = ceil($this->nbresults / $nb_per_page); } else { $this->nbepage = 1; } } } return ELT_LIST; }
function process_isbn($isbn) { /* We've got everything, let's have a look if ISBN already exists in notices table */ $isbn_nettoye = preg_replace('/-|\\.| |\\(|\\)|\\[|\\]|\\:|\\;|[A-WY-Z]/i', '', $isbn); $isbn_nettoye_13 = substr($isbn_nettoye, 0, 13); $isbn_nettoye_10 = substr($isbn_nettoye, 0, 10); $isbn_OK = ""; if (isEAN($isbn_nettoye_13)) { /* it's an EAN -> convert it to ISBN */ $isbn_OK = EANtoISBN($isbn_nettoye_13); } if (!$isbn_OK) { if (isISBN($isbn_nettoye_10)) { $isbn_OK = formatISBN($isbn_nettoye_10); } } if (!$isbn_OK) { $isbn_OK = clean_string($isbn); } return $isbn_OK; }
function getEnrichment($notice_id, $source_id, $type = "", $enrich_params = array(), $page = 1) { $params = $this->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; } } $enrichment = array(); //on renvoi ce qui est demandé... si on demande rien, on renvoi tout.. switch ($type) { case "books": default: $rqt = "select code from notices where notice_id = '{$notice_id}'"; $res = pmb_mysql_query($rqt); if (pmb_mysql_num_rows($res)) { $ref = pmb_mysql_result($res, 0, 0); //google change son API, on s'assure d'avoir un ISBN13 formaté ! if (isEAN(${$ref})) { // la saisie est un EAN -> on tente de le formater en ISBN $EAN = $ref; $isbn = EANtoISBN($ref); // si échec, on prend l'EAN comme il vient if (!$isbn) { $code = str_replace("*", "%", $ref); } else { $code = $isbn; $code10 = formatISBN($code, 10); } } else { if (isISBN($ref)) { // si la saisie est un ISBN $isbn = formatISBN($ref); // si échec, ISBN erroné on le prend sous cette forme if (!$isbn) { $code = str_replace("*", "%", $ref); } else { $code10 = $isbn; $code = formatISBN($code10, 13); } } else { // ce n'est rien de tout ça, on prend la saisie telle quelle $code = str_replace("*", "%", $ref); } } //plutot que de faire une requete pour lancer que si ca marche, on ajoute un callback en cas d'échec if ($code) { $enrichment['books']['content'] = "\n\t\t\t\t\t\t<div id='gbook{$notice_id}' style='width: " . $width . "px; height: " . $height . "px;margin-bottom:0.5em;'></div>"; $enrichment['books']['callback'] = "\n\t\t\t\t\t\t\tvar viewer = new google.books.DefaultViewer(document.getElementById('gbook" . $notice_id . "'));\n\t\t\t\t\t\t\tvar gbook" . $notice_id . "_failed = function(){\n\t\t\t\t\t\t\t\tvar content = document.getElementById('gbook" . $notice_id . "');\n\t\t\t\t\t\t\t\tvar span = document.createElement('span');\n\t\t\t\t\t\t\t\tvar txt = document.createTextNode('" . $this->msg["gbook_no_preview"] . "');\n\t\t\t\t\t\t\t\tspan.appendChild(txt);\n\t\t\t\t\t\t\t\tcontent.appendChild(span);\n\t\t\t\t\t\t\t\tcontent.style.height='auto';\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tviewer.load('ISBN:" . str_replace("-", "", $code) . "',gbook" . $notice_id . "_failed);\t\n\t\t\t\t\t\t"; } else { $enrichment['books']['content'] = "<span>" . $this->msg["gbook_no_preview"] . "</span>"; } } break; } $enrichment['source_label'] = $this->msg['gbooks_enrichment_source']; return $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}"; 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 } }
if (mysql_num_rows($res)) { $rep = mysql_fetch_object($res); $img = $rep->repertoire_path . "img_" . $notice_id; header('Content-Type: image/png'); $fp = @fopen($img, "rb"); fpassthru($fp); fclose($fp); exit; } } if ($noticecode) { if (isEAN($noticecode)) { if (isISBN($noticecode)) { if (isISBN10($noticecode)) { $url_image10 = str_replace("!!isbn!!", str_replace("-", "", $noticecode), $_GET['url_image']); $url_image13 = str_replace("!!isbn!!", str_replace("-", "", formatISBN($noticecode, "13")), $_GET['url_image']); } else { $url_image10 = str_replace("!!isbn!!", str_replace("-", "", EANtoISBN10($noticecode)), $_GET['url_image']); $url_image13 = str_replace("!!isbn!!", str_replace("-", "", $noticecode), $_GET['url_image']); } } else { $url_imageEAN = str_replace("!!isbn!!", str_replace("-", "", $noticecode), $_GET['url_image']); } } $url_image = str_replace("!!isbn!!", $noticecode, $_GET['url_image']); } else { $url_image = rawurldecode(stripslashes($_GET['url_image'])); } if ($opac_curl_available) { $image = ""; $aCurl = new Curl();
} else { $requete = "select if(indexint_comment is not null and indexint_comment!='',concat(indexint_name,' - ',indexint_comment),indexint_name) as indexint,indexint_id, concat( indexint_name,' ',indexint_comment) as indexsimple from indexint \n\t\t\twhere if(indexint_comment is not null and indexint_comment!='',concat(indexint_name,' - ',indexint_comment),indexint_name) like '" . addslashes($start) . "%' {$restrict} and num_pclass = '{$thesaurus_classement_defaut}' order by 1 limit 20"; } $origine = "SQL"; break; case 'notice': require_once './includes/isbn.inc.php'; if ($autexclude) { $restrict = " AND notice_id not in ({$autexclude}) "; } $requete = "select if(serie_name is not null,if(tnvol is not null,concat(serie_name,', ',tnvol,'. ',tit1),concat(serie_name,'. ',tit1)),tit1), notice_id from notices left join series on serie_id=tparent_id where (index_sew like ' " . addslashes(strip_empty_words($start)) . "%' or TRIM(index_wew) like '" . addslashes($start) . "%' or tit1 like '" . addslashes($start) . "%' or (code like '" . traite_code_isbn(addslashes($start)) . "'"; if (isISBN(traite_code_isbn($start))) { if (strlen(traite_code_isbn($start)) == 13) { $requete .= " or code like '" . formatISBN(traite_code_isbn($start), 13) . "'"; } else { $requete .= " or code like '" . formatISBN(traite_code_isbn($start), 10) . "'"; } } $requete .= ")) {$restrict} order by index_serie, tnvol, index_sew , code limit 20 "; $origine = "SQL"; break; case 'serie': if ($autexclude) { $restrict = " AND serie_id not in ({$autexclude}) "; } $requete = "select serie_name,serie_id from series where serie_name like '" . addslashes($start) . "%' {$restrict} order by 1 limit 20"; $origine = "SQL"; break; case 'fonction': // récupération des codes de fonction if (!count($s_func)) {
function search($source_id, $query, $search_id) { $params = $this->get_source_params($source_id); $this->fetch_global_properties(); if ($params["PARAMETERS"]) { //Affichage du formulaire avec $params["PARAMETERS"] $vars = unserialize($params["PARAMETERS"]); foreach ($vars as $key => $val) { global ${$key}; ${$key} = $val; } } if (!isset($url)) { $url = ""; } if (!isset($username)) { $username = ""; } if (!isset($password)) { $password = ""; } if (!isset($fetch_images)) { $fetch_images = 0; } if (!isset($image_folder)) { $image_folder = 0; } if (!isset($image_folder_public)) { $image_folder_public = 0; } if (!isset($image_thumb_url)) { $image_thumb_url = 0; } if (!isset($image_front)) { $image_front = 0; } if (!isset($image_back)) { $image_back = 0; } $this->url = $url; $this->username = $username; $this->password = $password; $this->source_id = $source_id; $this->search_id = 0; $this->image_thumb_url = $image_thumb_url; $this->image_front = $image_front; $this->image_back = $image_back; $this->image_folder = $image_folder; $this->image_folder_url = $image_folder_public; $this->fetchimages = $fetch_images; $isbns = array(); foreach ($query as $amterm) { if ($amterm->ufield == '010$a') { $isbns[] = $amterm->values[0]; } } global $base_path; $xsl_transform = file_get_contents($base_path . "/admin/connecteurs/in/aligastore/xslt/aligatopmbunimarx.xsl"); foreach ($isbns as $isbn) { //Si on veut des images, il nous faut un isbn 13 $isbn = formatISBN($isbn, 13); $isbn = preg_replace('/-|\\.| /', '', $isbn); $this->fetch_and_record_notice($isbn, $xsl_transform); } }
function import_basic($notices, $params = array(), $with_expl = false) { global $base_path, $class_path, $include_path, $dbh, $msg, $charset; global $deflt_integration_notice_statut, $deflt_lenders, $deflt_docs_statut, $deflt_docs_location; $log = array(); //On contrôle tous les paramètres obligatoires if (!$params["func_import"]) { $params["func_import"] = "func_bdp.inc.php"; //Function d'import à utiliser } if (file_exists($base_path . "/admin/import/" . $params["func_import"])) { require_once $base_path . "/admin/import/" . $params["func_import"]; } else { require_once $base_path . "/admin/import/func_bdp.inc.php"; } //Notices if (!isset($params["isbn_mandatory"])) { $params["isbn_mandatory"] = "0"; } //ISBN obligatoire ? if (!isset($params["isbn_dedoublonnage"])) { $params["isbn_dedoublonnage"] = "1"; } //Dédoublonnage sur ISBN ? if (!isset($params["isbn_only"])) { $params["isbn_only"] = "0"; } //Que les ISBN if (!isset($params["statutnot"])) { $params["statutnot"] = $deflt_integration_notice_statut; } //Statut des notices importées -> On met la valeur du paramètre utilisateur "Statut de notice par défaut en intégration de notice" if (!isset($params["link_generate"])) { $params["link_generate"] = "0"; } //Générer les liens entre notices ? if (!isset($params["authorities_notices"])) { $params["authorities_notices"] = "0"; } //Tenir compte des notices d'autorités if (!isset($params["authorities_default_origin"])) { $params["authorities_default_origin"] = ""; } //Origine par défaut des autorités si non précisé dans les notices //Exemplaires if ($with_expl) { if (!isset($params["book_lender_id"])) { $params["book_lender_id"] = $deflt_lenders; } //Propriétaire -> On met la valeur du paramètre utilisateur "Propriétaire par défaut en création d'exemplaire" if (!isset($params["book_statut_id"])) { $params["book_statut_id"] = $deflt_docs_statut; } //Statut -> On met la valeur du paramètre utilisateur "Statut de document par défaut en création d'exemplaire" if (!isset($params["book_location_id"])) { $params["book_location_id"] = $deflt_docs_location; } //Localisation -> On met la valeur du paramètre utilisateur "Localisation du document par défaut en création d'exemplaire" if (!isset($params["cote_mandatory"])) { $params["cote_mandatory"] = "0"; } //Cote obligatoire ? if (!isset($params["tdoc_codage"])) { $params["tdoc_codage"] = "0"; } //Types de document Codage du propriétaire ? if (!isset($params["statisdoc_codage"])) { $params["statisdoc_codage"] = "0"; } //Codes statistiques Codage du propriétaire ? if (!isset($params["sdoc_codage"])) { $params["sdoc_codage"] = "0"; } //Sections Codage du propriétaire ? } //Find de contrôle des paramètres obligatoires //On rend global tous les paramètres passés (et pas forcément que les obligatoires) pour la suite foreach ($params as $key => $value) { global ${$key}; ${$key} = $value; } if (count($notices)) { ob_start(); //On temporise toutes les sorties (dans le cas ou dans la fonction d'import on fait des sorties écrans directement) $nbtot_notice = count($notices); $notice_deja_presente = 0; $notice_rejetee = 0; global $notices_crees, $notices_a_creer, $bulletins_crees, $bulletins_a_creer; $notices_crees = $notices_a_creer = $bulletins_crees = $bulletins_a_creer = array(); if ($with_expl) { global $section_995, $typdoc_995, $codstatdoc_995, $nb_expl_ignores; $section_995_ = new marc_list("section_995"); $section_995 = $section_995_->table; $typdoc_995_ = new marc_list("typdoc_995"); $typdoc_995 = $typdoc_995_->table; $codstatdoc_995_ = new marc_list("codstatdoc_995"); $codstatdoc_995 = $codstatdoc_995_->table; $nb_expl_ignores = 0; } foreach ($notices as $notice) { $notice = utf8_decode($notice); $res_lecture = recup_noticeunimarc($notice); if ($params["link_generate"]) { recup_noticeunimarc_link($notice); } global $tit_200a; if (!$res_lecture || !$tit_200a[0]) { $res_lecture = 0; $fp = fopen($base_path . "/temp/err_import.unimarc", "a+"); fwrite($fp, $notice); fclose($fp); $notice_rejetee++; } else { recup_noticeunimarc_suite($notice); global $isbn, $EAN, $issn_011, $collection_225, $collection_410, $code, $code10, $isbn_OK, $notice_id; if ($isbn[0] == "NULL") { $isbn[0] = ""; } // si isbn vide, on va tenter de prendre l'EAN stocké en 345$b if ($isbn[0] == "") { $isbn[0] = $EAN[0]; } // si isbn vide, on va tenter de prendre le serial en 011 if ($isbn[0] == "") { $isbn[0] = $issn_011[0]; } // si ISBN obligatoire et isbn toujours vide : if ($params["isbn_mandatory"] == 1 && $isbn[0] == "") { // on va tenter de prendre l'ISSN stocké en 225$x $isbn[0] = $collection_225[0]['x']; // si isbn toujours vide, on va tenter de prendre l'ISSN stocké en 410$x if ($isbn[0] == "") { $isbn[0] = $collection_410[0]['x']; } } // on commence par voir ce que le code est (basé sur la recherche par code du module catalogage $ex_query = clean_string($isbn[0]); $EAN = ''; $isbn = ''; $code = ''; $code10 = ''; if (isEAN($ex_query)) { // la saisie est un EAN -> on tente de le formater en ISBN $EAN = $ex_query; $isbn = EANtoISBN($ex_query); // si échec, on prend l'EAN comme il vient if (!$isbn) { $code = str_replace("*", "%", $ex_query); } else { $code = $isbn; $code10 = formatISBN($code, 10); } } else { if (isISBN($ex_query)) { // si la saisie est un ISBN $isbn = formatISBN($ex_query); // si échec, ISBN erroné on le prend sous cette forme if (!$isbn) { $code = str_replace("*", "%", $ex_query); } else { $code10 = $isbn; $code = formatISBN($code10, 13); } } else { // ce n'est rien de tout ça, on prend la saisie telle quelle $code = str_replace("*", "%", $ex_query); } } $isbn_OK = $code; $new_notice = 0; $notice_id = 0; // le paramétrage est-il : dédoublonnage sur code ? / Ne dédoublonner que sur code ISBN (ignorer les ISSN) ? if ($params["isbn_dedoublonnage"] && !$params["isbn_only"] || $params["isbn_dedoublonnage"] && $params["isbn_only"] && isISBN($isbn)) { $trouvees = 0; if ($EAN && $isbn) { // cas des EAN purs : constitution de la requête $requete = "SELECT distinct notice_id FROM notices "; $requete .= " WHERE notices.code in ('{$code}','{$EAN}'" . ($code10 ? ",'{$code10}'" : "") . ") limit 1"; $myQuery = mysql_query($requete, $dbh); $trouvees = mysql_num_rows($myQuery); } elseif ($isbn) { // recherche d'un isbn $requete = "SELECT distinct notice_id FROM notices "; $requete .= " WHERE notices.code in ('{$code}'" . ($code10 ? ",'{$code10}'" : "") . ") limit 1"; $myQuery = mysql_query($requete, $dbh); $trouvees = mysql_num_rows($myQuery); } elseif ($code) { // note : le code est recherché dans le champ code des notices // (cas des code-barres disques qui échappent à l'EAN) // $requete = "SELECT notice_id FROM notices "; $requete .= " WHERE notices.code like '{$code}' limit 10"; $myQuery = mysql_query($requete, $dbh); $trouvees = mysql_num_rows($myQuery); } // dédoublonnage sur isbn if ($EAN || $isbn || $code) { if ($trouvees == 0) { $new_notice = 1; } else { $new_notice = 0; $notice_id = mysql_result($myQuery, 0, "notice_id"); $sql_log = mysql_query("insert into error_log (error_origin, error_text) values ('import_expl_" . addslashes(SESSid) . ".inc', '" . $msg[542] . " {$EAN} || {$isbn} || {$code} " . addslashes($tit_200a[0]) . "') "); } } else { if ($params["isbn_mandatory"] == 1) { $sql_log = mysql_query("insert into error_log (error_origin, error_text) values ('import_" . addslashes(SESSid) . ".inc', '" . $msg[543] . "') "); } else { $new_notice = 1; $sql_log = mysql_query("insert into error_log (error_origin, error_text) values ('import_" . addslashes(SESSid) . ".inc', '" . $msg[565] . "') "); } } } else { // pas de dédoublonnage if ($params["isbn_mandatory"] == 1 && $isbn_OK == "") { $sql_log = mysql_query("insert into error_log (error_origin, error_text) values ('import_" . addslashes(SESSid) . ".inc', '" . $msg[543] . "') "); } elseif ($isbn_OK) { $new_notice = 1; } else { $new_notice = 1; $sql_log = mysql_query("insert into error_log (error_origin, error_text) values ('import_" . addslashes(SESSid) . ".inc', '" . $msg[565] . "') "); } } /* the notice is new, we are going to import it... */ if ($new_notice == 1) { import_new_notice(); if ($params["link_generate"]) { import_notice_link(); } import_new_notice_suite(); // Mise à jour de la table "notices_global_index" notice::majNoticesGlobalIndex($notice_id); // Mise à jour de la table "notices_mots_global_index" notice::majNoticesMotsGlobalIndex($notice_id); } else { $notice_deja_presente++; //TRAITEMENT DES DOCS NUMERIQUES SUR NOTICE EXISTANTE global $add_explnum; //Fonction d'import func_ensai_ensae.inc.php if ($add_explnum === TRUE && function_exists("ajoute_explnum")) { ajoute_explnum(); } } // TRAITEMENT DES EXEMPLAIRES ICI if ($with_expl) { traite_exemplaires(); } } } //Fin du traitement des notices //Gestion des logs $formulaire = ""; $script = ""; $log["notice_deja_presente"] = $notice_deja_presente; $log["notice_rejetee"] = $notice_rejetee; $log["nbtot_notice"] = $nbtot_notice; $log["stdout"] = ob_get_contents(); if ($charset != "utf-8") { $log["stdout"] = utf8_encode($log["stdout"]); } ob_end_clean(); $gen_liste_log = ""; $resultat_liste = mysql_query("SELECT error_origin, error_text, count(*) as nb_error FROM error_log where error_origin in ('expl_" . addslashes(SESSid) . ".class','import_expl_" . addslashes(SESSid) . ".inc','iimport_expl_" . addslashes(SESSid) . ".inc','import_" . addslashes(SESSid) . ".inc.php', 'import_" . addslashes(SESSid) . ".inc','import_func_" . addslashes(SESSid) . ".inc.php') group by error_origin, error_text", $dbh); $nb_liste = mysql_num_rows($resultat_liste); if ($nb_liste > 0) { $i_log = 0; while ($i_log < $nb_liste) { $tmp = array(); $tmp["error_origin"] = mysql_result($resultat_liste, $i_log, "error_origin"); if ($charset != "utf-8") { $tmp["error_origin"] = utf8_encode($tmp["error_origin"]); } $tmp["error_text"] = mysql_result($resultat_liste, $i_log, "error_text"); if ($charset != "utf-8") { $tmp["error_text"] = utf8_encode($tmp["error_text"]); } $tmp["nb_error"] = mysql_result($resultat_liste, $i_log, "nb_error"); $log["error_log"][] = $tmp; $i_log++; } mysql_query("DELETE FROM error_log WHERE error_origin in ('expl_" . addslashes(SESSid) . ".class','import_expl_" . addslashes(SESSid) . ".inc','iimport_expl_" . addslashes(SESSid) . ".inc','import_" . addslashes(SESSid) . ".inc.php', 'import_" . addslashes(SESSid) . ".inc','import_func_" . addslashes(SESSid) . ".inc.php')", $dbh); } else { $log["result"] = $this->msg["import_basic_msg_ok"]; if ($charset != "utf-8") { $log["result"] = utf8_encode($log["result"]); } } } else { $log["result"] = $this->msg["import_basic_msg_ko"]; if ($charset != "utf-8") { $log["result"] = utf8_encode($log["result"]); } } return $log; }
static function getNbActes($id_bibli, $type_acte, $statut = '-1', $aq = 0, $user_input = '') { global $dbh; if ($statut == '-1') { $filtre = ''; } elseif ($statut == 32) { $filtre = "and ((actes.statut & 32) = 32) "; } else { $filtre = "and ((actes.statut & 32) = 0) and ((actes.statut & " . $statut . ") = '" . $statut . "') "; } if (!$aq) { $q = "select count(1) from actes where num_entite = '" . $id_bibli . "' "; $q .= "and type_acte = '" . $type_acte . "' " . $filtre . " "; } else { $isbn = ''; $t_codes = array(); if ($user_input !== '') { if (isEAN($user_input)) { // la saisie est un EAN -> on tente de le formater en ISBN $isbn = EANtoISBN($user_input); if ($isbn) { $t_codes[] = $isbn; $t_codes[] = formatISBN($isbn, 10); } } elseif (isISBN($user_input)) { // si la saisie est un ISBN $isbn = formatISBN($user_input); if ($isbn) { $t_codes[] = $isbn; $t_codes[] = formatISBN($isbn, 13); } } } if (count($t_codes)) { $q = "select count(distinct(id_acte)) from actes left join lignes_actes on num_acte=id_acte "; $q .= "where ( num_entite='" . $id_bibli . "' and type_acte='" . $type_acte . "' " . $filtre . " ) "; $q .= "and ('0' "; foreach ($t_codes as $v) { $q .= "or code like '%" . $v . "%' "; } $q .= ") "; } else { $members_actes = $aq->get_query_members("actes", "numero", "index_acte", "id_acte"); $members_lignes = $aq->get_query_members("lignes_actes", "code", "index_ligne", "id_ligne"); $q = "select count(distinct(id_acte)) from actes left join lignes_actes on num_acte=id_acte "; $q .= "where ( num_entite='" . $id_bibli . "' and type_acte='" . $type_acte . "' " . $filtre . " ) "; $q .= "and (" . $members_actes["where"] . " or " . $members_lignes["where"] . ") "; } } $r = mysql_query($q, $dbh); return mysql_result($r, 0, 0); }
function construct_query($query, $not, $level, $argn = "") { //La requête commence-t-elle par and, or ou and not ? $pos = strpos($query, "and not"); if ($pos !== false && $pos == 0) { $ope = "and not"; } else { $pos = strpos($query, "or"); if ($pos !== false && $pos == 0) { $ope = "or"; } else { $pos = strpos($query, "and"); if ($pos !== false && $pos == 0) { $ope = "and"; } else { $ope = ""; } } } if ($ope != "") { //Si opérateur, recherche des arguments $arqs = array(); preg_match("/^" . $ope . " arg" . $level . "!1\\((.*)\\) arg" . $level . "!2\\((.*)\\)\$/", $query, $args); $return1 = construct_query($args[1], 0, $level + 1, 1); if ($ope == "and not") { $return2 = construct_query($args[2], 1, $level + 1, 2); } else { $return2 = construct_query($args[2], 0, $level + 1, 2); } if ($ope == "and not") { $ope = "and"; } $requete = "create temporary table r{$level} ENGINE=MyISAM "; if ($ope == "and") { $requete .= "select distinct {$return1}.notice_id from {$return1}, {$return2} where {$return1}.notice_id={$return2}.notice_id"; @pmb_mysql_query($requete); } else { $requete .= "select distinct notice_id from {$return1}"; @pmb_mysql_query($requete); $requete = "insert into r{$level} select distinct notice_id from {$return2} "; @pmb_mysql_query($requete); } $return = "r{$level}"; } else { $use = explode("=", $query); switch ($use[0]) { //Titre case 4: if ($not) { $requete = "select distinct notice_id from notices where (index_wew not like '%" . $use[1] . "%' )"; } else { $requete = "select distinct notice_id from notices where (index_wew like '%" . $use[1] . "%' )"; } break; //ISBN //ISBN case 7: if (isISBN($use[1])) { // si la saisie est un ISBN $code = formatISBN($use[1]); // si échec, ISBN erroné on le prend sous cette forme if (!$code) { $code = $use[1]; } } else { $code = $use[1]; } if ($not) { $requete = "select notice_id from notices where (code!='" . $code . "')"; } else { $requete = "select notice_id from notices where (code='" . $code . "')"; } break; // Auteur // Auteur case 1003: if ($not) { $requete = "create temporary table aut ENGINE=MyISAM select distinct responsability.responsability_notice as notice_id, index_author as auth from authors, responsability where responsability_author = author_id "; @pmb_mysql_query($requete); $requete = "select distinct notice_id from aut where auth not like '%" . $use[1] . "%'"; } else { $requete = "select distinct notice_id from responsability, authors, notices where index_author like '%" . $use[1] . "%' and author_id=responsability_author and notice_id=responsability_notice "; } break; default: make_error(3, "1=" . $use[0]); break; } $requete = "create temporary table r" . $level . "_" . $argn . " ENGINE=MyISAM " . $requete; @pmb_mysql_query($requete); $return = "r" . $level . "_" . $argn; } return $return; }
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: <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'); if (!$rows[0]["oeuvre"] && $isbn13) { $sparql = "prefix bnf-onto: <http://data.bnf.fr/ontology/>\n\t\t\t\t\tprefix rdarelationships: <http://rdvocab.info/RDARelationshipsWEMI/>\n\t\t\t\t\tSELECT ?oeuvre WHERE {\n\t\t\t\t\t?manifestation bnf-onto:ISBN '{$isbn13}' .\n\t\t\t\t\t?manifestation rdarelationships:workManifested ?oeuvre\n\t\t\t\t\t}"; 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: <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/a9782ddcfea7752a2c5224f971cd991d/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; }
static function get_notice_id_from_cb($code) { if (!$code) { return 0; } $isbn = traite_code_isbn($code); if (isISBN10($isbn)) { $isbn13 = formatISBN($isbn, 13); $isbn10 = $isbn; } elseif (isISBN13($isbn)) { $isbn10 = formatISBN($isbn, 10); $isbn13 = $isbn; } else { // ce n'est pas un code au format isbn $isbn10 = $code; } $requete = "SELECT notice_id FROM notices WHERE ( code='{$isbn10}' or code='{$isbn13}') and code !='' LIMIT 1 "; if ($result = pmb_mysql_query($requete)) { if (pmb_mysql_num_rows($result)) { $notice = pmb_mysql_fetch_object($result); return $notice->notice_id; } } return 0; }
function test_cb() { global $cb; global $barcode; $isbn = ''; $barcode = ''; // on commence par voir ce que la saisie utilisateur est ($cb) $cb = clean_string($cb); if (isEAN($cb)) { // la saisie est un EAN -> on tente de le formater en ISBN $isbn = EANtoISBN($cb); // si échec, on prend l'EAN comme il vient if (!$isbn) { $barcode = $cb; } else { $barcode = $isbn; } } else { if (isISBN($cb)) { // si la saisie est un ISBN $isbn = formatISBN($cb); // si échec, ISBN erroné on le prend sous cette forme if (!$isbn) { $barcode = $cb; } else { $barcode = $isbn; } } else { // ce n'est rien de tout ça, on prend la saisie telle quelle $barcode = $cb; } } }
function getNoticeInfos($notice_id, $source_id) { global $search_index, $url; $error = false; $info = ""; $asin = 0; $params = $this->get_source_params($source_id); $this->fetch_global_properties(); $parameters = unserialize($this->parameters); if ($params["PARAMETERS"]) { //Affichage du formulaire avec $params["PARAMETERS"] $vars = unserialize($params["PARAMETERS"]); foreach ($vars as $key => $val) { global ${$key}; ${$key} = $val; } } $client = $this->initAWS($source_id); $client->__setSoapHeaders($this->make_soap_headers('ItemSearch')); $rqt = "select code from notices where notice_id = '" . $notice_id . "'"; $res = pmb_mysql_query($rqt); if (pmb_mysql_num_rows($res)) { $code = pmb_mysql_result($res, 0, 0); if ($code != "") { $code = preg_replace('/-|\\.| /', '', $code); $paws["Request"] = array("SearchIndex" => $search_index[$url][0], "ResponseGroup" => "ItemIds", "Keywords" => "{$code}"); $paws["AssociateTag"] = $parameters['associatetag']; try { $this->sleep_needed(); $result = $client->ItemSearch($paws); } catch (Exception $e) { $error = true; } if (!$error) { if (is_object($result)) { $result = amazon::objectToArrayAndCharset($result); } $items = $this->soap2array($result["Items"], "Item"); $asin = $items[0][ASIN]; if ($asin) { $client->__setSoapHeaders(NULL); $client->__setSoapHeaders($this->make_soap_headers('ItemLookup')); $paws["Request"] = array("ResponseGroup" => "Large", "IdType" => "ASIN", "ItemId" => $asin); try { $this->sleep_needed(); $result = $client->ItemLookup($paws); } catch (Exception $e) { $error = true; } if (!$error) { if (is_object($result)) { $result = amazon::objectToArrayAndCharset($result); } $items = $this->soap2array($result["Items"], "Item"); //récupération des résumés... $resumes = $this->soap2array($items[0]["EditorialReviews"], "EditorialReview"); if (count($resumes)) { for ($i = 0; $i < count($resumes); $i++) { $infos['resume'] .= $resumes[$i]["Content"] . ($resumes[$i]["Source"] ? " (" . $resumes[$i]["Source"] . ")" : ""); } } //récupération des avis ... $links = $this->soap2array($items[0]["ItemLinks"], "ItemLink"); if (count($links)) { for ($i = 0; $i < count($links); $i++) { if ($links[$i]['Description'] == "All Customer Reviews") { $infos['review'] .= "<iframe src='" . $links[$i]['URL'] . "' style='width:" . $review_width . ";height:" . $review_height . ";'></iframe>"; } } } //récupération des extrait sonore si dispo ... $discs = $this->soap2array($items[0]["Tracks"], "Disc"); if (count($discs)) { $infos['extract_audio'] = "\n\t\t\t\t\t\t\t\t<table>\n\t\t\t\t\t\t\t\t\t<tr>"; for ($i = 0; $i < count($discs); $i++) { $infos['extract_audio'] .= "\n\t\t\t\t\t\t\t\t\t\t<td>\n\t\t\t\t\t\t\t\t\t\t\t<h4>Disque " . $discs[$i]['Number'] . "</h4>\n\t\t\t\t\t\t\t\t\t\t\t<ul>"; for ($j = 0; $j < count($discs[$i]['Track']); $j++) { $infos['extract_audio'] .= "\n\t\t\t\t\t\t\t\t\t\t\t\t<li><a href='http://www.amazon.fr/gp/recsradio/radio/" . $asin . "/ref=pd_krex_dp_a&disc=" . $discs[$i]['Number'] . "&track=" . $discs[$i]['Track'][$j]['Number'] . "' target='_blank' alt='" . sprintf($this->msg['amazon_enrichment_listen_extract'], $discs[$i]['Track'][$j]['_']) . "' title='" . sprintf($this->msg['amazon_enrichment_listen_extract'], $discs[$i]['Track'][$j]['_']) . "'>" . $discs[$i]['Track'][$j]['Number'] . " - " . $discs[$i]['Track'][$j]['_'] . "</a></li>"; } $infos['extract_audio'] .= "\n\t\t\t\t\t\t\t\t\t\t\t</ul>\n\t\t\t\t\t\t\t\t\t\t</td>"; } $infos['extract_audio'] .= "\n\t\t\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t\t</table>"; } //pour les similarités foreach ($items[0][SimilarProducts][SimilarProduct] as $similar) { if (isISBN($similar[ASIN])) { $rqt = "select notice_id from notices where code = '" . formatISBN($similar[ASIN], 10) . "' or code = '" . formatISBN($similar[ASIN], 13) . "' limit 1"; $res = mysql_query($rqt); if (mysql_num_rows($res)) { $notice = mysql_result($res, 0, 0); if ($notice) { $infos['similarities'] .= aff_notice($notice, 1, 1, 0, AFF_ETA_NOTICES_REDUIT, "no", 0, 1); } } } else { //si c'est pas un ISBN on cherche ce que ca peut être... $paws["Request"] = array("ResponseGroup" => "ItemAttributes", "IdType" => "ASIN", "ItemId" => $similar[ASIN]); try { $result = $client->ItemLookup($paws); if (is_object($result)) { $result = amazon::objectToArrayAndCharset($result); } } catch (Exception $e) { $error = true; } if (!$error) { $items = $this->soap2array($result["Items"], "Item"); $code = $items[0][ItemAttributes][UPC]; if ($code) { $rqt = "select notice_id from notices where code = '" . $code . "' or code = '" . $code . "' limit 1"; $res = mysql_query($rqt); if (mysql_num_rows($res)) { $notice = mysql_result($res, 0, 0); if ($notice) { $infos['similarities'] .= aff_notice($notice, 1, 1, 0, AFF_ETA_NOTICES_REDUIT, "no", 0, 1); } } } } } } } } } } } return $infos; }
} // traitement de la soumission if ($suite) { // un CB a été soumis if ($cb) { if (isEAN($cb)) { // la saisie est un EAN -> on tente de le formater en ISBN $code = EANtoISBN($cb); // si échec, on prend l'EAN comme il vient if (!$code) { $code = $cb; } } else { if (isISBN($cb)) { // si la saisie est un ISBN $code = formatISBN($cb, 13); // si échec, ISBN erroné on le prend sous cette forme if (!$code) { $code = $cb; } } else { // ce n'est rien de tout ça, on prend la saisie telle quelle $code = $cb; } } $code_temp = $code; } if ($code_temp) { if ($bulletin) { if ($notice_id) { $and_clause = " and bulletin_id!='" . $notice_id . "'";
} } else { include "./circ/pret.inc.php"; } break; case 'pret_express': $pe_isbn = traite_code_isbn(stripslashes($pe_isbn)); $suite_rqt = ""; $requete_idexpl = "select expl_id from exemplaires where expl_cb='" . addslashes($pe_excb) . "'"; $result = pmb_mysql_query($requete_idexpl, $dbh); if (pmb_mysql_num_rows($result) == 0) { if (isISBN($pe_isbn)) { if (strlen($pe_isbn) == 13) { $suite_rqt = " or code='" . formatISBN($pe_isbn, 13) . "' "; } else { $suite_rqt = "or code='" . formatISBN($pe_isbn, 10) . "' "; } } $acreer = 1; if ($pe_isbn) { $requete = "select notice_id from notices where code='" . addslashes($pe_isbn) . "' " . $suite_rqt . " and niveau_biblio='m' and niveau_hierar='0' "; $result = pmb_mysql_query($requete, $dbh); if ($tmp_not = pmb_mysql_fetch_object($result)) { $id_notice = $tmp_not->notice_id; $acreer = 0; } } if ($acreer) { $requete = "INSERT INTO notices SET code='" . addslashes($pe_isbn) . "', tit1='{$pe_titre}', statut='{$pmb_pret_express_statut}', niveau_biblio='m', niveau_hierar='0', create_date=sysdate() "; $result = pmb_mysql_query($requete, $dbh); if (!$result) {
static function listSuggestions($id_bibli = 0, $statut = '-1', $num_categ = '-1', $mask, $debut = 0, $nb_per_page = 0, $aq = 0, $order = '', $location = 0, $user_input = '', $source = 0, $user_id = 0, $user_statut = '-1') { if ($source) { $filtre_src = " sugg_source = '" . $source . "' "; } else { $filtre_src = " 1 "; } if (!$statut) { $statut = '-1'; } if ($statut == '-1') { $filtre1 = '1'; } elseif ($statut == $mask) { $filtre1 = "(statut & '" . $mask . "') = '" . $mask . "' "; } else { $filtre1 = "(statut & '" . $mask . "') = 0 and (statut & " . $statut . ") = '" . $statut . "' "; } if ($num_categ == '-1') { $filtre2 = '1'; } else { $filtre2 = "num_categ = '" . $num_categ . "' "; } if (!$id_bibli) { $filtre3 = '1'; } else { $filtre3 .= "num_entite = '" . $id_bibli . "' "; } if ($location == 0) { $filtre4 = '1'; } else { $filtre4 = "sugg_location = '" . $location . "' "; } $filtre_empr = ''; $tab_empr = array(); $filtre_user = ''; $tab_user = array(); if (is_array($user_id) && count($user_id) && is_array($user_statut) && count($user_statut)) { foreach ($user_id as $k => $id) { if ($user_statut[$k] == "0") { $tab_user[] = $id; } if ($user_statut[$k] == "1") { $tab_empr[] = $id; } } } if (is_array($tab_empr) && count($tab_empr)) { $filtre_empr = "suggestions_origine.origine in ('" . implode("','", $tab_empr) . "') and type_origine='1' "; } if (is_array($tab_user) && count($tab_user)) { $filtre_user = "******" . implode("','", $tab_user) . "') and type_origine='0' "; } if ($filtre_empr != "" || $filtre_user != "") { $table_origine = ", suggestions_origine "; $join_origine = " id_suggestion=num_suggestion "; if ($filtre_empr && $filtre_user) { $clause_origine = " and ( (" . $filtre_empr . ") or (" . $filtre_user . ") ) and "; } elseif ($filtre_empr) { $clause_origine = " and (" . $filtre_empr . ") and "; } elseif ($filtre_user) { $clause_origine = " and (" . $filtre_user . ") and "; } } if (!$aq) { $q = "select * from suggestions {$table_origine}"; $q .= "where {$join_origine} {$clause_origine} " . $filtre1 . " and " . $filtre2 . " and " . $filtre3 . " and " . $filtre4 . " and " . $filtre_src; if (!$order) { $q .= "order by statut, date_creation desc "; } else { $q .= "order by" . $order . " "; } } else { $isbn = ''; $t_codes = array(); if ($user_input !== '') { if (isEAN($user_input)) { // la saisie est un EAN -> on tente de le formater en ISBN $isbn = EANtoISBN($user_input); if ($isbn) { $t_codes[] = $isbn; $t_codes[] = formatISBN($isbn, 10); } } elseif (isISBN($user_input)) { // si la saisie est un ISBN $isbn = formatISBN($user_input); if ($isbn) { $t_codes[] = $isbn; $t_codes[] = formatISBN($isbn, 13); } } } if (count($t_codes)) { $q = "select * from suggestions {$table_origine}"; $q .= "where {$join_origine} {$clause_origine} (" . $filtre1 . " and " . $filtre2 . " and " . $filtre3 . " and " . $filtre4 . " and " . $filtre_src; $q .= ") "; $q .= "and ('0' "; foreach ($t_codes as $v) { $q .= "or code like '%" . $v . "%' "; } $q .= ") "; if (!$order) { $q .= "order by statut, date_creation desc "; } else { $q .= "order by" . $order . " "; } } else { $members = $aq->get_query_members("suggestions", "concat(titre,' ',editeur,' ',auteur,' ',commentaires)", "index_suggestion", "id_suggestion"); $q = $q = "select *, " . $members["select"] . " as pert from suggestions {$table_origine} "; $q .= "where {$join_origine} {$clause_origine} (" . $filtre1 . " and " . $filtre2 . " and " . $filtre3 . " and " . $filtre4 . " and " . $filtre_src; $q .= ") "; $q .= "and (" . $members["where"] . " "; foreach ($t_codes as $v) { $q .= "or index_suggestion like ('%" . $v . "%') "; } $q .= ") "; if (!$order) { $q .= "order by pert desc "; } else { $q .= "order by " . $order . ", pert desc "; } } } if (!$debut && $nb_per_page) { $q .= "limit " . $nb_per_page; } if ($debut && $nb_per_page) { $q .= "limit " . $debut . "," . $nb_per_page; } return $q; }
if (isEAN($code)) { $EAN = $code; $isbn = EANtoISBN($code); if ($isbn) { //formatISBN10 $tab[] = formatISBN($code, 10); //formatISBN13 $tab[] = formatISBN($code, 13); } } if (isISBN($code)) { $isbn = formatISBN($code); if ($isbn) { //formatISBN10 $tab[] = formatISBN($code, 10); //formatISBN13 $tab[] = formatISBN($code, 13); //format EAN $tab[] = str_replace('-', '', formatISBN($code, 13)); } } if (isISSN($code)) { $tab[] = substr($code, 0, 4) . '-' . substr($code, 4, 4); } $tab = array_unique($tab); ajax_http_send_response(json_encode($tab), 'text/html'); break; default: break; } }
static function get_manifestation_list($uri) { $isbns = array(); $configbnf = array('remote_store_endpoint' => 'http://data.bnf.fr/sparql'); $storebnf = ARC2::getRemoteStore($configbnf); $sparql = "\n\t\tPREFIX bnf-onto: <http://data.bnf.fr/ontology/bnf-onto/>\n\t\tprefix rdarelationships: <http://rdvocab.info/RDARelationshipsWEMI/>\n\t\t\n\t\tSELECT ?isbn WHERE {\n\t\t\t?manifestation bnf-onto:isbn ?isbn.\n\t\t \t?manifestation rdarelationships:workManifested <{$uri}>.\n\t\t}"; $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(); if (!$err) { for ($i = 0; $i < count($rows); $i++) { $isbns[] = formatISBN($rows[$i]['isbn'], 13); $isbns[] = formatISBN($rows[$i]['isbn'], 10); } } return $isbns; }
$resultat_isbd = $ligne["isbd"]; $test_resultat++; $lien = $resultat_titre . " / " . $resultat_auteur; print pmb_bidi(zshow_isbd($resultat_isbd, $lien)); if ($action != "integrerexpl") { if ($source == 'form') { $notice = new z3950_notice('form'); } else { // avant affichage du formulaire : détecter si notice déjà présente pour proposer MAJ $isbn_verif = traite_code_isbn($ligne['isbn']); $suite_rqt = ""; if (isISBN($isbn_verif)) { if (strlen($isbn_verif) == 13) { $suite_rqt = " or code='" . formatISBN($isbn_verif, 13) . "' "; } else { $suite_rqt = "or code='" . formatISBN($isbn_verif, 10) . "' "; } } if ($isbn_verif) { $requete = "SELECT notice_id FROM notices WHERE code='{$isbn_verif}' " . $suite_rqt; $myQuery = mysql_query($requete, $dbh); $temp_nb_notice = mysql_num_rows($myQuery); if ($temp_nb_notice) { $not_id = mysql_result($myQuery, 0, 0); } else { $not_id = 0; } } // if ($not_id) METTRE ICI TRAITEMENT DU CHOIX DU DOUBLON echo "<script> alert('Existe déjà'); </script>" ; $notice = new z3950_notice($format, $ligne['z_marc']); }
function make_search($prefixe = "") { global $search; global $dbh; global $msg; global $include_path; global $pmb_multi_search_operator; global $pmb_search_stemming_active; $this->error_message = ""; $last_table = ""; $field_keyName = $this->keyName; //Pour chaque champ for ($i = 0; $i < count($search); $i++) { //construction de la requete $s = explode("_", $search[$i]); //Recuperation de l'operateur $op = "op_" . $i . "_" . $search[$i]; //Recuperation du contenu de la recherche $field_ = "field_" . $i . "_" . $search[$i]; global ${$field_}; $field = ${$field_}; //Recuperation de l'operateur inter-champ $inter = "inter_" . $i . "_" . $search[$i]; global ${$inter}; global ${$op}; //Recuperation des variables auxiliaires $fieldvar_ = "fieldvar_" . $i . "_" . $search[$i]; global ${$fieldvar_}; $fieldvar = ${$fieldvar_}; //Si c'est un champ fixe if ($s[0] == "f") { $ff = $this->fixedfields[$s[1]]; //Choix du moteur if ($this->memory_engine_allowed && !$ff['MEMORYENGINEFORBIDDEN']) { $this->current_engine = 'MEMORY'; } else { $this->current_engine = 'MyISAM'; } //Calcul des variables $var_table = array(); for ($j = 0; $j < count($ff["VAR"]); $j++) { switch ($ff["VAR"][$j]["TYPE"]) { case "input": $var_table[$ff["VAR"][$j]["NAME"]] = @implode(",", $fieldvar[$ff["VAR"][$j]["NAME"]]); break; case "global": $global_name = $ff["VAR"][$j]["NAME"]; global ${$global_name}; $var_table[$ff["VAR"][$j]["NAME"]] = ${$global_name}; break; case "calculated": $calc = $ff["VAR"][$j]["OPTIONS"]["CALC"][0]; switch ($calc["TYPE"]) { case "value_from_query": $query_calc = $calc["QUERY"][0]["value"]; @reset($var_table); while (list($var_name, $var_value) = @each($var_table)) { $query_calc = str_replace("!!" . $var_name . "!!", $var_value, $query_calc); } $r_calc = pmb_mysql_query($query_calc); $var_table[$ff["VAR"][$j]["NAME"]] = @pmb_mysql_result($r_calc, 0, 0); break; } break; } } $q_index = $ff["QUERIES_INDEX"]; //Recuperation de la requete associee au champ et a l'operateur $q = $ff["QUERIES"][$q_index[${$op}]]; //Si c'est une requete conditionnelle, on sélectionne la bonne requete et on supprime les autres if ($q[0]["CONDITIONAL"]) { $k_default = 0; $q_temp = array(); $q_temp["OPERATOR"] = $q["OPERATOR"]; for ($k = 0; $k < count($q) - 1; $k++) { if ($var_table[$q[$k]["CONDITIONAL"]["name"]] == $q[$k]["CONDITIONAL"]["value"]) { break; } if ($q[$k]["CONDITIONAL"]["value"] == "default") { $k_default = $k; } } if ($k == count($q) - 1) { $k = $k_default; } $q_temp[0] = $q[$k]; $q = $q_temp; } //Remplacement par les variables eventuelles pour chaque requete for ($k = 0; $k < count($q) - 1; $k++) { reset($var_table); while (list($var_name, $var_value) = each($var_table)) { $q[$k]["MAIN"] = str_replace("!!" . $var_name . "!!", $var_value, $q[$k]["MAIN"]); $q[$k]["MULTIPLE_TERM"] = str_replace("!!" . $var_name . "!!", $var_value, $q[$k]["MULTIPLE_TERM"]); } } $last_main_table = ""; // pour les listes, si un opérateur permet une valeur vide, il en faut une... if ($this->op_empty[${$op}] && !is_array($field)) { $field = array(); $field[0] = ""; } // si sélection d'autorité et champ vide : on ne doit pas le prendre en compte if (${$op} == 'AUTHORITY') { $suppr = false; foreach ($field as $k => $v) { if ($v == 0) { unset($field[$k]); $suppr = true; } } if ($suppr) { $field = array_values($field); } } //Pour chaque valeur du champ for ($j = 0; $j < count($field); $j++) { //Pour chaque requete $field_origine = $field[$j]; for ($z = 0; $z < count($q) - 1; $z++) { //Pour chaque valeur du cha //Si le nettoyage de la saisie est demande if ($q[$z]["KEEP_EMPTYWORD"]) { $field[$j] = strip_empty_chars($field_origine); } elseif ($q[$z]["REGDIACRIT"]) { $field[$j] = strip_empty_words($field_origine); } elseif ($q[$z]["DETECTDATE"]) { $field[$j] = detectFormatDate($field_origine, $q[$z]["DETECTDATE"]); } $main = $q[$z]["MAIN"]; //Si il y a plusieurs termes possibles on construit la requete avec le terme !!multiple_term!! if ($q[$z]["MULTIPLE_WORDS"]) { $terms = explode(" ", $field[$j]); //Pour chaque terme, $multiple_terms = array(); for ($k = 0; $k < count($terms); $k++) { $multiple_terms[] = str_replace("!!p!!", $terms[$k], $q[$z]["MULTIPLE_TERM"]); } $final_term = implode(" " . $q[$z]["MULTIPLE_OPERATOR"] . " ", $multiple_terms); $main = str_replace("!!multiple_term!!", $final_term, $main); //Si la saisie est un ISBN } else { if ($q[$z]["ISBN"]) { //Code brut $terms[0] = $field[$j]; //EAN ? if (isEAN($field[$j])) { //C'est un isbn ? if (isISBN($field[$j])) { $rawisbn = preg_replace('/-|\\.| /', '', $field[$j]); //On envoi tout ce qu'on sait faire en matiere d'ISBN, en raw et en formatte, en 10 et en 13 $terms[1] = formatISBN($rawisbn, 10); $terms[2] = formatISBN($rawisbn, 13); $terms[3] = preg_replace('/-|\\.| /', '', $terms[1]); $terms[4] = preg_replace('/-|\\.| /', '', $terms[2]); } } else { if (isISBN($field[$j])) { $rawisbn = preg_replace('/-|\\.| /', '', $field[$j]); //On envoi tout ce qu'on sait faire en matiere d'ISBN, en raw et en formatte, en 10 et en 13 $terms[1] = formatISBN($rawisbn, 10); $terms[2] = formatISBN($rawisbn, 13); $terms[3] = preg_replace('/-|\\.| /', '', $terms[1]); $terms[4] = preg_replace('/-|\\.| /', '', $terms[2]); } } //Pour chaque terme, $multiple_terms = array(); for ($k = 0; $k < count($terms); $k++) { $multiple_terms[] = str_replace("!!p!!", $terms[$k], $q[$z]["MULTIPLE_TERM"]); } $final_term = implode(" " . $q[$z]["MULTIPLE_OPERATOR"] . " ", $multiple_terms); $main = str_replace("!!multiple_term!!", $final_term, $main); } else { if ($q[$z]["BOOLEAN"]) { if ($q[$z]['STEMMING']) { $stemming = $pmb_search_stemming_active; } else { $stemming = 0; } $aq = new analyse_query($field[$j], 0, 0, 1, 0, $stemming); $aq1 = new analyse_query($field[$j], 0, 0, 1, 1, $stemming); if ($q[$z]["KEEP_EMPTY_WORDS_FOR_CHECK"]) { $err = $aq1->error; } else { $err = $aq->error; } if (!$err) { if (is_array($q[$z]["TABLE"])) { for ($z1 = 0; $z1 < count($q[$z]["TABLE"]); $z1++) { $is_fulltext = false; if ($q[$z]["FULLTEXT"][$z1]) { $is_fulltext = true; } if (!$q[$z]["KEEP_EMPTY_WORDS"][$z1]) { $members = $aq->get_query_members($q[$z]["TABLE"][$z1], $q[$z]["INDEX_L"][$z1], $q[$z]["INDEX_I"][$z1], $q[$z]["ID_FIELD"][$z1], $q[$z]["RESTRICT"][$z1], 0, 0, $is_fulltext); } else { $members = $aq1->get_query_members($q[$z]["TABLE"][$z1], $q[$z]["INDEX_L"][$z1], $q[$z]["INDEX_I"][$z1], $q[$z]["ID_FIELD"][$z1], $q[$z]["RESTRICT"][$z1], 0, 0, $is_fulltext); } $main = str_replace("!!pert_term_" . ($z1 + 1) . "!!", $members["select"], $main); $main = str_replace("!!where_term_" . ($z1 + 1) . "!!", $members["where"], $main); } } else { $is_fulltext = false; if ($q[$z]["FULLTEXT"]) { $is_fulltext = true; } if ($q[$z]["KEEP_EMPTY_WORDS"]) { $members = $aq1->get_query_members($q[$z]["TABLE"], $q[$z]["INDEX_L"], $q[$z]["INDEX_I"], $q[$z]["ID_FIELD"], $q[$z]["RESTRICT"], 0, 0, $is_fulltext); } else { $members = $aq->get_query_members($q[$z]["TABLE"], $q[$z]["INDEX_L"], $q[$z]["INDEX_I"], $q[$z]["ID_FIELD"], $q[$z]["RESTRICT"], 0, 0, $is_fulltext); } $main = str_replace("!!pert_term!!", $members["select"], $main); $main = str_replace("!!where_term!!", $members["where"], $main); } } else { $main = "select notice_id from notices where notice_id=0"; $this->error_message = sprintf($msg["searcher_syntax_error_desc"], $aq->current_car, $aq->input_html, $aq->error_message); } } else { if ($q[$z]["WORD"]) { if ($q[$z]['CLASS'] == "searcher_all_fields") { //Pour savoir si la recherche tous champs inclut les docnum ou pas global $mutli_crit_indexation_docnum_allfields; if ($var_table["is_num"]) { $mutli_crit_indexation_docnum_allfields = 1; } else { $mutli_crit_indexation_docnum_allfields = -1; } } //recherche par terme... if ($q[$z]["FIELDS"]) { $searcher = new $q[$z]['CLASS']($field[$j], $q[$z]["FIELDS"]); } else { $searcher = new $q[$z]['CLASS']($field[$j]); } $main = $searcher->get_full_query(); // print "<br><br>".$main; } else { $main = str_replace("!!p!!", addslashes($field[$j]), $main); } } } } //Y-a-t-il une close repeat ? if ($q[$z]["REPEAT"]) { //Si oui, on repete !! $onvals = $q[$z]["REPEAT"]["ON"]; global ${$onvals}; $onvalst = explode($q[$z]["REPEAT"]["SEPARATOR"], ${$onvals}); $mains = array(); for ($ir = 0; $ir < count($onvalst); $ir++) { $mains[] = str_replace("!!" . $q[$z]["REPEAT"]["NAME"] . "!!", $onvalst[$ir], $main); } $main = implode(" " . $q[$z]["REPEAT"]["OPERATOR"] . " ", $mains); $main = "select * from (" . $main . ") as sbquery" . ($q[$z]["REPEAT"]["ORDERTERM"] ? " order by " . $q[$z]["REPEAT"]["ORDERTERM"] : ""); } if ($z < count($q) - 2) { pmb_mysql_query($main); } } if ($fieldvar["operator_between_multiple_authorities"]) { $operator = $fieldvar["operator_between_multiple_authorities"][0]; } elseif ($q["DEFAULT_OPERATOR"]) { $operator = $q["DEFAULT_OPERATOR"]; } else { $operator = $pmb_multi_search_operator ? $pmb_multi_search_operator : "or"; } if (count($field) > 1) { if ($operator == "or") { //Ou logique si plusieurs valeurs if ($prefixe) { $requete = "create temporary table " . $prefixe . "mf_" . $j . " ENGINE=" . $this->current_engine . " " . $main; @pmb_mysql_query($requete, $dbh); $requete = "alter table " . $prefixe . "mf_" . $j . " add idiot int(1)"; @pmb_mysql_query($requete); $requete = "alter table " . $prefixe . "mf_" . $j . " add unique({$field_keyName})"; @pmb_mysql_query($requete); } else { $requete = "create temporary table mf_" . $j . " ENGINE=" . $this->current_engine . " " . $main; @pmb_mysql_query($requete, $dbh); $requete = "alter table mf_" . $j . " add idiot int(1)"; @pmb_mysql_query($requete); $requete = "alter table mf_" . $j . " add unique({$field_keyName})"; @pmb_mysql_query($requete); } if ($last_main_table) { if ($prefixe) { $requete = "insert ignore into " . $prefixe . "mf_" . $j . " select " . $last_main_table . ".* from " . $last_main_table; } else { $requete = "insert ignore into mf_" . $j . " select " . $last_main_table . ".* from " . $last_main_table; } pmb_mysql_query($requete, $dbh); //pmb_mysql_query("drop table mf_".$j,$dbh); pmb_mysql_query("drop table " . $last_main_table, $dbh); } //else pmb_mysql_query("drop table mf_".$j,$dbh); if ($prefixe) { $last_main_table = $prefixe . "mf_" . $j; } else { $last_main_table = "mf_" . $j; } } elseif ($operator == "and") { //ET logique si plusieurs valeurs if ($prefixe) { $requete = "create temporary table " . $prefixe . "mf_" . $j . " ENGINE=" . $this->current_engine . " " . $main; @pmb_mysql_query($requete, $dbh); $requete = "alter table " . $prefixe . "mf_" . $j . " add idiot int(1)"; @pmb_mysql_query($requete); $requete = "alter table " . $prefixe . "mf_" . $j . " add unique({$field_keyName})"; @pmb_mysql_query($requete); } else { $requete = "create temporary table mf_" . $j . " ENGINE=" . $this->current_engine . " " . $main; @pmb_mysql_query($requete, $dbh); $requete = "alter table mf_" . $j . " add idiot int(1)"; @pmb_mysql_query($requete); $requete = "alter table mf_" . $j . " add unique({$field_keyName})"; @pmb_mysql_query($requete); } if ($last_main_table) { if ($prefixe) { $requete = "create temporary table " . $prefixe . "and_result_" . $j . " ENGINE=" . $this->current_engine . " select " . $last_tables . ".* from " . $last_tables . " where exists ( select " . $prefixe . "mf_" . $j . ".* from " . $prefixe . "mf_" . $j . " where " . $last_tables . ".notice_id=" . $prefixe . "mf_" . $j . ".notice_id)"; } else { $requete = "create temporary table and_result_" . $j . " ENGINE=" . $this->current_engine . " select " . $last_tables . ".* from " . $last_tables . " where exists ( select mf_" . $j . ".* from mf_" . $j . " where " . $last_tables . ".notice_id=mf_" . $j . ".notice_id)"; } pmb_mysql_query($requete, $dbh); pmb_mysql_query("drop table " . $last_tables, $dbh); } if ($prefixe) { $last_tables = $prefixe . "mf_" . $j; } else { $last_tables = "mf_" . $j; } if ($prefixe) { $last_main_table = $prefixe . "and_result_" . $j; } else { $last_main_table = "and_result_" . $j; } } } //else print $main; } if ($last_main_table) { $main = "select * from " . $last_main_table; } } elseif (array_key_exists($s[0], $this->pp)) { $datatype = $this->pp[$s[0]]->t_fields[$s[1]]["DATATYPE"]; $df = $this->dynamicfields[$s[0]]["FIELD"][$this->get_id_from_datatype($datatype, $s[0])]; $q_index = $df["QUERIES_INDEX"]; $q = $df["QUERIES"][$q_index[${$op}]]; //Choix du moteur if ($this->memory_engine_allowed && !$df['MEMORYENGINEFORBIDDEN']) { $this->current_engine = 'MEMORY'; } else { $this->current_engine = 'MyISAM'; } //Pour chaque valeur du champ $last_main_table = ""; if (count($field) == 0) { $field[0] = ""; } for ($j = 0; $j < count($field); $j++) { if ($q["KEEP_EMPTYWORD"]) { $field[$j] = strip_empty_chars($field[$j]); } elseif ($q["REGDIACRIT"]) { $field[$j] = strip_empty_words($field[$j]); } $main = $q["MAIN"]; //Si il y a plusieurs termes possibles if ($q["MULTIPLE_WORDS"]) { $terms = explode(" ", $field[$j]); //Pour chaque terme $multiple_terms = array(); for ($k = 0; $k < count($terms); $k++) { $mt = str_replace("!!p!!", addslashes($terms[$k]), $q["MULTIPLE_TERM"]); $mt = str_replace("!!field!!", $s[1], $mt); $multiple_terms[] = $mt; } $final_term = implode(" " . $q["MULTIPLE_OPERATOR"] . " ", $multiple_terms); $main = str_replace("!!multiple_term!!", $final_term, $main); } else { $main = str_replace("!!p!!", addslashes($field[$j]), $main); } $main = str_replace("!!field!!", $s[1], $main); if ($q["WORD"]) { //recherche par terme... $searcher = new $q['CLASS']($field[$j], $s[1]); $main = $searcher->get_full_query(); } //Choix de l'operateur dans la liste if ($q["DEFAULT_OPERATOR"]) { $operator = $q["DEFAULT_OPERATOR"]; } else { $operator = $pmb_multi_search_operator ? $pmb_multi_search_operator : "or"; } if (count($field) > 1) { if ($operator == "or") { //Ou logique si plusieurs valeurs if ($prefixe) { $requete = "create temporary table " . $prefixe . "mf_" . $j . " ENGINE=" . $this->current_engine . " " . $main; @pmb_mysql_query($requete, $dbh); $requete = "alter table " . $prefixe . "mf_" . $j . " add idiot int(1)"; @pmb_mysql_query($requete); $requete = "alter table " . $prefixe . "mf_" . $j . " add unique({$field_keyName})"; @pmb_mysql_query($requete); } else { $requete = "create temporary table mf_" . $j . " ENGINE=" . $this->current_engine . " " . $main; @pmb_mysql_query($requete, $dbh); $requete = "alter table mf_" . $j . " add idiot int(1)"; @pmb_mysql_query($requete); $requete = "alter table mf_" . $j . " add unique({$field_keyName})"; @pmb_mysql_query($requete); } if ($last_main_table) { if ($prefixe) { $requete = "insert ignore into " . $prefixe . "mf_" . $j . " select " . $last_main_table . ".* from " . $last_main_table; } else { $requete = "insert ignore into mf_" . $j . " select " . $last_main_table . ".* from " . $last_main_table; } pmb_mysql_query($requete, $dbh); //pmb_mysql_query("drop table mf_".$j,$dbh); pmb_mysql_query("drop table " . $last_main_table, $dbh); } //else pmb_mysql_query("drop table mf_".$j,$dbh); if ($prefixe) { $last_main_table = $prefixe . "mf_" . $j; } else { $last_main_table = "mf_" . $j; } } elseif ($operator == "and") { //ET logique si plusieurs valeurs if ($prefixe) { $requete = "create temporary table " . $prefixe . "mf_" . $j . " ENGINE=" . $this->current_engine . " " . $main; @pmb_mysql_query($requete, $dbh); $requete = "alter table " . $prefixe . "mf_" . $j . " add idiot int(1)"; @pmb_mysql_query($requete); $requete = "alter table " . $prefixe . "mf_" . $j . " add unique({$field_keyName})"; @pmb_mysql_query($requete); } else { $requete = "create temporary table mf_" . $j . " ENGINE=" . $this->current_engine . " " . $main; @pmb_mysql_query($requete, $dbh); $requete = "alter table mf_" . $j . " add idiot int(1)"; @pmb_mysql_query($requete); $requete = "alter table mf_" . $j . " add unique({$field_keyName})"; @pmb_mysql_query($requete); } if ($last_main_table) { if ($prefixe) { $requete = "create temporary table " . $prefixe . "and_result_" . $j . " ENGINE=" . $this->current_engine . " select " . $last_tables . ".* from " . $last_tables . " where exists ( select " . $prefixe . "mf_" . $j . ".* from " . $prefixe . "mf_" . $j . " where " . $last_tables . ".notice_id=" . $prefixe . "mf_" . $j . ".notice_id)"; } else { $requete = "create temporary table and_result_" . $j . " ENGINE=" . $this->current_engine . " select " . $last_tables . ".* from " . $last_tables . " where exists ( select mf_" . $j . ".* from mf_" . $j . " where " . $last_tables . ".notice_id=mf_" . $j . ".notice_id)"; } pmb_mysql_query($requete, $dbh); pmb_mysql_query("drop table " . $last_tables, $dbh); } if ($prefixe) { $last_tables = $prefixe . "mf_" . $j; } else { $last_tables = "mf_" . $j; } if ($prefixe) { $last_main_table = $prefixe . "and_result_" . $j; } else { $last_main_table = "and_result_" . $j; } } } //else print $main; } if ($last_main_table) { $main = "select * from " . $last_main_table; } } elseif ($s[0] == "s") { //instancier la classe de traitement du champ special $type = $this->specialfields[$s[1]]["TYPE"]; for ($is = 0; $is < count($this->tableau_speciaux["TYPE"]); $is++) { if ($this->tableau_speciaux["TYPE"][$is]["NAME"] == $type) { $sf = $this->specialfields[$s[1]]; require_once $include_path . "/search_queries/specials/" . $this->tableau_speciaux["TYPE"][$is]["PATH"] . "/search.class.php"; $specialclass = new $this->tableau_speciaux["TYPE"][$is]["CLASS"]($s[1], $i, $sf, $this); $last_main_table = $specialclass->make_search(); break; } } if ($last_main_table) { $main = "select * from " . $last_main_table; } } elseif ($s[0] == "authperso") { $aq = new analyse_query($field[0], 0, 0, 1, 1, $opac_stemming_active); $members = $aq->get_query_members("authperso_authorities", "authperso_infos_global", "authperso_index_infos_global", "id_authperso_authority"); $clause = "where " . $members["where"] . " and notice_id=notice_authperso_notice_num and notice_authperso_authority_num=id_authperso_authority and authperso_authority_authperso_num=" . $s[1]; $main = "select distinct notice_id FROM notices,notices_authperso,authperso_authorities {$clause} "; if ($last_main_table) { $main = "select * from " . $last_main_table; } } if ($prefixe) { $table = $prefixe . "t_" . $i . "_" . $search[$i]; $requete = "create temporary table " . $prefixe . "t_" . $i . "_" . $search[$i] . " ENGINE=" . $this->current_engine . " " . $main; pmb_mysql_query($requete, $dbh); $requete = "alter table " . $prefixe . "t_" . $i . "_" . $search[$i] . " add idiot int(1)"; @pmb_mysql_query($requete); $requete = "alter table " . $prefixe . "t_" . $i . "_" . $search[$i] . " add unique({$field_keyName})"; pmb_mysql_query($requete); } else { $table = "t_" . $i . "_" . $search[$i]; $requete = "create temporary table t_" . $i . "_" . $search[$i] . " ENGINE=" . $this->current_engine . " " . $main; pmb_mysql_query($requete, $dbh); $requete = "alter table t_" . $i . "_" . $search[$i] . " add idiot int(1)"; @pmb_mysql_query($requete); $requete = "alter table t_" . $i . "_" . $search[$i] . " add unique({$field_keyName})"; pmb_mysql_query($requete); } if ($last_main_table) { $requete = "drop table " . $last_main_table; pmb_mysql_query($requete); } if ($prefixe) { $requete = "create temporary table " . $prefixe . "t" . $i . " ENGINE=" . $this->current_engine . " "; } else { $requete = "create temporary table t" . $i . " ENGINE=" . $this->current_engine . " "; } $isfirst_criteria = false; switch (${$inter}) { case "and": $requete .= "select " . $table . ".* from {$last_table},{$table} where " . $table . ".{$field_keyName}=" . $last_table . ".{$field_keyName} and {$table}.idiot is null and {$last_table}.idiot is null"; @pmb_mysql_query($requete, $dbh); break; case "or": //Si la table précédente est vide, c'est comme au premier jour ! $requete_c = "select count(*) from " . $last_table; if (!@pmb_mysql_result(pmb_mysql_query($requete_c), 0, 0)) { $isfirst_criteria = true; } else { $requete .= "select * from " . $table; @pmb_mysql_query($requete, $dbh); if ($prefixe) { $requete = "alter table " . $prefixe . "t" . $i . " add idiot int(1)"; @pmb_mysql_query($requete); $requete = "alter table " . $prefixe . "t" . $i . " add unique({$field_keyName})"; @pmb_mysql_query($requete); } else { $requete = "alter table t" . $i . " add idiot int(1)"; @pmb_mysql_query($requete); $requete = "alter table t" . $i . " add unique({$field_keyName})"; @pmb_mysql_query($requete); } if ($prefixe) { $requete = "insert into " . $prefixe . "t" . $i . " ({$field_keyName},idiot) select distinct " . $last_table . "." . $field_keyName . "," . $last_table . ".idiot from " . $last_table . " left join " . $table . " on " . $last_table . ".{$field_keyName}=" . $table . ".{$field_keyName} where " . $table . ".{$field_keyName} is null"; } else { $requete = "insert into t" . $i . " ({$field_keyName},idiot) select distinct " . $last_table . "." . $field_keyName . "," . $last_table . ".idiot from " . $last_table . " left join " . $table . " on " . $last_table . ".{$field_keyName}=" . $table . ".{$field_keyName} where " . $table . ".{$field_keyName} is null"; //print $requete; } @pmb_mysql_query($requete, $dbh); } break; case "ex": //$requete_not="create temporary table ".$table."_b select notices.notice_id from notices left join ".$table." on notices.notice_id=".$table.".notice_id where ".$table.".notice_id is null"; //@pmb_mysql_query($requete_not); //$requete_not="alter table ".$table."_b add idiot int(1), add unique(notice_id)"; //@pmb_mysql_query($requete_not); $requete .= "select " . $last_table . ".* from {$last_table} left join " . $table . " on " . $table . ".{$field_keyName}=" . $last_table . ".{$field_keyName} where " . $table . ".{$field_keyName} is null"; @pmb_mysql_query($requete); //$requete="drop table ".$table."_b"; //@pmb_mysql_query($requete); if ($prefixe) { $requete = "alter table " . $prefixe . "t" . $i . " add idiot int(1)"; @pmb_mysql_query($requete); $requete = "alter table " . $prefixe . "t" . $i . " add unique({$field_keyName})"; @pmb_mysql_query($requete); } else { $requete = "alter table t" . $i . " add idiot int(1)"; @pmb_mysql_query($requete); $requete = "alter table t" . $i . " add unique({$field_keyName})"; @pmb_mysql_query($requete); } break; default: $isfirst_criteria = true; @pmb_mysql_query($requete, $dbh); $requete = "alter table {$table} add idiot int(1)"; @pmb_mysql_query($requete); $requete = "alter table {$table} add unique({$field_keyName})"; @pmb_mysql_query($requete); break; } if (!$isfirst_criteria) { pmb_mysql_query("drop table if exists {$last_table}", $dbh); pmb_mysql_query("drop table if exists {$table}", $dbh); if ($prefixe) { $last_table = $prefixe . "t" . $i; } else { $last_table = "t" . $i; } } else { pmb_mysql_query("drop table if exists {$last_table}", $dbh); $last_table = $table; } } return $last_table; }
} // les requis par display.inc.php include "{$include_path}/marc_tables/{$pmb_indexation_lang}/empty_words"; include "{$class_path}/iso2709.class.php"; $rqsql = "select * from z_notices, z_bib where znotices_query_id ='{$last_query_id}' and bib_id=znotices_bib_id order by {$tri1}, {$tri2}"; $resultat3 = mysql_query($rqsql); $test_resultat = 0; $retour_affichage = ""; $i = 0; while ($ligne3 = mysql_fetch_array($resultat3)) { $znotices_id = $ligne3["znotices_id"]; $resultat_titre = $ligne3["titre"]; $resultat_auteur = $ligne3["auteur"]; $resultat_isbd = $ligne3["isbd"]; if (isISBN($ligne3["isbn"])) { $resultat_isbn = formatISBN($ligne3["isbn"]); } else { $resultat_isbn = $ligne3["isbn"]; } $resultat_bib_name = $ligne3["bib_nom"]; $resultat_bib_format = $ligne3["format"]; $test_resultat++; $lien = "<a "; if ($i == 0) { $lien .= " id='premierresultat' "; } $i++; $lien .= " href='./catalog.php?categ=z3950&action=import&id_notice={$id_notice}&znotices_id=" . $znotices_id . "&last_query_id=" . $last_query_id . "&tri1=" . $tri1 . "&tri2=" . $tri2 . "' >" . $resultat_titre . " / " . $resultat_auteur . "</a>"; $retour_affichage .= zshow_isbd($resultat_isbd, $lien); $retour_affichage .= "<small><strong>( {$resultat_bib_name} / {$resultat_bib_format} )<br /></strong></small><br />"; }
if (!$isbn) { $code = str_replace("*", "%", $ex_query); } else { $code = $isbn; $code10 = formatISBN($code, 10); } } else { if (isISBN($ex_query)) { // si la saisie est un ISBN $isbn = formatISBN($ex_query); // si échec, ISBN erroné on le prend sous cette forme if (!$isbn) { $code = str_replace("*", "%", $ex_query); } else { $code10 = $isbn; $code = formatISBN($code10, 13); } } else { // ce n'est rien de tout ça, on prend la saisie telle quelle $code = str_replace("*", "%", $ex_query); // filtrer par typdoc_query si selectionné if ($typdoc_query) { $where_typedoc = " and typdoc='{$typdoc_query}' "; } } } if ($nb_results) { $limit_page = " limit " . $page * $nb_per_page_search . ", {$nb_per_page_search} "; } else { $limit_page = " "; $page = 0;
function show_results($dbh, $user_input, $nbr_lignes = 0, $page = 0, $id = 0) { global $nb_per_page; global $base_url; global $caller; global $msg; global $no_display; global $charset; global $niveau_biblio, $modele_id, $serial_id; global $acces_j; if ($niveau_biblio) { $filtre_notice = " and niveau_biblio='{$niveau_biblio}' "; } // on récupére le nombre de lignes qui vont bien if ($user_input == "") { $requete_count = "SELECT COUNT(1) FROM notices "; $requete_count .= $acces_j; $requete_count .= "where notice_id!='" . $no_display . "' {$filtre_notice} "; } else { $aq = new analyse_query(stripslashes($user_input)); if ($aq->error) { error_message($msg["searcher_syntax_error"], sprintf($msg["searcher_syntax_error_desc"], $aq->current_car, $aq->input_html, $aq->error_message)); exit; } $members = $aq->get_query_members("notices", "index_wew", "index_sew", "notice_id"); $isbn_verif = traite_code_isbn(stripslashes($user_input)); $suite_rqt = ""; if (isISBN($isbn_verif)) { if (strlen($isbn_verif) == 13) { $suite_rqt = " code like '" . formatISBN($isbn_verif, 13) . "' or code like '" . addslashes($isbn_verif) . "' "; } else { $suite_rqt = " code like '" . formatISBN($isbn_verif, 10) . "' or code like '" . addslashes($isbn_verif) . "' "; } $requete_count = "select count(1) from notices "; $requete_count .= $acces_j; $requete_count .= "where ( " . $suite_rqt . " ) "; $requete_count .= "and notice_id!='" . $no_display . "' {$filtre_notice}"; } else { $requete_count = "select count(1) from notices "; $requete_count .= $acces_j; $requete_count .= "where (" . $members["where"] . " or code like '" . addslashes($isbn_verif) . "' ) "; $requete_count .= "and notice_id!='" . $no_display . "' {$filtre_notice}"; } } $res = mysql_query($requete_count, $dbh); $nbr_lignes = @mysql_result($res, 0, 0); if (!$page) { $page = 1; } $debut = ($page - 1) * $nb_per_page; if ($nbr_lignes) { // on lance la vraie requête if ($user_input == "") { $requete = "SELECT notice_id, tit1, serie_name, tnvol, code FROM notices "; $requete .= $acces_j; $requete .= "left join series on serie_id=tparent_id "; $requete .= "where notice_id!='" . $no_display . "' {$filtre_notice} ORDER BY index_sew, code LIMIT {$debut},{$nb_per_page} "; } else { $isbn_verif = traite_code_isbn(stripslashes($user_input)); $suite_rqt = ""; if (isISBN($isbn_verif)) { if (strlen($isbn_verif) == 13) { $suite_rqt = " code like '" . formatISBN($isbn_verif, 13) . "' or code like '" . addslashes($isbn_verif) . "' "; } else { $suite_rqt = " code like '" . formatISBN($isbn_verif, 10) . "' or code like '" . addslashes($isbn_verif) . "' "; } $requete = "select notice_id, tit1, serie_name, tnvol, code from notices "; $requete .= $acces_j; $requete .= "left join series on serie_id=tparent_id "; $requete .= "where ( " . $suite_rqt . " ) "; $requete .= "and notice_id!='" . $no_display . "' {$filtre_notice} group by notice_id limit {$debut},{$nb_per_page}"; } else { $requete = "select notice_id, tit1, serie_name, tnvol, code, " . $members["select"] . " as pert from notices "; $requete .= $acces_j; $requete .= "left join series on serie_id=tparent_id where (" . $members["where"] . " or (code like '" . addslashes($isbn_verif) . "' )) "; $requete .= "and notice_id!='" . $no_display . "' {$filtre_notice} group by notice_id order by pert desc, index_sew, code limit {$debut},{$nb_per_page}"; } } $res = @mysql_query($requete, $dbh); while ($notice = mysql_fetch_object($res)) { $notice_entry = ""; if ($notice->serie_name) { $notice_entry .= $notice->serie_name; if ($notice->tnvol) { $notice_entry .= ", " . $notice->tnvol; } } $notice_entry ? $notice_entry .= '. ' . $notice->tit1 : ($notice_entry = $notice->tit1); if ($niveau_biblio) { $location = "./catalog.php?categ=serials&sub=modele&act=copy&modele_id={$modele_id}&serial_id={$serial_id}&new_serial_id={$notice->notice_id}"; $display = new mono_display($notice->notice_id, 0, '', 0, '', '', '', 0, 0, 0, 0, "", 0, false, true); print pmb_bidi("<div class='row'>\n\t\t\t\t\t\t\t\t<div class='left'>\n\t\t\t\t\t\t\t\t\t<a href='#' onclick=\"copier_modele('{$location}')\">" . $display->result . "</a>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div class='right'>\n\t\t\t\t\t\t\t\t\t" . htmlentities($notice->code, ENT_QUOTES, $charset) . "\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>"); } else { $display = new mono_display($notice->notice_id, 0, '', 0, '', '', '', 0, 0, 0, 0, "", 0, false, true); print pmb_bidi("<div class='row'>\n\t\t\t\t\t\t\t\t<div class='left'>\n\t\t\t\t\t\t\t\t\t<a href='#' onclick=\"set_parent('{$caller}', '{$notice->notice_id}', '" . htmlentities(addslashes($notice_entry), ENT_QUOTES, $charset) . " ({$notice->code})')\">" . $display->result . "</a>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t<div class='right'>\n\t\t\t\t\t\t\t\t\t" . htmlentities($notice->code, ENT_QUOTES, $charset) . "\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>"); } } mysql_free_result($res); // constitution des liens $nbepages = ceil($nbr_lignes / $nb_per_page); $suivante = $page + 1; $precedente = $page - 1; } print "<div class='row'> <hr /></div><div align='center'>"; $url_base = $base_url . "&user_input=" . rawurlencode(stripslashes($user_input)); $nav_bar = aff_pagination($url_base, $nbr_lignes, $nb_per_page, $page, 10, false, true); print $nav_bar; print "</div>"; }