Completed
Push — master ( bc13d2...dfa4f2 )
by cam
01:15
created
ecrire/inc/json.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 // Les fonctions de toggg pour faire du JSON
@@ -26,64 +26,64 @@  discard block
 block discarded – undo
26 26
 
27 27
 // https://code.spip.net/@var2js
28 28
 function var2js($var) {
29
-	$asso = false;
30
-	switch (true) {
31
-		case is_null($var):
32
-			return 'null';
33
-		case is_string($var):
34
-			return '"' . addcslashes($var, "\"\\\n\r/") . '"';
35
-		case is_bool($var):
36
-			return $var ? 'true' : 'false';
37
-		case is_scalar($var):
38
-			return (string)$var;
39
-		case is_object($var):// blam
40
-			$var = get_object_vars($var);
41
-			$asso = true;
42
-			// $var devient un array, on continue
43
-		case is_array($var):
44
-			$keys = array_keys($var);
45
-			$ikey = count($keys);
46
-			while (!$asso && $ikey--) {
47
-				$asso = $ikey !== $keys[$ikey];
48
-			}
49
-			$sep = '';
50
-			if ($asso) {
51
-				$ret = '{';
52
-				foreach ($var as $key => $elt) {
53
-					$ret .= $sep . '"' . $key . '":' . var2js($elt);
54
-					$sep = ',';
55
-				}
29
+    $asso = false;
30
+    switch (true) {
31
+        case is_null($var):
32
+            return 'null';
33
+        case is_string($var):
34
+            return '"' . addcslashes($var, "\"\\\n\r/") . '"';
35
+        case is_bool($var):
36
+            return $var ? 'true' : 'false';
37
+        case is_scalar($var):
38
+            return (string)$var;
39
+        case is_object($var):// blam
40
+            $var = get_object_vars($var);
41
+            $asso = true;
42
+            // $var devient un array, on continue
43
+        case is_array($var):
44
+            $keys = array_keys($var);
45
+            $ikey = count($keys);
46
+            while (!$asso && $ikey--) {
47
+                $asso = $ikey !== $keys[$ikey];
48
+            }
49
+            $sep = '';
50
+            if ($asso) {
51
+                $ret = '{';
52
+                foreach ($var as $key => $elt) {
53
+                    $ret .= $sep . '"' . $key . '":' . var2js($elt);
54
+                    $sep = ',';
55
+                }
56 56
 
57
-				return $ret . '}';
58
-			} else {
59
-				$ret = '[';
60
-				foreach ($var as $elt) {
61
-					$ret .= $sep . var2js($elt);
62
-					$sep = ',';
63
-				}
57
+                return $ret . '}';
58
+            } else {
59
+                $ret = '[';
60
+                foreach ($var as $elt) {
61
+                    $ret .= $sep . var2js($elt);
62
+                    $sep = ',';
63
+                }
64 64
 
65
-				return $ret . ']';
66
-			}
67
-	}
65
+                return $ret . ']';
66
+            }
67
+    }
68 68
 
69
-	return false;
69
+    return false;
70 70
 }
71 71
 
72 72
 if (!function_exists('json_encode')) {
73
-	function json_encode($v) {
74
-		return var2js($v);
75
-	}
73
+    function json_encode($v) {
74
+        return var2js($v);
75
+    }
76 76
 }
77 77
 
78 78
 // https://code.spip.net/@json_export
79 79
 function json_export($var) {
80
-	$var = json_encode($var);
80
+    $var = json_encode($var);
81 81
 
82
-	// flag indiquant qu'on est en iframe et qu'il faut proteger nos
83
-	// donnees dans un <textarea> ; attention $_FILES a ete vide par array_pop
84
-	if (defined('FILE_UPLOAD')) {
85
-		return '<textarea>' . spip_htmlspecialchars($var) . '</textarea>';
86
-	} else {
87
-		return $var;
88
-	}
82
+    // flag indiquant qu'on est en iframe et qu'il faut proteger nos
83
+    // donnees dans un <textarea> ; attention $_FILES a ete vide par array_pop
84
+    if (defined('FILE_UPLOAD')) {
85
+        return '<textarea>' . spip_htmlspecialchars($var) . '</textarea>';
86
+    } else {
87
+        return $var;
88
+    }
89 89
 }
Please login to merge, or discard this patch.
ecrire/inc/layer.php 1 patch
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 /**
@@ -26,41 +26,41 @@  discard block
 block discarded – undo
26 26
  * @return string Code HTML du cadre dépliable
27 27
  **/
28 28
 function cadre_depliable($icone, $titre, $deplie, $contenu, $ids = '', $style_cadre = 'r') {
29
-	$bouton = bouton_block_depliable($titre, $deplie, $ids);
30
-
31
-	return
32
-		debut_cadre($style_cadre, $icone, '', $bouton, '', '', false)
33
-		. debut_block_depliable($deplie, $ids)
34
-		. "<div class='cadre_padding'>\n"
35
-		. $contenu
36
-		. "</div>\n"
37
-		. fin_block()
38
-		. fin_cadre();
29
+    $bouton = bouton_block_depliable($titre, $deplie, $ids);
30
+
31
+    return
32
+        debut_cadre($style_cadre, $icone, '', $bouton, '', '', false)
33
+        . debut_block_depliable($deplie, $ids)
34
+        . "<div class='cadre_padding'>\n"
35
+        . $contenu
36
+        . "</div>\n"
37
+        . fin_block()
38
+        . fin_cadre();
39 39
 }
40 40
 
41 41
 // https://code.spip.net/@block_parfois_visible
42 42
 function block_parfois_visible($nom, $invite, $masque, $style = '', $visible = false) {
43
-	return "\n"
44
-	. bouton_block_depliable($invite, $visible, $nom)
45
-	. debut_block_depliable($visible, $nom)
46
-	. $masque
47
-	. fin_block();
43
+    return "\n"
44
+    . bouton_block_depliable($invite, $visible, $nom)
45
+    . debut_block_depliable($visible, $nom)
46
+    . $masque
47
+    . fin_block();
48 48
 }
49 49
 
50 50
 // https://code.spip.net/@debut_block_depliable
51 51
 function debut_block_depliable($deplie, $id = "") {
52
-	$class = ' blocdeplie';
53
-	// si on n'accepte pas js, ne pas fermer
54
-	if (!$deplie) {
55
-		$class = " blocreplie";
56
-	}
52
+    $class = ' blocdeplie';
53
+    // si on n'accepte pas js, ne pas fermer
54
+    if (!$deplie) {
55
+        $class = " blocreplie";
56
+    }
57 57
 
58
-	return "<div " . ($id ? "id='$id' " : "") . "class='bloc_depliable$class'>";
58
+    return "<div " . ($id ? "id='$id' " : "") . "class='bloc_depliable$class'>";
59 59
 }
60 60
 
61 61
 // https://code.spip.net/@fin_block
62 62
 function fin_block() {
63
-	return "<div class='nettoyeur'></div>\n</div>";
63
+    return "<div class='nettoyeur'></div>\n</div>";
64 64
 }
65 65
 
66 66
 // $texte : texte du bouton
@@ -68,32 +68,32 @@  discard block
 block discarded – undo
68 68
 // $ids : id des div lies au bouton (facultatif, par defaut c'est le div.bloc_depliable qui suit)
69 69
 // https://code.spip.net/@bouton_block_depliable
70 70
 function bouton_block_depliable($texte, $deplie, $ids = "") {
71
-	$bouton_id = 'b' . substr(md5($texte . microtime()), 0, 8);
72
-
73
-	$class = ($deplie === true) ? " deplie" : (($deplie == -1) ? " impliable" : " replie");
74
-	if (strlen($ids)) {
75
-		$cible = explode(',', $ids);
76
-		$cible = '#' . implode(",#", $cible);
77
-	} else {
78
-		$cible = "#$bouton_id + div.bloc_depliable";
79
-	}
80
-
81
-	$b = (strpos($texte, "<h") === false ? 'h3' : 'div');
82
-
83
-	return "<$b "
84
-	. ($bouton_id ? "id='$bouton_id' " : "")
85
-	. "class='titrem$class'"
86
-	. (($deplie === -1)
87
-		? ""
88
-		: " onmouseover=\"jQuery(this).depliant('$cible');\""
89
-	)
90
-	. ">"
91
-	// une ancre pour rendre accessible au clavier le depliage du sous bloc
92
-	. "<a href='#' onclick=\"return jQuery(this).depliant_clicancre('$cible');\" class='titremancre'></a>"
93
-	. "$texte</$b>"
94
-	. http_script(($deplie === 'incertain')
95
-		? "jQuery(function($){if ($('$cible').is(':visible')) { $('#$bouton_id').addClass('deplie').removeClass('replie'); }});"
96
-		: '');
71
+    $bouton_id = 'b' . substr(md5($texte . microtime()), 0, 8);
72
+
73
+    $class = ($deplie === true) ? " deplie" : (($deplie == -1) ? " impliable" : " replie");
74
+    if (strlen($ids)) {
75
+        $cible = explode(',', $ids);
76
+        $cible = '#' . implode(",#", $cible);
77
+    } else {
78
+        $cible = "#$bouton_id + div.bloc_depliable";
79
+    }
80
+
81
+    $b = (strpos($texte, "<h") === false ? 'h3' : 'div');
82
+
83
+    return "<$b "
84
+    . ($bouton_id ? "id='$bouton_id' " : "")
85
+    . "class='titrem$class'"
86
+    . (($deplie === -1)
87
+        ? ""
88
+        : " onmouseover=\"jQuery(this).depliant('$cible');\""
89
+    )
90
+    . ">"
91
+    // une ancre pour rendre accessible au clavier le depliage du sous bloc
92
+    . "<a href='#' onclick=\"return jQuery(this).depliant_clicancre('$cible');\" class='titremancre'></a>"
93
+    . "$texte</$b>"
94
+    . http_script(($deplie === 'incertain')
95
+        ? "jQuery(function($){if ($('$cible').is(':visible')) { $('#$bouton_id').addClass('deplie').removeClass('replie'); }});"
96
+        : '');
97 97
 }
98 98
 
99 99
 //
@@ -102,62 +102,62 @@  discard block
 block discarded – undo
102 102
 // https://code.spip.net/@verif_butineur
103 103
 function verif_butineur() {
104 104
 
105
-	preg_match(",^([A-Za-z]+)/([0-9]+\.[0-9]+) (.*)$,", $_SERVER['HTTP_USER_AGENT'], $match);
106
-	$GLOBALS['browser_name'] = $match[1];
107
-	$GLOBALS['browser_version'] = $match[2];
108
-	$GLOBALS['browser_description'] = $match[3];
109
-	$GLOBALS['browser_layer'] = ' '; // compat avec vieux scripts qui testent la valeur
110
-	$GLOBALS['browser_barre'] = '';
111
-
112
-	if (!preg_match(",opera,i", $GLOBALS['browser_description']) && preg_match(",opera,i", $GLOBALS['browser_name'])) {
113
-		$GLOBALS['browser_name'] = "Opera";
114
-		$GLOBALS['browser_version'] = $match[2];
115
-		$GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 8.5);
116
-	} else {
117
-		if (preg_match(",opera,i", $GLOBALS['browser_description'])) {
118
-			preg_match(",Opera ([^\ ]*),i", $GLOBALS['browser_description'], $match);
119
-			$GLOBALS['browser_name'] = "Opera";
120
-			$GLOBALS['browser_version'] = $match[1];
121
-			$GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 8.5);
122
-		} else {
123
-			if (preg_match(",msie,i", $GLOBALS['browser_description'])) {
124
-				preg_match(",MSIE ([^;]*),i", $GLOBALS['browser_description'], $match);
125
-				$GLOBALS['browser_name'] = "MSIE";
126
-				$GLOBALS['browser_version'] = $match[1];
127
-				$GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 5.5);
128
-			} else {
129
-				if (preg_match(",KHTML,i", $GLOBALS['browser_description']) &&
130
-					preg_match(",Safari/([^;]*),", $GLOBALS['browser_description'], $match)
131
-				) {
132
-					$GLOBALS['browser_name'] = "Safari";
133
-					$GLOBALS['browser_version'] = $match[1];
134
-					$GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 5.0);
135
-				} else {
136
-					if (preg_match(",mozilla,i", $GLOBALS['browser_name']) and $GLOBALS['browser_version'] >= 5) {
137
-						// Numero de version pour Mozilla "authentique"
138
-						if (preg_match(",rv:([0-9]+\.[0-9]+),", $GLOBALS['browser_description'], $match)) {
139
-							$GLOBALS['browser_rev'] = doubleval($match[1]);
140
-						} // Autres Gecko => equivalents 1.4 par defaut (Galeon, etc.)
141
-						else {
142
-							if (strpos($GLOBALS['browser_description'], "Gecko") and !strpos($GLOBALS['browser_description'],
143
-									"KHTML")
144
-							) {
145
-								$GLOBALS['browser_rev'] = 1.4;
146
-							} // Machins quelconques => equivalents 1.0 par defaut (Konqueror, etc.)
147
-							else {
148
-								$GLOBALS['browser_rev'] = 1.0;
149
-							}
150
-						}
151
-						$GLOBALS['browser_barre'] = $GLOBALS['browser_rev'] >= 1.3;
152
-					}
153
-				}
154
-			}
155
-		}
156
-	}
157
-
158
-	if (!$GLOBALS['browser_name']) {
159
-		$GLOBALS['browser_name'] = "Mozilla";
160
-	}
105
+    preg_match(",^([A-Za-z]+)/([0-9]+\.[0-9]+) (.*)$,", $_SERVER['HTTP_USER_AGENT'], $match);
106
+    $GLOBALS['browser_name'] = $match[1];
107
+    $GLOBALS['browser_version'] = $match[2];
108
+    $GLOBALS['browser_description'] = $match[3];
109
+    $GLOBALS['browser_layer'] = ' '; // compat avec vieux scripts qui testent la valeur
110
+    $GLOBALS['browser_barre'] = '';
111
+
112
+    if (!preg_match(",opera,i", $GLOBALS['browser_description']) && preg_match(",opera,i", $GLOBALS['browser_name'])) {
113
+        $GLOBALS['browser_name'] = "Opera";
114
+        $GLOBALS['browser_version'] = $match[2];
115
+        $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 8.5);
116
+    } else {
117
+        if (preg_match(",opera,i", $GLOBALS['browser_description'])) {
118
+            preg_match(",Opera ([^\ ]*),i", $GLOBALS['browser_description'], $match);
119
+            $GLOBALS['browser_name'] = "Opera";
120
+            $GLOBALS['browser_version'] = $match[1];
121
+            $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 8.5);
122
+        } else {
123
+            if (preg_match(",msie,i", $GLOBALS['browser_description'])) {
124
+                preg_match(",MSIE ([^;]*),i", $GLOBALS['browser_description'], $match);
125
+                $GLOBALS['browser_name'] = "MSIE";
126
+                $GLOBALS['browser_version'] = $match[1];
127
+                $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 5.5);
128
+            } else {
129
+                if (preg_match(",KHTML,i", $GLOBALS['browser_description']) &&
130
+                    preg_match(",Safari/([^;]*),", $GLOBALS['browser_description'], $match)
131
+                ) {
132
+                    $GLOBALS['browser_name'] = "Safari";
133
+                    $GLOBALS['browser_version'] = $match[1];
134
+                    $GLOBALS['browser_barre'] = ($GLOBALS['browser_version'] >= 5.0);
135
+                } else {
136
+                    if (preg_match(",mozilla,i", $GLOBALS['browser_name']) and $GLOBALS['browser_version'] >= 5) {
137
+                        // Numero de version pour Mozilla "authentique"
138
+                        if (preg_match(",rv:([0-9]+\.[0-9]+),", $GLOBALS['browser_description'], $match)) {
139
+                            $GLOBALS['browser_rev'] = doubleval($match[1]);
140
+                        } // Autres Gecko => equivalents 1.4 par defaut (Galeon, etc.)
141
+                        else {
142
+                            if (strpos($GLOBALS['browser_description'], "Gecko") and !strpos($GLOBALS['browser_description'],
143
+                                    "KHTML")
144
+                            ) {
145
+                                $GLOBALS['browser_rev'] = 1.4;
146
+                            } // Machins quelconques => equivalents 1.0 par defaut (Konqueror, etc.)
147
+                            else {
148
+                                $GLOBALS['browser_rev'] = 1.0;
149
+                            }
150
+                        }
151
+                        $GLOBALS['browser_barre'] = $GLOBALS['browser_rev'] >= 1.3;
152
+                    }
153
+                }
154
+            }
155
+        }
156
+    }
157
+
158
+    if (!$GLOBALS['browser_name']) {
159
+        $GLOBALS['browser_name'] = "Mozilla";
160
+    }
161 161
 }
