function get_array($start = '', $pos_cursor = 0) { global $dbh; global $pmb_keyword_sep; $liste_mots = array(); $liste_res = array(); $tags = array(); $liste_finale = array(); $deb_chaine = ''; $fin_chaine = ''; if (strlen($start) == $pos_cursor) { $liste_mots = explode($pmb_keyword_sep, $start); $mot = array_pop($liste_mots); $deb_chaine = implode($pmb_keyword_sep, $liste_mots); if (trim($deb_chaine) !== '') { $deb_chaine .= $pmb_keyword_sep; } } else { $liste_mots = explode($pmb_keyword_sep, substr($start, 0, $pos_cursor)); $mot = array_pop($liste_mots); $deb_chaine = implode($pmb_keyword_sep, $liste_mots); if (trim($deb_chaine) !== '') { $deb_chaine .= $pmb_keyword_sep; } $liste_mots = explode($pmb_keyword_sep, substr($start, $pos_cursor)); array_shift($liste_mots); $fin_chaine = $pmb_keyword_sep . implode($pmb_keyword_sep, $liste_mots); } $mot = trim($mot); if ($mot === '') { return $liste_finale; } $this->search_tag = $mot; $requete = "select distinct index_l from notices where index_l is not null and index_l like '" . addslashes($mot) . "%' or index_l like '%" . $pmb_keyword_sep . addslashes($mot) . "%' "; $res = mysql_query($requete, $dbh); while ($mot_trouve = mysql_fetch_object($res)) { $liste_tmp = explode($pmb_keyword_sep, $mot_trouve->index_l); foreach ($liste_tmp as $v) { if (strip_empty_chars(substr($v, 0, strlen($mot))) == strip_empty_chars($mot)) { $liste_res[] = $v; } } } $liste_res = array_unique($liste_res); asort($liste_res); foreach ($liste_res as $v) { $liste_finale[] = array($v => $deb_chaine . $v . $fin_chaine); } return $liste_finale; }
public function maj_indexation($datatype = 'all') { global $include_path; global $dbh, $champ_base; //recuperation du fichier xml de configuration if (!count($champ_base)) { $file = $include_path . "/indexation/editorial_content/" . $this->type . "_subst.xml"; if (!file_exists($file)) { $file = $include_path . "/indexation/editorial_content/" . $this->type . ".xml"; } $fp = fopen($file, "r"); if ($fp) { $xml = fread($fp, filesize($file)); } fclose($fp); $champ_base = _parser_text_no_function_($xml, "INDEXATION"); } $tableau = $champ_base; //analyse des donnees des tables $temp_not = array(); $temp_not['t'][0][0] = $tableau['REFERENCE'][0][value]; $temp_ext = array(); $temp_marc = array(); $champ_trouve = false; $tab_code_champ = array(); $tab_languages = array(); $tab_keep_empty = array(); $tab_pp = array(); for ($i = 0; $i < count($tableau['FIELD']); $i++) { //pour chacun des champs decrits //recuperation de la liste des informations a mettre a jour if ($datatype == 'all' || $datatype == $tableau['FIELD'][$i]['DATATYPE']) { //conservation des mots vides if ($tableau['FIELD'][$i]['KEEPEMPTYWORD'] == "yes") { $tab_keep_empty[] = $tableau['FIELD'][$i]['ID']; } //champ perso if ($tableau['FIELD'][$i]['DATATYPE'] == "custom_field") { $tab_pp[$tableau['FIELD'][$i]['ID']] = $tableau['FIELD'][$i]['TABLE'][0]['value']; } else { if ($tableau['FIELD'][$i]['EXTERNAL'] == "yes") { //champ externe à la table notice //Stockage de la structure pour un accès plus facile $temp_ext[$tableau['FIELD'][$i]['ID']] = $tableau['FIELD'][$i]; } else { //champ de la table notice $temp_not['f'][0][$tableau['FIELD'][$i]['ID']] = $tableau['FIELD'][$i]['TABLE'][0]['TABLEFIELD'][0]['value']; $tab_code_champ[0][$tableau['FIELD'][$i]['TABLE'][0]['TABLEFIELD'][0]['value']] = array('champ' => $tableau['FIELD'][$i]['ID'], 'ss_champ' => 0, 'pond' => $tableau['FIELD'][$i]['POND'], 'no_words' => $tableau['FIELD'][$i]['DATATYPE'] == "marclist" ? true : false); if ($tableau['FIELD'][$i]['TABLE'][0]['TABLEFIELD'][0]['MARCTYPE']) { $tab_code_champ[0][$tableau['FIELD'][$i]['TABLE'][0]['TABLEFIELD'][0]['value']]['marctype'] = $tableau['FIELD'][$i]['TABLE'][0]['TABLEFIELD'][0]['MARCTYPE']; } } } $champ_trouve = true; } } if ($champ_trouve) { $tab_req = array(); //Recherche des champs directs if ($datatype == 'all') { $tab_req[0]["rqt"] = "select " . implode(',', $temp_not['f'][0]) . " from " . $temp_not['t'][0][0]; $tab_req[0]["rqt"] .= " where " . $tableau['REFERENCEKEY'][0][value] . "='" . $this->id . "'"; $tab_req[0]["table"] = $temp_not['t'][0][0]; } foreach ($temp_ext as $k => $v) { //Construction de la requete //Champs pour le select $select = array(); //on harmonise les fichiers XML décrivant des requetes... for ($i = 0; $i < count($v["TABLE"]); $i++) { $table = $v['TABLE'][$i]; $select = array(); for ($j = 0; $j < count($table['TABLEFIELD']); $j++) { $select[] = ($table['ALIAS'] ? $table['ALIAS'] . "." : "") . $table['TABLEFIELD'][$j]["value"]; if ($table['LANGUAGE']) { $select[] = $table['LANGUAGE'][0]['value']; $tab_languages[$k] = $table['LANGUAGE'][0]['value']; } $field_name = $table['TABLEFIELD'][$j]["value"]; if (strpos($table['TABLEFIELD'][$j]["value"], ".") !== false) { $field_name = substr($table['TABLEFIELD'][$j]["value"], strpos($table['TABLEFIELD'][$j]["value"], ".") + 1); } $tab_code_champ[$v['ID']][$field_name] = array('champ' => $v['ID'], 'ss_champ' => $table['TABLEFIELD'][$j]["ID"], 'pond' => $table['TABLEFIELD'][$j]['POND'], 'no_words' => $tableau['FIELD'][$i]['DATATYPE'] == "marclist" ? true : false); if ($v['TABLEFIELD'][$j]['marclist']) { $tab_code_champ[$v['ID']][$v['TABLEFIELD'][$j]["value"]]['marctype'] = $v['TABLEFIELD'][$j]['marctype']; } } $query = "select " . implode(",", $select) . " from " . $tableau['REFERENCE'][0]['value']; $jointure = ""; for ($j = 0; $j < count($table['LINK']); $j++) { $link = $table['LINK'][$j]; if ($link["TABLE"][0]['ALIAS']) { $alias = $link["TABLE"][0]['ALIAS']; } else { $alias = $link["TABLE"][0]['value']; } switch ($link["TYPE"]) { case "n1": if ($link["TABLEKEY"][0]['value']) { $jointure .= " JOIN " . $link["TABLE"][0]['value'] . ($link["TABLE"][0]['value'] != $alias ? " AS " . $alias : ""); if ($link["EXTERNALTABLE"][0]['value']) { $jointure .= " ON " . $link["EXTERNALTABLE"][0]['value'] . "." . $link["EXTERNALFIELD"][0]['value']; } else { $jointure .= " ON " . ($table['ALIAS'] ? $table['ALIAS'] : $table['NAME']) . "." . $link["EXTERNALFIELD"][0]['value']; } $jointure .= "=" . $alias . "." . $link["TABLEKEY"][0]['value']; } else { $jointure .= " JOIN " . $table['NAME'] . ($table['ALIAS'] ? " as " . $table['ALIAS'] : ""); $jointure .= " ON " . $tableau['REFERENCE'][0]['value'] . "." . $tableau['REFERENCEKEY'][0]['value']; $jointure .= "=" . ($table['ALIAS'] ? $table['ALIAS'] : $table['NAME']) . "." . $link["EXTERNALFIELD"][0]['value']; } break; case "1n": $jointure .= " JOIN " . $table['NAME'] . ($table['ALIAS'] ? " as " . $table['ALIAS'] : ""); $jointure .= " ON (" . ($table['ALIAS'] ? $table['ALIAS'] : $table['NAME']) . "." . $table["TABLEKEY"][0]['value']; $jointure .= "=" . $tableau['REFERENCE'][0]['value'] . "." . $link["REFERENCEFIELD"][0]['value'] . ") "; break; case "nn": $jointure .= " JOIN " . $link["TABLE"][0]['value'] . ($link["TABLE"][0]['value'] != $alias ? " AS " . $alias : ""); $jointure .= " ON (" . $tableau['REFERENCE'][0]['value'] . "." . $tableau['REFERENCEKEY'][0]['value']; $jointure .= "=" . $alias . "." . $link["REFERENCEFIELD"][0]['value'] . ") "; if ($link["TABLEKEY"][0]['value']) { $jointure .= " JOIN " . $table['NAME'] . ($table['ALIAS'] ? " as " . $table['ALIAS'] : ""); $jointure .= " ON (" . $alias . "." . $link["TABLEKEY"][0]['value']; $jointure .= "=" . ($table['ALIAS'] ? $table['ALIAS'] : $table['NAME']) . "." . $link["EXTERNALFIELD"][0]['value'] . " " . $link["LINKRESTRICT"][0]['value'] . ") "; } else { $jointure .= " JOIN " . $table['NAME'] . ($table['ALIAS'] ? " as " . $table['ALIAS'] : ""); $jointure .= " ON (" . $alias . "." . $link["EXTERNALFIELD"][0]['value']; $jointure .= "=" . ($table['ALIAS'] ? $table['ALIAS'] : $table['NAME']) . "." . $table["TABLEKEY"][0]['value'] . " " . $link["LINKRESTRICT"][0]['value'] . ") "; } break; } } if ($table['LANGUAGE']) { $tab_req_lang[$k] = "select " . $table['LANGUAGE'][0]['value'] . " from "; } $query .= $jointure . " where " . $temp_not['t'][0][0] . "." . $tableau['REFERENCEKEY'][0][value] . "=" . $this->id; if ($table['LANGUAGE']) { $tab_req_lang[$k] .= $jointure . " where " . $temp_not['t'][0][0] . "." . $tableau['REFERENCEKEY'][0][value] . "=" . $this->id; } $tab_req[$k]["new_rqt"]['rqt'][] = $query; } $tab_req[$k]["rqt"] = implode(" union ", $tab_req[$k]["new_rqt"]['rqt']); } //qu'est-ce qu'on efface? if ($datatype == "all") { $req_del = "delete from cms_editorial_words_global_index where num_obj='" . $this->id . "' and type = '" . $this->type . "'"; pmb_mysql_query($req_del, $dbh); //la table pour les recherche exacte $req_del = "delete from cms_editorial_fields_global_index where num_obj='" . $this->id . "' and type = '" . $this->type . "'"; pmb_mysql_query($req_del, $dbh); } else { foreach ($tab_code_champ as $subfields) { foreach ($subfields as $subfield) { $req_del = "delete from cms_editorial_words_global_index where num_obj='" . $this->id . "' and type = '" . $this->type . "' and code_champ='" . $subfield['champ'] . "'"; pmb_mysql_query($req_del, $dbh); //la table pour les recherche exacte $req_del = "delete from cms_editorial_fields_global_index where num_obj='" . $this->id . "' and type = '" . $this->type . "' and code_champ='" . $subfield['champ'] . "'"; pmb_mysql_query($req_del, $dbh); break; } } //Les champs perso if (count($tab_pp)) { foreach ($tab_pp as $id) { $req_del = "delete from cms_editorial_words_global_index where num_obj='" . $this->id . "' and type = '" . $this->type . "' and code_champ='" . $id . "' "; pmb_mysql_query($req_del, $dbh); //la table pour les recherche exacte $req_del = "delete from cms_editorial_fields_global_index where num_obj='" . $this->id . "' and type = '" . $this->type . "' and code_champ='" . $id . "' "; pmb_mysql_query($req_del, $dbh); } } } //qu'est-ce qu'on met a jour ? $tab_insert = array(); $tab_field_insert = array(); foreach ($tab_req as $k => $v) { $r = pmb_mysql_query($v["rqt"], $dbh); $tab_mots = array(); $tab_fields = array(); if (pmb_mysql_num_rows($r)) { while ($tab_row = pmb_mysql_fetch_array($r, MYSQL_ASSOC)) { if (isset($tab_row[$tab_languages[$k]])) { $lang = $tab_row[$tab_languages[$k]]; unset($tab_row[$tab_languages[$k]]); } else { $lang = ""; } foreach ($tab_row as $nom_champ => $liste_mots) { if ($tab_code_champ[$k][$nom_champ]['marctype']) { $marclist = new marc_list($tab_code_champ[$k][$nom_champ]['marctype']); $liste_mots = $marclist->table[$liste_mots]; } if ($liste_mots != '') { $liste_mots = strip_tags($liste_mots); $tab_tmp = array(); if (!in_array($k, $tab_keep_empty)) { $tab_tmp = explode(' ', strip_empty_words($liste_mots)); } else { $tab_tmp = explode(' ', strip_empty_chars(clean_string($liste_mots))); } // if($lang!="") $tab_tmp[]=$lang; //la table pour les recherche exacte if (!$tab_fields[$nom_champ]) { $tab_fields[$nom_champ] = array(); } $tab_fields[$nom_champ][] = array('value' => trim($liste_mots), 'lang' => $lang); if (!$tab_code_champ[$k][$nom_champ]['no_words']) { foreach ($tab_tmp as $mot) { if (trim($mot)) { $tab_mots[$nom_champ][$mot] = $lang; } } } } } } } foreach ($tab_mots as $nom_champ => $tab) { $pos = 1; foreach ($tab as $mot => $lang) { //on cherche le mot dans la table de mot... $num_word = 0; $query = "select id_word from words where word = '" . $mot . "' and lang = '" . $lang . "'"; $result = pmb_mysql_query($query); if (pmb_mysql_num_rows($result)) { $num_word = pmb_mysql_result($result, 0, 0); } else { $dmeta = new DoubleMetaPhone($mot); $stemming = new stemming($mot); $element_to_update = ""; if ($dmeta->primary || $dmeta->secondary) { $element_to_update .= "\n\t\t\t\t\t\t\t\tdouble_metaphone = '" . $dmeta->primary . " " . $dmeta->secondary . "'"; } if ($element_to_update) { $element_to_update .= ","; } $element_to_update .= "stem = '" . $stemming->stem . "'"; $query = "insert into words set word = '" . $mot . "', lang = '" . $langage . "'" . ($element_to_update ? ", " . $element_to_update : ""); pmb_mysql_query($query); $num_word = pmb_mysql_insert_id(); } if ($num_word != 0) { $tab_insert[] = "(" . $this->id . ",'" . $this->type . "'," . $tab_code_champ[$k][$nom_champ]['champ'] . "," . $tab_code_champ[$k][$nom_champ]['ss_champ'] . "," . $num_word . "," . $tab_code_champ[$k][$nom_champ]['pond'] . ",{$pos})"; $pos++; } } } //la table pour les recherche exacte foreach ($tab_fields as $nom_champ => $tab) { foreach ($tab as $order => $values) { //$tab_field_insert[]="(".$this->id.",".$tab_code_champ[$v["table"]][$nom_champ][0].",".$tab_code_champ[$v["table"]][$nom_champ][1].",".$order.",'".addslashes($values['value'])."','".addslashes($values['lang'])."',".$tab_code_champ[$v["table"]][$nom_champ][2].")"; $tab_field_insert[] = "(" . $this->id . ",'" . $this->type . "'," . $tab_code_champ[$k][$nom_champ]['champ'] . "," . $tab_code_champ[$k][$nom_champ]['ss_champ'] . "," . $order . ",'" . addslashes($values['value']) . "','" . addslashes($values['lang']) . "'," . $tab_code_champ[$k][$nom_champ]['pond'] . ")"; } } } //Les champs perso if (count($tab_pp)) { foreach ($tab_pp as $code_champ => $table) { $p_perso = new cms_editorial_parametres_perso($this->num_type); $data = $p_perso->get_fields_recherche_mot($this->id); $j = 0; foreach ($data as $code_ss_champ => $value) { $tab_mots = array(); $tab_tmp = explode(' ', strip_empty_words($value)); //la table pour les recherche exacte $tab_field_insert[] = "(" . $this->id . ",'" . $this->type . "'," . $code_champ . "," . $code_ss_champ . "," . $j . ",'" . addslashes(trim($value)) . "',''," . $p_perso->get_pond($code_ss_champ) . ")"; $j++; foreach ($tab_tmp as $mot) { if (trim($mot)) { $tab_mots[$mot] = ""; } } $pos = 1; foreach ($tab_mots as $mot => $lang) { //on cherche le mot dans la table de mot... $query = "select id_word from words where word = '" . $mot . "' and lang = '" . $lang . "'"; $result = pmb_mysql_query($query); if (pmb_mysql_num_rows($result)) { $num_word = pmb_mysql_result($result, 0, 0); } else { $query = "insert into words set word = '" . $mot . "', lang = '" . $lang . "'"; pmb_mysql_query($query); $num_word = pmb_mysql_insert_id(); } $tab_insert[] = "(" . $this->id . ",'" . $this->type . "'," . $code_champ . "," . $code_ss_champ . "," . $num_word . "," . $p_perso->get_pond($code_ss_champ) . ",{$pos})"; $pos++; } } } } $req_insert = "insert into cms_editorial_words_global_index(num_obj,type,code_champ,code_ss_champ,num_word,pond,position) values " . implode(',', $tab_insert); pmb_mysql_query($req_insert, $dbh); //la table pour les recherche exacte $req_insert = "insert into cms_editorial_fields_global_index(num_obj,type,code_champ,code_ss_champ,ordre,value,lang,pond) values " . implode(',', $tab_field_insert); pmb_mysql_query($req_insert, $dbh); } }
function import_new_notice_suite() { global $dbh; global $notice_id, $bulletin_ex; global $info_461, $info_463, $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; $bulletin_ex = 0; $is_object = false; //compatibilite avec import memonotices if (is_array($info_464)) { unset($info_461); unset($info_463); $info_461[0]['t'] = $info_464[0]['t']; $info_461[0]['9'] = 'lnk:perio'; $info_463[0]['v'] = $info_464[0]['v']; $info_463[0]['e'] = $info_464[0]['d']; $info_463[0]['9'] = 'lnk:bull'; if (strpos($info_904[0], "/") !== FALSE) { $dc = substr($info_904[0], 6, 4) . '-' . substr($info_904[0], 3, 2) . '-' . substr($info_904[0], 0, 2); $info_904[0] = $dc; } } //Si article if (is_array($info_461) && is_array($info_463)) { //recuperation infos notice $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_461[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_463[0]['v']) . "' and mention_date='" . addslashes($info_463[0]['e']) . "' 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); $info['bul_titre'] = "Bulletin " . $info_463[0]['v']; if ($info_463[0]['e']) { $info['bul_titre'] .= " - " . $info_463[0]['e']; } $info['bul_titre'] = addslashes($info['bul_titre']); $info['bul_no'] = addslashes($info_463[0]['v']); $info['bul_date'] = addslashes($info_463[0]['e']); $date_date = explode("/", $info_463[0]['e']); 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]; } } $bulletin_id = $bulletin->update($info); } } else { //Si non, création notice chapeau et bulletin $chapeau = new serial(); $info = array(); $info['tit1'] = addslashes($info_461[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'] = "Bulletin " . $info_463[0]['v']; if ($info_463[0]['e']) { $info['bul_titre'] .= " - " . $info_463[0]['e']; } $info['bul_titre'] = addslashes($info['bul_titre']); $info['bul_no'] = addslashes($info_463[0]['v']); $info['bul_date'] = addslashes($info_463[0]['e']); $date_date = explode("/", $info_463[0]['e']); 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]; } } $bulletin_id = $bulletin->update($info); } $bulletin_ex = $bulletin_id; if ($r->tit1 == '_OBJECT_BULLETIN_' || is_array($info_464) && $info_464[0]['z'] == 'objet') { //$info_464[0]['z']=='objet' >> Compatibilite import memonotices $is_object = true; //notice de bulletin a supprimer notice::del_notice($notice_id); } else { //Passage de la notice en article $np = ''; if (is_array($info_464) && $info_464[0]['p'] != '') { $np = ", npages='" . addslashes($info_464[0]['p']) . "' "; } $requete = "update notices set niveau_biblio='a', niveau_hierar='2', year='" . addslashes($info_463[0]['e']) . "'" . $np . ", 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); } } if (!$is_object) { //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 = $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,ordre_categorie) values({$notice_id},{$categ_id},{$ordre_categ})"; mysql_query($requete, $dbh); $ordre_categ++; } else { $unknown_desc[] = $descripteur; } } } if ($unknown_desc) { $mots_cles = implode($pmb_keyword_sep, $unknown_desc); $il = ''; $qil = "select index_l from notices where notice_id={$notice_id} "; $ril = mysql_query($qil, $dbh); $il = trim(mysql_result($ril, 0, 0)); if ($il) { $mots_cles = $il . $pmb_keyword_sep . $mots_cles; } $requete = "update notices set index_l='" . addslashes($mots_cles) . "', index_matieres=' " . addslashes(strip_empty_words($mots_cles)) . " ' where notice_id={$notice_id}"; mysql_query($requete, $dbh); } $notes = ''; //Thème $qn = "select idchamp from notices_custom where name='theme' "; $rn = mysql_query($qn, $dbh); if (mysql_num_rows($rn)) { $idc_theme = mysql_result($rn, 0, 0); } if (count($info_900) && $idc_theme) { 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={$idc_theme} "; $resultat = mysql_query($requete, $dbh); if (mysql_num_rows($resultat)) { $value = mysql_result($resultat, 0, 0); $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values({$idc_theme},{$notice_id},{$value})"; mysql_query($requete, $dbh); } else { //sinon dans notes $notes .= 'thème : ' . $info_900[$i][$j]; } } } } //Genres $qn = "select idchamp from notices_custom where name='genre' "; $rn = mysql_query($qn, $dbh); if (mysql_num_rows($rn)) { $idc_genre = mysql_result($rn, 0, 0); } if (count($info_901) && $idc_genre) { 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={$idc_genre} "; $resultat = mysql_query($requete, $dbh); if (mysql_num_rows($resultat)) { $value = mysql_result($resultat, 0, 0); $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values({$idc_genre},{$notice_id},{$value})"; mysql_query($requete, $dbh); } else { //sinon dans notes if ($notes) { $notes .= "\n"; } $notes .= 'genre : ' . $info_901[$i][$j]; } } } } //Discipline $qn = "select idchamp from notices_custom where name='discipline' "; $rn = mysql_query($qn, $dbh); if (mysql_num_rows($rn)) { $idc_discipline = mysql_result($rn, 0, 0); } if (count($info_902) && $idc_discipline) { 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={$idc_discipline} "; $resultat = mysql_query($requete, $dbh); if (mysql_num_rows($resultat)) { $value = mysql_result($resultat, 0, 0); $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values({$idc_discipline},{$notice_id},{$value})"; mysql_query($requete, $dbh); } else { //sinon dans notes if ($notes) { $notes .= "\n"; } $notes .= 'discipline : ' . $info_902[$i][$j]; } } } } //Type de nature $qn = "select idchamp from notices_custom where name='type_nature' "; $rn = mysql_query($qn, $dbh); if (mysql_num_rows($rn)) { $idc_type_nature = mysql_result($rn, 0, 0); } $qn = "select idchamp from notices_custom where name='pays' "; $rn = mysql_query($qn, $dbh); if (mysql_num_rows($rn)) { $idc_pays = mysql_result($rn, 0, 0); } $qn = "select idchamp from notices_custom where name='periode' "; $rn = mysql_query($qn, $dbh); if (mysql_num_rows($rn)) { $idc_periode = mysql_result($rn, 0, 0); } if (count($info_905)) { for ($i = 0; $i < count($info_905); $i++) { for ($j = 0; $j < count($info_905[$i]); $j++) { //essai dans type de nature $done = FALSE; if ($idc_type_nature) { $requete = "select notices_custom_list_value from notices_custom_lists where notices_custom_list_lib='" . addslashes($info_905[$i][$j]) . "' and notices_custom_champ={$idc_type_nature} "; $resultat = mysql_query($requete, $dbh); if (mysql_num_rows($resultat)) { $value = mysql_result($resultat, 0, 0); $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values({$idc_type_nature},{$notice_id},{$value})"; mysql_query($requete, $dbh); $done = TRUE; } } //essai dans genre if (!$done && $idc_genre) { $requete = "select notices_custom_list_value from notices_custom_lists where notices_custom_list_lib='" . addslashes($info_905[$i][$j]) . "' and notices_custom_champ={$idc_genre} "; $resultat = mysql_query($requete, $dbh); if (mysql_num_rows($resultat)) { $value = mysql_result($resultat, 0, 0); $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values({$idc_genre},{$notice_id},{$value})"; mysql_query($requete, $dbh); $done = TRUE; } } //essai dans theme if (!$done && $idc_theme) { $requete = "select notices_custom_list_value from notices_custom_lists where notices_custom_list_lib='" . addslashes($info_905[$i][$j]) . "' and notices_custom_champ={$idc_theme} "; $resultat = mysql_query($requete, $dbh); if (mysql_num_rows($resultat)) { $value = mysql_result($resultat, 0, 0); $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values({$idc_theme},{$notice_id},{$value})"; mysql_query($requete, $dbh); $done = TRUE; } } //essai dans discipline if (!$done && $idc_discipline) { $requete = "select notices_custom_list_value from notices_custom_lists where notices_custom_list_lib='" . addslashes($info_905[$i][$j]) . "' and notices_custom_champ={$idc_discipline} "; $resultat = mysql_query($requete, $dbh); if (mysql_num_rows($resultat)) { $value = mysql_result($resultat, 0, 0); $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values({$idc_discipline},{$notice_id},{$value})"; mysql_query($requete, $dbh); $done = TRUE; } } //essai dans pays if (!$done) { $done_pa = FALSE; if (!$done && $idc_pays) { $i_pays = strip_empty_chars($info_905[$i][$j]); $requete = "select notices_custom_list_value,notices_custom_list_lib from notices_custom_lists where notices_custom_champ={$idc_pays} "; $resultat = mysql_query($requete, $dbh); if (mysql_num_rows($resultat)) { while ($row = mysql_fetch_object($resultat)) { $r_pays = strip_empty_chars($row->notices_custom_list_lib); if (strpos($i_pays, $r_pays) !== FALSE) { $value = $row->notices_custom_list_value; $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values({$idc_pays},{$notice_id},{$value})"; mysql_query($requete, $dbh); $done_pa = TRUE; break; } } } } //essai dans periode $done_pe = FALSE; if (!$done && $idc_periode) { $i_periode = strip_empty_chars($info_905[$i][$j]); $requete = "select notices_custom_list_value,notices_custom_list_lib from notices_custom_lists where notices_custom_champ={$idc_periode} "; $resultat = mysql_query($requete, $dbh); if (mysql_num_rows($resultat)) { while ($row = mysql_fetch_object($resultat)) { $r_periode = strip_empty_chars($row->notices_custom_list_lib); if (strpos($i_periode, $r_periode) !== FALSE) { $value = $row->notices_custom_list_value; $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values({$idc_periode},{$notice_id},{$value})"; mysql_query($requete, $dbh); $done_pe = TRUE; break; } } } } if ($done_pa && $done_pe) { $done = TRUE; } } //sinon dans notes if (!$done) { if ($notes) { $notes .= "\n"; } $notes .= 'type de nature : ' . $info_905[$i][$j]; } } } } //Niveau if (count($info_906)) { $qn = "select idchamp from notices_custom where name='niveau' "; $rn = mysql_query($qn, $dbh); if (mysql_num_rows($rn)) { $idc_niveau = mysql_result($rn, 0, 0); for ($i = 0; $i < count($info_906); $i++) { for ($j = 0; $j < count($info_906[$i]); $j++) { $requete = "select notices_custom_list_value from notices_custom_lists where notices_custom_list_lib='" . addslashes($info_906[$i][$j]) . "' and notices_custom_champ={$idc_niveau} "; $resultat = mysql_query($requete, $dbh); if (mysql_num_rows($resultat)) { $value = mysql_result($resultat, 0, 0); $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) values({$idc_niveau},{$notice_id},{$value})"; mysql_query($requete, $dbh); } else { //sinon dans notes if ($notes) { $notes .= "\n"; } $notes .= 'niveau : ' . $info_906[$i][$j]; } } } } } //notes if ($notes) { $notes .= "\n"; $notes = addslashes($notes); $q = "update notices set n_contenu=concat('" . $notes . "',n_contenu) where notice_id='" . $notice_id . "' "; mysql_query($q, $dbh); } //Année de péremption if ($info_903[0]) { $qn = "select idchamp from notices_custom where name='annee_peremption' "; $rn = mysql_query($qn, $dbh); if (mysql_num_rows($rn)) { $idc_ap = mysql_result($rn, 0, 0); $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_small_text) values({$idc_ap},{$notice_id},'" . addslashes($info_903[0]) . "')"; mysql_query($requete, $dbh); } } //Date de saisie if ($info_904[0]) { $qn = "select idchamp from notices_custom where name='date_creation' "; $rn = mysql_query($qn, $dbh); if (mysql_num_rows($rn)) { $idc_ds = mysql_result($rn, 0, 0); $requete = "insert into notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_date) values({$idc_ds},{$notice_id},'" . $info_904[0] . "')"; mysql_query($requete, $dbh); } } } }
function getEnrichment($notice_id, $source_id, $type = "", $enrich_params = array()) { $params = $this->get_source_params($source_id); if ($params["PARAMETERS"]) { //Affichage du formulaire avec $params["PARAMETERS"] $vars = unserialize($params["PARAMETERS"]); foreach ($vars as $key => $val) { global ${$key}; ${$key} = $val; } } $enrichment = array(); //on renvoi ce qui est demandé... si on demande rien, on renvoi tout.. switch ($type) { case str_replace(array(" ", "%", "-", "?", "!", ";", ",", ":"), "", strip_empty_chars(strtolower($libelle))): default: $enrichment[str_replace(array(" ", "%", "-", "?", "!", ";", ",", ":"), "", strip_empty_chars(strtolower($libelle)))]['content'] = $this->urlsInfos($notice_id, $source_id); break; } $enrichment['source_label'] = sprintf($this->msg['urlslist_enrichment_source'], $source_name); return $enrichment; }
print "<img src='../../images/jauge.png' width='{$state}' height='16px'></td></tr></table>"; // calcul pourcentage avancement $percent = floor($start / $count * 100); // affichage du % d'avancement et de l'état print "<div align='center'>{$percent}%</div>"; require_once "{$class_path}/rdf/ontology.class.php"; $op = new ontology_parser("{$class_path}/rdf/skos_pmb.rdf"); $sh = new skos_handler($op); while ($triple = pmb_mysql_fetch_object($r_sel)) { $type = $sh->op->from_ns($sh->get_object_type($triple->subject_uri)); $q_ins = "insert ignore into rdfstore_index "; $q_ins .= "set num_triple='" . $triple->num_triple . "', "; $q_ins .= "subject_uri='" . addslashes($triple->subject_uri) . "', "; $q_ins .= "subject_type='" . addslashes($type) . "', "; $q_ins .= "predicat_uri='" . addslashes($triple->predicat_uri) . "', "; $q_ins .= "num_object='" . $triple->num_object . "', "; $q_ins .= "object_val ='" . addslashes($triple->object_val) . "', "; $q_ins .= "object_index=' " . strip_empty_chars($triple->object_val) . " ', "; $q_ins .= "object_lang ='" . addslashes($triple->object_lang) . "' "; $r_ins = pmb_mysql_query($q_ins, $dbh); } $next = $start + $lot; print "\n\t\t<form class='form-{$current_module}' name='current_state' action='./clean.php' method='post'>\n\t\t<input type='hidden' name='v_state' value=\"" . urlencode($v_state) . "\">\n\t\t<input type='hidden' name='spec' value=\"{$spec}\">\n\t\t<input type='hidden' name='start' value=\"{$next}\">\n\t\t<input type='hidden' name='count' value=\"{$count}\">\n\t\t</form>\n\t\t<script type=\"text/javascript\"><!-- \n\t\tsetTimeout(\"document.forms['current_state'].submit()\",1000); \n\t\t-->\n\t\t</script>"; } else { $spec = $spec - INDEX_RDFSTORE; $not = pmb_mysql_query("select count(1) from rdfstore_triple where o_type=2", $dbh); $compte = pmb_mysql_result($not, 0, 0); $v_state .= "<br /><img src=../../images/d.gif hspace=3>" . htmlentities($msg['nettoyage_rdfstore_reindexation'], ENT_QUOTES, $charset) . " : "; $v_state .= $compte . " " . htmlentities($msg['nettoyage_rdfstore_reindex_elt'], ENT_QUOTES, $charset); print "\n\t\t<form class='form-{$current_module}' name='process_state' action='./clean.php' method='post'>\n\t\t<input type='hidden' name='v_state' value=\"" . urlencode($v_state) . "\">\n\t\t<input type='hidden' name='spec' value=\"{$spec}\">\n\t\t</form>\n\t\t<script type=\"text/javascript\"><!--\n\t\t\tdocument.forms['process_state'].submit();\n\t\t\t-->\n\t\t</script>"; }
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; }
static function update_index_tu($tu_id) { global $dbh; global $msg; global $include_path; if ($tu_id) { $requete = "UPDATE titres_uniformes SET index_tu="; $oeuvre = new titre_uniforme($tu_id); $auteur = new auteur($oeuvre->num_author); $index .= $oeuvre->name . " " . $oeuvre->tonalite . " " . $oeuvre->subject . " " . $oeuvre->place . " " . $oeuvre->history . " "; $index .= $oeuvre->date . " " . $oeuvre->context . " " . $oeuvre->equinox . " " . $oeuvre->coordinates . " "; $index .= $auteur->name . " " . $auteur->rejete . " "; $req = "SELECT distrib_name FROM tu_distrib WHERE distrib_num_tu='{$tu_id}' "; $res = mysql_query($req, $dbh); if ($distrib = mysql_fetch_object($res)) { $index .= $distrib->distrib_name . " "; } $req = "SELECT ref_name FROM tu_ref WHERE ref_num_tu='{$tu_id}' "; $res = mysql_query($req, $dbh); if ($ref = mysql_fetch_object($res)) { $index .= $ref->ref_name . " "; } $requete .= "' " . addslashes(strip_empty_chars($index)) . " ' WHERE tu_id=" . $tu_id; $result = mysql_query($requete, $dbh); } return; }
static function majNoticesMotsGlobalIndex($notice, $datatype = 'all') { global $include_path; global $dbh, $champ_base; global $lang; global $indexation_lang; //recuperation du fichier xml de configuration if (!count($champ_base)) { $file = $include_path . "/indexation/notices/champs_base_subst.xml"; if (!file_exists($file)) { $file = $include_path . "/indexation/notices/champs_base.xml"; } $fp = fopen($file, "r"); if ($fp) { $xml = fread($fp, filesize($file)); } fclose($fp); $champ_base = _parser_text_no_function_($xml, "INDEXATION"); } $tableau = $champ_base; //analyse des donnees des tables $temp_not = array(); $temp_not['t'][0][0] = $tableau['REFERENCE'][0][value]; $temp_ext = array(); $temp_marc = array(); $champ_trouve = false; $tab_code_champ = array(); $tab_languages = array(); $tab_keep_empty = array(); $tab_pp = array(); $tab_authperso = array(); $authperso_code_champ_start = 0; $isbd_ask_list = array(); for ($i = 0; $i < count($tableau['FIELD']); $i++) { //pour chacun des champs decrits //recuperation de la liste des informations a mettre a jour if ($datatype == 'all' || $datatype == $tableau['FIELD'][$i]['DATATYPE']) { //conservation des mots vides if ($tableau['FIELD'][$i]['KEEPEMPTYWORD'] == "yes") { $tab_keep_empty[] = $tableau['FIELD'][$i]['ID']; } //champ perso if ($tableau['FIELD'][$i]['DATATYPE'] == "custom_field") { $tab_pp[$tableau['FIELD'][$i]['ID']] = $tableau['FIELD'][$i]['TABLE'][0]['value']; //autorité perso } elseif ($tableau['FIELD'][$i]['DATATYPE'] == "authperso") { $tab_authperso[$tableau['FIELD'][$i]['ID']] = $tableau['FIELD'][$i]['TABLE'][0]['value']; $authperso_code_champ_start = $tableau['FIELD'][$i]['ID']; $authpersos = new authperso_notice($notice); } else { if ($tableau['FIELD'][$i]['EXTERNAL'] == "yes") { //champ externe à la table notice //Stockage de la structure pour un accès plus facile $temp_ext[$tableau['FIELD'][$i]['ID']] = $tableau['FIELD'][$i]; } else { //champ de la table notice $temp_not['f'][0][$tableau['FIELD'][$i]['ID']] = $tableau['FIELD'][$i]['TABLE'][0]['TABLEFIELD'][0]['value']; $tab_code_champ[0][$tableau['FIELD'][$i]['TABLE'][0]['TABLEFIELD'][0]['value']] = array('champ' => $tableau['FIELD'][$i]['ID'], 'ss_champ' => 0, 'pond' => $tableau['FIELD'][$i]['POND'], 'no_words' => $tableau['FIELD'][$i]['DATATYPE'] == "marclist" ? true : false, 'internal' => 1, 'use_global_separator' => $tableau['FIELD'][$i]['TABLE'][0]['TABLEFIELD'][0]['USE_GLOBAL_SEPARATOR']); if ($tableau['FIELD'][$i]['TABLE'][0]['TABLEFIELD'][0]['MARCTYPE']) { $tab_code_champ[0][$tableau['FIELD'][$i]['TABLE'][0]['TABLEFIELD'][0]['value']]['marctype'] = $tableau['FIELD'][$i]['TABLE'][0]['TABLEFIELD'][0]['MARCTYPE']; $temp_not['f'][0][$tableau['FIELD'][$i]['ID'] . "_marc"] = $tableau['FIELD'][$i]['TABLE'][0]['TABLEFIELD'][0]['value'] . " as " . "subst_for_marc_" . $tableau['FIELD'][$i]['TABLE'][0]['TABLEFIELD'][0]['MARCTYPE']; } } } if ($tableau['FIELD'][$i]['ISBD']) { // isbd autorités $isbd_ask_list[$tableau['FIELD'][$i]['ID']] = array('champ' => $tableau['FIELD'][$i]['ID'], 'ss_champ' => $tableau['FIELD'][$i]['ISBD'][0]['ID'], 'pond' => $tableau['FIELD'][$i]['ISBD'][0]['POND'], 'class_name' => $tableau['FIELD'][$i]['ISBD'][0]['CLASS_NAME']); } $champ_trouve = true; } } if ($champ_trouve) { $tab_req = array(); //Recherche des champs directs if ($datatype == 'all') { $tab_req[0]["rqt"] = "select " . implode(',', $temp_not['f'][0]) . " from " . $temp_not['t'][0][0]; $tab_req[0]["rqt"] .= " where " . $tableau['REFERENCEKEY'][0][value] . "='" . $notice . "'"; $tab_req[0]["table"] = $temp_not['t'][0][0]; } foreach ($temp_ext as $k => $v) { $isbd_tab_req = array(); $no_word_field = false; //Construction de la requete //Champs pour le select $select = array(); //on harmonise les fichiers XML décrivant des requetes... for ($i = 0; $i < count($v["TABLE"]); $i++) { $table = $v['TABLE'][$i]; $select = array(); if (count($table['TABLEFIELD'])) { $use_word = true; } else { $use_word = false; } if ($table['IDKEY'][0]) { $select[] = $table['NAME'] . "." . $table['IDKEY'][0]['value'] . " as subst_for_autorite_" . $table['IDKEY'][0]['value']; } for ($j = 0; $j < count($table['TABLEFIELD']); $j++) { $select[] = ($table['ALIAS'] ? $table['ALIAS'] . "." : "") . $table['TABLEFIELD'][$j]["value"]; if ($table['LANGUAGE']) { $select[] = $table['LANGUAGE'][0]['value']; $tab_languages[$k] = $table['LANGUAGE'][0]['value']; } $field_name = $table['TABLEFIELD'][$j]["value"]; if (strpos(strtolower($table['TABLEFIELD'][$j]["value"]), " as ") !== false) { //Pour le cas où l'on a besoin de nommer un champ et d'utiliser un alias $field_name = substr($table['TABLEFIELD'][$j]["value"], strpos(strtolower($table['TABLEFIELD'][$j]["value"]), " as ") + 4); } elseif (strpos($table['TABLEFIELD'][$j]["value"], ".") !== false) { $field_name = substr($table['TABLEFIELD'][$j]["value"], strpos($table['TABLEFIELD'][$j]["value"], ".") + 1); } $field_name = trim($field_name); $tab_code_champ[$v['ID']][$field_name] = array('champ' => $v['ID'], 'ss_champ' => $table['TABLEFIELD'][$j]["ID"], 'pond' => $table['TABLEFIELD'][$j]['POND'], 'no_words' => $v['DATATYPE'] == "marclist" ? true : false, 'autorite' => $table['IDKEY'][0]['value']); if ($table['TABLEFIELD'][$j]['MARCTYPE']) { $tab_code_champ[$v['ID']][$table['TABLEFIELD'][$j]["value"]]['marctype'] = $table['TABLEFIELD'][$j]['MARCTYPE']; $select[] = $table['NAME'] . "." . $table['TABLEFIELD'][$j]["value"] . " as subst_for_marc_" . $table['TABLEFIELD'][$j]['MARCTYPE']; } } $query = "select " . implode(",", $select) . " from notices"; $jointure = ""; for ($j = 0; $j < count($table['LINK']); $j++) { $link = $table['LINK'][$j]; if ($link["TABLE"][0]['ALIAS']) { $alias = $link["TABLE"][0]['ALIAS']; } else { $alias = $link["TABLE"][0]['value']; } switch ($link["TYPE"]) { case "n0": if ($link["TABLEKEY"][0]['value']) { $jointure .= " LEFT JOIN " . $link["TABLE"][0]['value'] . ($link["TABLE"][0]['value'] != $alias ? " AS " . $alias : ""); if ($link["EXTERNALTABLE"][0]['value']) { $jointure .= " ON " . $link["EXTERNALTABLE"][0]['value'] . "." . $link["EXTERNALFIELD"][0]['value']; } else { $jointure .= " ON " . ($table['ALIAS'] ? $table['ALIAS'] : $table['NAME']) . "." . $link["EXTERNALFIELD"][0]['value']; } $jointure .= "=" . $alias . "." . $link["TABLEKEY"][0]['value'] . " " . $link["LINKRESTRICT"][0]['value']; } else { $jointure .= " LEFT JOIN " . $table['NAME'] . ($table['ALIAS'] ? " as " . $table['ALIAS'] : ""); $jointure .= " ON " . $tableau['REFERENCE'][0]['value'] . "." . $tableau['REFERENCEKEY'][0]['value']; $jointure .= "=" . ($table['ALIAS'] ? $table['ALIAS'] : $table['NAME']) . "." . $link["EXTERNALFIELD"][0]['value'] . " " . $link["LINKRESTRICT"][0]['value']; } break; case "n1": if ($link["TABLEKEY"][0]['value']) { $jointure .= " JOIN " . $link["TABLE"][0]['value'] . ($link["TABLE"][0]['value'] != $alias ? " AS " . $alias : ""); if ($link["EXTERNALTABLE"][0]['value']) { $jointure .= " ON " . $link["EXTERNALTABLE"][0]['value'] . "." . $link["EXTERNALFIELD"][0]['value']; } else { $jointure .= " ON " . ($table['ALIAS'] ? $table['ALIAS'] : $table['NAME']) . "." . $link["EXTERNALFIELD"][0]['value']; } $jointure .= "=" . $alias . "." . $link["TABLEKEY"][0]['value'] . " " . $link["LINKRESTRICT"][0]['value']; } else { $jointure .= " JOIN " . $table['NAME'] . ($table['ALIAS'] ? " as " . $table['ALIAS'] : ""); $jointure .= " ON " . $tableau['REFERENCE'][0]['value'] . "." . $tableau['REFERENCEKEY'][0]['value']; $jointure .= "=" . ($table['ALIAS'] ? $table['ALIAS'] : $table['NAME']) . "." . $link["EXTERNALFIELD"][0]['value'] . " " . $link["LINKRESTRICT"][0]['value']; } break; case "1n": $jointure .= " JOIN " . $table['NAME'] . ($table['ALIAS'] ? " as " . $table['ALIAS'] : ""); $jointure .= " ON (" . ($table['ALIAS'] ? $table['ALIAS'] : $table['NAME']) . "." . $table["TABLEKEY"][0]['value']; $jointure .= "=" . $tableau['REFERENCE'][0]['value'] . "." . $link["REFERENCEFIELD"][0]['value'] . " " . $link["LINKRESTRICT"][0]['value'] . ") "; break; case "nn": $jointure .= " JOIN " . $link["TABLE"][0]['value'] . ($link["TABLE"][0]['value'] != $alias ? " AS " . $alias : ""); $jointure .= " ON (" . $tableau['REFERENCE'][0]['value'] . "." . $tableau['REFERENCEKEY'][0]['value']; $jointure .= "=" . $alias . "." . $link["REFERENCEFIELD"][0]['value'] . ") "; if ($link["TABLEKEY"][0]['value']) { $jointure .= " JOIN " . $table['NAME'] . ($table['ALIAS'] ? " as " . $table['ALIAS'] : ""); $jointure .= " ON (" . $alias . "." . $link["TABLEKEY"][0]['value']; $jointure .= "=" . ($table['ALIAS'] ? $table['ALIAS'] : $table['NAME']) . "." . $link["EXTERNALFIELD"][0]['value'] . " " . $link["LINKRESTRICT"][0]['value'] . ") "; } else { $jointure .= " JOIN " . $table['NAME'] . ($table['ALIAS'] ? " as " . $table['ALIAS'] : ""); $jointure .= " ON (" . $alias . "." . $link["EXTERNALFIELD"][0]['value']; $jointure .= "=" . ($table['ALIAS'] ? $table['ALIAS'] : $table['NAME']) . "." . $table["TABLEKEY"][0]['value'] . " " . $link["LINKRESTRICT"][0]['value'] . ") "; } break; } } $where = " where " . $temp_not['t'][0][0] . "." . $tableau['REFERENCEKEY'][0][value] . "=" . $notice; if ($table['FILTER']) { foreach ($table['FILTER'] as $filter) { if ($tmp = trim($filter["value"])) { $where .= " AND (" . $tmp . ")"; } } } if ($table['LANGUAGE']) { $tab_req_lang[$k] = "select " . $table['LANGUAGE'][0]['value'] . " from "; } $query .= $jointure . $where; if ($table['LANGUAGE']) { $tab_req_lang[$k] .= $jointure . $where; } if ($use_word) { $tab_req[$k]["new_rqt"]['rqt'][] = $query; } if ($isbd_ask_list[$k]) { // isbd => memo de la requete pour retrouver les id des autorités $id_aut = $table['NAME'] . "." . $table["TABLEKEY"][0]['value']; $req = "select {$id_aut} as id_aut_for_isbd from notices" . $jointure . $where; $isbd_tab_req[] = $req; } } if ($use_word) { $tab_req[$k]["rqt"] = implode(" union ", $tab_req[$k]["new_rqt"]['rqt']); } if ($isbd_ask_list[$k]) { // isbd => memo de la requete pour retrouver les id des autorités $req = implode(" union ", $isbd_tab_req); $isbd_ask_list[$k]['req'] = $req; } } //qu'est-ce qu'on efface? if ($datatype == 'all') { $req_del = "delete from notices_mots_global_index where id_notice='" . $notice . "' "; pmb_mysql_query($req_del, $dbh); //la table pour les recherche exacte $req_del = "delete from notices_fields_global_index where id_notice='" . $notice . "' "; pmb_mysql_query($req_del, $dbh); } else { foreach ($tab_code_champ as $subfields) { foreach ($subfields as $subfield) { $req_del = "delete from notices_mots_global_index where id_notice='" . $notice . "' and code_champ='" . $subfield['champ'] . "'"; pmb_mysql_query($req_del, $dbh); //la table pour les recherche exacte $req_del = "delete from notices_fields_global_index where id_notice='" . $notice . "' and code_champ='" . $subfield['champ'] . "'"; pmb_mysql_query($req_del, $dbh); break; } } //Les champs perso if (count($tab_pp)) { foreach ($tab_pp as $id) { $req_del = "delete from notices_mots_global_index where id_notice='" . $notice . "' and code_champ=100 and code_ss_champ='" . $id . "' "; pmb_mysql_query($req_del, $dbh); //la table pour les recherche exacte $req_del = "delete from notices_fields_global_index where id_notice='" . $notice . "' and code_champ=100 and code_ss_champ='" . $id . "' "; pmb_mysql_query($req_del, $dbh); } } //Les autorités perso if (count($tab_authperso)) { $authperso_fields = $authpersos->get_index_fields_to_delete(); foreach ($authperso_fields as $code_champ) { $code_champ += $authperso_code_champ_start; $req_del = "delete from notices_mots_global_index where id_notice='" . $notice . "' and code_champ={$code_champ} "; pmb_mysql_query($req_del, $dbh); //la table pour les recherche exacte $req_del = "delete from notices_fields_global_index where id_notice='" . $notice . "' and code_champ={$code_champ} "; pmb_mysql_query($req_del, $dbh); } } } //qu'est-ce qu'on met a jour ? $tab_insert = array(); $tab_field_insert = array(); foreach ($tab_req as $k => $v) { $r = pmb_mysql_query($v["rqt"], $dbh); $tab_mots = array(); $tab_fields = array(); if (pmb_mysql_num_rows($r)) { while ($tab_row = pmb_mysql_fetch_array($r, MYSQL_ASSOC)) { $langage = ""; if (isset($tab_row[$tab_languages[$k]])) { $langage = $tab_row[$tab_languages[$k]]; unset($tab_row[$tab_languages[$k]]); } foreach ($tab_row as $nom_champ => $liste_mots) { if (substr($nom_champ, 0, 10) == 'subst_for_') { continue; } if ($tab_code_champ[$k][$nom_champ]['internal']) { $langage = $indexation_lang; } if ($tab_code_champ[$k][$nom_champ]['marctype']) { //on veut toutes les langues, pas seulement celle de l'interface... $saved_lang = $lang; $code = $liste_mots; $dir = opendir($include_path . "/marc_tables"); while ($dir_lang = readdir($dir)) { if ($dir_lang != "." && $dir_lang != ".." && $dir_lang != "CVS" && $dir_lang != ".svn" && is_dir($include_path . "/marc_tables/" . $dir_lang)) { $lang = $dir_lang; $marclist = new marc_list($tab_code_champ[$k][$nom_champ]['marctype']); $liste_mots = $marclist->table[$code]; $tab_fields[$nom_champ][] = array('value' => trim($liste_mots), 'lang' => $lang, 'autorite' => $tab_row["subst_for_marc_" . $tab_code_champ[$k][$nom_champ]['marctype']]); } } $lang = $saved_lang; $liste_mots = ""; } if ($liste_mots != '') { $tab_tmp = array(); $liste_mots = strip_tags($liste_mots); if (!in_array($k, $tab_keep_empty)) { $tab_tmp = explode(' ', strip_empty_words($liste_mots)); } else { $tab_tmp = explode(' ', strip_empty_chars(clean_string($liste_mots))); } // if($lang!="") $tab_tmp[]=$lang; //la table pour les recherche exacte if (!$tab_fields[$nom_champ]) { $tab_fields[$nom_champ] = array(); } if (!$tab_code_champ[$k][$nom_champ]['use_global_separator']) { $tab_fields[$nom_champ][] = array('value' => trim($liste_mots), 'lang' => $langage, 'autorite' => $tab_row["subst_for_autorite_" . $tab_code_champ[$k][$nom_champ]['autorite']]); } else { $var_global_sep = $tab_code_champ[$k][$nom_champ]['use_global_separator']; global ${$var_global_sep}; $tab_liste_mots = explode(${$var_global_sep}, $liste_mots); if (count($tab_liste_mots)) { foreach ($tab_liste_mots as $mot) { $tab_fields[$nom_champ][] = array('value' => trim($mot), 'lang' => $langage, 'autorite' => $tab_row["subst_for_autorite_" . $tab_code_champ[$k][$nom_champ]['autorite']]); } } } if (!$tab_code_champ[$k][$nom_champ]['no_words']) { foreach ($tab_tmp as $mot) { if (trim($mot)) { $langageKey = $langage; if (!trim($langageKey)) { $langageKey = "empty"; } $tab_mots[$nom_champ][$langageKey][] = $mot; } } } } } } } foreach ($tab_mots as $nom_champ => $tab) { $memo_ss_champ = ""; $order_fields = 1; $pos = 1; foreach ($tab as $langage => $mots) { if ($langage == "empty") { $langage = ""; } foreach ($mots as $mot) { //on cherche le mot dans la table de mot... $num_word = 0; $query = "select id_word from words where word = '" . $mot . "' and lang = '" . $langage . "'"; $result = pmb_mysql_query($query); if (pmb_mysql_num_rows($result)) { $num_word = pmb_mysql_result($result, 0, 0); } else { $dmeta = new DoubleMetaPhone($mot); $stemming = new stemming($mot); $element_to_update = ""; if ($dmeta->primary || $dmeta->secondary) { $element_to_update .= "\n\t\t\t\t\t\t\t\t\t\tdouble_metaphone = '" . $dmeta->primary . " " . $dmeta->secondary . "'"; } if ($element_to_update) { $element_to_update .= ","; } $element_to_update .= "stem = '" . $stemming->stem . "'"; $query = "insert into words set word = '" . $mot . "', lang = '" . $langage . "'" . ($element_to_update ? ", " . $element_to_update : ""); pmb_mysql_query($query); $num_word = pmb_mysql_insert_id(); } if ($num_word != 0) { $tab_insert[] = "(" . $notice . "," . $tab_code_champ[$k][$nom_champ]['champ'] . "," . $tab_code_champ[$k][$nom_champ]['ss_champ'] . "," . $num_word . "," . $tab_code_champ[$k][$nom_champ]['pond'] . ",{$order_fields},{$pos})"; $pos++; if ($tab_code_champ[$k][$nom_champ]['ss_champ'] != $memo_ss_champ) { $order_fields++; } $memo_ss_champ = $tab_code_champ[$k][$nom_champ]['ss_champ']; } } } } //la table pour les recherche exacte foreach ($tab_fields as $nom_champ => $tab) { foreach ($tab as $order => $values) { //$tab_field_insert[]="(".$notice.",".$tab_code_champ[$v["table"]][$nom_champ][0].",".$tab_code_champ[$v["table"]][$nom_champ][1].",".$order.",'".addslashes($values['value'])."','".addslashes($values['lang'])."',".$tab_code_champ[$v["table"]][$nom_champ][2].")"; $tab_field_insert[] = "(" . $notice . "," . $tab_code_champ[$k][$nom_champ]['champ'] . "," . $tab_code_champ[$k][$nom_champ]['ss_champ'] . "," . ($order + 1) . ",'" . addslashes($values['value']) . "','" . addslashes($values['lang']) . "'," . $tab_code_champ[$k][$nom_champ]['pond'] . ",'" . addslashes($values['autorite']) . "')"; } } } //Les champs perso if (count($tab_pp)) { foreach ($tab_pp as $code_champ => $table) { $p_perso = new parametres_perso($table); //on doit retrouver l'id des eléments... switch ($table) { case "expl": $rqt = "select expl_id from notices join exemplaires on expl_notice = notice_id and expl_notice!=0 where notice_id = {$notice} union select expl_id from notices join bulletins on num_notice = notice_id join exemplaires on expl_bulletin = bulletin_id and expl_bulletin != 0 where notice_id = {$notice}"; $res = pmb_mysql_query($rqt); if (pmb_mysql_num_rows($res)) { $ids = array(); while ($row = pmb_mysql_fetch_object($res)) { $ids[] = $row->expl_id; } } break; case "collstate": break; default: $ids = array($notice); } if (count($ids)) { for ($i = 0; $i < count($ids); $i++) { $data = $p_perso->get_fields_recherche_mot_array($ids[$i]); $j = 0; $order_fields = 1; foreach ($data as $code_ss_champ => $value) { $tab_mots = array(); foreach ($value as $val) { $tab_tmp = explode(' ', strip_empty_words($val)); //la table pour les recherche exacte $tab_field_insert[] = "(" . $notice . "," . $code_champ . "," . $code_ss_champ . "," . $j . ",'" . addslashes(trim($val)) . "',''," . $p_perso->get_pond($code_ss_champ) . ",0)"; $j++; foreach ($tab_tmp as $mot) { if (trim($mot)) { $tab_mots[$mot] = ""; } } } $pos = 1; foreach ($tab_mots as $mot => $langage) { $num_word = 0; //on cherche le mot dans la table de mot... $query = "select id_word from words where word = '" . $mot . "' and lang = '" . $langage . "'"; $result = pmb_mysql_query($query); if (pmb_mysql_num_rows($result)) { $num_word = pmb_mysql_result($result, 0, 0); } else { $dmeta = new DoubleMetaPhone($mot); $stemming = new stemming($mot); $element_to_update = ""; if ($dmeta->primary || $dmeta->secondary) { $element_to_update .= "\n\t\t\t\t\t\t\t\t\t\t\t\tdouble_metaphone = '" . $dmeta->primary . " " . $dmeta->secondary . "'"; } if ($element_to_update) { $element_to_update .= ","; } $element_to_update .= "stem = '" . $stemming->stem . "'"; $query = "insert into words set word = '" . $mot . "', lang = '" . $langage . "'" . ($element_to_update ? ", " . $element_to_update : ""); pmb_mysql_query($query); $num_word = pmb_mysql_insert_id(); } if ($num_word != 0) { $tab_insert[] = "(" . $notice . "," . $code_champ . "," . $code_ss_champ . "," . $num_word . "," . $p_perso->get_pond($code_ss_champ) . ",{$order_fields},{$pos})"; $pos++; } } $order_fields++; } } } } } //Les autorités perso if (count($tab_authperso)) { $order_fields = 1; $index_fields = $authpersos->get_index_fields($notice); foreach ($index_fields as $code_champ => $auth) { $code_champ += $authperso_code_champ_start; $tab_mots = array(); foreach ($auth['ss_champ'] as $ss_field) { foreach ($ss_field as $code_ss_champ => $val) { $tab_field_insert[] = "(" . $notice . "," . $code_champ . "," . $code_ss_champ . "," . $j . ",'" . addslashes(trim($val)) . "',''," . $auth['pond'] . ",0)"; $tab_tmp = explode(' ', strip_empty_words($val)); foreach ($tab_tmp as $mot) { if (trim($mot)) { $tab_mots[$mot] = ""; } } $pos = 1; foreach ($tab_mots as $mot => $langage) { $num_word = 0; //on cherche le mot dans la table de mot... $query = "select id_word from words where word = '" . $mot . "' and lang = '" . $langage . "'"; $result = pmb_mysql_query($query); if (pmb_mysql_num_rows($result)) { $num_word = pmb_mysql_result($result, 0, 0); } else { $dmeta = new DoubleMetaPhone($mot); $stemming = new stemming($mot); $element_to_update = ""; if ($dmeta->primary || $dmeta->secondary) { $element_to_update .= "\n\t\t\t\t\t\t\t\t\t\t\tdouble_metaphone = '" . $dmeta->primary . " " . $dmeta->secondary . "'"; } if ($element_to_update) { $element_to_update .= ","; } $element_to_update .= "stem = '" . $stemming->stem . "'"; $query = "insert into words set word = '" . $mot . "', lang = '" . $langage . "'" . ($element_to_update ? ", " . $element_to_update : ""); pmb_mysql_query($query); $num_word = pmb_mysql_insert_id(); } if ($num_word != 0) { $tab_insert[] = "(" . $notice . "," . $code_champ . "," . $code_ss_champ . "," . $num_word . "," . $auth['pond'] . ",{$order_fields},{$pos})"; $pos++; } } $order_fields++; } } } } if (count($isbd_ask_list)) { // Les isbd d'autorités foreach ($isbd_ask_list as $infos) { $isbd_s = array(); // cumul des isbd $res = pmb_mysql_query($infos["req"]) or die($infos["req"]); if (pmb_mysql_num_rows($res)) { switch ($infos["class_name"]) { case 'author': while ($row = pmb_mysql_fetch_object($res)) { $aut = new auteur($row->id_aut_for_isbd); $isbd_s[] = $aut->isbd_entry; } break; case 'editeur': while ($row = pmb_mysql_fetch_object($res)) { $aut = new editeur($row->id_aut_for_isbd); $isbd_s[] = $aut->isbd_entry; } break; case 'indexint': while ($row = pmb_mysql_fetch_object($res)) { $aut = new indexint($row->id_aut_for_isbd); $isbd_s[] = $aut->display; } break; case 'collection': while ($row = pmb_mysql_fetch_object($res)) { $aut = new collection($row->id_aut_for_isbd); $isbd_s[] = $aut->isbd_entry; } break; case 'subcollection': while ($row = pmb_mysql_fetch_object($res)) { $aut = new subcollection($row->id_aut_for_isbd); $isbd_s[] = $aut->isbd_entry; } break; case 'serie': while ($row = pmb_mysql_fetch_object($res)) { $aut = new serie($row->id_aut_for_isbd); $isbd_s[] = $aut->name; } break; case 'categories': while ($row = pmb_mysql_fetch_object($res)) { $aut = new categories($row->id_aut_for_isbd, $lang); $isbd_s[] = $aut->libelle_categorie; } break; case 'titre_uniforme': while ($row = pmb_mysql_fetch_object($res)) { $aut = new titre_uniforme($row->id_aut_for_isbd); $isbd_s[] = $aut->libelle; } break; } } $order_fields = 1; for ($i = 0; $i < count($isbd_s); $i++) { $tab_mots = array(); $tab_field_insert[] = "(" . $notice . "," . $infos["champ"] . "," . $infos["ss_champ"] . "," . $order_fields . ",'" . addslashes(trim($isbd_s[$i])) . "',''," . $infos["pond"] . ",0)"; $tab_tmp = explode(' ', strip_empty_words($isbd_s[$i])); foreach ($tab_tmp as $mot) { if (trim($mot)) { $tab_mots[$mot] = ""; } } $pos = 1; foreach ($tab_mots as $mot => $langage) { $num_word = 0; //on cherche le mot dans la table de mot... $query = "select id_word from words where word = '" . $mot . "' and lang = '" . $langage . "'"; $result = pmb_mysql_query($query); if (pmb_mysql_num_rows($result)) { $num_word = pmb_mysql_result($result, 0, 0); } else { $dmeta = new DoubleMetaPhone($mot); $stemming = new stemming($mot); $element_to_update = ""; if ($dmeta->primary || $dmeta->secondary) { $element_to_update .= "\n\t\t\t\t\t\t\t\t\t\tdouble_metaphone = '" . $dmeta->primary . " " . $dmeta->secondary . "'"; } if ($element_to_update) { $element_to_update .= ","; } $element_to_update .= "stem = '" . $stemming->stem . "'"; $query = "insert into words set word = '" . $mot . "', lang = '" . $langage . "'" . ($element_to_update ? ", " . $element_to_update : ""); pmb_mysql_query($query); $num_word = pmb_mysql_insert_id(); } if ($num_word != 0) { $tab_insert[] = "(" . $notice . "," . $infos["champ"] . "," . $infos["ss_champ"] . "," . $num_word . "," . $infos["pond"] . ",{$order_fields},{$pos})"; $pos++; } } $order_fields++; } } } if (count($tab_insert)) { $req_insert = "insert ignore into notices_mots_global_index(id_notice,code_champ,code_ss_champ,num_word,pond,position, field_position) values " . implode(',', $tab_insert); pmb_mysql_query($req_insert, $dbh); } if (count($tab_field_insert)) { //la table pour les recherche exacte $req_insert = "insert ignore into notices_fields_global_index(id_notice,code_champ,code_ss_champ,ordre,value,lang,pond,authority_num) values " . implode(',', $tab_field_insert); pmb_mysql_query($req_insert, $dbh); } } }
function import($data) { global $dbh; // check sur le type de la variable passee en parametre if (!sizeof($data) || !is_array($data)) { // si ce n'est pas un tableau ou un tableau vide, on retourne 0 return 0; } // tentative de recuperer l'id associee dans la base (implique que l'autorite existe) // preparation de la requeªte $long_maxi = pmb_mysql_field_len(pmb_mysql_query("SELECT ed_name FROM publishers limit 1"), 0); $key = addslashes(rtrim(substr(preg_replace('/\\[|\\]/', '', rtrim(ltrim($data['name']))), 0, $long_maxi))); $ville = addslashes(trim($data['ville'])); $adr = addslashes(trim($data['adr'])); $adr2 = addslashes(trim($data['adr2'])); $cp = addslashes(trim($data['cp'])); $pays = addslashes(trim($data['pays'])); $web = addslashes(trim($data['web'])); $ed_comment = addslashes(trim($data['ed_comment'])); if ($key == "") { return 0; } /* on laisse tomber les editeurs sans nom !!! exact. FL*/ $query = "SELECT ed_id FROM publishers WHERE ed_name='{$key}' and ed_ville = '{$ville}' "; $result = @pmb_mysql_query($query, $dbh); if (!$result) { die("can't SELECT publisher " . $query); } // resultat // recuperation du resultat de la recherche $tediteur = pmb_mysql_fetch_object($result); // et recuperation eventuelle de l'id if ($tediteur->ed_id) { return $tediteur->ed_id; } // id non-recuperee, il faut creer la forme. $query = "INSERT INTO publishers SET ed_name='{$key}', ed_ville = '{$ville}', ed_adr1 = '{$adr}', ed_comment='" . $ed_comment . "', ed_adr2='" . $adr2 . "', ed_cp='" . $cp . "', ed_pays='" . $pays . "', ed_web='" . $web . "', index_publisher=' " . strip_empty_chars($key) . " ' "; $result = @pmb_mysql_query($query, $dbh); if (!$result) { die("can't INSERT into publisher : " . $query); } $id = pmb_mysql_insert_id($dbh); audit::insert_creation(AUDIT_PUBLISHER, $id); return $id; }
} print "<br /><br /><h2 align='center'>" . htmlentities($msg["nettoyage_reindex_publishers"], ENT_QUOTES, $charset) . "</h2>"; $query = mysql_query("SELECT ed_id as id, ed_name as publisher, ed_ville, ed_pays from publishers LIMIT {$start}, {$lot}"); if (mysql_num_rows($query)) { // définition de l'état de la jauge $state = floor($start / ($count / $jauge_size)); // mise à jour de l'affichage de la jauge print "<table border='0' align='center' width='{$jauge_size}' cellpadding='0'><tr><td class='jauge'>"; print "<img src='../../images/jauge.png' width='{$state}' height='16'></td></tr></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 = mysql_fetch_object($query)) { // constitution des pseudo-indexes $ind_elt = strip_empty_chars($row->publisher . " " . $row->ed_ville . " " . $row->ed_pays); $req_update = "UPDATE publishers "; $req_update .= " SET index_publisher=' {$ind_elt} '"; $req_update .= " WHERE ed_id={$row->id} "; $update = mysql_query($req_update); } 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=\"EDITEURS\">\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_publishers"], ENT_QUOTES, $charset) . " {$count} " . htmlentities($msg["nettoyage_res_reindex_publishers"], ENT_QUOTES, $charset); 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='0'>\n\t\t\t\t<input type='hidden' name='count' value='0'>\n\t\t\t\t<input type='hidden' name='index_quoi' value=\"CATEGORIES\">\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>";
function import($data) { // cette méthode prend en entrée un tableau constitué des informations éditeurs suivantes : // $data['type'] type de l'autorité (70 , 71 ou 72) // $data['name'] élément d'entrée de l'autorité // $data['rejete'] élément rejeté // $data['date'] dates de l'autorité // $data['lieu'] lieu du congrès 210$e // $data['ville'] ville du congrès // $data['pays'] pays du congrès // $data['subdivision'] 210$b // $data['numero'] numero du congrès 210$d // $data['voir_id'] id de la forme retenue (sans objet pour l'import de notices) // $data['author_comment'] commentaire // $data['authority_number'] Numéro d'autortité // TODO gestion du dédoublonnage ! global $dbh; global $opac_enrichment_bnf_sparql; // 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'] ou data['rejete'] est requis). $long_maxi_name = pmb_mysql_field_len(pmb_mysql_query("SELECT author_name FROM authors limit 1"), 0); $long_maxi_rejete = pmb_mysql_field_len(pmb_mysql_query("SELECT author_rejete FROM authors limit 1"), 0); $data['name'] = rtrim(substr(preg_replace('/\\[|\\]/', '', rtrim(ltrim($data['name']))), 0, $long_maxi_name)); $data['rejete'] = rtrim(substr(preg_replace('/\\[|\\]/', '', rtrim(ltrim($data['rejete']))), 0, $long_maxi_rejete)); if (!$data['name'] && !$data['rejete']) { return 0; } // check sur le type d'autorité if (!$data['type'] == 70 && !$data['type'] == 71 && !$data['type'] == 72) { return 0; } // tentative de récupérer l'id associée dans la base (implique que l'autorité existe) // préparation de la requête $key0 = $data['type']; $key1 = addslashes($data['name']); $key2 = addslashes($data['rejete']); $key3 = addslashes($data['date']); $key4 = addslashes($data['subdivision']); $key5 = addslashes($data['lieu']); $key6 = addslashes($data['ville']); $key7 = addslashes($data['pays']); $key8 = addslashes($data['numero']); $data['lieu'] = addslashes($data['lieu']); $data['ville'] = addslashes($data['ville']); $data['pays'] = addslashes($data['pays']); $data['subdivision'] = addslashes($data['subdivision']); $data['numero'] = addslashes($data['numero']); $data['author_comment'] = addslashes($data['author_comment']); $data['author_web'] = addslashes($data['author_web']); $query = "SELECT author_id FROM authors WHERE author_type='{$key0}' AND author_name='{$key1}' AND author_rejete='{$key2}' AND author_date='{$key3}'"; if ($data["type"] > 70) { $query .= " and author_subdivision='{$key4}' and author_lieu='{$key5}' and author_ville='{$key6}' and author_pays='{$key7}' and author_numero='{$key8}'"; } $query .= " LIMIT 1"; $result = @pmb_mysql_query($query, $dbh); if (!$result) { die("can't SELECT in database"); } // résultat // récupération du résultat de la recherche $aut = pmb_mysql_fetch_object($result); // du résultat et récupération éventuelle de l'id if ($aut->author_id) { return $aut->author_id; } // id non-récupérée, il faut créer l'auteur $query = "INSERT INTO authors SET author_type='{$key0}', "; $query .= "author_name='{$key1}', "; $query .= "author_rejete='{$key2}', "; $query .= "author_date='{$key3}', "; $query .= "author_lieu='" . $data['lieu'] . "', "; $query .= "author_ville='" . $data['ville'] . "', "; $query .= "author_pays='" . $data['pays'] . "', "; $query .= "author_subdivision='" . $data['subdivision'] . "', "; $query .= "author_numero='" . $data['numero'] . "', "; $query .= "author_web='" . $data['author_web'] . "', "; $query .= "author_comment='" . $data['author_comment'] . "', "; $word_to_index = $key1 . " " . $key2 . " " . $data['lieu'] . " " . $data['ville'] . " " . $data['pays'] . " " . $data['numero'] . " " . $data["subdivision"]; if ($key0 == "72") { $word_to_index .= " " . $key3; } $query .= "index_author=' " . strip_empty_chars($word_to_index) . " ' "; $result = @pmb_mysql_query($query, $dbh); if (!$result) { die("can't INSERT into table authors :<br /><b>{$query}</b> "); } $id = pmb_mysql_insert_id($dbh); audit::insert_creation(AUDIT_AUTHOR, $id); return $id; }
function majNoticesGlobalIndex($notice, $NoIndex = 1, $contenuflux = "") { global $dbh; pmb_mysql_query("delete from notices_global_index where num_notice = " . $notice . " AND no_index = " . $NoIndex, $dbh); $titres = pmb_mysql_query("select index_serie, tnvol, index_wew, index_sew, index_l, index_matieres, n_gen, n_contenu, n_resume, index_n_gen, index_n_contenu, index_n_resume, eformat from notices where notice_id = " . $notice, $dbh); $mesNotices = pmb_mysql_fetch_assoc($titres); $tit = $mesNotices['index_wew']; $indTit = $mesNotices['index_sew']; $indMat = $mesNotices['index_matieres']; $indL = $mesNotices['index_l']; $indResume = $mesNotices['index_n_resume']; $indGen = $mesNotices['index_n_gen']; $indContenu = $mesNotices['index_n_contenu']; $resume = $mesNotices['n_resume']; $gen = $mesNotices['n_gen']; $contenu = $mesNotices['n_contenu']; $indSerie = $mesNotices['index_serie']; $tvol = $mesNotices['tnvol']; $eformatlien = $mesNotices['eformat']; $infos_global = ' '; $infos_global_index = " "; pmb_mysql_query("insert into notices_global_index (num_notice, no_index, infos_global, index_infos_global) values(" . $notice . "," . $NoIndex . ",\n\tCONCAT(' " . addslashes($tvol) . " ','" . addslashes($tit) . " ','" . addslashes($resume) . " ','" . addslashes($gen) . " ','" . addslashes($contenu) . " ','" . addslashes($indL) . " '),\n\tCONCAT(' " . $indSerie . " ','" . addslashes($indTit) . " ','" . addslashes($indResume) . " ','" . addslashes($indGen) . " ','" . addslashes($indContenu) . " ','" . addslashes($indMat) . " '))", $dbh); // Authors : $auteurs = pmb_mysql_query("select author_name, author_rejete, index_author from authors, responsability WHERE responsability_author = author_id AND responsability_notice = {$notice}", $dbh); $numA = pmb_mysql_num_rows($auteurs); for ($j = 0; $j < $numA; $j++) { $mesAuteurs = pmb_mysql_fetch_assoc($auteurs); $infos_global .= $mesAuteurs['author_name'] . ' ' . $mesAuteurs['author_rejete'] . ' '; $infos_global_index .= strip_empty_chars($mesAuteurs['author_name'] . ' ' . $mesAuteurs['author_rejete']) . " "; } pmb_mysql_free_result($auteurs); // Nom du p�riodique associ�e � la notice de d�pouillement le cas �ch�ant : $temp = pmb_mysql_query("select bulletin_notice, bulletin_titre, index_titre, index_wew, index_sew from analysis, bulletins, notices WHERE analysis_notice=" . $notice . " and analysis_bulletin = bulletin_id and bulletin_notice=notice_id", $dbh); $numP = pmb_mysql_num_rows($temp); if ($numP) { // La notice appartient a un perdiodique, on selectionne le titre de p�riodique : $mesTemp = pmb_mysql_fetch_assoc($temp); $infos_global .= $mesTemp['index_wew'] . ' ' . $mesTemp['bulletin_titre'] . ' ' . $mesTemp['index_titre'] . ' '; $infos_global_index .= strip_empty_words($mesTemp['index_wew'] . ' ' . $mesTemp['bulletin_titre'] . ' ' . $mesTemp['index_titre']) . " "; } pmb_mysql_free_result($temp); // Categories : $noeud = pmb_mysql_query("select notices_categories.num_noeud,libelle_categorie from notices_categories,categories where notcateg_notice = " . $notice . " and notices_categories.num_noeud=categories.num_noeud order by ordre_categorie", $dbh); $numNoeuds = pmb_mysql_num_rows($noeud); // Pour chaque noeud trouv�s on cherche les noeuds parents et les noeuds fils : for ($j = 0; $j < $numNoeuds; $j++) { // On met � jours la table notices_global_index avec le noeud trouv�: $mesNoeuds = pmb_mysql_fetch_assoc($noeud); $noeudInit = $mesNoeuds['num_noeud']; $infos_global .= $mesNoeuds['libelle_categorie'] . " "; $infos_global_index .= strip_empty_words($mesNoeuds['libelle_categorie']) . " "; } // Sous-collection : $subColls = pmb_mysql_query("select sub_coll_name, index_sub_coll from notices, sub_collections WHERE subcoll_id = sub_coll_id AND notice_id = " . $notice, $dbh); $numSC = pmb_mysql_num_rows($subColls); for ($j = 0; $j < $numSC; $j++) { $mesSubColl = pmb_mysql_fetch_assoc($subColls); $infos_global .= $mesSubColl['index_sub_coll'] . ' ' . $mesSubColl['sub_coll_name'] . ' '; $infos_global_index .= strip_empty_words($mesSubColl['index_sub_coll'] . ' ' . $mesSubColl['sub_coll_name']) . " "; } pmb_mysql_free_result($subColls); // Indexation num�rique : $indexNums = pmb_mysql_query("select indexint_name, indexint_comment, index_indexint from notices, indexint WHERE indexint = indexint_id AND notice_id = " . $notice, $dbh); $numIN = pmb_mysql_num_rows($indexNums); for ($j = 0; $j < $numIN; $j++) { $mesindexNums = pmb_mysql_fetch_assoc($indexNums); $infos_global .= $mesindexNums['indexint_name'] . ' ' . $mesindexNums['indexint_comment'] . ' '; $infos_global_index .= strip_empty_words($mesindexNums['indexint_name'] . ' ' . $mesindexNums['indexint_comment']) . " "; } pmb_mysql_free_result($indexNums); // Collection : $Colls = pmb_mysql_query("select collection_name, index_coll from notices, collections WHERE coll_id = collection_id AND notice_id = " . $notice, $dbh); $numCo = pmb_mysql_num_rows($Colls); for ($j = 0; $j < $numCo; $j++) { $mesColl = pmb_mysql_fetch_assoc($Colls); $infos_global .= $mesColl['collection_name'] . ' '; $infos_global_index .= strip_empty_words($mesColl['collection_name']) . " "; } pmb_mysql_free_result($Colls); // Editeurs : $editeurs = pmb_mysql_query("select ed_name, index_publisher from notices, publishers WHERE (ed1_id = ed_id OR ed2_id = ed_id) AND notice_id = " . $notice, $dbh); $numE = pmb_mysql_num_rows($editeurs); for ($j = 0; $j < $numE; $j++) { $mesEditeurs = pmb_mysql_fetch_assoc($editeurs); $infos_global .= $mesEditeurs['ed_name'] . ' '; $infos_global_index .= strip_empty_chars($mesEditeurs['ed_name']) . " "; } pmb_mysql_free_result($editeurs); pmb_mysql_free_result($titres); // champ perso cherchable $p_perso = new parametres_perso("notices"); $mots_perso = $p_perso->get_fields_recherche($notice); if ($mots_perso) { $infos_global .= $mots_perso . ' '; $infos_global_index .= strip_empty_words($mots_perso) . " "; } // flux RSS éventuellement $eformat = array(); $eformat = explode(' ', $eformatlien); if ($eformat[0] == 'RSS' && $eformat[3] == '1') { $flux = strip_tags($contenuflux); $infos_global_index .= strip_empty_words($flux) . " "; } pmb_mysql_query("UPDATE notices_global_index SET infos_global = CONCAT(infos_global,'" . addslashes($infos_global) . " '), index_infos_global = CONCAT(index_infos_global,'" . addslashes($infos_global_index) . " ') WHERE num_notice = " . $notice . " AND no_index = " . $NoIndex, $dbh); }
static function do_login($nom, $prenom) { global $dbh; $nom_forate = str_replace(' ', '', strtolower(strip_empty_chars($nom))); $prenom_forate = str_replace(' ', '', strtolower(strip_empty_chars($prenom))); $empr_login = substr($prenom_forate, 0, 1) . $nom_forate; $pb = 1; $num_login = 1; $empr_login2 = $empr_login; while ($pb == 1) { $q = "SELECT empr_login FROM empr WHERE empr_login='******' LIMIT 1 "; $r = mysql_query($q, $dbh); $nb = mysql_num_rows($r); if ($nb) { $empr_login2 = $empr_login . $num_login; $num_login++; } else { $pb = 0; } } return $empr_login2; }
public function maj($object_id, $datatype = 'all') { global $dbh, $lang; // global $indexation_lang; spécificité des notices (langue d'indexation) //on s'assure qu'on a lu le XML et initialisé ce qu'il faut... if (!$this->initialized) { $this->init(); } //on réinitialise les tableaux d'injection $tab_insert = array(); $tab_field_insert = array(); //on a des éléments à indexer... if ($this->champ_trouve) { //Recherche des champs directs if ($datatype == 'all') { $this->queries[0]["rqt"] = "select " . implode(',', $this->temp_not['f'][0]) . " from " . $this->reference_table; $this->queries[0]["rqt"] .= " where " . $this->reference_key . "='" . $object_id . "'"; $this->queries[0]["table"] = $this->reference_table; } //qu'est-ce qu'on efface? if ($datatype == 'all') { $req_del = "delete from " . $this->table_prefix . "_words_global_index where " . $this->reference_key . "='" . $object_id . "' "; pmb_mysql_query($req_del, $dbh); //la table pour les recherche exacte $req_del = "delete from " . $this->table_prefix . "_fields_global_index where " . $this->reference_key . "='" . $object_id . "' "; pmb_mysql_query($req_del, $dbh); //Les champs perso if (count($this->tab_pp)) { foreach ($this->tab_pp as $id) { $req_del = "delete from " . $this->table_prefix . "_words_global_index where " . $this->reference_key . "='" . $object_id . "' and code_champ=100 and code_ss_champ='" . $id . "' "; pmb_mysql_query($req_del, $dbh); //la table pour les recherche exacte $req_del = "delete from " . $this->table_prefix . "_fields_global_index where " . $this->reference_key . "='" . $object_id . "' and code_champ=100 and code_ss_champ='" . $id . "' "; pmb_mysql_query($req_del, $dbh); } } } else { foreach ($this->datatypes as $xml_datatype => $codes) { if ($xml_datatype == $datatype) { foreach ($codes as $code_champ) { foreach ($subfields as $subfield) { $req_del = "delete from " . $this->table_prefix . "_words_global_index where " . $this->reference_key . "='" . $object_id . "' and code_champ='" . $code_champ . "'"; pmb_mysql_query($req_del, $dbh); //la table pour les recherche exacte $req_del = "delete from " . $this->table_prefix . "_fields_global_index where " . $this->reference_key . "='" . $object_id . "' and code_champ='" . $code_champ . "'"; pmb_mysql_query($req_del, $dbh); break; } } } } } //qu'est-ce qu'on met a jour ? $tab_insert = array(); $tab_field_insert = array(); foreach ($this->datatypes as $xml_datatype => $code_champ) { if ($datatype == "all" || $xml_datatype == $datatype) { } } foreach ($this->queries as $k => $v) { if ($datatype == 'all' || in_array($k, $this->datatypes[$datatype])) { $v['rqt'] = str_replace("!!object_id!!", $object_id, $v['rqt']); $r = pmb_mysql_query($v["rqt"], $dbh) or die("Requete echouee."); $tab_mots = array(); $tab_fields = array(); if (pmb_mysql_num_rows($r)) { while ($tab_row = pmb_mysql_fetch_array($r, MYSQL_ASSOC)) { $langage = ""; if (isset($tab_row[$this->tab_languages[$k]])) { $langage = $tab_row[$this->tab_languages[$k]]; unset($tab_row[$this->tab_languages[$k]]); } foreach ($tab_row as $nom_champ => $liste_mots) { if (substr($nom_champ, 0, 10) == 'subst_for_') { continue; } if ($this->tab_code_champ[$k][$nom_champ]['internal']) { $langage = $indexation_lang; } if ($this->tab_code_champ[$k][$nom_champ]['marctype']) { //on veut toutes les langues, pas seulement celle de l'interface... $saved_lang = $lang; $code = $liste_mots; $dir = opendir($include_path . "/marc_tables"); while ($dir_lang = readdir($dir)) { if ($dir_lang != "." && $dir_lang != ".." && $dir_lang != "CVS" && $dir_lang != ".svn" && is_dir($include_path . "/marc_tables/" . $dir_lang)) { $lang = $dir_lang; $marclist = new marc_list($this->tab_code_champ[$k][$nom_champ]['marctype']); $liste_mots = $marclist->table[$code]; $tab_fields[$nom_champ][] = array('value' => trim($liste_mots), 'lang' => $lang, 'autorite' => $tab_row["subst_for_marc_" . $this->tab_code_champ[$k][$nom_champ]['marctype']]); } } $lang = $saved_lang; $liste_mots = ""; } if ($liste_mots != '') { $liste_mots = strip_tags($liste_mots); $tab_tmp = array(); if (!in_array($k, $this->tab_keep_empty)) { $tab_tmp = explode(' ', strip_empty_words($liste_mots)); } else { $tab_tmp = explode(' ', strip_empty_chars(clean_string($liste_mots))); } // if($lang!="") $tab_tmp[]=$lang; //la table pour les recherche exacte if (!$tab_fields[$nom_champ]) { $tab_fields[$nom_champ] = array(); } $tab_fields[$nom_champ][] = array('value' => trim($liste_mots), 'lang' => $langage, 'autorite' => $tab_row["subst_for_autorite_" . $this->tab_code_champ[$k][$nom_champ]['autorite']]); if (!$this->tab_code_champ[$k][$nom_champ]['no_words']) { foreach ($tab_tmp as $mot) { if (trim($mot)) { $tab_mots[$nom_champ][$mot] = $langage; } } } } } } } foreach ($tab_mots as $nom_champ => $tab) { $memo_ss_champ = ""; $order_fields = 1; $pos = 1; foreach ($tab as $mot => $langage) { $num_word = indexation::add_word($mot, $langage); if ($num_word != 0) { $tab_insert[] = "(" . $object_id . "," . $this->tab_code_champ[$k][$nom_champ]['champ'] . "," . $this->tab_code_champ[$k][$nom_champ]['ss_champ'] . "," . $num_word . "," . $this->tab_code_champ[$k][$nom_champ]['pond'] . ",{$order_fields},{$pos})"; $pos++; if ($this->tab_code_champ[$k][$nom_champ]['ss_champ'] != $memo_ss_champ) { $order_fields++; } $memo_ss_champ = $this->tab_code_champ[$k][$nom_champ]['ss_champ']; } } } //la table pour les recherche exacte foreach ($tab_fields as $nom_champ => $tab) { foreach ($tab as $order => $values) { $tab_field_insert[] = "(" . $object_id . "," . $this->tab_code_champ[$k][$nom_champ]['champ'] . "," . $this->tab_code_champ[$k][$nom_champ]['ss_champ'] . "," . ($order + 1) . ",'" . addslashes($values['value']) . "','" . addslashes($values['lang']) . "'," . $this->tab_code_champ[$k][$nom_champ]['pond'] . ",'" . addslashes($values['autorite']) . "')"; } } } // //Les champs perso // if(count($this->tab_pp)){ // foreach ( $this->tab_pp as $code_champ => $table ) { // $p_perso=new parametres_perso($table); // //on doit retrouver l'id des eléments... // switch($table){ // case "expl" : // $rqt = "select expl_id from notices join exemplaires on expl_notice = notice_id and expl_notice!=0 where notice_id = $notice union select expl_id from notices join bulletins on num_notice = notice_id join exemplaires on expl_bulletin = bulletin_id and expl_bulletin != 0 where notice_id = $notice"; // $res = pmb_mysql_query($rqt); // if(pmb_mysql_num_rows($res)) { // $ids = array(); // while($row= pmb_mysql_fetch_object($res)){ // $ids[] =$row->expl_id; // } // } // break; // case "collstate" : // break; // default : // $ids = array($notice); // } // if(count($ids)){ // for($i=0 ; $i<count($ids) ; $i++) { // $data=$p_perso->get_fields_recherche_mot_array($ids[$i]); // $j=0; // $order_fields=1; // foreach ( $data as $code_ss_champ => $value ) { // $tab_mots=array(); // foreach($value as $val) { // $tab_tmp=explode(' ',strip_empty_words($val)); // //la table pour les recherche exacte // $tab_field_insert[]="(".$notice.",".$code_champ.",".$code_ss_champ.",".$j.",'".addslashes(trim($val))."','',".$p_perso->get_pond($code_ss_champ).",0)"; // $j++; // foreach($tab_tmp as $mot) { // if(trim($mot)){ // $tab_mots[$mot]= ""; // } // } // } // $pos=1; // foreach ( $tab_mots as $mot => $langage ) { // //on cherche le mot dans la table de mot... // $query = "select id_word from words where word = '".$mot."' and lang = '".$langage."'"; // $result = pmb_mysql_query($query); // if(pmb_mysql_num_rows($result)){ // $num_word = pmb_mysql_result($result,0,0); // }else{ // $dmeta = new DoubleMetaPhone($mot); // $stemming = new stemming($mot); // $element_to_update = ""; // if($dmeta->primary || $dmeta->secondary){ // $element_to_update.=" // double_metaphone = '".$dmeta->primary." ".$dmeta->secondary."'"; // } // if($element_to_update) $element_to_update.=","; // $element_to_update.="stem = '".$stemming->stem."'"; // $query = "insert into words set word = '".$mot."', lang = '".$langage."'".($element_to_update ? ", ".$element_to_update : ""); // pmb_mysql_query($query); // $num_word = pmb_mysql_insert_id(); // } // $tab_insert[]="(".$notice.",".$code_champ.",".$code_ss_champ.",".$num_word.",".$p_perso->get_pond($code_ss_champ).",$order_fields,$pos)"; // $pos++; // } // $order_fields++; // } // } // } // } // } } if (count($this->isbd_ask_list)) { // Les isbd d'autorités foreach ($this->isbd_ask_list as $k => $infos) { $isbd_s = array(); // cumul des isbd if ($datatype == "all" || in_array($k, $this->datatypes[$datatype])) { $query = str_replace("!!object_id!!", $object_id, $infos["req"]); $res = pmb_mysql_query($query) or die($query); if (pmb_mysql_num_rows($res)) { switch ($infos["class_name"]) { case 'author': while ($row = pmb_mysql_fetch_object($res)) { $aut = new auteur($row->id_aut_for_isbd); $isbd_s[] = $aut->isbd_entry; } break; case 'editeur': while ($row = pmb_mysql_fetch_object($res)) { $aut = new editeur($row->id_aut_for_isbd); $isbd_s[] = $aut->isbd_entry; } break; case 'indexint': while ($row = pmb_mysql_fetch_object($res)) { $aut = new indexint($row->id_aut_for_isbd); $isbd_s[] = $aut->display; } break; case 'collection': while ($row = pmb_mysql_fetch_object($res)) { $aut = new collection($row->id_aut_for_isbd); $isbd_s[] = $aut->isbd_entry; } break; case 'subcollection': while ($row = pmb_mysql_fetch_object($res)) { $aut = new subcollection($row->id_aut_for_isbd); $isbd_s[] = $aut->isbd_entry; } break; case 'serie': while ($row = pmb_mysql_fetch_object($res)) { $aut = new serie($row->id_aut_for_isbd); $isbd_s[] = $aut->name; } break; case 'categories': while ($row = pmb_mysql_fetch_object($res)) { $aut = new categories($row->id_aut_for_isbd, $lang); $isbd_s[] = $aut->libelle_categorie; } break; case 'titre_uniforme': while ($row = pmb_mysql_fetch_object($res)) { $aut = new titre_uniforme($row->id_aut_for_isbd); $isbd_s[] = $aut->libelle; } break; } } } $order_fields = 1; for ($i = 0; $i < count($isbd_s); $i++) { $tab_mots = array(); $tab_field_insert[] = "(" . $object_id . "," . $infos["champ"] . "," . $infos["ss_champ"] . "," . $order_fields . ",'" . addslashes(trim($isbd_s[$i])) . "',''," . $infos["pond"] . ",0)"; $tab_tmp = explode(' ', strip_empty_words($isbd_s[$i])); foreach ($tab_tmp as $mot) { if (trim($mot)) { $tab_mots[$mot] = ""; } } $pos = 1; foreach ($tab_mots as $mot => $langage) { $num_word = indexation::add_word($mot, $langage); $tab_insert[] = "(" . $object_id . "," . $infos["champ"] . "," . $infos["ss_champ"] . "," . $num_word . "," . $infos["pond"] . ",{$order_fields},{$pos})"; $pos++; } $order_fields++; } } } $this->save_elements($tab_insert, $tab_field_insert); } }
function getTypeOfEnrichment($notice_id, $source_id) { $params = $this->get_source_params($source_id); if ($params["PARAMETERS"]) { //Affichage du formulaire avec $params["PARAMETERS"] $vars = unserialize($params["PARAMETERS"]); foreach ($vars as $key => $val) { global ${$key}; ${$key} = $val; } } $type['type'] = array(array('code' => str_replace(array(" ", "%", "-", "?", "!", ";", ",", ":"), "", strip_empty_chars(strtolower($libelle))), 'label' => $libelle, 'infobulle' => $infobulle)); $type['source_id'] = $source_id; return $type; }
function clean_string_to_base($string) { return str_replace(" ", "_", strip_empty_chars($string)); }
static function update_index_tu($tu_id) { global $dbh; global $msg; global $include_path; if ($tu_id) { $requete = "UPDATE titres_uniformes SET index_tu="; $oeuvre = new titre_uniforme($tu_id); $index .= $oeuvre->name . " " . $oeuvre->tonalite . " " . $oeuvre->subject . " " . $oeuvre->place . " " . $oeuvre->history . " "; $index .= $oeuvre->date . " " . $oeuvre->context . " " . $oeuvre->equinox . " " . $oeuvre->coordinates . " "; $as = array_keys($oeuvre->responsabilites["responsabilites"], "0"); for ($i = 0; $i < count($as); $i++) { $indice = $as[$i]; $auteur_0 = $oeuvre->responsabilites["auteurs"][$indice]; $auteur = new auteur($auteur_0["id"]); $index .= $auteur->name . " " . $auteur->rejete . " "; } $req = "SELECT distrib_name FROM tu_distrib WHERE distrib_num_tu='{$tu_id}' "; $res = pmb_mysql_query($req, $dbh); if ($distrib = pmb_mysql_fetch_object($res)) { $index .= $distrib->distrib_name . " "; } $req = "SELECT ref_name FROM tu_ref WHERE ref_num_tu='{$tu_id}' "; $res = pmb_mysql_query($req, $dbh); if ($ref = pmb_mysql_fetch_object($res)) { $index .= $ref->ref_name . " "; } $requete .= "' " . addslashes(strip_empty_chars($index)) . " ' WHERE tu_id=" . $tu_id; $result = pmb_mysql_query($requete, $dbh); } return; }
function getEnrichment($notice_id, $source_id, $type = "", $enrich_params = array(), $page = 1) { $params = $this->get_source_params($source_id); if ($params["PARAMETERS"]) { //Affichage du formulaire avec $params["PARAMETERS"] $vars = unserialize($params["PARAMETERS"]); foreach ($vars as $key => $val) { global ${$key}; ${$key} = $val; } } $enrichment = array(); //on renvoi ce qui est demandé... si on demande rien, on renvoi tout.. switch ($type) { case str_replace(array(" ", "%", "-", "?", "!", ";", ",", ":"), "", strip_empty_chars(strtolower($libelle))): default: $openurl_param = new openurl_parameters(); $openurl_param->setParameters($vars); $openurl_instance = new openurl_instance($notice_id, 0, $openurl_param->getParameters(), $source_id); global $debug; if ($debug == 1) { print $openurl_instance->getInFrame(1980, 980); } else { $enrichment[str_replace(array(" ", "%", "-", "?", "!", ";", ",", ":"), "", strip_empty_chars(strtolower($libelle)))]['content'] = $openurl_instance->getInFrame($iwidth, $iheight); } break; } $enrichment['source_label'] = sprintf($this->msg['openurl_enrichment_source'], $source_name); return $enrichment; }
function indexNotices() { global $msg, $dbh, $charset, $PMBusername; if (SESSrights & ADMINISTRATION_AUTH) { //NOTICES $result .= "<h3>" . htmlentities($msg["nettoyage_reindex_notices"], ENT_QUOTES, $charset) . "</h3>"; $query = mysql_query("SELECT notice_id FROM notices"); if (mysql_num_rows($query)) { while ($row = mysql_fetch_object($query)) { // constitution des pseudo-indexes notice::majNotices($row->notice_id); } mysql_free_result($query); } $notices = mysql_query("SELECT count(1) FROM notices", $dbh); $count = mysql_result($notices, 0, 0); $result .= "" . htmlentities($msg["nettoyage_reindex_notices"], ENT_QUOTES, $charset) . " {$count} " . htmlentities($msg["nettoyage_res_reindex_notices"], ENT_QUOTES, $charset); //AUTEURS $result .= "<h3>" . htmlentities($msg["nettoyage_reindex_authors"], ENT_QUOTES, $charset) . "</h3>"; $query = mysql_query("SELECT author_id as id,concat(author_name,' ',author_rejete,' ', author_lieu, ' ',author_ville,' ',author_pays,' ',author_numero,' ',author_subdivision) as auteur from authors LIMIT {$start}, {$lot}", $dbh); if (mysql_num_rows($query)) { while ($row = mysql_fetch_object($query)) { // constitution des pseudo-indexes $ind_elt = strip_empty_chars($row->auteur); $req_update = "UPDATE authors "; $req_update .= " SET index_author=' {$ind_elt} '"; $req_update .= " WHERE author_id={$row->id} "; $update = mysql_query($req_update, $dbh); } mysql_free_result($query); } $elts = mysql_query("SELECT count(1) FROM authors", $dbh); $count = mysql_result($elts, 0, 0); $result .= "" . htmlentities($msg["nettoyage_reindex_authors"], ENT_QUOTES, $charset) . " {$count} " . htmlentities($msg["nettoyage_res_reindex_authors"], ENT_QUOTES, $charset); //EDITEURS $result .= "<h3>" . htmlentities($msg["nettoyage_reindex_publishers"], ENT_QUOTES, $charset) . "</h3>"; $query = mysql_query("SELECT ed_id as id, ed_name as publisher, ed_ville, ed_pays from publishers"); if (mysql_num_rows($query)) { while ($row = mysql_fetch_object($query)) { // constitution des pseudo-indexes $ind_elt = strip_empty_chars($row->publisher . " " . $row->ed_ville . " " . $row->ed_pays); $req_update = "UPDATE publishers "; $req_update .= " SET index_publisher=' {$ind_elt} '"; $req_update .= " WHERE ed_id={$row->id} "; $update = mysql_query($req_update); } mysql_free_result($query); } $elts = mysql_query("SELECT count(1) FROM publishers", $dbh); $count = mysql_result($elts, 0, 0); $result .= "" . htmlentities($msg["nettoyage_reindex_publishers"], ENT_QUOTES, $charset) . " {$count} " . htmlentities($msg["nettoyage_res_reindex_publishers"], ENT_QUOTES, $charset); //CATEGORIES $result .= "<h3>" . htmlentities($msg["nettoyage_reindex_categories"], ENT_QUOTES, $charset) . "</h3>"; $req = "select num_noeud, langue, libelle_categorie from categories"; $query = mysql_query($req, $dbh); if (mysql_num_rows($query)) { while ($row = mysql_fetch_object($query)) { // constitution des pseudo-indexes $ind_elt = strip_empty_words($row->libelle_categorie, $row->langue); $req_update = "UPDATE categories "; $req_update .= "SET index_categorie=' {$ind_elt} '"; $req_update .= "WHERE num_noeud='" . $row->num_noeud . "' and langue='" . $row->langue . "' "; $update = mysql_query($req_update); } mysql_free_result($query); } $elts = mysql_query("SELECT count(1) FROM categories", $dbh); $count = mysql_result($elts, 0, 0); $result .= "" . htmlentities($msg["nettoyage_reindex_categories"], ENT_QUOTES, $charset) . " {$count} " . htmlentities($msg["nettoyage_res_reindex_categories"], ENT_QUOTES, $charset); //COLLECTIONS $result .= "<h3>" . htmlentities($msg["nettoyage_reindex_collections"], ENT_QUOTES, $charset) . "</h3>"; $query = mysql_query("SELECT collection_id as id, collection_name as collection from collections"); if (mysql_num_rows($query)) { while ($row = mysql_fetch_object($query)) { // constitution des pseudo-indexes $ind_elt = strip_empty_words($row->collection); $req_update = "UPDATE collections "; $req_update .= " SET index_coll=' {$ind_elt} '"; $req_update .= " WHERE collection_id={$row->id} "; $update = mysql_query($req_update); } mysql_free_result($query); } $elts = mysql_query("SELECT count(1) FROM collections", $dbh); $count = mysql_result($elts, 0, 0); $result .= "" . htmlentities($msg["nettoyage_reindex_collections"], ENT_QUOTES, $charset) . " {$count} " . htmlentities($msg["nettoyage_res_reindex_collections"], ENT_QUOTES, $charset); //SOUSCOLLECTIONS $result .= "<h3>" . htmlentities($msg["nettoyage_reindex_sub_collections"], ENT_QUOTES, $charset) . "</h3>"; $query = mysql_query("SELECT sub_coll_id as id, sub_coll_name as sub_collection from sub_collections"); if (mysql_num_rows($query)) { while ($row = mysql_fetch_object($query)) { // constitution des pseudo-indexes $ind_elt = strip_empty_words($row->sub_collection); $req_update = "UPDATE sub_collections "; $req_update .= " SET index_sub_coll=' {$ind_elt} '"; $req_update .= " WHERE sub_coll_id={$row->id} "; $update = mysql_query($req_update); } mysql_free_result($query); } $elts = mysql_query("SELECT count(1) FROM sub_collections", $dbh); $count = mysql_result($elts, 0, 0); $result .= "" . htmlentities($msg["nettoyage_reindex_sub_collections"], ENT_QUOTES, $charset) . " {$count} " . htmlentities($msg["nettoyage_res_reindex_sub_collections"], ENT_QUOTES, $charset); //SERIES $result .= "<h3>" . htmlentities($msg["nettoyage_reindex_series"], ENT_QUOTES, $charset) . "</h3>"; $query = mysql_query("SELECT serie_id as id, serie_name from series LIMIT {$start}, {$lot}"); if (mysql_num_rows($query)) { while ($row = mysql_fetch_object($query)) { // constitution des pseudo-indexes $ind_elt = strip_empty_words($row->serie_name); $req_update = "UPDATE series "; $req_update .= " SET serie_index=' {$ind_elt} '"; $req_update .= " WHERE serie_id={$row->id} "; $update = mysql_query($req_update); } mysql_free_result($query); } $elts = mysql_query("SELECT count(1) FROM series", $dbh); $count = mysql_result($elts, 0, 0); $result .= "" . htmlentities($msg["nettoyage_reindex_series"], ENT_QUOTES, $charset) . " {$count} " . htmlentities($msg["nettoyage_res_reindex_series"], ENT_QUOTES, $charset); //DEWEY $result .= "<h3>" . htmlentities($msg["nettoyage_reindex_indexint"], ENT_QUOTES, $charset) . "</h3>"; $query = mysql_query("SELECT indexint_id as id, concat(indexint_name,' ',indexint_comment) as index_indexint from indexint LIMIT {$start}, {$lot}"); if (mysql_num_rows($query)) { while ($row = mysql_fetch_object($query)) { // constitution des pseudo-indexes $ind_elt = strip_empty_words($row->index_indexint); $req_update = "UPDATE indexint "; $req_update .= " SET index_indexint=' {$ind_elt} '"; $req_update .= " WHERE indexint_id={$row->id} "; $update = mysql_query($req_update); } mysql_free_result($query); } $elts = mysql_query("SELECT count(1) FROM indexint", $dbh); $count = mysql_result($elts, 0, 0); $result .= "" . htmlentities($msg["nettoyage_reindex_indexint"], ENT_QUOTES, $charset) . " {$count} " . htmlentities($msg["nettoyage_res_reindex_indexint"], ENT_QUOTES, $charset); } else { $result .= sprintf($msg["planificateur_rights_bad_user_rights"], $PMBusername); } return $result; }
function cleanRdfStore() { global $msg, $dbh, $charset, $PMBusername; global $class_path; if (SESSrights & ADMINISTRATION_AUTH) { $result .= "<h3>" . htmlentities($msg["nettoyage_rdfstore_reindexation"], ENT_QUOTES, $charset) . "</h3>"; //remise a zero de la table au début pmb_mysql_query("TRUNCATE rdfstore_index", $dbh); $query = "select t.t as num_triple, s.val as subject_uri, p.val as predicat_uri, o.id as num_object, o.val as object_val, l.val as object_lang \n\t\t\t\tfrom rdfstore_triple t, rdfstore_s2val s, rdfstore_id2val p, rdfstore_o2val o, rdfstore_id2val l \n\t\t\t\twhere t.o_type=2 and t.o_lang_dt=l.id and length(l.val)<3 and t.s=s.id and t.p=p.id and t.o=o.id \n\t\t\t\torder by t.t"; $rdfStore = pmb_mysql_query($query, $dbh); if (pmb_mysql_num_rows($rdfStore)) { $op = new ontology_parser("{$class_path}/rdf/skos_pmb.rdf"); $sh = new skos_handler($op); while ($triple = pmb_mysql_fetch_object($rdfStore)) { $type = $sh->op->from_ns($sh->get_object_type($triple->subject_uri)); $q_ins = "insert ignore into rdfstore_index "; $q_ins .= "set num_triple='" . $triple->num_triple . "', "; $q_ins .= "subject_uri='" . addslashes($triple->subject_uri) . "', "; $q_ins .= "subject_type='" . addslashes($type) . "', "; $q_ins .= "predicat_uri='" . addslashes($triple->predicat_uri) . "', "; $q_ins .= "num_object='" . $triple->num_object . "', "; $q_ins .= "object_val ='" . addslashes($triple->object_val) . "', "; $q_ins .= "object_index=' " . strip_empty_chars($triple->object_val) . " ', "; $q_ins .= "object_lang ='" . addslashes($triple->object_lang) . "' "; $r_ins = pmb_mysql_query($q_ins, $dbh); } } $rdfStore = pmb_mysql_query("select count(1) from rdfstore_triple where o_type=2", $dbh); $count = pmb_mysql_result($rdfStore, 0, 0); $result .= $count . " " . htmlentities($msg['nettoyage_rdfstore_reindex_elt'], ENT_QUOTES, $charset); } else { $result .= sprintf($msg["planificateur_rights_bad_user_rights"], $PMBusername); } return $result; }