function create_categ($th, $num_parent, $libelle, $index, $num_aut = '') { //global $thes; $n = new noeuds(); $n->num_thesaurus = $th->id_thesaurus; $n->num_parent = $num_parent; $n->autorite = $num_aut; $n->save(); $c = new categories($n->id_noeud, 'fr_FR'); $c->libelle_categorie = $libelle; $c->index_categorie = $index; $c->save(); return $n->id_noeud; }
static function build_categ($tab_categ, $id_thes, $id_parent, $do_lien = true, $do_create = true) { global $incr_categ, $notice_id, $lang; if (trim($tab_categ)) { $resultat = categories::searchLibelle(addslashes($tab_categ), $id_thes, $lang, $id_parent); if (!$resultat && $id_parent && $do_create) { // création de la catégorie $n = new noeuds(); $n->num_parent = $id_parent; $n->num_thesaurus = $id_thes; $n->save(); $resultat = $id_n = $n->id_noeud; $c = new categories($id_n, $lang); $c->libelle_categorie = $tab_categ; $c->save(); } // ajout de l'indexation à la notice dans la table notices_categories if ($do_lien && $resultat && $notice_id) { $incr_categ++; $rqt_ajout = "insert IGNORE into notices_categories set notcateg_notice='" . $notice_id . "', num_noeud='" . $resultat . "', ordre_categorie='" . $incr_categ . "' "; pmb_mysql_query($rqt_ajout); } return $resultat; } return 0; }
function create_categ($tab_categ, $id_thes, $id_parent, $create_node = true) { global $lang; if (trim($tab_categ)) { $resultat = categories::searchLibelle(addslashes($tab_categ), $id_thes, $lang, $id_parent); if (!$resultat && $id_parent && $create_node) { // création de la catégorie $n = new noeuds(); $n->num_parent = $id_parent; $n->num_thesaurus = $id_thes; $n->save(); $resultat = $id_n = $n->id_noeud; $c = new categories($id_n, $lang); $c->libelle_categorie = $tab_categ; $c->save(); } return $resultat; } return 0; }
function add_categ($term, $id_thesaurus, $non_classes, $lang) { $n = new noeuds(); $n->num_thesaurus = $id_thesaurus; $n->num_parent = $non_classes; $n->save(); $c = new categories($n->id_noeud, $lang); $c->libelle_categorie = $term; $c->index_categorie = ' ' . strip_empty_words($term) . ' '; $c->save(); return $n->id_noeud; }
function import_new_notice_suite() { global $dbh; global $notice_id; global $info_464, $info_676; global $info_606_a, $info_606_x; global $info_900, $info_901, $info_902, $info_200, $info_903, $info_904, $info_910; global $rs, $bl, $dt; global $bulletin_ex; global $m_thess; //si on est en multi-thesaurus if (!$m_thess) { $rqt = "SELECT count(1) FROM thesaurus WHERE active=1"; $m_thess = mysql_result(mysql_query($rqt), 0, 0); } //Cas des périodiques if (is_array($info_464)) { $requete = "SELECT * FROM notices WHERE notice_id={$notice_id}"; $resultat = mysql_query($requete); $r = mysql_fetch_object($resultat); //Notice chapeau existe-t-elle ? $requete = "SELECT notice_id FROM notices WHERE tit1='" . addslashes($info_464[0]['t']) . "' and niveau_hierar='1' and niveau_biblio='s'"; $resultat = mysql_query($requete); if (@mysql_num_rows($resultat)) { //Si oui, récupération id $chapeau_id = mysql_result($resultat, 0, 0); //Mise à jour du champ commentaire de gestion si nécessaire if ($info_903[0]) { $requete = "UPDATE notices SET commentaire_gestion=concat(commentaire_gestion,' ','" . addslashes($info_903[0]) . "') WHERE notice_id={$chapeau_id}"; mysql_query($requete); } //Bulletin existe-t-il ? $requete = "SELECT bulletin_id FROM bulletins WHERE bulletin_numero='" . addslashes($info_464[0]['v']) . "' AND mention_date='" . addslashes($info_464[0]['d']) . "' AND bulletin_notice={$chapeau_id}"; $resultat = mysql_query($requete); if (@mysql_num_rows($resultat)) { //Si oui, récupération id bulletin $bulletin_id = mysql_result($resultat, 0, 0); } else { //Si non, création bulletin $info = array(); $bulletin = new bulletinage("", $chapeau_id); if ($info_464[0]['u']) { $info['bul_titre'] = addslashes($info_464[0]['u']); } else { $info['bul_titre'] = addslashes("Bulletin " . $info_464[0]['v']); } $info['bul_no'] = addslashes($info_464[0]['v']); $info['bul_date'] = addslashes($info_464[0]['d']); if (!$info_464[0]['e']) { if ($info_902[0]) { $info['date_date'] = $info_902[0]; } } else { $info['date_date'] = $info_464[0]['e']; } $bulletin_id = $bulletin->update($info); } } else { //Si non, création notice chapeau et bulletin $chapeau = new serial(); $info = array(); $info['tit1'] = addslashes($info_464[0]['t']); $info['niveau_biblio'] = 's'; $info['niveau_hierar'] = '1'; $info['typdoc'] = $r->typdoc; $chapeau->update($info); $chapeau_id = $chapeau->serial_id; //Mise à jour du champ commentaire de gestion si nécessaire if ($info_903[0]) { $requete = "UPDATE notices SET commentaire_gestion=concat(commentaire_gestion,' ','" . addslashes($info_903[0]) . "') WHERE notice_id={$chapeau_id}"; mysql_query($requete); } $bulletin = new bulletinage("", $chapeau_id); $info = array(); if ($info_464[0]['u']) { $info['bul_titre'] = addslashes($info_464[0]['u']); } else { $info['bul_titre'] = addslashes("Bulletin " . $info_464[0]['v']); } $info['bul_no'] = addslashes($info_464[0]['v']); $info['bul_date'] = addslashes($info_464[0]['d']); if (!$info_464[0]['e']) { if ($info_902[0]) { $info['date_date'] = $info_902[0]; } } else { $info['date_date'] = $info_464[0]['e']; } $bulletin_id = $bulletin->update($info); } //Passage de la notice en article $requete = "UPDATE notices SET niveau_biblio='a', niveau_hierar='2', npages='" . addslashes($info_464[0]['p']) . "' WHERE notice_id={$notice_id}"; mysql_query($requete); $requete = "INSERT INTO analysis (analysis_bulletin,analysis_notice) VALUES({$bulletin_id},{$notice_id})"; mysql_query($requete); $bulletin_ex = $bulletin_id; } else { $bulletin_ex = 0; } //Traitement du thésaurus if ($m_thess > 1) { //on est en multi-thesaurus for ($i = 0; $i < count($info_606_a); $i++) { for ($j = 0; $j < count($info_606_a[$i]); $j++) { $descripteur_tete = $info_606_a[$i][$j]; $descripteur_fils = $info_606_x[$i][$j]; //Recherche du thésaurus $thes_id = trouve_thesaurus($descripteur_tete); //Recherche du terme fils if ($thes_id > 0) { $categ_id_fils = categories::searchLibelle(addslashes(trim($descripteur_fils)), $thes_id, "fr_FR"); if (!$categ_id_fils) { //Création $new_thes = $thes_id == 1 ? 4 : $thes_id; //Choix du thesaurus Candidats descripteurs si descripteur inexistant $categ_id_fils = categories::searchLibelle(addslashes(trim($descripteur_fils)), $new_thes, "fr_FR"); if (!$categ_id_fils) { $noeud = new noeuds(); $noeud->num_thesaurus = $new_thes; $thesau = new thesaurus($new_thes); $noeud->num_parent = $thesau->num_noeud_racine; $noeud->save(); $categ_id_fils = $noeud->id_noeud; //Création du libellé $categ = new categories($noeud->id_noeud, 'fr_FR'); $categ->libelle_categorie = $descripteur_fils; $categ->index_categorie = " " . strip_empty_words($descripteur_fils) . " "; $categ->save(); } } $requete = "INSERT INTO notices_categories (notcateg_notice, num_noeud, ordre_categorie) VALUES ({$notice_id},{$categ_id_fils}, " . ($i + 1) . ")"; mysql_query($requete); } } } //for($i } else { //Traitement du thésaurus unique for ($i = 0; $i < count($info_606_a); $i++) { for ($j = 0; $j < count($info_606_a[$i]); $j++) { $descripteur_tete = $info_606_a[$i][$j]; $descripteur_fils = $info_606_x[$i][$j]; //Recherche du terme de tête //$requete="SELECT num_noeud FROM categories WHERE libelle_categorie='".addslashes($descripteur_tete)."' AND langue='fr_FR'"; $requete = "SELECT id_noeud FROM noeuds WHERE autorite='" . addslashes($descripteur_tete) . "'"; $resultat = mysql_query($requete); if (@mysql_num_rows($resultat)) { //la tête existe ! $categ_id_tete = mysql_result($resultat, 0, 0); } else { //Création de la tête //Nouveau Noeud ! $th = new thesaurus(1); $noeud = new noeuds(); $noeud->num_thesaurus = $th->id_thesaurus; $noeud->num_parent = $th->num_noeud_racine; $noeud->autorite = $descripteur_tete; $noeud->save(); $categ_id_tete = $noeud->id_noeud; //Création du libellé $categ = new categories($noeud->id_noeud, 'fr_FR'); $categ->libelle_categorie = $descripteur_tete; $categ->index_categorie = " " . strip_empty_words($descripteur_tete) . " "; $categ->save(); } //Recherche du terme fils $categ_id_fils = categories::searchLibelle(addslashes($descripteur_fils), 1, "fr_FR"); if (!$categ_id_fils) { //Création $noeud = new noeuds(); $noeud->num_thesaurus = 1; $noeud->num_parent = $categ_id_tete; $noeud->save(); $categ_id_fils = $noeud->id_noeud; //Création du libellé $categ = new categories($noeud->id_noeud, 'fr_FR'); $categ->libelle_categorie = $descripteur_fils; $categ->index_categorie = " " . strip_empty_words($descripteur_fils) . " "; $categ->save(); } $requete = "INSERT INTO notices_categories (notcateg_notice, num_noeud, ordre_categorie) VALUES ({$notice_id}, {$categ_id_fils}, " . ($i + 1) . ")"; mysql_query($requete); } } } //Indexation décimale if ($info_676[0]) { $requete = "select indexint_id from indexint where indexint_name='" . addslashes($info_676[0]) . "'"; $resultat = mysql_query($requete); if (mysql_num_rows($resultat)) { $indexint = mysql_result($resultat, 0, 0); } else { $requete = "insert into indexint (indexint_name) values('" . addslashes($info_676[0]) . "')"; mysql_query($requete); $indexint = mysql_insert_id(); } $requete = "update notices set indexint=" . $indexint . " where notice_id=" . $notice_id; mysql_query($requete); } //Organisme if ($info_900[0]) { $no_champ = trouve_champ_perso("op"); if ($no_champ > 0) { $requete = "SELECT max(notices_custom_list_value*1) FROM notices_custom_lists WHERE notices_custom_champ=" . $no_champ; $resultat = mysql_query($requete); $max = @mysql_result($resultat, 0, 0); $n = $max + 1; $requete = "SELECT notices_custom_list_value FROM notices_custom_lists WHERE notices_custom_list_lib='" . addslashes($info_900[0]) . "' AND notices_custom_champ=" . $no_champ; $resultat = mysql_query($requete); if (mysql_num_rows($resultat)) { $value = mysql_result($resultat, 0, 0); } else { $requete = "INSERT INTO notices_custom_lists (notices_custom_champ,notices_custom_list_value,notices_custom_list_lib) VALUES({$no_champ},{$n},'" . addslashes($info_900[0]) . "')"; mysql_query($requete); $value = $n; $n++; } $requete = "INSERT INTO notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) VALUES({$no_champ},{$notice_id},{$value})"; mysql_query($requete); } } //Genre if ($info_901[0]) { $no_champ = trouve_champ_perso("gen"); if ($no_champ > 0) { $requete = "SELECT max(notices_custom_list_value*1) FROM notices_custom_lists WHERE notices_custom_champ=" . $no_champ; $resultat = mysql_query($requete); $max = @mysql_result($resultat, 0, 0); $n = $max + 1; $requete = "SELECT notices_custom_list_value FROM notices_custom_lists WHERE notices_custom_list_lib='" . addslashes($info_901[0]) . "' AND notices_custom_champ=" . $no_champ; $resultat = mysql_query($requete); if (mysql_num_rows($resultat)) { $value = mysql_result($resultat, 0, 0); } else { $requete = "INSERT INTO notices_custom_lists (notices_custom_champ,notices_custom_list_value,notices_custom_list_lib) VALUES({$no_champ},{$n},'" . addslashes($info_901[0]) . "')"; mysql_query($requete); $value = $n; $n++; } $requete = "INSERT INTO notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) VALUES({$no_champ},{$notice_id},{$value})"; mysql_query($requete); } } //Type de texte if (count($info_904)) { $no_champ = trouve_champ_perso("typtext"); if ($no_champ > 0) { for ($i = 0; $i < count($info_904); $i++) { for ($j = 0; $j < count($info_904[$i]); $j++) { $requete = "SELECT max(notices_custom_list_value*1) FROM notices_custom_lists WHERE notices_custom_champ=" . $no_champ; $resultat = mysql_query($requete); $max = @mysql_result($resultat, 0, 0); $n = $max + 1; $requete = "SELECT notices_custom_list_value FROM notices_custom_lists WHERE notices_custom_list_lib='" . addslashes($info_904[$i][$j]) . "' AND notices_custom_champ=" . $no_champ; $resultat = mysql_query($requete); if (mysql_num_rows($resultat)) { $value = mysql_result($resultat, 0, 0); } else { $requete = "INSERT INTO notices_custom_lists (notices_custom_champ,notices_custom_list_value,notices_custom_list_lib) VALUES({$no_champ},{$n},'" . addslashes($info_904[$i][$j]) . "')"; mysql_query($requete); $value = $n; $n++; } $requete = "INSERT INTO notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_integer) VALUES({$no_champ},{$notice_id},{$value})"; mysql_query($requete); } } } } //Date de saisie if ($info_902[0]) { $no_champ = trouve_champ_perso("ds"); if ($no_champ > 0) { $requete = "INSERT INTO notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_date) VALUES({$no_champ},{$notice_id},'" . str_replace(".", "-", $info_902[0]) . "')"; mysql_query($requete); } } //N° de lot if ($info_903[0]) { $requete = "UPDATE notices SET commentaire_gestion='" . addslashes($info_903[0]) . "' WHERE notice_id={$notice_id}"; mysql_query($requete); } //Cas de la mise à jour des périodiques ou du champ bord (notices chapeau) if ($bl == "s") { //Si c'est un périodique if ($dt == "a") { //Passage de la notice en notice chapeau $requete = "UPDATE notices SET niveau_biblio='s', niveau_hierar='1' WHERE notice_id={$notice_id}"; mysql_query($requete); //Recherche si la notice existe déjà par rapport au titre $requete = "select notice_id FROM notices WHERE ucase(tit1)='" . addslashes(strtoupper($info_200[0])) . "' AND niveau_biblio='s' AND niveau_hierar='1' AND notice_id!={$notice_id}"; $resultat = mysql_query($requete); $update = false; if (mysql_num_rows($resultat)) { $update = true; $n_update = mysql_result($resultat, 0, 0); //Mise à jour de tous les bulletins $requete = "UPDATE bulletins SET bulletin_notice=" . $notice_id . " WHERE bulletin_notice=" . $n_update; mysql_query($requete); //Suppression de l'ancienne notice $requete = "DELETE FROM notices WHERE notice_id={$n_update}"; mysql_query($requete); $requete = "DELETE FROM notices_categories WHERE notcateg_notice=" . $n_update; mysql_query($requete); $requete = "DELETE FROM notices_custom_values WHERE notices_custom_origine=" . $n_update; mysql_query($requete); $requete = "DELETE FROM responsability WHERE responsability_author=" . $n_update; mysql_query($requete); } if (!$update && $rs != "n") { //Si il n'y a pas de création, on supprime la notice $requete = "DELETE FROM notices WHERE notice_id={$notice_id}"; mysql_query($requete); $requete = "DELETE FROM notices_categories WHERE notcateg_notice=" . $notice_id; mysql_query($requete); $requete = "DELETE FROM notices_custom_values WHERE notices_custom_origine=" . $notice_id; mysql_query($requete); $requete = "DELETE FROM responsability WHERE responsability_author=" . $notice_id; mysql_query($requete); } } else { if ($dt == "l") { //Recherche si la notice existe déjà par rapport au titre $requete = "select notice_id FROM notices WHERE ucase(tit1)='" . addslashes(strtoupper($info_200[0])) . "' AND typdoc='l' AND notice_id!={$notice_id}"; $resultat = mysql_query($requete); $update = false; if (mysql_num_rows($resultat)) { $update = true; $n_update = mysql_result($resultat, 0, 0); //Suppression de l'ancienne notice $requete = "DELETE FROM notices WHERE notice_id={$n_update}"; mysql_query($requete); $requete = "DELETE FROM notices_categories WHERE notcateg_notice=" . $n_update; mysql_query($requete); $requete = "DELETE FROM notices_custom_values WHERE notices_custom_origine=" . $n_update; mysql_query($requete); $requete = "DELETE FROM responsability WHERE responsability_author=" . $n_update; mysql_query($requete); } } else { if ($dt == "r") { //Mise à jour du champ bord if ($info_910[0]) { $no_champ = trouve_champ_perso("bord"); if ($no_champ > 0) { //Recherche si la notice existe déjà par rapport au titre $requete = "SELECT notice_id FROM notices WHERE ucase(tit1)='" . addslashes(strtoupper($info_200[0])) . "' AND niveau_biblio='s' AND niveau_hierar='1' AND notice_id!={$notice_id}"; $resultat = mysql_query($requete); if (mysql_num_rows($resultat)) { $notice_update = mysql_result($resultat, 0, 0); $requete = "UPDATE notices_custom_values SET notices_custom_text='" . addslashes(str_replace("##", "\n", $info_910[0])) . "' WHERE notices_custom_champ={$no_champ} AND notices_custom_origine=" . $notice_update; mysql_query($requete); if (!mysql_affected_rows()) { $requete = "INSERT INTO notices_custom_values (notices_custom_champ,notices_custom_origine,notices_custom_text) VALUES({$no_champ},{$notice_update},'" . addslashes(str_replace("##", "\n", $info_910[0])) . "')"; mysql_query($requete); } } } } //Suppression de la nouvelle notice $requete = "DELETE FROM notices WHERE notice_id=" . $notice_id; mysql_query($requete); } } } } }
$id_thes = thesaurus::getSessionThesaurusId(); } thesaurus::setSessionThesaurusId($id_thes); break; } $thes = new thesaurus($id_thes); if ($aj == 'add' && SESSrights & THESAURUS_AUTH) { // on arrive du formulaire d'ajout à la volée if (!strlen($category_parent)) { $category_parent_id = $thes->num_noeud_racine; } $category_voir_id = 0; $noeud = new noeuds(); $noeud->num_parent = $category_parent_id; $noeud->num_thesaurus = $thes->id_thesaurus; $noeud->save(); $cat = new categories($noeud->id_noeud, $thes->langue_defaut); $cat->libelle_categorie = stripslashes($category_libelle); $cat->note_application = stripslashes($category_comment); $cat->index_categorie = " " . strip_empty_words($cat->libelle_categorie) . " "; $cat->save(); if ($thesaurus_mode_pmb && $caller == 'notice') { $nom_tesaurus = '[' . $thes->getLibelle() . '] '; } else { $nom_tesaurus = ''; } $browser_content = "<a href='#' {$java_comment} onclick=\"set_parent('{$caller}', '{$noeud->id_noeud}', '" . htmlentities(addslashes($nom_tesaurus . $cat->libelle_categorie), ENT_QUOTES, $charset) . "','{$callback}','" . $cat->num_thesaurus . "')\">"; $browser_content .= $cat->libelle_categorie; $browser_content .= "</a>"; } // nombre de références par pages
function create_categ_cpt_rameau_first_level($num_parent, $libelle, $index) { global $thes; $n = new noeuds(); $n->num_thesaurus = $thes->id_thesaurus; $n->num_parent = $num_parent; $n->save(); $c = new categories($n->id_noeud, 'fr_FR'); $c->libelle_categorie = $libelle; $c->index_categorie = $index; $c->save(); return $n->id_noeud; }
function do_thesaurus_ascodocpsy($id_thesaurus, $nom_categ, $branch_values = array(), $lang = 'fr_FR', $ordre_categ = 0) { global $notice_id; $res = pmb_mysql_query("select id_noeud from noeuds where autorite='TOP' and num_thesaurus='" . $id_thesaurus . "'"); if ($res && pmb_mysql_num_rows($res)) { $parent_thes = pmb_mysql_result($res, 0, 0); } else { return; } $rqt = "select id_noeud from noeuds join categories on id_noeud=num_noeud and libelle_categorie='" . $nom_categ . "' and num_parent='" . $parent_thes . "'"; $res = pmb_mysql_query($rqt); if ($res && pmb_mysql_num_rows($res)) { $num_parent = pmb_mysql_result($res, 0, 0); foreach ($branch_values as $terms) { foreach ($terms as $term) { $categ_id = categories::searchLibelle(addslashes($term), $id_thesaurus, $lang, $num_parent); if ($categ_id) { //le terme existe $noeud = new noeuds($categ_id); if ($noeud->num_renvoi_voir) { $categ_to_index = $noeud->num_renvoi_voir; } else { $categ_to_index = $categ_id; } } else { //le terme est à créé $n = new noeuds(); $n->num_thesaurus = $id_thesaurus; $n->num_parent = $num_parent; $n->save(); $c = new categories($n->id_noeud, $lang); $c->libelle_categorie = $term; $c->index_categorie = ' ' . strip_empty_words($term) . ' '; $c->save(); $categ_to_index = $n->id_noeud; } $requete = "INSERT INTO notices_categories (notcateg_notice,num_noeud,ordre_categorie) VALUES({$notice_id},{$categ_to_index},{$ordre_categ})"; pmb_mysql_query($requete); $ordre_categ++; } } } }
function import_new_notice_suite() { global $info_461, $info_463, $info_530; global $info_900, $info_901, $tit_200a; global $info_215, $titre_ppal_200, $champ_210, $titre_perio_530a; global $info_606_a, $info_897; global $notice_id; global $bull_id; global $bl, $hl; echo "<pre>"; $bull_id = 0; //cas d'un article if ($bl == "a" && $hl == "2") { //on peut pas découper une date, on a pas de date mais une mention if (decoupe_date($info_463[0]["d"]) == 0 && clean_string($info_463[0]["e"]) == "") { $info_463[0]["e"] = $info_463[0]["d"]; $info_463[0]["d"] = ""; } $bulletin = array('titre' => clean_string($info_463[0]["t"]), 'date' => decoupe_date($info_463[0]["d"]), 'mention' => clean_string($info_463[0]["e"]), 'num' => clean_string($info_463[0]["v"])); $perio = array('titre' => $info_461[0]['t'], 'code' => $info_461[0]['x']); notice_to_article($perio, $bulletin); $update = " update notices set typdoc='t' where notice_id = {$notice_id}"; mysql_query($update); //cas d'un bulletin } else { if ($bl == "s" && $hl == "2") { if (decoupe_date($champ_210[0]['h']) == 0 && clean_string($titre_ppal_200[0]['h']) == "") { $titre_ppal_200[0]['h'] = $champ_210[0]['h']; $champ_210[0]['h'] = ""; } $bulletin = array('titre' => clean_string($titre_ppal_200[0]['i']), 'date' => decoupe_date($champ_210[0]['h']), 'mention' => clean_string($champ_210[0]['d']), 'num' => clean_string($titre_ppal_200[0]['h'])); $perio = array('titre' => $info_461[0]['t'], 'code' => $info_461[0]['x']); $bull_id = genere_bulletin($perio, $bulletin); $update = " update notices set typdoc='t' where notice_id = {$notice_id}"; mysql_query($update); } } //on s'occupe des descripteurs; $id_thesaurus = 1; $non_classes = 3; $lang = "fr_FR"; $ordre_categ = 0; foreach ($info_606_a as $terms) { foreach ($terms as $term) { $categ_id = categories::searchLibelle(addslashes($term), $id_thesaurus, $lang); if ($categ_id) { //le terme existe $noeud = new noeuds($categ_id); if ($noeud->num_renvoi_voir) { $categ_to_index = $noeud->num_renvoi_voir; } else { $categ_to_index = $categ_id; } } else { //le terme est à créé $n = new noeuds(); $n->num_thesaurus = $id_thesaurus; $n->num_parent = $non_classes; $n->save(); $c = new categories($n->id_noeud, $lang); $c->libelle_categorie = $term; $c->index_categorie = ' ' . strip_empty_words($term) . ' '; $c->save(); $categ_to_index = $n->id_noeud; } $requete = "INSERT INTO notices_categories (notcateg_notice,num_noeud,ordre_categorie) VALUES({$notice_id},{$categ_to_index},{$ordre_categ})"; mysql_query($requete); $ordre_categ++; } } //on traite le commentaire de gestion $up = "update notices set commentaire_gestion = '" . addslashes($info_901[0][0]) . "' where notice_id = {$notice_id}"; mysql_query($up); //traitement des Champs perso //classique on commence par cherché l'id foreach ($info_900 as $champperso) { $champ = array('libelle' => $champperso['l'], 'nom' => $champperso['n'], 'value' => $champperso['a']); recup_champ_perso($champ, "notices", $notice_id); } //gestion des 897$... foreach ($info_897 as $docnum) { //si on a pas d'url, on traite pas if ($docnum['u']) { //on reprend pas les site web... if ($docnum['m'] != "text/html") { $doc = array('titre' => clean_string($docnum['a']), 'mimetype' => $docnum['m'], 'nom_fic' => clean_string($docnum['f']), 'url' => $docnum['u']); create_docnum($doc); } } } echo "</pre>"; }
function save() { global $dbh; global $msg; if ($this->libelle_thesaurus == '') { die("Erreur de création thésaurus"); } if ($this->langue_defaut == '') { $this->langue_defaut = 'fr_FR'; } if ($this->id_thesaurus) { //mise à jour thesaurus $q = "update thesaurus set libelle_thesaurus = '" . $this->libelle_thesaurus . "' "; $q .= ", active = '" . $this->active . "' "; $q .= ", opac_active = '" . $this->opac_active . "' "; $q .= ", langue_defaut = '" . $this->langue_defaut . "' "; $q .= "where id_thesaurus = '" . $this->id_thesaurus . "' "; $r = pmb_mysql_query($q, $dbh); } else { //création thesaurus $q = "insert into thesaurus set libelle_thesaurus = '" . $this->libelle_thesaurus . "', active = '1', opac_active = '1', langue_defaut = '" . $this->langue_defaut . "' "; $r = pmb_mysql_query($q, $dbh); $this->id_thesaurus = pmb_mysql_insert_id($dbh); //creation noeud racine $noeud = new noeuds(); $noeud->autorite = 'TOP'; $noeud->num_parent = 0; $noeud->num_renvoi_voir = 0; $noeud->visible = '0'; $noeud->num_thesaurus = $this->id_thesaurus; $noeud->save(); $this->num_noeud_racine = $noeud->id_noeud; //rattachement noeud racine au thesaurus $q = "update thesaurus set num_noeud_racine = '" . $this->num_noeud_racine . "' "; $q .= "where id_thesaurus = '" . $this->id_thesaurus . "' "; $r = pmb_mysql_query($q, $dbh); //creation noeud orphelins $noeud = new noeuds(); $noeud->autorite = 'ORPHELINS'; $noeud->num_parent = $this->num_noeud_racine; $noeud->num_renvoi_voir = 0; $noeud->visible = '0'; $noeud->num_thesaurus = $this->id_thesaurus; $noeud->save(); $this->num_noeud_orphelins = $noeud->id_noeud; //Creation catégorie orphelins langue par défaut $categ = new categories($this->num_noeud_orphelins, $this->langue_defaut); $categ->libelle_categorie = $msg["thes_orphelins"]; $categ->save(); //creation noeud non classes; $noeud = new noeuds(); $noeud->autorite = 'NONCLASSES'; $noeud->num_parent = $this->num_noeud_racine; $noeud->num_renvoi_voir = 0; $noeud->visible = '0'; $noeud->num_thesaurus = $this->id_thesaurus; $noeud->save(); $this->num_noeud_nonclasses = $noeud->id_noeud; //Creation catégorie non classes langue par défaut $categ = new categories($this->num_noeud_nonclasses, $this->langue_defaut); $categ->libelle_categorie = $msg["thes_non_classes"]; $categ->save(); } }
function update($data, $id_thesaurus, $num_parent, $lang) { $lang = strtolower($lang); switch ($lang) { case "fr": case "fre": case "français": case "francais": case "french": $lang = "fr_FR"; break; default: $lang = "fr_FR"; break; } if ($data['label'] == "") { return 0; } if ($num_parent) { //Le noeud parent doit être dans le même thésaurus $req = "SELECT id_noeud FROM noeuds WHERE id_noeud='" . $num_parent . "' AND num_thesaurus='" . $id_thesaurus . "'"; $res = pmb_mysql_query($req); if ($res && !pmb_mysql_num_rows($res)) { return 0; } } if ($this->id == 0) { $query = "select * from thesaurus where id_thesaurus = " . $id_thesaurus; $result = pmb_mysql_query($query); if (pmb_mysql_num_rows($result)) { $row = pmb_mysql_fetch_object($result); //création $n = new noeuds(); $n->num_parent = $num_parent != 0 ? $num_parent : $row->num_noeud_racine; $n->num_thesaurus = $id_thesaurus; $n->save(); $id = $n->id_noeud; $c = new categories($id, $lang); $c->libelle_categorie = $data['label']; $c->note_application = $data['note']; $c->comment_public = $data['comment']; $c->save(); $this->id = $c->num_noeud; return 1; } } else { $c = new categories($this->id, $lang); $c->libelle_categorie = $data['label']; $c->note_application = $data['note']; $c->comment_public = $data['comment']; $c->save(); return 1; } }
function import_new_notice_suite() { global $id_unimarc, $info_100, $notice_id, $info_606_a, $info_606_9, $info_900, $info_950, $info_951; global $suffix, $isbn_OK, $from_file, $thesaurus_defaut; global $bibliographic_level, $hierarchic_level; if (trim($info_100[0])) { $date = decoupe_date(substr($info_100[0], 0, 8)); $requete = "update notices set create_date = '" . addslashes($date) . "' where notice_id='" . $notice_id . "' "; mysql_query($requete); /*if(!mysql_query($requete)){ echo "requete echoué : ".$requete."<br>"; }*/ } $incr_categ = 0; if (count($info_606_a)) { $thes = new thesaurus($thesaurus_defaut); for ($i = 0; $i < count($info_606_a); $i++) { if ($libelle = trim($info_606_a[$i][0])) { //echo "ici : ".$info_606[$i]["a"]."<br>"; $trouve = false; $id_noeud = 0; foreach ($info_606_9[$i] as $value) { if (preg_match("/^id:([0-9]+)\$/", $value, $matches)) { $id_noeud = $matches[1]; break; } } if ($id_noeud) { if (categories::exists($id_noeud, "fr_FR")) { //echo "la : ".$info_606[$i]["a"]."<br>"; $categ = new categories($id_noeud, "fr_FR"); if ($categ->libelle_categorie == $libelle) { //echo "ou la : ".$info_606[$i]["a"]."<br>"; // ajout de l'indexation à la notice dans la table notices_categories $rqt_ajout = "insert into notices_categories set notcateg_notice='" . $notice_id . "', num_noeud='" . $categ->num_noeud . "', ordre_categorie='" . $incr_categ . "' "; $res_ajout = @mysql_query($rqt_ajout); $incr_categ++; $trouve = true; } } } if (!$trouve) { //Je regarde si il y a une autre catégorie avec ce libellé dans les thésaurus $q = "SELECT id_noeud from noeuds JOIN categories ON noeuds.id_noeud = categories.num_noeud WHERE categories.libelle_categorie = '" . addslashes($libelle) . "'"; $res = mysql_query($q); if ($res) { if (mysql_num_rows($res) == 1) { $rqt_ajout = "insert into notices_categories set notcateg_notice='" . $notice_id . "', num_noeud='" . mysql_result($res, 0, 0) . "', ordre_categorie='" . $incr_categ . "' "; $res_ajout = @mysql_query($rqt_ajout); $incr_categ++; } elseif (mysql_num_rows($res) > 1) { $mon_msg = "Catégorie non reprise car elle est présente plusieurs fois dans les thésaurus de PMB: " . $libelle; affiche_mes_erreurs($mon_msg); } else { $n = new noeuds(); $n->num_parent = $thes->num_noeud_racine; $n->num_thesaurus = $thesaurus_defaut; $n->save(); $resultat = $id_n = $n->id_noeud; $c = new categories($id_n, $thes->langue_defaut); $c->libelle_categorie = $libelle; $c->save(); $rqt_ajout = "insert into notices_categories set notcateg_notice='" . $notice_id . "', num_noeud='" . $id_n . "', ordre_categorie='" . $incr_categ . "' "; $res_ajout = @mysql_query($rqt_ajout); $incr_categ++; $mon_msg = "Catégorie créée à la racine du thésaurus par défaut: " . $libelle; affiche_mes_erreurs($mon_msg); } } } } } } if ($bibliographic_level == "s" && $hierarchic_level == "1" && count($info_950)) { foreach ($info_950 as $value) { //Emplacement if (!$value["c"]) { $mon_msg = "Etat de collection non importé car pas d'emplacement pour le périodique: " . $id_unimarc; affiche_mes_erreurs($mon_msg); continue; } $requete = "SELECT archempla_id FROM arch_emplacement WHERE archempla_libelle='" . addslashes($value["c"]) . "'"; $res = mysql_query($requete); if (mysql_num_rows($res)) { $id_empl = mysql_result($res, 0, 0); } else { $requete = "INSERT INTO arch_emplacement(archempla_libelle) VALUES('" . addslashes($value["c"]) . "')"; if (!mysql_query($requete)) { $mon_msg = "Etat de collection non importé problème avec la requête: " . $requete; affiche_mes_erreurs($mon_msg); continue; } else { $id_empl = mysql_insert_id(); } } //Statut if (!$value["h"] && !$value["k"]) { $mon_msg = "Etat de collection non importé car pas de statut pour le périodique: " . $id_unimarc; affiche_mes_erreurs($mon_msg); continue; } $requete = "SELECT archstatut_id FROM arch_statut WHERE archstatut_gestion_libelle='" . addslashes($value["k"]) . "' AND archstatut_opac_libelle='" . addslashes($value["h"]) . "'"; $res = mysql_query($requete); if (mysql_num_rows($res)) { $id_statut = mysql_result($res, 0, 0); } else { $requete = "INSERT INTO arch_statut(archstatut_gestion_libelle,archstatut_opac_libelle) VALUES('" . addslashes($value["k"]) . "','" . addslashes($value["h"]) . "')"; if (!mysql_query($requete)) { $mon_msg = "Etat de collection non importé problème avec la requête: " . $requete; affiche_mes_erreurs($mon_msg); continue; } else { $id_statut = mysql_insert_id(); } } //Support if (!$value["d"]) { $mon_msg = "Etat de collection non importé car pas de support pour le périodique: " . $id_unimarc; affiche_mes_erreurs($mon_msg); continue; } $requete = "SELECT archtype_id FROM arch_type WHERE archtype_libelle='" . addslashes($value["d"]) . "'"; $res = mysql_query($requete); if (mysql_num_rows($res)) { $id_support = mysql_result($res, 0, 0); } else { $requete = "INSERT INTO arch_type(archtype_libelle) VALUES('" . addslashes($value["d"]) . "')"; if (!mysql_query($requete)) { $mon_msg = "Etat de collection non importé problème avec la requête: " . $requete; affiche_mes_erreurs($mon_msg); continue; } else { $id_support = mysql_insert_id(); } } //Localisation if (!$value["a"]) { $mon_msg = "Etat de collection non importé car pas de localisation pour le périodique: " . $id_unimarc; affiche_mes_erreurs($mon_msg); continue; } $requete = "SELECT idlocation FROM docs_location WHERE location_libelle='" . addslashes($value["a"]) . "'"; $res = mysql_query($requete); if (mysql_num_rows($res)) { $id_loc = mysql_result($res, 0, 0); } else { $requete = "INSERT INTO docs_location(location_libelle) VALUES('" . addslashes($value["a"]) . "')"; if (!mysql_query($requete)) { $mon_msg = "Etat de collection non importé problème avec la requête: " . $requete; affiche_mes_erreurs($mon_msg); continue; } else { $id_loc = mysql_insert_id(); } } $stat = $value["b"]; $cote = $value["f"]; $archive = $value["g"]; $origine = $value["e"]; $note = $value["j"]; $lacune = $value["i"]; $requete = "insert into collections_state(id_serial,location_id,state_collections,collstate_emplacement,collstate_type,collstate_origine,collstate_cote,collstate_archive,collstate_statut,collstate_lacune,collstate_note) values (" . "'" . $notice_id . "','" . $id_loc . "','" . addslashes($stat) . "','" . $id_empl . "','" . $id_support . "','" . addslashes($origine) . "','" . addslashes($cote) . "','" . addslashes($archive) . "','" . $id_statut . "','" . addslashes($lacune) . "','" . addslashes($note) . "'" . ")"; if (!mysql_query($requete)) { $mon_msg = "Etat de collection non importé problème avec la requete: " . $requete; affiche_mes_erreurs($mon_msg); continue; } else { $id_coll_stat = mysql_insert_id(); if (count($info_951)) { foreach ($info_951 as $cle => $val) { if ($val["f"] == $id_coll_stat) { //Je suis bien sur un cp de cet exemplaire if (!renseigne_cp($val, $id_coll_stat, "collstate")) { $mon_msg = "La valeur : " . $value["a"] . " n'a pas été reprise dans le champ personnalisé : " . $value["n"] . " car le champ n'existe pas"; affiche_mes_erreurs($mon_msg); } else { unset($info_951[$cle]); } } } } } } } if (count($info_900)) { for ($i = 0; $i < count($info_900); $i++) { if (trim($info_900[$i]["a"])) { if (!renseigne_cp($info_900[$i], $notice_id)) { $mon_msg = "La valeur : " . $info_900[$i]["a"] . " n'a pas été reprise dans le champ personnalisé : " . $info_900[$i]["n"] . " car le champ n'existe pas ou n'est pas défini de la même façon"; affiche_mes_erreurs($mon_msg); } } } } }