From 2c2ad593bfef7f3437dd27465334ef7d99b7d34a Mon Sep 17 00:00:00 2001
From: "Committo,Ergo:sum" <esj@rezo.net>
Date: Fri, 6 Oct 2006 08:48:32 +0000
Subject: [PATCH] =?UTF-8?q?Permettre=20la=20surcharge=20des=20etapes=20d'i?=
 =?UTF-8?q?nstallation.=20En=20profiter=20pour=20les=20mettre=20dans=20un?=
 =?UTF-8?q?=20r=C3=A9pertoire=20diff=C3=A9rent,=20inc/=20devenant=20vraime?=
 =?UTF-8?q?nt=20trop=20gros.=20Et=20extension=20de=20charger=5Ffonction=20?=
 =?UTF-8?q?pour=20qu'elle=20accepte=20des=20r=C3=A9pertoires=20de=20profon?=
 =?UTF-8?q?deur=20quelconque=20(pas=20encore=20utilis=C3=A9=20finalement?=
 =?UTF-8?q?=20mais=20=C3=A7a=20finira=20par=20servir).?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 .gitattributes                                | 27 ++++++------
 ecrire/exec/install.php                       |  4 +-
 ecrire/inc/install_.php                       | 43 -------------------
 ecrire/inc/utils.php                          | 16 ++++---
 .../{inc/install_0.php => install/etape_.php} |  2 +-
 .../install_1.php => install/etape_1.php}     |  2 +-
 .../install_2.php => install/etape_2.php}     |  2 +-
 .../install_3.php => install/etape_3.php}     |  2 +-
 .../install_4.php => install/etape_4.php}     |  2 +-
 .../install_5.php => install/etape_5.php}     |  2 +-
 .../install_6.php => install/etape_6.php}     |  2 +-
 .../etape_ldap1.php}                          |  4 +-
 .../etape_ldap2.php}                          |  2 +-
 .../etape_ldap3.php}                          |  4 +-
 .../etape_ldap4.php}                          |  4 +-
 .../etape_ldap5.php}                          |  4 +-
 .../etape_unpack.php}                         |  4 +-
 17 files changed, 42 insertions(+), 84 deletions(-)
 delete mode 100644 ecrire/inc/install_.php
 rename ecrire/{inc/install_0.php => install/etape_.php} (98%)
 rename ecrire/{inc/install_1.php => install/etape_1.php} (98%)
 rename ecrire/{inc/install_2.php => install/etape_2.php} (98%)
 rename ecrire/{inc/install_3.php => install/etape_3.php} (99%)
 rename ecrire/{inc/install_4.php => install/etape_4.php} (99%)
 rename ecrire/{inc/install_5.php => install/etape_5.php} (98%)
 rename ecrire/{inc/install_6.php => install/etape_6.php} (99%)
 rename ecrire/{inc/install_ldap1.php => install/etape_ldap1.php} (98%)
 rename ecrire/{inc/install_ldap2.php => install/etape_ldap2.php} (98%)
 rename ecrire/{inc/install_ldap3.php => install/etape_ldap3.php} (98%)
 rename ecrire/{inc/install_ldap4.php => install/etape_ldap4.php} (98%)
 rename ecrire/{inc/install_ldap5.php => install/etape_ldap5.php} (97%)
 rename ecrire/{inc/install_unpack.php => install/etape_unpack.php} (97%)

diff --git a/.gitattributes b/.gitattributes
index 8d194e3cbd..711de67996 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -443,20 +443,6 @@ ecrire/inc/import_0_0.php -text
 ecrire/inc/import_1_2.php -text
 ecrire/inc/import_1_3.php -text
 ecrire/inc/informer.php -text
-ecrire/inc/install_.php -text
-ecrire/inc/install_0.php -text
-ecrire/inc/install_1.php -text
-ecrire/inc/install_2.php -text
-ecrire/inc/install_3.php -text
-ecrire/inc/install_4.php -text
-ecrire/inc/install_5.php -text
-ecrire/inc/install_6.php -text
-ecrire/inc/install_ldap1.php -text
-ecrire/inc/install_ldap2.php -text
-ecrire/inc/install_ldap3.php -text
-ecrire/inc/install_ldap4.php -text
-ecrire/inc/install_ldap5.php -text
-ecrire/inc/install_unpack.php -text
 ecrire/inc/instituer_article.php -text
 ecrire/inc/instituer_auteur.php -text
 ecrire/inc/joindre.php -text
@@ -477,6 +463,19 @@ ecrire/inc/syndic.php -text
 ecrire/inc/tourner.php -text
 ecrire/inc/utils.php -text
 ecrire/inc/virtualiser.php -text
