diff --git a/ecrire/mots_tous.php3 b/ecrire/mots_tous.php3 index 122c301d9b35f0dfc6c146279322baa209fdf2a0..fa596376104cca04b67a586221a93cdb13e0c2fb 100644 --- a/ecrire/mots_tous.php3 +++ b/ecrire/mots_tous.php3 @@ -52,15 +52,15 @@ if ($connect_statut == '0minirezo') { if ($ancien_type) { // modif groupe $query = "UPDATE spip_mots SET type=\"$change_type\" WHERE id_groupe='$id_groupe'"; spip_query($query); - - $query = "UPDATE spip_groupes_mots SET titre=\"$change_type\", unseul='$unseul', obligatoire='$obligatoire', - articles='$articles', breves='$breves', rubriques='$rubriques', syndic='$syndic', + + $query = "UPDATE spip_groupes_mots SET titre=\"$change_type\", unseul='$unseul', obligatoire='$obligatoire', + articles='$articles', breves='$breves', rubriques='$rubriques', syndic='$syndic', 0minirezo='$acces_minirezo', 1comite='$acces_comite', 6forum='$acces_forum' WHERE id_groupe='$id_groupe'"; spip_query($query); } else { // creation groupe - $query = "INSERT INTO spip_groupes_mots SET titre=\"$change_type\", unseul='$unseul', obligatoire='$obligatoire', - articles='$articles', breves='$breves', rubriques='$rubriques', syndic='$syndic', + $query = "INSERT INTO spip_groupes_mots SET titre=\"$change_type\", unseul='$unseul', obligatoire='$obligatoire', + articles='$articles', breves='$breves', rubriques='$rubriques', syndic='$syndic', 0minirezo='$acces_minirezo', 1comite='$acces_comite', 6forum='$acces_forum'"; spip_query($query); } @@ -89,12 +89,12 @@ if ($conf_mot>0) { $texte_lie = _T('info_un_article')." "; } else if ($nb_articles > 1) { $texte_lie = _T('info_nombre_articles', array('nb_articles' => $nb_articles)) ." "; - } + } if ($nb_breves == 1) { $texte_lie .= _T('info_une_breve')." "; } else if ($nb_breves > 1) { $texte_lie .= _T('info_nombre_breves', array('nb_breves' => $nb_breves))." "; - } + } if ($nb_sites == 1) { $texte_lie .= _T('info_un_site')." "; } else if ($nb_sites > 1) { @@ -109,7 +109,7 @@ if ($conf_mot>0) { debut_boite_info(); echo "<FONT FACE='Georgia,Garamond,Times,serif' SIZE=3>"; echo _T('info_delet_mots_cles', array('titre_mot' => $titre_mot, 'type_mot' => $type_mot, 'texte_lie' => $texte_lie)); - + echo "<UL>"; echo "<LI><B><A HREF='mots_edit.php3?supp_mot=$id_mot&redirect_ok=oui&redirect=mots_tous.php3'>"._T('item_oui')."</A>,</B> "._T('info_oui_suppression_mot_cle'); echo "<LI><B><A HREF='mots_tous.php3'>"._T('item_non')."</A>,</B> "._T('info_non_suppression_mot_cle'); @@ -120,65 +120,63 @@ if ($conf_mot>0) { } +// +// Calculer les nombres d'elements (articles, etc.) lies a chaque mot +// - /// Calculer les nombre d'elements lies a chaque mot - if ($connect_statut=="0minirezo") $aff_articles="prepa,prop,publie,refuse"; - else $aff_articles="prop,publie"; +if ($connect_statut=="0minirezo") $aff_articles = "'prepa','prop','publie'"; +else $aff_articles = "'prop','publie'"; - $result_articles = spip_query( - "SELECT COUNT(*) as cnt, mots.id_mot FROM spip_mots_articles AS lien, spip_articles AS article, spip_mots AS mots - WHERE lien.id_mot=mots.id_mot AND article.id_article=lien.id_article - AND FIND_IN_SET(article.statut,'$aff_articles')>0 AND article.statut!='refuse' GROUP BY mots.id_mot" - ); - while ($row_articles = spip_fetch_array($result_articles)){ - $id_mot = $row_articles['id_mot']; - $total_articles = $row_articles['cnt']; - $nb_articles[$id_mot] = $total_articles; - } - - - $result_rubriques = spip_query( - "SELECT COUNT(*) AS cnt, mots.id_mot FROM spip_mots_rubriques AS lien, spip_rubriques AS rubrique, spip_mots AS mots - WHERE lien.id_mot=mots.id_mot AND rubrique.id_rubrique=lien.id_rubrique GROUP BY mots.id_mot" - ); - while ($row_rubriques = spip_fetch_array($result_rubriques)){ - $id_mot = $row_rubriques['id_mot']; - $total_rubriques = $row_rubriques['cnt']; - $nb_rubriques[$id_mot] = $total_rubriques; - } - - $result_breves = spip_query( - "SELECT COUNT(*) AS cnt, mots.id_mot FROM spip_mots_breves AS lien, spip_breves AS breve, spip_mots AS mots - WHERE lien.id_mot=mots.id_mot AND breve.id_breve=lien.id_breve - AND FIND_IN_SET(breve.statut,'$aff_articles')>0 AND breve.statut!='refuse' GROUP BY mots.id_mot" - ); - while ($row_breves = spip_fetch_array($result_breves)){ - $id_mot = $row_breves['id_mot']; - $total_breves = $row_breves['cnt']; - $nb_breves[$id_mot] = $total_breves; - } - - $result_syndic = spip_query( - "SELECT COUNT(*) AS cnt, mots.id_mot FROM spip_mots_syndic AS lien, spip_syndic AS syndic, spip_mots AS mots - WHERE lien.id_mot=mots.id_mot AND syndic.id_syndic=lien.id_syndic - AND FIND_IN_SET(syndic.statut,'$aff_articles')>0 AND syndic.statut!='refuse' GROUP BY mots.id_mot" - ); - while ($row_syndic = spip_fetch_array($result_syndic)){ - $id_mot = $row_syndic['id_mot']; - $total_sites = $row_syndic['cnt']; - $nb_sites[$id_mot] = $total_sites; - } +$result_articles = spip_query( + "SELECT COUNT(*) as cnt, lien.id_mot FROM spip_mots_articles AS lien, spip_articles AS article + WHERE article.id_article=lien.id_article AND article.statut IN ($aff_articles) GROUP BY lien.id_mot" +); +while ($row_articles = spip_fetch_array($result_articles)){ + $id_mot = $row_articles['id_mot']; + $total_articles = $row_articles['cnt']; + $nb_articles[$id_mot] = $total_articles; +} +$result_rubriques = spip_query( + "SELECT COUNT(*) AS cnt, lien.id_mot FROM spip_mots_rubriques AS lien, spip_rubriques AS rubrique + WHERE rubrique.id_rubrique=lien.id_rubrique GROUP BY lien.id_mot" + ); +while ($row_rubriques = spip_fetch_array($result_rubriques)){ + $id_mot = $row_rubriques['id_mot']; + $total_rubriques = $row_rubriques['cnt']; + $nb_rubriques[$id_mot] = $total_rubriques; +} +$result_breves = spip_query( + "SELECT COUNT(*) AS cnt, lien.id_mot FROM spip_mots_breves AS lien, spip_breves AS breve + WHERE breve.id_breve=lien.id_breve AND breve.statut IN ($aff_articles) GROUP BY lien.id_mot" + ); +while ($row_breves = spip_fetch_array($result_breves)){ + $id_mot = $row_breves['id_mot']; + $total_breves = $row_breves['cnt']; + $nb_breves[$id_mot] = $total_breves; +} + +$result_syndic = spip_query( + "SELECT COUNT(*) AS cnt, lien.id_mot FROM spip_mots_syndic AS lien, spip_syndic AS syndic + WHERE syndic.id_syndic=lien.id_syndic AND syndic.statut IN ($aff_articles') GROUP BY lien.id_mot" + ); +while ($row_syndic = spip_fetch_array($result_syndic)){ + $id_mot = $row_syndic['id_mot']; + $total_sites = $row_syndic['cnt']; + $nb_sites[$id_mot] = $total_sites; +} -////// -$query_groupes = "SELECT * FROM spip_groupes_mots ORDER BY titre"; -$result_groupes = spip_query($query_groupes); +// +// On boucle d'abord sur les groupes de mots +// +$query_groupes = "SELECT * FROM spip_groupes_mots ORDER BY titre"; +$result_groupes = spip_query($query_groupes); -while($row_groupes = spip_fetch_array($result_groupes)) { +while ($row_groupes = spip_fetch_array($result_groupes)) { $id_groupe = $row_groupes['id_groupe']; $titre_groupe = $row_groupes['titre']; $unseul = $row_groupes['unseul']; @@ -199,79 +197,65 @@ while($row_groupes = spip_fetch_array($result_groupes)) { echo "<td bgcolor='$couleur_foncee' align='right'><font face='Verdana,Arial,Helvetica,sans-serif' size=1>"; echo "</font></td></tr>"; - - + // Affichage des options du groupe (types d'éléments, permissions...) echo "<tr><td colspan=3><font face='Verdana,Arial,Helvetica,sans-serif' size=1>"; - if ($articles == "oui") echo "> "._T('info_articles_2')." "; - if ($breves == "oui") echo "> "._T('info_breves_02')." "; - if ($rubriques == "oui") echo "> "._T('info_rubriques')." "; - if ($syndic == "oui") echo "> "._T('icone_sites_references')." "; - - - - if ($unseul == "oui" OR $obligatoire == "oui") echo "<br>"; - if ($unseul == "oui") echo "> "._T('info_un_mot')." "; - if ($obligatoire == "oui") echo "> "._T('info_groupe_important')." "; - + if ($articles == "oui") echo "> "._T('info_articles_2')." "; + if ($breves == "oui") echo "> "._T('info_breves_02')." "; + if ($rubriques == "oui") echo "> "._T('info_rubriques')." "; + if ($syndic == "oui") echo "> "._T('icone_sites_references')." "; + if ($unseul == "oui" OR $obligatoire == "oui") echo "<br>"; + if ($unseul == "oui") echo "> "._T('info_un_mot')." "; + if ($obligatoire == "oui") echo "> "._T('info_groupe_important')." "; echo "<br>"; - if ($acces_minirezo == "oui") echo "> "._T('info_administrateurs')." "; - if ($acces_comite == "oui") echo "> "._T('info_redacteurs')." "; - if ($acces_forum == "oui") echo "> "._T('info_visiteurs_02')." "; - - echo "</font></td></tr></table>"; - - - + if ($acces_minirezo == "oui") echo "> "._T('info_administrateurs')." "; + if ($acces_comite == "oui") echo "> "._T('info_redacteurs')." "; + if ($acces_forum == "oui") echo "> "._T('info_visiteurs_02')." "; + echo "</font></td></tr></table>"; + // + // Afficher les mots-cles du groupe + // $query = "SELECT * FROM spip_mots WHERE id_groupe = '$id_groupe' ORDER BY titre"; $result = spip_query($query); if (spip_num_rows($result) > 0) { debut_cadre_relief("mot-cle-24.gif"); echo "<table border=0 cellspacing=0 cellpadding=3 width=\"100%\">"; - // Afficher les mots-cles - while($row = spip_fetch_array($result)) { + while ($row = spip_fetch_array($result)) { $id_mot = $row['id_mot']; $titre_mot = $row['titre']; $type_mot = $row['type']; $descriptif_mot = $row['descriptif']; - if ($connect_statut=="0minirezo") + if ($connect_statut == "0minirezo") $aff_articles="prepa,prop,publie,refuse"; else $aff_articles="prop,publie"; - $query2 = "SELECT COUNT(*) FROM spip_mots_articles AS lien, spip_articles AS article WHERE lien.id_mot=$id_mot AND article.id_article=lien.id_article AND FIND_IN_SET(article.statut,'$aff_articles')>0 AND article.statut!='refuse'"; - $result2 = spip_query($query2); - list($nombre_mots) = spip_fetch_array($result2); - - if ($nombre_articles>0) $nombre_articles++; - if ($id_mot!=$conf_mot) { $couleur = $ifond ? "#FFFFFF" : $couleur_claire; $ifond = $ifond ^ 1; echo "<TR BGCOLOR='$couleur'>"; echo "<TD>"; - if ($connect_statut == "0minirezo" OR $nombre_mots>0) + if ($connect_statut == "0minirezo" OR $nb_articles[$id_mot] > 0) echo "<A HREF='mots_edit.php3?id_mot=$id_mot&redirect=mots_tous.php3'><img src='img_pack/petite-cle.gif' alt='' width='23' height='12' border='0'></A>"; else echo "<img src='img_pack/petite-cle.gif' alt='' width='23' height='12' border='0'>"; echo "</TD>"; - echo "<TD WIDTH=\"50%\">"; + echo "<TD>"; echo "<FONT FACE='Georgia,Garamond,Times,serif' SIZE=3>"; - if ($connect_statut == "0minirezo" OR $nombre_mots>0) + if ($connect_statut == "0minirezo" OR $nb_articles[$id_mot] > 0) echo "<A HREF='mots_edit.php3?id_mot=$id_mot&redirect=mots_tous.php3'>$titre_mot</A>"; else echo "$titre_mot"; echo "</FONT></TD>"; - echo "<TD WIDTH=\"50%\" ALIGN='right'>"; + echo "<TD ALIGN='right'>"; echo "<FONT FACE='Verdana,Arial,Helvetica,sans-serif' SIZE=2>"; - $texte_lie = array(); if ($nb_articles[$id_mot] == 1) @@ -295,7 +279,7 @@ while($row_groupes = spip_fetch_array($result_groupes)) { $texte_lie[] = $nb_rubriques[$id_mot]." "._T('info_rubriques_02'); echo $texte_lie = join($texte_lie,", "); - + if ($connect_statut=="0minirezo") { echo " "; echo "<FONT SIZE=1>[<A HREF='mots_tous.php3?conf_mot=$id_mot'>"._T('info_supprimer_mot')."</A>]</FONT>";