162 162
 
163 163
 verif_butineur();
Please login to merge, or discard this patch.
ecrire/inc/install.php 1 patch
Indentation   +354 added lines, -354 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
  * @return void
44 44
  **/
45 45
 function install_fichier_connexion($nom, $texte) {
46
-	$texte = "<" . "?php\n"
47
-		. "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n"
48
-		. $texte
49
-		. "?" . ">";
46
+    $texte = "<" . "?php\n"
47
+        . "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n"
48
+        . $texte
49
+        . "?" . ">";
50 50
 
51
-	ecrire_fichier($nom, $texte);
51
+    ecrire_fichier($nom, $texte);
52 52
 }
53 53
 
54 54
 
@@ -77,20 +77,20 @@  discard block
 block discarded – undo
77 77
  *
78 78
  **/
79 79
 function install_connexion($adr, $port, $login, $pass, $base, $type, $pref, $ldap = '', $charset = '') {
80
-	$adr = addcslashes($adr, "'\\");
81
-	$port = addcslashes($port, "'\\");
82
-	$login = addcslashes($login, "'\\");
83
-	$pass = addcslashes($pass, "'\\");
84
-	$base = addcslashes($base, "'\\");
85
-	$type = addcslashes($type, "'\\");
86
-	$pref = addcslashes($pref, "'\\");
87
-	$ldap = addcslashes($ldap, "'\\");
88
-	$charset = addcslashes($charset, "'\\");
89
-
90
-	return "\$GLOBALS['spip_connect_version'] = 0.8;\n"
91
-	. "spip_connect_db("
92
-	. "'$adr','$port','$login','$pass','$base'"
93
-	. ",'$type', '$pref','$ldap','$charset');\n";
80
+    $adr = addcslashes($adr, "'\\");
81
+    $port = addcslashes($port, "'\\");
82
+    $login = addcslashes($login, "'\\");
83
+    $pass = addcslashes($pass, "'\\");
84
+    $base = addcslashes($base, "'\\");
85
+    $type = addcslashes($type, "'\\");
86
+    $pref = addcslashes($pref, "'\\");
87
+    $ldap = addcslashes($ldap, "'\\");
88
+    $charset = addcslashes($charset, "'\\");
89
+
90
+    return "\$GLOBALS['spip_connect_version'] = 0.8;\n"
91
+    . "spip_connect_db("
92
+    . "'$adr','$port','$login','$pass','$base'"
93
+    . ",'$type', '$pref','$ldap','$charset');\n";
94 94
 }
95 95
 
96 96
 
@@ -106,26 +106,26 @@  discard block
 block discarded – undo
106 106
  *     Tableau des informations sur la connexion
107 107
  **/
108 108
 function analyse_fichier_connection($file) {
109
-	$s = @join('', file($file));
110
-	if (preg_match("#mysql_connect\([\"'](.*)[\"'],[\"'](.*)[\"'],[\"'](.*)[\"']\)#", $s, $regs)) {
111
-		array_shift($regs);
112
-
113
-		return $regs;
114
-	} else {
115
-		$ar = '\s*\'([^\']*)\'';
116
-		$r = '\s*,' . $ar;
117
-		$r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#";
118
-		if (preg_match($r, $s, $regs)) {
119
-			$regs[2] = $regs[1] . (!$regs[2] ? '' : ":" . $regs[2] . ";");
120
-			array_shift($regs);
121
-			array_shift($regs);
122
-
123
-			return $regs;
124
-		}
125
-	}
126
-	spip_log("$file n'est pas un fichier de connexion");
127
-
128
-	return array();
109
+    $s = @join('', file($file));
110
+    if (preg_match("#mysql_connect\([\"'](.*)[\"'],[\"'](.*)[\"'],[\"'](.*)[\"']\)#", $s, $regs)) {
111
+        array_shift($regs);
112
+
113
+        return $regs;
114
+    } else {
115
+        $ar = '\s*\'([^\']*)\'';
116
+        $r = '\s*,' . $ar;
117
+        $r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#";
118
+        if (preg_match($r, $s, $regs)) {
119
+            $regs[2] = $regs[1] . (!$regs[2] ? '' : ":" . $regs[2] . ";");
120
+            array_shift($regs);
121
+            array_shift($regs);
122
+
123
+            return $regs;
124
+        }
125
+    }
126
+    spip_log("$file n'est pas un fichier de connexion");
127
+
128
+    return array();
129 129
 }
130 130
 
131 131
 /**
@@ -142,21 +142,21 @@  discard block
 block discarded – undo
142 142
  *     Liste des noms de connecteurs
143 143
  **/
144 144
 function bases_referencees($exclu = '') {
145
-	$tables = array();
146
-	foreach (preg_files(_DIR_CONNECT, '.php$') as $f) {
147
-		if ($f != $exclu and analyse_fichier_connection($f)) {
148
-			$tables[] = basename($f, '.php');
149
-		}
150
-	}
151
-
152
-	return $tables;
145
+    $tables = array();
146
+    foreach (preg_files(_DIR_CONNECT, '.php$') as $f) {
147
+        if ($f != $exclu and analyse_fichier_connection($f)) {
148
+            $tables[] = basename($f, '.php');
149
+        }
150
+    }
151
+
152
+    return $tables;
153 153
 }
154 154
 
155 155
 
156 156
 function install_mode_appel($server_db, $tout = true) {
157
-	return ($server_db != 'mysql') ? ''
158
-		: (($tout ? test_rappel_nom_base_mysql($server_db) : '')
159
-			. test_sql_mode_mysql($server_db));
157
+    return ($server_db != 'mysql') ? ''
158
+        : (($tout ? test_rappel_nom_base_mysql($server_db) : '')
159
+            . test_sql_mode_mysql($server_db));
160 160
 }
161 161
 
162 162
 //
@@ -164,52 +164,52 @@  discard block
 block discarded – undo
164 164
 // (sert a l'etape 1 de l'installation)
165 165
 // https://code.spip.net/@tester_compatibilite_hebergement
166 166
 function tester_compatibilite_hebergement() {
167
-	$err = array();
168
-
169
-	$p = phpversion();
170
-	if (version_compare($p, _PHP_MIN, '<')) {
171
-		$err[] = _T('install_php_version', array('version' => $p, 'minimum' => _PHP_MIN));
172
-	}
173
-
174
-	// Si on n'a pas la bonne version de PHP, c'est la fin
175
-	if ($err) {
176
-		die("<div class='error'>"
177
-			. "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"
178
-			. "<li><strong>{$err[0]}</strong></li>\n</ul></div>");
179
-	}
180
-
181
-	// Il faut une base de donnees tout de meme ...
182
-	$serveurs = install_select_serveur();
183
-	if (!$serveurs) {
184
-		$err[] = _T('install_extension_php_obligatoire')
185
-			. " <a href='http://www.php.net/mysql'>MYSQL</a>"
186
-			. "| <a href='http://www.php.net/pgsql'>PostgreSQL</a>"
187
-			. "| <a href='http://www.php.net/sqlite'>SQLite</a>";
188
-	}
189
-
190
-	// et il faut preg
191
-	if (!function_exists('preg_match_all')) {
192
-		$err[] = _T('install_extension_php_obligatoire')
193
-			. " <a href='http://se.php.net/pcre'>PCRE</a>";
194
-	}
195
-
196
-	// et surtout pas ce mbstring.overload
197
-	if ($a = @ini_get('mbstring.func_overload')) {
198
-		$err[] = _T('install_extension_mbstring')
199
-			. "mbstring.func_overload=$a - <a href='http://www.php.net/mb_string'>mb_string</a>.<br /><small>";
200
-	}
201
-
202
-	if ($err) {
203
-		echo "<div class='error'>"
204
-			. "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>";
205
-		foreach ($err as $e) {
206
-			echo "<li><strong>$e</strong></li>\n";
207
-		}
208
-
209
-		# a priori ici on pourrait die(), mais il faut laisser la possibilite
210
-		# de forcer malgre tout (pour tester, ou si bug de detection)
211
-		echo "</ul></div>\n";
212
-	}
167
+    $err = array();
168
+
169
+    $p = phpversion();
170
+    if (version_compare($p, _PHP_MIN, '<')) {
171
+        $err[] = _T('install_php_version', array('version' => $p, 'minimum' => _PHP_MIN));
172
+    }
173
+
174
+    // Si on n'a pas la bonne version de PHP, c'est la fin
175
+    if ($err) {
176
+        die("<div class='error'>"
177
+            . "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"
178
+            . "<li><strong>{$err[0]}</strong></li>\n</ul></div>");
179
+    }
180
+
181
+    // Il faut une base de donnees tout de meme ...
182
+    $serveurs = install_select_serveur();
183
+    if (!$serveurs) {
184
+        $err[] = _T('install_extension_php_obligatoire')
185
+            . " <a href='http://www.php.net/mysql'>MYSQL</a>"
186
+            . "| <a href='http://www.php.net/pgsql'>PostgreSQL</a>"
187
+            . "| <a href='http://www.php.net/sqlite'>SQLite</a>";
188
+    }
189
+
190
+    // et il faut preg
191
+    if (!function_exists('preg_match_all')) {
192
+        $err[] = _T('install_extension_php_obligatoire')
193
+            . " <a href='http://se.php.net/pcre'>PCRE</a>";
194
+    }
195
+
196
+    // et surtout pas ce mbstring.overload
197
+    if ($a = @ini_get('mbstring.func_overload')) {
198
+        $err[] = _T('install_extension_mbstring')
199
+            . "mbstring.func_overload=$a - <a href='http://www.php.net/mb_string'>mb_string</a>.<br /><small>";
200
+    }
201
+
202
+    if ($err) {
203
+        echo "<div class='error'>"
204
+            . "<h3>" . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>";
205
+        foreach ($err as $e) {
206
+            echo "<li><strong>$e</strong></li>\n";
207
+        }
208
+
209
+        # a priori ici on pourrait die(), mais il faut laisser la possibilite
210
+        # de forcer malgre tout (pour tester, ou si bug de detection)
211
+        echo "</ul></div>\n";
212
+    }
213 213
 }
214 214
 
215 215
 
@@ -219,24 +219,24 @@  discard block
 block discarded – undo
219 219
  * @note superflu ??
220 220
  */
