From 31447219dca77be6e48ef3fbb86e4100d4fe88b8 Mon Sep 17 00:00:00 2001
From: "Committo,Ergo:sum" <esj@rezo.net>
Date: Tue, 2 Jan 2007 17:53:45 +0000
Subject: [PATCH] Evacuation de balises font {{{ for i in $(grep -l  "<font
 color=.[^>]*>.*</font" [ei]*/*p) 	do 	sed  "s,<font
 color=\(.\)\([^>]*\)>\(.*\)</font,<span style=\1color: \2>\3</span," $i > x 
  mv x $i done }}}

---
 .gitattributes                                |   3 +
 dist/javascript/presentation.js               |  32 +++-
 dist/style_prive.html                         |  28 ++--
 ecrire/action/editer_article.php              |   8 +-
 ecrire/action/instituer_rubrique_articles.php |  39 +++++
 ecrire/action/instituer_rubrique_breves.php   |  38 +++++
 ecrire/exec/meme_rubrique.php                 |  37 +++++
 ecrire/exec/puce_statut_article.php           |  20 ++-
 ecrire/inc/presentation.php                   | 156 ++++++++++--------
 9 files changed, 253 insertions(+), 108 deletions(-)
 create mode 100644 ecrire/action/instituer_rubrique_articles.php
 create mode 100644 ecrire/action/instituer_rubrique_breves.php
 create mode 100644 ecrire/exec/meme_rubrique.php

diff --git a/.gitattributes b/.gitattributes
index bdab5f1fd6..f824d47c1c 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -339,6 +339,8 @@ ecrire/action/instituer_forum.php -text
 ecrire/action/instituer_groupe_mots.php -text
 ecrire/action/instituer_langue_rubrique.php -text
 ecrire/action/instituer_mot.php -text
+ecrire/action/instituer_rubrique_articles.php -text
+ecrire/action/instituer_rubrique_breves.php -text
 ecrire/action/instituer_syndic.php -text
 ecrire/action/joindre.php -text
 ecrire/action/legender.php -text
@@ -423,6 +425,7 @@ ecrire/exec/instituer_auteur.php -text
 ecrire/exec/lang_raccourcis.php -text
 ecrire/exec/legender.php -text
 ecrire/exec/legender_auteur.php -text
+ecrire/exec/meme_rubrique.php -text
 ecrire/exec/memoriser.php -text
 ecrire/exec/message.php -text
 ecrire/exec/message_edit.php -text
diff --git a/dist/javascript/presentation.js b/dist/javascript/presentation.js
index 3f5c9a6ab4..8db6a6e31a 100644
--- a/dist/javascript/presentation.js
+++ b/dist/javascript/presentation.js
@@ -38,19 +38,34 @@ function selec_statut(id, type, decal, puce, script) {
 	if (!accepter_change_statut)
 		accepter_change_statut = confirm(confirm_changer_statut);
 
-	if (accepter_change_statut) {
-		changestyle ('statutdecal'+type+id, 'marginLeft', decal+'px');
-		cacher ('statutdecal'+type+id);
+	if (!accepter_change_statut) return;
+
+	changestyle ('statutdecal'+type+id, 'marginLeft', decal+'px');
+	cacher ('statutdecal'+type+id);
+
+	$.get(script,
+		function (c) {
+			node = findObj('imgstatut'+type+id);
+			if (!((type == 'article') || (type == 'breve'))) {
+				node.innerHTML = c;
+			} else {
 
-		$.get(script,
-			function (c) {
 				if (!c)
-					findObj('imgstatut'+type+id).src = puce;
+					node.src = puce;
+
 				else
 					alert(c); // eventuel message d'erreur (TODO)
 			}
-		);
-	}
+	      }
+	      );
+}
+
+function prepare_selec_statut(nom, type, id, action)
+{
+	$('#' + nom + type + id).load(action + '&type='+type+'&id='+id,
+		function(){ 
+			findObj_forcer('statutdecal'+type+id).style.visibility = 'visible';
+					  });
 }
 
 function changeclass(objet, myClass) {
@@ -73,7 +88,6 @@ function cacher(objet) {
 }
 
 
-
 function getHeight(obj) {
 	if (obj == "window") {
 		return hauteur_fenetre();
diff --git a/dist/style_prive.html b/dist/style_prive.html
index 8c4b9fe3e7..2f762c4cca 100644
--- a/dist/style_prive.html
+++ b/dist/style_prive.html
@@ -1159,43 +1159,37 @@ a.liste-mot {
 	overflow: hidden;
 }
 
-.tr_liste:hover td div.liste_clip {
+.tr_liste:hover td div.liste_clip, span.liste_clip {
 	overflow: visible;
 	height: 100%;
 }
 
-div.puce_article {
+div.puce_article, span.puce_articlen div.puce_breve, span.puce_breve {
 	position: relative; 
-	height: 11px; 
-	width: 11px;
 }
-
-div.puce_breve {
-	position: relative; 
-	height: 9px; 
-	width: 9px;
-}
-div.puce_article_fixe, div.puce_breve_fixe {
-	position: absolute;
+div.puce_article_fixe, div.puce_breve_fixe, span.puce_article_fixe, span.puce_breve_fixe {
+	position: relative;
 }
 
-div.puce_article_popup, div.puce_breve_popup {
+div.puce_article_popup, div.puce_breve_popup, span.puce_article_popup, span.puce_breve_popup {
 	position: absolute;
+	top: 0; 
 	visibility: hidden;
-	margin-top: -1px; top: 0; 
 	border: 1px solid #666; 
 	background-color: #ccc; z-index: 10; 
 	-moz-border-radius: 3px;
 }
-div.puce_article_popup img, div.puce_breve_popup img {
+
+div.puce_article_popup img, div.puce_breve_popup img, span.puce_article_popup img, span.puce_breve_popup img {
 	padding: 1px;
 	border: none;
 }
 
-div.puce_article_popup {
+div.puce_article_popup, span.puce_article_popup {
 	width: 55px; 
 }
-div.puce_breve_popup {
+
+div.puce_breve_popup, span.puce_breve_popup {
 	width: 27px; 
 }
 
diff --git a/ecrire/action/editer_article.php b/ecrire/action/editer_article.php
index a8d4c256d5..68f6979f2b 100644
--- a/ecrire/action/editer_article.php
+++ b/ecrire/action/editer_article.php
@@ -150,10 +150,11 @@ function revisions_articles ($id_article, $c=false) {
 // statut et rubrique sont lies, car un admin restreint peut deplacer
 // un article publie vers une rubrique qu'il n'administre pas
 // http://doc.spip.org/@instituer_article
-function instituer_article($id_article, $c) {
+function instituer_article($id_article, $c, $calcul_rub=true) {
 
 	include_spip('inc/autoriser');
 	include_spip('inc/rubriques');
+	include_spip('inc/modifier');
 
 	$s = spip_query("SELECT statut, id_rubrique FROM spip_articles WHERE id_article=$id_article");
 	$row = spip_fetch_array($s);
@@ -223,7 +224,6 @@ function instituer_article($id_article, $c) {
 
 	spip_query("UPDATE spip_articles SET ".join(', ',$update)." WHERE id_article=$id_article");
 
-
 	// Si on a deplace l'article
 	// - propager les secteurs
 	// - changer sa langue (si heritee)
@@ -248,8 +248,8 @@ function instituer_article($id_article, $c) {
 
 	// Recalculer les rubriques (statuts et dates) si l'on deplace
 	// un article publie, ou si on le depublie
-	if (($statut == 'publie' AND isset($champ['id_rubrique']))
-	OR ($statut_ancien=='publie' AND $champ['statut']))
+	if (($statut == 'publie' AND isset($champs['id_rubrique']))
+	OR ($statut_ancien=='publie' AND $champs['statut'] AND $calcul_rub))
 		calculer_rubriques();
 
 	// Pipeline
diff --git a/ecrire/action/instituer_rubrique_articles.php b/ecrire/action/instituer_rubrique_articles.php
new file mode 100644
index 0000000000..3d88fc212a
--- /dev/null
+++ b/ecrire/action/instituer_rubrique_articles.php
@@ -0,0 +1,39 @@
+<?php
+
+/***************************************************************************\
+ *  SPIP, Systeme de publication pour l'internet                           *
+ *                                                                         *
+ *  Copyright (c) 2001-2007                                                *
+ *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
+ *                                                                         *
+ *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
+ *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
+\***************************************************************************/
+
+if (!defined("_ECRIRE_INC_VERSION")) return;
+
+// http://doc.spip.org/@action_instituer_article_dist
+function action_instituer_rubrique_articles_dist() {
+
+	$securiser_action = charger_fonction('securiser_action', 'inc');
+	$arg = $securiser_action();
+
+	list($id, $statut) = preg_split('/\W/', $arg);
+	$id = intval($id);
+	$statut =array('statut' => $statut);
+
+	include_spip('action/editer_article');
+
+	$table = 'articles';
+	$key = 'id_article';
+
+	$voss = spip_query("SELECT $key AS id FROM spip_$table WHERE id_rubrique=$id AND (statut = 'publie' OR statut = 'prop' OR statut = 'prepa')");
+
+	while($row = spip_fetch_array($voss)) {
+		instituer_article($row['id'], $statut, false);
+	}
+	include_spip('inc/rubriques');
+	calculer_rubriques();
+	redirige_par_entete(generer_url_ecrire('meme_rubrique', "id=$id&type=article&date=date", true));
+}
+?>
diff --git a/ecrire/action/instituer_rubrique_breves.php b/ecrire/action/instituer_rubrique_breves.php
new file mode 100644
index 0000000000..7d36e57bf0
--- /dev/null
+++ b/ecrire/action/instituer_rubrique_breves.php
@@ -0,0 +1,38 @@
+<?php
+
+/***************************************************************************\
+ *  SPIP, Systeme de publication pour l'internet                           *
+ *                                                                         *
+ *  Copyright (c) 2001-2007                                                *
+ *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
+ *                                                                         *
+ *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
+ *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
+\***************************************************************************/
+
+if (!defined("_ECRIRE_INC_VERSION")) return;
+
+// http://doc.spip.org/@action_instituer_article_dist
+function action_instituer_rubrique_breves_dist() {
+
+	$securiser_action = charger_fonction('securiser_action', 'inc');
+	$arg = $securiser_action();
+
+	list($id, $statut) = preg_split('/\W/', $arg);
+	$id = intval($id);
+
+	include_spip('action/editer_breve');
+
+	$table = 'articles';
+	$key = 'id_article';
+
+	$voss = spip_query("SELECT $key AS id FROM spip_$table WHERE id_rubrique=$id AND (statut = 'publie' OR statut = 'prop')");
+
+	while($row = spip_fetch_array($voss)) {
+                set_request('statut', $statut);
+		revisions_breves($row['id']);
+	}
+
+	redirige_par_entete(generer_url_ecrire('meme_rubrique', "id=$id&type=breve&date=date_heure", true));
+}
+?>
diff --git a/ecrire/exec/meme_rubrique.php b/ecrire/exec/meme_rubrique.php
new file mode 100644
index 0000000000..79e018c5ec
--- /dev/null
+++ b/ecrire/exec/meme_rubrique.php
@@ -0,0 +1,37 @@
+<?php
+
+/***************************************************************************\
+ *  SPIP, Systeme de publication pour l'internet                           *
+ *                                                                         *
+ *  Copyright (c) 2001-2007                                                *
+ *  Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James  *
+ *                                                                         *
+ *  Ce programme est un logiciel libre distribue sous licence GNU/GPL.     *
+ *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
+\***************************************************************************/
+
+if (!defined("_ECRIRE_INC_VERSION")) return;
+
+include_spip('inc/presentation');
+
+// http://doc.spip.org/@exec_puce_statut_article_dist
+function exec_meme_rubrique_dist()
+{
+	$id = intval(_request('id'));
+	$type = _request('type');
+	$date = _request('date');
+
+        if (($GLOBALS['auteur_session']['statut'] != '0minirezo')
+        OR (!acces_rubrique($id))
+	OR (!preg_match('/^[\w_-]+$/',$date))
+        OR (!preg_match('/^[\w_-]+$/',$type))) {
+                include_spip('inc/minipres');
+                echo minipres();
+                exit;
+        }
+
+	// on connait pas le vrai 2e arg mais c'est pas dramatique
+	$res = meme_rubrique($id, 0, $type, $date, 30, true);
+	ajax_retour($res);
+}
+?>
\ No newline at end of file
diff --git a/ecrire/exec/puce_statut_article.php b/ecrire/exec/puce_statut_article.php
index db8dfbffda..cd1fe82718 100644
--- a/ecrire/exec/puce_statut_article.php
+++ b/ecrire/exec/puce_statut_article.php
@@ -10,7 +10,6 @@
  *  Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne.   *
 \***************************************************************************/
 
-
 if (!defined("_ECRIRE_INC_VERSION")) return;
 
 include_spip('inc/presentation');
@@ -19,12 +18,19 @@ include_spip('inc/autoriser');
 // http://doc.spip.org/@exec_puce_statut_article_dist
 function exec_puce_statut_article_dist()
 {
-	$id = _request('id');
-	$s = spip_query(
-	"SELECT id_rubrique,statut FROM spip_articles WHERE id_article="._q($id));
-	$r = spip_fetch_array($s);
+	$id = intval(_request('id'));
+	$type = _request('type');
 
-	ajax_retour(puce_statut_article($id,$r['statut'],$r['id_rubrique'],true));
+	if ($type == 'article') {
+		$s = spip_query("SELECT id_rubrique,statut FROM spip_articles WHERE id_article=$id");
+		$r = spip_fetch_array($s);
+		$statut = $r['statut'];
+		$id_rubrique = $r['id_rubrique'];
+	} else {
+		$id_rubrique = $id;
+		$id = 0;
+		$statut = 'prop'; // arbitraire
+	}
+	ajax_retour(puce_statut_article($id,$statut,$id_rubrique,$type, true));
 }
-
 ?>
\ No newline at end of file
diff --git a/ecrire/inc/presentation.php b/ecrire/inc/presentation.php
index 2d2db77ac1..3521b0b773 100644
--- a/ecrire/inc/presentation.php
+++ b/ecrire/inc/presentation.php
@@ -254,12 +254,13 @@ function fin_boite_info($return=false) {
 function bandeau_titre_boite2($titre, $logo="", $fond="white", $texte="black", $af = true) {
 	global $spip_lang_left, $spip_display, $browser_name;
 	
+	$logo = http_img_pack($logo, "", "");
 	if (strlen($logo) > 0 AND $spip_display != 1 AND $spip_display != 4) {
 		$ie_style = ($browser_name == "MSIE") ? "height:1%" : '';
 
 		$retour = "\n<div style='position: relative;$ie_style'>"
-		. "\n<div style='position: absolute; top: -12px; $spip_lang_left: 3px;'>" .
-		  http_img_pack("$logo", "", "")
+		. "\n<div style='position: absolute; top: -12px; $spip_lang_left: 3px;'>"
+		. $logo  
 		. "</div>"
 		. "\n<div style='background-color: $fond; color: $texte; padding: 3px; padding-$spip_lang_left: 30px; border-bottom: 1px solid #444444;' class='verdana2'>$titre</div>"
 		 . "</div>";
@@ -497,99 +498,92 @@ function afficher_liste_fin_tableau() {
 
 
 // http://doc.spip.org/@puce_statut_article
-function puce_statut_article($id, $statut, $id_rubrique, $ajax = false) {
+function puce_statut_article($id, $statut, $id_rubrique, $type='article', $ajax = false) {
 	global $spip_lang_left, $dir_lang, $connect_statut, $options;
-	static $script=NULL;
 	
+	if (!$id) {
+	  $id = $id_rubrique;
+	  $ajax_node ='';
+	} else	$ajax_node = " id='imgstatut$type$id'";
+
 	switch ($statut) {
 	case 'publie':
 		$clip = 2;
-		$puce = 'verte';
+		$puce = 'puce-verte.gif';
 		$title = _T('info_article_publie');
 		break;
 	case 'prepa':
 		$clip = 0;
-		$puce = 'blanche';
+		$puce = 'puce-blanche.gif';
 		$title = _T('info_article_redaction');
 		break;
 	case 'prop':
 		$clip = 1;
-		$puce = 'orange';
+		$puce = 'puce-orange.gif';
 		$title = _T('info_article_propose');
 		break;
 	case 'refuse':
 		$clip = 3;
-		$puce = 'rouge';
+		$puce = 'puce-rouge.gif';
 		$title = _T('info_article_refuse');
 		break;
 	case 'poubelle':
 		$clip = 4;
-		$puce = 'poubelle';
+		$puce = 'puce-poubelle.gif';
 		$title = _T('info_article_supprime');
 		break;
 	}
-	$puce = "puce-$puce.gif";
+
+	$inser_puce = http_img_pack($puce, $title, " style='margin: 1px;'$ajax_node");
 
 	include_spip('inc/autoriser');
-	if (autoriser('publierdans', 'rubrique', $id_rubrique)) {
-	  // les versions de MSIE ne font pas toutes pareil sur alt/title
-	  // la combinaison suivante semble ok pour tout le monde.
-	  $titles = array(
+	if (!autoriser('publierdans', 'rubrique', $id_rubrique))
+		return $inser_puce;
+
+	$titles = array(
 			  "blanche" => _T('texte_statut_en_cours_redaction'),
 			  "orange" => _T('texte_statut_propose_evaluation'),
 			  "verte" => _T('texte_statut_publie'),
 			  "rouge" => _T('texte_statut_refuse'),
 			  "poubelle" => _T('texte_statut_poubelle'));
-		if ($ajax){
-		  $action = "\nonmouseover=\"montrer('statutdecalarticle$id');\"";
-		  $inser_puce = 
-		  	// "\n<div class='puce_article' id='statut$id'$dir_lang>" .
-				"<div class='puce_article_fixe'\n$action>" .
-			  http_img_pack($puce, $title, "id='imgstatutarticle$id' style='margin: 1px;'") ."</div>"
-				. "<div class='puce_article_popup' id='statutdecalarticle$id'\nonmouseout=\"cacher('statutdecalarticle$id');\" style=' margin-left: -".((11*$clip)+1)."px;'>"
-				. afficher_script_statut($id, 'article', -1, 'puce-blanche.gif', 'prepa', $titles['blanche'], $action)
-				. afficher_script_statut($id, 'article', -12, 'puce-orange.gif', 'prop', $titles['orange'], $action)
-				. afficher_script_statut($id, 'article', -23, 'puce-verte.gif', 'publie', $titles['verte'], $action)
-				. afficher_script_statut($id, 'article', -34, 'puce-rouge.gif', 'refuse', $titles['rouge'], $action)
-				. afficher_script_statut($id, 'article', -45, 'puce-poubelle.gif', 'poubelle', $titles['poubelle'], $action)
-			. "</div>"
-			//. "</div>"
-			;
-		}
-		else{
-		  $inser_puce = "<div class='puce_article' id='statut$id'$dir_lang>".
-			  http_img_pack($puce, $title, "id='imgstatutarticle$id' style='margin: 1px;'") ."</div>";
-			if ($script==NULL && _SPIP_AJAX){
-				$action = "'".generer_url_ecrire('puce_statut_article',"id='+id",true);
-				$script = "<script type='text/javascript'>//<!--\n";
-				$script .= "$(document).ready(function(){
-					$('div.puce_article').mouseover( function() {
-						if(this.puce_loaded) return;
-						this.puce_loaded = true;
-						id = $(this).id();
-						id = id.substr(6,id.length-1);
-						$('#statut'+id).load($action,function(){ 
-								$('#statutdecalarticle'+id).show(); 
-								/*$('#statut'+id).mouseover(function(){ $(this).children('.puce_article_popup').show(); });*/
-							});
-						});
-					
-				})";
-				$script .= "//--></script>"; 
-				$inser_puce = $script . $inser_puce;
-			}
-		}
-	} else {
-		$inser_puce = http_img_pack($puce, $title, "id='imgstatutarticle$id' style='margin: 1px;'");
+	if ($ajax){
+		$action = "\nonmouseover=\"montrer('statutdecal$type$id');\"";
+		return 	"<div class='puce_article_fixe'\n$action>"
+		. $inser_puce
+		. "</div>"
+		. "<div class='puce_article_popup' id='statutdecal$type$id'\nonmouseout=\"cacher('statutdecal$type$id');\" style='margin-left: -".((11*$clip)+1)."px;'>"
+		  . afficher_script_statut($id, $type, -1, 'puce-blanche.gif', 'prepa', $titles['blanche'], $action)
+		  . afficher_script_statut($id, $type, -12, 'puce-orange.gif', 'prop', $titles['orange'], $action)
+		  . afficher_script_statut($id, $type, -23, 'puce-verte.gif', 'publie', $titles['verte'], $action)
+		  . afficher_script_statut($id, $type, -34, 'puce-rouge.gif', 'refuse', $titles['rouge'], $action)
+		  . afficher_script_statut($id, $type, -45, 'puce-poubelle.gif', 'poubelle', $titles['poubelle'], $action)
+		  . "</div>";
 	}
 
-	return $inser_puce;
+	$nom = "puce_statut_";
+
+	if ((! _SPIP_AJAX) AND $type != 'article') 
+	  $over ='';
+	else {
+
+	  $action = generer_url_ecrire('puce_statut_article',"",true);
+	  $action = "if (!this.puce_loaded) { this.puce_loaded = true; prepare_selec_statut('$nom', '$type', $id, '$action'); } }";
+	  $over = "\nonmouseover=\"$action\"";
+	}
+
+	return 	"<div class='puce_article' id='$nom$type$id'$dir_lang$over>"
+	. $inser_puce
+	. '</div>';
 }
 
 // http://doc.spip.org/@puce_statut_breve
-function puce_statut_breve($id, $statut, $type, $droit) {
+function puce_statut_breve($id, $statut, $type, $droit='AUTO') {
 	global $spip_lang_left, $dir_lang;
 
+	if ($droit == 'AUTO') {
+		include_spip('inc/autoriser');
+		$droit = autoriser('publierdans', 'rubrique', $id_rubrique);
+	}
 	$puces = array(
 		       0 => 'puce-orange-breve.gif',
 		       1 => 'puce-verte-breve.gif',
@@ -626,9 +620,6 @@ function puce_statut_breve($id, $statut, $type, $droit) {
 	$type2 = "statutdecal$type$id";
 	$action = "\nonmouseover=\"montrer('$type2');\"";
 
-	  // les versions de MSIE ne font pas toutes pareil sur alt/title
-	  // la combinaison suivante semble ok pour tout le monde.
-
 	return	"<div class='puce_breve' id='$type1'$dir_lang>"
 		. "<div class='puce_breve_fixe' $action>"
 		. $inser_puce
@@ -747,9 +738,11 @@ function afficher_articles_trad($titre_table, $requete, $formater, $tmp_var, $ha
 	}
 	$texte .=  '<b>' . $titre_table  . '</b>';
 
+	$icone = http_img_pack("article-24.gif",'','');
+
 	$res =  "\n<div style='height: 12px;'></div>"
 	. "\n<div class='liste'>"
-	. bandeau_titre_boite2($texte, "article-24.gif", 'white', 'black',false)
+	. bandeau_titre_boite2($texte, $icone, 'white', 'black',false)
 
 	. (($cpt <= $nb_aff) ? ''
 	   : afficher_tranches_requete($cpt, $tmp_var, generer_url_ecrire('memoriser', "hash=$hash&trad=$trad"), $nb_aff))
@@ -913,7 +906,7 @@ function afficher_breves_boucle($row, &$tous_id,  $voir_logo, $own)
 	else $lang = $langue_defaut;
 	$id_rubrique = $row['id_rubrique'];
 			
-	$vals[] = puce_statut_breve($id_breve, $statut, 'breve', ($droit && acces_rubrique($id_rubrique)), $id_rubrique);
+	$vals[] = puce_statut_breve($id_breve, $statut, 'breve', ($droit && acces_rubrique($id_rubrique)));
 
 	$s = "\n<div>";
 	$s .= "<a href='" . generer_url_ecrire("breves_voir","id_breve=$id_breve") . "' style=\"display:block;\">";
@@ -1786,7 +1779,7 @@ function debloquer_article($arg, $texte) {
 }
 
 // http://doc.spip.org/@meme_rubrique
-function meme_rubrique($id_rubrique, $id, $type, $order='date', $limit=30)
+function meme_rubrique($id_rubrique, $id, $type, $order='date', $limit=30, $ajax=false)
 {
 	global $options;
 
@@ -1794,18 +1787,30 @@ function meme_rubrique($id_rubrique, $id, $type, $order='date', $limit=30)
 
 	$table = $type . 's';
 	$key = 'id_' . $type;
+	$where = ($GLOBALS['auteur_session']['statut'] == '0minirezo')
+	? ''
+	:  " AND (statut = 'publie' OR statut = 'prop')"; 
+
+	$query = "SELECT $key AS id, titre, statut FROM spip_$table WHERE id_rubrique=$id_rubrique$where AND ($key != $id)";
 
-	$voss = spip_query("SELECT $key AS id, titre, statut FROM spip_$table WHERE id_rubrique=$id_rubrique AND (statut = 'publie' OR statut = 'prop') AND ($key != $id) ORDER BY $order DESC LIMIT $limit");
+	$n = spip_num_rows(spip_query($query));
 
-	if (!spip_num_rows($voss)) return '';
+	if (!$n) return '';
 
+	$voss = spip_query($query . " ORDER BY $order DESC LIMIT $limit");
+
+	$limit -= $n;
 	$retour = '';
+	$statuts = array();
+	$fstatut = 'puce_statut_' . $type;
 
 	while($row = spip_fetch_array($voss)) {
 		$id = $row['id'];
 		$num = afficher_numero_edit($id, $key, $type);
-		$statut = puce_statut_article($id, $row['statut'], $id_rubrique);
-		$href = "<a href='"
+		$statut = $row['statut'];
+		$statuts[$statut]++;
+		$statut = $fstatut($id, $statut, $id_rubrique);
+		$href = "<a class='verdana1' href='"
 		. generer_url_ecrire($table,"$key=$id")
 		. "'>"
 		. typo($row['titre'])
@@ -1813,12 +1818,21 @@ function meme_rubrique($id_rubrique, $id, $type, $order='date', $limit=30)
 		$retour .= "<tr class='tr_liste' style='background-color: #e0e0e0;'><td>$statut</td><td>$href</td><td style='width: 25%;'>$num</td></tr>";
 	}
 
-	return "\n<div>&nbsp;</div>"
-	. "\n<div class='bandeau_rubriques' style='z-index: 1;'>"
-	. bandeau_titre_boite2('<b>' . _T('info_meme_rubrique')  . '</b>', "article-24.gif",'','',false)
+	$type = 'rubrique_' . $table;
+	$statut = array_search(max($statuts), $statuts);
+	$icone =  puce_statut_article(0, $statut, $id_rubrique, $type);
+
+	$retour = bandeau_titre_boite2('<b>' . _T('info_meme_rubrique')  . '</b>' . $icone, 'article-24.gif','','',false)
 	. "\n<table style='font-size: 11px; background-color: #e0e0e0;border: 0px; padding-left:4px;'>"
 	. $retour
-	. "</table></div>";
+	. (($limit > 0) ? '' : "<tr><td colspan='3' style='text-align: center'>+ $limit</td></tr>")
+	. "</table>";
+
+	if ($ajax) return $retour;
+
+	// id utilise dans puce_statut_article
+	return "\n<div>&nbsp;</div>"
+	. "\n<div id='imgstatut$type$id_rubrique' class='bandeau_rubriques' style='z-index: 1;'>$retour</div>";
 }
 
 // http://doc.spip.org/@afficher_numero_edit
-- 
GitLab