From e51a5706676da0d8201575ff42a97bc756ab5e0c Mon Sep 17 00:00:00 2001
From: "Committo,Ergo:sum" <esj@rezo.net>
Date: Tue, 26 Jan 2010 13:15:59 +0000
Subject: [PATCH] =?UTF-8?q?Une=20petite=20fonction=20pour=20signaler=20(au?=
 =?UTF-8?q?x=20seuls=20webmestres)=20qu'une=20(ou=20des)=20versions=20de?=
 =?UTF-8?q?=20SPIP=20plus=20r=C3=A9centes=20que=20celle=20utilis=C3=A9e=20?=
 =?UTF-8?q?sont=20disponibles=20au=20chargement.=20Sans=20doute=20=C3=A0?=
 =?UTF-8?q?=20am=C3=A9liorer=20graphiquement,=20voire=20=C3=A0=20coupler?=
 =?UTF-8?q?=20avec=20[http://zone.spip.org/trac/spip-zone/changeset/34610?=
 =?UTF-8?q?=20spip=5Floader=20versions=20>=3D=202.1.0],=20mais=20ce=20sera?=
 =?UTF-8?q?it=20utile=20de=20le=20reporter=20en=202.1,=20voire=20dans=20le?=
 =?UTF-8?q?s=20futures=202.0.11=20et=201.9.2j.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 ecrire/inc/presentation_mini.php | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/ecrire/inc/presentation_mini.php b/ecrire/inc/presentation_mini.php
index 985d395605..79a0f20e1b 100644
--- a/ecrire/inc/presentation_mini.php
+++ b/ecrire/inc/presentation_mini.php
@@ -348,6 +348,8 @@ function fin_page()
 			.  _T("access_interface_graphique")
 			. "</a></div>")
 		: ("<div id='copyright'>"
+
+		. info_maj ()
 			. info_copyright()
 			. "<br />"
 		 	. _T('info_copyright_doc',
@@ -393,8 +395,36 @@ function info_copyright() {
 		   array('spip' => "<b>SPIP $version</b> ",
 			 'lien_gpl' =>
 			 "<a href='". generer_url_ecrire("aide_index", "aide=licence&var_lang=$spip_lang") . "' onclick=\"window.open(this.href, 'spip_aide', 'scrollbars=yes,resizable=yes,width=740,height=580'); return false;\">" . _T('info_copyright_gpl')."</a>"))
-			. $secu;
+		. $secu;
+
+}
 
+define('_VERSIONS_SERVEUR', 'http://files.spip.org/spip/archives/');
+
+function info_maj ()
+{
+	global $spip_version_branche;
+	if (!autoriser('webmestre')) return '';
+	include_spip('inc/distant');
+	if (!$page = recuperer_page(_VERSIONS_SERVEUR)) return '';
+	list($maj,$min,$rev) = preg_split('/\D+/', $spip_version_branche);
+#	list($maj,$min,$rev) = preg_split('/\D+/', '1.9.2i'); # pour test
+	// reperer toutes les versions de numero majeur superieur ou egal
+	// (a revoir quand on arrivera a SPIP V10 ...)
+	$p = substr("0123456789", intval($maj));
+	$re = ',' . _VERSIONS_SERVEUR . 'SPIP\D+([' . $p . ']+)\D+(\d+)(\D+(\d+))?[\w.-]*,';
+	preg_match_all($re, $page, $m,  PREG_SET_ORDER);
+	foreach ($m as $v) {
+		list(, $maj2, $min2,, $rev2) = $v;
+		if (($maj2 > $maj)
+		OR (($maj2 == $maj)
+			AND (($min2 > $min)
+				OR (($min2 == $min) AND ($rev2 > $rev)))))
+	    return "<br /><a style='color: red' href='" . _VERSIONS_SERVEUR . "'>" . 
+	    _L('De nouvelles_versions_de_SPIP_sont_disponibles') .
+	    '</a><br />';
+	}
+	  return "";
 }
 
 // http://doc.spip.org/@debloquer_article
-- 
GitLab