221 221
 function login_hebergeur() {
222
-	$base_hebergeur = 'localhost'; # par defaut
222
+    $base_hebergeur = 'localhost'; # par defaut
223 223
 
224
-	// Free
225
-	if (preg_match(',(.*)\.free\.fr$,', $_SERVER['SERVER_NAME'], $regs)) {
226
-		$base_hebergeur = 'sql.free.fr';
227
-		$login_hebergeur = $regs[1];
228
-	} else {
229
-		$login_hebergeur = '';
230
-	}
224
+    // Free
225
+    if (preg_match(',(.*)\.free\.fr$,', $_SERVER['SERVER_NAME'], $regs)) {
226
+        $base_hebergeur = 'sql.free.fr';
227
+        $login_hebergeur = $regs[1];
228
+    } else {
229
+        $login_hebergeur = '';
230
+    }
231 231
 
232
-	return array($base_hebergeur, $login_hebergeur);
232
+    return array($base_hebergeur, $login_hebergeur);
233 233
 }
234 234
 
235 235
 
236 236
 // https://code.spip.net/@info_etape
237 237
 function info_etape($titre, $complement = '') {
238
-	return "<h2>" . $titre . "</h2>\n" .
239
-	($complement ? "" . $complement . "\n" : '');
238
+    return "<h2>" . $titre . "</h2>\n" .
239
+    ($complement ? "" . $complement . "\n" : '');
240 240
 }
241 241
 
242 242
 /**
@@ -246,155 +246,155 @@  discard block
 block discarded – undo
246 246
  * @return string Code HTML du bouton
247 247
  **/
248 248
 function bouton_suivant($code = '') {
249
-	if ($code == '') {
250
-		$code = _T('bouton_suivant');
251
-	}
252
-	static $suivant = 0;
253
-	$id = 'suivant' . (($suivant > 0) ? strval($suivant) : '');
254
-	$suivant += 1;
255
-
256
-	return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" .
257
-	$code .
258
-	" >>\" /></p>\n";
249
+    if ($code == '') {
250
+        $code = _T('bouton_suivant');
251
+    }
252
+    static $suivant = 0;
253
+    $id = 'suivant' . (($suivant > 0) ? strval($suivant) : '');
254
+    $suivant += 1;
255
+
256
+    return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" .
257
+    $code .
258
+    " >>\" /></p>\n";
259 259
 }
260 260
 
261 261
 // https://code.spip.net/@info_progression_etape
262 262
 function info_progression_etape($en_cours, $phase, $dir, $erreur = false) {
263
-	//$en_cours = _request('etape')?_request('etape'):"";
264
-	$liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$');
265
-	$debut = 1;
266
-	$etat = "ok";
267
-	$last = count($liste);
263
+    //$en_cours = _request('etape')?_request('etape'):"";
264
+    $liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$');
265
+    $debut = 1;
266
+    $etat = "ok";
267
+    $last = count($liste);
268 268
 //	$texte_etat = array('ok'=>'OK','encours'=>_T('en_cours'),'todo'=>_T('todo'));
269 269
 
270
-	$intitule_etat["etape_"][1] = typo(_T('info_connexion_base_donnee'));
271
-	$intitule_etat["etape_"][2] = typo(_T('menu_aide_installation_choix_base'));
272
-	$intitule_etat["etape_"][3] = typo(_T('info_informations_personnelles'));
273
-	$intitule_etat["etape_"][4] = typo(_T('info_derniere_etape'));
270
+    $intitule_etat["etape_"][1] = typo(_T('info_connexion_base_donnee'));
271
+    $intitule_etat["etape_"][2] = typo(_T('menu_aide_installation_choix_base'));
272
+    $intitule_etat["etape_"][3] = typo(_T('info_informations_personnelles'));
273
+    $intitule_etat["etape_"][4] = typo(_T('info_derniere_etape'));
274 274
 
275
-	$intitule_etat["etape_ldap"][1] = typo(_T('titre_connexion_ldap'));
276
-	$intitule_etat["etape_ldap"][2] = typo(_T('titre_connexion_ldap'));
277
-	$intitule_etat["etape_ldap"][3] = typo(_T('info_chemin_acces_1'));
278
-	$intitule_etat["etape_ldap"][4] = typo(_T('info_reglage_ldap'));
279
-	$intitule_etat["etape_ldap"][5] = typo(_T('info_ldap_ok'));
275
+    $intitule_etat["etape_ldap"][1] = typo(_T('titre_connexion_ldap'));
276
+    $intitule_etat["etape_ldap"][2] = typo(_T('titre_connexion_ldap'));
277
+    $intitule_etat["etape_ldap"][3] = typo(_T('info_chemin_acces_1'));
278
+    $intitule_etat["etape_ldap"][4] = typo(_T('info_reglage_ldap'));
279
+    $intitule_etat["etape_ldap"][5] = typo(_T('info_ldap_ok'));
280 280
 
281 281
 //	$aff_etapes = "<span id='etapes'>";
282 282
 
283
-	$aff_etapes = "<ul id='infos_etapes' class='infos_$phase$en_cours'>";
284
-
285
-	foreach ($liste as $etape => $fichier) {
286
-		if ($debut < $last) {
287
-			if ($debut == $en_cours && $erreur) {
288
-				$class = "on erreur";
289
-			} else {
290
-				if ($debut == $en_cours) {
291
-					$class = "on";
292
-				} else {
293
-					if ($debut > $en_cours) {
294
-						$class = "prochains";
295
-					} else {
296
-						$class = "valides";
297
-					}
298
-				}
299
-			}
300
-
301
-			$aff_etapes .= "<li class='$class'><div class='fond'>";
302
-			$aff_etapes .= ($debut == $en_cours) ? "<strong>" : '';
303
-			$aff_etapes .= "<em>" . _T('etape') . " </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
304
-			$aff_etapes .= $intitule_etat["$phase"][$debut];
305
-			$aff_etapes .= ($debut == $en_cours) ? "</strong>" : '';
306
-			$aff_etapes .= "</div></li>";
307
-		}
308
-		$debut++;
309
-	}
310
-	$aff_etapes .= "</ul>";
311
-	$aff_etapes .= "<br class='nettoyeur' />\n";
312
-
313
-	return $aff_etapes;
283
+    $aff_etapes = "<ul id='infos_etapes' class='infos_$phase$en_cours'>";
284
+
285
+    foreach ($liste as $etape => $fichier) {
286
+        if ($debut < $last) {
287
+            if ($debut == $en_cours && $erreur) {
288
+                $class = "on erreur";
289
+            } else {
290
+                if ($debut == $en_cours) {
291
+                    $class = "on";
292
+                } else {
293
+                    if ($debut > $en_cours) {
294
+                        $class = "prochains";
295
+                    } else {
296
+                        $class = "valides";
297
+                    }
298
+                }
299
+            }
300
+
301
+            $aff_etapes .= "<li class='$class'><div class='fond'>";
302
+            $aff_etapes .= ($debut == $en_cours) ? "<strong>" : '';
303
+            $aff_etapes .= "<em>" . _T('etape') . " </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
304
+            $aff_etapes .= $intitule_etat["$phase"][$debut];
305
+            $aff_etapes .= ($debut == $en_cours) ? "</strong>" : '';
306
+            $aff_etapes .= "</div></li>";
307
+        }
308
+        $debut++;
309
+    }
310
+    $aff_etapes .= "</ul>";
311
+    $aff_etapes .= "<br class='nettoyeur' />\n";
312
+
313
+    return $aff_etapes;
314 314
 }
315 315
 
316 316
 
317 317
 // https://code.spip.net/@fieldset
318 318
 function fieldset($legend, $champs = array(), $apres = '', $avant = '') {
319
-	return "<fieldset>\n" .
320
-	$avant .
321
-	($legend ? "<legend>" . $legend . "</legend>\n" : '') .
322
-	fieldset_champs($champs) .
323
-	$apres .
324
-	"</fieldset>\n";
319
+    return "<fieldset>\n" .
320
+    $avant .
321
+    ($legend ? "<legend>" . $legend . "</legend>\n" : '') .
322
+    fieldset_champs($champs) .
323
+    $apres .
324
+    "</fieldset>\n";
325 325
 }
326 326
 
327 327
 function fieldset_champs($champs = array()) {
328
-	$fieldset = '';
329
-	foreach ($champs as $nom => $contenu) {
330
-		$type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text');
331
-		$class = isset($contenu['hidden']) ? '' : "class='formo' size='40' ";
332
-		if (isset($contenu['alternatives'])) {
333
-			$fieldset .= $contenu['label'] . "\n";
334
-			foreach ($contenu['alternatives'] as $valeur => $label) {
335
-				$fieldset .= "<input type='radio' name='" . $nom .
336
-					"' id='$nom-$valeur' value='$valeur'"
337
-					. (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '')
338
-					. "/>\n";
339
-				$fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n";
340
-			}
341
-			$fieldset .= "<br />\n";
342
-		} else {
343
-			$fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n";
344
-			$fieldset .= "<input " . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'"
345
-				. (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '')
346
-				. ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : "")
347
-				. " />\n";
348
-		}
349
-	}
350
-
351
-	return $fieldset;
328
+    $fieldset = '';
329
+    foreach ($champs as $nom => $contenu) {
330
+        $type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', $nom) ? 'password' : 'text');
331
+        $class = isset($contenu['hidden']) ? '' : "class='formo' size='40' ";
332
+        if (isset($contenu['alternatives'])) {
333
+            $fieldset .= $contenu['label'] . "\n";
334
+            foreach ($contenu['alternatives'] as $valeur => $label) {
335
+                $fieldset .= "<input type='radio' name='" . $nom .
336
+                    "' id='$nom-$valeur' value='$valeur'"
337
+                    . (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '')
338
+                    . "/>\n";
339
+                $fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n";
340
+            }
341
+            $fieldset .= "<br />\n";
342
+        } else {
343
+            $fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n";
344
+            $fieldset .= "<input " . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'"
345
+                . (preg_match(',^(pass|login),', $nom) ? " autocomplete='off'" : '')
346
+                . ((isset($contenu['required']) and $contenu['required']) ? " required='required'" : "")
347
+                . " />\n";
348
+        }
349
+    }
350
+
351
+    return $fieldset;
352 352
 }
353 353
 
354 354
 function install_select_serveur() {
355
-	$options = array();
356
-	$dir = _DIR_RESTREINT . 'req/';
357
-	$d = opendir($dir);
358
-	if (!$d) {
359
-		return array();
360
-	}
361
-	while (($f = readdir($d)) !== false) {
362
-		if ((preg_match('/^(.*)[.]php$/', $f, $s))
363
-			and is_readable($f = $dir . $f)
364
-		) {
365
-			require_once($f);
366
-			$s = $s[1];
367
-			$v = 'spip_versions_' . $s;
368
-			if (function_exists($v) and $v()) {
369
-				$titre = _T("install_select_type_$s");
370
-				// proposer mysql par defaut si dispo
371
-				$checked = ($s == 'mysql' ? " checked='checked'" : "");
372
-				$options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>"
373
-					. "<label for='$s'>" . ($titre ? $titre : $s) . "</label></li>";
374
-			} else {
375
-				spip_log("$s: portage indisponible");
376
-			}
377
-		}
378
-	}
379
-	sort($options);
380
-
381
-	return $options;
355
+    $options = array();
356
+    $dir = _DIR_RESTREINT . 'req/';
357
+    $d = opendir($dir);
358
+    if (!$d) {
359
+        return array();
360
+    }
361
+    while (($f = readdir($d)) !== false) {
362
+        if ((preg_match('/^(.*)[.]php$/', $f, $s))
363
+            and is_readable($f = $dir . $f)
364
+        ) {
365
+            require_once($f);
366
+            $s = $s[1];
367
+            $v = 'spip_versions_' . $s;
368
+            if (function_exists($v) and $v()) {
369
+                $titre = _T("install_select_type_$s");
370
+                // proposer mysql par defaut si dispo
371
+                $checked = ($s == 'mysql' ? " checked='checked'" : "");
372
+                $options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>"
373
+                    . "<label for='$s'>" . ($titre ? $titre : $s) . "</label></li>";
374
+            } else {
375
+                spip_log("$s: portage indisponible");
376
+            }
377
+        }
378
+    }
379
+    sort($options);
380
+
381
+    return $options;
382 382
 }
383 383
 
384 384
 // https://code.spip.net/@install_connexion_form
