function import_new_notice_suite() { global $dbh; global $notice_id; global $info_606_a; global $pmb_keyword_sep; global $info_900; $mots_cles = ''; for ($a = 0; $a < sizeof($info_606_a); $a++) { $mots_cles .= $info_606_a[$a][0] . " {$pmb_keyword_sep} "; } $mots_cles ? $index_matieres = strip_empty_words($mots_cles) : ($index_matieres = ''); $rqt_maj = "update notices set index_l='" . addslashes($mots_cles) . "', index_matieres=' " . addslashes($index_matieres) . " ' where notice_id='{$notice_id}' "; pmb_mysql_query($rqt_maj, $dbh); for ($i = 0; $i < count($info_900); $i++) { $req = " select idchamp, type, datatype from notices_custom where name='" . $info_900[$i]['n'] . "'"; $res = pmb_mysql_query($req, $dbh); if (pmb_mysql_num_rows($res)) { $perso = pmb_mysql_fetch_object($res); if ($perso->idchamp) { if ($perso->type == 'list') { $requete = "select notices_custom_list_value from notices_custom_lists where notices_custom_list_lib='" . addslashes($info_900[$i]['a']) . "' and notices_custom_champ={$perso->idchamp}"; $resultat = pmb_mysql_query($requete); if (pmb_mysql_num_rows($resultat)) { $value = pmb_mysql_result($resultat, 0, 0); } else { $requete = "select max(notices_custom_list_value*1) from notices_custom_lists where notices_custom_champ={$perso->idchamp}"; $resultat = pmb_mysql_query($requete); $max = @pmb_mysql_result($resultat, 0, 0); $n = $max + 1; $requete = "insert into notices_custom_lists (notices_custom_champ,notices_custom_list_value,notices_custom_list_lib) values({$perso->idchamp},{$n},'" . addslashes($info_900[$i]['a']) . "')"; pmb_mysql_query($requete); $value = $n; } $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values({$perso->idchamp},{$notice_id},{$value})"; pmb_mysql_query($requete); } elseif ($perso->type == 'date_box') { $tmp_date = ''; $tmp_date = str_replace('/', '', $info_900[$i]['a']); $tmp_date = substr($tmp_date, 4, 4) . '-' . substr($tmp_date, 0, 2) . '-' . substr($tmp_date, 2, 2); $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_date) values({$perso->idchamp},{$notice_id},'" . addslashes($tmp_date) . "')"; pmb_mysql_query($requete); } else { $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_" . $perso->datatype . ") values({$perso->idchamp},{$notice_id},'" . addslashes($info_900[$i]['a']) . "')"; pmb_mysql_query($requete); } } } } }
function save() { global $dbh; $no = new noeuds($this->num_noeud); $num_thesaurus = $no->num_thesaurus; $q = "update categories set "; $q .= "num_thesaurus = '" . $num_thesaurus . "', "; $q .= "libelle_categorie = '" . addslashes($this->libelle_categorie) . "', "; $q .= "note_application = '" . addslashes($this->note_application) . "', "; $q .= "comment_public = '" . addslashes($this->comment_public) . "', "; $q .= "comment_voir = '" . addslashes($this->comment_voir) . "', "; $q .= "index_categorie = ' " . addslashes(strip_empty_words($this->libelle_categorie, $this->langue)) . " ' "; $q .= "where num_noeud = '" . $this->num_noeud . "' and langue = '" . $this->langue . "' "; $r = pmb_mysql_query($q, $dbh); categories::update_index($this->num_noeud); }
function save() { global $dbh; if ($this->libelle == '') { die("Erreur de création frais"); } if ($this->id_frais) { $q = "update frais set libelle ='" . $this->libelle . "', condition_frais = '" . $this->condition_frais . "', "; $q .= "montant = '" . $this->montant . "', num_cp_compta = '" . $this->num_cp_compta . "', "; $q .= "num_tva_achat = '" . $this->num_tva_achat . "', index_libelle = ' " . strip_empty_words($this->libelle) . " ' "; $q .= "where id_frais = '" . $this->id_frais . "' "; $r = mysql_query($q, $dbh); } else { $q = "insert into frais set libelle = '" . $this->libelle . "', condition_frais = '" . $this->condition_frais . "', "; $q .= "montant = '" . $this->montant . "', num_cp_compta = '" . $this->num_cp_compta . "', num_tva_achat = '" . $this->num_tva_achat . "', index_libelle = ' " . strip_empty_words($this->libelle) . " ' "; $r = mysql_query($q, $dbh); $this->id_frais = mysql_insert_id($dbh); } }
function save() { global $titre, $sujet, $idtheme, $idtype, $date_fin, $id_empr, $dbh, $demandes_statut_notice, $pmb_type_audit; global $demandes_email_demandes; $index_wew = $titre; $index_sew = strip_empty_words($index_wew); $index_ncontenu = strip_empty_words($sujet); $req = "insert into notices set \n\t\ttit1='" . $titre . "',\n\t\tn_contenu='" . $sujet . "',\n\t\tstatut ='" . $demandes_statut_notice . "',\n\t\tindex_sew ='" . $index_sew . "',\n\t\tindex_wew ='" . $index_wew . "',\n\t\tindex_n_contenu = '" . $index_ncontenu . "',\n\t\tcreate_date = CURRENT_TIMESTAMP()\n\t\t"; mysql_query($req, $dbh); $id_notice = mysql_insert_id(); if ($pmb_type_audit) { $query = "INSERT INTO audit SET "; $query .= "type_obj='1', "; $query .= "object_id='{$id_notice}', "; $query .= "type_modif=1 "; $result = @mysql_query($query, $dbh); } $date = date("Ymd", time()); $req = "insert into demandes set \n\t\t\ttitre_demande='" . $titre . "',\n\t\t\tsujet_demande='" . $sujet . "',\n\t\t\ttheme_demande='" . $idtheme . "',\n\t\t\ttype_demande='" . $idtype . "',\n\t\t\tdeadline_demande='" . $date_fin . "',\n\t\t\tdate_demande='" . $date . "',\n\t\t\tdate_prevue='" . $date . "',\n\t\t\tnum_demandeur='" . $id_empr . "',\n\t\t\tnum_notice='" . $id_notice . "',\n\t\t\tetat_demande=1\n\t\t"; mysql_query($req, $dbh); if ($demandes_email_demandes) { $this->alert_mail_users_pmb($id_empr); } }
function rec_record($record, $source_id, $search_id) { global $charset, $base_path, $url, $search_index; $date_import = date("Y-m-d H:i:s", time()); //Recherche du 001 $ref = $record["001"][0]; //Mise � jour if ($ref) { //Si conservation des anciennes notices, on regarde si elle existe if (!$this->del_old) { $requete = "select count(*) from entrepot_source_" . $source_id . " where ref='" . addslashes($ref) . "' and search_id='" . addslashes($search_id) . "'"; $rref = pmb_mysql_query($requete); if ($rref) { $ref_exists = pmb_mysql_result($rref, 0, 0); } } //Si pas de conservation des anciennes notices, on supprime if ($this->del_old) { $requete = "delete from entrepot_source_" . $source_id . " where ref='" . addslashes($ref) . "' and search_id='" . addslashes($search_id) . "'"; pmb_mysql_query($requete); $this->delete_from_external_count($source_id, $ref); } //Si pas de conservation ou ref�rence inexistante if ($this->del_old || !$this->del_old && !$ref_exists) { //Insertion de l'ent�te $n_header["rs"] = "*"; $n_header["ru"] = "*"; $n_header["el"] = "1"; $n_header["bl"] = "m"; $n_header["hl"] = "0"; $n_header["dt"] = $this->types[$search_index[$url][0]]; if (!$n_header["dt"]) { $n_header["dt"] = "a"; } $n_header["001"] = $record["001"][0]; //R�cup�ration d'un ID $requete = "insert into external_count (recid, source_id) values('" . addslashes($this->get_id() . " " . $source_id . " " . $ref) . "', " . $source_id . ")"; $rid = pmb_mysql_query($requete); if ($rid) { $recid = pmb_mysql_insert_id(); } foreach ($n_header as $hc => $code) { $requete = "insert into entrepot_source_" . $source_id . " (connector_id,source_id,ref,date_import,ufield,usubfield,field_order,subfield_order,value,i_value,recid,search_id) values(\n\t\t\t\t\t'" . addslashes($this->get_id()) . "'," . $source_id . ",'" . addslashes($ref) . "','" . $date_import . "',\n\t\t\t\t\t'" . $hc . "','',-1,0,'" . addslashes($code) . "','',{$recid},'" . addslashes($search_id) . "')"; pmb_mysql_query($requete); } $field_order = 0; foreach ($record as $field => $val) { for ($i = 0; $i < count($val); $i++) { if (is_array($val[$i])) { foreach ($val[$i] as $sfield => $vals) { for ($j = 0; $j < count($vals); $j++) { //if ($charset!="utf-8") $vals[$j]=utf8_decode($vals[$j]); $requete = "insert into entrepot_source_" . $source_id . " (connector_id,source_id,ref,date_import,ufield,usubfield,field_order,subfield_order,value,i_value,recid,search_id) values(\n\t\t\t\t\t\t\t\t\t'" . addslashes($this->get_id()) . "'," . $source_id . ",'" . addslashes($ref) . "','" . $date_import . "',\n\t\t\t\t\t\t\t\t\t'" . addslashes($field) . "','" . addslashes($sfield) . "'," . $field_order . "," . $j . ",'" . addslashes($vals[$j]) . "',\n\t\t\t\t\t\t\t\t\t' " . addslashes(strip_empty_words($vals[$j])) . " ',{$recid},'" . addslashes($search_id) . "')"; pmb_mysql_query($requete); } } } else { //if ($charset!="utf-8") $vals[$i]=utf8_decode($vals[$i]); $requete = "insert into entrepot_source_" . $source_id . " (connector_id,source_id,ref,date_import,ufield,usubfield,field_order,subfield_order,value,i_value,recid) values(\n\t\t\t\t\t\t\t'" . addslashes($this->get_id()) . "'," . $source_id . ",'" . addslashes($ref) . "','" . $date_import . "',\n\t\t\t\t\t\t\t'" . addslashes($field) . "',''," . $field_order . ",0,'" . addslashes($val[$i]) . "',\n\t\t\t\t\t\t\t' " . addslashes(strip_empty_words($val[$i])) . " ',{$recid},'" . addslashes($search_id) . "')"; pmb_mysql_query($requete); } $field_order++; } } } } }
function import_new_notice_suite() { global $dbh; global $notice_id; global $info_464; global $info_606_a; global $info_900, $info_901, $info_902, $info_903, $info_904, $info_905, $info_906; global $pmb_keyword_sep; global $bulletin_ex; //Cas des périodiques if (is_array($info_464)) { $requete = "select * from notices where notice_id={$notice_id}"; $resultat = mysql_query($requete); $r = mysql_fetch_object($resultat); //Notice chapeau existe-t-elle ? $requete = "select notice_id from notices where tit1='" . addslashes($info_464[0]['t']) . "' and niveau_hierar='1' and niveau_biblio='s'"; $resultat = mysql_query($requete); if (@mysql_num_rows($resultat)) { //Si oui, récupération id $chapeau_id = mysql_result($resultat, 0, 0); //Bulletin existe-t-il ? $requete = "select bulletin_id from bulletins where bulletin_numero='" . addslashes($info_464[0]['v']) . "' and mention_date='" . addslashes($info_464[0]['d']) . "' and bulletin_notice={$chapeau_id}"; $resultat = mysql_query($requete); if (@mysql_num_rows($resultat)) { //Si oui, récupération id bulletin $bulletin_id = mysql_result($resultat, 0, 0); } else { //Si non, création bulltin $info = array(); $bulletin = new bulletinage("", $chapeau_id); $info['bul_titre'] = addslashes("Bulletin N°" . $info_464[0]['v']); $info['bul_no'] = addslashes($info_464[0]['v']); $info['bul_date'] = addslashes($info_464[0]['d']); if (!$info_464[0]['e']) { if ($info_904[0]) { $info['date_date'] = $info_904[0]; } } else { $info['date_date'] = $info_464[0]['e']; } $bulletin_id = $bulletin->update($info); } } else { //Si non, création notice chapeau et bulletin $chapeau = new serial(); $info = array(); $info['tit1'] = addslashes($info_464[0]['t']); $info['niveau_biblio'] = 's'; $info['niveau_hierar'] = '1'; $info['typdoc'] = $r->typdoc; $chapeau->update($info); $chapeau_id = $chapeau->serial_id; $bulletin = new bulletinage("", $chapeau_id); $info = array(); $info['bul_titre'] = addslashes("Bulletin N°" . $info_464[0]['v']); $info['bul_no'] = addslashes($info_464[0]['v']); $info['bul_date'] = addslashes($info_464[0]['d']); if (!$info_464[0]['e']) { if ($info_904[0]) { $info['date_date'] = $info_904[0]; } } else { $info['date_date'] = $info_464[0]['e']; } $bulletin_id = $bulletin->update($info); } //Notice objet ? if ($info_464[0]['z'] == 'objet') { //Supression de la notice $requete = "delete from notices where notice_id={$notice_id}"; mysql_query($requete); $bulletin_ex = $bulletin_id; } else { //Passage de la notice en article $requete = "update notices set niveau_biblio='a', niveau_hierar='2', year='" . addslashes($info_464[0]['d']) . "', npages='" . addslashes($info_464[0]['p']) . "', date_parution='" . $info['date_date'] . "' where notice_id={$notice_id}"; mysql_query($requete); $requete = "insert into analysis (analysis_bulletin,analysis_notice) values({$bulletin_id},{$notice_id})"; mysql_query($requete); $bulletin_ex = $bulletin_id; } } else { $bulletin_ex = 0; } //Traitement du thésaurus $unknown_desc = array(); $ordre_categ = 0; for ($i = 0; $i < count($info_606_a); $i++) { for ($j = 0; $j < count($info_606_a[$i]); $j++) { $descripteur = trim($info_606_a[$i][$j]); //Recherche du terme $requete = "SELECT id_noeud,num_renvoi_voir from noeuds JOIN categories ON (noeuds.id_noeud = categories.num_noeud) where categories.libelle_categorie = '" . addslashes($descripteur) . "' "; $resultat = mysql_query($requete); if (mysql_num_rows($resultat) == 1) { $categ_id = mysql_result($resultat, 0, 0); if (mysql_result($resultat, 0, 1)) { $categ_id = mysql_result($resultat, 0, 1); } $requete = "INSERT IGNORE INTO notices_categories (notcateg_notice,num_noeud,ordre_categorie) VALUES({$notice_id},{$categ_id},{$ordre_categ})"; mysql_query($requete); $ordre_categ++; } else { $unknown_desc[] = $descripteur; } } } if (count($unknown_desc)) { $mots_cles = implode($pmb_keyword_sep, $unknown_desc); $requete = "UPDATE notices SET index_l=IF(index_l != '',CONCAT(index_l,'" . $pmb_keyword_sep . "','" . addslashes($mots_cles) . "'),'" . addslashes($mots_cles) . "'), index_matieres=IF(index_matieres != '',CONCAT(index_matieres,' ','" . addslashes(strip_empty_words($mots_cles)) . "'),'" . addslashes(strip_empty_words($mots_cles)) . "') WHERE notice_id='" . $notice_id . "'"; mysql_query($requete); } //Thème if (count($info_900)) { $requete = "SELECT name,type,datatype FROM notices_custom WHERE idchamp=1"; $res = mysql_query($requete); if (mysql_num_rows($res) && mysql_result($res, 0, 1) == "list" && mysql_result($res, 0, 2) == "integer") { $requete = "select max(notices_custom_list_value*1) from notices_custom_lists where notices_custom_champ=1"; $resultat = mysql_query($requete); $max = @mysql_result($resultat, 0, 0); $n = $max + 1; for ($i = 0; $i < count($info_900); $i++) { for ($j = 0; $j < count($info_900[$i]); $j++) { $requete = "select notices_custom_list_value from notices_custom_lists where notices_custom_list_lib='" . addslashes($info_900[$i][$j]) . "' and notices_custom_champ=1"; $resultat = mysql_query($requete); if (mysql_num_rows($resultat)) { $value = mysql_result($resultat, 0, 0); } else { $requete = "insert into notices_custom_lists (notices_custom_champ,notices_custom_list_value,notices_custom_list_lib) values(1,{$n},'" . addslashes($info_900[$i][$j]) . "')"; mysql_query($requete); $value = $n; $n++; } $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values(1,{$notice_id},{$value})"; mysql_query($requete); } } } else { mysql_query("insert into error_log (error_origin, error_text) values ('import_expl_" . addslashes(SESSid) . ".inc', 'Il n\\'y a pas de CP de notice avec l\\'identifiant=1 ou il n\\'est pas de type liste entier : le 900 n\\'est donc pas repris (Thème)') "); } } //Genres if (count($info_901)) { $requete = "SELECT name,type,datatype FROM notices_custom WHERE idchamp=2"; $res = mysql_query($requete); if (mysql_num_rows($res) && mysql_result($res, 0, 1) == "list" && mysql_result($res, 0, 2) == "integer") { $requete = "select max(notices_custom_list_value*1) from notices_custom_lists where notices_custom_champ=2"; $resultat = mysql_query($requete); $max = @mysql_result($resultat, 0, 0); $n = $max + 1; for ($i = 0; $i < count($info_901); $i++) { for ($j = 0; $j < count($info_901[$i]); $j++) { $requete = "select notices_custom_list_value from notices_custom_lists where notices_custom_list_lib='" . addslashes($info_901[$i][$j]) . "' and notices_custom_champ=2"; $resultat = mysql_query($requete); if (mysql_num_rows($resultat)) { $value = mysql_result($resultat, 0, 0); } else { $requete = "insert into notices_custom_lists (notices_custom_champ,notices_custom_list_value,notices_custom_list_lib) values(2,{$n},'" . addslashes($info_901[$i][$j]) . "')"; mysql_query($requete); $value = $n; $n++; } $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values(2,{$notice_id},{$value})"; mysql_query($requete); } } } else { mysql_query("insert into error_log (error_origin, error_text) values ('import_expl_" . addslashes(SESSid) . ".inc', 'Il n\\'y a pas de CP de notice avec l\\'identifiant=2 ou il n\\'est pas de type liste entier : le 901 n\\'est donc pas repris (Genres)') "); } } //Discipline if (count($info_902)) { $requete = "SELECT name,type,datatype FROM notices_custom WHERE idchamp=3"; $res = mysql_query($requete); if (mysql_num_rows($res) && mysql_result($res, 0, 1) == "list" && mysql_result($res, 0, 2) == "integer") { $requete = "select max(notices_custom_list_value*1) from notices_custom_lists where notices_custom_champ=3"; $resultat = mysql_query($requete); $max = @mysql_result($resultat, 0, 0); $n = $max + 1; for ($i = 0; $i < count($info_902); $i++) { for ($j = 0; $j < count($info_902[$i]); $j++) { $requete = "select notices_custom_list_value from notices_custom_lists where notices_custom_list_lib='" . addslashes($info_902[$i][$j]) . "' and notices_custom_champ=3"; $resultat = mysql_query($requete); if (mysql_num_rows($resultat)) { $value = mysql_result($resultat, 0, 0); } else { $requete = "insert into notices_custom_lists (notices_custom_champ,notices_custom_list_value,notices_custom_list_lib) values(3,{$n},'" . addslashes($info_902[$i][$j]) . "')"; mysql_query($requete); $value = $n; $n++; } $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values(3,{$notice_id},{$value})"; mysql_query($requete); } } } else { mysql_query("insert into error_log (error_origin, error_text) values ('import_expl_" . addslashes(SESSid) . ".inc', 'Il n\\'y a pas de CP de notice avec l\\'identifiant=3 ou il n\\'est pas de type liste entier : le 902 n\\'est donc pas repris (Discipline)') "); } } //Type de nature if ($info_905[0]) { $requete = "SELECT name,type,datatype FROM notices_custom WHERE idchamp=6"; $res = mysql_query($requete); if (mysql_num_rows($res) && mysql_result($res, 0, 1) == "list" && mysql_result($res, 0, 2) == "integer") { $requete = "select max(notices_custom_list_value*1) from notices_custom_lists where notices_custom_champ=6"; $resultat = mysql_query($requete); $max = @mysql_result($resultat, 0, 0); $n = $max + 1; $requete = "select notices_custom_list_value from notices_custom_lists where notices_custom_list_lib='" . addslashes($info_905[0]) . "' and notices_custom_champ=6"; $resultat = mysql_query($requete); if (mysql_num_rows($resultat)) { $value = mysql_result($resultat, 0, 0); } else { $requete = "insert into notices_custom_lists (notices_custom_champ,notices_custom_list_value,notices_custom_list_lib) values(6,{$n},'" . addslashes($info_905[0]) . "')"; mysql_query($requete); $value = $n; $n++; } $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values(6,{$notice_id},{$value})"; mysql_query($requete); } else { mysql_query("insert into error_log (error_origin, error_text) values ('import_expl_" . addslashes(SESSid) . ".inc', 'Il n\\'y a pas de CP de notice avec l\\'identifiant=6 ou il n\\'est pas de type liste entier : le 905 n\\'est donc pas repris (Type de nature)') "); } } //Niveau if (count($info_906)) { $requete = "SELECT name,type,datatype FROM notices_custom WHERE idchamp=7"; $res = mysql_query($requete); if (mysql_num_rows($res) && mysql_result($res, 0, 1) == "list" && mysql_result($res, 0, 2) == "integer") { for ($i = 0; $i < count($info_906); $i++) { for ($j = 0; $j < count($info_906[$i]); $j++) { $requete = "select max(notices_custom_list_value*1) from notices_custom_lists where notices_custom_champ=7"; $resultat = mysql_query($requete); $max = @mysql_result($resultat, 0, 0); $n = $max + 1; $requete = "select notices_custom_list_value from notices_custom_lists where notices_custom_list_lib='" . addslashes($info_906[$i][$j]) . "' and notices_custom_champ=7"; $resultat = mysql_query($requete); if (mysql_num_rows($resultat)) { $value = mysql_result($resultat, 0, 0); } else { $requete = "insert into notices_custom_lists (notices_custom_champ,notices_custom_list_value,notices_custom_list_lib) values(7,{$n},'" . addslashes($info_906[$i][$j]) . "')"; mysql_query($requete); $value = $n; $n++; } $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values(7,{$notice_id},{$value})"; mysql_query($requete); } } } else { mysql_query("insert into error_log (error_origin, error_text) values ('import_expl_" . addslashes(SESSid) . ".inc', 'Il n\\'y a pas de CP de notice avec l\\'identifiant=7 ou il n\\'est pas de type liste entier : le 906 n\\'est donc pas repris (Niveau)') "); } } //Année de péremption if ($info_903[0]) { $requete = "SELECT name,type,datatype FROM notices_custom WHERE idchamp=4"; $res = mysql_query($requete); if (mysql_num_rows($res) && mysql_result($res, 0, 2) == "integer") { $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values(4,{$notice_id},'" . addslashes($info_903[0]) . "')"; mysql_query($requete); } else { mysql_query("insert into error_log (error_origin, error_text) values ('import_expl_" . addslashes(SESSid) . ".inc', 'Il n\\'y a pas de CP de notice avec l\\'identifiant=4 ou il n\\'est pas de type entier : le 903 n\\'est donc pas repris (Année de péremption)') "); } } //Date de saisie if ($info_904[0]) { $requete = "SELECT name,type,datatype FROM notices_custom WHERE idchamp=5"; $res = mysql_query($requete); if (mysql_num_rows($res) && mysql_result($res, 0, 2) == "date") { $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_date) values(5,{$notice_id},'" . $info_904[0] . "')"; mysql_query($requete); } else { mysql_query("insert into error_log (error_origin, error_text) values ('import_expl_" . addslashes(SESSid) . ".inc', 'Il n\\'y a pas de CP de notice avec l\\'identifiant=5 ou il n\\'est pas de type date : le 904 n\\'est donc pas repris (Date de saisie)') "); } } }
function rec_record($record) { global $charset, $base_path; $rec = new oai_record($record, $charset, $base_path . "/admin/connecteurs/in/oai/xslt", $this->metadata_prefix, $this->xslt_transform, $this->sets_names); $rec_uni = $rec->unimarc; if (!$rec->error) { //On a un enregistrement unimarc, on l'enregistre $rec_uni_dom = new xml_dom($rec_uni, $charset); if (!$rec_uni_dom->error) { //Initialisation $ref = ""; $ufield = ""; $usubfield = ""; $field_order = 0; $subfield_order = 0; $value = ""; $date_import = $rec->header["DATESTAMP"]; $fs = $rec_uni_dom->get_nodes("unimarc/notice/f"); //Recherche du 001 for ($i = 0; $i < count($fs); $i++) { if ($fs[$i]["ATTRIBS"]["c"] == "001") { $ref = $rec_uni_dom->get_datas($fs[$i]); break; } } //Mise à jour if ($ref) { //Si conservation des anciennes notices, on regarde si elle existe if (!$this->del_old) { $requete = "select count(*) from entrepot_source_" . $this->source_id . " where connector_id='" . addslashes($this->get_id()) . "' and ref='" . addslashes($ref) . "'"; $rref = pmb_mysql_query($requete); if ($rref) { $ref_exists = pmb_mysql_result($rref, 0, 0); } } //Si pas de conservation des anciennes notices, on supprime if ($this->del_old) { $requete = "delete from entrepot_source_" . $this->source_id . " where connector_id='" . addslashes($this->get_id()) . "' and ref='" . addslashes($ref) . "'"; pmb_mysql_query($requete); } //Si pas de conservation ou reférence inexistante if ($this->del_old || !$this->del_old && !$ref_exists) { //Insertion de l'entête $n_header["rs"] = $rec_uni_dom->get_value("unimarc/notice/rs"); $n_header["ru"] = $rec_uni_dom->get_value("unimarc/notice/ru"); $n_header["el"] = $rec_uni_dom->get_value("unimarc/notice/el"); $n_header["bl"] = $rec_uni_dom->get_value("unimarc/notice/bl"); $n_header["hl"] = $rec_uni_dom->get_value("unimarc/notice/hl"); $n_header["dt"] = $rec_uni_dom->get_value("unimarc/notice/dt"); //Récupération d'un ID $requete = "insert into external_count (recid) values('" . addslashes($this->get_id() . " " . $this->source_id . " " . $ref) . "')"; $rid = pmb_mysql_query($requete); if ($rid) { $recid = pmb_mysql_insert_id(); } foreach ($n_header as $hc => $code) { $requete = "insert into entrepot_source_" . $this->source_id . " (connector_id,source_id,ref,date_import,ufield,usubfield,field_order,subfield_order,value,i_value,recid) values(\n\t\t\t\t\t\t\t'" . addslashes($this->get_id()) . "'," . $this->source_id . ",'" . addslashes($ref) . "','" . addslashes($date_import) . "',\n\t\t\t\t\t\t\t'" . $hc . "','',-1,0,'" . addslashes($code) . "','',{$recid})"; pmb_mysql_query($requete); } for ($i = 0; $i < count($fs); $i++) { $ufield = $fs[$i]["ATTRIBS"]["c"]; $field_order = $i; $ss = $rec_uni_dom->get_nodes("s", $fs[$i]); if (is_array($ss)) { for ($j = 0; $j < count($ss); $j++) { $usubfield = $ss[$j]["ATTRIBS"]["c"]; $value = $rec_uni_dom->get_datas($ss[$j]); $subfield_order = $j; $requete = "insert into entrepot_source_" . $this->source_id . " (connector_id,source_id,ref,date_import,ufield,usubfield,field_order,subfield_order,value,i_value,recid) values(\n\t\t\t\t\t\t\t\t\t'" . addslashes($this->get_id()) . "'," . $this->source_id . ",'" . addslashes($ref) . "','" . addslashes($date_import) . "',\n\t\t\t\t\t\t\t\t\t'" . addslashes($ufield) . "','" . addslashes($usubfield) . "'," . $field_order . "," . $subfield_order . ",'" . addslashes($value) . "',\n\t\t\t\t\t\t\t\t\t' " . addslashes(strip_empty_words($value)) . " ',{$recid})"; pmb_mysql_query($requete); } } else { $value = $rec_uni_dom->get_datas($fs[$i]); $requete = "insert into entrepot_source_" . $this->source_id . " (connector_id,source_id,ref,date_import,ufield,usubfield,field_order,subfield_order,value,i_value,recid) values(\n\t\t\t\t\t\t\t\t'" . addslashes($this->get_id()) . "'," . $this->source_id . ",'" . addslashes($ref) . "','" . addslashes($date_import) . "',\n\t\t\t\t\t\t\t\t'" . addslashes($ufield) . "','" . addslashes($usubfield) . "'," . $field_order . "," . $subfield_order . ",'" . addslashes($value) . "',\n\t\t\t\t\t\t\t\t' " . addslashes(strip_empty_words($value)) . " ',{$recid})"; pmb_mysql_query($requete); } } } $this->n_recu++; } } } }
function indexAcquisitions() { global $msg, $dbh, $charset, $PMBusername; if (SESSrights & ADMINISTRATION_AUTH) { //SUGGESTIONS $result .= "<h3>" . htmlentities($msg["nettoyage_reindex_sug"], ENT_QUOTES, $charset) . "</h3>"; $query = mysql_query("SELECT id_suggestion, titre, editeur, auteur, code, commentaires FROM suggestions"); if (mysql_num_rows($query)) { while ($row = mysql_fetch_object($query)) { // index acte $req_update = "UPDATE suggestions "; $req_update .= "SET index_suggestion = ' " . strip_empty_words($row->titre) . " " . strip_empty_words($row->editeur) . " " . strip_empty_words($row->auteur) . " " . $row->code . " " . strip_empty_words($row->commentaires) . " ' "; $req_update .= "WHERE id_suggestion = " . $row->id_suggestion . " "; $update = mysql_query($req_update); } mysql_free_result($query); } $actes = mysql_query("SELECT count(1) FROM suggestions", $dbh); $count = mysql_result($actes, 0, 0); $result .= htmlentities($msg["nettoyage_reindex_sug"], ENT_QUOTES, $charset) . " {$count} " . htmlentities($msg["nettoyage_res_reindex_sug"], ENT_QUOTES, $charset); //ENTITES $result .= "<h3>" . htmlentities($msg["nettoyage_reindex_ent"], ENT_QUOTES, $charset) . "</h3>"; $query = mysql_query("SELECT id_entite, raison_sociale FROM entites"); if (mysql_num_rows($query)) { while ($row = mysql_fetch_object($query)) { // index acte $req_update = "UPDATE entites "; $req_update .= "SET index_entite = ' " . strip_empty_words($row->raison_sociale) . " ' "; $req_update .= "WHERE id_entite = " . $row->id_entite . " "; $update = mysql_query($req_update); } mysql_free_result($query); } $entites = mysql_query("SELECT count(1) FROM entites", $dbh); $count = mysql_result($entites, 0, 0); $result .= htmlentities($msg["nettoyage_reindex_ent"], ENT_QUOTES, $charset) . " {$count} " . htmlentities($msg["nettoyage_res_reindex_ent"], ENT_QUOTES, $charset); //ACTES $result .= "<h3>" . htmlentities($msg["nettoyage_reindex_act"], ENT_QUOTES, $charset) . "</h3>"; $query = mysql_query("SELECT actes.id_acte, actes.numero, entites.raison_sociale, actes.commentaires, actes.reference FROM actes, entites where num_fournisseur=id_entite LIMIT " . $start . ", " . $lot . " "); if (mysql_num_rows($query)) { while ($row = mysql_fetch_object($query)) { // index acte $req_update = "UPDATE actes "; $req_update .= "SET index_acte = ' " . $row->numero . " " . strip_empty_words($row->raison_sociale) . " " . strip_empty_words($row->commentaires) . " " . strip_empty_words($row->reference) . " ' "; $req_update .= "WHERE id_acte = " . $row->id_acte . " "; $update = mysql_query($req_update); //index lignes_actes $query_2 = mysql_query("SELECT id_ligne, code, libelle FROM lignes_actes where num_acte = '" . $row->id_acte . "' "); if (mysql_num_rows($query_2)) { while ($row_2 = mysql_fetch_object($query_2)) { $req_update_2 = "UPDATE lignes_actes "; $req_update_2 .= "SET index_ligne = ' " . strip_empty_words($row_2->libelle) . " ' "; $req_update_2 .= "WHERE id_ligne = " . $row_2->id_ligne . " "; $update_2 = mysql_query($req_update_2); } mysql_free_result($query_2); } } mysql_free_result($query); } $actes = mysql_query("SELECT count(1) FROM actes", $dbh); $count = mysql_result($actes, 0, 0); $result .= htmlentities($msg["nettoyage_reindex_act"], ENT_QUOTES, $charset) . " {$count} " . htmlentities($msg["nettoyage_res_reindex_act"], ENT_QUOTES, $charset); //FINI $result .= htmlentities($msg["nettoyage_reindex_acq_fini"], ENT_QUOTES, $charset); } else { $result .= sprintf($msg["planificateur_rights_bad_user_rights"], $PMBusername); } }
function update_global_index($id) { global $dbh; global $include_path; $p_perso = new custom_parametres_perso("authperso", "authperso", $this->id); $mots_perso = $p_perso->get_fields_recherche($id); if ($mots_perso) { $infos_global .= $mots_perso . ' '; $infos_global_index .= strip_empty_words($mots_perso) . ' '; } $req = "update authperso_authorities set authperso_infos_global='" . addslashes($infos_global) . "', authperso_index_infos_global='" . addslashes(' ' . $infos_global_index) . "' where id_authperso_authority={$id}"; pmb_mysql_query($req, $dbh); $indexation_authority = new indexation_authperso($include_path . "/indexation/authorities/authperso/champs_base.xml", "authorities", AUT_TABLE_AUTHPERSO, $this->id); $indexation_authority->maj($id); }
function import_new_notice_suite() { global $dbh; global $notice_id, $info_856; global $index_sujets; global $pmb_keyword_sep; global $info_600_a, $info_600_j, $info_600_x, $info_600_y, $info_600_z; global $info_601_a, $info_601_j, $info_601_x, $info_601_y, $info_601_z; global $info_602_a, $info_602_j, $info_602_x, $info_602_y, $info_602_z; global $info_605_a, $info_605_j, $info_605_x, $info_605_y, $info_605_z; global $info_606_a, $info_606_j, $info_606_x, $info_606_y, $info_606_z; global $info_607_a, $info_607_j, $info_607_x, $info_607_y, $info_607_z; if (is_array($index_sujets)) { $mots_cles = implode(" {$pmb_keyword_sep} ", $index_sujets); } else { $mots_cles = $index_sujets; } for ($a = 0; $a < sizeof($info_600_a); $a++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_600_a[$a][0]; for ($j = 0; $j < sizeof($info_600_j[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_600_j[$a][$j]; } for ($j = 0; $j < sizeof($info_600_x[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_600_x[$a][$j]; } for ($j = 0; $j < sizeof($info_600_y[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_600_y[$a][$j]; } for ($j = 0; $j < sizeof($info_600_z[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_600_z[$a][$j]; } } for ($a = 0; $a < sizeof($info_601_a); $a++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_601_a[$a][0]; for ($j = 0; $j < sizeof($info_601_j[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_601_j[$a][$j]; } for ($j = 0; $j < sizeof($info_601_x[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_601_x[$a][$j]; } for ($j = 0; $j < sizeof($info_601_y[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_601_y[$a][$j]; } for ($j = 0; $j < sizeof($info_601_z[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_601_z[$a][$j]; } } for ($a = 0; $a < sizeof($info_602_a); $a++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_602_a[$a][0]; for ($j = 0; $j < sizeof($info_602_j[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_602_j[$a][$j]; } for ($j = 0; $j < sizeof($info_602_x[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_602_x[$a][$j]; } for ($j = 0; $j < sizeof($info_602_y[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_602_y[$a][$j]; } for ($j = 0; $j < sizeof($info_602_z[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_602_z[$a][$j]; } } for ($a = 0; $a < sizeof($info_605_a); $a++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_605_a[$a][0]; for ($j = 0; $j < sizeof($info_605_j[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_605_j[$a][$j]; } for ($j = 0; $j < sizeof($info_605_x[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_605_x[$a][$j]; } for ($j = 0; $j < sizeof($info_605_y[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_605_y[$a][$j]; } for ($j = 0; $j < sizeof($info_605_z[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_605_z[$a][$j]; } } for ($a = 0; $a < sizeof($info_606_a); $a++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_606_a[$a][0]; for ($j = 0; $j < sizeof($info_606_j[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_606_j[$a][$j]; } for ($j = 0; $j < sizeof($info_606_x[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_606_x[$a][$j]; } for ($j = 0; $j < sizeof($info_606_y[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_606_y[$a][$j]; } for ($j = 0; $j < sizeof($info_606_z[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_606_z[$a][$j]; } } for ($a = 0; $a < sizeof($info_607_a); $a++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_607_a[$a][0]; for ($j = 0; $j < sizeof($info_607_j[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_607_j[$a][$j]; } for ($j = 0; $j < sizeof($info_607_x[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_607_x[$a][$j]; } for ($j = 0; $j < sizeof($info_607_y[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_607_y[$a][$j]; } for ($j = 0; $j < sizeof($info_607_z[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_607_z[$a][$j]; } } $mots_cles ? $index_matieres = strip_empty_words($mots_cles) : ($index_matieres = ''); $rqt_maj = "update notices set index_l='" . addslashes($mots_cles) . "', index_matieres=' " . addslashes($index_matieres) . " ' where notice_id='{$notice_id}' "; mysql_query($rqt_maj, $dbh); if ($tmp = trim($info_856[0])) { $rqt_maj = "update notices set thumbnail_url='" . addslashes($tmp) . "' where notice_id='" . $notice_id . "' "; mysql_query($rqt_maj, $dbh); } }
function startwith($elt) { if (pmb_substr(strip_empty_words($elt["title"]), 0, pmb_strlen(strip_empty_words($this->start))) == strip_empty_words($this->start)) { return true; } else { return false; } }
function rec_record($record, $source_id, $search_id) { global $charset, $base_path; $date_import = date("Y-m-d H:i:s", time()); $r = array(); //Inversion du tableau $r["rs"] = $record["RS"][0]["value"] ? $record["RS"][0]["value"] : "*"; $r["ru"] = $record["RU"][0]["value"] ? $record["RU"][0]["value"] : "*"; $r["el"] = $record["EL"][0]["value"] ? $record["EL"][0]["value"] : "*"; $r["bl"] = $record["BL"][0]["value"] ? $record["BL"][0]["value"] : "*"; $r["hl"] = $record["HL"][0]["value"] ? $record["HL"][0]["value"] : "*"; $r["dt"] = $record["DT"][0]["value"] ? $record["DT"][0]["value"] : "*"; $exemplaires = array(); for ($i = 0; $i < count($record["F"]); $i++) { if ($record["F"][$i]["C"] == 996) { //C'est une localisation, les localisations ne sont pas fusionnées. $t = array(); for ($j = 0; $j < count($record["F"][$i]["S"]); $j++) { //Sous champ $sub = $record["F"][$i]["S"][$j]; $t[$sub["C"]] = $sub["value"]; } $exemplaires[] = $t; } else { if ($record["F"][$i]["value"]) { $r[$record["F"][$i]["C"]][] = $record["F"][$i]["value"]; } else { $t = array(); for ($j = 0; $j < count($record["F"][$i]["S"]); $j++) { //Sous champ $sub = $record["F"][$i]["S"][$j]; $t[$sub["C"]][] = $sub["value"]; } $r[$record["F"][$i]["C"]][] = $t; } } } $record = $r; //Recherche du 001 $ref = $record["001"][0]; //Mise à jour if (!$ref) { $ref = md5(print_r($record, true)); } if ($ref) { //Si conservation des anciennes notices, on regarde si elle existe if (!$this->del_old) { $requete = "select count(*) from entrepot_source_{$source_id} where ref='" . addslashes($ref) . "'"; $rref = pmb_mysql_query($requete); if ($rref) { $ref_exists = pmb_mysql_result($rref, 0, 0); } } //Si pas de conservation des anciennes notices, on supprime if ($this->del_old) { $requete = "delete from entrepot_source_{$source_id} where ref='" . addslashes($ref) . "'"; pmb_mysql_query($requete); $this->delete_from_external_count($source_id, $ref); } //Si pas de conservation ou reférence inexistante if ($this->del_old || !$this->del_old && !$ref_exists) { //Insertion de l'entête $n_header["rs"] = $record["rs"]; $n_header["ru"] = $record["ru"]; $n_header["el"] = $record["el"]; $n_header["bl"] = $record["bl"]; $n_header["hl"] = $record["hl"]; $n_header["dt"] = $record["dt"]; //Récupération d'un ID $requete = "insert into external_count (recid, source_id) values('" . addslashes($this->get_id() . " " . $source_id . " " . $ref) . "', {$source_id})"; $rid = pmb_mysql_query($requete); if ($rid) { $recid = pmb_mysql_insert_id(); } foreach ($n_header as $hc => $code) { $requete = "insert into entrepot_source_{$source_id} (connector_id,source_id,ref,date_import,ufield,usubfield,field_order,subfield_order,value,i_value,recid,search_id) values(\n\t\t\t\t\t'" . addslashes($this->get_id()) . "'," . $source_id . ",'" . addslashes($ref) . "','" . $date_import . "',\n\t\t\t\t\t'" . $hc . "','',-1,0,'" . addslashes($code) . "','',{$recid},'" . addslashes($search_id) . "')"; pmb_mysql_query($requete); } $field_order = 0; foreach ($exemplaires as $exemplaire) { $sub_field_order = 0; foreach ($exemplaire as $exkey => $exvalue) { $requete = "insert into entrepot_source_{$source_id} (connector_id,source_id,ref,date_import,ufield,usubfield,field_order,subfield_order,value,i_value,recid,search_id) values(\n\t\t\t\t\t\t'" . addslashes($this->get_id()) . "'," . $source_id . ",'" . addslashes($ref) . "','" . $date_import . "',\n\t\t\t\t\t\t'996','" . addslashes($exkey) . "'," . $field_order . "," . $sub_field_order . ",'" . addslashes($exvalue) . "',\n\t\t\t\t\t\t' " . addslashes(strip_empty_words($exvalue)) . " ',{$recid},'" . addslashes($search_id) . "')"; pmb_mysql_query($requete); $sub_field_order++; } $field_order++; } foreach ($record as $field => $val) { for ($i = 0; $i < count($val); $i++) { if (is_array($val[$i])) { foreach ($val[$i] as $sfield => $vals) { for ($j = 0; $j < count($vals); $j++) { $requete = "insert into entrepot_source_{$source_id} (connector_id,source_id,ref,date_import,ufield,usubfield,field_order,subfield_order,value,i_value,recid,search_id) values(\n\t\t\t\t\t\t\t\t\t'" . addslashes($this->get_id()) . "'," . $source_id . ",'" . addslashes($ref) . "','" . $date_import . "',\n\t\t\t\t\t\t\t\t\t'" . addslashes($field) . "','" . addslashes($sfield) . "'," . $field_order . "," . $j . ",'" . addslashes($vals[$j]) . "',\n\t\t\t\t\t\t\t\t\t' " . addslashes(strip_empty_words($vals[$j])) . " ',{$recid},'" . addslashes($search_id) . "')"; pmb_mysql_query($requete); } } } else { $requete = "insert into entrepot_source_{$source_id} (connector_id,source_id,ref,date_import,ufield,usubfield,field_order,subfield_order,value,i_value,recid,search_id) values(\n\t\t\t\t\t\t\t'" . addslashes($this->get_id()) . "'," . $source_id . ",'" . addslashes($ref) . "','" . $date_import . "',\n\t\t\t\t\t\t\t'" . addslashes($field) . "',''," . $field_order . ",0,'" . addslashes($val[$i]) . "',\n\t\t\t\t\t\t\t' " . addslashes(strip_empty_words($val[$i])) . " ',{$recid},'" . addslashes($search_id) . "')"; pmb_mysql_query($requete); } $field_order++; } } } } }
function test_other_query($n_res = 0, $n_gen = 0, $n_tit = 0, $n_mat = 0, $query, $operator = TRUE, $force_regexp = FALSE) { // fonction d'analyse d'une recherche sur titre // la fonction retourne un tableau : $query_result = array('type' => 0, 'restr' => '', 'order' => '', 'display', 'nbr_rows' => 0); // $query_result['type'] = type de la requête : // 0 : rien (problème) // 1: match/against // 2: regexp // 3: regexp pure sans traitement // $query_result['restr'] = critères de restriction // $query_result['order'] = critères de tri // $query_result['nbr_rows'] = nombre de lignes qui matchent // $query_result['display'] = affichage en clair de la requête utilisateur // si operator TRUE La recherche est booléenne AND // si operator FALSE La recherche est booléenne OR // si force_regexp : la recherche est forcée en mode regexp $stopwords = FALSE; global $dbh; // initialisation opérateur $operator ? $dopt = 'AND' : ($dopt = 'OR'); $query = pmb_strtolower($query); // espaces en début et fin $query = pmb_preg_replace('/^\\s+|\\s+$/', '', $query); // espaces en double $query = pmb_preg_replace('/\\s+/', ' ', $query); // contrôle de la requete if (!$query) { return $query_result; } // déterminer si la requête est une regexp // si c'est le cas, on utilise la saisie utilisateur sans modification // (on part du principe qu'il sait ce qu'il fait) if (pmb_preg_match('/\\^|\\$|\\[|\\]|\\.|\\*|\\{|\\}|\\|/', $query)) { // regexp pure : pas de modif de la saisie utilisateur $query_result['type'] = 3; if ($n_res) { $query_result['restr'] = "n_resume REGEXP '{$query}' OR n_contenu REGEXP '{$query}' "; } else { $query_result['restr'] = ""; } if ($n_gen) { if ($query_result['restr']) { $query_result['restr'] .= " OR "; } $query_result['restr'] .= " n_gen REGEXP '{$query}'"; } if ($n_tit) { if ($query_result['restr']) { $query_result['restr'] .= " OR "; } $query_result['restr'] .= " tit1 REGEXP '{$query}' OR tit2 REGEXP '{$query}' OR tit3 REGEXP '{$query}' OR tit4 REGEXP '{$query}' OR index_serie REGEXP '{$query}' "; } if ($n_mat) { if ($query_result['restr']) { $query_result['restr'] .= " OR "; } $query_result['restr'] .= " index_l REGEXP '{$query}' "; } $query_result['order'] = "index_serie ASC, tnvol ASC, index_sew ASC"; $query_result['display'] = $query; } else { // nettoyage de la chaîne $query = pmb_preg_replace("/[\\(\\)\\,\\;\\'\\!\\-\\+]/", ' ', $query); // on supprime les mots vides $query = strip_empty_words($query); // contrôle de la requete if (!$query) { return $query_result; } // la saisie est splitée en un tableau $tab = pmb_split('/\\s+/', $query); // on cherche à détecter les mots de moins de 4 caractères (stop words) // si il y des mots remplissant cette condition, c'est la méthode regexp qui sera employée foreach ($tab as $dummykey => $word) { if (pmb_strlen($word) < 4) { $stopwords = TRUE; break; } } if ($stopwords || $force_regexp) { // méthode REGEXP $query_result['type'] = 2; // constitution du membre restricteur // premier mot if ($n_res) { $query_result['restr'] = "( n_resume REGEXP '{$tab[0]}' OR n_contenu REGEXP '{$tab[0]}' "; } else { $query_result['restr'] = ""; } if ($n_gen) { if ($query_result['restr']) { $query_result['restr'] .= " OR n_gen REGEXP '{$tab[0]}'"; } else { $query_result['restr'] = "( n_gen REGEXP '{$tab[0]}'"; } } if ($n_tit) { if ($query_result['restr']) { $query_result['restr'] .= " OR tit1 REGEXP '{$tab[0]}' OR tit2 REGEXP '{$tab[0]}' OR tit3 REGEXP '{$tab[0]}' OR tit4 REGEXP '{$tab[0]}' OR index_serie REGEXP '{$tab[0]}'"; } else { $query_result['restr'] = "( tit1 REGEXP '{$tab[0]}' OR tit2 REGEXP '{$tab[0]}' OR tit3 REGEXP '{$tab[0]}' OR tit4 REGEXP '{$tab[0]}' OR index_serie REGEXP '{$tab[0]}' "; } } if ($n_mat) { if ($query_result['restr']) { $query_result['restr'] .= " OR index_l REGEXP '{$tab[0]}' "; } else { $query_result['restr'] = "( index_l REGEXP '{$tab[0]}' "; } } $query_result['restr'] .= ") "; //$query_result['restr'] = "(n_resume REGEXP '${tab[0]}'"; //$query_result['restr'] .= " OR n_contenu REGEXP '$tab[0]')"; $query_result['display'] = $tab[0]; for ($i = 1; $i < sizeof($tab); $i++) { $query_suite = ""; if ($n_res) { $query_suite = " ( n_resume REGEXP '{$tab[$i]}' OR n_contenu REGEXP '{$tab[$i]}' "; } if ($n_gen) { if ($query_suite) { $query_suite .= " OR n_gen REGEXP '{$tab[$i]}'"; } else { $query_suite = "( n_gen REGEXP '{$tab[$i]}'"; } } if ($n_tit) { if ($query_suite) { $query_suite .= " OR tit1 REGEXP '{$tab[$i]}' OR tit2 REGEXP '{$tab[$i]}' OR tit3 REGEXP '{$tab[$i]}' OR tit4 REGEXP '{$tab[$i]}' OR index_serie REGEXP '{$tab[$i]}'"; } else { $query_suite = "( tit1 REGEXP '{$tab[$i]}' OR tit2 REGEXP '{$tab[$i]}' OR tit3 REGEXP '{$tab[$i]}' OR tit4 REGEXP '{$tab[$i]}' OR index_serie REGEXP '{$tab[$i]}' "; } } if ($n_mat) { if ($query_suite) { $query_suite .= " OR index_l REGEXP '{$tab[$i]}' "; } else { $query_suite = "( index_l REGEXP '{$tab[$i]}' "; } } if ($query_suite) { $query_suite .= " ) "; $query_result['restr'] .= " {$dopt} " . $query_suite; } //$query_result['restr'] .= " $dopt (n_resume REGEXP '${tab[$i]}'"; //$query_result['restr'] .= " OR n_contenu REGEXP '${tab[$i]}')"; $query_result['display'] .= " {$dopt} {$tab[$i]}"; } //echo "<br /><br /><br />".$query_result['restr']."<br /><br /><br />"; // contitution de la clause de tri $query_result['order'] = "index_serie ASC, tnvol ASC, index_sew ASC"; } else { // méthode FULLTEXT $query_result['type'] = 1; // membre restricteur if ($n_res) { $query_result['restr'] = "( MATCH (n_resume, n_contenu) AGAINST ('{$tab[0]}') "; } else { $query_result['restr'] = ""; } if ($n_gen) { if ($query_result['restr']) { $query_result['restr'] .= " OR MATCH (n_gen) AGAINST ('{$tab[0]}') "; } else { $query_result['restr'] = "( MATCH (n_gen) AGAINST ('{$tab[0]}') "; } } if ($n_tit) { if ($query_result['restr']) { $query_result['restr'] .= " OR MATCH (index_wew) AGAINST ('{$tab[0]}') "; } else { $query_result['restr'] = "( MATCH (index_wew) AGAINST ('{$tab[0]}') "; } } if ($n_mat) { if ($query_result['restr']) { $query_result['restr'] .= " OR MATCH (index_matieres) AGAINST ('{$tab[0]}') "; } else { $query_result['restr'] = "( MATCH (index_matieres) AGAINST ('{$tab[0]}') "; } } $query_result['restr'] .= ") "; //$query_result['restr'] = "MATCH (n_resume, n_contenu) AGAINST ('${tab[0]}')"; $query_result['display'] = $tab[0]; for ($i = 1; $i < sizeof($tab); $i++) { $query_suite = ""; if ($n_res) { $query_suite = " ( MATCH (n_resume, n_contenu) AGAINST ('{$tab[$i]}') "; } if ($n_gen) { if ($query_suite) { $query_suite .= " OR MATCH (n_gen) AGAINST ('{$tab[$i]}') "; } else { $query_suite = "( MATCH (n_gen) AGAINST ('{$tab[$i]}')"; } } if ($n_tit) { if ($query_suite) { $query_suite .= " OR MATCH (index_wew) AGAINST ('{$tab[$i]}') "; } else { $query_suite = "( MATCH (index_wew) AGAINST ('{$tab[$i]}') "; } } if ($n_mat) { if ($query_suite) { $query_suite .= " OR MATCH (index_matieres) AGAINST ('{$tab[$i]}') "; } else { $query_suite = "( MATCH (index_matieres) AGAINST ('{$tab[$i]}') "; } } if ($query_suite) { $query_suite .= " ) "; $query_result['restr'] .= " {$dopt} " . $query_suite; } //$query_result['restr'] .= " $dopt MATCH"; //$query_result['restr'] .= " (n_resume, n_contenu)"; //$query_result['restr'] .= " AGAINST ('${tab[$i]}')"; $query_result['display'] .= " {$dopt} {$tab[$i]}"; } // membre de tri $query_result['order'] = "index_serie ASC, tnvol ASC, index_sew ASC"; } } // récupération du nombre de lignes $rws = "SELECT count(1) FROM notices WHERE {$query_result['restr']}"; $result = @pmb_mysql_query($rws, $dbh); $query_result['nbr_rows'] = pmb_mysql_result($result, 0, 0); return $query_result; }
function search($user_query) { global $charset; $matches = array(); if (!file_exists($this->doc->driver->get_cached_filename($this->doc->id) . ".bbox")) { exec("pdftotext -bbox -enc UTF-8 " . $this->doc->driver->get_cached_filename($this->doc->id) . " " . $this->doc->driver->get_cached_filename($this->doc->id) . ".bbox"); } ini_set("zend.ze1_compatibility_mode", "0"); $dom = new DOMDocument('1.0', 'UTF-8'); file_put_contents($this->doc->driver->get_cached_filename($this->doc->id) . ".bbox", str_replace(array(chr("0x01"), chr("0x02"), chr("0x1f"), chr("0x1e")), "", file_get_contents($this->doc->driver->get_cached_filename($this->doc->id) . ".bbox"))); $dom->load($this->doc->driver->get_cached_filename($this->doc->id) . ".bbox"); // On nettoie la recherche $user_query = strip_empty_words(strtolower(convert_diacrit($user_query))); $terms = explode(" ", $user_query); $pages = $dom->getElementsByTagName("page"); $height = 0; $width = 0; //on parcourt les pages for ($i = 0; $i < $pages->length; $i++) { $current_page = $pages->item($i); $height = $current_page->getAttribute("height"); $width = $current_page->getAttribute("width"); $h_ratio = $this->getHeight($i + 1) / $height; $w_ratio = $this->getWidth($i + 1) / $width; $words = $current_page->getElementsByTagName("word"); //on parcourt les mots du fichier for ($j = 0; $j < $words->length; $j++) { //on parcourt les termes de la recherche $current_word = $words->item($j); if ($charset == "iso-8859-1") { $current_word_value = iconv("UTF-8", "ISO-8859-1//TRANSLIT", $current_word->nodeValue); } else { $current_word_value = $current_word->nodeValue; } foreach ($terms as $term) { if (strpos(strtolower(convert_diacrit($current_word_value)), $term) !== false) { //trouvé //texte à afficher en aperçu $text = "..."; for ($k = $j - 3; $k <= $j + 3; $k++) { if ($j == $k) { $text .= "<span style='background-color:#CCCCFF;font-size:100%;font-style:normal;color:#000000;'>"; } if ($charset == "iso-8859-1") { $text .= htmlentities(iconv("UTF-8", "ISO-8859-1//TRANSLIT", $words->item($k)->nodeValue), ENT_QUOTES, $charset) . " "; } else { $text .= htmlentities($words->item($k)->nodeValue, ENT_QUOTES, $charset); } if ($j == $k) { $text .= "</span>"; } $text .= " "; } $text .= "... "; $matches[] = array("text" => $text, 'par' => array(array('page' => $i + 1, 'page_height' => $height, 'b' => $height, 't' => 0, 'page_width' => $width, 'r' => $width, 'l' => 0, 'boxes' => array(array('l' => $current_word->getAttribute("xMin") * $w_ratio, 'r' => $current_word->getAttribute("xMax") * $w_ratio, 'b' => $current_word->getAttribute("yMax") * $h_ratio, 't' => $current_word->getAttribute("yMin") * $h_ratio, 'page' => $i + 1))))); } else { if (strpos($term, strtolower(convert_diacrit($current_word_value))) === 0) { // On regarde si le terme n'est pas découpé dans le document // Le mot correspond au début du terme, on va regarder les mots suivants $offset = 0; $word_index = $j; $word_index_value = $current_word_value; do { $offset += strlen(strtolower(convert_diacrit($word_index_value))); $word_index++; if ($charset == "iso-8859-1") { $word_index_value = iconv("UTF-8", "ISO-8859-1//TRANSLIT", $words->item($word_index)->nodeValue); } else { $word_index_value = $words->item($word_index)->nodeValue; } } while (strpos($term, strtolower(convert_diacrit($word_index_value)), $offset) === $offset); if ($offset >= strlen($term)) { // le terme à été trouvé //texte à afficher en aperçu $word_index--; $text = "..."; for ($k = $j - 3; $k <= $word_index + 3; $k++) { if ($j == $k) { $text .= "<span style='background-color:#CCCCFF;font-size:100%;font-style:normal;color:#000000;'>"; } if ($charset == "iso-8859-1") { $text .= htmlentities(iconv("UTF-8", "ISO-8859-1//TRANSLIT", $words->item($k)->nodeValue), ENT_QUOTES, $charset); } else { $text .= htmlentities($words->item($k)->nodeValue, ENT_QUOTES, $charset); } if ($k == $word_index) { $text .= "</span>"; } $text .= " "; } $text .= "... "; $matches[] = array("text" => $text, 'par' => array(array('page' => $i + 1, 'page_height' => $height, 'b' => $height, 't' => 0, 'page_width' => $width, 'r' => $width, 'l' => 0, 'boxes' => array(array('l' => $current_word->getAttribute("xMin") * $w_ratio, 'r' => $words->item($word_index)->getAttribute("xMax") * $w_ratio, 'b' => $words->item($word_index)->getAttribute("yMax") * $h_ratio, 't' => $current_word->getAttribute("yMin") * $h_ratio, 'page' => $i + 1))))); } } else { //perdu continue; } } } } } return array('matches' => $matches); }
function import_new_notice_suite() { global $dbh; global $notice_id; global $info_464, $info_676; global $info_606_a, $info_606_x; global $info_900, $info_901, $info_902, $info_200, $info_903, $info_904, $info_910; global $rs, $bl, $dt; global $bulletin_ex; global $m_thess; //si on est en multi-thesaurus if (!$m_thess) { $rqt = "SELECT count(1) FROM thesaurus WHERE active=1"; $m_thess = mysql_result(mysql_query($rqt), 0, 0); } //Cas des périodiques if (is_array($info_464)) { $requete = "SELECT * FROM notices WHERE notice_id={$notice_id}"; $resultat = mysql_query($requete); $r = mysql_fetch_object($resultat); //Notice chapeau existe-t-elle ? $requete = "SELECT notice_id FROM notices WHERE tit1='" . addslashes($info_464[0]['t']) . "' and niveau_hierar='1' and niveau_biblio='s'"; $resultat = mysql_query($requete); if (@mysql_num_rows($resultat)) { //Si oui, récupération id $chapeau_id = mysql_result($resultat, 0, 0); //Mise à jour du champ commentaire de gestion si nécessaire if ($info_903[0]) { $requete = "UPDATE notices SET commentaire_gestion=concat(commentaire_gestion,' ','" . addslashes($info_903[0]) . "') WHERE notice_id={$chapeau_id}"; mysql_query($requete); } //Bulletin existe-t-il ? $requete = "SELECT bulletin_id FROM bulletins WHERE bulletin_numero='" . addslashes($info_464[0]['v']) . "' AND mention_date='" . addslashes($info_464[0]['d']) . "' AND bulletin_notice={$chapeau_id}"; $resultat = mysql_query($requete); if (@mysql_num_rows($resultat)) { //Si oui, récupération id bulletin $bulletin_id = mysql_result($resultat, 0, 0); } else { //Si non, création bulletin $info = array(); $bulletin = new bulletinage("", $chapeau_id); if ($info_464[0]['u']) { $info['bul_titre'] = addslashes($info_464[0]['u']); } else { $info['bul_titre'] = addslashes("Bulletin " . $info_464[0]['v']); } $info['bul_no'] = addslashes($info_464[0]['v']); $info['bul_date'] = addslashes($info_464[0]['d']); if (!$info_464[0]['e']) { if ($info_902[0]) { $info['date_date'] = $info_902[0]; } } else { $info['date_date'] = $info_464[0]['e']; } $bulletin_id = $bulletin->update($info); } } else { //Si non, création notice chapeau et bulletin $chapeau = new serial(); $info = array(); $info['tit1'] = addslashes($info_464[0]['t']); $info['niveau_biblio'] = 's'; $info['niveau_hierar'] = '1'; $info['typdoc'] = $r->typdoc; $chapeau->update($info); $chapeau_id = $chapeau->serial_id; //Mise à jour du champ commentaire de gestion si nécessaire if ($info_903[0]) { $requete = "UPDATE notices SET commentaire_gestion=concat(commentaire_gestion,' ','" . addslashes($info_903[0]) . "') WHERE notice_id={$chapeau_id}"; mysql_query($requete); } $bulletin = new bulletinage("", $chapeau_id); $info = array(); if ($info_464[0]['u']) { $info['bul_titre'] = addslashes($info_464[0]['u']); } else { $info['bul_titre'] = addslashes("Bulletin " . $info_464[0]['v']); } $info['bul_no'] = addslashes($info_464[0]['v']); $info['bul_date'] = addslashes($info_464[0]['d']); if (!$info_464[0]['e']) { if ($info_902[0]) { $info['date_date'] = $info_902[0]; } } else { $info['date_date'] = $info_464[0]['e']; } $bulletin_id = $bulletin->update($info); } //Passage de la notice en article $requete = "UPDATE notices SET niveau_biblio='a', niveau_hierar='2', npages='" . addslashes($info_464[0]['p']) . "' WHERE notice_id={$notice_id}"; mysql_query($requete); $requete = "INSERT INTO analysis (analysis_bulletin,analysis_notice) VALUES({$bulletin_id},{$notice_id})"; mysql_query($requete); $bulletin_ex = $bulletin_id; } else { $bulletin_ex = 0; } //Traitement du thésaurus if ($m_thess > 1) { //on est en multi-thesaurus for ($i = 0; $i < count($info_606_a); $i++) { for ($j = 0; $j < count($info_606_a[$i]); $j++) { $descripteur_tete = $info_606_a[$i][$j]; $descripteur_fils = $info_606_x[$i][$j]; //Recherche du thésaurus $thes_id = trouve_thesaurus($descripteur_tete); //Recherche du terme fils if ($thes_id > 0) { $categ_id_fils = categories::searchLibelle(addslashes(trim($descripteur_fils)), $thes_id, "fr_FR"); if (!$categ_id_fils) { //Création $new_thes = $thes_id == 1 ? 4 : $thes_id; //Choix du thesaurus Candidats descripteurs si descripteur inexistant $categ_id_fils = categories::searchLibelle(addslashes(trim($descripteur_fils)), $new_thes, "fr_FR"); if (!$categ_id_fils) { $noeud = new noeuds(); $noeud->num_thesaurus = $new_thes; $thesau = new thesaurus($new_thes); $noeud->num_parent = $thesau->num_noeud_racine; $noeud->save(); $categ_id_fils = $noeud->id_noeud; //Création du libellé $categ = new categories($noeud->id_noeud, 'fr_FR'); $categ->libelle_categorie = $descripteur_fils; $categ->index_categorie = " " . strip_empty_words($descripteur_fils) . " "; $categ->save(); } } $requete = "INSERT INTO notices_categories (notcateg_notice, num_noeud, ordre_categorie) VALUES ({$notice_id},{$categ_id_fils}, " . ($i + 1) . ")"; mysql_query($requete); } } } //for($i } else { //Traitement du thésaurus unique for ($i = 0; $i < count($info_606_a); $i++) { for ($j = 0; $j < count($info_606_a[$i]); $j++) { $descripteur_tete = $info_606_a[$i][$j]; $descripteur_fils = $info_606_x[$i][$j]; //Recherche du terme de tête //$requete="SELECT num_noeud FROM categories WHERE libelle_categorie='".addslashes($descripteur_tete)."' AND langue='fr_FR'"; $requete = "SELECT id_noeud FROM noeuds WHERE autorite='" . addslashes($descripteur_tete) . "'"; $resultat = mysql_query($requete); if (@mysql_num_rows($resultat)) { //la tête existe ! $categ_id_tete = mysql_result($resultat, 0, 0); } else { //Création de la tête //Nouveau Noeud ! $th = new thesaurus(1); $noeud = new noeuds(); $noeud->num_thesaurus = $th->id_thesaurus; $noeud->num_parent = $th->num_noeud_racine; $noeud->autorite = $descripteur_tete; $noeud->save(); $categ_id_tete = $noeud->id_noeud; //Création du libellé $categ = new categories($noeud->id_noeud, 'fr_FR'); $categ->libelle_categorie = $descripteur_tete; $categ->index_categorie = " " . strip_empty_words($descripteur_tete) . " "; $categ->save(); } //Recherche du terme fils $categ_id_fils = categories::searchLibelle(addslashes($descripteur_fils), 1, "fr_FR"); if (!$categ_id_fils) { //Création $noeud = new noeuds(); $noeud->num_thesaurus = 1; $noeud->num_parent = $categ_id_tete; $noeud->save(); $categ_id_fils = $noeud->id_noeud; //Création du libellé $categ = new categories($noeud->id_noeud, 'fr_FR'); $categ->libelle_categorie = $descripteur_fils; $categ->index_categorie = " " . strip_empty_words($descripteur_fils) . " "; $categ->save(); } $requete = "INSERT INTO notices_categories (notcateg_notice, num_noeud, ordre_categorie) VALUES ({$notice_id}, {$categ_id_fils}, " . ($i + 1) . ")"; mysql_query($requete); } } } //Indexation décimale if ($info_676[0]) { $requete = "select indexint_id from indexint where indexint_name='" . addslashes($info_676[0]) . "'"; $resultat = mysql_query($requete); if (mysql_num_rows($resultat)) { $indexint = mysql_result($resultat, 0, 0); } else { $requete = "insert into indexint (indexint_name) values('" . addslashes($info_676[0]) . "')"; mysql_query($requete); $indexint = mysql_insert_id(); } $requete = "update notices set indexint=" . $indexint . " where notice_id=" . $notice_id; mysql_query($requete); } //Organisme if ($info_900[0]) { $no_champ = trouve_champ_perso("op"); if ($no_champ > 0) { $requete = "SELECT max(notices_custom_list_value*1) FROM notices_custom_lists WHERE notices_custom_champ=" . $no_champ; $resultat = mysql_query($requete); $max = @mysql_result($resultat, 0, 0); $n = $max + 1; $requete = "SELECT notices_custom_list_value FROM notices_custom_lists WHERE notices_custom_list_lib='" . addslashes($info_900[0]) . "' AND notices_custom_champ=" . $no_champ; $resultat = mysql_query($requete); if (mysql_num_rows($resultat)) { $value = mysql_result($resultat, 0, 0); } else { $requete = "INSERT INTO notices_custom_lists (notices_custom_champ,notices_custom_list_value,notices_custom_list_lib) VALUES({$no_champ},{$n},'" . addslashes($info_900[0]) . "')"; mysql_query($requete); $value = $n; $n++; } $requete = "INSERT INTO notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) VALUES({$no_champ},{$notice_id},{$value})"; mysql_query($requete); } } //Genre if ($info_901[0]) { $no_champ = trouve_champ_perso("gen"); if ($no_champ > 0) { $requete = "SELECT max(notices_custom_list_value*1) FROM notices_custom_lists WHERE notices_custom_champ=" . $no_champ; $resultat = mysql_query($requete); $max = @mysql_result($resultat, 0, 0); $n = $max + 1; $requete = "SELECT notices_custom_list_value FROM notices_custom_lists WHERE notices_custom_list_lib='" . addslashes($info_901[0]) . "' AND notices_custom_champ=" . $no_champ; $resultat = mysql_query($requete); if (mysql_num_rows($resultat)) { $value = mysql_result($resultat, 0, 0); } else { $requete = "INSERT INTO notices_custom_lists (notices_custom_champ,notices_custom_list_value,notices_custom_list_lib) VALUES({$no_champ},{$n},'" . addslashes($info_901[0]) . "')"; mysql_query($requete); $value = $n; $n++; } $requete = "INSERT INTO notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) VALUES({$no_champ},{$notice_id},{$value})"; mysql_query($requete); } } //Type de texte if (count($info_904)) { $no_champ = trouve_champ_perso("typtext"); if ($no_champ > 0) { for ($i = 0; $i < count($info_904); $i++) { for ($j = 0; $j < count($info_904[$i]); $j++) { $requete = "SELECT max(notices_custom_list_value*1) FROM notices_custom_lists WHERE notices_custom_champ=" . $no_champ; $resultat = mysql_query($requete); $max = @mysql_result($resultat, 0, 0); $n = $max + 1; $requete = "SELECT notices_custom_list_value FROM notices_custom_lists WHERE notices_custom_list_lib='" . addslashes($info_904[$i][$j]) . "' AND notices_custom_champ=" . $no_champ; $resultat = mysql_query($requete); if (mysql_num_rows($resultat)) { $value = mysql_result($resultat, 0, 0); } else { $requete = "INSERT INTO notices_custom_lists (notices_custom_champ,notices_custom_list_value,notices_custom_list_lib) VALUES({$no_champ},{$n},'" . addslashes($info_904[$i][$j]) . "')"; mysql_query($requete); $value = $n; $n++; } $requete = "INSERT INTO notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) VALUES({$no_champ},{$notice_id},{$value})"; mysql_query($requete); } } } } //Date de saisie if ($info_902[0]) { $no_champ = trouve_champ_perso("ds"); if ($no_champ > 0) { $requete = "INSERT INTO notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_date) VALUES({$no_champ},{$notice_id},'" . str_replace(".", "-", $info_902[0]) . "')"; mysql_query($requete); } } //N° de lot if ($info_903[0]) { $requete = "UPDATE notices SET commentaire_gestion='" . addslashes($info_903[0]) . "' WHERE notice_id={$notice_id}"; mysql_query($requete); } //Cas de la mise à jour des périodiques ou du champ bord (notices chapeau) if ($bl == "s") { //Si c'est un périodique if ($dt == "a") { //Passage de la notice en notice chapeau $requete = "UPDATE notices SET niveau_biblio='s', niveau_hierar='1' WHERE notice_id={$notice_id}"; mysql_query($requete); //Recherche si la notice existe déjà par rapport au titre $requete = "select notice_id FROM notices WHERE ucase(tit1)='" . addslashes(strtoupper($info_200[0])) . "' AND niveau_biblio='s' AND niveau_hierar='1' AND notice_id!={$notice_id}"; $resultat = mysql_query($requete); $update = false; if (mysql_num_rows($resultat)) { $update = true; $n_update = mysql_result($resultat, 0, 0); //Mise à jour de tous les bulletins $requete = "UPDATE bulletins SET bulletin_notice=" . $notice_id . " WHERE bulletin_notice=" . $n_update; mysql_query($requete); //Suppression de l'ancienne notice $requete = "DELETE FROM notices WHERE notice_id={$n_update}"; mysql_query($requete); $requete = "DELETE FROM notices_categories WHERE notcateg_notice=" . $n_update; mysql_query($requete); $requete = "DELETE FROM notices_custom_values WHERE notices_custom_origine=" . $n_update; mysql_query($requete); $requete = "DELETE FROM responsability WHERE responsability_author=" . $n_update; mysql_query($requete); } if (!$update && $rs != "n") { //Si il n'y a pas de création, on supprime la notice $requete = "DELETE FROM notices WHERE notice_id={$notice_id}"; mysql_query($requete); $requete = "DELETE FROM notices_categories WHERE notcateg_notice=" . $notice_id; mysql_query($requete); $requete = "DELETE FROM notices_custom_values WHERE notices_custom_origine=" . $notice_id; mysql_query($requete); $requete = "DELETE FROM responsability WHERE responsability_author=" . $notice_id; mysql_query($requete); } } else { if ($dt == "l") { //Recherche si la notice existe déjà par rapport au titre $requete = "select notice_id FROM notices WHERE ucase(tit1)='" . addslashes(strtoupper($info_200[0])) . "' AND typdoc='l' AND notice_id!={$notice_id}"; $resultat = mysql_query($requete); $update = false; if (mysql_num_rows($resultat)) { $update = true; $n_update = mysql_result($resultat, 0, 0); //Suppression de l'ancienne notice $requete = "DELETE FROM notices WHERE notice_id={$n_update}"; mysql_query($requete); $requete = "DELETE FROM notices_categories WHERE notcateg_notice=" . $n_update; mysql_query($requete); $requete = "DELETE FROM notices_custom_values WHERE notices_custom_origine=" . $n_update; mysql_query($requete); $requete = "DELETE FROM responsability WHERE responsability_author=" . $n_update; mysql_query($requete); } } else { if ($dt == "r") { //Mise à jour du champ bord if ($info_910[0]) { $no_champ = trouve_champ_perso("bord"); if ($no_champ > 0) { //Recherche si la notice existe déjà par rapport au titre $requete = "SELECT notice_id FROM notices WHERE ucase(tit1)='" . addslashes(strtoupper($info_200[0])) . "' AND niveau_biblio='s' AND niveau_hierar='1' AND notice_id!={$notice_id}"; $resultat = mysql_query($requete); if (mysql_num_rows($resultat)) { $notice_update = mysql_result($resultat, 0, 0); $requete = "UPDATE notices_custom_values SET notices_custom_text='" . addslashes(str_replace("##", "\n", $info_910[0])) . "' WHERE notices_custom_champ={$no_champ} AND notices_custom_origine=" . $notice_update; mysql_query($requete); if (!mysql_affected_rows()) { $requete = "INSERT INTO notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_text) VALUES({$no_champ},{$notice_update},'" . addslashes(str_replace("##", "\n", $info_910[0])) . "')"; mysql_query($requete); } } } } //Suppression de la nouvelle notice $requete = "DELETE FROM notices WHERE notice_id=" . $notice_id; mysql_query($requete); } } } } }
function import_new_notice_suite() { global $dbh; global $notice_id; global $thes; global $index_sujets; global $pmb_keyword_sep; global $info_600_a, $info_600_j, $info_600_x, $info_600_y, $info_600_z; global $info_601_a, $info_601_j, $info_601_x, $info_601_y, $info_601_z; global $info_602_a, $info_602_j, $info_602_x, $info_602_y, $info_602_z; global $info_605_a, $info_605_j, $info_605_x, $info_605_y, $info_605_z; global $info_606_a, $info_606_j, $info_606_x, $info_606_y, $info_606_z; global $info_607_a, $info_607_j, $info_607_x, $info_607_y, $info_607_z; for ($a = 0; $a < sizeof($info_600_a); $a++) { $rameau .= "@@@" . trim($info_600_a[$a][0]); for ($j = 0; $j < sizeof($info_600_j[$a]); $j++) { $rameau .= " -- " . trim($info_600_j[$a][$j]); } for ($j = 0; $j < sizeof($info_600_x[$a]); $j++) { $rameau .= " -- " . trim($info_600_x[$a][$j]); } for ($j = 0; $j < sizeof($info_600_y[$a]); $j++) { $rameau .= " -- " . trim($info_600_y[$a][$j]); } for ($j = 0; $j < sizeof($info_600_z[$a]); $j++) { $rameau .= " -- " . trim($info_600_z[$a][$j]); } } for ($a = 0; $a < sizeof($info_601_a); $a++) { $rameau .= "@@@" . trim($info_601_a[$a][0]); for ($j = 0; $j < sizeof($info_601_j[$a]); $j++) { $rameau .= " -- " . trim($info_601_j[$a][$j]); } for ($j = 0; $j < sizeof($info_601_x[$a]); $j++) { $rameau .= " -- " . trim($info_601_x[$a][$j]); } for ($j = 0; $j < sizeof($info_601_y[$a]); $j++) { $rameau .= " -- " . trim($info_601_y[$a][$j]); } for ($j = 0; $j < sizeof($info_601_z[$a]); $j++) { $rameau .= " -- " . trim($info_601_z[$a][$j]); } } for ($a = 0; $a < sizeof($info_602_a); $a++) { $rameau .= "@@@" . trim($info_602_a[$a][0]); for ($j = 0; $j < sizeof($info_602_j[$a]); $j++) { $rameau .= " -- " . trim($info_602_j[$a][$j]); } for ($j = 0; $j < sizeof($info_602_x[$a]); $j++) { $rameau .= " -- " . trim($info_602_x[$a][$j]); } for ($j = 0; $j < sizeof($info_602_y[$a]); $j++) { $rameau .= " -- " . trim($info_602_y[$a][$j]); } for ($j = 0; $j < sizeof($info_602_z[$a]); $j++) { $rameau .= " -- " . trim($info_602_z[$a][$j]); } } for ($a = 0; $a < sizeof($info_605_a); $a++) { $rameau .= "@@@" . trim($info_605_a[$a][0]); for ($j = 0; $j < sizeof($info_605_j[$a]); $j++) { $rameau .= " -- " . trim($info_605_j[$a][$j]); } for ($j = 0; $j < sizeof($info_605_x[$a]); $j++) { $rameau .= " -- " . trim($info_605_x[$a][$j]); } for ($j = 0; $j < sizeof($info_605_y[$a]); $j++) { $rameau .= " -- " . trim($info_605_y[$a][$j]); } for ($j = 0; $j < sizeof($info_605_z[$a]); $j++) { $rameau .= " -- " . trim($info_605_z[$a][$j]); } } for ($a = 0; $a < sizeof($info_606_a); $a++) { $rameau .= "@@@" . trim($info_606_a[$a][0]); for ($j = 0; $j < sizeof($info_606_j[$a]); $j++) { $rameau .= " -- " . trim($info_606_j[$a][$j]); } for ($j = 0; $j < sizeof($info_606_x[$a]); $j++) { $rameau .= " -- " . trim($info_606_x[$a][$j]); } for ($j = 0; $j < sizeof($info_606_y[$a]); $j++) { $rameau .= " -- " . trim($info_606_y[$a][$j]); } for ($j = 0; $j < sizeof($info_606_z[$a]); $j++) { $rameau .= " -- " . trim($info_606_z[$a][$j]); } } for ($a = 0; $a < sizeof($info_607_a); $a++) { $rameau .= "@@@" . trim($info_607_a[$a][0]); for ($j = 0; $j < sizeof($info_607_j[$a]); $j++) { $rameau .= " -- " . trim($info_607_j[$a][$j]); } for ($j = 0; $j < sizeof($info_607_x[$a]); $j++) { $rameau .= " -- " . trim($info_607_x[$a][$j]); } for ($j = 0; $j < sizeof($info_607_y[$a]); $j++) { $rameau .= " -- " . trim($info_607_y[$a][$j]); } for ($j = 0; $j < sizeof($info_607_z[$a]); $j++) { $rameau .= " -- " . trim($info_607_z[$a][$j]); } } $categ_first = explode("@@@", stripslashes($rameau)); for ($i = 1; $i < count($categ_first); $i++) { $resultat = categories::searchLibelle(addslashes($categ_first[$i]), $thesaurus_defaut, 'fr_FR'); if (!$resultat) { /*vérification de l'existence des categs, sinon création */ $resultat = create_categ_cpt_rameau_first_level($thes->num_noeud_racine, $categ_first[$i], ' ' . strip_empty_words($categ_first[$i]) . ' '); } /* ajout de l'indexation à la notice dans la table notices_categories*/ $rqt_ajout = "insert into notices_categories set notcateg_notice='" . $notice_id . "', num_noeud='" . $resultat . "', ordre_categorie=" . ($i - 1); $res_ajout = @mysql_query($rqt_ajout, $dbh); } }
function calculer_cote_gaillarde($text) { global $f_ex_location, $dbh; $section = 'f_ex_section' . $f_ex_location; global ${$section}; $array_result = array(); $req_section = " select section_libelle from docs_section where idsection='" . ${$section} . "'"; $res_sect = mysql_query($req_section, $dbh); $sec_libelle = mysql_result($res_sect, 0, 0); $tab_section_auto = array("Congrès" => "20", "Accueil" => "Accueil", "ANL" => "ANL", "ECO" => "ECO", "ENV" => "ENV", "F" => "F", "GES" => "GES", "IAA" => "IAA", "Langues" => "LANG", "MAGASIN" => "MAGASIN", "MVV" => "MVV", "PROF" => "PROF", "S" => "S", "SCH" => "SCH", "SVI" => "SVI", "U" => "U", "VEG" => "VEG", "VIDEO" => "VIDEO"); if ($tab_section_auto[$sec_libelle]) { //Si on est dans un section d'incrément automatique //On récupère le maximum de toutes les cotes $req_max = "select expl_cote\n\t\t\tfrom exemplaires \n\t\t\twhere expl_location='" . $f_ex_location . "' \n\t\t\tand expl_cote REGEXP '(" . implode('/|', $tab_section_auto) . ")'\n\t\t"; $res_max = mysql_query($req_max, $dbh); $regexp = $cotes = array(); while ($expl = mysql_fetch_object($res_max)) { if (preg_match("/([0-9]*)\$/", $expl->expl_cote, $regexp)) { $cotes[] = $regexp[1]; } } $max = 0; for ($i = 0; $i < count($cotes); $i++) { $max = $max < $cotes[$i] ? $cotes[$i] : $max; } //On calcule les cotes dispo en fonction de la section et de la saisi de l'user $req_cote = "select indexint_name as name from indexint \n\t\t\twhere (indexint_name like '" . addslashes($tab_section_auto[$sec_libelle]) . "%') \n\t\t\tand (indexint_name like '" . addslashes($text) . "%') \n\t\t\tand num_pclass ='1'\n\t\t\torder by indexint_name, num_pclass limit 20"; $res_cote = mysql_query($req_cote, $dbh); while ($cote = mysql_fetch_object($res_cote)) { $array_result[] = $cote->name . " " . ($max + 1); } } else { //Catalogage manuelle if (${$section} != 27) { $array_sec = explode(' ', strip_empty_words($sec_libelle)); } else { $array_sec = array(); } $req_index = "select indexint_id as id, indexint_name as name from indexint \n\t\t\twhere index_indexint like '%" . addslashes(strip_empty_words($sec_libelle)) . "%' and num_pclass='1' \n\t\t\tand index_indexint like '" . addslashes($text) . "'\n\t\t\torder by indexint_name, num_pclass\n\t\t\tlimit 20\n\t\t\t"; $res_index = mysql_query($req_index, $dbh); if (mysql_num_rows($res_index) == 0) { $req_index = "select indexint_id as id, indexint_name as name from indexint \n\t\t\t\twhere index_indexint REGEXP '(" . implode('|', $array_sec) . ")' and num_pclass='1' \n\t\t\t\tand indexint_name like '" . addslashes($text) . "%'\n\t\t\t\torder by indexint_name, num_pclass\n\t\t\t\tlimit 20\n\t\t\t\t"; $res_index = mysql_query($req_index, $dbh); } if (mysql_num_rows($res_index) >= 1) { while ($cote = mysql_fetch_object($res_index)) { $array_result[] = $cote->name; } } else { $array_result[] = $sec_libelle; } } return $array_result; }
function save($explnum_doc = "") { global $dbh; if ($this->titre == '' || $this->editeur == '' && $this->auteur == '' && !$this->code && (!$this->sugg_explnum && !$explnum_doc)) { die("Erreur de création suggestions"); } if ($this->id_suggestion) { $q = "update suggestions set titre = '" . addslashes($this->titre) . "', editeur = '" . addslashes($this->editeur) . "', "; $q .= "auteur = '" . addslashes($this->auteur) . "', code = '" . addslashes($this->code) . "', prix = '" . $this->prix . "', nb = '" . $this->nb . "', commentaires = '" . addslashes($this->commentaires) . "', "; $q .= "commentaires_gestion = '" . addslashes($this->commentaires_gestion) . "', date_creation = '" . $this->date_creation . "', date_decision = '" . $this->date_decision . "', statut = '" . $this->statut . "', "; $q .= "num_produit = '" . $this->num_produit . "', num_entite = '" . $this->num_entite . "', num_rubrique = '" . $this->num_rubrique . "', "; $q .= "num_fournisseur = '" . $this->num_fournisseur . "', num_notice = '" . $this->num_notice . "', "; $q .= "index_suggestion = ' " . strip_empty_words($this->titre) . " " . strip_empty_words($this->editeur) . " " . strip_empty_words($this->auteur) . " " . $this->code . " " . strip_empty_words($this->commentaires) . " ', "; $q .= "url_suggestion = '" . addslashes($this->url_suggestion) . "', "; $q .= "num_categ = '" . $this->num_categ . "', "; $q .= "sugg_location = '" . $this->sugg_location . "', "; $q .= "date_publication = '" . $this->date_publi . "', "; $q .= "sugg_source = '" . $this->sugg_src . "' "; $q .= "where id_suggestion = '" . $this->id_suggestion . "' "; pmb_mysql_query($q, $dbh); } else { $q = "insert into suggestions set titre = '" . addslashes($this->titre) . "', editeur = '" . addslashes($this->editeur) . "', "; $q .= "auteur = '" . addslashes($this->auteur) . "', code = '" . addslashes($this->code) . "', prix = '" . $this->prix . "', nb = '" . $this->nb . "', commentaires = '" . addslashes($this->commentaires) . "', "; $q .= "commentaires_gestion = '" . addslashes($this->commentaires_gestion) . "', date_creation = '" . $this->date_creation . "', date_decision = '" . $this->date_decision . "', statut = '" . $this->statut . "', "; $q .= "num_produit = '" . $this->num_produit . "', num_entite = '" . $this->num_entite . "', num_rubrique = '" . $this->num_rubrique . "', "; $q .= "num_fournisseur = '" . $this->num_fournisseur . "', num_notice = '" . $this->num_notice . "', "; $q .= "index_suggestion = ' " . addslashes(strip_empty_words($this->titre) . " " . strip_empty_words($this->editeur) . " " . strip_empty_words($this->auteur) . " " . $this->code . " " . strip_empty_words($this->commentaires)) . " ', "; $q .= "url_suggestion = '" . addslashes($this->url_suggestion) . "', "; $q .= "num_categ = '" . $this->num_categ . "', "; $q .= "sugg_location = '" . $this->sugg_location . "', "; $q .= "date_publication = '" . $this->date_publi . "', "; $q .= "sugg_source = '" . $this->sugg_src . "' "; pmb_mysql_query($q, $dbh); $this->id_suggestion = pmb_mysql_insert_id($dbh); } if ($explnum_doc) { $explnum_doc->save(); $req = "insert into explnum_doc_sugg set \n\t\t\t\tnum_explnum_doc='" . $explnum_doc->explnum_doc_id . "',\n\t\t\t\tnum_suggestion='" . $this->id_suggestion . "'"; pmb_mysql_query($req, $dbh); } }
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; }
// calcul pourcentage avancement $percent = floor($start / $count * 100); // affichage du % d'avancement et de l'état print "<div align='center'>{$percent}%</div>"; while ($row = pmb_mysql_fetch_object($query)) { // index acte $req_update = "UPDATE actes "; $req_update .= "SET index_acte = ' " . $row->numero . " " . strip_empty_words($row->raison_sociale) . " " . strip_empty_words($row->commentaires) . " " . strip_empty_words($row->reference) . " ' "; $req_update .= "WHERE id_acte = " . $row->id_acte . " "; $update = pmb_mysql_query($req_update); //index lignes_actes $query_2 = pmb_mysql_query("SELECT id_ligne, code, libelle FROM lignes_actes where num_acte = '" . $row->id_acte . "' "); if (pmb_mysql_num_rows($query_2)) { while ($row_2 = pmb_mysql_fetch_object($query_2)) { $req_update_2 = "UPDATE lignes_actes "; $req_update_2 .= "SET index_ligne = ' " . strip_empty_words($row_2->libelle) . " ' "; $req_update_2 .= "WHERE id_ligne = " . $row_2->id_ligne . " "; $update_2 = pmb_mysql_query($req_update_2); } pmb_mysql_free_result($query_2); } } pmb_mysql_free_result($query); $next = $start + $lot; print "\n\t\t\t\t<form class='form-{$current_module}' name='current_state' action='./clean.php' method='post'>\n\t\t\t\t<input type='hidden' name='v_state' value=\"" . urlencode($v_state) . "\">\n\t\t\t\t<input type='hidden' name='spec' value=\"{$spec}\">\n\t\t\t\t<input type='hidden' name='start' value=\"{$next}\">\n\t\t\t\t<input type='hidden' name='count' value=\"{$count}\">\n\t\t\t\t<input type='hidden' name='index_quoi' value=\"ACTES\">\n\t\t\t\t</form>\n\t\t\t\t<script type=\"text/javascript\"><!-- \n\t\t\t\t\tsetTimeout(\"document.forms['current_state'].submit()\",1000); \n\t\t\t\t\t-->\n\t\t\t\t</script>"; } else { // mise à jour de l'affichage de la jauge print "<table border='0' align='center' width='{$table_size}' cellpadding='0'><tr><td class='jauge'>"; print "<img src='../../images/jauge.png' width='{$jauge_size}' height='16'></td></tr></table>"; print "<div align='center'>100%</div>"; $v_state .= "<br /><img src=../../images/d.gif hspace=3>" . htmlentities($msg["nettoyage_reindex_act"], ENT_QUOTES, $charset) . " {$count} " . htmlentities($msg["nettoyage_res_reindex_act"], ENT_QUOTES, $charset);
function import_new_notice_suite() { global $dbh; global $notice_id; global $info_464; global $info_606_a; global $info_900, $info_901, $info_902, $info_903, $info_904, $info_905, $info_906; global $pmb_keyword_sep; global $bulletin_ex; //Cas des périodiques if (is_array($info_464)) { $requete = "select * from notices where notice_id={$notice_id}"; $resultat = pmb_mysql_query($requete); $r = pmb_mysql_fetch_object($resultat); //Notice chapeau existe-t-elle ? $requete = "select notice_id from notices where tit1='" . addslashes($info_464[0]['t']) . "' and niveau_hierar='1' and niveau_biblio='s'"; $resultat = pmb_mysql_query($requete); if (@pmb_mysql_num_rows($resultat)) { //Si oui, récupération id $chapeau_id = pmb_mysql_result($resultat, 0, 0); //Bulletin existe-t-il ? $requete = "select bulletin_id from bulletins where bulletin_numero='" . addslashes($info_464[0]['v']) . "' and mention_date='" . addslashes($info_464[0]['d']) . "' and bulletin_notice={$chapeau_id}"; //$requete="select bulletin_id from bulletins where bulletin_numero='".addslashes($info_464[0]['v'])."' and bulletin_notice=$chapeau_id"; $resultat = pmb_mysql_query($requete); if (@pmb_mysql_num_rows($resultat)) { //Si oui, récupération id bulletin $bulletin_id = pmb_mysql_result($resultat, 0, 0); } else { //Si non, création bulltin $info = array(); $bulletin = new bulletinage("", $chapeau_id); $info['bul_titre'] = addslashes("Bulletin N°" . $info_464[0]['v']); $info['bul_no'] = addslashes($info_464[0]['v']); $info['bul_date'] = addslashes($info_464[0]['d']); if (!$info_464[0]['e']) { $date_date = explode("/", $info_464[0]['d']); if (count($date_date)) { if (count($date_date) == 1) { $info['date_date'] = $date_date[0] . "-01-01"; } if (count($date_date) == 2) { $info['date_date'] = $date_date[1] . "-" . $date_date[0] . "-01"; } if (count($date_date) == 3) { $info['date_date'] = $date_date[2] . "-" . $date_date[1] . "-" . $date_date[0]; } } else { if ($info_904[0]) { $info['date_date'] = $info_904[0]; } } } else { $info['date_date'] = $info_464[0]['e']; } $bulletin_id = $bulletin->update($info); } } else { //Si non, création notice chapeau et bulletin $chapeau = new serial(); $info = array(); $info['tit1'] = addslashes($info_464[0]['t']); $info['niveau_biblio'] = 's'; $info['niveau_hierar'] = '1'; $info['typdoc'] = $r->typdoc; $chapeau->update($info); $chapeau_id = $chapeau->serial_id; $bulletin = new bulletinage("", $chapeau_id); $info = array(); $info['bul_titre'] = addslashes("Bulletin N°" . $info_464[0]['v']); $info['bul_no'] = addslashes($info_464[0]['v']); $info['bul_date'] = addslashes($info_464[0]['d']); if (!$info_464[0]['e']) { $date_date = explode("/", $info_464[0]['d']); if (count($date_date)) { if (count($date_date) == 1) { $info['date_date'] = $date_date[0] . "-01-01"; } if (count($date_date) == 2) { $info['date_date'] = $date_date[1] . "-" . $date_date[0] . "-01"; } if (count($date_date) == 3) { $info['date_date'] = $date_date[2] . "-" . $date_date[1] . "-" . $date_date[0]; } } else { if ($info_904[0]) { $info['date_date'] = $info_904[0]; } } } else { $info['date_date'] = $info_464[0]['e']; } $bulletin_id = $bulletin->update($info); } //Notice objet ? if ($info_464[0]['z'] == 'objet') { //Supression de la notice $requete = "delete from notices where notice_id={$notice_id}"; pmb_mysql_query($requete); $bulletin_ex = $bulletin_id; } else { //Passage de la notice en article $requete = "update notices set niveau_biblio='a', niveau_hierar='2', year='" . addslashes($info_464[0]['d']) . "', npages='" . addslashes($info_464[0]['p']) . "', date_parution='" . $info['date_date'] . "' where notice_id={$notice_id}"; pmb_mysql_query($requete); $requete = "insert into analysis (analysis_bulletin,analysis_notice) values({$bulletin_id},{$notice_id})"; pmb_mysql_query($requete); $bulletin_ex = $bulletin_id; } } else { $bulletin_ex = 0; } //Traitement du thésaurus $unknown_desc = array(); for ($i = 0; $i < count($info_606_a); $i++) { for ($j = 0; $j < count($info_606_a[$i]); $j++) { $descripteur = $info_606_a[$i][$j]; //Recherche du terme //dans le thesaurus par defaut et dans la langue de l'interface $libelle = addslashes($descripteur); $categ_id = categories::searchLibelle($libelle); if ($categ_id) { $requete = "insert into notices_categories (notcateg_notice,num_noeud) values({$notice_id},{$categ_id})"; pmb_mysql_query($requete); } else { $unknown_desc[] = $descripteur; } } if ($unknown_desc) { $mots_cles = implode($pmb_keyword_sep, $unknown_desc); $requete = "update notices set index_l='" . addslashes($mots_cles) . "', index_matieres=' " . addslashes(strip_empty_words($mots_cles)) . " ' where notice_id={$notice_id}"; pmb_mysql_query($requete); } } }
function import_new_notice_suite() { global $dbh; global $notice_id; global $index_sujets; global $pmb_keyword_sep; global $id_notices_custom_opsys, $id_notices_custom_type_opsys; global $info_001, $info_464, $info_464_a, $info_464_e, $info_464_f, $info_461_3, $info_461_t, $info_200_a, $info_200_e, $info_210_d, $info_902_a, $info_686_a, $info_462_3, $info_462_t; global $num_thesaurus, $thes; global $info_675_a; global $info_600_a, $info_600_b, $info_600_j, $info_600_x, $info_600_y, $info_600_z; global $info_601_a, $info_601_b, $info_601_j, $info_601_x, $info_601_y, $info_601_z; global $info_602_a, $info_602_b, $info_602_j, $info_602_x, $info_602_y, $info_602_z; global $info_605_a, $info_605_b, $info_605_j, $info_605_x, $info_605_y, $info_605_z; global $info_606_a, $info_606_b, $info_606_j, $info_606_x, $info_606_y, $info_606_z; global $info_607_a, $info_607_b, $info_607_j, $info_607_x, $info_607_y, $info_607_z; global $info_610_a, $info_610_e, $info_610_b, $info_610_j, $info_610_x, $info_610_y, $info_610_z, $info_610_3, $info_610; global $bulletin_id; global $flag_titre_serie_recuperation; global $flag_depouillements_464, $flag_depouillements_464_doc_sonore, $flag_depouillements_464_doc_imprime; global $aut_700, $aut_701, $aut_702, $aut_710, $aut_711, $aut_712; global $accomp_345_c; global $table_responsability_function; global $lang, $include_path, $xml_changement; global $info_345_d; global $info_071_a, $info_071_b; global $thes_centre_interet, $num_thesaurus_centre_interet, $info_901; global $flag_import_610_in_mot_cles, $thes_610, $num_thesaurus_610; global $collection_225, $sous_coll; // prix dvd et video if ($info_345_d[0]) { $requete = "update notices set prix='" . addslashes($info_345_d[0]) . "' where notice_id='{$notice_id}' "; pmb_mysql_query($requete); } // EAN if ($info_071_a[0]) { $requete = "update notices set code='" . addslashes($info_071_a[0]) . "' where notice_id='{$notice_id}' "; pmb_mysql_query($requete); } // Producteur -> Editeur if ($info_071_b[0]) { $nom = $info_071_b[0]; $requete = "select ed_id from publishers where ed_name='" . addslashes($nom) . "' "; $result = pmb_mysql_query($requete); if ($row = pmb_mysql_fetch_row($result)) { $ed_id = $row[0]; } else { $requete = "insert into publishers SET ed_name='{$nom}', "; $requete .= "index_publisher=' " . strip_empty_words($nom) . " '"; pmb_mysql_query($requete); $ed_id = pmb_mysql_insert_id(); } $requete = "update notices set ed1_id='" . $ed_id . "' where notice_id='{$notice_id}' "; pmb_mysql_query($requete); } // 345_c Matériel d'accompagnement if ($accomp_345_c[0]) { $requete = "update notices set accomp='" . addslashes($accomp_345_c[0]) . "' where notice_id='{$notice_id}' "; pmb_mysql_query($requete); } update_authors_num_opsys($aut_700, 0); update_authors_num_opsys($aut_701, 1); update_authors_num_opsys($aut_702, 2); update_authors_num_opsys($aut_710, 2); update_authors_num_opsys($aut_711, 2); update_authors_num_opsys($aut_712, 2); if ($xml_changement) { xml_save_table("{$include_path}/marc_tables/{$lang}/function_subst.xml", $table_responsability_function); } //UDC if ($info_675_a[0]) { $indexint_id = indexint::import(clean_string($info_675_a[0])); $requete = "update notices set indexint='{$indexint_id}' where notice_id='{$notice_id}' "; pmb_mysql_query($requete); } if ($aut_700[0][a] != "") { if ($aut_700[0][3] != "") { $requete = "select author_id from authors where author_name='" . addslashes($aut_700[0][a]) . "' and author_rejete='" . addslashes($aut_700[0][b]) . "' "; $result = pmb_mysql_query($requete); if ($row = pmb_mysql_fetch_row($result)) { $author_id = $row[0]; $requete = "update authors set author_comment='" . addslashes($aut_700[0][3]) . "' where author_id='{$author_id}' "; pmb_mysql_query($requete); } } } if ($sous_coll == '1' && $collection_225[0]['a'] != "" && $collection_225[1]['a'] != "") { $q = "select coll_id from notices where notice_id='{$notice_id}' "; $r = pmb_mysql_query($q, $dbh); $coll_id = pmb_mysql_result($r, 0, 0); if ($coll_id != '0') { /* sous collection */ $subcollec['name'] = clean_string($collection_225[1]['a']); $subcollec['coll_parent'] = $coll_id; $subcoll_id = subcollection::import($subcollec); $requete = "update notices set subcoll_id='{$subcoll_id}' where notice_id='{$notice_id}' "; pmb_mysql_query($requete); } } $bulletin_id = 0; // Effacement de la notice temporaire eventuelle list($num_opsys, $type_opsys) = explode(" ", $info_001[0]); if ($type_opsys == 'UMO:13') { $requete = "update notices set niveau_biblio='b', niveau_hierar='2' where notice_id='{$notice_id}' "; //print "$requete <br />"; pmb_mysql_query($requete); } if ($type_opsys == 'UMO:23' || $type_opsys == 'UMO:3') { // Titre de périodique $requete = "select * from notices_custom_values where notices_custom_small_text='" . $num_opsys . "'"; //print "new $type_opsys: $requete <br />"; $resultat = pmb_mysql_query($requete); //Notice existe-t-elle comme notice temporaire? if (@pmb_mysql_num_rows($resultat)) { //Si oui, récupération id notice temporaire a supprimer $old_n = pmb_mysql_fetch_object($resultat); $notice_id_old = $old_n->notices_custom_origine; // modifie les anciennes relations sur la vrai notice $requete = "update notices_relations set linked_notice='{$notice_id}' where linked_notice='{$notice_id_old}' "; //print "$requete <br />"; pmb_mysql_query($requete); $requete = "update bulletins set bulletin_notice='{$notice_id}' where bulletin_notice='{$notice_id_old}' "; //print "$requete <br />"; pmb_mysql_query($requete); $requete = "update notices set niveau_biblio='s', niveau_hierar='1' where notice_id='{$notice_id}' "; //print "$requete <br />"; pmb_mysql_query($requete); // suppression de la notice temporaire $requete = "delete from notices where notice_id=" . $notice_id_old; pmb_mysql_query($requete); $requete = "delete from notices_custom_values where notices_custom_origine='" . $notice_id_old . "'"; pmb_mysql_query($requete); //print "$requete <br />"; } else { $requete = "update notices set niveau_biblio='s', niveau_hierar='1' where notice_id='{$notice_id}' "; pmb_mysql_query($requete); } } else { if ($type_opsys == 'UMO:41' || $type_opsys == 'UMO:42') { // Dépouillement (hors article) //Rien } else { if ($type_opsys == 'UMO:43') { // Dépouillement article de périodique $requete = "select * from notices_custom_values where notices_custom_small_text='" . $num_opsys . "'"; //print "new $type_opsys: $requete <br />"; $resultat = pmb_mysql_query($requete); //Notice existe-t-elle comme notice temporaire? if (@pmb_mysql_num_rows($resultat)) { //Si oui, récupération id notice temporaire a supprimer $old_n = pmb_mysql_fetch_object($resultat); $notice_id_old = $old_n->notices_custom_origine; // modifie les anciennes relations sur la vrai notice $requete = "update analysis set analysis_notice='{$notice_id}' where analysis_notice='{$notice_id_old}' "; //print "$requete <br />"; pmb_mysql_query($requete); $requete = "update notices set niveau_biblio='a', niveau_hierar='2' where notice_id='{$notice_id}' "; //print "$requete <br />"; pmb_mysql_query($requete); // suppression de la notice temporaire $requete = "delete from notices where notice_id=" . $notice_id_old; pmb_mysql_query($requete); $requete = "delete from notices_custom_values where notices_custom_origine='" . $notice_id_old . "'"; pmb_mysql_query($requete); } else { $requete = "update notices set niveau_biblio='a', niveau_hierar='2' where notice_id='{$notice_id}' "; pmb_mysql_query($requete); //print "$requete <br />"; } } else { // UMO 1 2 4 8 21 22 24 28 $is_serie = $type_opsys == 'UMO:21' || $type_opsys == 'UMO:22' || $type_opsys == 'UMO:24' || $type_opsys == 'UMO:28'; if ($flag_titre_serie_recuperation && $is_serie || !$is_serie) { $requete = "select * from notices_custom_values where notices_custom_small_text='" . $num_opsys . "'"; //print "new $type_opsys: $requete <br />"; $resultat = pmb_mysql_query($requete); //Notice existe-t-elle comme notice temporaire? if (@pmb_mysql_num_rows($resultat)) { //Si oui, récupération id notice temporaire a supprimer $old_n = pmb_mysql_fetch_object($resultat); $notice_id_old = $old_n->notices_custom_origine; // modifie les anciennes relations sur la vrai notice $requete = "update notices_relations set linked_notice='{$notice_id}' where linked_notice='{$notice_id_old}' "; //print "$requete <br />"; pmb_mysql_query($requete); // suppression de la notice temporaire $requete = "delete from notices where notice_id=" . $notice_id_old; pmb_mysql_query($requete); $requete = "delete from notices_custom_values where notices_custom_origine='" . $notice_id_old . "'"; pmb_mysql_query($requete); //print "$requete <br />"; } } else { if ($is_serie) { // suprimer la notice car on en veut pas del_notice($notice_id); return; } } } } } //Genre dans Thesaurus for ($i = 0; $i < count($info_902_a); $i++) { for ($j = 0; $j < count($info_902_a[$i]); $j++) { $resultat = categories::searchLibelle(addslashes($info_902_a[$i][$j]), $num_thesaurus, 'fr_FR'); if (!$resultat) { /*vérification de l'existence des categs, sinon création */ $resultat = create_categ($thes, $thes->num_noeud_racine, $info_902_a[$i][$j], ' ' . strip_empty_words($info_902_a[$i][$j]) . ' '); } /* ajout de l'indexation à la notice dans la table notices_categories*/ $rqt_ajout = "insert into notices_categories set notcateg_notice='" . $notice_id . "', num_noeud='" . $resultat . "' "; $res_ajout = @pmb_mysql_query($rqt_ajout, $dbh); } } //centre interet dans Thesaurus for ($i = 0; $i < count($info_901); $i++) { $resultat = categories::searchLibelle(addslashes($info_901[$i]['a']), $num_thesaurus_centre_interet, 'fr_FR'); if (!$resultat) { /*vérification de l'existence des categs, sinon création */ $resultat = create_categ($thes_centre_interet, $thes_centre_interet->num_noeud_racine, $info_901[$i]['a'], ' ' . strip_empty_words($info_901[$i]['a']) . ' ', $info_901[$i][3]); } /* ajout de l'indexation à la notice dans la table notices_categories*/ $rqt_ajout = "insert into notices_categories set notcateg_notice='" . $notice_id . "', num_noeud='" . $resultat . "' "; $res_ajout = @pmb_mysql_query($rqt_ajout, $dbh); } // Pcdm (686) dans le plan de classement // print "<pre>"; print_r($info_686_a);print "</pre>"; if (count($info_686_a)) { //vérification de l'existence des categs, sinon création $requete = "select indexint_id from indexint where indexint_name='" . addslashes($info_686_a[0]) . "' and num_pclass='2'"; //print "$requete <br />"; $result = pmb_mysql_query($requete); if ($row = pmb_mysql_fetch_row($result)) { $indexint_id = $row[0]; } else { $requete = "insert into indexint SET indexint_name='" . addslashes($info_686_a[0]) . "', num_pclass='2' "; //print "$requete <br />"; pmb_mysql_query($requete); $indexint_id = pmb_mysql_insert_id(); } $requete = "update notices set indexint='{$indexint_id}' where notice_id='{$notice_id}' "; // print "$requete <br />"; @pmb_mysql_query($requete, $dbh); } // if (is_array($index_sujets)) $mots_cles = implode (" $pmb_keyword_sep ",$index_sujets); // else $mots_cles = $index_sujets; $mots_cles = ''; for ($a = 0; $a < sizeof($info_600_a); $a++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_600_a[$a][0]; for ($j = 0; $j < sizeof($info_600_b[$a]); $j++) { $mots_cles .= " , " . $info_600_b[$a][0]; } for ($j = 0; $j < sizeof($info_600_j[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_600_j[$a][$j]; } for ($j = 0; $j < sizeof($info_600_x[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_600_x[$a][$j]; } for ($j = 0; $j < sizeof($info_600_y[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_600_y[$a][$j]; } for ($j = 0; $j < sizeof($info_600_z[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_600_z[$a][$j]; } } for ($a = 0; $a < sizeof($info_601_a); $a++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_601_a[$a][0]; for ($j = 0; $j < sizeof($info_601_b[$a]); $j++) { $mots_cles .= " , " . $info_601_b[$a][0]; } for ($j = 0; $j < sizeof($info_601_j[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_601_j[$a][$j]; } for ($j = 0; $j < sizeof($info_601_x[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_601_x[$a][$j]; } for ($j = 0; $j < sizeof($info_601_y[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_601_y[$a][$j]; } for ($j = 0; $j < sizeof($info_601_z[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_601_z[$a][$j]; } } for ($a = 0; $a < sizeof($info_602_a); $a++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_602_a[$a][0]; for ($j = 0; $j < sizeof($info_602_b[$a]); $j++) { $mots_cles .= " , " . $info_602_b[$a][0]; } for ($j = 0; $j < sizeof($info_602_j[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_602_j[$a][$j]; } for ($j = 0; $j < sizeof($info_602_x[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_602_x[$a][$j]; } for ($j = 0; $j < sizeof($info_602_y[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_602_y[$a][$j]; } for ($j = 0; $j < sizeof($info_602_z[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_602_z[$a][$j]; } } for ($a = 0; $a < sizeof($info_605_a); $a++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_605_a[$a][0]; for ($j = 0; $j < sizeof($info_605_b[$a]); $j++) { $mots_cles .= " , " . $info_605_b[$a][0]; } for ($j = 0; $j < sizeof($info_605_j[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_605_j[$a][$j]; } for ($j = 0; $j < sizeof($info_605_x[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_605_x[$a][$j]; } for ($j = 0; $j < sizeof($info_605_y[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_605_y[$a][$j]; } for ($j = 0; $j < sizeof($info_605_z[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_605_z[$a][$j]; } } for ($a = 0; $a < sizeof($info_606_a); $a++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_606_a[$a][0]; for ($j = 0; $j < sizeof($info_606_b[$a]); $j++) { $mots_cles .= " , " . $info_606_b[$a][0]; } for ($j = 0; $j < sizeof($info_606_j[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_606_j[$a][$j]; } for ($j = 0; $j < sizeof($info_606_x[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_606_x[$a][$j]; } for ($j = 0; $j < sizeof($info_606_y[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_606_y[$a][$j]; } for ($j = 0; $j < sizeof($info_606_z[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_606_z[$a][$j]; } } for ($a = 0; $a < sizeof($info_607_a); $a++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_607_a[$a][0]; for ($j = 0; $j < sizeof($info_607_b[$a]); $j++) { $mots_cles .= " , " . $info_607_b[$a][0]; } for ($j = 0; $j < sizeof($info_607_j[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_607_j[$a][$j]; } for ($j = 0; $j < sizeof($info_607_x[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_607_x[$a][$j]; } for ($j = 0; $j < sizeof($info_607_y[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_607_y[$a][$j]; } for ($j = 0; $j < sizeof($info_607_z[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_607_z[$a][$j]; } } if ($flag_import_610_in_mot_cles) { for ($a = 0; $a < sizeof($info_610_a); $a++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_610_a[$a][0]; for ($j = 0; $j < sizeof($info_610_b[$a]); $j++) { $mots_cles .= " , " . $info_610_b[$a][0]; } for ($j = 0; $j < sizeof($info_610_j[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_610_j[$a][$j]; } for ($j = 0; $j < sizeof($info_610_x[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_610_x[$a][$j]; } for ($j = 0; $j < sizeof($info_610_y[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_610_y[$a][$j]; } for ($j = 0; $j < sizeof($info_610_z[$a]); $j++) { $mots_cles .= " {$pmb_keyword_sep} " . $info_610_z[$a][$j]; } if (sizeof($info_610_e[$a])) { $mots_cles .= " ( "; for ($j = 0; $j < sizeof($info_610_e[$a]); $j++) { if ($j) { $mots_cles .= " , "; } $mots_cles .= $info_610_e[$a][$j]; } $mots_cles .= " ) "; } } } //print"<pre>";print_r($info_610_a);print_r($info_610_e);print"</pre>"; for ($a = 0; $a < sizeof($info_610_a); $a++) { $resultat = categories::searchLibelle(addslashes($info_610_a[$a][0]), $num_thesaurus_610, 'fr_FR', $thes_610->num_noeud_racine); if (!$resultat) { /*vérification de l'existence des categs, sinon création */ $resultat = create_categ($thes_610, $thes_610->num_noeud_racine, $info_610_a[$a][0], ' ' . strip_empty_words($info_610_a[$a][0]) . ' ', $info_610_3[$a][0]); } for ($j = 0; $j < sizeof($info_610_e[$a]); $j++) { if ($info_610_e[$a][$j]) { $num_parent = $resultat; $resultat = categories::searchLibelle(addslashes($info_610_e[$a][$j]), $num_thesaurus_610, 'fr_FR', $num_parent); if (!$resultat) { /*vérification de l'existence des categs, sinon création */ $resultat = create_categ($thes_610, $num_parent, $info_610_e[$a][$j], ' ' . strip_empty_words($info_610_e[$a][$j]) . ' ', $info_610_3[$a][0]); } } } /* ajout de l'indexation à la notice dans la table notices_categories*/ $rqt_ajout = "insert into notices_categories set notcateg_notice='" . $notice_id . "', num_noeud='" . $resultat . "' "; $res_ajout = @pmb_mysql_query($rqt_ajout, $dbh); } if (substr($mots_cles, 0, 2) == ' ;') { $mots_cles = substr($mots_cles, 2); } $mots_cles ? $index_matieres = strip_empty_words($mots_cles) : ($index_matieres = ''); $rqt_maj = "update notices set index_l='" . addslashes($mots_cles) . "', index_matieres=' " . addslashes($index_matieres) . " ' where notice_id='{$notice_id}' "; $res_ajout = pmb_mysql_query($rqt_maj, $dbh); // insert du param perso mémorisant le numero Opsys de la notice if (!$id_notices_custom_opsys) { $rqt = "select idchamp from notices_custom where name='num_opsys'"; $res = pmb_mysql_query($rqt, $dbh); if ($res && ($r = pmb_mysql_fetch_object($res))) { $id_notices_custom_opsys = $r->idchamp; } $rqt = "select idchamp from notices_custom where name='type_opsys'"; $res = pmb_mysql_query($rqt, $dbh); if ($res && ($r = pmb_mysql_fetch_object($res))) { $id_notices_custom_type_opsys = $r->idchamp; } } $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_small_text) values({$id_notices_custom_opsys},{$notice_id},'" . addslashes($num_opsys) . "')"; pmb_mysql_query($requete); $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_small_text) values({$id_notices_custom_type_opsys},{$notice_id},'" . addslashes($type_opsys) . "')"; pmb_mysql_query($requete); $requete = "select * from notices where notice_id={$notice_id}"; $resultat = pmb_mysql_query($requete); $r = pmb_mysql_fetch_object($resultat); // $flag_depouillements_464_doc_sonore // $flag_depouillements_464_doc_imprime=0; // Traiter les dépouillement du champ 464 if ($flag_depouillements_464) { if (is_array($info_464)) { switch ($type_opsys) { case 'UMO:1': // Documents imprimés Unimarc moyen $niveau_biblio = 'm'; $niveau_hierar = '0'; break; case 'UMO:2': // Documents sonores Unimarc moyen $niveau_biblio = 'm'; $niveau_hierar = '0'; break; case 'UMO:13': // bulletin $niveau_biblio = 'a'; $niveau_hierar = '2'; break; case 'UMO:4': // Documents audiovisuel Unimarc moyen $niveau_biblio = 'm'; $niveau_hierar = '0'; break; case 'UMO:8': // Logiciels - CDrom $niveau_biblio = 'm'; $niveau_hierar = '0'; break; default: $niveau_biblio = 'm'; $niveau_hierar = '0'; break; } //print "<pre>";print_r ($info_464);print "</pre>"; for ($i = 0; $i < sizeof($info_464); $i++) { $a_464 = $e_464 = $_3_464 = array(); $author_id = 0; for ($j = 0; $j < sizeof($info_464[$i]); $j++) { if ($info_464[$i][$j]['label'] == 'a') { $a_464[] = $info_464[$i][$j]['content']; } if ($info_464[$i][$j]['label'] == 'e') { $e_464[] = $info_464[$i][$j]['content']; } // Complément du titre if ($info_464[$i][$j]['label'] == '3') { $_3_464[] = $info_464[$i][$j]['content']; } // Complément du titre } //print "<pre>";print_r ($_3_464);print "</pre>"; for ($j = 0; $j < sizeof($a_464); $j++) { if ($_3_464[$j]) { $requete = "select author_id from authors where author_comment='" . addslashes($_3_464[$j]) . "' "; $result = pmb_mysql_query($requete); if ($row = pmb_mysql_fetch_row($result)) { $author_id = $row[0]; //print $author_id."<br />"; } } if ($a_464[$j] != '...') { $requete = "insert into notices set typdoc='{$r->typdoc}', tit1 ='" . addslashes($a_464[$j]) . "',tit2 ='" . addslashes($e_464[$j]) . "', niveau_biblio='{$niveau_biblio}',niveau_hierar='{$niveau_hierar}' "; //if ($type_opsys="UMO:2") print $requete ."<br />"; pmb_mysql_query($requete); $depouille_id = pmb_mysql_insert_id(); if ($depouille_id) { //link notice $requete = "insert into notices_relations set num_notice='{$depouille_id}', linked_notice ='{$notice_id}', relation_type='a' "; pmb_mysql_query($requete); if ($author_id) { $requete = "insert into responsability SET responsability_fonction='070' , responsability_notice='{$depouille_id}' , responsability_author = {$author_id}, responsability_type=0"; //print $requete."<br />"; $result = pmb_mysql_query($requete); } } } } } /* for ($i=0; $i<sizeof($info_464); $i++) { $a_464=''; $e_464=''; for ($j=0; $j<sizeof($info_464[$i]); $j++) { if($info_464[$i][$j]['label']=='a') $a_464=$info_464[$i][$j]['content']; if($info_464[$i][$j]['label']=='e') $e_464=$info_464[$i][$j]['content']; } $requete="insert into notices set typdoc='$r->typdoc', tit1 ='".addslashes($a_464)."',tit2 ='".addslashes($e_464)."', niveau_biblio='$niveau_biblio',niveau_hierar='$niveau_hierar' "; //if ($type_opsys="UMO:2") print $requete ."<br />"; pmb_mysql_query($requete); $depouille_id=pmb_mysql_insert_id(); if ($depouille_id) { //link notice $requete="insert into notices_relations set num_notice='$depouille_id', linked_notice ='$notice_id', relation_type='a' "; pmb_mysql_query($requete); } } */ } } // $info_461_3,$info_461_t : dépendance d'une notice chapeau for ($_3 = 0; $_3 < sizeof($info_461_3); $_3++) { switch ($type_opsys) { case 'UMO:1': case 'UMO:2': case 'UMO:4': case 'UMO:8': if ($flag_titre_serie_recuperation) { // que si on veut $requete = "select notices_custom_origine from notices_custom_values where notices_custom_small_text='" . $info_461_3[$_3] . "'"; //print "$requete <br />"; $resultat = pmb_mysql_query($requete); //Notice chapeau existe-t-elle ? if (@pmb_mysql_num_rows($resultat)) { //Si oui, récupération id $chapeau_id = pmb_mysql_result($resultat, 0, 0); } else { $niveau_biblio = 'm'; $niveau_hierar = '1'; // Création de la notice temporaire chapeau $requete = "insert into notices set typdoc='{$r->typdoc}', tit1 ='" . addslashes($info_461_t[$a]) . "' , niveau_biblio='{$niveau_biblio}',niveau_hierar='{$niveau_hierar}' "; //print "$requete <br />"; pmb_mysql_query($requete); $chapeau_id = pmb_mysql_insert_id(); $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_small_text) values({$id_notices_custom_opsys},{$chapeau_id},'" . addslashes($info_461_3[$_3]) . "')"; //print "$requete <br />"; pmb_mysql_query($requete); } if ($chapeau_id) { //link notice $requete = "insert into notices_relations set num_notice='{$notice_id}', linked_notice ='{$chapeau_id}', relation_type='a' "; //print "$requete <br />"; pmb_mysql_query($requete); } } break; case 'UMO:13': // bulletin de périodique $requete = "select notices_custom_origine from notices_custom_values where notices_custom_small_text='" . $info_461_3[$_3] . "'"; //print "$requete <br />"; $resultat = pmb_mysql_query($requete); //Notice chapeau existe-t-elle ? if (@pmb_mysql_num_rows($resultat)) { //Si oui, récupération id $chapeau_id = pmb_mysql_result($resultat, 0, 0); } else { $niveau_biblio = 's'; $niveau_hierar = '1'; // Création de la notice temporaire chapeau $requete = "insert into notices set typdoc='{$r->typdoc}', tit1 ='" . addslashes($info_461_t[$a]) . "' , niveau_biblio='{$niveau_biblio}',niveau_hierar='{$niveau_hierar}' "; //print "$requete <br />"; pmb_mysql_query($requete); $chapeau_id = pmb_mysql_insert_id(); $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_small_text) values({$id_notices_custom_opsys},{$chapeau_id},'" . addslashes($info_461_3[$_3]) . "')"; //print "$requete <br />"; pmb_mysql_query($requete); } if ($chapeau_id) { //link notice $requete = "insert into notices_relations set num_notice='{$notice_id}', linked_notice ='{$chapeau_id}', relation_type='b' , rank ='1'"; //print "$requete <br />"; pmb_mysql_query($requete); // création bulletin $info = array(); $bulletin = new bulletinage("", $chapeau_id); $info['bul_titre'] = addslashes($info_200_a[0]); $info['bul_no'] = addslashes($info_200_e[0]); $info['bul_date'] = addslashes($info_200_e[1]); $info['date_date'] = gen_date($info_200_e[1], $info_210_d[0]); $bulletin->bull_num_notice = $notice_id; $bulletin_id = $bulletin->update($info, true); } break; default: break; } } // $info_462_3,$info_462_t : Dépouillement, article for ($_3 = 0; $_3 < sizeof($info_462_3); $_3++) { switch ($type_opsys) { case 'UMO:1': case 'UMO:2': case 'UMO:8': $requete = "select notices_custom_origine from notices_custom_values where notices_custom_small_text='" . $info_462_3[$_3] . "'"; //print "$requete <br />"; $resultat = pmb_mysql_query($requete); //Notice chapeau existe-t-elle ? if (@pmb_mysql_num_rows($resultat)) { //Si oui, récupération id $chapeau_id = pmb_mysql_result($resultat, 0, 0); } else { $niveau_biblio = 'm'; $niveau_hierar = '0'; // Création de la notice temporaire chapeau $requete = "insert into notices set typdoc='{$r->typdoc}', tit1 ='" . addslashes($info_462_t[$a]) . "' , niveau_biblio='{$niveau_biblio}',niveau_hierar='{$niveau_hierar}' "; //print "$requete <br />"; pmb_mysql_query($requete); $chapeau_id = pmb_mysql_insert_id(); $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_small_text) values({$id_notices_custom_opsys},{$chapeau_id},'" . addslashes($info_462_3[$_3]) . "')"; //print "$requete <br />"; pmb_mysql_query($requete); } if ($chapeau_id) { //link notice $requete = "insert into notices_relations set num_notice='{$notice_id}', linked_notice ='{$chapeau_id}', relation_type='a' "; //print "$requete <br />"; pmb_mysql_query($requete); } break; case 'UMO:13': // bulletin de périodique => création des articles $requete = "select notices_custom_origine from notices_custom_values where notices_custom_small_text='" . $info_462_3[$_3] . "'"; //print "$requete <br />"; $resultat = pmb_mysql_query($requete); //Notice article existe-t-elle ? if (@pmb_mysql_num_rows($resultat)) { //Si oui, récupération id $article_id = pmb_mysql_result($resultat, 0, 0); } else { $niveau_biblio = 'a'; $niveau_hierar = '2'; // Création de la notice temporaire de l'article $requete = "insert into notices set typdoc='{$r->typdoc}', tit1 ='" . addslashes($info_462_t[$a]) . "' , niveau_biblio='{$niveau_biblio}',niveau_hierar='{$niveau_hierar}' "; //print "$requete <br />"; pmb_mysql_query($requete); $article_id = pmb_mysql_insert_id(); $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_small_text) values({$id_notices_custom_opsys},{$article_id},'" . addslashes($info_462_3[$_3]) . "')"; //print "$requete <br />"; pmb_mysql_query($requete); } if ($article_id) { //lien article de bulletin créé dans table analitique $requete = "insert into analysis set analysis_bulletin='{$bulletin_id}', analysis_notice ='{$article_id}' "; //print "$requete <br />"; pmb_mysql_query($requete); } break; default: break; } } }
function update($value, $dont_update_bul = false, $other_fields = "") { global $dbh, $pmb_newrecord_timeshift; // clean des vieilles nouveautés if ($pmb_newrecord_timeshift) { $req_old = "UPDATE notices SET notice_date_is_new ='', notice_is_new=0, update_date=update_date where notice_date_is_new !='0000-00-00 00:00:00' and (notice_date_is_new < now() - interval {$pmb_newrecord_timeshift} day )"; mysql_query($req_old, $dbh); } if (is_array($value)) { $this->bulletin_titre = $value['bul_titre']; $this->bulletin_numero = $value['bul_no']; $this->bulletin_cb = $value['bul_cb']; $this->mention_date = $value['bul_date']; // Note YPR : à revoir if ($value['date_date']) { $this->date_date = $value['date_date']; } else { $this->date_date = today(); } // construction de la requete : $data = "bulletin_titre='" . $this->bulletin_titre . "'"; $data .= ",bulletin_numero='" . $this->bulletin_numero . "'"; $data .= ",bulletin_cb='" . $this->bulletin_cb . "'"; $data .= ",mention_date='" . $this->mention_date . "'"; $data .= ",date_date='" . $this->date_date . "'"; $data .= ",index_titre=' " . strip_empty_words($this->bulletin_titre) . " '"; if (!$this->bulletin_id) { // si c'est une creation, on ajoute l'id du parent la date et on cree la notice ! $data .= ",bulletin_notice='" . $this->bulletin_notice . "'"; // fabrication de la requete finale $requete = "INSERT INTO bulletins SET {$data}"; $myQuery = pmb_mysql_query($requete, $dbh); $insert_last_id = pmb_mysql_insert_id($dbh); audit::insert_creation(AUDIT_BULLETIN, $insert_last_id); $this->bulletin_id = $insert_last_id; } else { $requete = "UPDATE bulletins SET {$data} WHERE bulletin_id='" . $this->bulletin_id . "' LIMIT 1"; $myQuery = pmb_mysql_query($requete, $dbh); audit::insert_modif(AUDIT_BULLETIN, $this->bulletin_id); $requete = "UPDATE notices SET date_parution='" . $value['date_parution'] . "', year='" . $value['year'] . "' WHERE notice_id in (SELECT analysis_notice FROM analysis WHERE analysis_bulletin={$this->bulletin_id})"; pmb_mysql_query($requete, $dbh); } } else { return; } global $include_path; if (!$dont_update_bul) { // formatage des valeurs de $value // $value est un tableau contenant les infos du périodique if (!$value['tit1']) { $this->bull_num_notice = 0; //return; } //Nettoyage des infos bulletin unset($value['bul_titre']); unset($value['bul_no']); unset($value['bul_cb']); unset($value['bul_date']); unset($value['date_date']); if ($value['index_l']) { $value['index_l'] = clean_tags($value['index_l']); } if (is_array($value['aut']) && $value['aut'][0]['id']) { $value['aut'] = 'aut_exist'; } else { $value['aut'] = ''; } if (is_array($value['categ']) && $value['categ'][0]['id']) { $value['categ'] = 'categ_exist'; } else { $value['categ'] = ''; } if ($value["concept"]) { $value["concept"] = 'concept_exist'; } else { $value["concept"] = ''; } /* * On a un lien? */ if (is_array($value['rel']) && $value['rel'][0]['id_notice']) { $value['rel'] = 'rel_exist'; } else { $value['rel'] = ''; } //type de document //$value['typdoc']=$value['typdoc']; $empty = ""; if ($value['force_empty']) { $empty = "perso"; } unset($value['force_empty']); $values = ''; while (list($cle, $valeur) = each($value)) { if ($cle != "statut" && $cle != "tit1" && $cle != "niveau_hierar" && $cle != "niveau_biblio" && $cle != "index_sew" && $cle != "index_wew" && $cle != "typdoc" && $cle != "date_parution" && $cle != "year" && $cle != "indexation_lang") { if ($cle == "indexint" && $valeur || $cle != "indexint") { $empty .= $valeur; } } if ($cle == 'aut' || $cle == 'categ' || $cle == 'rel' || $cle == 'concept') { $values .= ''; } else { $values ? $values .= ",{$cle}='{$valeur}'" : ($values .= "{$cle}='{$valeur}'"); } } if ($this->bull_num_notice) { if ($empty) { // modif pmb_mysql_query("UPDATE notices SET {$values} , update_date=sysdate() {$other_fields} WHERE notice_id=" . $this->bull_num_notice, $dbh); // Mise à jour des index de la notice notice::majNoticesTotal($this->bull_num_notice); audit::insert_modif(AUDIT_NOTICE, $this->bull_num_notice); } else { notice::del_notice($this->bull_num_notice); $this->bull_num_notice = ""; pmb_mysql_query("update bulletins set num_notice=0 where bulletin_id=" . $this->bulletin_id); } return $this->bulletin_id; } else { // create if ($empty) { pmb_mysql_query("INSERT INTO notices SET {$values} , create_date=sysdate(), update_date=sysdate() {$other_fields} ", $dbh); $this->bull_num_notice = pmb_mysql_insert_id($dbh); // Mise à jour des index de la notice notice::majNoticesTotal($this->bull_num_notice); audit::insert_creation(AUDIT_NOTICE, $this->bull_num_notice); //Mise à jour du bulletin $requete = "update bulletins set num_notice=" . $this->bull_num_notice . " where bulletin_id=" . $this->bulletin_id; pmb_mysql_query($requete); //Mise à jour des liens bulletin -> notice mère $requete = "insert into notices_relations (num_notice,linked_notice,relation_type,rank) values(" . $this->bull_num_notice . "," . $this->serial_id . ",'b',1)"; pmb_mysql_query($requete); } return $this->bulletin_id; } } else { /* * Quand passe-t'on ici ? */ if ($this->bull_num_notice) { //Mise à jour du bulletin $requete = "update bulletins,notices set num_notice=" . $this->bull_num_notice . ",bulletin_titre=tit1 where bulletin_id=" . $this->bulletin_id . " and notice_id=" . $this->bull_num_notice; pmb_mysql_query($requete); //Mise à jour des liens bulletin -> notice mere $requete = "insert into notices_relations (num_notice,linked_notice,relation_type,rank) values(" . $this->bull_num_notice . "," . $this->serial_id . ",'b',1)"; pmb_mysql_query($requete); //Recherche des articles $requete = "select analysis_notice from analysis where analysis_bulletin=" . $this->bulletin_id; $resultat_analysis = pmb_mysql_query($requete); $n = 1; while ($r_a = pmb_mysql_fetch_object($resultat_analysis)) { $requete = "insert into notices_relations (num_notice,linked_notice,relation_type,rank) values(" . $r_a->analysis_notice . "," . $this->bull_num_notice . ",'a',{$n})"; pmb_mysql_query($requete); $n++; } } return $this->bulletin_id; } }
function cleanString($string) { $string = str_replace("%", "", $string); $string = convert_diacrit($string); $string = strip_empty_words($string); return $string; }
function rec_record($record, $source_id, $search_id) { global $charset, $base_path; //On a un enregistrement unimarc, on l'enregistre $rec_uni_dom = new xml_dom_sru($record, $charset, false); if (!$rec_uni_dom->error) { //Initialisation $ref = ""; $ufield = ""; $usubfield = ""; $field_order = 0; $subfield_order = 0; $value = ""; $date_import = date("Y-m-d H:i:s", time()); $fs = $rec_uni_dom->get_nodes("unimarc/notice/f"); //Recherche du 001 if ($fs) { for ($i = 0; $i < count($fs); $i++) { if ($fs[$i]["ATTRIBS"]["c"] == "001") { $ref = $rec_uni_dom->get_datas($fs[$i]); break; } } } if (!$ref) { $ref = md5($record); } //Mise � jour if ($ref) { //Si conservation des anciennes notices, on regarde si elle existe if (!$this->del_old) { $requete = "select count(*) from entrepot_source_" . $source_id . " where ref='" . addslashes($ref) . "'"; $rref = mysql_query($requete); if ($rref) { $ref_exists = mysql_result($rref, 0, 0); } } //Si pas de conservation des anciennes notices, on supprime if ($this->del_old) { // $requete="delete from entrepot_source_".$source_id." where ref='".addslashes($ref)."'"; // mysql_query($requete); } $ref_exists = false; //Si pas de conservation ou ref�rence inexistante if ($this->del_old || !$this->del_old && !$ref_exists) { //Insertion de l'ent�te $n_header["rs"] = $rec_uni_dom->get_value("unimarc/notice/rs"); $n_header["ru"] = $rec_uni_dom->get_value("unimarc/notice/ru"); $n_header["el"] = $rec_uni_dom->get_value("unimarc/notice/el"); $n_header["bl"] = $rec_uni_dom->get_value("unimarc/notice/bl"); $n_header["hl"] = $rec_uni_dom->get_value("unimarc/notice/hl"); $n_header["dt"] = $rec_uni_dom->get_value("unimarc/notice/dt"); //R�cup�ration d'un ID $requete = "insert into external_count (recid, source_id) values('" . addslashes($this->get_id() . " " . $source_id . " " . $ref) . "', " . $source_id . ")"; $rid = mysql_query($requete); if ($rid) { $recid = mysql_insert_id(); } foreach ($n_header as $hc => $code) { $requete = "insert into entrepot_source_" . $source_id . " (connector_id,source_id,ref,date_import,ufield,usubfield,field_order,subfield_order,value,i_value,recid, search_id) values(\n\t\t\t\t\t\t'" . addslashes($this->get_id()) . "'," . $source_id . ",'" . addslashes($ref) . "','" . addslashes($date_import) . "',\n\t\t\t\t\t\t'" . $hc . "','',-1,0,'" . addslashes($code) . "','',{$recid}, '{$search_id}')"; mysql_query($requete); } if ($fs) { for ($i = 0; $i < count($fs); $i++) { $ufield = $fs[$i]["ATTRIBS"]["c"]; $field_order = $i; $ss = $rec_uni_dom->get_nodes("s", $fs[$i]); if (is_array($ss)) { for ($j = 0; $j < count($ss); $j++) { $usubfield = $ss[$j]["ATTRIBS"]["c"]; $value = $rec_uni_dom->get_datas($ss[$j]); $subfield_order = $j; $requete = "insert into entrepot_source_" . $source_id . " (connector_id,source_id,ref,date_import,ufield,usubfield,field_order,subfield_order,value,i_value,recid, search_id) values(\n\t\t\t\t\t\t\t\t'" . addslashes($this->get_id()) . "'," . $source_id . ",'" . addslashes($ref) . "','" . addslashes($date_import) . "',\n\t\t\t\t\t\t\t\t'" . addslashes($ufield) . "','" . addslashes($usubfield) . "'," . $field_order . "," . $subfield_order . ",'" . addslashes($value) . "',\n\t\t\t\t\t\t\t\t' " . addslashes(strip_empty_words($value)) . " ',{$recid}, '{$search_id}')"; mysql_query($requete); } } else { $value = $rec_uni_dom->get_datas($fs[$i]); $requete = "insert into entrepot_source_" . $source_id . " (connector_id,source_id,ref,date_import,ufield,usubfield,field_order,subfield_order,value,i_value,recid, search_id) values(\n\t\t\t\t\t\t\t'" . addslashes($this->get_id()) . "'," . $source_id . ",'" . addslashes($ref) . "','" . addslashes($date_import) . "',\n\t\t\t\t\t\t\t'" . addslashes($ufield) . "','" . addslashes($usubfield) . "'," . $field_order . "," . $subfield_order . ",'" . addslashes($value) . "',\n\t\t\t\t\t\t\t' " . addslashes(strip_empty_words($value)) . " ',{$recid}, '{$search_id}')"; mysql_query($requete); } } } } $this->n_recu++; } } }
function import_new_notice_suite() { global $dbh; global $notice_id; global $info_606_a, $info_606_j, $info_606_x, $info_606_y, $info_606_z; global $id_rech_theme; global $thesaurus_defaut; global $thes; /* echo "<pre>"; print_r ($info_949); print_r ($info_997); echo "</pre>"; */ // les champs $606 sont stockés dans les catégories // $a >> en sous catégories de $id_rech_theme // $j en complément de $a // $x en sous catégories de $a // $y >> en sous catégories de $id_rech_geo // $z >> en sous catégories de $id_rech_chrono // TRAITEMENT : // pour $a=0 à size_of $info_606_a // pour $j=0 à size_of $info_606_j[$a] // concaténer $libelle_j .= $info_606_j[$a][$j] // $libelle_final = $info_606_a[0]." ** ".$libelle_j // Rechercher si l'enregistrement existe déjà dans categories = // $categid = categories::searchLibelle(addslashes($libelle_final), $thesaurus_defaut, 'fr_FR', $id_rech_theme) // Créer si besoin et récupérer l'id $categid_a // $categid_parent = $categid_a // pour $x=0 à size_of $info_606_x[$a] // Rechercher si l'enregistrement existe déjà dans categories = // $categid = categories::searchLibelle(addslashes($info_606_x[$a][$x]), $thesaurus_defaut, 'fr_FR', $categ_parent) // Créer si besoin et récupérer l'id $categid_parent // // $categid_parent = $id_rech_geo // pour $y=0 à size_of $info_606_y[$a] // Rechercher si l'enregistrement existe déjà dans categories = // $categid = categories::searchLibelle(addslashes($info_606_y[$a][$y]), $thesaurus_defaut, 'fr_FR', $categ_parent) // Créer si besoin et récupérer l'id $categid_parent // // $categid_parent = $id_rech_chrono // pour $y=0 à size_of $info_606_z[$a] // Rechercher si l'enregistrement existe déjà dans categories = // $categid = categories::searchLibelle(addslashes($info_606_z[$a][$y]]), $thesaurus_defaut, 'fr_FR', $categ_parent) // Créer si besoin et récupérer l'id $categid_parent // $libelle_j = ""; for ($a = 0; $a < sizeof($info_606_a); $a++) { for ($j = 0; $j < sizeof($info_606_j[$a]); $j++) { if (!$libelle_j) { $libelle_j .= trim($info_606_j[$a][$j]); } else { $libelle_j .= " ** " . trim($info_606_j[$a][$j]); } } if (!$libelle_j) { $libelle_final = trim($info_606_a[$a][0]); } else { $libelle_final = trim($info_606_a[$a][0]) . " ** " . $libelle_j; } if (!$libelle_final) { break; } $res_a = categories::searchLibelle(addslashes($libelle_final), $thesaurus_defaut, 'fr_FR', $id_rech_theme); if ($res_a) { $categid_a = $res_a; } else { $categid_a = create_categ($id_rech_theme, $libelle_final, strip_empty_words($libelle_final, 'fr_FR')); } // récup des sous-categ en cascade sous $a $categ_parent = $categid_a; for ($x = 0; $x < sizeof($info_606_x[$a]); $x++) { $res_x = categories::searchLibelle(addslashes(trim($info_606_x[$a][$x])), $thesaurus_defaut, 'fr_FR', $categ_parent); if ($res_x) { $categ_parent = $res_x; } else { $categ_parent = create_categ($categ_parent, trim($info_606_x[$a][$x]), strip_empty_words($info_606_x[$a][$x], 'fr_FR')); } } // fin récup des $x en cascade sous l'id de la catégorie 606$a if ($categ_parent != $id_rech_theme) { // insertion dans la table notices_categories $rqt_ajout = "insert into notices_categories set notcateg_notice='" . $notice_id . "', num_noeud='" . $categ_parent . "' "; $res_ajout = @mysql_query($rqt_ajout, $dbh); } // récup TOUT EN CASCADE $id_rech_geo = $categ_parent; // récup des categ géo à loger sous la categ géo principale $categ_parent = $id_rech_geo; for ($y = 0; $y < sizeof($info_606_y[$a]); $y++) { $res_y = categories::searchLibelle(addslashes(trim($info_606_y[$a][$y])), $thesaurus_defaut, 'fr_FR', $categ_parent); if ($res_y) { $categ_parent = $res_y; } else { $categ_parent = create_categ($categ_parent, trim($info_606_y[$a][$y]), strip_empty_words($info_606_y[$a][$y], 'fr_FR')); } } // fin récup des $y en cascade sous l'id de la catégorie principale thème géo if ($categ_parent != $id_rech_geo) { // insertion dans la table notices_categories $rqt_ajout = "insert into notices_categories set notcateg_notice='" . $notice_id . "', num_noeud='" . $categ_parent . "' "; $res_ajout = @mysql_query($rqt_ajout, $dbh); } // récup TOUT EN CASCADE $id_rech_chrono = $categ_parent; // récup des categ chrono à loger sous la categ chrono principale $categ_parent = $id_rech_chrono; for ($z = 0; $z < sizeof($info_606_z[$a]); $z++) { $res_z = categories::searchLibelle(addslashes(trim($info_606_z[$a][$z])), $thesaurus_defaut, 'fr_FR', $categ_parent); if ($res_z) { $categ_parent = $res_z; } else { $categ_parent = create_categ($categ_parent, trim($info_606_z[$a][$z]), strip_empty_words($info_606_z[$a][$z], 'fr_FR')); } } // fin récup des $z en cascade sous l'id de la catégorie principale thème chrono if ($categ_parent != $id_rech_chrono) { // insertion dans la table notices_categories $rqt_ajout = "insert into notices_categories set notcateg_notice='" . $notice_id . "', num_noeud='" . $categ_parent . "' "; $res_ajout = @mysql_query($rqt_ajout, $dbh); } } }
static function import($data) { // cette méthode prend en entrée un tableau constitué des informations éditeurs suivantes : // $data['name'] Nom de la collection // $data['parent'] id de l'éditeur parent de la collection // $data['issn'] numéro ISSN de la collection global $dbh; // check sur le type de la variable passée en paramètre if (!sizeof($data) || !is_array($data)) { // si ce n'est pas un tableau ou un tableau vide, on retourne 0 return 0; } // check sur les éléments du tableau (data['name'] est requis). $long_maxi_name = pmb_mysql_field_len(pmb_mysql_query("SELECT collection_name FROM collections limit 1"), 0); $data['name'] = rtrim(substr(preg_replace('/\\[|\\]/', '', rtrim(ltrim($data['name']))), 0, $long_maxi_name)); //si on a pas d'id, on peut avoir les infos de l'éditeur if (!$data['parent']) { if ($data['publisher']) { //on les a, on crée l'éditeur $data['parent'] = editeur::import($data['publisher']); } } if ($data['name'] == "" || $data['parent'] == 0) { /* il nous faut impérativement un éditeur */ return 0; } // préparation de la requête $key0 = addslashes($data['name']); $key1 = $data['parent']; $key2 = addslashes($data['issn']); /* vérification que l'éditeur existe bien ! */ $query = "SELECT ed_id FROM publishers WHERE ed_id='{$key1}' LIMIT 1 "; $result = @pmb_mysql_query($query, $dbh); if (!$result) { die("can't SELECT publishers " . $query); } if (pmb_mysql_num_rows($result) == 0) { return 0; } /* vérification que la collection existe */ $query = "SELECT collection_id FROM collections WHERE collection_name='{$key0}' AND collection_parent='{$key1}' LIMIT 1 "; $result = @pmb_mysql_query($query, $dbh); if (!$result) { die("can't SELECT collections " . $query); } $collection = pmb_mysql_fetch_object($result); /* la collection existe, on retourne l'ID */ if ($collection->collection_id) { return $collection->collection_id; } // id non-récupérée, il faut créer la forme. $query = 'INSERT INTO collections SET collection_name="' . $key0 . '", '; $query .= 'collection_parent="' . $key1 . '", '; $query .= 'collection_issn="' . $key2 . '", '; $query .= 'index_coll=" ' . strip_empty_words($key0) . ' ' . strip_empty_words($key2) . ' ", '; $query .= 'collection_comment = "' . addslashes($data['comment']) . '" '; $result = @pmb_mysql_query($query, $dbh); if (!$result) { die("can't INSERT into database"); } $id = pmb_mysql_insert_id($dbh); if ($data['subcollections']) { for ($i = 0; $i < count($data['subcollections']); $i++) { $subcoll = $data['subcollections'][$i]; $subcoll['coll_parent'] = $id; subcollection::import($subcoll); } } audit::insert_creation(AUDIT_COLLECTION, $id); //update authority informations $authority = new authority(0, $id, AUT_TABLE_COLLECTIONS); $authority->set_num_statut($data['statut']); $authority->update(); collection::update_index($id); return $id; }
function add_categ($term, $id_thesaurus, $non_classes, $lang) { $n = new noeuds(); $n->num_thesaurus = $id_thesaurus; $n->num_parent = $non_classes; $n->save(); $c = new categories($n->id_noeud, $lang); $c->libelle_categorie = $term; $c->index_categorie = ' ' . strip_empty_words($term) . ' '; $c->save(); return $n->id_noeud; }
function import($name, $comment = "", $id_pclassement = "") { global $dbh; global $pmb_limitation_dewey; global $thesaurus_classement_defaut; // check sur la variable passée en paramètre if (!$name) { return 0; } if ($pmb_limitation_dewey < 0) { return 0; } if ($pmb_limitation_dewey) { $name = substr($name, 0, $pmb_limitation_dewey); } // tentative de récupérer l'id associée dans la base (implique que l'autorité existe) // préparation de la requête $key = addslashes($name); $comment = addslashes($comment); if (!$id_pclassement) { $num_pclass = $thesaurus_classement_defaut; } else { $num_pclass = $id_pclassement; } //On regarde si le plan de classement existe $query = "SELECT name_pclass FROM pclassement WHERE id_pclass='" . addslashes($num_pclass) . "' LIMIT 1 "; $result = @pmb_mysql_query($query, $dbh); if (!$result) { die("can't SELECT pclassement " . $query); } if (!pmb_mysql_num_rows($result)) { //Le plan de classement demandé n'existe pas return 0; // -> pas d'import } $query = "SELECT indexint_id FROM indexint WHERE indexint_name='" . rtrim(substr($key, 0, 255)) . "' and num_pclass='{$num_pclass}' LIMIT 1 "; $result = @pmb_mysql_query($query, $dbh); if (!$result) { die("can't SELECT indexint " . $query); } // résultat // récupération du résultat de la recherche $tindexint = pmb_mysql_fetch_object($result); // du résultat et récupération éventuelle de l'id if ($tindexint->indexint_id) { return $tindexint->indexint_id; } // id non-récupérée >> création if (!$id_pclassement) { $num_pclass = $thesaurus_classement_defaut; } else { $num_pclass = $id_pclassement; } $query = "INSERT INTO indexint SET indexint_name='{$key}', indexint_comment='{$comment}', index_indexint=' " . strip_empty_words($key . " " . $comment) . " ', num_pclass={$num_pclass} "; $result = @pmb_mysql_query($query, $dbh); if (!$result) { die("can't INSERT into indexint " . $query); } $id = pmb_mysql_insert_id($dbh); audit::insert_creation(AUDIT_INDEXINT, $id); return $id; }
/** * Somme du nombre de mots non vides dans le document entre chaque mot non vide * constituant le terme * * entre chaque mot non vide du terme * * Elle est pourrie mais claire... (m1(\w)*m2(\w)*m3) * * @param char $full_clean_text * @param char $lang * * @return void * * @access public */ public function calc_term_document_distance($full_clean_text = '', $lang = 'fr_FR') { global $autoindex_distance_ratio, $autoindex_distance_type; if (!$this->id || $full_clean_text === '') { return; } $clean_label = strip_empty_words($this->label, $lang); switch ($autoindex_distance_type) { case '1': default: // Distance tenant compte du nombre de mots non vides entre les mots du terme dans le texte //$expr = str_replace(' ', "(\/w)", "/(\/w)".$clean_label."/"); >> ne marche pas si les mots sont accollés !! $expr = str_replace(' ', "(\\s+.*?)", "/" . $clean_label . "\\s+.*?" . "/"); $dmax = str_word_count($full_clean_text, 0, "0123456789"); $this->document_distance = $dmax; $dterm = $dmax; if (preg_match_all($expr, ' ' . $full_clean_text . ' ', $matches, PREG_SET_ORDER)) { for ($i = 1; $i < count($matches); $i++) { $d = 0; for ($j = 1; $j < count($matches[$i]); $j++) { if ($matches[$i][$j]) { $d += str_word_count($matches[$i][$j], 0, "0123456789"); } } if ($d < $dterm) { $dterm = $d; } } $this->document_distance = $dterm; $this->total_relevancy = $this->total_relevancy * (1 + ($dmax - $dterm) * $autoindex_distance_ratio / $dmax); } break; case '2': // Distance tenant compte du nombre de caractères entre les mots du terme dans le texte $dmax = strlen($full_clean_text); $this->document_distance = $dmax; $dterm = 0; $expr = str_replace(' ', "(.*?)", "/(.*?)" . $clean_label . "/"); if (preg_match($expr, $full_clean_text, $matches)) { for ($i = 1; $i < count($matches) - 1; $i++) { $dterm += strlen($matches[$i]); } $this->document_distance = $dterm; $this->total_relevancy = $this->total_relevancy * (1 + ($dmax - $dterm) * $autoindex_distance_ratio / $dmax); } break; case '3': // distance tenant compte de la position des mots du terme dans le texte $dmax = strlen($full_clean_text); $this->document_distance = $dmax; $dterm = 0; $t_label = explode(' ', $clean_label); foreach ($t_label as $k => $l) { $dl = stripos($full_clean_text, $l); if ($dl !== false) { $dterm += $dl; } else { $dterm += $dmax; } } //$dl = $dl / (count($t_label)); $this->document_distance = $dterm; $this->total_relevancy = $this->total_relevancy * (1 + ($dmax - $dterm) * $autoindex_distance_ratio / $dmax); break; case '4': // Distance tenant compte de l'ordre et de la position des mots du terme dans le texte $dmax = strlen($full_clean_text); $this->document_distance = $dmax; $dterm = 0; $t_label = explode(' ', $clean_label); $old_dl = 0; foreach ($t_label as $k => $l) { $dl = stripos(' ' . $full_clean_text . ' ', ' ' . $l . ' '); if ($dl !== false && $dl >= $old_dl) { $dterm += $dl - $old_dl; $old_dl = $dl; } else { $dterm += $dmax; } } $this->document_distance = $dterm; $this->total_relevancy = $this->total_relevancy * (1 + ($dmax - $dterm) * $autoindex_distance_ratio / $dmax); break; } }