From 91893a7f2808fb4ae1a512d08ba4af0534e9473b Mon Sep 17 00:00:00 2001
From: Fil <fil@rezo.net>
Date: Tue, 1 Feb 2005 09:28:41 +0000
Subject: [PATCH] =?UTF-8?q?retour=20aux=20boutons=20d'admin=20compos=C3=A9?=
 =?UTF-8?q?s=20directement=20et=20sans=20css=20funky=20(=C3=A0=20revoir=20?=
 =?UTF-8?q?=C3=A9ventuellement)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

ajout : si on appelle article.php3?id_article=90 et que l'article 90 n'existe pas dans la base de données, n'afficher ni le bouton "Modifier cet article (90)" ni les stats.
---
 inc-admin.php3         | 57 +++++++++++++++++++++---------------------
 inc-public-global.php3 |  7 ------
 inc-public.php3        |  6 +++++
 3 files changed, 35 insertions(+), 35 deletions(-)

diff --git a/inc-admin.php3 b/inc-admin.php3
index 639ce0953c..41df71161d 100644
--- a/inc-admin.php3
+++ b/inc-admin.php3
@@ -4,7 +4,25 @@
 // puis les boutons
 // Feuilles de style admin : d'abord la CSS officielle, puis la perso,
 
-function affiche_boutons_admin(&$contenu) {
+function affiche_boutons_admin($contenu) {
+	$css = "<link rel='stylesheet' href='spip_admin.css' type='text/css' />\n";
+	if ($f = find_in_path('spip_admin_perso.css'))
+		$css2 = "<link rel='stylesheet' href='$f' type='text/css' />\n";
+
+	if (preg_match('@<(/head|body)@i', $contenu, $regs)) {
+		$contenu = explode($regs[0], $contenu, 2);
+		$contenu = $contenu[0] . $css. $css2 . $regs[0] . $contenu[1];
+	} else
+		$contenu = $css . $css2 . $contenu;
+
+	if (preg_match('@<(/body|/html)@i', $contenu, $regs)) {
+		$split = explode($regs[0], $contenu, 2);
+		$contenu = $split[0];
+		$suite = $regs[0].$split[1];
+	}
+
+	echo $contenu;
+
 	//
 	// Regler les boutons dans la langue de l'admin (sinon tant pis)
 	//
@@ -14,36 +32,19 @@ function affiche_boutons_admin(&$contenu) {
 	if ($row = spip_fetch_array(spip_query("SELECT lang FROM spip_auteurs WHERE login='$login'"))) {
 		$lang = $row['lang'];
 	}
+	lang_select($lang);
 
-	$css = "<link rel='stylesheet' href='spip_admin.css' type='text/css' />\n";
-	if ($f = find_in_path('spip_admin_perso.css'))
-		$css .= "<link rel='stylesheet' href='$f' type='text/css' />\n";
-
-#	$n = stripos($contenu, '</head>'); #PHP5
-	preg_match('@</head>@i',$contenu,$regs);
-	$n = strpos($contenu, $regs[0]);
-	if ($n)
-	  $contenu = substr($contenu,0,$n) . $css . substr($contenu,$n);
-	else 
-	  // squelette pourri: on force
-	  $contenu = "<html><head>$css</head>$contenu";
-	$insere = synthetiser_balise_dynamique('formulaire_admin',
-					       array(
+	// Afficher la balise #FORMULAIRE_ADMIN mais en float
+	inclure_balise_dynamique(
+		balise_formulaire_admin_dyn(
 		$GLOBALS['id_article'], $GLOBALS['id_breve'],
 		$GLOBALS['id_rubrique'], $GLOBALS['id_mot'],
-		$GLOBALS['id_auteur'], 'div'),
-					       find_in_path('inc-formulaire_admin' . _EXTENSION_PHP),
-					       $lang);
-
-	preg_match('@<body[^>]*>@i',$contenu,$regs);
-	$n = strpos($contenu, $regs[0]) + strlen($regs[0]);
-	if ($n) 
-	  $contenu = substr($contenu,0,$n) . $insere . substr($contenu,$n);
-	else 
-	  // squelette pourri: on force
-	  $contenu .=  $insere;
-
-	return $contenu;
+		$GLOBALS['id_auteur'], 'div'
+	));
+
+	lang_dselect();
+
+	return $suite;
 }
 
 ?>
diff --git a/inc-public-global.php3 b/inc-public-global.php3
index 1ef4239557..b73404c60f 100644
--- a/inc-public-global.php3
+++ b/inc-public-global.php3
@@ -97,13 +97,6 @@ function calcule_header_et_page ($fond, $delais) {
 			header("Last-Modified: ".http_gmoddate($lastmodified)." GMT");
 			header("Content-Type: text/html; charset=".lire_meta('charset'));
 		}
-
-		// Inserer au besoin les boutons admins
-		if ($affiche_boutons_admin) {
-			include_local("inc-admin.php3");
-			$page['process_ins'] = 'php';
-			$page['texte'] = affiche_boutons_admin($page['texte']);
-		}
 	}
 
 	return $page;
diff --git a/inc-public.php3 b/inc-public.php3
index c7f1c29cff..3eb5808490 100644
--- a/inc-public.php3
+++ b/inc-public.php3
@@ -57,6 +57,12 @@ if (defined("_INC_PUBLIC")) {
 		}
 	}
 
+	// Inserer au besoin les boutons admins
+	if ($affiche_boutons_admin) {
+		include_local("inc-admin.php3");
+		$page = affiche_boutons_admin($page);
+	}
+
 	// Passer la main au debuggueur le cas echeant 
 	if ($var_mode == 'debug') {
 		include_ecrire("inc_debug_sql.php3");
-- 
GitLab