385 385
 function install_connexion_form($db, $login, $pass, $predef, $hidden, $etape, $jquery = true) {
386
-	$server_db = (is_string($predef[0])) ? $predef[0] : '';
387
-
388
-	return generer_form_ecrire('install', (
389
-		"\n<input type='hidden' name='etape' value='$etape' />"
390
-		. $hidden
391
-		. (_request('echec') ?
392
-			("<p><b>" . _T('avis_connexion_echec_1') .
393
-				"</b></p><p>" . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . "</p>")
394
-			: "")
395
-
396
-		. ($jquery ? http_script('', 'jquery.js') : '')
397
-		. http_script('
386
+    $server_db = (is_string($predef[0])) ? $predef[0] : '';
387
+
388
+    return generer_form_ecrire('install', (
389
+        "\n<input type='hidden' name='etape' value='$etape' />"
390
+        . $hidden
391
+        . (_request('echec') ?
392
+            ("<p><b>" . _T('avis_connexion_echec_1') .
393
+                "</b></p><p>" . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . "</p>")
394
+            : "")
395
+
396
+        . ($jquery ? http_script('', 'jquery.js') : '')
397
+        . http_script('
398 398
 		jQuery(function($) {
399 399
 			$details_db = $("#install_adresse_base_hebergeur,#install_login_base_hebergeur,#install_pass_base_hebergeur");
400 400
 			$("input[type=hidden][name=server_db]").each(function(){
@@ -427,67 +427,67 @@  discard block
 block discarded – undo
427 427
 			});
428 428
 		});')
429 429
 
430
-		. ($server_db
431
-			? '<input type="hidden" name="server_db" value="' . $server_db . '" />'
432
-			. (($predef[0])
433
-				? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>')
434
-				: '')
435
-			: ('<fieldset><legend>'
436
-				. _T('install_select_type_db')
437
-				. "</legend>"
438
-				. '<p class="explication">'
439
-				. _T('install_types_db_connus')
440
-				// Passer l'avertissement SQLIte en  commentaire, on pourra facilement le supprimer par la suite sans changer les traductions.
441
-				// . "<br /><small>(". _T('install_types_db_connus_avertissement') .')</small>'
442
-				. '</p>'
443
-				. "\n<div class='p'>\n<ul>\n"
444
-				. join("\n", install_select_serveur())
445
-				. "\n</ul>\n</div></fieldset>")
446
-		)
447
-		. '<div id="install_adresse_base_hebergeur">'
448
-		. '<p>' . _T('texte_connexion_mysql') . '</p>'
449
-		. ($predef[1]
450
-			? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>'
451
-			: fieldset(_T('entree_base_donnee_1'),
452
-				array(
453
-					'adresse_db' => array(
454
-						'label' => $db[1],
455
-						'valeur' => $db[0]
456
-					),
457
-				)
458
-			)
459
-		)
460
-		. '</div>'
461
-
462
-		. '<div id="install_login_base_hebergeur">'
463
-		. ($predef[2]
464
-			? '<h3>' . _T('install_login_base_hebergeur') . '</h3>'
465
-			: fieldset(_T('entree_login_connexion_1'),
466
-				array(
467
-					'login_db' => array(
468
-						'label' => $login[1],
469
-						'valeur' => $login[0]
470
-					),
471
-				)
472
-			)
473
-		)
474
-		. '</div>'
475
-
476
-		. '<div id="install_pass_base_hebergeur">'
477
-		. ($predef[3]
478
-			? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>'
479
-			: fieldset(_T('entree_mot_passe_1'),
480
-				array(
481
-					'pass_db' => array(
482
-						'label' => $pass[1],
483
-						'valeur' => $pass[0]
484
-					),
485
-				)
486
-			)
487
-		)
488
-		. '</div>'
489
-
490
-		. bouton_suivant()));
430
+        . ($server_db
431
+            ? '<input type="hidden" name="server_db" value="' . $server_db . '" />'
432
+            . (($predef[0])
433
+                ? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>')
434
+                : '')
435
+            : ('<fieldset><legend>'
436
+                . _T('install_select_type_db')
437
+                . "</legend>"
438
+                . '<p class="explication">'
439
+                . _T('install_types_db_connus')
440
+                // Passer l'avertissement SQLIte en  commentaire, on pourra facilement le supprimer par la suite sans changer les traductions.
441
+                // . "<br /><small>(". _T('install_types_db_connus_avertissement') .')</small>'
442
+                . '</p>'
443
+                . "\n<div class='p'>\n<ul>\n"
444
+                . join("\n", install_select_serveur())
445
+                . "\n</ul>\n</div></fieldset>")
446
+        )
447
+        . '<div id="install_adresse_base_hebergeur">'
448
+        . '<p>' . _T('texte_connexion_mysql') . '</p>'
449
+        . ($predef[1]
450
+            ? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>'
451
+            : fieldset(_T('entree_base_donnee_1'),
452
+                array(
453
+                    'adresse_db' => array(
454
+                        'label' => $db[1],
455
+                        'valeur' => $db[0]
456
+                    ),
457
+                )
458
+            )
459
+        )
460
+        . '</div>'
461
+
462
+        . '<div id="install_login_base_hebergeur">'
463
+        . ($predef[2]
464
+            ? '<h3>' . _T('install_login_base_hebergeur') . '</h3>'
465
+            : fieldset(_T('entree_login_connexion_1'),
466
+                array(
467
+                    'login_db' => array(
468
+                        'label' => $login[1],
469
+                        'valeur' => $login[0]
470
+                    ),
471
+                )
472
+            )
473
+        )
474
+        . '</div>'
475
+
476
+        . '<div id="install_pass_base_hebergeur">'
477
+        . ($predef[3]
478
+            ? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>'
479
+            : fieldset(_T('entree_mot_passe_1'),
480
+                array(
481
+                    'pass_db' => array(
482
+                        'label' => $pass[1],
483
+                        'valeur' => $pass[0]
484
+                    ),
485
+                )
486
+            )
487
+        )
488
+        . '</div>'
489
+
490
+        . bouton_suivant()));
491 491
 
492 492
 }
493 493
 
@@ -496,75 +496,75 @@  discard block
 block discarded – undo
496 496
 
497 497
 // https://code.spip.net/@predef_ou_cache
498 498
 function predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) {
499
-	return ((defined('_INSTALL_HOST_DB'))
500
-		? ''
501
-		: "\n<input type='hidden' name='adresse_db'  value=\"" . spip_htmlspecialchars($adresse_db) . "\" />"
502
-	)
503
-	. ((defined('_INSTALL_USER_DB'))
504
-		? ''
505
-		: "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . "\" />"
506
-	)
507
-	. ((defined('_INSTALL_PASS_DB'))
508
-		? ''
509
-		: "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . "\" />"
510
-	)
511
-
512
-	. ((defined('_INSTALL_SERVER_DB'))
513
-		? ''
514
-		: "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . "\" />"
515
-	);
499
+    return ((defined('_INSTALL_HOST_DB'))
500
+        ? ''
501
+        : "\n<input type='hidden' name='adresse_db'  value=\"" . spip_htmlspecialchars($adresse_db) . "\" />"
502
+    )
503
+    . ((defined('_INSTALL_USER_DB'))
504
+        ? ''
505
+        : "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . "\" />"
506
+    )
507
+    . ((defined('_INSTALL_PASS_DB'))
508
+        ? ''
509
+        : "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . "\" />"
510
+    )
511
+
512
+    . ((defined('_INSTALL_SERVER_DB'))
513
+        ? ''
514
+        : "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . "\" />"
515
+    );
516 516
 }
517 517
 
518 518
 // presentation des bases existantes
519 519
 
520 520
 // https://code.spip.net/@install_etape_liste_bases
521 521
 function install_etape_liste_bases($server_db, $login_db, $disabled = array()) {
522
-	$bases = $checked = array();
523
-	$noms = sql_listdbs($server_db);
524
-	if (!$noms) {
525
-		return '';
526
-	}
527
-
528
-	foreach ($noms as $nom) {
529
-		$id = spip_htmlspecialchars($nom);
530
-		$dis = in_array($nom, $disabled) ? " disabled='disabled'" : '';
531
-		$base = " name=\"choix_db\" value=\""
532
-			. $nom
533
-			. '"'
534
-			. $dis
535
-			. " type='radio' id='$id'";
536
-		$label = "<label for='$id'>"
537
-			. ($dis ? "<i>$nom</i>" : $nom)
538
-			. "</label>";
539
-
540
-		if (!$checked and !$dis and
541
-			(($nom == $login_db) or
542
-				($GLOBALS['table_prefix'] == $nom))
543
-		) {
544
-			$checked = "<input$base checked='checked' />\n$label";
545
-		} else {
546
-			$bases[] = "<input$base />\n$label";
547
-		}
548
-	}
549
-
550
-	if (!$bases && !$checked) {
551
-		return false;
552
-	}
553
-
554
-	if ($checked) {
555
-		array_unshift($bases, $checked);
556
-		$checked = true;
557
-	}
558
-
559
-	return array($checked, $bases);
522
+    $bases = $checked = array();
523
+    $noms = sql_listdbs($server_db);
524
+    if (!$noms) {
525
+        return '';
526
+    }
527
+
528
+    foreach ($noms as $nom) {
529
+        $id = spip_htmlspecialchars($nom);
530
+        $dis = in_array($nom, $disabled) ? " disabled='disabled'" : '';
531
+        $base = " name=\"choix_db\" value=\""
532
+            . $nom
533
+            . '"'
534
+            . $dis
535
+            . " type='radio' id='$id'";
536
+        $label = "<label for='$id'>"
537
+            . ($dis ? "<i>$nom</i>" : $nom)
538
+            . "</label>";
539
+
540
+        if (!$checked and !$dis and
541
+            (($nom == $login_db) or
542
+                ($GLOBALS['table_prefix'] == $nom))
543
+        ) {
544
+            $checked = "<input$base checked='checked' />\n$label";
545
+        } else {
546
+            $bases[] = "<input$base />\n$label";
547
+        }
548
+    }
549
+
550
+    if (!$bases && !$checked) {
551
+        return false;
552
+    }
553
+
554
+    if ($checked) {
555
+        array_unshift($bases, $checked);
556
+        $checked = true;
557
+    }
558
+
559
+    return array($checked, $bases);
560 560
 }
561 561
 
562 562
 function install_propager($hidden) {
563
-	$res = '';
564
-	foreach ($hidden as $k) {
565
-		$v = spip_htmlentities(_request($k));
566
-		$res .= "<input type='hidden' name='$k' value='$v' />";
567
-	}
563
+    $res = '';
564
+    foreach ($hidden as $k) {
565
+        $v = spip_htmlentities(_request($k));
566
+        $res .= "<input type='hidden' name='$k' value='$v' />";
567
+    }
568 568
 
569
-	return $res;
569
+    return $res;
570 570
 }
Please login to merge, or discard this patch.
ecrire/inc/genie.php 1 patch
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 /**
@@ -75,24 +75,24 @@  discard block
 block discarded – undo
75 75
  * @return
76 76
  **/
77 77
 function inc_genie_dist($taches = array()) {
78
-	include_spip('inc/queue');
79
-
80
-	if (_request('exec') == 'job_queue') {
81
-		return false;
82
-	}
83
-
84
-	$force_jobs = array();
85
-	// l'ancienne facon de lancer une tache cron immediatement
86
-	// etait de la passer en parametre a ing_genie_dist
87
-	// on reroute en ajoutant simplement le job a la queue, ASAP
88
-	foreach ($taches as $function => $period) {
89
-		$force_jobs[] = queue_add_job($function, _T('tache_cron_asap', array('function' => $function)),
90
-			array(time() - abs($period)), "genie/");
91
-	}
92
-
93
-	// et on passe la main a la gestion de la queue !
94
-	// en forcant eventuellement les jobs ajoute a l'instant
95
-	return queue_schedule(count($force_jobs) ? $force_jobs : null);
78
+    include_spip('inc/queue');
79
+
80
+    if (_request('exec') == 'job_queue') {
81
+        return false;
82
+    }
83
+
84
+    $force_jobs = array();
85
+    // l'ancienne facon de lancer une tache cron immediatement
86
+    // etait de la passer en parametre a ing_genie_dist
87
+    // on reroute en ajoutant simplement le job a la queue, ASAP
88
+    foreach ($taches as $function => $period) {
89
+        $force_jobs[] = queue_add_job($function, _T('tache_cron_asap', array('function' => $function)),
90
+            array(time() - abs($period)), "genie/");
91
+    }
92
+
93
+    // et on passe la main a la gestion de la queue !
94
+    // en forcant eventuellement les jobs ajoute a l'instant
95
+    return queue_schedule(count($force_jobs) ? $force_jobs : null);
96 96
 }
97 97
 
98 98
 //
@@ -106,32 +106,32 @@  discard block
 block discarded – undo
106 106
 // https://code.spip.net/@taches_generales
107 107
 function taches_generales($taches_generales = array()) {
108 108
 
109
-	// verifier que toutes les taches cron sont planifiees
110
-	// c'est une tache cron !
111
-	$taches_generales['queue_watch'] = 3600 * 24;
109
+    // verifier que toutes les taches cron sont planifiees
110
+    // c'est une tache cron !
111
+    $taches_generales['queue_watch'] = 3600 * 24;
112 112
 
113
-	// MAJ des rubriques publiques (cas de la publication post-datee)
114
-	// est fait au coup par coup a present
115
-	//	$taches_generales['rubriques'] = 3600;
113
+    // MAJ des rubriques publiques (cas de la publication post-datee)
114
+    // est fait au coup par coup a present
115
+    //	$taches_generales['rubriques'] = 3600;
116 116
 
117
-	// Optimisation de la base
118
-	$taches_generales['optimiser'] = 3600 * 48;
117
+    // Optimisation de la base
118
+    $taches_generales['optimiser'] = 3600 * 48;
119 119
 
120
-	// nouveautes
121
-	if (isset($GLOBALS['meta']['adresse_neuf']) and $GLOBALS['meta']['adresse_neuf']
122
-		and $GLOBALS['meta']['jours_neuf']
123
-		and ($GLOBALS['meta']['quoi_de_neuf'] == 'oui')
124
-	) {
125
-		$taches_generales['mail'] = 3600 * 24 * $GLOBALS['meta']['jours_neuf'];
126
-	}
120
+    // nouveautes
121
+    if (isset($GLOBALS['meta']['adresse_neuf']) and $GLOBALS['meta']['adresse_neuf']
122
+        and $GLOBALS['meta']['jours_neuf']
123
+        and ($GLOBALS['meta']['quoi_de_neuf'] == 'oui')
124
+    ) {
125
+        $taches_generales['mail'] = 3600 * 24 * $GLOBALS['meta']['jours_neuf'];
126
+    }
127 127
 
128
-	// maintenance (ajax, verifications diverses)
129
-	$taches_generales['maintenance'] = 3600 * 2;
128
+    // maintenance (ajax, verifications diverses)
129
+    $taches_generales['maintenance'] = 3600 * 2;
130 130
 
131
-	// verifier si une mise a jour de spip est disponible (2 fois par semaine suffit largement)
132
-	$taches_generales['mise_a_jour'] = 3 * 24 * 3600;
131
+    // verifier si une mise a jour de spip est disponible (2 fois par semaine suffit largement)
132
+    $taches_generales['mise_a_jour'] = 3 * 24 * 3600;
133 133
 
134
-	return pipeline('taches_generales_cron', $taches_generales);
134
+    return pipeline('taches_generales_cron', $taches_generales);
135 135
 }
136 136
 
137 137
 /**
@@ -147,22 +147,22 @@  discard block
 block discarded – undo
147 147
  * @return int
148 148
  */
149 149
 function genie_queue_watch_dist() {
150
-	static $deja_la = false;
151
-	if ($deja_la) {
152
-		return;
153
-	} // re-entrance si l'insertion des jobs echoue (pas de table spip_jobs a l'upgrade par exemple)
154
-	$deja_la = true;
155
-	$taches = taches_generales();
156
-	$programmees = sql_allfetsel('fonction', 'spip_jobs', sql_in('fonction', array_keys($taches)));
157
-	$programmees = array_column($programmees, 'fonction');
158
-	foreach ($taches as $tache => $periode) {
159
-		if (!in_array($tache, $programmees)) {
160
-			queue_genie_replan_job($tache, $periode, time() - round(rand(1, $periode)), 0);
161
-		}
162
-	}
163
-	$deja_la = false;
164
-
165
-	return 1;
150
+    static $deja_la = false;
151
+    if ($deja_la) {
152
+        return;
153
+    } // re-entrance si l'insertion des jobs echoue (pas de table spip_jobs a l'upgrade par exemple)
154
+    $deja_la = true;
155
+    $taches = taches_generales();
156
+    $programmees = sql_allfetsel('fonction', 'spip_jobs', sql_in('fonction', array_keys($taches)));
157
+    $programmees = array_column($programmees, 'fonction');
158
+    foreach ($taches as $tache => $periode) {
159
+        if (!in_array($tache, $programmees)) {
160
+            queue_genie_replan_job($tache, $periode, time() - round(rand(1, $periode)), 0);
161
+        }
162
+    }
163
+    $deja_la = false;
164
+
165
+    return 1;
166 166
 }
167 167
 
168 168
 /**
@@ -183,25 +183,25 @@  discard block
 block discarded – undo
183 183
  * @return void
184 184
  */
185 185
 function queue_genie_replan_job($function, $period, $last = 0, $time = null, $priority = 0) {
186
-	static $done = array();
187
-	if (isset($done[$function])) {
188
-		return;
189
-	}
190
-	$done[$function] = true;
191
-	if (is_null($time)) {
192
-		$time = time();
193
-		if ($last) {
194
-			$time = max($last + $period, $time);
195
-		}
196
-	}
197
-	if (!$last) {
198
-		$last = $time - $period;
199
-	}
200
-	spip_log("replan_job $function $period $last $time $priority", 'queue');
201
-	include_spip('inc/queue');
202
-	// on replanifie un job cron
203
-	// uniquement si il n'y en a pas deja un avec le meme nom
204
-	// independament de l'argument
205
-	queue_add_job($function, _T('tache_cron_secondes', array('function' => $function, 'nb' => $period)), array($last),
206
-		"genie/", 'function_only', $time, $priority);
186
+    static $done = array();
187
+    if (isset($done[$function])) {
188
+        return;
189
+    }
190
+    $done[$function] = true;
191
+    if (is_null($time)) {
192
+        $time = time();
193
+        if ($last) {
194
+            $time = max($last + $period, $time);
195
+        }
196
+    }
197
+    if (!$last) {
198
+        $last = $time - $period;
199
+    }
200
+    spip_log("replan_job $function $period $last $time $priority", 'queue');
201
+    include_spip('inc/queue');
202
+    // on replanifie un job cron
203
+    // uniquement si il n'y en a pas deja un avec le meme nom
204
+    // independament de l'argument
205
+    queue_add_job($function, _T('tache_cron_secondes', array('function' => $function, 'nb' => $period)), array($last),
206
+        "genie/", 'function_only', $time, $priority);
207 207
 }
Please login to merge, or discard this patch.
ecrire/inc/presentation.php 1 patch
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Presentation
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 include_spip('inc/presentation_mini');
@@ -31,44 +31,44 @@  discard block
 block discarded – undo
31 31
 
32 32
 // https://code.spip.net/@debut_cadre
33 33
 function debut_cadre($style, $icone = "", $fonction = "", $titre = "", $id = "", $class = "", $padding = true) {
34
-	$style_mapping = array(
35
-		'r' => 'simple',
36
-		'e' => 'raccourcis',
37
-		'couleur' => 'basic highlight',
38
-		'couleur-foncee' => 'basic highlight',
39
-		'trait-couleur' => 'important',
40
-		'alerte' => 'notice',
41
-		'info' => 'info',
42
-		'sous_rub' => 'simple sous-rub'
43
-	);
44
-	$style_titre_mapping = array('couleur' => 'topper', 'trait-couleur' => 'section');
45
-	$c = isset($style_mapping[$style]) ? $style_mapping[$style] : 'simple';
46
-	$class = $c . ($class ? " $class" : "");
47
-	if (!$padding) {
48
-		$class .= ($class ? " " : "") . "no-padding";
49
-	}
50
-
51
-	//($id?"id='$id' ":"")
52
-	if (strlen($icone) > 1) {
53
-		if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
54
-			list($fond, $fonction) = $icone_renommer($icone, $fonction);
55
-		}
56
-		$size = 24;
57
-		if (preg_match("/-([0-9]{1,3})[.](gif|png)$/i", $fond, $match)) {
58
-			$size = $match[1];
59
-		}
60
-		if ($fonction) {
61
-			// 2 images pour composer l'icone : le fond (article) en background,
62
-			// la fonction (new) en image
63
-			$icone = http_img_pack($fonction, "", "class='cadre-icone' width='$size' height='$size'\n" .
64
-				http_style_background($fond, "no-repeat center center", $size));
65
-		} else {
66
-			$icone = http_img_pack($fond, "", "class='cadre-icone' width='$size' height='$size'");
67
-		}
68
-		$titre = $icone . $titre;
69
-	}
70
-
71
-	return boite_ouvrir($titre, $class, isset($style_titre_mapping[$style]) ? $style_titre_mapping[$style] : '', $id);
34
+    $style_mapping = array(
35
+        'r' => 'simple',
36
+        'e' => 'raccourcis',
37
+        'couleur' => 'basic highlight',
38
+        'couleur-foncee' => 'basic highlight',
39
+        'trait-couleur' => 'important',
40
+        'alerte' => 'notice',
41
+        'info' => 'info',
42
+        'sous_rub' => 'simple sous-rub'
43
+    );
44
+    $style_titre_mapping = array('couleur' => 'topper', 'trait-couleur' => 'section');
45
+    $c = isset($style_mapping[$style]) ? $style_mapping[$style] : 'simple';
46
+    $class = $c . ($class ? " $class" : "");
47
+    if (!$padding) {
48
+        $class .= ($class ? " " : "") . "no-padding";
49
+    }
50
+
51
+    //($id?"id='$id' ":"")
52
+    if (strlen($icone) > 1) {
53
+        if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
54
+            list($fond, $fonction) = $icone_renommer($icone, $fonction);
55
+        }
56
+        $size = 24;
57
+        if (preg_match("/-([0-9]{1,3})[.](gif|png)$/i", $fond, $match)) {
58
+            $size = $match[1];
59
+        }
60
+        if ($fonction) {
61
+            // 2 images pour composer l'icone : le fond (article) en background,
62
+            // la fonction (new) en image
63
+            $icone = http_img_pack($fonction, "", "class='cadre-icone' width='$size' height='$size'\n" .
64
+                http_style_background($fond, "no-repeat center center", $size));
65
+        } else {
66
+            $icone = http_img_pack($fond, "", "class='cadre-icone' width='$size' height='$size'");
67
+        }
68
+        $titre = $icone . $titre;
69
+    }
70
+
71
+    return boite_ouvrir($titre, $class, isset($style_titre_mapping[$style]) ? $style_titre_mapping[$style] : '', $id);
72 72
 }
