From 81822b784331d9bbdcbc1f2d2110165be5efdb2c Mon Sep 17 00:00:00 2001
From: Fil <fil@rezo.net>
Date: Mon, 20 Dec 2004 21:18:05 +0000
Subject: [PATCH] gestion + correcte des boutons d'admin

---
 article-dist.html          |   1 -
 auteur-dist.html           |   2 -
 breve-dist.html            |   1 -
 ecrire/inc_auth.php3       |   3 +-
 formulaire_admin-dist.html |  18 +++----
 forum-dist.html            |   1 -
 inc-admin.php3             | 100 ++++++++++++++++++-------------------
 inc-calcul.php3            |   9 +++-
 login-dist.html            |   1 -
 mot-dist.html              |   1 -
 plan-dist.html             |   1 -
 recherche-dist.html        |   1 -
 resume-dist.html           |   1 -
 rubrique-dist.html         |   1 -
 site-dist.html             |   1 -
 sommaire-dist.html         |   1 -
 16 files changed, 67 insertions(+), 76 deletions(-)

diff --git a/article-dist.html b/article-dist.html
index fc32569baf..aacbf4bdce 100644
--- a/article-dist.html
+++ b/article-dist.html
@@ -14,7 +14,6 @@
 <link rel="stylesheet" href="habillage.css" type="text/css" media="projection, screen, tv">
 <!-- media="print" permet d'utiliser cette feuille de style quand vous imprimez depuis votre navigateur -->
 <link rel="stylesheet" href="impression.css" type="text/css" media="print">
-<link rel='stylesheet' href='spip_admin.css' type='text/css' />
 </head>
 
 <body bgcolor="white" dir="#LANG_DIR">
diff --git a/auteur-dist.html b/auteur-dist.html
index 1e03a808ba..e92f817222 100644
--- a/auteur-dist.html
+++ b/auteur-dist.html
@@ -16,8 +16,6 @@
 <link rel="stylesheet" href="habillage.css" type="text/css" media="projection, screen, tv">
 <!-- media="print" permet d'utiliser cette feuille de style quand vous imprimez depuis votre navigateur -->
 <link rel="stylesheet" href="impression.css" type="text/css" media="print">
-<link rel='stylesheet' href='spip_admin.css' type='text/css' />
-
 </head>
 
 <body bgcolor="white">
diff --git a/breve-dist.html b/breve-dist.html
index dc285c0fbd..fca1768ee1 100644
--- a/breve-dist.html
+++ b/breve-dist.html
@@ -16,7 +16,6 @@
 <link rel="stylesheet" href="habillage.css" type="text/css" media="projection, screen, tv">
 <!-- media="print" permet d'utiliser cette feuille de style quand vous imprimez depuis votre navigateur -->
 <link rel="stylesheet" href="impression.css" type="text/css" media="print">
-<link rel='stylesheet' href='spip_admin.css' type='text/css' />
 </head>
 
 <body bgcolor="white" dir="#LANG_DIR">
diff --git a/ecrire/inc_auth.php3 b/ecrire/inc_auth.php3
index ffa5c31be1..edabb8ed8d 100644
--- a/ecrire/inc_auth.php3
+++ b/ecrire/inc_auth.php3
@@ -5,7 +5,8 @@
 if (defined("_ECRIRE_INC_AUTH")) return;
 define("_ECRIRE_INC_AUTH", "1");
 
-include_ecrire ("inc_meta.php3"); // amorce la connexion MySQL
+include_ecrire ("inc_connect.php3");
+include_ecrire ("inc_meta.php3");
 include_ecrire ("inc_session.php3");
 
 //
diff --git a/formulaire_admin-dist.html b/formulaire_admin-dist.html
index bc7abb17d8..fc365e4609 100644
--- a/formulaire_admin-dist.html
+++ b/formulaire_admin-dist.html
@@ -1,16 +1,16 @@
 <div class="spip-admin-float">
