id = $id+0; $this->is_under_tilde=0; if($this->id) { $this->thes = thesaurus::getByEltId($this->id); } $this->getData(); } // --------------------------------------------------------------- // getData() : récupération des propriétés // --------------------------------------------------------------- public function getData() { global $dbh; global $lang; global $opac_url_base, $use_opac_url_base; global $thesaurus_categories_show_only_last ; // le paramètre pour afficher le chemin complet ou pas $anti_recurse=array(); if(!$this->id) return; $requete = "SELECT noeuds.id_noeud as categ_id, autorite, "; $requete.= "if (catlg.num_noeud is null, catdef.libelle_categorie, catlg.libelle_categorie) as categ_libelle, "; $requete.= "noeuds.num_parent as categ_parent, "; $requete.= "noeuds.num_renvoi_voir as categ_see, "; $requete.= "noeuds.not_use_in_indexation as not_use_in_indexation, "; $requete.= "noeuds.authority_import_denied as authority_import_denied, "; $requete.= "if (catlg.num_noeud is null, catdef.note_application, catlg.note_application) as categ_comment "; $requete.= "FROM noeuds left join categories as catdef on noeuds.id_noeud = catdef.num_noeud and catdef.langue = '".$this->thes->langue_defaut."' "; $requete.= "left join categories as catlg on catdef.num_noeud = catlg.num_noeud and catlg.langue = '".$lang."' "; $requete.= "where noeuds.id_noeud = '".$this->id."' limit 1 "; $result = pmb_mysql_query($requete, $dbh); if(!pmb_mysql_num_rows($result)) return; $data = pmb_mysql_fetch_object($result); $this->id = $data->categ_id; $this->autorite = $data->autorite; $id_top = $this->thes->num_noeud_racine; $this->libelle = $data->categ_libelle; if(preg_match("#^~#",$this->libelle)){ $this->is_under_tilde=1; } $this->commentaire = $data->categ_comment; $this->parent_id = $data->categ_parent; $this->voir_id = $data->categ_see; $this->import_denied = $data->authority_import_denied; $this->not_use_in_indexation = $data->not_use_in_indexation; //$anti_recurse[$this->voir_id]=1; if($this->parent_id != $id_top) $this->has_parent = TRUE; $requete = "SELECT 1 FROM noeuds WHERE num_parent='".$this->id."' limit 1"; $result = @pmb_mysql_query($requete, $dbh); if(pmb_mysql_num_rows($result)) $this->has_child = TRUE; // constitution du chemin $anti_recurse[$this->id]=1; $this->path_table=array(); if ($this->has_parent) { $id_parent=$this->parent_id; do { $requete = "select id_noeud as categ_id, num_noeud, num_parent as categ_parent, libelle_categorie as categ_libelle, num_renvoi_voir as categ_see, note_application as categ_comment,if(langue = '".$lang."',2, if(langue= '".$this->thes->langue_defaut."' ,1,0)) as p FROM noeuds, categories where id_noeud ='".$id_parent."' AND noeuds.id_noeud = categories.num_noeud order by p desc limit 1"; $result=@pmb_mysql_query($requete); if (pmb_mysql_num_rows($result)) { $parent = pmb_mysql_fetch_object($result); if(preg_match("#^~#",$parent->categ_libelle)){ $this->is_under_tilde=1; } $anti_recurse[$parent->categ_id]=1; $this->path_table[] = array( 'id' => $parent->categ_id, 'libelle' => $parent->categ_libelle, 'commentaire' => $parent->categ_comment); $id_parent=$parent->categ_parent; } else { break; } if(!isset($anti_recurse[$parent->categ_parent])) $anti_recurse[$parent->categ_parent] = 0; } while (($parent->categ_parent != $id_top) &&(!$anti_recurse[$parent->categ_parent])); } // ceci remet le tableau dans l'ordre général->particulier $this->path_table = array_reverse($this->path_table); if ($thesaurus_categories_show_only_last) { $this->catalog_form = $this->libelle; // si notre catégorie a un parent, on initie la boucle en le récupérant /* $requete_temp = "SELECT noeuds.id_noeud as categ_id, "; $requete_temp.= "if (catlg.num_noeud is null, catdef.libelle_categorie, catlg.libelle_categorie) as categ_libelle "; $requete_temp.= "FROM noeuds left join categories as catdef on noeuds.id_noeud = catdef.num_noeud and catdef.langue = '".$this->thes->langue_defaut."' "; $requete_temp.= "left join categories as catlg on catdef.num_noeud = catlg.num_noeud and catlg.langue = '".$lang."' "; $requete_temp.= "where noeuds.id_noeud = '".$this->parent_id."' limit 1 "; ER 12/08/2008 NOUVELLE VERSION OPTIMISEE DESSOUS : */ $requete_temp = "select id_noeud as categ_id, num_noeud, num_parent as categ_parent, libelle_categorie as categ_libelle, num_renvoi_voir as categ_see, note_application as categ_comment,if(langue = '".$lang."',2, if(langue= '".$this->thes->langue_defaut."' ,1,0)) as p FROM noeuds, categories where id_noeud ='".$this->parent_id."' AND noeuds.id_noeud = categories.num_noeud order by p desc limit 1"; $result_temp=@pmb_mysql_query($requete_temp); if (pmb_mysql_num_rows($result_temp)) { $parent = pmb_mysql_fetch_object($result_temp); $this->parent_libelle = $parent->categ_libelle ; } else $this->parent_libelle ; } elseif (!empty($this->path_table)) { foreach ($this->path_table as $i => $l) { $temp_table[] = $l['libelle']; } $this->parent_libelle = implode(':', $temp_table); $this->catalog_form = $this->parent_libelle.':'.$this->libelle; } else { $this->catalog_form = $this->libelle; } // Ajoute un lien sur la fiche catégorie si l'utilisateur à accès aux autorités, ou bien en envoi en OPAC. if ($use_opac_url_base) $url_base_lien_aut = $opac_url_base."index.php?&lvl=categ_see&id=" ; else $url_base_lien_aut = static::format_url("&sub=categ_form&id="); if (SESSrights & AUTORITES_AUTH || $use_opac_url_base) $this->isbd_entry_lien_gestion = "".$this->catalog_form.""; else $this->isbd_entry_lien_gestion = $this->catalog_form; //Recherche des termes associés $requete = "select count(1) from categories where num_noeud = '".$this->id."' and langue = '".$lang."' "; $result = pmb_mysql_query($requete, $dbh); if (pmb_mysql_result($result, 0,0) == 0) $lg = $this->thes->langue_defaut ; else $lg = $lang; $requete = "SELECT distinct voir_aussi.num_noeud_dest as categ_assoc_categassoc, "; $requete.= "categories.libelle_categorie as categ_libelle, categories.note_application as categ_comment "; $requete.= "FROM voir_aussi, categories "; $requete.= "WHERE voir_aussi.num_noeud_orig='".$this->id."' "; $requete.= "AND categories.num_noeud=voir_aussi.num_noeud_dest "; $requete.= "AND categories.langue = '".$lg."' "; $result=@pmb_mysql_query($requete,$dbh); while ($ta=pmb_mysql_fetch_object($result)) { //Recherche des renvois réciproques $requete1 = "select count(1) from voir_aussi where num_noeud_orig = '".$ta->categ_assoc_categassoc."' and num_noeud_dest = '".$this->id."' "; if (pmb_mysql_result(pmb_mysql_query($requete1, $dbh), 0, 0)) $rec=1; else $rec=0; $this->associated_terms[] = array( 'id' => $ta->categ_assoc_categassoc, 'libelle' => $ta->categ_libelle, 'commentaire' => $ta->categ_comment, 'rec' => $rec); } } public function build_header_to_export() { global $msg; $data = array( $msg[67], $msg[707], $msg['categ_parent'], $msg['aut_categs_children'], $msg['categ_renvoi'], ); return $data; } public function build_data_to_export() { $listchilds_display = ''; $this->listChilds(); foreach ($this->listchilds as $child) { if ($listchilds_display) $listchilds_display.= '; '; $listchilds_display.= $child['libelle']; } $renvoivoir = $this->get_renvoivoir(); $data = array( $this->libelle, $this->commentaire, $this->parent_libelle, $listchilds_display, $renvoivoir['libelle'], ); return $data; } /** * catégorie parente */ public function get_form_categ_parent() { global $charset; global $form_categ_parent; global $parent; if($this->id) { $p_value = $this->parent_id; $p_libelle = $this->parent_libelle; } else { if($parent) { $pr = new category($parent); $p_value = $pr->id; $p_libelle = $pr->catalog_form; } else { $p_value = 0; $p_libelle = ''; } } $form = $form_categ_parent; $form = str_replace('!!parent_value!!', $p_value, $form); $form = str_replace('!!parent_libelle!!', htmlentities($p_libelle,ENT_QUOTES, $charset), $form); return $form; } /** * renvoi voir */ public function get_renvoivoir() { if ($this->id) { $v_value = $this->voir_id; if ($v_value) { $voir = new category($v_value); $v_libelle = $voir->catalog_form; } else { $v_libelle = ""; } } else { $v_value = 0; $v_libelle = ''; } return array( 'id' => $v_value, 'libelle' => $v_libelle ); } public function get_form_renvoivoir() { global $charset; global $form_renvoivoir; $form = $form_renvoivoir; $data = $this->get_renvoivoir(); $form = str_replace('!!voir_value!!', $data['id'], $form); $form = str_replace('!!voir_libelle!!', htmlentities($data['libelle'],ENT_QUOTES, $charset), $form); return $form; } /** * renvois voir aussi */ public function get_form_renvoivoiraussi() { global $add_see_also; global $form_renvoivoiraussi; global $categ0, $categ_add_button; global $parent; $see_also = array(); if ($this->id) { $see_also = $this->associated_terms; } $categ0_rec = ''; if (empty($see_also)) { $max_categ = 1; $categ0_id = 0; $categ0_lib = ''; } else { $max_categ = count($see_also); $csa = new category($see_also[0]['id']); $categ0_id = $see_also[0]['id']; $categ0_lib = $csa->catalog_form; if (!empty($see_also[0]['rec'])) { $categ0_rec = 'checked'; } } $see_also_form = $add_see_also; $see_also_form .= "\n"; $categ_ = $categ0; $categ_ = str_replace("!!categ_libelle!!", $categ0_lib, $categ_); $categ_ = str_replace("!!categ_id!!", $categ0_id, $categ_); $categ_ = str_replace("!!icateg!!", "0", $categ_); $categ_ = str_replace("!!parent!!", $parent, $categ_); $categ_ = str_replace("!!chk!!", $categ0_rec, $categ_); $categ_sort = []; $categ_sort[$categ0_lib] = $categ_; if (is_array($see_also) && count($see_also)) { for ($i = 1; $i < count($see_also); $i++) { $csa = new category($see_also[$i]['id']); $categ_ = $categ0; $categ_ = str_replace("!!categ_libelle!!", $csa->catalog_form, $categ_); $categ_ = str_replace("!!categ_id!!", $see_also[$i]['id'], $categ_); $categ_ = str_replace("!!icateg!!", $i, $categ_); $categ_ = str_replace("!!parent!!", $parent, $categ_); $categ_rec = "unchecked='unchecked'"; if (!empty($see_also[$i]['rec'])) { $categ_rec = "checked='checked'"; } $categ_ = str_replace("!!chk!!", $categ_rec, $categ_); $categ_sort[$csa->catalog_form] = $categ_; } ksort($categ_sort); } $categ_last_key = array_key_last($categ_sort); $categ_sort[$categ_last_key] = str_replace("!!categ_add_button!!", $categ_add_button, $categ_sort[$categ_last_key]); $first = true; foreach ($categ_sort as $categ_aff) { $categ_aff = str_replace("!!categ_add_button!!", "", $categ_aff); $see_also_form .= $categ_aff."\n"; if ($first) { $see_also_form .= "
'.$this->catalog_form.'
'; //Non utilisisable en indexation $not_use_in_indexation=$this->not_use_in_indexation; //numero autorite $n=new noeuds($this->id); $num_aut=$n->autorite; $authority_statut=$n->num_statut; //import bloqué $import_denied = $n->authority_import_denied; if (noeuds::isProtected($this->id)) { $aff_node_info=false; } else { $aff_node_info=true; } } else { $action = static::format_url("&sub=update&id=".$this->id."&parent=".$parent); $delete_button = ''; $button_voir = ''; $title = $msg[319]; $libelle = ''; $c_form = ''; $not_use_in_indexation = 0; $num_aut=0; $authority_statut=0; $aff_node_info=true; $import_denied = 0; } if ($thesaurus_mode_pmb != 0) { $title.= ' ('.htmlentities($thes->libelle_thesaurus, ENT_QUOTES, $charset).')'; if(!$this->id) { $thesaurus_action = static::format_url("&sub=categ_form&id=".$this->id."&parent=0"); if(strpos($thesaurus_action, '&action=update&') !== false) { $thesaurus_action = str_replace('&action=update&', '&', $thesaurus_action); } $category_form = str_replace('', thesaurus::getSelectorCategoryForm($thes->id_thesaurus, $thesaurus_action, true), $category_form); } else { $category_form = str_replace('', thesaurus::getSelectorCategoryForm($thes->id_thesaurus, '', false), $category_form); } } //Traductions $tab_traductions = array(); //Affichage des boutons de traduction $bt_lib_trad = ''; $bt_cm_trad = ''; $bt_na_trad = ''; if ( count($lg1) > 0 ) { $bt_lib_trad = ""; $bt_cm_trad = ""; $bt_na_trad = ""; } $category_form = str_replace('', $bt_lib_trad, $category_form); $category_form = str_replace('', $bt_cm_trad, $category_form); $category_form = str_replace('', $bt_na_trad, $category_form); //On lit d'abord dans la langue par défaut du thesaurus if (categories::exists($this->id, $thes->langue_defaut)) { $c = new categories($this->id, $thes->langue_defaut); $libelle_categorie = $c->libelle_categorie; $note_application = $c->note_application; $commentaire = $c->comment_public; } else { $libelle_categorie = ''; $note_application = ''; $commentaire = ''; } $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($this->id, $key)) { $c = new categories($this->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 $category_form = str_replace('!!lang_def_cle!!', htmlentities('['.$thes->langue_defaut.']', ENT_QUOTES, $charset), $category_form); $category_form = str_replace('!!lang_def!!', htmlentities(' ('.$tab_traductions[$thes->langue_defaut][0].') ', ENT_QUOTES, $charset), $category_form); $category_form = str_replace('!!lang_def_js!!', ' ('.$tab_traductions[$thes->langue_defaut][0].') ', $category_form); $category_form = str_replace('!!lang_def_libelle!!', htmlentities($tab_traductions[$thes->langue_defaut][1], ENT_QUOTES, $charset), $category_form); $label1 = "\t\n"; $input1 = "\t\n"; //categories langue interface (si dans la liste des langues pour les thesaurus) if ( ($lang != $thes->langue_defaut) && ($lg1[$lang] != '') ) { $c_libelle_trad = $label1.htmlentities($tab_traductions[$lang][0], ENT_QUOTES, $charset).$label2; $c_libelle_trad.= $input1.$lang.$input2.htmlentities($tab_traductions[$lang][1], ENT_QUOTES, $charset).$input3; } else { $c_libelle_trad = ''; } //categories autres langues foreach($tab_traductions as $key=>$value) { if ($key != $thes->langue_defaut && $key != $lang) { $c_libelle_trad.= $label1.htmlentities($tab_traductions[$key][0], ENT_QUOTES, $charset).$label2; $c_libelle_trad.= $input1.$key.$input2.htmlentities($tab_traductions[$key][1], ENT_QUOTES, $charset).$input3; } } $category_form = str_replace('!!c_libelle_trad!!', $c_libelle_trad, $category_form); //Non utilisisable en indexation if($not_use_in_indexation == 1){ $not_use_checked = "checked='checked'"; }else{ $not_use_checked = ""; } $category_form = str_replace('!!not_use_in_indexation!!',$not_use_checked,$category_form); //note d'application langue par defaut thesaurus $category_form = str_replace('!!lang_def_na!!', htmlentities($tab_traductions[$thes->langue_defaut][2], ENT_QUOTES, $charset), $category_form); //commentaire langue par defaut thesaurus $category_form = str_replace('!!lang_def_cm!!', htmlentities($tab_traductions[$thes->langue_defaut][3], ENT_QUOTES, $charset), $category_form); $na_trad = ""; $cm_trad = ""; //note d'application et commentaire en langue de l'interface if ($lang != $thes->langue_defaut) { $na_trad = $traduction_na_tpl; $na_trad = str_replace('!!lang_value!!', htmlentities($tab_traductions[$lang][0], ENT_QUOTES, $charset), $na_trad); $na_trad = str_replace('!!lang!!', $lang, $na_trad); $na_trad = str_replace('!!note_application!!', htmlentities($tab_traductions[$lang][2], ENT_QUOTES, $charset), $na_trad); $cm_trad = $traduction_cm_tpl; $cm_trad = str_replace('!!lang_value!!', htmlentities($tab_traductions[$lang][0], ENT_QUOTES, $charset), $cm_trad); $cm_trad = str_replace('!!lang!!', $lang, $cm_trad); $cm_trad = str_replace('!!commentaire!!', htmlentities($tab_traductions[$lang][3], ENT_QUOTES, $charset), $cm_trad); } //note d'application et commentaire autres langues foreach($tab_traductions as $key=>$value) { if ($key != $thes->langue_defaut && $key != $lang) { $temp_na_trad = $traduction_na_tpl; $temp_na_trad = str_replace('!!lang_value!!', htmlentities($tab_traductions[$key][0], ENT_QUOTES, $charset), $temp_na_trad); $temp_na_trad = str_replace('!!lang!!', $key, $temp_na_trad); $temp_na_trad = str_replace('!!note_application!!', htmlentities($tab_traductions[$key][2], ENT_QUOTES, $charset), $temp_na_trad); $na_trad .= $temp_na_trad; $temp_cm_trad = $traduction_cm_tpl; $temp_cm_trad = str_replace('!!lang_value!!', htmlentities($tab_traductions[$key][0], ENT_QUOTES, $charset), $temp_cm_trad); $temp_cm_trad = str_replace('!!lang!!', $key, $temp_cm_trad); $temp_cm_trad = str_replace('!!commentaire!!', htmlentities($tab_traductions[$key][3], ENT_QUOTES, $charset), $temp_cm_trad); $cm_trad .= $temp_cm_trad; } } $category_form = str_replace('!!na_trad!!', $na_trad, $category_form); $category_form = str_replace('!!cm_trad!!', $cm_trad, $category_form); $category_form = str_replace('!!action!!', $action, $category_form); $category_form = str_replace('!!cancel_action!!', static::format_back_url(), $category_form); $category_form = str_replace('!!id_parent!!', $parent, $category_form); $category_form = str_replace('!!form_title!!', $title, $category_form); $category_form = str_replace('!!category_comment!!', htmlentities($commentaire,ENT_QUOTES, $charset), $category_form); /** * Gestion du selecteur de statut d'autorité */ $category_form = str_replace('!!auth_statut_selector!!', authorities_statuts::get_form_for(AUT_TABLE_CATEG, $authority_statut), $category_form); if ($aff_node_info) { $category_form = str_replace('', $this->get_form_categ_parent(), $category_form); $category_form = str_replace('', $this->get_form_renvoivoir() , $category_form); $category_form=str_replace("",$this->get_form_renvoivoiraussi(),$category_form); //liaisons $category_form=str_replace("", $this->get_form_links(),$category_form); //Numéro d'autorité $form_num_aut=str_replace("!!num_aut!!",$num_aut,$form_num_aut); $category_form=str_replace("",$form_num_aut,$category_form); // Indexation concepts if($thesaurus_concepts_active == 1 ){ $index_concept = new index_concept($this->id, TYPE_CATEGORY); $category_form = str_replace('!!concept_form!!', $index_concept->get_form('categ_form'), $category_form); }else{ $category_form = str_replace('!!concept_form!!', "", $category_form); } if ($tab_traductions[$thes->langue_defaut][1]) { $category_form = str_replace('!!document_title!!', addslashes($tab_traductions[$thes->langue_defaut][1].' - '.$title), $category_form); } else { $category_form = str_replace('!!document_title!!', addslashes($title), $category_form); } if ($this->id) { // Impression de la branche du thésaurus $lien_impression_thesaurus="id."','print'); return false;\">".$msg['print_branche'].""; $category_form=str_replace("",$lien_impression_thesaurus,$category_form); } //Remplacement $button_remplace = "id."&parent=".$parent)."\"'/>"; $category_form = str_replace("", $button_remplace, $category_form); //Suppression $category_form = str_replace('', $delete_button, $category_form); } else { $category_form=str_replace("",$num_aut,$category_form); $category_form = str_replace('!!concept_form!!', "", $category_form); } $authority = new authority(0, $this->id, AUT_TABLE_CATEG); $category_form = str_replace('!!thumbnail_url_form!!', thumbnail::get_form('authority', $authority->get_thumbnail_url()), $category_form); if($import_denied == 1 || !$this->id){ $import_denied_checked = "checked='checked'"; }else{ $import_denied_checked = ""; } $category_form = str_replace('!!authority_import_denied!!',$import_denied_checked,$category_form); $aut_link= new aut_link(AUT_TABLE_CATEG,$this->id); $category_form = str_replace('', $aut_link->get_form('categ_form') , $category_form); global $pmb_map_activate; if($pmb_map_activate){ $map_edition=new map_edition_controler(AUT_TABLE_CATEG,$this->id); $map_form=$map_edition->get_form(); $category_form = str_replace('', $map_form , $category_form); } $aut_pperso= new aut_pperso("categ",$this->id); $category_form = str_replace('!!aut_pperso!!', $aut_pperso->get_form(), $category_form); $category_form = str_replace('!!voir_notices!!', $button_voir, $category_form); if($pmb_type_audit && $this->id) { $bouton_audit= audit::get_dialog_button($this->id, AUDIT_CATEG); } else { $bouton_audit= ""; } $category_form = str_replace('!!audit_bt!!', $bouton_audit, $category_form); $category_form = str_replace('!!user_input!!', htmlentities($user_input,ENT_QUOTES, $charset), $category_form); $category_form = str_replace('!!nbr_lignes!!', $nbr_lignes, $category_form); $category_form = str_replace('!!page!!', $page, $category_form); $category_form = str_replace('!!nb_per_page!!', $nb_per_page_gestion, $category_form); $category_form = str_replace('!!id!!', $this->id, $category_form); $category_form = str_replace('!!parent!!', $parent, $category_form); $category_form = str_replace('!!controller_url_base!!', static::format_url(), $category_form); $category_form = str_replace('!!delete_action!!', static::format_delete_url("&parent=".$parent."&id=".$this->id), $category_form); print $category_form; } public function has_notices() { global $dbh; global $thesaurus_auto_postage_montant,$thesaurus_auto_postage_descendant,$thesaurus_auto_postage_nb_montant,$thesaurus_auto_postage_nb_descendant; global $thesaurus_auto_postage_etendre_recherche,$nb_level_enfants,$nb_level_parents; $thesaurus_auto_postage_descendant = $thesaurus_auto_postage_montant=0; // Autopostage actif if ($thesaurus_auto_postage_descendant || $thesaurus_auto_postage_montant ) { if(!isset($nb_level_enfants)) { // non defini, prise des valeurs par défaut if(isset($_SESSION["nb_level_enfants"]) && $thesaurus_auto_postage_etendre_recherche) $nb_level_descendant=$_SESSION["nb_level_enfants"]; else $nb_level_descendant=$thesaurus_auto_postage_nb_descendant; } else { $nb_level_descendant=$nb_level_enfants; } // lien Etendre auto_postage if(!isset($nb_level_parents)) { // non defini, prise des valeurs par défaut if(isset($_SESSION["nb_level_parents"]) && $thesaurus_auto_postage_etendre_recherche) $nb_level_montant=$_SESSION["nb_level_parents"]; else $nb_level_montant=$thesaurus_auto_postage_nb_montant; } else { $nb_level_montant=$nb_level_parents; } $_SESSION["nb_level_enfants"]= $nb_level_descendant; $_SESSION["nb_level_parents"]= $nb_level_montant; $q = "select path from noeuds where id_noeud = '".$this->id."' "; $r = pmb_mysql_query($q); $path=pmb_mysql_result($r, 0, 0); $nb_pere=substr_count($path,'/'); // Si un path est renseigné et le paramètrage activé if ($path && ($thesaurus_auto_postage_descendant || $thesaurus_auto_postage_montant || $thesaurus_auto_postage_etendre_recherche) && ($nb_level_montant || $nb_level_descendant)){ //Recherche des fils if(($thesaurus_auto_postage_descendant || $thesaurus_auto_postage_etendre_recherche)&& $nb_level_descendant) { if($nb_level_descendant != '*' && is_numeric($nb_level_descendant)) $liste_fils=" path regexp '^$path(\\/[0-9]*){0,$nb_level_descendant}$' "; else $liste_fils=" path regexp '^$path(\\/[0-9]*)*' "; } else { $liste_fils=" id_noeud='".$this->id."' "; } // recherche des pères if(($thesaurus_auto_postage_montant || $thesaurus_auto_postage_etendre_recherche) && $nb_level_montant) { $id_list_pere=explode('/',$path); $stop_pere=0; if($nb_level_montant != '*' && is_numeric($nb_level_montant)) $stop_pere=$nb_pere-$nb_level_montant; for($i=$nb_pere;$i>=$stop_pere; $i--) { $liste_pere.= " or id_noeud='".$id_list_pere[$i]."' "; } } // requete permettant de remonter les notices associées à la liste des catégories trouvées; $suite_req = " FROM noeuds inner join notices_categories on id_noeud=num_noeud inner join notices on notcateg_notice=notice_id WHERE ($liste_fils $liste_pere) and notices_categories.notcateg_notice = notices.notice_id "; } else { // cas normal d'avant $suite_req=" FROM notices_categories, notices WHERE notices_categories.num_noeud = '".$this->id."' and notices_categories.notcateg_notice = notices.notice_id "; } $query ="SELECT COUNT(1) ".$suite_req; } else { // Autopostage désactivé $query ="SELECT COUNT(1) FROM notices_categories WHERE notices_categories.num_noeud='".$this->id."' "; } $result = pmb_mysql_query($query, $dbh); return (pmb_mysql_result($result, 0, 0)); } public function notice_count($include_subcategories=true) { /* * $include_subcategories : Inclue également les notices dans les catégories filles */ $listcontent = array(); if (!$include_subcategories) { $asql = "SELECT notcateg_notice FROM notices_categories WHERE num_noeud = ".$this->id; $ares = pmb_mysql_query($asql); while ($arow=pmb_mysql_fetch_row($ares)) { $listcontent[] = $arow[0]; } $notice_count = count($listcontent); return $notice_count; } else { get_category_notice_count($this->id, $listcontent); $listcontent = array_unique($listcontent); //S'agirait pas d'avoir deux fois la même notice comptée. $notice_count = count($listcontent); return $notice_count; } } public static function get_informations_from_unimarc($fields,$link = false,$code_field="250"){ $data = array(); if(!$link){ $data['label'] = $fields[$code_field][0]['a'][0]; if($fields[$code_field][0]['j']){ for($i=0 ; $i