73 73
 
74 74
 // https://code.spip.net/@fin_cadre
@@ -76,66 +76,66 @@  discard block
 block discarded – undo
76 76
 
77 77
 
78 78
 function debut_cadre_relief(
79
-	$icone = '',
80
-	$dummy = '',
81
-	$fonction = '',
82
-	$titre = '',
83
-	$id = "",
84
-	$class = ""
79
+    $icone = '',
80
+    $dummy = '',
81
+    $fonction = '',
82
+    $titre = '',
83
+    $id = "",
84
+    $class = ""
85 85
 ) {
86
-	return debut_cadre('r', $icone, $fonction, $titre, $id, $class);
86
+    return debut_cadre('r', $icone, $fonction, $titre, $id, $class);
87 87
 }
88 88
 
89 89
 function fin_cadre_relief() { return fin_cadre('r'); }
90 90
 
91 91
 function debut_cadre_enfonce(
92
-	$icone = '',
93
-	$dummy = '',
94
-	$fonction = '',
95
-	$titre = '',
96
-	$id = "",
97
-	$class = ""
92
+    $icone = '',
93
+    $dummy = '',
94
+    $fonction = '',
95
+    $titre = '',
96
+    $id = "",
97
+    $class = ""
98 98
 ) {
99
-	return debut_cadre('e', $icone, $fonction, $titre, $id, $class);
99
+    return debut_cadre('e', $icone, $fonction, $titre, $id, $class);
100 100
 }
101 101
 
102 102
 function fin_cadre_enfonce() { return fin_cadre('e'); }
103 103
 
104 104
 function debut_cadre_sous_rub(
105
-	$icone = '',
106
-	$dummy = '',
107
-	$fonction = '',
108
-	$titre = '',
109
-	$id = "",
110
-	$class = ""
105
+    $icone = '',
106
+    $dummy = '',
107
+    $fonction = '',
108
+    $titre = '',
109
+    $id = "",
110
+    $class = ""
111 111
 ) {
112
-	return debut_cadre('sous_rub', $icone, $fonction, $titre, $id, $class);
112
+    return debut_cadre('sous_rub', $icone, $fonction, $titre, $id, $class);
113 113
 }
114 114
 
115 115
 function fin_cadre_sous_rub() { return fin_cadre('sous_rub'); }
116 116
 
117 117
 function debut_cadre_couleur(
118
-	$icone = '',
119
-	$dummy = '',
120
-	$fonction = '',
121
-	$titre = '',
122
-	$id = "",
123
-	$class = ""
118
+    $icone = '',
119
+    $dummy = '',
120
+    $fonction = '',
121
+    $titre = '',
122
+    $id = "",
123
+    $class = ""
124 124
 ) {
125
-	return debut_cadre('couleur', $icone, $fonction, $titre, $id, $class);
125
+    return debut_cadre('couleur', $icone, $fonction, $titre, $id, $class);
126 126
 }
127 127
 
128 128
 function fin_cadre_couleur() { return fin_cadre('couleur'); }
129 129
 
130 130
 function debut_cadre_trait_couleur(
131
-	$icone = '',
132
-	$dummy = '',
133
-	$fonction = '',
134
-	$titre = '',
135
-	$id = "",
136
-	$class = ""
131
+    $icone = '',
132
+    $dummy = '',
133
+    $fonction = '',
134
+    $titre = '',
135
+    $id = "",
136
+    $class = ""
137 137
 ) {
138
-	return debut_cadre('trait-couleur', $icone, $fonction, $titre, $id, $class);
138
+    return debut_cadre('trait-couleur', $icone, $fonction, $titre, $id, $class);
139 139
 }
140 140
 
141 141
 function fin_cadre_trait_couleur() { return fin_cadre('trait-couleur'); }
@@ -156,18 +156,18 @@  discard block
 block discarded – undo
156 156
  * @return string Code PHP.
157 157
  **/
158 158
 function gros_titre(
159
-	$titre,
160
-	$ze_logo = ''
159
+    $titre,
160
+    $ze_logo = ''
161 161
 ) {
162
-	return "<h1 class = 'grostitre'>" . $ze_logo . ' ' . typo($titre) . "</h1>\n";
162
+    return "<h1 class = 'grostitre'>" . $ze_logo . ' ' . typo($titre) . "</h1>\n";
163 163
 }
164 164
 
165 165
 // La boite des raccourcis
166 166
 // Se place a droite si l'ecran est en mode panoramique.
167 167
 // https://code.spip.net/@bloc_des_raccourcis
168 168
 function bloc_des_raccourcis($bloc) {
169
-	return creer_colonne_droite()
170
-	. boite_ouvrir(_T('titre_cadre_raccourcis'), 'raccourcis') . $bloc . boite_fermer();
169
+    return creer_colonne_droite()
170
+    . boite_ouvrir(_T('titre_cadre_raccourcis'), 'raccourcis') . $bloc . boite_fermer();
171 171
 }
172 172
 
173 173
 //
@@ -184,10 +184,10 @@  discard block
 block discarded – undo
184 184
 
185 185
 // https://code.spip.net/@onglet
186 186
 function onglet($texte, $lien, $onglet_ref, $onglet, $icone = "") {
187
-	return "<li>"
188
-	. ($icone ? http_img_pack($icone, '', " class='cadre-icone'") : '')
189
-	. lien_ou_expose($lien, $texte, $onglet == $onglet_ref)
190
-	. "</li>";
187
+    return "<li>"
188
+    . ($icone ? http_img_pack($icone, '', " class='cadre-icone'") : '')
189
+    . lien_ou_expose($lien, $texte, $onglet == $onglet_ref)
190
+    . "</li>";
191 191
 }