-  <div class="spip-admin-bloc" dir='#LANG_DIR'>
-    <div class="spip-admin">
+<div class="spip-admin-bloc" dir='#LANG_DIR'>
+<div class="spip-admin">
 	<ul>[
-	<li><a href='ecrire/articles.php3?id_article=(#HTTP_VARS{id_article})' class='spip-admin-boutons'><:admin_modifier_article:></a></li>][
-	<li><a href='ecrire/breves_voir.php3?id_breve=(#HTTP_VARS{id_breve})' class='spip-admin-boutons'><:admin_modifier_breve:></a></li>][
-	<li><a href='ecrire/naviguer.php3?id_rubrique=(#HTTP_VARS{id_rubrique})' class='spip-admin-boutons'><:admin_modifier_rubrique:></a></li>][
-	<li><a href='ecrire/mots_edit.php3?id_mot=(#HTTP_VARS{id_mot})' class='spip-admin-boutons'><:admin_modifier_mot:></a></li>][
-	<li><a href='ecrire/auteurs_edit.php3?id_auteur=(#HTTP_VARS{id_auteur})' class='spip-admin-boutons'><:admin_modifier_auteur:></a></li>]
+	<li><a href='ecrire/articles.php3?id_article=(#HTTP_VARS{id_article})' class='spip-admin-boutons'><:admin_modifier_article:> ([(#HTTP_VARS{id_article})])</a></li>][
+	<li><a href='ecrire/breves_voir.php3?id_breve=(#HTTP_VARS{id_breve})' class='spip-admin-boutons'><:admin_modifier_breve:> ([(#HTTP_VARS{id_breve})])</a></li>][
+	<li><a href='ecrire/naviguer.php3?id_rubrique=(#HTTP_VARS{id_rubrique})' class='spip-admin-boutons'><:admin_modifier_rubrique:> ([(#HTTP_VARS{id_rubrique})])</a></li>][
+	<li><a href='ecrire/mots_edit.php3?id_mot=(#HTTP_VARS{id_mot})' class='spip-admin-boutons'><:admin_modifier_mot:> ([(#HTTP_VARS{id_mot})])</a></li>][
+	<li><a href='ecrire/auteurs_edit.php3?id_auteur=(#HTTP_VARS{id_auteur})' class='spip-admin-boutons'><:admin_modifier_auteur:> ([(#HTTP_VARS{id_auteur})])</a></li>]
 	<li><a href='[(#HTTP_VARS{action})]var_mode=recalcul' class='spip-admin-boutons'><:admin_recalculer:>[(#HTTP_VARS{use_cache})]</a></li>[
 	<li><a href='ecrire/(#HTTP_VARS{statistiques})[id_article=(#HTTP_VARS{id_article})]' class='spip-admin-boutons'><:info_visites:>&nbsp;[(#HTTP_VARS{visites})];&nbsp;<:info_popularite_5:>&nbsp;[(#HTTP_VARS{popularite})]</a></li>][
 	<li><a href='[(#HTTP_VARS{action})]var_mode=(#HTTP_VARS{debug})' class='spip-admin-boutons'>Debug</a></li>]
 	</ul>
-    </div>
-  </div>
+</div>
+</div>
 </div>
diff --git a/forum-dist.html b/forum-dist.html
index b48613b72d..7a4cb62fd5 100644
--- a/forum-dist.html
+++ b/forum-dist.html
@@ -12,7 +12,6 @@
 
 <!-- media="..." permet de ne pas utiliser ce style sous Netscape 4 (sinon plantage) -->
 <link rel="stylesheet" href="habillage.css" type="text/css" media="print, projection, screen, tv">
-<link rel='stylesheet' href='spip_admin.css' type='text/css' />
 </head>
 
 <body bgcolor="white" dir="#LANG_DIR">
diff --git a/inc-admin.php3 b/inc-admin.php3
index 721da34819..7f24036a63 100644
--- a/inc-admin.php3
+++ b/inc-admin.php3
@@ -27,27 +27,25 @@ function admin_dyn($id_article, $id_breve, $id_rubrique, $id_mot, $id_auteur, $d
 	static $dejafait = false;
 
 	if ($GLOBALS['flag_preserver'] || !$GLOBALS['spip_admin'])
-	  return '';
-
-	if (!is_array($debug))
-	  {
-	    if ($dejafait) return '';
-	  }
-	else {
-	  if ($dejafait) {
-	    $res = '';
-	    foreach($debug['sourcefile'] as $k => $v) {
-	      if (strpos($v,'formulaire_admin') === 0)
-		{return $debug['resultat'][$k . 'tout'];}
-	    }
-	    return '';
-	  }
-	}
+		return '';
 
+	if (!is_array($debug)) {
+		if ($dejafait)
+			return '';
+	} else {
+		if ($dejafait) {
+			$res = '';
+			foreach($debug['sourcefile'] as $k => $v) {
+				if (strpos($v,'formulaire_admin') === 0)
+					return $debug['resultat'][$k . 'tout'];
+			}
+			return '';
+		}
+	}
 	$dejafait = true;
 
-	include(_FILE_CONNECT);
 	// regler les boutons dans la langue de l'admin (sinon tant pis)
+	include(_FILE_CONNECT);
 	$login = addslashes(ereg_replace('^@','',$GLOBALS['spip_admin']));
 	if ($row = spip_fetch_array(spip_query("SELECT lang FROM spip_auteurs WHERE login='$login'"))) {
 		$lang = $row['lang'];
@@ -66,8 +64,8 @@ function admin_dyn($id_article, $id_breve, $id_rubrique, $id_mot, $id_auteur, $d
 	if (!$var_preview) {
 		// Bouton statistiques
 		if (lire_meta("activer_statistiques") != "non" 
-		    AND $id_article
-		    AND ($GLOBALS['auteur_session']['statut'] == '0minirezo')) {
+		AND $id_article
+		AND ($GLOBALS['auteur_session']['statut'] == '0minirezo')) {
 			if (spip_fetch_array(spip_query("SELECT id_article
 			FROM spip_articles WHERE statut='publie'
 			AND id_article =".intval($id_article)))) {
@@ -80,28 +78,34 @@ function admin_dyn($id_article, $id_breve, $id_rubrique, $id_mot, $id_auteur, $d
 		}
 
 		// Bouton de debug
-		$debug = (($forcer_debug
-			  OR $GLOBALS['bouton_admin_debug']
-			  OR ($GLOBALS['var_mode'] == 'debug'
-			      AND $GLOBALS['HTTP_COOKIE_VARS']['spip_debug']))
-		  	AND ($GLOBALS['code_activation_debug'] == 'oui' OR
-			     ($GLOBALS['auteur_session']['statut'] == '0minirezo'))) ?
-		  'debug' : '';
+		$debug = (
+			($forcer_debug
+			OR $GLOBALS['bouton_admin_debug']
+			OR ($GLOBALS['var_mode'] == 'debug'
+				AND $GLOBALS['HTTP_COOKIE_VARS']['spip_debug']
+			)) AND ($GLOBALS['code_activation_debug'] == 'oui'
+				OR $GLOBALS['auteur_session']['statut'] == '0minirezo')
+		) ? 'debug' : '';
 	}
 
+	// hack - ne pas avoir la rubrique si un autre bouton est deja present
+	if ($id_article OR $id_breve) unset ($id_rubrique);
+
 	return array('formulaire_admin', 0,
-		     array(
-			   'action' => $action,
-			   'id_article' => $id_article,
-			   'id_auteur' => $id_auteur,
-			   'id_breve' => $id_breve,
-			   'debug' => $debug,
-			   'id_mot' => $id_mot,
-			   'popularite' => intval($popularite),
-			   'rubrique' => $rubrique,
-			   'statistiques' => $statistiques,
-			   'visites' => intval($visites),
-			   'use_cache' => ($use_cache ? ' *' : '')));
+			array(
+				'id_article' => $id_article,
+				'id_rubrique' => $id_rubrique,
+				'id_auteur' => $id_auteur,
+				'id_breve' => $id_breve,
+				'id_mot' => $id_mot,
+				'action' => $action,
+				'debug' => $debug,
+				'popularite' => intval($popularite),
+				'statistiques' => $statistiques,
+				'visites' => intval($visites),
+				'use_cache' => ($use_cache ? ' *' : '')
+			)
+		);
 }
 
 
@@ -111,20 +115,12 @@ function perso_admin($texte) {
 	$css = "<link rel='stylesheet' href='spip_admin.css' type='text/css' />\n";
 	if (@file_exists('spip_admin_perso.css'))
 		$css2 = "<link rel='stylesheet' href='spip_admin_perso.css' type='text/css' />\n";
-	else $css2 = '';
-	$x = strpos($texte,$css);
-	if ($x !== false) {
-		if ($css2) {
-			$x+=strlen($css);
-			return substr($texte,0,$x) . $css2 . substr($texte,$x+1);
-		} else 	return $texte;
-	} else {
-		if (eregi('<(/head|body)', $texte, $regs)) {
-			$texte = explode($regs[0], $texte, 2);
-			return $texte[0] . $css. $css2 . $regs[0] . $texte[1];
-		} else
-			return $css . $css2 . $texte;
-	}
+
+	if (eregi('<(/head|body)', $texte, $regs)) {
+		$texte = explode($regs[0], $texte, 2);
+		return $texte[0] . $css. $css2 . $regs[0] . $texte[1];
+	} else
+		return $css . $css2 . $texte;
 }
 
 ?>
diff --git a/inc-calcul.php3 b/inc-calcul.php3
index 16ca8328e7..bc5946bd74 100644
--- a/inc-calcul.php3
+++ b/inc-calcul.php3
@@ -176,7 +176,14 @@ function cherche_page ($cache, $contexte, $fond)  {
 	return $page;
 }
 
-// Contexte: les parametres HHTP sauf ceux ajoutés par spip + la globale date
+
+//
+// Contexte : lors du calcul d'une page spip etablit le contexte a partir
+// des variables $HTTP_GET_VARS et $HTTP_POST_VARS, et leur ajoute la date
+// Note : pour hacker le contexte depuis le fichier d'appel (article.php3),
+// il est recommande de modifier $HTTP_GET_VARS['toto'] (meme si la page est
+// appelee avec la methode POST).
+//
 function calculer_contexte() {
 	foreach($GLOBALS['HTTP_GET_VARS'] as $var => $val) {
 		if (strpos($var, 'var_') !== 0)
diff --git a/login-dist.html b/login-dist.html
index 5870ea3f02..add5835cd4 100644
--- a/login-dist.html
+++ b/login-dist.html
@@ -4,7 +4,6 @@
 	<title><:login_acces_prive:></title>
 	<meta http-equiv="Content-Type" content="text/html; charset=#CHARSET">
 	<link rel="stylesheet" href="spip_style.css" type="text/css">
-	<link rel='stylesheet' href='spip_admin.css' type='text/css' />
 </head>
 <body dir="#LANG_DIR" bgcolor="#ffffff" text="#000000" link="#e86519" vlink="#6e003a" alink="#ff9900">
 
diff --git a/mot-dist.html b/mot-dist.html
index 0c79df6bd2..022f62cc0f 100644
--- a/mot-dist.html
+++ b/mot-dist.html
@@ -16,7 +16,6 @@
 <link rel="stylesheet" href="habillage.css" type="text/css" media="projection, screen, tv">
 <!-- media="print" permet d'utiliser cette feuille de style quand vous imprimez depuis votre navigateur -->
 <link rel="stylesheet" href="impression.css" type="text/css" media="print">
-<link rel='stylesheet' href='spip_admin.css' type='text/css' />
 </head>
 
 <body bgcolor="white" dir="#LANG_DIR">
diff --git a/plan-dist.html b/plan-dist.html
index e2d00770a6..6ff2474133 100644
--- a/plan-dist.html
+++ b/plan-dist.html
@@ -12,7 +12,6 @@
 
 <!-- media="..." permet de ne pas utiliser ce style sous Netscape 4 (sinon plantage) -->
 <link rel="stylesheet" href="habillage.css" type="text/css" media="print, projection, screen, tv">
-<link rel='stylesheet' href='spip_admin.css' type='text/css' />
 </head>
 
 <body bgcolor="white" dir="#LANG_DIR">
diff --git a/recherche-dist.html b/recherche-dist.html
index efd7004bf4..c5e5c2ff5d 100644
--- a/recherche-dist.html
+++ b/recherche-dist.html
@@ -15,7 +15,6 @@
 <link rel="stylesheet" href="habillage.css" type="text/css" media="projection, screen, tv">
 <!-- media="print" permet d'utiliser cette feuille de style quand vous imprimez depuis votre navigateur -->
 <link rel="stylesheet" href="impression.css" type="text/css" media="print">
-<link rel='stylesheet' href='spip_admin.css' type='text/css' />
 </head>
 
 <body bgcolor="white" dir="#LANG_DIR">
diff --git a/resume-dist.html b/resume-dist.html
index 70c08703a6..46bbf9de0c 100644
--- a/resume-dist.html
+++ b/resume-dist.html
@@ -12,7 +12,6 @@
 
 <!-- media="..." permet de ne pas utiliser ce style sous Netscape 4 (sinon plantage) -->
 <link rel="stylesheet" href="habillage.css" type="text/css" media="print, projection, screen, tv">
-<link rel='stylesheet' href='spip_admin.css' type='text/css' />
 </head>
 
 <body bgcolor="white" dir="#LANG_DIR">
diff --git a/rubrique-dist.html b/rubrique-dist.html
index 7ad805dd21..890a0ee9a9 100644
--- a/rubrique-dist.html
+++ b/rubrique-dist.html
@@ -19,7 +19,6 @@
 
 <!-- Lien vers le backend pour navigateurs eclaires -->
 <link rel="alternate" type="application/rss+xml" title="<:syndiquer_rubrique:>" href="backend.php3?id_rubrique=#ID_RUBRIQUE">
-<link rel='stylesheet' href='spip_admin.css' type='text/css' />
 </head>
 
 <body bgcolor="white" dir="#LANG_DIR">
diff --git a/site-dist.html b/site-dist.html
index 8e20f0eeb8..f40ff3dea1 100644
--- a/site-dist.html
+++ b/site-dist.html
@@ -16,7 +16,6 @@
 <link rel="stylesheet" href="habillage.css" type="text/css" media="projection, screen, tv">
 <!-- media="print" permet d'utiliser cette feuille de style quand vous imprimez depuis votre navigateur -->
 <link rel="stylesheet" href="impression.css" type="text/css" media="print">
-<link rel='stylesheet' href='spip_admin.css' type='text/css' />
 </head>
 
 <body bgcolor="white">
diff --git a/sommaire-dist.html b/sommaire-dist.html
index b8de073306..4efe41812f 100644
--- a/sommaire-dist.html
+++ b/sommaire-dist.html
@@ -15,7 +15,6 @@
 
 <!-- Lien vers le backend pour navigateurs eclaires -->
 <link rel="alternate" type="application/rss+xml" title="<:syndiquer_site:>" href="backend.php3">
-<link rel='stylesheet' href='spip_admin.css' type='text/css' />
 </head>
 
 <body bgcolor="white" dir="#LANG_DIR">
-- 
GitLab