",$mots_lies); else $mots_lies=str_replace("!!bouton_ajouter!!","",$mots_lies); } $aff_mots=str_replace("!!supprimer!!","
\n",$aff_mots); $aff_mots=str_replace("!!mots_lie!!",$mots_lies,$aff_mots); $aff_mots=str_replace("!!max_word!!",$compt,$aff_mots); } else { //pas de résultat on affiche une seule case de saisie $aff_mot_lie=str_replace("!!iword!!","0",$aff_mot_lie); $aff_mot_lie=str_replace("!!word!!","",$aff_mot_lie); $aff_mot_lie=str_replace("!!id_word!!","",$aff_mot_lie); $aff_mots=str_replace("!!mots_lie!!",$aff_mot_lie,$aff_mots); $aff_mots=str_replace("!!supprimer!!","
\n",$aff_mots); $aff_mots=str_replace("!!max_word!!","1",$aff_mots); $aff_mots=str_replace("!!bouton_ajouter!!","",$aff_mots); } // $baseurl.="&word_selected=".$mot; $aff_mots=str_replace("!!mot!!",rawurlencode($mot),$aff_mots); $aff_mots=str_replace("!!id_mot!!",$id_mot,$aff_mots); $aff_mots=str_replace("!!mot_original!!",$mot,$aff_mots); } else { //si le mot est vide, on affiche le formulaire vierge $aff_mot_lie=str_replace("!!iword!!","0",$aff_mot_lie); $aff_mot_lie=str_replace("!!word!!","",$aff_mot_lie); $aff_mot_lie=str_replace("!!id_word!!","",$aff_mot_lie); $aff_mots=str_replace("!!mots_lie!!",$aff_mot_lie,$aff_mots); $aff_mots=str_replace("!!mot!!","",$aff_mots); $aff_mots=str_replace("!!mot_original!!","",$aff_mots); //on ne peut supprimer un mot inexistant $aff_mots=str_replace("!!supprimer!!","",$aff_mots); $aff_mots=str_replace("!!max_word!!","1",$aff_mots); $aff_mots=str_replace("!!id_mot!!","",$aff_mots); $aff_mots=str_replace("!!bouton_ajouter!!","",$aff_mots); } if ($word_search) $baseurl.="&action=search&word_search=".rawurlencode($word_search); $aff_mots=str_replace("!!action!!",$baseurl,$aff_mots); print $aff_mots; break; case 'modif': $bool_erreur=false; if ($word_selected) { //insertion d'un nouveau mot if ($word_code_selected)$rqt_ins = "update mots set mot='".$word_selected."' where id_mot='$word_code_selected' "; else $rqt_ins ="insert into mots set mot='".$word_selected."' "; @mysql_query($rqt_ins); if (!$word_code_selected)$word_code_selected= mysql_insert_id(); } else { $bool_erreur=true; print ""; } if ($bool_erreur==false) { $f_words=array(); //récupération des synonymes affectés au mot for ($i=$max_word-1;$i>=0 ; $i--) { $var_word = "f_word$i" ; global $$var_word; if ($$var_word && ($$var_word!=$word_selected)) { $var_word_code="f_word_code$i"; global $$var_word_code; if ($$var_word_code) $f_words[]=$$var_word_code; else { //vérification de l'existence du mot $rqt_exist="select id_mot, mot from mots left join linked_mots on (num_mot=id_mot) where mot='".$$var_word."' and id_mot not in (select num_mot from linked_mots where linked_mots.num_linked_mot=0) group by id_mot"; $query_exist=mysql_query($rqt_exist); if (!mysql_num_rows($query_exist)) { //insertion d'un nouveau mot $rqt_ins="insert into mots (mot) values ('".$$var_word."')"; @mysql_query($rqt_ins); //recherche de l'id du mot inséré $f_words[]=mysql_insert_id(); } } } } //dédoublonne le tableau $f_words=array_unique($f_words); //suppression des enregistrements existants $rqt_del = "delete from linked_mots where num_mot='".$word_code_selected."' "; $res_del = mysql_query($rqt_del, $dbh); //insertion du mot et de ses synonymes $rqt_ins = "insert into linked_mots (num_mot, num_linked_mot, type_lien, ponderation) VALUES "; //récupération des synonymes affectés au mot for ($i=0;$i alert('".addslashes($msg["other_word_syn_error"])."'); document.location='./autorites.php?categ=semantique&sub=synonyms&id_mot=$id_mot&mot=$mot&action=view';"; } else print ""; break; default: break; } if ($action!='view') { if (!$nb_per_page) $nb_per_page=$nb_per_page_gestion; if ($action!='last_words') $tri="order by mot"; //comptage des mots $rqt1="select id_mot, mot from mots left join linked_mots on (num_mot=id_mot) where id_mot not in (select num_mot from linked_mots where linked_mots.num_linked_mot=0)$clause group by id_mot"; $execute_query1=mysql_query($rqt1); $nb_result=mysql_num_rows($execute_query1); mysql_free_result($execute_query1); //recherche des mots $rqt="select id_mot, mot from mots left join linked_mots on (num_mot=id_mot) where id_mot not in (select num_mot from linked_mots where linked_mots.num_linked_mot=0)$clause group by id_mot $tri $limit"; $execute_query=mysql_query($rqt); if ($execute_query&&$nb_result) { $affichage_mots="
"; if ($action=='last_words'||$word_search) { $parity=1; $affichage_mots.=""; $affichage_mots.=""; } else { $words_for_syn=array(); $words_for_syn1=array(); } while ($r=mysql_fetch_object($execute_query)) { if (!$word_search&&$action!='last_words') { $words_for_syn[$r->id_mot]=stripslashes($r->mot); $words_for_syn1[$r->id_mot]=convert_diacrit(pmb_strtolower(stripslashes($r->mot))); } else { if ($parity % 2) { $pair_impair = "even"; } else { $pair_impair = "odd"; } $parity += 1; $affichage_mots.=""; } } if ($action=='last_words'||$word_search) { $aff_liste_mots=str_replace("!!lettres!!","",$aff_liste_mots); $affichage_mots.="
".$msg["word_selected"]."
".stripslashes($r->mot)."
"; $compt=$nb_result; } else { if (count($words_for_syn)) { //toutes les lettres de l'alphabet dans un tableau $alphabet=array(); $alphabet[]=''; for ($i=97;$i<=122;$i++) { $alphabet[]=chr($i); } $bool=false; foreach($words_for_syn as $val) { if ($val!="") { $carac=convert_diacrit(pmb_strtolower(pmb_substr($val,0,1))); if ($bool==false) { if ($word_selected) $premier_carac=convert_diacrit(pmb_strtolower(pmb_substr($word_selected,0,1))); else $premier_carac=$carac; $bool=true; } if (array_search($carac,$alphabet)===FALSE) $alphabet_num[]=$carac; } } //dédoublonnage du tableau des autres caractères if (count($alphabet_num)) $alphabet_num = array_unique($alphabet_num); if (!$letter) { if (count($alphabet_num)) $letter="My"; elseif ($premier_carac) $letter=$premier_carac; else $letter="a"; } elseif (!array_search($letter,$alphabet)) $letter="My"; // affichage d'un sommaire par lettres $affichage_lettres="
"; if (count($alphabet_num)) { if ($letter=='My') $affichage_lettres.="# "; else $affichage_lettres.="# "; } foreach($alphabet as $char) { $present = pmb_preg_grep("/^$char/i", $words_for_syn1); if(sizeof($present) && strcasecmp($letter, $char)) $affichage_lettres.="$char "; else if(!strcasecmp($letter, $char)) $affichage_lettres.="$char "; else $affichage_lettres.="".$char." "; } $affichage_lettres.="
"; //affichage des mots $compt=0; $bool=false; if (!$page) $page=1; //parcours du tableau de mots, découpage en colonne et détermination des valeurs par rapport à la pagination et la lettre foreach ($words_for_syn as $key=>$valeur_syn) { if ($valeur_syn!="") { if ($compt>=(($page-1)*$nb_per_page)&&($compt<($page*$nb_per_page))) { if ($bool==false&&(($compt % 30)==0)) { $affichage_mots.="
"; } } if ($letter!='My') { if (preg_match("/^$letter/i", convert_diacrit(pmb_strtolower($valeur_syn)))) { if (($compt>=(($page-1)*$nb_per_page))&&($compt<($page*$nb_per_page))) { $affichage_mots.="".htmlentities($valeur_syn,ENT_QUOTES,$charset)."
\n"; } $compt++; } } else { if (pmb_substr($valeur_syn,0,1)=='0'||!array_search(convert_diacrit(pmb_strtolower(pmb_substr($valeur_syn,0,1))),$alphabet)) { if (($compt>=(($page-1)*$nb_per_page))&&($compt<($page*$nb_per_page))) { $affichage_mots.="".htmlentities($valeur_syn,ENT_QUOTES,$charset)."
\n"; } $compt++; } } if ($compt>=(($page-1)*$nb_per_page)&&($compt<($page*$nb_per_page))) { if ($compt!=0&&(($compt % 30)==0)) { $affichage_mots.="
"; } } if ($compt==0) $bool=true; } } $aff_liste_mots=str_replace("!!lettres!!",$affichage_lettres,$aff_liste_mots); } } $affichage_mots.="
"; $affichage_mots.="
 
\n"; //affichage de la pagination $affichage_mots.=aff_pagination ($baseurl, $compt, $nb_per_page, $page) ; $affichage_mots.="
 
\n"; $aff_liste_mots=str_replace("!!see_last_words!!","
".$msg["see_last_words_created"]."
",$aff_liste_mots); } else $aff_liste_mots=str_replace("!!see_last_words!!","",$aff_liste_mots); $aff_liste_mots=str_replace("!!lettres!!",$affichage_lettres,$aff_liste_mots); $aff_liste_mots=str_replace("!!liste_mots!!",$affichage_mots,$aff_liste_mots); $aff_liste_mots=str_replace("!!action!!",$baseurl,$aff_liste_mots); print $aff_liste_mots; } ?>