".$msg[print_thes_title]."\n"; print "
".$msh[print_thes_options]."
".$msg[print_thes_list_type]."
 ".$msg[print_thes_na]."
 ".$msg[print_thes_comment]."
 ".$msg[print_thes_voir]."
 ".$msg[print_thes_ta]."
 ".$msg[print_thes_tg]."
 ".$msg[print_thes_ts]."
".$msg["print_output_title"]."
 ".$msg["print_output_printer"]."
 ".$msg["print_output_writer"]."
 
"; print ""; } $rqlang = "select langue_defaut from thesaurus where id_thesaurus=".$aff_num_thesaurus ; $reslang = mysql_query($rqlang) or die("
Query 'langue_defaut' failed ".mysql_error()."
".$rqlang); $objlang = mysql_fetch_object($reslang); if ($objlang->langue_defaut) $aff_langue = $objlang->langue_defaut; else $aff_langue ="fr_FR"; if ($action=="print") { if ($output=="tt") { header("Content-Type: application/word"); header("Content-Disposition: attachement; filename=thesaurus.doc"); } print ""; print "

".$msg["print_thes_titre_".$typeimpression]."

"; switch($typeimpression) { case "arbo": $res.=" "; if ($id_noeud_origine) { // un noeud était fourni pour n'imprimer que cette branche $id_noeud_top = $id_noeud_origine ; } else { $rqt_id_noeud_top = "select id_noeud from noeuds where autorite='TOP' and num_thesaurus=".$aff_num_thesaurus ; $result_rqt_id_noeud_top = mysql_query($rqt_id_noeud_top) or die("Query 'TOP' failed"); $obj_id_noeud_top = mysql_fetch_object($result_rqt_id_noeud_top); $id_noeud_top = $obj_id_noeud_top->id_noeud; } // premier parcours pour calculer la profondeur du thésaurus : $profondeurmax $niveau=0; $resultat=""; $profondeurmax=0; enfants($id_noeud_top, $niveau, $resultat, $profondeurmax, false); /// deuxième parcours, cette fois-ci on imprime $niveau=0; $resultat=""; echo ""; enfants($id_noeud_top, $niveau, $resultat, $profondeurmax, true); echo "
" ; break; case "alph": $rqt = "select id_noeud from noeuds n, categories c where c.num_thesaurus=$aff_num_thesaurus and n.num_thesaurus=$aff_num_thesaurus and id_noeud=num_noeud and langue='$aff_langue' and autorite!='TOP' and autorite!='ORPHELINS' and autorite!='NONCLASSES' order by libelle_categorie "; $result = mysql_query($rqt) or die("Query alpha failed"); while ($obj_id_noeud = mysql_fetch_object($result)){ echo infos_categorie($obj_id_noeud->id_noeud); } break; case "rota": $mots=array(); if (file_exists("$include_path/marc_tables/$aff_langue/empty_words_thesaurus")) { $mots_vides_thesaurus=true; include("$include_path/marc_tables/$aff_langue/empty_words_thesaurus"); } else $mots_vides_thesaurus=false; $rqt = "select id_noeud, libelle_categorie, index_categorie from noeuds n, categories c where c.num_thesaurus=$aff_num_thesaurus and n.num_thesaurus=$aff_num_thesaurus and id_noeud=num_noeud and langue='$aff_langue' and autorite!='TOP' and autorite!='ORPHELINS' and autorite!='NONCLASSES' order by libelle_categorie "; $result = mysql_query($rqt) or die("Query rota failed"); while ($obj = mysql_fetch_object($result)) { // récupération de l'index du libellé, nettoyage $icat=$obj->index_categorie ; // si mots vides supplémentaires if ($mots_vides_thesaurus) { // suppression des mots vides if (is_array($empty_word_thesaurus)) { foreach($empty_word_thesaurus as $dummykey=>$word) { $word = convert_diacrit($word); $icat = pmb_preg_replace("/^${word}$|^${word}\s|\s${word}\s|\s${word}\$/i", ' ', $icat); } } } $icat = trim($icat); // echo "
".$obj->id_noeud." - ".$icat ; $icat = pmb_preg_replace('/\s+/', ' ', $icat); // l'index est propre, on va pouvoir exploser sur espace. $mot=array(); // index non vide (des fois que le ménage précédent l'aie vidé complètement) if ($icat) { $mot = explode(' ',$icat); for ($imot=0;$imotid_noeud ; } } } } // on a un super tableau de mots ksort($mots, SORT_STRING); echo ""; foreach ($mots as $mot=>$idiz) { // on parcourt tous les mots trouvés $rqt="select libelle_categorie, num_noeud from categories where num_noeud in(".implode(",",$idiz).") and langue='".$aff_langue."' order by index_categorie"; $ressql = mysql_query($rqt) or die ($rqt."

