\n",$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_mot_lie=str_replace("!!word_mutual_checked!!","checked='checked'",$aff_mot_lie); $aff_mots=str_replace("!!mots_lie!!",$aff_mot_lie,$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_f_word!!","1",$aff_mots); $aff_mots=str_replace("!!id_mot!!","",$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_id_selected)$rqt_ins = "update mots set mot='".$word_selected."' where id_mot='$word_id_selected' "; else $rqt_ins ="insert into mots set mot='".$word_selected."' "; @pmb_mysql_query($rqt_ins); if (!$word_id_selected)$word_id_selected= pmb_mysql_insert_id(); } else { $bool_erreur=true; print ""; } if ($bool_erreur==false) { $f_words=array(); $f_words_mutal=array(); //récupération des synonymes affectés au mot for ($i=$max_f_word-1;$i>=0 ; $i--) { $var_word = "f_word$i" ; global ${$var_word}; if (${$var_word} && (${$var_word}!=$word_selected)) { $var_word_id="f_word_id$i"; global ${$var_word_id}; $var_word_mutual = "f_word_mutual$i" ; global ${$var_word_mutual}; if (${$var_word_id}) { $f_words[]=${$var_word_id}; $f_words_mutal[]=array( 'code' =>${$var_word_id}, 'is_mutual' => (${$var_word_mutual} ? 1 : 0) ); } 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=pmb_mysql_query($rqt_exist); if (!pmb_mysql_num_rows($query_exist)) { //insertion d'un nouveau mot $rqt_ins="insert into mots (mot) values ('".${$var_word}."')"; @pmb_mysql_query($rqt_ins); //recherche de l'id du mot inséré $f_words[]=pmb_mysql_insert_id(); $f_words_mutal[]=array( 'code' => pmb_mysql_insert_id(), 'is_mutual' => (${$var_word_mutual} ? 1 : 0) ); } } } } //dédoublonne le tableau $f_words=array_unique($f_words); //suppression des enregistrements existants $rqt_del = "delete from linked_mots where num_mot='".$word_id_selected."' "; pmb_mysql_query($rqt_del); //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=pmb_mysql_query($rqt1); $nb_result=pmb_mysql_num_rows($execute_query1); pmb_mysql_free_result($execute_query1); //recherche des mots $affichage_mots=""; $affichage_lettres=""; $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=pmb_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=pmb_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; $alphabet_num = array(); 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 (!empty($alphabet_num)) { if ($letter == 'My') { $affichage_lettres .= "# "; } else { $affichage_lettres .= "# "; } } foreach ($alphabet as $char) { $present = pmb_preg_grep("/^$char/i", $words_for_syn1); if (!empty($present) && strcasecmp($letter, $char)) { $affichage_lettres .= "$char "; } elseif (!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.($letter ? "&letter=".$letter : ''), $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; } ?>