192 192
 
193 193
 /**
@@ -219,14 +219,14 @@  discard block
 block discarded – undo
219 219
  *     Code HTML du lien
220 220
  **/
221 221
 function icone_verticale($texte, $lien, $fond, $fonction = "", $align = "", $javascript = "") {
222
-	// cas d'ajax_action_auteur: faut defaire le boulot
223
-	// (il faudrait fusionner avec le cas $javascript)
224
-	if (preg_match(",^<a\shref='([^']*)'([^>]*)>(.*)</a>$,i", $lien, $r)) {
225
-		list($x, $lien, $atts, $texte) = $r;
226
-		$javascript .= $atts;
227
-	}
228
-
229
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $align", $javascript);
222
+    // cas d'ajax_action_auteur: faut defaire le boulot
223
+    // (il faudrait fusionner avec le cas $javascript)
224
+    if (preg_match(",^<a\shref='([^']*)'([^>]*)>(.*)</a>$,i", $lien, $r)) {
225
+        list($x, $lien, $atts, $texte) = $r;
226
+        $javascript .= $atts;
227
+    }
228
+
229
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $align", $javascript);
230 230
 }
231 231
 
232 232
 /**
@@ -251,15 +251,15 @@  discard block
 block discarded – undo
251 251
  *     Code HTML du lien
252 252
  **/
253 253
 function icone_horizontale($texte, $lien, $fond, $fonction = "", $dummy = "", $javascript = "") {
254
-	$retour = '';
255
-	// cas d'ajax_action_auteur: faut defaire le boulot
256
-	// (il faudrait fusionner avec le cas $javascript)
257
-	if (preg_match(",^<a\shref='([^']*)'([^>]*)>(.*)</a>$,i", $lien, $r)) {
258
-		list($x, $lien, $atts, $texte) = $r;
259
-		$javascript .= $atts;
260
-	}
254
+    $retour = '';
255
+    // cas d'ajax_action_auteur: faut defaire le boulot
256
+    // (il faudrait fusionner avec le cas $javascript)
257
+    if (preg_match(",^<a\shref='([^']*)'([^>]*)>(.*)</a>$,i", $lien, $r)) {
258
+        list($x, $lien, $atts, $texte) = $r;
259
+        $javascript .= $atts;
260
+    }
261 261
 
262
-	$retour = icone_base($lien, $texte, $fond, $fonction, "horizontale", $javascript);
262
+    $retour = icone_base($lien, $texte, $fond, $fonction, "horizontale", $javascript);
263 263
 
264
-	return $retour;
264
+    return $retour;
265 265
 }
Please login to merge, or discard this patch.
ecrire/plugins/afficher_liste.php 1 patch
Indentation   +72 added lines, -72 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 include_spip('inc/charsets');
17 17
 
@@ -28,88 +28,88 @@  discard block
 block discarded – undo
28 28
  * @return string
29 29
  */
30 30
 function plugins_afficher_liste_dist(
31
-	$url_page,
32
-	$liste_plugins,
33
-	$liste_plugins_checked,
34
-	$liste_plugins_actifs,
35
-	$dir_plugins = _DIR_PLUGINS,
36
-	$afficher_un = 'afficher_plugin'
31
+    $url_page,
32
+    $liste_plugins,
33
+    $liste_plugins_checked,
34
+    $liste_plugins_actifs,
35
+    $dir_plugins = _DIR_PLUGINS,
36
+    $afficher_un = 'afficher_plugin'
37 37
 ) {
38
-	$get_infos = charger_fonction('get_infos', 'plugins');
39
-	$ligne_plug = charger_fonction($afficher_un, 'plugins');
38
+    $get_infos = charger_fonction('get_infos', 'plugins');
39
+    $ligne_plug = charger_fonction($afficher_un, 'plugins');
40 40
 
41
-	$all_infos = $get_infos($liste_plugins, false, $dir_plugins);
41
+    $all_infos = $get_infos($liste_plugins, false, $dir_plugins);
42 42
 
43
-	$all_infos = pipeline('filtrer_liste_plugins',
44
-		array(
45
-			'args' => array(
46
-				'liste_plugins' => $liste_plugins,
47
-				'liste_plugins_checked' => $liste_plugins_checked,
48
-				'liste_plugins_actifs' => $liste_plugins_actifs,
49
-				'dir_plugins' => $dir_plugins
50
-			),
51
-			'data' => $all_infos
52
-		)
53
-	);
43
+    $all_infos = pipeline('filtrer_liste_plugins',
44
+        array(
45
+            'args' => array(
46
+                'liste_plugins' => $liste_plugins,
47
+                'liste_plugins_checked' => $liste_plugins_checked,
48
+                'liste_plugins_actifs' => $liste_plugins_actifs,
49
+                'dir_plugins' => $dir_plugins
50
+            ),
51
+            'data' => $all_infos
52
+        )
53
+    );
54 54
 
55
-	$liste_plugins = array_flip($liste_plugins);
56
-	foreach ($liste_plugins as $chemin => $v) {
57
-		// des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte.
58
-		if (isset($all_infos[$chemin])) {
59
-			$liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom']))))));
60
-		} else {
61
-			unset($liste_plugins[$chemin]);
62
-		}
63
-	}
64
-	asort($liste_plugins);
65
-	$exposed = urldecode(_request('plugin'));
55
+    $liste_plugins = array_flip($liste_plugins);
56
+    foreach ($liste_plugins as $chemin => $v) {
57
+        // des plugins ont pu etre enleves de la liste par le pipeline. On en tient compte.
58
+        if (isset($all_infos[$chemin])) {
59
+            $liste_plugins[$chemin] = strtoupper(trim(typo(translitteration(unicode2charset(html2unicode($all_infos[$chemin]['nom']))))));
60
+        } else {
61
+            unset($liste_plugins[$chemin]);
62
+        }
63
+    }
64
+    asort($liste_plugins);
65
+    $exposed = urldecode(_request('plugin'));
66 66
 
67
-	$block_par_lettre = false;//count($liste_plugins)>10;
68
-	$fast_liste_plugins_actifs = array();
69
-	$fast_liste_plugins_checked = array();
70
-	if (is_array($liste_plugins_actifs)) {
71
-		$fast_liste_plugins_actifs = array_flip($liste_plugins_actifs);
72
-	}
73
-	if (is_array($liste_plugins_checked)) {
74
-		$fast_liste_plugins_checked = array_flip($liste_plugins_checked);
75
-	}
67
+    $block_par_lettre = false;//count($liste_plugins)>10;
68
+    $fast_liste_plugins_actifs = array();
69
+    $fast_liste_plugins_checked = array();
70
+    if (is_array($liste_plugins_actifs)) {
71
+        $fast_liste_plugins_actifs = array_flip($liste_plugins_actifs);
72
+    }
73
+    if (is_array($liste_plugins_checked)) {
74
+        $fast_liste_plugins_checked = array_flip($liste_plugins_checked);
75
+    }
76 76
 
77
-	$res = '';
78
-	$block = '';
79
-	$initiale = '';
80
-	$block_actif = false;
81
-	foreach ($liste_plugins as $plug => $nom) {
82
-		if (($i = substr($nom, 0, 1)) !== $initiale) {
83
-			$res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
84
-			$initiale = $i;
85
-			$block = '';
86
-			$block_actif = false;
87
-		}
88
-		// le rep suivant
89
-		$actif = isset($fast_liste_plugins_actifs[$plug]);
90
-		$checked = isset($fast_liste_plugins_checked[$plug]);
91
-		$block_actif = $block_actif | $actif;
92
-		$expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr($dir_plugins,
93
-					strlen(_DIR_RACINE)) . $plug));
94
-		$block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, "item", $dir_plugins) . "\n";
95
-	}
96
-	$res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
97
-	$class = basename($dir_plugins);
77
+    $res = '';
78
+    $block = '';
79
+    $initiale = '';
80
+    $block_actif = false;
81
+    foreach ($liste_plugins as $plug => $nom) {
82
+        if (($i = substr($nom, 0, 1)) !== $initiale) {
83
+            $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
84
+            $initiale = $i;
85
+            $block = '';
86
+            $block_actif = false;
87
+        }
88
+        // le rep suivant
89
+        $actif = isset($fast_liste_plugins_actifs[$plug]);
90
+        $checked = isset($fast_liste_plugins_checked[$plug]);
91
+        $block_actif = $block_actif | $actif;
92
+        $expose = ($exposed and ($exposed == $plug or $exposed == $dir_plugins . $plug or $exposed == substr($dir_plugins,
93
+                    strlen(_DIR_RACINE)) . $plug));
94
+        $block .= $ligne_plug($url_page, $plug, $checked, $actif, $expose, "item", $dir_plugins) . "\n";
95
+    }
96
+    $res .= $block_par_lettre ? affiche_block_initiale($initiale, $block, $block_actif) : $block;
97
+    $class = basename($dir_plugins);
98 98
 
99
-	return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : "";
99
+    return $res ? "<ul class='liste-items plugins $class'>$res</ul>" : "";
100 100
 }
101 101
 
102 102
 
103 103
 // https://code.spip.net/@affiche_block_initiale
104 104
 function affiche_block_initiale($initiale, $block, $block_actif) {
105
-	if (strlen($block)) {
106
-		return "<li class='item'>"
107
-		. bouton_block_depliable($initiale, $block_actif ? true : false)
108
-		. debut_block_depliable($block_actif)
109
-		. "<ul>$block</ul>"
110
-		. fin_block()
111
-		. "</li>";
112
-	}
105
+    if (strlen($block)) {
106
+        return "<li class='item'>"
107
+        . bouton_block_depliable($initiale, $block_actif ? true : false)
108
+        . debut_block_depliable($block_actif)
109
+        . "<ul>$block</ul>"
110
+        . fin_block()
111
+        . "</li>";
112
+    }
113 113
 
114
-	return "";
114
+    return "";
115 115
 }
Please login to merge, or discard this patch.
ecrire/plugins/afficher_repertoires.php 1 patch
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -11,64 +11,64 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 // https://code.spip.net/@affiche_arbre_plugins
18 18
 function plugins_afficher_repertoires_dist($url_page, $liste_plugins, $liste_plugins_actifs) {
19
-	$ligne_plug = charger_fonction('afficher_plugin', 'plugins');
20
-	$racine = basename(_DIR_PLUGINS);
21
-	$init_dir = $current_dir = "";
22
-	// liste des repertoires deplies : construit en remontant l'arbo de chaque plugin actif
23
-	// des qu'un path est deja note deplie on s'arrete
24
-	$deplie = array($racine => true);
25
-	$fast_liste_plugins_actifs = array();
26
-	foreach ($liste_plugins_actifs as $key => $plug) {
27
-		$chemin_plug = chemin_plug($racine, $plug);
28
-		$fast_liste_plugins_actifs[$chemin_plug] = true;
29
-		$dir = dirname($chemin_plug);
30
-		$maxiter = 100;
31
-		while (strlen($dir) && !isset($deplie[$dir]) && $dir != $racine && $maxiter-- > 0) {
32
-			$deplie[$dir] = true;
33
-			$dir = dirname($dir);
34
-		}
35
-	}
19
+    $ligne_plug = charger_fonction('afficher_plugin', 'plugins');
20
+    $racine = basename(_DIR_PLUGINS);
21
+    $init_dir = $current_dir = "";
22
+    // liste des repertoires deplies : construit en remontant l'arbo de chaque plugin actif
23
+    // des qu'un path est deja note deplie on s'arrete
24
+    $deplie = array($racine => true);
25
+    $fast_liste_plugins_actifs = array();
26
+    foreach ($liste_plugins_actifs as $key => $plug) {
27
+        $chemin_plug = chemin_plug($racine, $plug);
28
+        $fast_liste_plugins_actifs[$chemin_plug] = true;
29
+        $dir = dirname($chemin_plug);
30
+        $maxiter = 100;
31
+        while (strlen($dir) && !isset($deplie[$dir]) && $dir != $racine && $maxiter-- > 0) {
32
+            $deplie[$dir] = true;
33
+            $dir = dirname($dir);
34
+        }
35
+    }
36 36
 
37
-	// index repertoires --> plugin
38
-	$dir_index = array();
39
-	foreach ($liste_plugins as $key => $plug) {
40
-		$liste_plugins[$key] = chemin_plug($racine, $plug);
41
-		$dir_index[dirname($liste_plugins[$key])][] = $key;
42
-	}
37
+    // index repertoires --> plugin
38
+    $dir_index = array();
39
+    foreach ($liste_plugins as $key => $plug) {
40
+        $liste_plugins[$key] = chemin_plug($racine, $plug);
41
+        $dir_index[dirname($liste_plugins[$key])][] = $key;
42
+    }
43 43
 
44
-	$visible = @isset($deplie[$current_dir]);
45
-	$maxiter = 1000;
44
+    $visible = @isset($deplie[$current_dir]);
45
+    $maxiter = 1000;
46 46
 
47
-	$res = '';
48
-	while (count($liste_plugins) && $maxiter--) {
49
-		// le rep suivant
50
-		$dir = dirname(reset($liste_plugins));
51
-		if ($dir != $current_dir) {
52
-			$res .= tree_open_close_dir($current_dir, $dir, $deplie);
53
-		}
47
+    $res = '';
48
+    while (count($liste_plugins) && $maxiter--) {
49
+        // le rep suivant
50
+        $dir = dirname(reset($liste_plugins));
51
+        if ($dir != $current_dir) {
52
+            $res .= tree_open_close_dir($current_dir, $dir, $deplie);
53
+        }
54 54
 
55
-		// d'abord tous les plugins du rep courant
56
-		if (isset($dir_index[$current_dir])) {
57
-			foreach ($dir_index[$current_dir] as $key) {
58
-				$plug = $liste_plugins[$key];
59
-				$actif = @isset($fast_liste_plugins_actifs[$plug]);
60
-				$id = substr(md5($plug), 0, 16);
61
-				$res .= $ligne_plug($url_page, str_replace(_DIR_PLUGINS, '', _DIR_RACINE . $plug), $actif,
62
-						'menu-entree') . "\n";
63
-				unset($liste_plugins[$key]);
64
-			}
65
-		}
66
-	}
67
-	$res .= tree_open_close_dir($current_dir, $init_dir, true);
55
+        // d'abord tous les plugins du rep courant
56
+        if (isset($dir_index[$current_dir])) {
57
+            foreach ($dir_index[$current_dir] as $key) {
58
+                $plug = $liste_plugins[$key];
59
+                $actif = @isset($fast_liste_plugins_actifs[$plug]);
60
+                $id = substr(md5($plug), 0, 16);
61
+                $res .= $ligne_plug($url_page, str_replace(_DIR_PLUGINS, '', _DIR_RACINE . $plug), $actif,
62
+                        'menu-entree') . "\n";
63
+                unset($liste_plugins[$key]);
64
+            }
65
+        }
66
+    }
67
+    $res .= tree_open_close_dir($current_dir, $init_dir, true);
68 68
 
69
-	return "<ul class='menu-liste plugins'>"
70
-	. $res
71
-	. "</ul>";
69
+    return "<ul class='menu-liste plugins'>"
70
+    . $res
71
+    . "</ul>";
72 72
 }