+ecrire/install/etape_.php -text
+ecrire/install/etape_1.php -text
+ecrire/install/etape_2.php -text
+ecrire/install/etape_3.php -text
+ecrire/install/etape_4.php -text
+ecrire/install/etape_5.php -text
+ecrire/install/etape_6.php -text
+ecrire/install/etape_ldap1.php -text
+ecrire/install/etape_ldap2.php -text
+ecrire/install/etape_ldap3.php -text
+ecrire/install/etape_ldap4.php -text
+ecrire/install/etape_ldap5.php -text
+ecrire/install/etape_unpack.php -text
 ecrire/lang/ecrire_br.php -text
 ecrire/lang/ecrire_bs.php -text
 ecrire/lang/ecrire_cs.php -text
diff --git a/ecrire/exec/install.php b/ecrire/exec/install.php
index d7c342a56f..6ab3ab3ac7 100644
--- a/ecrire/exec/install.php
+++ b/ecrire/exec/install.php
@@ -18,7 +18,7 @@ define('_FILE_TMP', '_install');
 // http://doc.spip.org/@exec_install_dist
 function exec_install_dist()
 {
-	global $etape;
+	$etape = _request('etape');
 	if (_FILE_CONNECT && $etape != 'unpack') 
 		minipres(_T('avis_espace_interdit'));
 	else {
@@ -34,7 +34,7 @@ function exec_install_dist()
 	include_spip('base/create');
 	include_spip('base/db_mysql');
 
-	$fonc = charger_fonction("install_$etape", 'inc');
+	$fonc = charger_fonction("etape_$etape", 'install');
 	$fonc();
 	}
 }
diff --git a/ecrire/inc/install_.php b/ecrire/inc/install_.php
deleted file mode 100644
index 64b5d1841e..0000000000
--- a/ecrire/inc/install_.php
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php
-
-/***************************************************************************\
- *  SPIP, Systeme de publication pour l'internet                           *
- *                                                                         *
- *  Copyright (c) 2001-2006                                                *
- *  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.   *
-\***************************************************************************/
-
-// http://doc.spip.org/@inc_install_
-function inc_install_()
-{
-	global $spip_lang_right;
-
-	$menu_langues = menu_langues('var_lang_ecrire');
-	if (!$menu_langues)
-		redirige_par_entete(generer_url_action('test_dirs'));
-	else {
-		install_debut_html();
-	
-		echo "<p align='center'><img src='" . _DIR_IMG_PACK . "logo-spip.gif'></p>",
-		  "<p style='text-align: center; font-family: Verdana,Arial,Sans,sans-serif; font-size: 10px;'>",
-		 info_copyright(),
-		  "</p>",
-		  "<p>" . _T('install_select_langue'),
-		  "<p><div align='center'>",
-		  $menu_langues,
-		  "</div>",
-		  "<p><form action='", generer_url_action('test_dirs'),
-		  "'>",
-		  '<input type="hidden" name="action" value="test_dirs" />',
-		  "<div align='$spip_lang_right'><input type='submit' class='fondl'  VALUE='",
-		  _T('bouton_suivant'),
-		  " >>'>",
-		  "</form>";
-		install_fin_html();
-	}
-}
-
-?>
\ No newline at end of file
diff --git a/ecrire/inc/utils.php b/ecrire/inc/utils.php
index 919a73fbd4..3d084bb15e 100644
--- a/ecrire/inc/utils.php
+++ b/ecrire/inc/utils.php
@@ -47,15 +47,17 @@ function charger_fonction($nom, $dossier='exec', $continue=false) {
 	if (!preg_match(',^\w+$,', $nom))
 		redirige_par_entete('./');
 
-	if (substr($dossier,-1) == '/') $dossier = substr($dossier,0,-1);
+	if (substr($dossier,-1) != '/') $dossier .= '/';
 	// Si la fonction existe deja (definie par mes_options, par exemple)
 	
-	if (function_exists($f = $dossier.'_'.$nom)) return $f;
-	if (function_exists($g = $f . '_dist'))	return $g;
+	if (function_exists($f = str_replace('/','_',$dossier) . $nom))
+		return $f;
+	if (function_exists($g = $f . '_dist'))
+		return $g;
 
 	// Sinon charger le fichier de declaration
 	// passer en minuscules (cf les balises de formulaires)
-	$inc = include_spip($dossier.'/'. strtolower($nom));
+	$inc = include_spip($d = ($dossier . strtolower($nom)));
 
 	if (function_exists($f)) return $f;
 	if (function_exists($g)) return $g;
@@ -63,12 +65,12 @@ function charger_fonction($nom, $dossier='exec', $continue=false) {
 	if ($continue) return false;
 
 	// Echec : message d'erreur
-	spip_log("fonction $nom indisponible" .
-		($inc ? "" : "(fichier $dossier/$nom absent)"));
+	spip_log("fonction $nom ($f ou $g) indisponible" .
+		($inc ? "" : " (fichier $d absent)"));
 
 	include_spip('inc/minipres');
 	minipres(_T('forum_titre_erreur'),
-		 _T('fichier_introuvable', array('fichier'=> '<b>'.htmlentities("$dossier/$nom").'</b>')));
+		 _T('fichier_introuvable', array('fichier'=> '<b>'.htmlentities($d).'</b>')));
 }
 
 //
