diff --git a/ecrire/index.php3 b/ecrire/index.php3 index d53dd6a3db6f1678e9c105d0d41ed6baff976c9d..3b6c1be824c9f05210e2fbba270d9a872236f17a 100644 --- a/ecrire/index.php3 +++ b/ecrire/index.php3 @@ -37,8 +37,6 @@ if ($spip_display != 4) { icone_horizontale( $texte , "../spip_cookie.php3?cookie_admin=non&url=".rawurlencode(_DIR_RESTREINT_ABS), "cookie-24.gif", ""); } - - $nom_site_spip = propre(lire_meta("nom_site")); if (!$nom_site_spip) $nom_site_spip="SPIP"; @@ -59,36 +57,35 @@ if ($spip_display != 4) { } } echo "<div class='verdana1'>"; - $query = "SELECT count(*) AS cnt FROM spip_articles where statut='publie'"; - $result = spip_fetch_array(spip_query($query)); - $nb_art_publie = $result['cnt']; - $query = "SELECT count(*) AS cnt FROM spip_articles where statut='prop'"; - $result = spip_fetch_array(spip_query($query)); - $nb_art_prop = $result['cnt']; - $query = "SELECT count(*) AS cnt FROM spip_articles where statut='prepa'"; - $result = spip_fetch_array(spip_query($query)); - $nb_art_redac= $result['cnt']; - - - if ($nb_art_redac OR $nb_art_prop OR $nb_art_publie) - { + + $query = "SELECT count(*) AS cnt, statut FROM spip_articles GROUP BY statut"; + $res = spip_query($query); + + while($row = spip_fetch_array($res)) { + $var = 'nb_art_'.$row['statut']; + $$var = $row['cnt']; + } + + if ($nb_art_prepa OR $nb_art_prop OR $nb_art_publie) { + echo afficher_plus("articles_page.php3")."<b>"._T('info_articles')."</b>"; echo "<ul style='margin:0px; padding-$spip_lang_left: 20px; margin-bottom: 5px;'>"; - if ($nb_art_redac) echo "<li>"._T("texte_statut_en_cours_redaction").": ".$nb_art_redac; + if ($nb_art_prepa) echo "<li>"._T("texte_statut_en_cours_redaction").": ".$nb_art_prepa; if ($nb_art_prop) echo "<li>"._T("texte_statut_attente_validation").": ".$nb_art_prop; if ($nb_art_publie) echo "<li><b>"._T("texte_statut_publies").": ".$nb_art_publie."</b>"; echo "</ul>"; + } - $query = "SELECT count(*) AS cnt FROM spip_breves where statut='publie'"; - $result = spip_fetch_array(spip_query($query)); - $nb_bre_publie = $result['cnt']; - $query = "SELECT count(*) AS cnt FROM spip_breves where statut='prop'"; - $result = spip_fetch_array(spip_query($query)); - $nb_bre_prop = $result['cnt']; + $query = "SELECT count(*) AS cnt, statut FROM spip_breves GROUP BY statut"; + $res = spip_query($query); + + while($row = spip_fetch_array($res)) { + $var = 'nb_bre_'.$row['statut']; + $$var = $row['cnt']; + } - if ($nb_bre_prop OR $nb_bre_publie) - { + if ($nb_bre_prop OR $nb_bre_publie) { echo afficher_plus("breves.php3")."<b>"._T('info_breves_02')."</b>"; echo "<ul style='margin:0px; padding-$spip_lang_left: 20px; margin-bottom: 5px;'>"; if ($nb_bre_prop) echo "<li>"._T("texte_statut_attente_validation").": ".$nb_bre_prop; @@ -108,32 +105,25 @@ if ($spip_display != 4) { echo "</ul>"; } - $query = "SELECT count(*) AS cnt FROM spip_auteurs where statut='0minirezo'"; - $result = spip_fetch_array(spip_query($query)); - $nb_admin = $result['cnt']; - - $query = "SELECT count(*) AS cnt FROM spip_auteurs where statut='1comite'"; - $result = spip_fetch_array(spip_query($query)); - $nb_redac = $result['cnt']; + $query = "SELECT count(*) AS cnt, statut FROM spip_auteurs GROUP BY statut"; + $res = spip_query($query); - $query = "SELECT count(*) AS cnt FROM spip_auteurs where statut='6forum'"; - $result = spip_fetch_array(spip_query($query)); - $nb_abonn = $result['cnt']; + while($row = spip_fetch_array($res)) { + $var = 'nb_aut_'.$row['statut']; + $$var = $row['cnt']; + } - if ($nb_admin OR $nb_redac OR $nb_abonn) - { + if ($nb_aut_0minirezo OR $nb_aut_1comite OR $nb_aut_6forum) { echo afficher_plus("auteurs.php3")."<b>"._T('icone_auteurs')."</b>"; echo "<ul style='margin:0px; padding-$spip_lang_left: 20px; margin-bottom: 5px;'>"; - if ($nb_admin) echo "<li>"._T("info_administrateurs").": ".$nb_admin; - if ($nb_redac) echo "<li>"._T("info_redacteurs").": ".$nb_redac; - if ($nb_abonn) echo "<li>"._T("info_visiteurs").": ".$nb_abonn; + if ($nb_aut_0minirezo) echo "<li>"._T("info_administrateurs").": ".$nb_aut_0minirezo; + if ($nb_aut_1comite) echo "<li>"._T("info_redacteurs").": ".$nb_aut_1comite; + if ($nb_aut_6forum) echo "<li>"._T("info_visiteurs").": ".$nb_aut_6forum; echo "</ul>"; } - echo "</div>"; - echo fin_cadre_relief(); diff --git a/ecrire/js_menu_rubriques.php b/ecrire/js_menu_rubriques.php index 7cc004aa2a8fea70c7d4bdb2391570919dbd718f..eeca8bba31748fc51598cc5425b2442804b1b4b0 100644 --- a/ecrire/js_menu_rubriques.php +++ b/ecrire/js_menu_rubriques.php @@ -1,14 +1,12 @@ <?php -include ("inc.php3"); - +include_once("inc.php3"); // Gestion d'expiration de ce jaja $expire = $date + 3600*24; $headers_only = http_last_modified($expire); - $date = gmdate("D, d M Y H:i:s", $date); $expire = gmdate("D, d M Y H:i:s", $expire); @Header ("Content-Type: text/javascript"); @@ -16,57 +14,79 @@ if ($headers_only) exit; @Header ("Last-Modified: ".$date." GMT"); @Header ("Expires: ".$expire." GMT"); +function extraire_article($id_p) { + if (array_key_exists($id_p, $GLOBALS['db_art_cache'])) { + return $GLOBALS['db_art_cache'][$id_p]; + } else { + return array(); + } +} + +function gen_liste_rubriques() { + $q = "SELECT id_rubrique, id_parent, titre + FROM spip_rubriques + ORDER BY id_parent, titre"; + + $res = spip_query($q); + + $GLOBALS['db_art_cache'] = array(); + if (spip_num_rows($res) > 0) { + while ($row = spip_fetch_array($res)) { + $parent = $row['id_parent']; + $id = $row['id_rubrique']; + $GLOBALS['db_art_cache'][$parent][$id] = $row['titre']; + } + } +} function bandeau_menu() { global $spip_ecran; - $result_racine = spip_query("SELECT * FROM spip_rubriques WHERE id_parent=0 ORDER BY titre"); - $i = spip_num_rows($result_racine); - - $total_lignes = $i; - if ($spip_ecran == "large") $max_lignes = 20; - else $max_lignes = 15; - - $nb_col = ceil($total_lignes / $max_lignes); - if ($nb_col < 1) $nb_col = 1; - $max_lignes = ceil($total_lignes / $nb_col); - - - $count_lignes = 0; - - if ($i > 0) { - $ret = "<div> </div>"; - $ret .= "<div class='bandeau_rubriques' style='z-index: 1;'>"; - while ($row = spip_fetch_array($result_racine)) { - - if ($count_lignes == $max_lignes) { - $count_lignes = 0; - $ret .= "</div></td><td valign='top' width='200'><div> </div><div class='bandeau_rubriques' style='z-index: 1;'>"; - } - $count_lignes ++; - - $id_rubrique = $row["id_rubrique"]; - $titre_rubrique = supprimer_numero(typo($row["titre"])); - - $ret .= bandeau_rubrique ($id_rubrique, $titre_rubrique, $i); - - $i = $i - 1; + + gen_liste_rubriques(); + $arr_low = extraire_article(0); + + $i = sizeof($arr_low); + + $total_lignes = $i; + if ($spip_ecran == "large") $max_lignes = 20; + else $max_lignes = 15; + + $nb_col = ceil($total_lignes / $max_lignes); + if ($nb_col < 1) $nb_col = 1; + $max_lignes = ceil($total_lignes / $nb_col); + + $count_lignes = 0; + + if ($i > 0) { + $ret = "<div> </div>"; + $ret .= "<div class='bandeau_rubriques' style='z-index: 1;'>"; + foreach( $arr_low as $id_rubrique => $titre_rubrique) { + + if ($count_lignes == $max_lignes) { + $count_lignes = 0; + $ret .= "</div></td><td valign='top' width='200'><div> </div><div class='bandeau_rubriques' style='z-index: 1;'>"; } - $ret .= "</div>"; + $count_lignes ++; + + $titre_rubrique = supprimer_numero(typo($titre_rubrique)); + $ret .= bandeau_rubrique($id_rubrique, $titre_rubrique, $i); + $i = $i - 1; } - - return $ret; + $ret .= "</div>"; + } + unset($GLOBALS['db_art_cache']); // On libère la mémoire + return $ret; } -function bandeau_rubrique ($id_rubrique, $titre_rubrique, $z = 1) { +function bandeau_rubrique($id_rubrique, $titre_rubrique, $z = 1) { global $zdecal; global $spip_ecran, $spip_display; global $spip_lang, $spip_lang_rtl, $spip_lang_left, $spip_lang_right; $titre_rubrique = preg_replace(',[\x00-\x1f]+,', ' ', $titre_rubrique); - // Calcul du nombre max de sous-menus $zdecal = $zdecal + 1; if ($spip_ecran == "large") $zmax = 8; @@ -81,18 +101,18 @@ function bandeau_rubrique ($id_rubrique, $titre_rubrique, $z = 1) { else $image = ''; if (strlen($image) > 1) $image = " style='background-image:url(" . _DIR_IMG_PACK . $image .");'"; - - $result_rub = spip_query("SELECT * FROM spip_rubriques WHERE id_parent=$id_rubrique ORDER BY titre"); - $i = spip_num_rows($result_rub); + + $arr_rub = extraire_article($id_rubrique); + + $i = sizeof($arr_rub); if ($i > 0 AND $zdecal < $zmax) { $ret .= '<div class=\"pos_r\" style=\"z-index: '.$z.';\" onMouseOver=\"montrer(\'b_'.$id_rubrique.'\');\" onMouseOut=\"cacher(\'b_'.$id_rubrique.'\');\">'; $ret .= '<div class=\"brt\"><a href=\"naviguer.php3?coll='.$id_rubrique.'\" class=\"bandeau_rub\"'.$image.'>'.addslashes(supprimer_tags($titre_rubrique)).'</a></div>'; $ret .= '<div class=\"bandeau_rub\" style=\"z-index: '.($z+1).';\" id=\"b_'.$id_rubrique.'\">'; - while ($row_rub = spip_fetch_array($result_rub)) { - $id_rub = $row_rub["id_rubrique"]; - $titre_rub = supprimer_numero(typo($row_rub["titre"])); - $ret .= bandeau_rubrique ($id_rub, $titre_rub, ($z+$i)); + foreach( $arr_rub as $id_rub => $titre_rub) { + $titre_rub = supprimer_numero(typo($titre_rub)); + $ret .= bandeau_rubrique($id_rub, $titre_rub, ($z+$i)); $i = $i - 1; } $ret .= "</div></div>"; @@ -109,4 +129,4 @@ echo bandeau_menu(); echo "</td></tr></table>"; echo "\");\n"; -?> \ No newline at end of file +?>