73 73
 
74 74
 
@@ -76,44 +76,44 @@  discard block
 block discarded – undo
76 76
 // une fonction pour aider...
77 77
 // https://code.spip.net/@chemin_plug
78 78
 function chemin_plug($racine, $plug) {
79
-	return preg_replace(',[^/]+/\.\./,', '', "$racine/$plug");
79
+    return preg_replace(',[^/]+/\.\./,', '', "$racine/$plug");
80 80
 }
81 81
 
82 82
 // https://code.spip.net/@tree_open_close_dir
83 83
 function tree_open_close_dir(&$current, $target, $deplie = array()) {
84
-	if ($current == $target) {
85
-		return "";
86
-	}
87
-	$tcur = explode("/", $current);
88
-	$ttarg = explode("/", $target);
89
-	$tcom = array();
90
-	$output = "";
91
-	// la partie commune
92
-	while (reset($tcur) == reset($ttarg)) {
93
-		$tcom[] = array_shift($tcur);
94
-		array_shift($ttarg);
95
-	}
96
-	// fermer les repertoires courant jusqu'au point de fork
97
-	while ($close = array_pop($tcur)) {
98
-		$output .= "</ul>\n";
99
-		$output .= fin_block();
100
-		$output .= "</li>\n";
101
-	}
102
-	$chemin = "";
103
-	if (count($tcom)) {
104
-		$chemin .= implode("/", $tcom) . "/";
105
-	}
106
-	// ouvrir les repertoires jusqu'a la cible
107
-	while ($open = array_shift($ttarg)) {
108
-		$visible = @isset($deplie[$chemin . $open]);
109
-		$chemin .= $open . "/";
110
-		$output .= "<li>";
111
-		$output .= bouton_block_depliable($chemin, $visible);
112
-		$output .= debut_block_depliable($visible);
84
+    if ($current == $target) {
85
+        return "";
86
+    }
87
+    $tcur = explode("/", $current);
88
+    $ttarg = explode("/", $target);
89
+    $tcom = array();
90
+    $output = "";
91
+    // la partie commune
92
+    while (reset($tcur) == reset($ttarg)) {
93
+        $tcom[] = array_shift($tcur);
94
+        array_shift($ttarg);
95
+    }
96
+    // fermer les repertoires courant jusqu'au point de fork
97
+    while ($close = array_pop($tcur)) {
98
+        $output .= "</ul>\n";
99
+        $output .= fin_block();
100
+        $output .= "</li>\n";
101
+    }
102
+    $chemin = "";
103
+    if (count($tcom)) {
104
+        $chemin .= implode("/", $tcom) . "/";
105
+    }
106
+    // ouvrir les repertoires jusqu'a la cible
107
+    while ($open = array_shift($ttarg)) {
108
+        $visible = @isset($deplie[$chemin . $open]);
109
+        $chemin .= $open . "/";
110
+        $output .= "<li>";
111
+        $output .= bouton_block_depliable($chemin, $visible);
112
+        $output .= debut_block_depliable($visible);
113 113
 
114
-		$output .= "<ul>\n";
115
-	}
116
-	$current = $target;
114
+        $output .= "<ul>\n";
115
+    }
116
+    $current = $target;
117 117
 
118
-	return $output;
118
+    return $output;
119 119
 }
Please login to merge, or discard this patch.
ecrire/plugins/afficher_nom_plugin.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 include_spip('inc/charsets');
17 17
 include_spip('inc/texte');
@@ -19,54 +19,54 @@  discard block
 block discarded – undo
19 19
 
20 20
 // https://code.spip.net/@ligne_plug
21 21
 function plugins_afficher_nom_plugin_dist(
22
-	$url_page,
23
-	$plug_file,
24
-	$checked,
25
-	$actif,
26
-	$expose = false,
27
-	$class_li = "item",
28
-	$dir_plugins = _DIR_PLUGINS
22
+    $url_page,
23
+    $plug_file,
24
+    $checked,
25
+    $actif,
26
+    $expose = false,
27
+    $class_li = "item",
28
+    $dir_plugins = _DIR_PLUGINS
29 29
 ) {
30
-	static $id_input = 0;
31
-	static $versions = array();
30
+    static $id_input = 0;
31
+    static $versions = array();
32 32
 
33
-	$erreur = false;
34
-	$s = "";
33
+    $erreur = false;
34
+    $s = "";
35 35
 
36
-	$get_infos = charger_fonction('get_infos', 'plugins');
37
-	$info = $get_infos($plug_file, false, $dir_plugins);
36
+    $get_infos = charger_fonction('get_infos', 'plugins');
37
+    $info = $get_infos($plug_file, false, $dir_plugins);
38 38
 
39
-	// numerotons les occurences d'un meme prefix
40
-	$versions[$info['prefix']] = isset($versions[$info['prefix']]) ? $versions[$info['prefix']] + 1 : '';
41
-	$id = $info['prefix'] . $versions[$info['prefix']];
39
+    // numerotons les occurences d'un meme prefix
40
+    $versions[$info['prefix']] = isset($versions[$info['prefix']]) ? $versions[$info['prefix']] + 1 : '';
41
+    $id = $info['prefix'] . $versions[$info['prefix']];
42 42
 
43
-	$class = $class_li;
44
-	$class .= $actif ? " actif" : "";
45
-	$class .= $expose ? " on" : "";
46
-	$erreur = isset($info['erreur']);
47
-	if ($erreur) {
48
-		$class .= " error";
49
-	}
50
-	$s .= "<li id='$id' class='$class'>";
43
+    $class = $class_li;
44
+    $class .= $actif ? " actif" : "";
45
+    $class .= $expose ? " on" : "";
46
+    $erreur = isset($info['erreur']);
47
+    if ($erreur) {
48
+        $class .= " error";
49
+    }
50
+    $s .= "<li id='$id' class='$class'>";
51 51
 
52
-	// Cartouche Resume
53
-	$s .= "<div class='resume'>";
52
+    // Cartouche Resume
53
+    $s .= "<div class='resume'>";
54 54
 
55
-	$prefix = $info['prefix'];
56
-	$dir = "$dir_plugins$plug_file/lang/$prefix";
57
-	$desc = plugin_propre($info['description'], $dir);
58
-	$url_stat = parametre_url($url_page, "plugin", $dir_plugins . $plug_file);
55
+    $prefix = $info['prefix'];
56
+    $dir = "$dir_plugins$plug_file/lang/$prefix";
57
+    $desc = plugin_propre($info['description'], $dir);
58
+    $url_stat = parametre_url($url_page, "plugin", $dir_plugins . $plug_file);
59 59
 
60
-	$s .= "<strong class='nom'>" . typo($info['nom']) . "</strong>";
61
-	$s .= " <span class='version'>" . $info['version'] . "</span>";
62
-	$s .= " <span class='etat'> - " . plugin_etat_en_clair($info['etat']) . "</span>";
63
-	$s .= "</div>";
60
+    $s .= "<strong class='nom'>" . typo($info['nom']) . "</strong>";
61
+    $s .= " <span class='version'>" . $info['version'] . "</span>";
62
+    $s .= " <span class='etat'> - " . plugin_etat_en_clair($info['etat']) . "</span>";
63
+    $s .= "</div>";
64 64
 
65
-	if ($erreur) {
66
-		$s .= "<div class='erreur'>" . join('<br >', $info['erreur']) . "</div>";
67
-	}
65
+    if ($erreur) {
66
+        $s .= "<div class='erreur'>" . join('<br >', $info['erreur']) . "</div>";
67
+    }
68 68
 
69
-	$s .= "</li>";
69
+    $s .= "</li>";
70 70
 
71
-	return $s;
71
+    return $s;
72 72
 }
Please login to merge, or discard this patch.
ecrire/plugins/verifie_conformite.php 1 patch
Indentation   +203 added lines, -203 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 include_spip('inc/xml');
@@ -19,208 +19,208 @@  discard block
 block discarded – undo
19 19
 
20 20
 // https://code.spip.net/@plugin_verifie_conformite