diff --git a/ecrire/inc/install_0.php b/ecrire/install/etape_.php
similarity index 98%
rename from ecrire/inc/install_0.php
rename to ecrire/install/etape_.php
index 69a29142a1..f29780de63 100644
--- a/ecrire/inc/install_0.php
+++ b/ecrire/install/etape_.php
@@ -11,7 +11,7 @@
 \***************************************************************************/
 
 // http://doc.spip.org/@inc_install_
-function inc_install_()
+function install_etape__dist()
 {
 	global $spip_lang_right;
 
diff --git a/ecrire/inc/install_1.php b/ecrire/install/etape_1.php
similarity index 98%
rename from ecrire/inc/install_1.php
rename to ecrire/install/etape_1.php
index bf9b4381a2..885a82dd8c 100644
--- a/ecrire/inc/install_1.php
+++ b/ecrire/install/etape_1.php
@@ -11,7 +11,7 @@
 \***************************************************************************/
 
 // http://doc.spip.org/@inc_install_1
-function inc_install_1()
+function install_etape_1_dist()
 {
 	global $spip_lang_right;
 
diff --git a/ecrire/inc/install_2.php b/ecrire/install/etape_2.php
similarity index 98%
rename from ecrire/inc/install_2.php
rename to ecrire/install/etape_2.php
index afc1ba9d6a..1fc3f41f80 100644
--- a/ecrire/inc/install_2.php
+++ b/ecrire/install/etape_2.php
@@ -11,7 +11,7 @@
 \***************************************************************************/
 
 // http://doc.spip.org/@inc_install_2
-function inc_install_2()
+function install_etape_2_dist()
 {
 	global $adresse_db, $login_db, $pass_db, $spip_lang_right;
 
diff --git a/ecrire/inc/install_3.php b/ecrire/install/etape_3.php
similarity index 99%
rename from ecrire/inc/install_3.php
rename to ecrire/install/etape_3.php
index 8a1a249fb5..ffc2a694dc 100644
--- a/ecrire/inc/install_3.php
+++ b/ecrire/install/etape_3.php
@@ -11,7 +11,7 @@
 \***************************************************************************/
 
 // http://doc.spip.org/@inc_install_3
-function inc_install_3()
+function install_etape_3_dist()
 {
 	global $adresse_db, $login_db, $pass_db, $spip_lang_right;
 
diff --git a/ecrire/inc/install_4.php b/ecrire/install/etape_4.php
similarity index 99%
rename from ecrire/inc/install_4.php
rename to ecrire/install/etape_4.php
index 748c855a6a..9dae166ded 100644
--- a/ecrire/inc/install_4.php
+++ b/ecrire/install/etape_4.php
@@ -11,7 +11,7 @@
 \***************************************************************************/
 
 // http://doc.spip.org/@inc_install_4
-function inc_install_4()
+function install_etape_4_dist()
 {
 	global $adresse_db, $choix_db, $login_db, $pass_db, $spip_lang_right, $spip_version, $table_new;
 
diff --git a/ecrire/inc/install_5.php b/ecrire/install/etape_5.php
similarity index 98%
rename from ecrire/inc/install_5.php
rename to ecrire/install/etape_5.php
index 34679e4311..3aff37a5e0 100644
--- a/ecrire/inc/install_5.php
+++ b/ecrire/install/etape_5.php
@@ -11,7 +11,7 @@
 \***************************************************************************/
 
 // http://doc.spip.org/@inc_install_5
-function inc_install_5()
+function install_etape_5_dist()
 {
 	global $email, $ldap_present, $login, $nom, $pass, $spip_lang_right;
 
diff --git a/ecrire/inc/install_6.php b/ecrire/install/etape_6.php
similarity index 99%
rename from ecrire/inc/install_6.php
rename to ecrire/install/etape_6.php
index 60a4454120..cfe9f9357d 100644
--- a/ecrire/inc/install_6.php
+++ b/ecrire/install/etape_6.php
@@ -11,7 +11,7 @@
 \***************************************************************************/
 
 // http://doc.spip.org/@inc_install_6
-function inc_install_6()
+function install_etape_6_dist()
 {
 	global $email,$login,$nom,$pass,$spip_lang_right;
 
diff --git a/ecrire/inc/install_ldap1.php b/ecrire/install/etape_ldap1.php
similarity index 98%
rename from ecrire/inc/install_ldap1.php
rename to ecrire/install/etape_ldap1.php
index 6bdc5d9417..e77a2510a1 100644
--- a/ecrire/inc/install_ldap1.php
+++ b/ecrire/install/etape_ldap1.php
@@ -11,7 +11,7 @@
 \***************************************************************************/
 
 // http://doc.spip.org/@inc_install_ldap1
-function inc_install_ldap1()
+function install_etape_ldap1_dist()
 {
 	global $spip_lang_right;
 
@@ -82,4 +82,4 @@ function inc_install_ldap1()
 	install_fin_html();
 }
 
-?>
\ No newline at end of file
+?>
diff --git a/ecrire/inc/install_ldap2.php b/ecrire/install/etape_ldap2.php
similarity index 98%
rename from ecrire/inc/install_ldap2.php
rename to ecrire/install/etape_ldap2.php
index a0eb6e1008..00208de272 100644
--- a/ecrire/inc/install_ldap2.php
+++ b/ecrire/install/etape_ldap2.php
@@ -12,7 +12,7 @@
 
 
 // http://doc.spip.org/@inc_install_ldap2
-function inc_install_ldap2()
+function install_etape_ldap2_dist()
 {
 	global $adresse_ldap, $login_ldap, $pass_ldap, $port_ldap, $tls_ldap, $protocole_ldap, $spip_lang_right;
 
diff --git a/ecrire/inc/install_ldap3.php b/ecrire/install/etape_ldap3.php
similarity index 98%
rename from ecrire/inc/install_ldap3.php
rename to ecrire/install/etape_ldap3.php
index c6b650c6d2..61c6a56506 100644
--- a/ecrire/inc/install_ldap3.php
+++ b/ecrire/install/etape_ldap3.php
@@ -12,7 +12,7 @@
 
 
 // http://doc.spip.org/@inc_install_ldap3
-function inc_install_ldap3()
+function install_etape_ldap3_dist()
 {
 	global $adresse_ldap, $login_ldap, $pass_ldap, $port_ldap, $tls_ldap, $protocole_ldap, $spip_lang_right;
 
@@ -79,4 +79,4 @@ function inc_install_ldap3()
 }
 
 
-?>
\ No newline at end of file
+?>
diff --git a/ecrire/inc/install_ldap4.php b/ecrire/install/etape_ldap4.php
similarity index 98%
rename from ecrire/inc/install_ldap4.php
rename to ecrire/install/etape_ldap4.php
index dc8a8f2020..6eeaa90dd1 100644
--- a/ecrire/inc/install_ldap4.php
+++ b/ecrire/install/etape_ldap4.php
@@ -11,7 +11,7 @@
 \***************************************************************************/
 
 // http://doc.spip.org/@inc_install_ldap4
-function inc_install_ldap4()
+function install_etape_ldap4_dist()
 {
 	global $adresse_ldap, $login_ldap, $pass_ldap, $port_ldap, $tls_ldap, $protocole_ldap, $base_ldap, $base_ldap_text, $spip_lang_right;
 
@@ -76,4 +76,4 @@ function inc_install_ldap4()
 
 	install_fin_html();
 }
-?>
\ No newline at end of file
+?>
diff --git a/ecrire/inc/install_ldap5.php b/ecrire/install/etape_ldap5.php
similarity index 97%
rename from ecrire/inc/install_ldap5.php
rename to ecrire/install/etape_ldap5.php
index 43ddbb3321..d1531b1617 100644
--- a/ecrire/inc/install_ldap5.php
+++ b/ecrire/install/etape_ldap5.php
@@ -11,7 +11,7 @@
 \***************************************************************************/
 
 // http://doc.spip.org/@inc_install_ldap5
-function inc_install_ldap5()
+function install_etape_ldap5_dist()
 {
 	global $spip_lang_right, $statut_ldap;
 
@@ -39,4 +39,4 @@ function inc_install_ldap5()
 	echo "</FORM>";
 }
 
-?>
\ No newline at end of file
+?>
diff --git a/ecrire/inc/install_unpack.php b/ecrire/install/etape_unpack.php
similarity index 97%
rename from ecrire/inc/install_unpack.php
rename to ecrire/install/etape_unpack.php
index cb29dac37c..495db244ce 100644
--- a/ecrire/inc/install_unpack.php
+++ b/ecrire/install/etape_unpack.php
@@ -14,7 +14,7 @@ if (!defined("_ECRIRE_INC_VERSION")) return;
 include_spip('inc/actions');
 
 // http://doc.spip.org/@inc_install_unpack
-function inc_install_unpack()
+function install_etape_unpack_dist()
 {
   global  $connect_id_auteur;
 
@@ -35,4 +35,4 @@ function inc_install_unpack()
     redirige_par_entete(generer_action_auteur('loader','','',true));
 }
 
-?>
\ No newline at end of file
+?>
-- 
GitLab