function get_data() { global $dbh; global $categorie_separator; global $lang; // on récupère les infos de la catégorie $this->thes = thesaurus::getByEltId($this->id); if (categories::exists($this->id, $lang)) { $lg = $lang; } else { $lg = $this->thes->langue_defaut; } $query = "select "; $query .= "categories.libelle_categorie,categories.note_application, categories.comment_public, "; $query .= "noeuds.num_parent, noeuds.num_renvoi_voir "; $query .= "from noeuds, categories "; $query .= "where categories.langue = '" . $lg . "' "; $query .= "and noeuds.id_noeud = '" . $this->id . "' "; $query .= "and noeuds.id_noeud = categories.num_noeud "; $query .= "limit 1"; $result = pmb_mysql_query($query, $dbh); $current = pmb_mysql_fetch_object($result); $this->libelle = $current->libelle_categorie; $this->parent = $current->num_parent; $this->voir = $current->num_renvoi_voir; $this->note = $current->note_application; $this->comment = $current->comment_public; // on regarde si la catégorie à des enfants $query = "select count(1) from noeuds where num_parent = '" . $this->id . "' "; $result = pmb_mysql_query($query, $dbh); $this->has_child = pmb_mysql_result($result, 0, 0); // on regarde si la catégorie à des associées $query = "select count(1) from voir_aussi where num_noeud_orig = '" . $this->id . "' or num_noeud_dest = '" . $this->id . "' "; $result = pmb_mysql_query($query, $dbh); $this->has_child = $this->has_child + pmb_mysql_result($result, 0, 0); // on regarde si la catégorie est utilisée dans des notices $query = "select count(1) from notices_categories where num_noeud = '" . $this->id . "' "; $result = pmb_mysql_query($query, $dbh); $this->has_notices = pmb_mysql_result($result, 0, 0); }
$c = new categories($id, $thes->langue_defaut); $libelle_categorie = $c->libelle_categorie; $note_application = $c->note_application; $commentaire = $c->comment_public; } else { $libelle_categorie = ''; $note_application = ''; $comment_public = ''; } $tab_traductions[$thes->langue_defaut][0] = $lg[$thes->langue_defaut]; $tab_traductions[$thes->langue_defaut][1] = $libelle_categorie; $tab_traductions[$thes->langue_defaut][2] = $note_application; $tab_traductions[$thes->langue_defaut][3] = $commentaire; //Ensuite, on regarde si les categories existent pour les langues de traduction des thesaurus foreach ($lg1 as $key => $value) { if (categories::exists($id, $key)) { $c = new categories($id, $key); $libelle_categorie = $c->libelle_categorie; $note_application = $c->note_application; $commentaire = $c->comment_public; } else { $libelle_categorie = ''; $note_application = ''; $commentaire = ''; } $tab_traductions[$key][0] = $value; $tab_traductions[$key][1] = $libelle_categorie; $tab_traductions[$key][2] = $note_application; $tab_traductions[$key][3] = $commentaire; } //categories langue par defaut thesaurus
$q .= "join categories as catlg on catdef.num_noeud = catlg.num_noeud and catlg.langue = '" . $lang . "' "; $q .= "where 1 "; $q .= "and noeuds.num_thesaurus = '" . $thes->id_thesaurus . "' "; $q .= "and " . $first_clause . " "; $q .= "and ( if (catlg.num_noeud is null, " . $members_catdef['where'] . ", " . $members_catlg['where'] . ") ) "; } $r = mysql_query($q, $dbh); $q = "INSERT INTO catjoin SELECT "; } $q = 'select distinct catjoin.num_noeud, catjoin.* from catjoin ' . $clause . ' ORDER BY pert desc, catjoin.index_categorie ' . $limiter; $found = mysql_query($q, $dbh); while ($mesCategories_trouvees = mysql_fetch_object($found)) { print "<li class='categ_colonne'>"; if ($mesCategories_trouvees->num_renvoi_voir) { // Affichage des renvois_voir if (categories::exists($mesCategories_trouvees->num_renvoi_voir, $lang)) { $lg = $lang; } else { $thes = thesaurus::getByEltId($mesCategories_trouvees->num_noeud); $lg = $thes->langue_defaut; } $q = "select * from noeuds, categories where num_noeud='" . $mesCategories_trouvees->num_renvoi_voir . "' and langue = '" . $lg . "' and noeuds.id_noeud = categories.num_noeud limit 1"; $found_see = mysql_query($q, $dbh); $mesCategories = @mysql_fetch_object($found_see); print pmb_bidi("<b>" . $mesCategories_trouvees->libelle_categorie . "</b> " . $msg['term_show_see'] . " "); } else { $mesCategories = $mesCategories_trouvees; } // Affichage de l'arborescence des renvois voir if ($mesCategories->num_parent) { $bar = categories::listAncestors($mesCategories->num_noeud, $lang);
function getlibelle($num_noeud = 0, $langue = "") { global $dbh; $lib = ""; if (!$num_noeud) { $num_noeud = $this->num_noeud; $langue = $this->langue; } $thes = thesaurus::getByEltId($num_noeud); if (categories::exists($num_noeud, $langue)) { $lg = $langue; } else { $lg = $thes->langue_defaut; } $q = "select libelle_categorie from categories where num_noeud = '" . $num_noeud . "' "; $q .= "and langue = '" . $lg . "' limit 1"; $r = pmb_mysql_query($q, $dbh); if (pmb_mysql_num_rows($r)) { $lib = pmb_mysql_result($r, 0, 0); } return $lib; }
function import_new_notice_suite() { global $id_unimarc, $info_100, $notice_id, $info_606_a, $info_606_9, $info_900; global $suffix, $isbn_OK, $from_file; 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; for ($i = 0; $i < count($info_606_a); $i++) { if (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 == $info_606_a[$i][0]) { //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) { $mon_msg = "Catégorie non reprise car l'identifant n'existe pas dans PMB : " . $info_606_a[$i][0]; mysql_query("insert into error_log (error_origin, error_text) values ('import_" . addslashes(SESSid) . ".inc', '" . addslashes($mon_msg) . "') "); } } } for ($i = 0; $i < count($info_900); $i++) { if (trim($info_900[$i]["a"])) { if (!renseigne_cp($info_900[$i]["n"], $info_900[$i]["a"], $notice_id)) { $mon_msg = "La valeur : " . $info_900[$i]["a"] . " n'a pas été reprise dans le champ personalisé : " . $info_900[$i]["n"] . " car le champ n'existe pas"; mysql_query("insert into error_log (error_origin, error_text) values ('import_" . addslashes(SESSid) . ".inc', '" . addslashes($mon_msg) . "') "); /*echo "Erreur à l'enregistrement du champ perso<br>"; echo "<pre>"; print_r($info_900[$i]); echo "</pre>";*/ } } } }
} // liens entre autorités require_once "{$class_path}/aut_link.class.php"; $aut_link = new aut_link(AUT_TABLE_CATEG, $id); $aut_link->save_form(); global $pmb_map_activate; if ($pmb_map_activate) { $map = new map_edition_controler(AUT_TABLE_CATEG, $id); $map->save_form(); } $aut_pperso = new aut_pperso("categ", $id); $aut_pperso->save_form(); //traitement categories foreach ($lg as $key => $value) { if ($category_libelle[$key] !== NULL) { if ($category_libelle[$key] !== '' || $category_libelle[$key] === '' && categories::exists($id, $key)) { $cat = new categories($id, $key); $cat->libelle_categorie = stripslashes($category_libelle[$key]); $cat->note_application = stripslashes($category_na[$key]); $cat->comment_public = stripslashes($category_cm[$key]); $cat->index_categorie = strip_empty_words($category_libelle[$key]); $cat->save(); } } } if (!noeuds::isProtected($id)) { //Ajout des renvois "voir aussi" $requete = "DELETE FROM voir_aussi WHERE num_noeud_orig=" . $id; pmb_mysql_query($requete); for ($i = 0; $i < $max_categ; $i++) { $categ_id = "f_categ_id" . $i;
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); } } } } }