21 21
 function plugins_verifie_conformite_dist($plug, &$arbre, $dir_plugins = _DIR_PLUGINS) {
22
-	static $etats = array('dev', 'experimental', 'test', 'stable');
22
+    static $etats = array('dev', 'experimental', 'test', 'stable');
23 23
 
24
-	$matches = array();
25
-	$silence = false;
26
-	$p = null;
27
-	// chercher la declaration <plugin spip='...'> a prendre pour cette version de SPIP
28
-	if ($n = spip_xml_match_nodes(",^plugin(\s|$),", $arbre, $matches)) {
29
-		// version de SPIP
30
-		$vspip = $GLOBALS['spip_version_branche'];
31
-		foreach ($matches as $tag => $sous) {
32
-			list($tagname, $atts) = spip_xml_decompose_tag($tag);
33
-			if ($tagname == 'plugin' and is_array($sous)) {
34
-				// On rajoute la condition sur $n :
35
-				// -- en effet si $n==1 on a pas plus a choisir la balise que l'on ait
36
-				//    un attribut spip ou pas. Cela permet de traiter tous les cas mono-balise
37
-				//    de la meme facon.
38
-				if (!isset($atts['spip'])
39
-					or $n == 1
40
-					or plugin_version_compatible($atts['spip'], $vspip, 'spip')
41
-				) {
42
-					// on prend la derniere declaration avec ce nom
43
-					$p = end($sous);
44
-					$compat_spip = isset($atts['spip']) ? $atts['spip'] : '';
45
-				}
46
-			}
47
-		}
48
-	}
49
-	if (is_null($p)) {
50
-		$arbre = array('erreur' => array(_T('erreur_plugin_tag_plugin_absent') . " : $plug"));
51
-		$silence = true;
52
-	} else {
53
-		$arbre = $p;
54
-	}
55
-	if (!is_array($arbre)) {
56
-		$arbre = array();
57
-	}
58
-	// verification de la conformite du plugin avec quelques
59
-	// precautions elementaires
60
-	if (!isset($arbre['nom'])) {
61
-		if (!$silence) {
62
-			$arbre['erreur'][] = _T('erreur_plugin_nom_manquant');
63
-		}
64
-		$arbre['nom'] = array("");
65
-	}
66
-	if (!isset($arbre['version'])) {
67
-		if (!$silence) {
68
-			$arbre['erreur'][] = _T('erreur_plugin_version_manquant');
69
-		}
70
-		$arbre['version'] = array("");
71
-	}
72
-	if (!isset($arbre['prefix'])) {
73
-		if (!$silence) {
74
-			$arbre['erreur'][] = _T('erreur_plugin_prefix_manquant');
75
-		}
76
-		$arbre['prefix'] = array("");
77
-	} else {
78
-		$prefix = trim(end($arbre['prefix']));
79
-		if (strtoupper($prefix) == 'SPIP' and $plug != "./") {
80
-			$arbre['erreur'][] = _T('erreur_plugin_prefix_interdit');
81
-		}
82
-		if (isset($arbre['etat'])) {
83
-			$etat = trim(end($arbre['etat']));
84
-			if (!in_array($etat, $etats)) {
85
-				$arbre['erreur'][] = _T('erreur_plugin_etat_inconnu') . " : '$etat'";
86
-			}
87
-		}
88
-		if (isset($arbre['options'])) {
89
-			foreach ($arbre['options'] as $optfile) {
90
-				$optfile = trim($optfile);
91
-				if (!@is_readable($dir_plugins . "$plug/$optfile")) {
92
-					if (!$silence) {
93
-						$arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile";
94
-					}
95
-				}
96
-			}
97
-		}
98
-		if (isset($arbre['fonctions'])) {
99
-			foreach ($arbre['fonctions'] as $optfile) {
100
-				$optfile = trim($optfile);
101
-				if (!@is_readable($dir_plugins . "$plug/$optfile")) {
102
-					if (!$silence) {
103
-						$arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile";
104
-					}
105
-				}
106
-			}
107
-		}
108
-		$fonctions = array();
109
-		if (isset($arbre['fonctions'])) {
110
-			$fonctions = $arbre['fonctions'];
111
-		}
112
-		$liste_methodes_reservees = array(
113
-			'__construct',
114
-			'__destruct',
115
-			'plugin',
116
-			'install',
117
-			'uninstall',
118
-			strtolower($prefix)
119
-		);
24
+    $matches = array();
25
+    $silence = false;
26
+    $p = null;
27
+    // chercher la declaration <plugin spip='...'> a prendre pour cette version de SPIP
28
+    if ($n = spip_xml_match_nodes(",^plugin(\s|$),", $arbre, $matches)) {
29
+        // version de SPIP
30
+        $vspip = $GLOBALS['spip_version_branche'];
31
+        foreach ($matches as $tag => $sous) {
32
+            list($tagname, $atts) = spip_xml_decompose_tag($tag);
33
+            if ($tagname == 'plugin' and is_array($sous)) {
34
+                // On rajoute la condition sur $n :
35
+                // -- en effet si $n==1 on a pas plus a choisir la balise que l'on ait
36
+                //    un attribut spip ou pas. Cela permet de traiter tous les cas mono-balise
37
+                //    de la meme facon.
38
+                if (!isset($atts['spip'])
39
+                    or $n == 1
40
+                    or plugin_version_compatible($atts['spip'], $vspip, 'spip')
41
+                ) {
42
+                    // on prend la derniere declaration avec ce nom
43
+                    $p = end($sous);
44
+                    $compat_spip = isset($atts['spip']) ? $atts['spip'] : '';
45
+                }
46
+            }
47
+        }
48
+    }
49
+    if (is_null($p)) {
50
+        $arbre = array('erreur' => array(_T('erreur_plugin_tag_plugin_absent') . " : $plug"));
51
+        $silence = true;
52
+    } else {
53
+        $arbre = $p;
54
+    }
55
+    if (!is_array($arbre)) {
56
+        $arbre = array();
57
+    }
58
+    // verification de la conformite du plugin avec quelques
59
+    // precautions elementaires
60
+    if (!isset($arbre['nom'])) {
61
+        if (!$silence) {
62
+            $arbre['erreur'][] = _T('erreur_plugin_nom_manquant');
63
+        }
64
+        $arbre['nom'] = array("");
65
+    }
66
+    if (!isset($arbre['version'])) {
67
+        if (!$silence) {
68
+            $arbre['erreur'][] = _T('erreur_plugin_version_manquant');
69
+        }
70
+        $arbre['version'] = array("");
71
+    }
72
+    if (!isset($arbre['prefix'])) {
73
+        if (!$silence) {
74
+            $arbre['erreur'][] = _T('erreur_plugin_prefix_manquant');
75
+        }
76
+        $arbre['prefix'] = array("");
77
+    } else {
78
+        $prefix = trim(end($arbre['prefix']));
79
+        if (strtoupper($prefix) == 'SPIP' and $plug != "./") {
80
+            $arbre['erreur'][] = _T('erreur_plugin_prefix_interdit');
81
+        }
82
+        if (isset($arbre['etat'])) {
83
+            $etat = trim(end($arbre['etat']));
84
+            if (!in_array($etat, $etats)) {
85
+                $arbre['erreur'][] = _T('erreur_plugin_etat_inconnu') . " : '$etat'";
86
+            }
87
+        }
88
+        if (isset($arbre['options'])) {
89
+            foreach ($arbre['options'] as $optfile) {
90
+                $optfile = trim($optfile);
91
+                if (!@is_readable($dir_plugins . "$plug/$optfile")) {
92
+                    if (!$silence) {
93
+                        $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile";
94
+                    }
95
+                }
96
+            }
97
+        }
98
+        if (isset($arbre['fonctions'])) {
99
+            foreach ($arbre['fonctions'] as $optfile) {
100
+                $optfile = trim($optfile);
101
+                if (!@is_readable($dir_plugins . "$plug/$optfile")) {
102
+                    if (!$silence) {
103
+                        $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $optfile";
104
+                    }
105
+                }
106
+            }
107
+        }
108
+        $fonctions = array();
109
+        if (isset($arbre['fonctions'])) {
110
+            $fonctions = $arbre['fonctions'];
111
+        }
112
+        $liste_methodes_reservees = array(
113
+            '__construct',
114
+            '__destruct',
115
+            'plugin',
116
+            'install',
117
+            'uninstall',
118
+            strtolower($prefix)
119
+        );
120 120
 
121
-		$extraire_pipelines = charger_fonction("extraire_pipelines", "plugins");
122
-		$arbre['pipeline'] = $extraire_pipelines($arbre);
123
-		foreach ($arbre['pipeline'] as $pipe) {
124
-			if (!isset($pipe['nom'])) {
125
-				if (!$silence) {
126
-					$arbre['erreur'][] = _T("erreur_plugin_nom_pipeline_non_defini");
127
-				}
128
-			}
129
-			if (isset($pipe['action'])) {
130
-				$action = $pipe['action'];
131
-			} else {
132
-				$action = $pipe['nom'];
133
-			}
134
-			// verif que la methode a un nom autorise
135
-			if (in_array(strtolower($action), $liste_methodes_reservees)) {
136
-				if (!$silence) {
137
-					$arbre['erreur'][] = _T("erreur_plugin_nom_fonction_interdit") . " : $action";
138
-				}
139
-			}
140
-			if (isset($pipe['inclure'])) {
141
-				$inclure = $dir_plugins . "$plug/" . $pipe['inclure'];
142
-				if (!@is_readable($inclure)) {
143
-					if (!$silence) {
144
-						$arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $inclure";
145
-					}
146
-				}
147
-			}
148
-		}
149
-		$necessite = array();
150
-		$spip_trouve = false;
151
-		if (spip_xml_match_nodes(',^necessite,', $arbre, $needs)) {
152
-			foreach (array_keys($needs) as $tag) {
153
-				list($tag, $att) = spip_xml_decompose_tag($tag);
154
-				if (!isset($att['id'])) {
155
-					if (!$silence) {
156
-						$arbre['erreur'][] = _T('erreur_plugin_attribut_balise_manquant',
157
-							array('attribut' => 'id', 'balise' => $att));
158
-					}
159
-				} else {
160
-					$necessite[] = $att;
161
-				}
162
-				if (strtolower($att['id']) == 'spip') {
163
-					$spip_trouve = true;
164
-				}
165
-			}
166
-		}
167
-		if ($compat_spip and !$spip_trouve) {
168
-			$necessite[] = array('id' => 'spip', 'version' => $compat_spip);
169
-		}
170
-		$arbre['necessite'] = $necessite;
171
-		$utilise = array();
172
-		if (spip_xml_match_nodes(',^utilise,', $arbre, $uses)) {
173
-			foreach (array_keys($uses) as $tag) {
174
-				list($tag, $att) = spip_xml_decompose_tag($tag);
175
-				if (!isset($att['id'])) {
176
-					if (!$silence) {
177
-						$arbre['erreur'][] = _T('erreur_plugin_attribut_balise_manquant',
178
-							array('attribut' => 'id', 'balise' => $att));
179
-					}
180
-				} else {
181
-					$utilise[] = $att;
182
-				}
183
-			}
184
-		}
185
-		$arbre['utilise'] = $utilise;
186
-		$procure = array();
187
-		if (spip_xml_match_nodes(',^procure,', $arbre, $uses)) {
188
-			foreach (array_keys($uses) as $tag) {
189
-				list($tag, $att) = spip_xml_decompose_tag($tag);
190
-				$procure[] = $att;
191
-			}
192
-		}
193
-		$arbre['procure'] = $procure;
194
-		$path = array();
195
-		if (spip_xml_match_nodes(',^chemin,', $arbre, $paths)) {
196
-			foreach (array_keys($paths) as $tag) {
197
-				list($tag, $att) = spip_xml_decompose_tag($tag);
198
-				$att['path'] = $att['dir']; // ancienne syntaxe
199
-				$path[] = $att;
200
-			}
201
-		} else {
202
-			$path = array(array('dir' => ''));
203
-		} // initialiser par defaut
204
-		$arbre['path'] = $path;
205
-		// exposer les noisettes
206
-		if (isset($arbre['noisette'])) {
207
-			foreach ($arbre['noisette'] as $k => $nut) {
208
-				$nut = preg_replace(',[.]html$,uims', '', trim($nut));
209
-				$arbre['noisette'][$k] = $nut;
210
-				if (!@is_readable($dir_plugins . "$plug/$nut.html")) {
211
-					if (!$silence) {
212
-						$arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $nut";
213
-					}
214
-				}
215
-			}
216
-		}
217
-		$traduire = array();
218
-		if (spip_xml_match_nodes(',^traduire,', $arbre, $trads)) {
219
-			foreach (array_keys($trads) as $tag) {
220
-				list($tag, $att) = spip_xml_decompose_tag($tag);
221
-				$traduire[] = $att;
222
-			}
223
-		}
224
-		$arbre['traduire'] = $traduire;
225
-	}
121
+        $extraire_pipelines = charger_fonction("extraire_pipelines", "plugins");
122
+        $arbre['pipeline'] = $extraire_pipelines($arbre);
123
+        foreach ($arbre['pipeline'] as $pipe) {
124
+            if (!isset($pipe['nom'])) {
125
+                if (!$silence) {
126
+                    $arbre['erreur'][] = _T("erreur_plugin_nom_pipeline_non_defini");
127
+                }
128
+            }
129
+            if (isset($pipe['action'])) {
130
+                $action = $pipe['action'];
131
+            } else {
132
+                $action = $pipe['nom'];
133
+            }
134
+            // verif que la methode a un nom autorise
135
+            if (in_array(strtolower($action), $liste_methodes_reservees)) {
136
+                if (!$silence) {
137
+                    $arbre['erreur'][] = _T("erreur_plugin_nom_fonction_interdit") . " : $action";
138
+                }
139
+            }
140
+            if (isset($pipe['inclure'])) {
141
+                $inclure = $dir_plugins . "$plug/" . $pipe['inclure'];
142
+                if (!@is_readable($inclure)) {
143
+                    if (!$silence) {
144
+                        $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $inclure";
145
+                    }
146
+                }
147
+            }
148
+        }
149
+        $necessite = array();
150
+        $spip_trouve = false;
151
+        if (spip_xml_match_nodes(',^necessite,', $arbre, $needs)) {
152
+            foreach (array_keys($needs) as $tag) {
153
+                list($tag, $att) = spip_xml_decompose_tag($tag);
154
+                if (!isset($att['id'])) {
155
+                    if (!$silence) {
156
+                        $arbre['erreur'][] = _T('erreur_plugin_attribut_balise_manquant',
157
+                            array('attribut' => 'id', 'balise' => $att));
158
+                    }
159
+                } else {
160
+                    $necessite[] = $att;
161
+                }
162
+                if (strtolower($att['id']) == 'spip') {
163
+                    $spip_trouve = true;
164
+                }
165
+            }
166
+        }
167
+        if ($compat_spip and !$spip_trouve) {
168
+            $necessite[] = array('id' => 'spip', 'version' => $compat_spip);
169
+        }
170
+        $arbre['necessite'] = $necessite;
171
+        $utilise = array();
172
+        if (spip_xml_match_nodes(',^utilise,', $arbre, $uses)) {
173
+            foreach (array_keys($uses) as $tag) {
174
+                list($tag, $att) = spip_xml_decompose_tag($tag);
175
+                if (!isset($att['id'])) {
176
+                    if (!$silence) {
177
+                        $arbre['erreur'][] = _T('erreur_plugin_attribut_balise_manquant',
178
+                            array('attribut' => 'id', 'balise' => $att));
179
+                    }
180
+                } else {
181
+                    $utilise[] = $att;
182
+                }
183
+            }
184
+        }
185
+        $arbre['utilise'] = $utilise;
186
+        $procure = array();
187
+        if (spip_xml_match_nodes(',^procure,', $arbre, $uses)) {
188
+            foreach (array_keys($uses) as $tag) {
189
+                list($tag, $att) = spip_xml_decompose_tag($tag);
190
+                $procure[] = $att;
191
+            }
192
+        }
193
+        $arbre['procure'] = $procure;
194
+        $path = array();
195
+        if (spip_xml_match_nodes(',^chemin,', $arbre, $paths)) {
196
+            foreach (array_keys($paths) as $tag) {
197
+                list($tag, $att) = spip_xml_decompose_tag($tag);
198
+                $att['path'] = $att['dir']; // ancienne syntaxe
199
+                $path[] = $att;
200
+            }
201
+        } else {
202
+            $path = array(array('dir' => ''));
203
+        } // initialiser par defaut
204
+        $arbre['path'] = $path;
205
+        // exposer les noisettes
206
+        if (isset($arbre['noisette'])) {
207
+            foreach ($arbre['noisette'] as $k => $nut) {
208
+                $nut = preg_replace(',[.]html$,uims', '', trim($nut));
209
+                $arbre['noisette'][$k] = $nut;
210
+                if (!@is_readable($dir_plugins . "$plug/$nut.html")) {
211
+                    if (!$silence) {
212
+                        $arbre['erreur'][] = _T('erreur_plugin_fichier_absent') . " : $nut";
213
+                    }
214
+                }
215
+            }
216
+        }
217
+        $traduire = array();
218
+        if (spip_xml_match_nodes(',^traduire,', $arbre, $trads)) {
219
+            foreach (array_keys($trads) as $tag) {
220
+                list($tag, $att) = spip_xml_decompose_tag($tag);
221
+                $traduire[] = $att;
222
+            }
223
+        }
224
+        $arbre['traduire'] = $traduire;
225
+    }
226 226
 }
Please login to merge, or discard this patch.