".mysql_error()); while ($data=mysql_fetch_object($ressql)) { // on parcourt toutes les catégories utilisant ce mot pour chercher la position d'utilisation du mot $catnette = " ".str_replace(" - "," ",strtolower(strip_empty_chars_thesaurus($data->libelle_categorie)))." "; $catnette = str_replace(" -"," ",$catnette); $catnette = str_replace("- "," ",$catnette); $posdeb=strpos($catnette," ".$mot." "); $posfin=$posdeb+strlen($mot); // echo "

deb $posdeb - fin: $posfin mot: $mot LIB: ".$data->libelle_categorie ; echo " "; } } // print_r($mots); echo "
".substr($data->libelle_categorie,0,$posdeb)." ".substr($data->libelle_categorie,$posdeb,$posfin-$posdeb)."".substr($data->libelle_categorie,$posfin); echo infos_categorie($data->num_noeud, false, true)."
"; break; } // pied de page print ""; } mysql_close($dbh); function infos_noeud($idnoeud, $niveau, $profondeurmax) { global $dbh, $aff_langue; global $aff_note_application, $aff_commentaire, $aff_voir, $aff_voir_aussi, $aff_tg, $aff_ts; global $color, $fontsize, $paddingmargin ; global $id_noeud_origine; // récupération info du noeud $rqt = "select num_noeud, libelle_categorie, num_parent, note_application, comment_public, case when langue='$aff_langue' then '' else langue end as trad, langue from categories,noeuds where num_noeud = id_noeud and num_noeud='$idnoeud' order by trad "; $ressql = mysql_query($rqt) or die ($rqt."

".mysql_error()); while ($data=mysql_fetch_object($ressql)) { $res.= "\n"; $niv=$niveau-1; switch($niv) { case 10: $res.=" "; case 9: $res.=" "; case 8: $res.=" "; case 7: $res.=" "; case 6: $res.=" "; case 5: $res.=" "; case 4: $res.=" "; case 3: $res.=" "; case 2: $res.=" "; case 1: $res.=" "; } $printingBranche = false; // afin d'avoir les bons colspan sur la branche en cas d'impression d'une branche if ($id_noeud_origine==$idnoeud){ $niveau=$niveau+1 ; $printingBranche = true; } if (($data->note_application || $data->comment_public) && ($aff_note_application || $aff_commentaire)) { $style="style='border-top: 1px dotted gray;border-bottom: 1px dotted gray; "; $largeur="40%"; } else { $style="style='"; $largeur="70%"; } $style.=" ".$fontsize[$niveau]." ".$paddingmargin[$niveau]." '"; if ($data->trad) $res.="".$data->trad." ".$data->libelle_categorie.""; else $res.="".$data->libelle_categorie; //TERME GÉNÉRAL DANS LE CAS DE L'IMPRESSION D'UNE BRANCHE if ($printingBranche){ $rqttg = "select libelle_categorie from categories where num_noeud = '".$data->num_parent."'"; $restg = mysql_query($rqttg) or die ($rqttg."

".mysql_error()); if (mysql_num_rows($restg)) { $datatg=mysql_fetch_object($restg); $res.= "
TG ".$datatg->libelle_categorie.""; } } if ($aff_voir_aussi) { $rqtva = "select libelle_categorie from categories, voir_aussi where num_noeud_orig=$idnoeud and num_noeud=num_noeud_dest and categories.langue='".$data->langue."' and voir_aussi.langue='".$data->langue."' order by libelle_categorie " ; $resva = mysql_query($rqtva) or die ($rqtva."

".mysql_error()); if (mysql_num_rows($resva)) { $res.= "\n"; while ($datava=mysql_fetch_object($resva)) $res.= "
TA ".$datava->libelle_categorie; $res.= "
"; } } if ($aff_voir) { $rqtva = "select libelle_categorie from categories, noeuds where num_renvoi_voir=$idnoeud and num_noeud=id_noeud and categories.langue='".$data->langue."' order by libelle_categorie " ; $resva = mysql_query($rqtva) or die ($rqtva."

".mysql_error()); if (mysql_num_rows($resva)) { $res.= "\n"; while ($datava=mysql_fetch_object($resva)) $res.= "
EP ".$datava->libelle_categorie.""; $res.= "
"; } } $res.=""; if ($aff_note_application && $data->note_application) $res.="".$data->note_application.""; if ($aff_commentaire && $data->comment_public) $res.="".$data->comment_public.""; $res.="\n"; } return $res ; } function infos_categorie($idnoeud, $printcategnoeud=true, $forcer_em=false) { global $dbh, $aff_langue; global $aff_note_application, $aff_commentaire, $aff_voir, $aff_voir_aussi, $aff_tg, $aff_ts; // récupération info du noeud $rqt = "select num_noeud, num_parent, libelle_categorie, note_application, comment_public, case when langue='$aff_langue' then '' else langue end as trad, langue from categories join noeuds on num_noeud=id_noeud where num_noeud='$idnoeud' order by trad "; $ressql = mysql_query($rqt) or die ($rqt."

".mysql_error()); while ($data=mysql_fetch_object($ressql)) { if ($data->trad) $res.="
".$data->trad." ".$data->libelle_categorie.""; elseif ($printcategnoeud) $res.="

".$data->libelle_categorie.""; // EP et EM if ($aff_voir) { $rqtva = "select libelle_categorie from categories, noeuds where num_renvoi_voir=$idnoeud and num_noeud=id_noeud and categories.langue='".$data->langue."' order by libelle_categorie " ; $resva = mysql_query($rqtva) or die ($rqtva."

".mysql_error()); if (mysql_num_rows($resva)) { $res.= "\n"; while ($datava=mysql_fetch_object($resva)) $res.= "
EP ".$datava->libelle_categorie.""; $res.= "
"; } } if ($aff_voir || $forcer_em) { $rqtva = "select libelle_categorie from categories, noeuds where id_noeud=$idnoeud and num_noeud=num_renvoi_voir and categories.langue='".$data->langue."' order by libelle_categorie " ; $resva = mysql_query($rqtva) or die ($rqtva."

".mysql_error()); if (mysql_num_rows($resva)) { $res.= "\n"; while ($datava=mysql_fetch_object($resva)) $res.= "
EM ".$datava->libelle_categorie.""; $res.= "
"; } } // TG if ($aff_tg) { $rqttg = "select libelle_categorie from categories join noeuds on num_noeud=id_noeud where num_noeud='$data->num_parent' and libelle_categorie not like '~%' and categories.langue='".$data->langue."' " ; $restg = mysql_query($rqttg) or die ($rqttg."

".mysql_error()); if (mysql_num_rows($restg)) { $res.= "\n"; while ($datatg=mysql_fetch_object($restg)) $res.= "
TG ".$datatg->libelle_categorie; $res.= "
"; } } // TS if ($aff_ts) { $rqtts = "select libelle_categorie from categories join noeuds on num_noeud=id_noeud where num_parent='$data->num_noeud' and libelle_categorie not like '~%' and categories.langue='".$data->langue."' " ; $rests = mysql_query($rqtts) or die ($rqttg."

".mysql_error()); if (mysql_num_rows($rests)) { $res.= "\n"; while ($datats=mysql_fetch_object($rests)) $res.= "
TS ".$datats->libelle_categorie; $res.= "
"; } } // TA if ($aff_voir_aussi) { $rqtva = "select libelle_categorie from categories, voir_aussi where num_noeud_orig=$idnoeud and num_noeud=num_noeud_dest and categories.langue='".$data->langue."' and voir_aussi.langue='".$data->langue."' order by libelle_categorie " ; $resva = mysql_query($rqtva) or die ($rqtva."

".mysql_error()); if (mysql_num_rows($resva)) { $res.= "\n"; while ($datava=mysql_fetch_object($resva)) $res.= "
TA ".$datava->libelle_categorie; $res.= "
"; } } if ($aff_note_application && $data->note_application) $res.="
NA ".$data->note_application.""; if ($aff_commentaire && $data->comment_public) $res.="
PU ".$data->comment_public.""; } return $res ; } function enfants($id, $niveau, &$resultat, &$profondeurmax, $imprimer=false) { global $dbh, $aff_langue; if ($imprimer) { $resultat=infos_noeud($id, $niveau, $profondeurmax) ; echo $resultat; flush(); } elseif ($niveau>$profondeurmax) $profondeurmax=$niveau; // chercher les enfants $rqt = "select id_noeud from noeuds, categories where num_parent='$id' and id_noeud=num_noeud and langue='$aff_langue' and autorite!='TOP' and autorite!='ORPHELINS' and autorite!='NONCLASSES' order by libelle_categorie "; $res = mysql_query($rqt) ; if (mysql_num_rows($res)) { $niveau++; while ($data=mysql_fetch_object($res)) { enfants($data->id_noeud, $niveau, $resultat, $profondeurmax, $imprimer); } } } function strip_empty_chars_thesaurus($string) { // traitement des diacritiques $string = convert_diacrit($string); // Mis en commentaire : qu'en est-il des caractères non latins ??? // SUPPRIME DU COMMENTAIRE : ER : 12/05/2004 : ça fait tout merder... // RECH_14 : Attention : ici suppression des éventuels " // les " ne sont plus supprimés $string = stripslashes($string) ; $string = pmb_alphabetic('^a-z0-9\s', ' ',pmb_strtolower($string)); // espaces en début et fin $string = pmb_preg_replace('/^\s+|\s+$/', '', $string); return $string; } ?>