Completed
Push — master ( a5da4e...51674a )
by cam
01:27
created
ecrire/inc/install.php 2 patches
Indentation   +349 added lines, -349 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 
@@ -42,11 +42,11 @@  discard block
 block discarded – undo
42 42
  * @return void
43 43
  **/
44 44
 function install_fichier_connexion($nom, $texte) {
45
-	$texte = '<' . "?php\n"
46
-		. "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n"
47
-		. $texte;
45
+    $texte = '<' . "?php\n"
46
+        . "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n"
47
+        . $texte;
48 48
 
49
-	ecrire_fichier($nom, $texte);
49
+    ecrire_fichier($nom, $texte);
50 50
 }
51 51
 
52 52
 
@@ -75,20 +75,20 @@  discard block
 block discarded – undo
75 75
  *
76 76
  **/
77 77
 function install_connexion($adr, $port, $login, #[\SensitiveParameter] $pass, $base, $type, $pref, $ldap = '', $charset = '') {
78
-	$adr = addcslashes($adr, "'\\");
79
-	$port = addcslashes($port, "'\\");
80
-	$login = addcslashes($login, "'\\");
81
-	$pass = addcslashes($pass, "'\\");
82
-	$base = addcslashes($base, "'\\");
83
-	$type = addcslashes($type, "'\\");
84
-	$pref = addcslashes($pref, "'\\");
85
-	$ldap = addcslashes($ldap, "'\\");
86
-	$charset = addcslashes($charset, "'\\");
87
-
88
-	return "\$GLOBALS['spip_connect_version'] = 0.8;\n"
89
-	. 'spip_connect_db('
90
-	. "'$adr','$port','$login','$pass','$base'"
91
-	. ",'$type', '$pref','$ldap','$charset');\n";
78
+    $adr = addcslashes($adr, "'\\");
79
+    $port = addcslashes($port, "'\\");
80
+    $login = addcslashes($login, "'\\");
81
+    $pass = addcslashes($pass, "'\\");
82
+    $base = addcslashes($base, "'\\");
83
+    $type = addcslashes($type, "'\\");
84
+    $pref = addcslashes($pref, "'\\");
85
+    $ldap = addcslashes($ldap, "'\\");
86
+    $charset = addcslashes($charset, "'\\");
87
+
88
+    return "\$GLOBALS['spip_connect_version'] = 0.8;\n"
89
+    . 'spip_connect_db('
90
+    . "'$adr','$port','$login','$pass','$base'"
91
+    . ",'$type', '$pref','$ldap','$charset');\n";
92 92
 }
93 93
 
94 94
 
@@ -104,29 +104,29 @@  discard block
 block discarded – undo
104 104
  *     Tableau des informations sur la connexion
105 105
  **/
106 106
 function analyse_fichier_connection(string $file): array {
107
-	if (!file_exists($file)) {
108
-		return [];
109
-	}
110
-	$s = file_get_contents($file);
111
-	if (preg_match("#mysql_connect\([\"'](.*)[\"'],[\"'](.*)[\"'],[\"'](.*)[\"']\)#", $s, $regs)) {
112
-		array_shift($regs);
113
-
114
-		return $regs;
115
-	} else {
116
-		$ar = '\s*\'([^\']*)\'';
117
-		$r = '\s*,' . $ar;
118
-		$r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#";
119
-		if (preg_match($r, $s, $regs)) {
120
-			$regs[2] = $regs[1] . ($regs[2] ? ':' . $regs[2] . ';' : '');
121
-			array_shift($regs);
122
-			array_shift($regs);
123
-
124
-			return $regs;
125
-		}
126
-	}
127
-	spip_log("$file n'est pas un fichier de connexion");
128
-
129
-	return [];
107
+    if (!file_exists($file)) {
108
+        return [];
109
+    }
110
+    $s = file_get_contents($file);
111
+    if (preg_match("#mysql_connect\([\"'](.*)[\"'],[\"'](.*)[\"'],[\"'](.*)[\"']\)#", $s, $regs)) {
112
+        array_shift($regs);
113
+
114
+        return $regs;
115
+    } else {
116
+        $ar = '\s*\'([^\']*)\'';
117
+        $r = '\s*,' . $ar;
118
+        $r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#";
119
+        if (preg_match($r, $s, $regs)) {
120
+            $regs[2] = $regs[1] . ($regs[2] ? ':' . $regs[2] . ';' : '');
121
+            array_shift($regs);
122
+            array_shift($regs);
123
+
124
+            return $regs;
125
+        }
126
+    }
127
+    spip_log("$file n'est pas un fichier de connexion");
128
+
129
+    return [];
130 130
 }
131 131
 
132 132
 /**
@@ -143,80 +143,80 @@  discard block
 block discarded – undo
143 143
  *     Liste des noms de connecteurs
144 144
  **/
145 145
 function bases_referencees($exclu = '') {
146
-	$tables = [];
147
-	foreach (preg_files(_DIR_CONNECT, '.php$') as $f) {
148
-		if ($f != $exclu && analyse_fichier_connection($f)) {
149
-			$tables[] = basename((string) $f, '.php');
150
-		}
151
-	}
152
-
153
-	return $tables;
146
+    $tables = [];
147
+    foreach (preg_files(_DIR_CONNECT, '.php$') as $f) {
148
+        if ($f != $exclu && analyse_fichier_connection($f)) {
149
+            $tables[] = basename((string) $f, '.php');
150
+        }
151
+    }
152
+
153
+    return $tables;
154 154
 }
155 155
 
156 156
 
157 157
 function install_mode_appel($server_db, $tout = true) {
158
-	return ($server_db != 'mysql') ? ''
159
-		: (($tout ? test_rappel_nom_base_mysql($server_db) : '')
160
-			. test_sql_mode_mysql($server_db));
158
+    return ($server_db != 'mysql') ? ''
159
+        : (($tout ? test_rappel_nom_base_mysql($server_db) : '')
160
+            . test_sql_mode_mysql($server_db));
161 161
 }
162 162
 
163 163
 //
164 164
 // Verifier que l'hebergement est compatible SPIP ... ou l'inverse :-)
165 165
 // (sert a l'etape 1 de l'installation)
166 166
 function tester_compatibilite_hebergement() {
167
-	$err = [];
168
-
169
-	$p = phpversion();
170
-	if (version_compare($p, _PHP_MIN, '<')) {
171
-		$err[] = _T('install_php_version', ['version' => $p, 'minimum' => _PHP_MIN]);
172
-	}
173
-	if (version_compare($p, _PHP_MAX, '>')) {
174
-		$err[] = _T('install_php_version_max', ['version' => $p, 'maximum' => _PHP_MAX]);
175
-	}
176
-
177
-	$diff = array_diff(['sodium', 'xml', 'zip'], get_loaded_extensions());
178
-	if ($diff !== []) {
179
-		$err[] = _T('install_php_extension', ['extensions' => implode(',', $diff)]);
180
-	}
181
-
182
-	// Si on n'a pas la bonne version de PHP, c'est la fin
183
-	if ($err) {
184
-		die("<div class='error'>"
185
-			. '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"
186
-			. "<li><strong>{$err[0]}</strong></li>\n</ul></div>");
187
-	}
188
-
189
-	// Il faut une base de donnees tout de meme ...
190
-	$serveurs = install_select_serveur();
191
-	if (!$serveurs) {
192
-		$err[] = _T('install_extension_php_obligatoire')
193
-			. " <a href='http://www.php.net/mysql'>MYSQL</a>"
194
-			. "| <a href='http://www.php.net/sqlite'>SQLite</a>";
195
-	}
196
-
197
-	// et surtout pas ce mbstring.overload (has been DEPRECATED as of PHP 7.2.0, and REMOVED as of PHP 8.0.0)
198
-	if ($a = @ini_get('mbstring.func_overload')) {
199
-		$err[] = _T('install_extension_mbstring')
200
-			. "mbstring.func_overload=$a - <a href='http://www.php.net/mb_string'>mb_string</a>.<br /><small>";
201
-	}
202
-
203
-	if ($err) {
204
-		echo "<div class='error'>"
205
-			. '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>";
206
-		foreach ($err as $e) {
207
-			echo "<li><strong>$e</strong></li>\n";
208
-		}
209
-
210
-		# a priori ici on pourrait die(), mais il faut laisser la possibilite
211
-		# de forcer malgre tout (pour tester, ou si bug de detection)
212
-		echo "</ul></div>\n";
213
-	}
167
+    $err = [];
168
+
169
+    $p = phpversion();
170
+    if (version_compare($p, _PHP_MIN, '<')) {
171
+        $err[] = _T('install_php_version', ['version' => $p, 'minimum' => _PHP_MIN]);
172
+    }
173
+    if (version_compare($p, _PHP_MAX, '>')) {
174
+        $err[] = _T('install_php_version_max', ['version' => $p, 'maximum' => _PHP_MAX]);
175
+    }
176
+
177
+    $diff = array_diff(['sodium', 'xml', 'zip'], get_loaded_extensions());
178
+    if ($diff !== []) {
179
+        $err[] = _T('install_php_extension', ['extensions' => implode(',', $diff)]);
180
+    }
181
+
182
+    // Si on n'a pas la bonne version de PHP, c'est la fin
183
+    if ($err) {
184
+        die("<div class='error'>"
185
+            . '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"
186
+            . "<li><strong>{$err[0]}</strong></li>\n</ul></div>");
187
+    }
188
+
189
+    // Il faut une base de donnees tout de meme ...
190
+    $serveurs = install_select_serveur();
191
+    if (!$serveurs) {
192
+        $err[] = _T('install_extension_php_obligatoire')
193
+            . " <a href='http://www.php.net/mysql'>MYSQL</a>"
194
+            . "| <a href='http://www.php.net/sqlite'>SQLite</a>";
195
+    }
196
+
197
+    // et surtout pas ce mbstring.overload (has been DEPRECATED as of PHP 7.2.0, and REMOVED as of PHP 8.0.0)
198
+    if ($a = @ini_get('mbstring.func_overload')) {
199
+        $err[] = _T('install_extension_mbstring')
200
+            . "mbstring.func_overload=$a - <a href='http://www.php.net/mb_string'>mb_string</a>.<br /><small>";
201
+    }
202
+
203
+    if ($err) {
204
+        echo "<div class='error'>"
205
+            . '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>";
206
+        foreach ($err as $e) {
207
+            echo "<li><strong>$e</strong></li>\n";
208
+        }
209
+
210
+        # a priori ici on pourrait die(), mais il faut laisser la possibilite
211
+        # de forcer malgre tout (pour tester, ou si bug de detection)
212
+        echo "</ul></div>\n";
213
+    }
214 214
 }
215 215
 
216 216
 
217 217
 function info_etape($titre, $complement = '') {
218
-	return '<h2>' . $titre . "</h2>\n" .
219
-	($complement ? '' . $complement . "\n" : '');
218
+    return '<h2>' . $titre . "</h2>\n" .
219
+    ($complement ? '' . $complement . "\n" : '');
220 220
 }
221 221
 
222 222
 /**
@@ -226,143 +226,143 @@  discard block
 block discarded – undo
226 226
  * @return string Code HTML du bouton
227 227
  **/
228 228
 function bouton_suivant($code = '') {
229
-	if ($code == '') {
230
-		$code = _T('bouton_suivant');
231
-	}
232
-	static $suivant = 0;
233
-	$id = 'suivant' . (($suivant > 0) ? (string) $suivant : '');
234
-	$suivant += 1;
235
-
236
-	return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" .
237
-	$code .
238
-	" >>\" /></p>\n";
229
+    if ($code == '') {
230
+        $code = _T('bouton_suivant');
231
+    }
232
+    static $suivant = 0;
233
+    $id = 'suivant' . (($suivant > 0) ? (string) $suivant : '');
234
+    $suivant += 1;
235
+
236
+    return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" .
237
+    $code .
238
+    " >>\" /></p>\n";
239 239
 }
240 240
 
241 241
 function info_progression_etape($en_cours, $phase, $dir, $erreur = false) {
242
-	$intitule_etat = [];
243
-
244
-	$liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$');
245
-	$debut = 1;
246
-	$last = is_countable($liste) ? count($liste) : 0;
247
-
248
-	include_spip('inc/texte');
249
-	$intitule_etat['etape_'][1] = typo(_T('info_connexion_base_donnee'));
250
-	$intitule_etat['etape_'][2] = typo(_T('menu_aide_installation_choix_base'));
251
-	$intitule_etat['etape_'][3] = typo(_T('info_informations_personnelles'));
252
-	$intitule_etat['etape_'][4] = typo(_T('info_derniere_etape'));
253
-
254
-	$intitule_etat['etape_ldap'][1] = typo(_T('titre_connexion_ldap'));
255
-	$intitule_etat['etape_ldap'][2] = typo(_T('titre_connexion_ldap'));
256
-	$intitule_etat['etape_ldap'][3] = typo(_T('info_chemin_acces_1'));
257
-	$intitule_etat['etape_ldap'][4] = typo(_T('info_reglage_ldap'));
258
-	$intitule_etat['etape_ldap'][5] = typo(_T('info_ldap_ok'));
259
-
260
-	$aff_etapes = "<ul id='infos_etapes' class='infos_$phase$en_cours'>";
261
-
262
-	foreach (array_keys($liste) as $etape) {
263
-		if ($debut < $last) {
264
-			if ($debut == $en_cours && $erreur) {
265
-				$class = 'on erreur';
266
-			} else {
267
-				if ($debut == $en_cours) {
268
-					$class = 'on';
269
-				} else {
270
-					$class = $debut > $en_cours ? 'prochains' : 'valides';
271
-				}
272
-			}
273
-
274
-			$aff_etapes .= "<li class='$class'><div class='fond'>";
275
-			$aff_etapes .= '<em>' . _T('etape') . " </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
276
-			$aff_etapes .= '<' . (($debut == $en_cours) ? 'strong' : 'span') . ' class="label_etape">' . $intitule_etat["$phase"][$debut] . '</' . (($debut == $en_cours) ? 'strong' : 'span') . '>';
277
-			$aff_etapes .= '</div></li>';
278
-		}
279
-		$debut++;
280
-	}
281
-
282
-	return $aff_etapes . '</ul>';
242
+    $intitule_etat = [];
243
+
244
+    $liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$');
245
+    $debut = 1;
246
+    $last = is_countable($liste) ? count($liste) : 0;
247
+
248
+    include_spip('inc/texte');
249
+    $intitule_etat['etape_'][1] = typo(_T('info_connexion_base_donnee'));
250
+    $intitule_etat['etape_'][2] = typo(_T('menu_aide_installation_choix_base'));
251
+    $intitule_etat['etape_'][3] = typo(_T('info_informations_personnelles'));
252
+    $intitule_etat['etape_'][4] = typo(_T('info_derniere_etape'));
253
+
254
+    $intitule_etat['etape_ldap'][1] = typo(_T('titre_connexion_ldap'));
255
+    $intitule_etat['etape_ldap'][2] = typo(_T('titre_connexion_ldap'));
256
+    $intitule_etat['etape_ldap'][3] = typo(_T('info_chemin_acces_1'));
257
+    $intitule_etat['etape_ldap'][4] = typo(_T('info_reglage_ldap'));
258
+    $intitule_etat['etape_ldap'][5] = typo(_T('info_ldap_ok'));
259
+
260
+    $aff_etapes = "<ul id='infos_etapes' class='infos_$phase$en_cours'>";
261
+
262
+    foreach (array_keys($liste) as $etape) {
263
+        if ($debut < $last) {
264
+            if ($debut == $en_cours && $erreur) {
265
+                $class = 'on erreur';
266
+            } else {
267
+                if ($debut == $en_cours) {
268
+                    $class = 'on';
269
+                } else {
270
+                    $class = $debut > $en_cours ? 'prochains' : 'valides';
271
+                }
272
+            }
273
+
274
+            $aff_etapes .= "<li class='$class'><div class='fond'>";
275
+            $aff_etapes .= '<em>' . _T('etape') . " </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
276
+            $aff_etapes .= '<' . (($debut == $en_cours) ? 'strong' : 'span') . ' class="label_etape">' . $intitule_etat["$phase"][$debut] . '</' . (($debut == $en_cours) ? 'strong' : 'span') . '>';
277
+            $aff_etapes .= '</div></li>';
278
+        }
279
+        $debut++;
280
+    }
281
+
282
+    return $aff_etapes . '</ul>';
283 283
 }
284 284
 
285 285
 
286 286
 function fieldset($legend, $champs = [], $apres = '', $avant = '') {
287
-	return "<fieldset>\n" .
288
-	$avant .
289
-	($legend ? '<legend>' . $legend . "</legend>\n" : '') .
290
-	fieldset_champs($champs) .
291
-	$apres .
292
-	"</fieldset>\n";
287
+    return "<fieldset>\n" .
288
+    $avant .
289
+    ($legend ? '<legend>' . $legend . "</legend>\n" : '') .
290
+    fieldset_champs($champs) .
291
+    $apres .
292
+    "</fieldset>\n";
293 293
 }
294 294
 
295 295
 function fieldset_champs($champs = []) {
296
-	$fieldset = '';
297
-	foreach ($champs as $nom => $contenu) {
298
-		$type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', (string) $nom) ? 'password' : 'text');
299
-		$class = isset($contenu['hidden']) ? '' : "class='formo' size='40' ";
300
-		if (isset($contenu['alternatives'])) {
301
-			$fieldset .= $contenu['label'] . "\n";
302
-			foreach ($contenu['alternatives'] as $valeur => $label) {
303
-				$fieldset .= "<input type='radio' name='" . $nom .
304
-					"' id='$nom-$valeur' value='$valeur'"
305
-					. (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '')
306
-					. "/>\n";
307
-				$fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n";
308
-			}
309
-			$fieldset .= "<br />\n";
310
-		} else {
311
-			$fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n";
312
-			$fieldset .= '<input ' . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'"
313
-				. (preg_match(',^(pass|login),', (string) $nom) ? " autocomplete='off'" : '')
314
-				. ((isset($contenu['required']) && $contenu['required']) ? " required='required'" : '')
315
-				. " />\n";
316
-		}
317
-	}
318
-
319
-	return $fieldset;
296
+    $fieldset = '';
297
+    foreach ($champs as $nom => $contenu) {
298
+        $type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', (string) $nom) ? 'password' : 'text');
299
+        $class = isset($contenu['hidden']) ? '' : "class='formo' size='40' ";
300
+        if (isset($contenu['alternatives'])) {
301
+            $fieldset .= $contenu['label'] . "\n";
302
+            foreach ($contenu['alternatives'] as $valeur => $label) {
303
+                $fieldset .= "<input type='radio' name='" . $nom .
304
+                    "' id='$nom-$valeur' value='$valeur'"
305
+                    . (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '')
306
+                    . "/>\n";
307
+                $fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n";
308
+            }
309
+            $fieldset .= "<br />\n";
310
+        } else {
311
+            $fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n";
312
+            $fieldset .= '<input ' . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'"
313
+                . (preg_match(',^(pass|login),', (string) $nom) ? " autocomplete='off'" : '')
314
+                . ((isset($contenu['required']) && $contenu['required']) ? " required='required'" : '')
315
+                . " />\n";
316
+        }
317
+    }
318
+
319
+    return $fieldset;
320 320
 }
321 321
 
322 322
 function install_select_serveur() {
323
-	$options = [];
324
-	$dir = _DIR_RESTREINT . 'req/';
325
-	$d = opendir($dir);
326
-	if (!$d) {
327
-		return [];
328
-	}
329
-	while (($f = readdir($d)) !== false) {
330
-		if (
331
-			preg_match('/^(.*)[.]php$/', $f, $s)
332
-			&& is_readable($f = $dir . $f)
333
-		) {
334
-			require_once($f);
335
-			$s = $s[1];
336
-			$v = 'spip_versions_' . $s;
337
-			if (function_exists($v) && $v()) {
338
-				$titre = _T("install_select_type_$s");
339
-				// proposer mysql par defaut si dispo
340
-				$checked = ($s == 'mysql' ? " checked='checked'" : '');
341
-				$options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>"
342
-					. "<label for='$s'>" . ($titre ?: $s) . '</label></li>';
343
-			} else {
344
-				spip_log("$s: portage indisponible");
345
-			}
346
-		}
347
-	}
348
-	sort($options);
349
-
350
-	return $options;
323
+    $options = [];
324
+    $dir = _DIR_RESTREINT . 'req/';
325
+    $d = opendir($dir);
326
+    if (!$d) {
327
+        return [];
328
+    }
329
+    while (($f = readdir($d)) !== false) {
330
+        if (
331
+            preg_match('/^(.*)[.]php$/', $f, $s)
332
+            && is_readable($f = $dir . $f)
333
+        ) {
334
+            require_once($f);
335
+            $s = $s[1];
336
+            $v = 'spip_versions_' . $s;
337
+            if (function_exists($v) && $v()) {
338
+                $titre = _T("install_select_type_$s");
339
+                // proposer mysql par defaut si dispo
340
+                $checked = ($s == 'mysql' ? " checked='checked'" : '');
341
+                $options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>"
342
+                    . "<label for='$s'>" . ($titre ?: $s) . '</label></li>';
343
+            } else {
344
+                spip_log("$s: portage indisponible");
345
+            }
346
+        }
347
+    }
348
+    sort($options);
349
+
350
+    return $options;
351 351
 }
352 352
 
353 353
 function install_connexion_form($db, $login, #[\SensitiveParameter] $pass, $predef, $hidden, $etape, $jquery = true) {
354
-	$server_db = (is_string($predef[0])) ? $predef[0] : '';
355
-
356
-	return generer_form_ecrire('install', (
357
-		"\n<input type='hidden' name='etape' value='$etape' />"
358
-		. $hidden
359
-		. (_request('echec') ?
360
-			('<p><b>' . _T('avis_connexion_echec_1') .
361
-				'</b></p><p>' . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . '</p>')
362
-			: '')
363
-
364
-		. ($jquery ? http_script('', 'jquery.js') : '')
365
-		. http_script('
354
+    $server_db = (is_string($predef[0])) ? $predef[0] : '';
355
+
356
+    return generer_form_ecrire('install', (
357
+        "\n<input type='hidden' name='etape' value='$etape' />"
358
+        . $hidden
359
+        . (_request('echec') ?
360
+            ('<p><b>' . _T('avis_connexion_echec_1') .
361
+                '</b></p><p>' . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . '</p>')
362
+            : '')
363
+
364
+        . ($jquery ? http_script('', 'jquery.js') : '')
365
+        . http_script('
366 366
 		jQuery(function($) {
367 367
 			$details_db = $("#install_adresse_base_hebergeur,#install_login_base_hebergeur,#install_pass_base_hebergeur");
368 368
 			$("input[type=hidden][name=server_db]").each(function(){
@@ -395,145 +395,145 @@  discard block
 block discarded – undo
395 395
 			});
396 396
 		});')
397 397
 
398
-		. ($server_db
399
-			? '<input type="hidden" name="server_db" value="' . $server_db . '" />'
400
-			. (($predef[0])
401
-				? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>')
402
-				: '')
403
-			: ('<fieldset><legend>'
404
-				. _T('install_select_type_db')
405
-				. '</legend>'
406
-				. '<p class="explication">'
407
-				. _T('install_types_db_connus')
408
-				// Passer l'avertissement SQLIte en  commentaire, on pourra facilement le supprimer par la suite sans changer les traductions.
409
-				// . "<br /><small>(". _T('install_types_db_connus_avertissement') .')</small>'
410
-				. '</p>'
411
-				. "\n<div class='p'>\n<ul>\n"
412
-				. implode("\n", install_select_serveur())
413
-				. "\n</ul>\n</div></fieldset>")
414
-		)
415
-		. '<div id="install_adresse_base_hebergeur">'
416
-		. '<p>' . _T('texte_connexion_mysql') . '</p>'
417
-		. ($predef[1]
418
-			? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>'
419
-			: fieldset(
420
-				_T('entree_base_donnee_1'),
421
-				[
422
-					'adresse_db' => [
423
-						'label' => $db[1],
424
-						'valeur' => $db[0]
425
-					],
426
-				]
427
-			)
428
-		)
429
-		. '</div>'
430
-
431
-		. '<div id="install_login_base_hebergeur">'
432
-		. ($predef[2]
433
-			? '<h3>' . _T('install_login_base_hebergeur') . '</h3>'
434
-			: fieldset(
435
-				_T('entree_login_connexion_1'),
436
-				[
437
-					'login_db' => [
438
-						'label' => $login[1],
439
-						'valeur' => $login[0]
440
-					],
441
-				]
442
-			)
443
-		)
444
-		. '</div>'
445
-
446
-		. '<div id="install_pass_base_hebergeur">'
447
-		. ($predef[3]
448
-			? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>'
449
-			: fieldset(
450
-				_T('entree_mot_passe_1'),
451
-				[
452
-					'pass_db' => [
453
-						'label' => $pass[1],
454
-						'valeur' => $pass[0]
455
-					],
456
-				]
457
-			)
458
-		)
459
-		. '</div>'
460
-
461
-		. bouton_suivant()));
398
+        . ($server_db
399
+            ? '<input type="hidden" name="server_db" value="' . $server_db . '" />'
400
+            . (($predef[0])
401
+                ? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>')
402
+                : '')
403
+            : ('<fieldset><legend>'
404
+                . _T('install_select_type_db')
405
+                . '</legend>'
406
+                . '<p class="explication">'
407
+                . _T('install_types_db_connus')
408
+                // Passer l'avertissement SQLIte en  commentaire, on pourra facilement le supprimer par la suite sans changer les traductions.
409
+                // . "<br /><small>(". _T('install_types_db_connus_avertissement') .')</small>'
410
+                . '</p>'
411
+                . "\n<div class='p'>\n<ul>\n"
412
+                . implode("\n", install_select_serveur())
413
+                . "\n</ul>\n</div></fieldset>")
414
+        )
415
+        . '<div id="install_adresse_base_hebergeur">'
416
+        . '<p>' . _T('texte_connexion_mysql') . '</p>'
417
+        . ($predef[1]
418
+            ? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>'
419
+            : fieldset(
420
+                _T('entree_base_donnee_1'),
421
+                [
422
+                    'adresse_db' => [
423
+                        'label' => $db[1],
424
+                        'valeur' => $db[0]
425
+                    ],
426
+                ]
427
+            )
428
+        )
429
+        . '</div>'
430
+
431
+        . '<div id="install_login_base_hebergeur">'
432
+        . ($predef[2]
433
+            ? '<h3>' . _T('install_login_base_hebergeur') . '</h3>'
434
+            : fieldset(
435
+                _T('entree_login_connexion_1'),
436
+                [
437
+                    'login_db' => [
438
+                        'label' => $login[1],
439
+                        'valeur' => $login[0]
440
+                    ],
441
+                ]
442
+            )
443
+        )
444
+        . '</div>'
445
+
446
+        . '<div id="install_pass_base_hebergeur">'
447
+        . ($predef[3]
448
+            ? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>'
449
+            : fieldset(
450
+                _T('entree_mot_passe_1'),
451
+                [
452
+                    'pass_db' => [
453
+                        'label' => $pass[1],
454
+                        'valeur' => $pass[0]
455
+                    ],
456
+                ]
457
+            )
458
+        )
459
+        . '</div>'
460
+
461
+        . bouton_suivant()));
462 462
 }
463 463
 
464 464
 // 4 valeurs qu'on reconduit d'un script a l'autre
465 465
 // sauf s'ils sont predefinis.
466 466
 
467 467
 function predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) {
468
-	return ((defined('_INSTALL_HOST_DB'))
469
-		? ''
470
-		: "\n<input type='hidden' name='adresse_db'  value=\"" . spip_htmlspecialchars($adresse_db) . '" />'
471
-	)
472
-	. ((defined('_INSTALL_USER_DB'))
473
-		? ''
474
-		: "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . '" />'
475
-	)
476
-	. ((defined('_INSTALL_PASS_DB'))
477
-		? ''
478
-		: "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . '" />'
479
-	)
480
-
481
-	. ((defined('_INSTALL_SERVER_DB'))
482
-		? ''
483
-		: "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . '" />'
484
-	);
468
+    return ((defined('_INSTALL_HOST_DB'))
469
+        ? ''
470
+        : "\n<input type='hidden' name='adresse_db'  value=\"" . spip_htmlspecialchars($adresse_db) . '" />'
471
+    )
472
+    . ((defined('_INSTALL_USER_DB'))
473
+        ? ''
474
+        : "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . '" />'
475
+    )
476
+    . ((defined('_INSTALL_PASS_DB'))
477
+        ? ''
478
+        : "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . '" />'
479
+    )
480
+
481
+    . ((defined('_INSTALL_SERVER_DB'))
482
+        ? ''
483
+        : "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . '" />'
484
+    );
485 485
 }
486 486
 
487 487
 // presentation des bases existantes
488 488
 
489 489
 function install_etape_liste_bases($server_db, $login_db, $disabled = []) {
490
-	$bases = $checked = [];
491
-	$noms = sql_listdbs($server_db);
492
-	if (!$noms) {
493
-		return '';
494
-	}
495
-
496
-	foreach ($noms as $nom) {
497
-		$id = spip_htmlspecialchars($nom);
498
-		$dis = in_array($nom, $disabled) ? " disabled='disabled'" : '';
499
-		$base = ' name="choix_db" value="'
500
-			. $nom
501
-			. '"'
502
-			. $dis
503
-			. " type='radio' id='$id'";
504
-		$label = "<label for='$id'>"
505
-			. ($dis ? "<i>$nom</i>" : $nom)
506
-			. '</label>';
507
-
508
-		if (
509
-			!$checked
510
-			&& !$dis
511
-			&& ($nom == $login_db || $GLOBALS['table_prefix'] == $nom)
512
-		) {
513
-			$checked = "<input$base checked='checked' />\n$label";
514
-		} else {
515
-			$bases[] = "<input$base />\n$label";
516
-		}
517
-	}
518
-
519
-	if (!$bases && !$checked) {
520
-		return false;
521
-	}
522
-
523
-	if ($checked) {
524
-		array_unshift($bases, $checked);
525
-		$checked = true;
526
-	}
527
-
528
-	return [$checked, $bases];
490
+    $bases = $checked = [];
491
+    $noms = sql_listdbs($server_db);
492
+    if (!$noms) {
493
+        return '';
494
+    }
495
+
496
+    foreach ($noms as $nom) {
497
+        $id = spip_htmlspecialchars($nom);
498
+        $dis = in_array($nom, $disabled) ? " disabled='disabled'" : '';
499
+        $base = ' name="choix_db" value="'
500
+            . $nom
501
+            . '"'
502
+            . $dis
503
+            . " type='radio' id='$id'";
504
+        $label = "<label for='$id'>"
505
+            . ($dis ? "<i>$nom</i>" : $nom)
506
+            . '</label>';
507
+
508
+        if (
509
+            !$checked
510
+            && !$dis
511
+            && ($nom == $login_db || $GLOBALS['table_prefix'] == $nom)
512
+        ) {
513
+            $checked = "<input$base checked='checked' />\n$label";
514
+        } else {
515
+            $bases[] = "<input$base />\n$label";
516
+        }
517
+    }
518
+
519
+    if (!$bases && !$checked) {
520
+        return false;
521
+    }
522
+
523
+    if ($checked) {
524
+        array_unshift($bases, $checked);
525
+        $checked = true;
526
+    }
527
+
528
+    return [$checked, $bases];
529 529
 }
530 530
 
531 531
 function install_propager($hidden) {
532
-	$res = '';
533
-	foreach ($hidden as $k) {
534
-		$v = spip_htmlentities(_request($k));
535
-		$res .= "<input type='hidden' name='$k' value='$v' />";
536
-	}
532
+    $res = '';
533
+    foreach ($hidden as $k) {
534
+        $v = spip_htmlentities(_request($k));
535
+        $res .= "<input type='hidden' name='$k' value='$v' />";
536
+    }
537 537
 
538
-	return $res;
538
+    return $res;
539 539
 }
Please login to merge, or discard this patch.
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
  * @return void
43 43
  **/
44 44
 function install_fichier_connexion($nom, $texte) {
45
-	$texte = '<' . "?php\n"
45
+	$texte = '<'."?php\n"
46 46
 		. "if (!defined(\"_ECRIRE_INC_VERSION\")) return;\n"
47 47
 		. $texte;
48 48
 
@@ -114,10 +114,10 @@  discard block
 block discarded – undo
114 114
 		return $regs;
115 115
 	} else {
116 116
 		$ar = '\s*\'([^\']*)\'';
117
-		$r = '\s*,' . $ar;
117
+		$r = '\s*,'.$ar;
118 118
 		$r = "#spip_connect_db[(]$ar$r$r$r$r(?:$r(?:$r(?:$r(?:$r)?)?)?)?#";
119 119
 		if (preg_match($r, $s, $regs)) {
120
-			$regs[2] = $regs[1] . ($regs[2] ? ':' . $regs[2] . ';' : '');
120
+			$regs[2] = $regs[1].($regs[2] ? ':'.$regs[2].';' : '');
121 121
 			array_shift($regs);
122 122
 			array_shift($regs);
123 123
 
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 	// Si on n'a pas la bonne version de PHP, c'est la fin
183 183
 	if ($err) {
184 184
 		die("<div class='error'>"
185
-			. '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>"
185
+			. '<h3>'._T('avis_attention').'</h3><p>'._T('install_echec_annonce')."</p><ul class='spip'>"
186 186
 			. "<li><strong>{$err[0]}</strong></li>\n</ul></div>");
187 187
 	}
188 188
 
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 
203 203
 	if ($err) {
204 204
 		echo "<div class='error'>"
205
-			. '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>";
205
+			. '<h3>'._T('avis_attention').'</h3><p>'._T('install_echec_annonce')."</p><ul class='spip'>";
206 206
 		foreach ($err as $e) {
207 207
 			echo "<li><strong>$e</strong></li>\n";
208 208
 		}
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
 
216 216
 
217 217
 function info_etape($titre, $complement = '') {
218
-	return '<h2>' . $titre . "</h2>\n" .
219
-	($complement ? '' . $complement . "\n" : '');
218
+	return '<h2>'.$titre."</h2>\n".
219
+	($complement ? ''.$complement."\n" : '');
220 220
 }
221 221
 
222 222
 /**
@@ -230,18 +230,18 @@  discard block
 block discarded – undo
230 230
 		$code = _T('bouton_suivant');
231 231
 	}
232 232
 	static $suivant = 0;
233
-	$id = 'suivant' . (($suivant > 0) ? (string) $suivant : '');
233
+	$id = 'suivant'.(($suivant > 0) ? (string) $suivant : '');
234 234
 	$suivant += 1;
235 235
 
236
-	return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" .
237
-	$code .
236
+	return "\n<p class='boutons suivant'><input id='".$id."' type='submit'\nvalue=\"".
237
+	$code.
238 238
 	" >>\" /></p>\n";
239 239
 }
240 240
 
241 241
 function info_progression_etape($en_cours, $phase, $dir, $erreur = false) {
242 242
 	$intitule_etat = [];
243 243
 
244
-	$liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$');
244
+	$liste = find_all_in_path($dir, $phase.'(([0-9])+|fin)[.]php$');
245 245
 	$debut = 1;
246 246
 	$last = is_countable($liste) ? count($liste) : 0;
247 247
 
@@ -272,23 +272,23 @@  discard block
 block discarded – undo
272 272
 			}
273 273
 
274 274
 			$aff_etapes .= "<li class='$class'><div class='fond'>";
275
-			$aff_etapes .= '<em>' . _T('etape') . " </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
276
-			$aff_etapes .= '<' . (($debut == $en_cours) ? 'strong' : 'span') . ' class="label_etape">' . $intitule_etat["$phase"][$debut] . '</' . (($debut == $en_cours) ? 'strong' : 'span') . '>';
275
+			$aff_etapes .= '<em>'._T('etape')." </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
276
+			$aff_etapes .= '<'.(($debut == $en_cours) ? 'strong' : 'span').' class="label_etape">'.$intitule_etat["$phase"][$debut].'</'.(($debut == $en_cours) ? 'strong' : 'span').'>';
277 277
 			$aff_etapes .= '</div></li>';
278 278
 		}
279 279
 		$debut++;
280 280
 	}
281 281
 
282
-	return $aff_etapes . '</ul>';
282
+	return $aff_etapes.'</ul>';
283 283
 }
284 284
 
285 285
 
286 286
 function fieldset($legend, $champs = [], $apres = '', $avant = '') {
287
-	return "<fieldset>\n" .
288
-	$avant .
289
-	($legend ? '<legend>' . $legend . "</legend>\n" : '') .
290
-	fieldset_champs($champs) .
291
-	$apres .
287
+	return "<fieldset>\n".
288
+	$avant.
289
+	($legend ? '<legend>'.$legend."</legend>\n" : '').
290
+	fieldset_champs($champs).
291
+	$apres.
292 292
 	"</fieldset>\n";
293 293
 }
294 294
 
@@ -298,18 +298,18 @@  discard block
 block discarded – undo
298 298
 		$type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', (string) $nom) ? 'password' : 'text');
299 299
 		$class = isset($contenu['hidden']) ? '' : "class='formo' size='40' ";
300 300
 		if (isset($contenu['alternatives'])) {
301
-			$fieldset .= $contenu['label'] . "\n";
301
+			$fieldset .= $contenu['label']."\n";
302 302
 			foreach ($contenu['alternatives'] as $valeur => $label) {
303
-				$fieldset .= "<input type='radio' name='" . $nom .
303
+				$fieldset .= "<input type='radio' name='".$nom.
304 304
 					"' id='$nom-$valeur' value='$valeur'"
305 305
 					. (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '')
306 306
 					. "/>\n";
307
-				$fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n";
307
+				$fieldset .= "<label for='$nom-$valeur'>".$label."</label>\n";
308 308
 			}
309 309
 			$fieldset .= "<br />\n";
310 310
 		} else {
311
-			$fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n";
312
-			$fieldset .= '<input ' . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'"
311
+			$fieldset .= "<label for='".$nom."'>".$contenu['label']."</label>\n";
312
+			$fieldset .= '<input '.$class."type='".$type."' id='".$nom."' name='".$nom."'\nvalue='".$contenu['valeur']."'"
313 313
 				. (preg_match(',^(pass|login),', (string) $nom) ? " autocomplete='off'" : '')
314 314
 				. ((isset($contenu['required']) && $contenu['required']) ? " required='required'" : '')
315 315
 				. " />\n";
@@ -321,7 +321,7 @@  discard block
 block discarded – undo
321 321
 
322 322
 function install_select_serveur() {
323 323
 	$options = [];
324
-	$dir = _DIR_RESTREINT . 'req/';
324
+	$dir = _DIR_RESTREINT.'req/';
325 325
 	$d = opendir($dir);
326 326
 	if (!$d) {
327 327
 		return [];
@@ -329,17 +329,17 @@  discard block
 block discarded – undo
329 329
 	while (($f = readdir($d)) !== false) {
330 330
 		if (
331 331
 			preg_match('/^(.*)[.]php$/', $f, $s)
332
-			&& is_readable($f = $dir . $f)
332
+			&& is_readable($f = $dir.$f)
333 333
 		) {
334 334
 			require_once($f);
335 335
 			$s = $s[1];
336
-			$v = 'spip_versions_' . $s;
336
+			$v = 'spip_versions_'.$s;
337 337
 			if (function_exists($v) && $v()) {
338 338
 				$titre = _T("install_select_type_$s");
339 339
 				// proposer mysql par defaut si dispo
340 340
 				$checked = ($s == 'mysql' ? " checked='checked'" : '');
341 341
 				$options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>"
342
-					. "<label for='$s'>" . ($titre ?: $s) . '</label></li>';
342
+					. "<label for='$s'>".($titre ?: $s).'</label></li>';
343 343
 			} else {
344 344
 				spip_log("$s: portage indisponible");
345 345
 			}
@@ -357,8 +357,8 @@  discard block
 block discarded – undo
357 357
 		"\n<input type='hidden' name='etape' value='$etape' />"
358 358
 		. $hidden
359 359
 		. (_request('echec') ?
360
-			('<p><b>' . _T('avis_connexion_echec_1') .
361
-				'</b></p><p>' . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . '</p>')
360
+			('<p><b>'._T('avis_connexion_echec_1').
361
+				'</b></p><p>'._T('avis_connexion_echec_2')."</p><p style='font-size: small;'>"._T('avis_connexion_echec_3').'</p>')
362 362
 			: '')
363 363
 
364 364
 		. ($jquery ? http_script('', 'jquery.js') : '')
@@ -396,9 +396,9 @@  discard block
 block discarded – undo
396 396
 		});')
397 397
 
398 398
 		. ($server_db
399
-			? '<input type="hidden" name="server_db" value="' . $server_db . '" />'
399
+			? '<input type="hidden" name="server_db" value="'.$server_db.'" />'
400 400
 			. (($predef[0])
401
-				? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>')
401
+				? ('<h3>'._T('install_serveur_hebergeur').'</h3>')
402 402
 				: '')
403 403
 			: ('<fieldset><legend>'
404 404
 				. _T('install_select_type_db')
@@ -413,9 +413,9 @@  discard block
 block discarded – undo
413 413
 				. "\n</ul>\n</div></fieldset>")
414 414
 		)
415 415
 		. '<div id="install_adresse_base_hebergeur">'
416
-		. '<p>' . _T('texte_connexion_mysql') . '</p>'
416
+		. '<p>'._T('texte_connexion_mysql').'</p>'
417 417
 		. ($predef[1]
418
-			? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>'
418
+			? '<h3>'._T('install_adresse_base_hebergeur').'</h3>'
419 419
 			: fieldset(
420 420
 				_T('entree_base_donnee_1'),
421 421
 				[
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
 
431 431
 		. '<div id="install_login_base_hebergeur">'
432 432
 		. ($predef[2]
433
-			? '<h3>' . _T('install_login_base_hebergeur') . '</h3>'
433
+			? '<h3>'._T('install_login_base_hebergeur').'</h3>'
434 434
 			: fieldset(
435 435
 				_T('entree_login_connexion_1'),
436 436
 				[
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 
446 446
 		. '<div id="install_pass_base_hebergeur">'
447 447
 		. ($predef[3]
448
-			? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>'
448
+			? '<h3>'._T('install_pass_base_hebergeur').'</h3>'
449 449
 			: fieldset(
450 450
 				_T('entree_mot_passe_1'),
451 451
 				[
@@ -467,20 +467,20 @@  discard block
 block discarded – undo
467 467
 function predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) {
468 468
 	return ((defined('_INSTALL_HOST_DB'))
469 469
 		? ''
470
-		: "\n<input type='hidden' name='adresse_db'  value=\"" . spip_htmlspecialchars($adresse_db) . '" />'
470
+		: "\n<input type='hidden' name='adresse_db'  value=\"".spip_htmlspecialchars($adresse_db).'" />'
471 471
 	)
472 472
 	. ((defined('_INSTALL_USER_DB'))
473 473
 		? ''
474
-		: "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . '" />'
474
+		: "\n<input type='hidden' name='login_db' value=\"".spip_htmlspecialchars($login_db).'" />'
475 475
 	)
476 476
 	. ((defined('_INSTALL_PASS_DB'))
477 477
 		? ''
478
-		: "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . '" />'
478
+		: "\n<input type='hidden' name='pass_db' value=\"".spip_htmlspecialchars($pass_db).'" />'
479 479
 	)
480 480
 
481 481
 	. ((defined('_INSTALL_SERVER_DB'))
482 482
 		? ''
483
-		: "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . '" />'
483
+		: "\n<input type='hidden' name='server_db' value=\"".spip_htmlspecialchars($server_db).'" />'
484 484
 	);
485 485
 }
486 486
 
Please login to merge, or discard this patch.
ecrire/inc/actions.php 2 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
  *     URL, code HTML du formulaire ou tableau (action, arg, hash)
43 43
  */
44 44
 function generer_action_auteur($action, $arg = '', $redirect = '', $mode = false, $att = '', $public = false) {
45
-	$securiser_action = charger_fonction('securiser_action', 'inc');
45
+    $securiser_action = charger_fonction('securiser_action', 'inc');
46 46
 
47
-	return $securiser_action($action, $arg, $redirect, $mode, $att, $public);
47
+    return $securiser_action($action, $arg, $redirect, $mode, $att, $public);
48 48
 }
49 49
 
50 50
 /**
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
  *     Code HTML du formulaire
78 78
  */
79 79
 function redirige_action_auteur($action, $arg, $ret, $gra = '', $mode = false, $atts = '', $public = false) {
80
-	$r = ($public ? _DIR_RESTREINT_ABS : _DIR_RESTREINT) . generer_url_ecrire($ret, $gra, true, true);
80
+    $r = ($public ? _DIR_RESTREINT_ABS : _DIR_RESTREINT) . generer_url_ecrire($ret, $gra, true, true);
81 81
 
82
-	return generer_action_auteur($action, $arg, $r, $mode, $atts, $public);
82
+    return generer_action_auteur($action, $arg, $r, $mode, $atts, $public);
83 83
 }
84 84
 
85 85
 /**
@@ -104,9 +104,9 @@  discard block
 block discarded – undo
104 104
  *     URL, code HTML du formulaire ou tableau (action, arg, hash)
105 105
  */
106 106
 function redirige_action_post($action, $arg, $ret, $gra, $corps, $att = '') {
107
-	$r = _DIR_RESTREINT . generer_url_ecrire($ret, $gra, false, true);
107
+    $r = _DIR_RESTREINT . generer_url_ecrire($ret, $gra, false, true);
108 108
 
109
-	return generer_action_auteur($action, $arg, $r, $corps, $att . " method='post'");
109
+    return generer_action_auteur($action, $arg, $r, $corps, $att . " method='post'");
110 110
 }
111 111
 
112 112
 
@@ -123,26 +123,26 @@  discard block
 block discarded – undo
123 123
  *   passer "text/html" comme $content_type
124 124
  */
125 125
 function ajax_retour($corps, $content_type = null): void {
126
-	$xml = false;
127
-	if (is_null($content_type) || $content_type === true) {
128
-		$xml = true;
129
-		$content_type = 'text/html';
130
-	} elseif (!$content_type || !is_string($content_type) || !str_contains($content_type, '/')) {
131
-		$content_type = 'text/html';
132
-	}
126
+    $xml = false;
127
+    if (is_null($content_type) || $content_type === true) {
128
+        $xml = true;
129
+        $content_type = 'text/html';
130
+    } elseif (!$content_type || !is_string($content_type) || !str_contains($content_type, '/')) {
131
+        $content_type = 'text/html';
132
+    }
133 133
 
134
-	$e = '';
135
-	if (
136
-		isset($_COOKIE['spip_admin'])
137
-		&& (_request('var_mode') == 'debug' || !empty($GLOBALS['tableau_des_temps']))
138
-	) {
139
-		$e = erreur_squelette();
140
-	}
134
+    $e = '';
135
+    if (
136
+        isset($_COOKIE['spip_admin'])
137
+        && (_request('var_mode') == 'debug' || !empty($GLOBALS['tableau_des_temps']))
138
+    ) {
139
+        $e = erreur_squelette();
140
+    }
141 141
 
142
-	$c = $GLOBALS['meta']['charset'];
143
-	header('Content-Type: ' . $content_type . '; charset=' . $c);
144
-	$debut = (($xml && strlen(trim($corps))) ? '<' . "?xml version='1.0' encoding='" . $c . "'?" . ">\n" : '');
145
-	$fin = '';
142
+    $c = $GLOBALS['meta']['charset'];
143
+    header('Content-Type: ' . $content_type . '; charset=' . $c);
144
+    $debut = (($xml && strlen(trim($corps))) ? '<' . "?xml version='1.0' encoding='" . $c . "'?" . ">\n" : '');
145
+    $fin = '';
146 146
 
147
-	echo $debut, $corps, $fin, $e;
147
+    echo $debut, $corps, $fin, $e;
148 148
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
  *     Code HTML du formulaire
78 78
  */
79 79
 function redirige_action_auteur($action, $arg, $ret, $gra = '', $mode = false, $atts = '', $public = false) {
80
-	$r = ($public ? _DIR_RESTREINT_ABS : _DIR_RESTREINT) . generer_url_ecrire($ret, $gra, true, true);
80
+	$r = ($public ? _DIR_RESTREINT_ABS : _DIR_RESTREINT).generer_url_ecrire($ret, $gra, true, true);
81 81
 
82 82
 	return generer_action_auteur($action, $arg, $r, $mode, $atts, $public);
83 83
 }
@@ -104,9 +104,9 @@  discard block
 block discarded – undo
104 104
  *     URL, code HTML du formulaire ou tableau (action, arg, hash)
105 105
  */
106 106
 function redirige_action_post($action, $arg, $ret, $gra, $corps, $att = '') {
107
-	$r = _DIR_RESTREINT . generer_url_ecrire($ret, $gra, false, true);
107
+	$r = _DIR_RESTREINT.generer_url_ecrire($ret, $gra, false, true);
108 108
 
109
-	return generer_action_auteur($action, $arg, $r, $corps, $att . " method='post'");
109
+	return generer_action_auteur($action, $arg, $r, $corps, $att." method='post'");
110 110
 }
111 111
 
112 112
 
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
 	}
141 141
 
142 142
 	$c = $GLOBALS['meta']['charset'];
143
-	header('Content-Type: ' . $content_type . '; charset=' . $c);
144
-	$debut = (($xml && strlen(trim($corps))) ? '<' . "?xml version='1.0' encoding='" . $c . "'?" . ">\n" : '');
143
+	header('Content-Type: '.$content_type.'; charset='.$c);
144
+	$debut = (($xml && strlen(trim($corps))) ? '<'."?xml version='1.0' encoding='".$c."'?".">\n" : '');
145 145
 	$fin = '';
146 146
 
147 147
 	echo $debut, $corps, $fin, $e;
Please login to merge, or discard this patch.
ecrire/inc/cvt_autosave.php 2 patches
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  */
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  * @return string
27 27
  */
28 28
 function autosave_clean_value($val) {
29
-	return stripslashes(urldecode((string) $val));
29
+    return stripslashes(urldecode((string) $val));
30 30
 }
31 31
 
32 32
 /**
@@ -37,58 +37,58 @@  discard block
 block discarded – undo
37 37
  * @return array
38 38
  */
39 39
 function cvtautosave_formulaire_charger($flux) {
40
-	if (
41
-		is_array($flux['data'])
42
-		&& isset($flux['data']['_autosave_id'])
43
-		&& ($cle_autosave = $flux['data']['_autosave_id'])
44
-	) {
45
-		$form = $flux['args']['form'];
46
-		$je_suis_poste = $flux['args']['je_suis_poste'];
40
+    if (
41
+        is_array($flux['data'])
42
+        && isset($flux['data']['_autosave_id'])
43
+        && ($cle_autosave = $flux['data']['_autosave_id'])
44
+    ) {
45
+        $form = $flux['args']['form'];
46
+        $je_suis_poste = $flux['args']['je_suis_poste'];
47 47
 
48
-		$cle_autosave = serialize($cle_autosave);
49
-		$cle_autosave = $form . '_' . md5($cle_autosave);
48
+        $cle_autosave = serialize($cle_autosave);
49
+        $cle_autosave = $form . '_' . md5($cle_autosave);
50 50
 
51
-		// si on a un backup en session et qu'on est au premier chargement, non poste
52
-		// on restitue les donnees
53
-		if (
54
-			isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])
55
-			&& !$je_suis_poste
56
-		) {
57
-			parse_str((string) $GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave], $vars);
58
-			foreach ($vars as $key => $val) {
59
-				if (isset($flux['data'][$key])) {
60
-					$flux['data'][$key] = (is_string($val) ? autosave_clean_value($val) : array_map(
61
-						'autosave_clean_value',
62
-						$val
63
-					));
64
-				}
65
-			}
66
-		}
51
+        // si on a un backup en session et qu'on est au premier chargement, non poste
52
+        // on restitue les donnees
53
+        if (
54
+            isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])
55
+            && !$je_suis_poste
56
+        ) {
57
+            parse_str((string) $GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave], $vars);
58
+            foreach ($vars as $key => $val) {
59
+                if (isset($flux['data'][$key])) {
60
+                    $flux['data'][$key] = (is_string($val) ? autosave_clean_value($val) : array_map(
61
+                        'autosave_clean_value',
62
+                        $val
63
+                    ));
64
+                }
65
+            }
66
+        }
67 67
 
68
-		// si on est dans le charger() qui suit le traiter(), l'autosave a normalement ete vide
69
-		// mais si il y a plusieurs sessions il peut y avoir concurrence et un retour de l'autosave
70
-		if ($je_suis_poste && _request('autosave') === $cle_autosave && function_exists('terminer_actualiser_sessions')) {
71
-			terminer_actualiser_sessions();
72
-			// et verifions si jamais l'autosave a fait un come back, dans ce cas on le revide
73
-			if (isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])) {
74
-				session_set('session_autosave_' . $cle_autosave, null);
75
-				// en court sleep pour etre certain que la concurrence est finie
76
-				sleep(1);
77
-				terminer_actualiser_sessions();
78
-			}
79
-		}
68
+        // si on est dans le charger() qui suit le traiter(), l'autosave a normalement ete vide
69
+        // mais si il y a plusieurs sessions il peut y avoir concurrence et un retour de l'autosave
70
+        if ($je_suis_poste && _request('autosave') === $cle_autosave && function_exists('terminer_actualiser_sessions')) {
71
+            terminer_actualiser_sessions();
72
+            // et verifions si jamais l'autosave a fait un come back, dans ce cas on le revide
73
+            if (isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])) {
74
+                session_set('session_autosave_' . $cle_autosave, null);
75
+                // en court sleep pour etre certain que la concurrence est finie
76
+                sleep(1);
77
+                terminer_actualiser_sessions();
78
+            }
79
+        }
80 80
 
81 81
 
82
-		/**
83
-		 * Envoyer le input hidden et le bout de js qui l'utilisera
84
-		 */
85
-		$flux['data']['_hidden'] .= "<input type='hidden' name='autosave' class='autosaveactive' value='$cle_autosave' />"
86
-			. '<script type="text/javascript">/*<![CDATA[*/if (window.jQuery) jQuery(function(){
82
+        /**
83
+         * Envoyer le input hidden et le bout de js qui l'utilisera
84
+         */
85
+        $flux['data']['_hidden'] .= "<input type='hidden' name='autosave' class='autosaveactive' value='$cle_autosave' />"
86
+            . '<script type="text/javascript">/*<![CDATA[*/if (window.jQuery) jQuery(function(){
87 87
 		  $("input.autosaveactive").closest("form:not(.autosaveon)").autosave({url:"' . $GLOBALS['meta']['adresse_site'] . '/"}).addClass("autosaveon");
88 88
 			});/*]]>*/</script>';
89
-	}
89
+    }
90 90
 
91
-	return $flux;
91
+    return $flux;
92 92
 }
93 93
 
94 94
 /**
@@ -102,33 +102,33 @@  discard block
 block discarded – undo
102 102
  * @return array
103 103
  */
104 104
 function cvtautosave_formulaire_traiter($flux) {
105
-	// si on poste 'autosave' c'est qu'on n'a plus besoin de sauvegarder :
106
-	// on elimine les donnees de la session
107
-	if ($cle_autosave = _request('autosave')) {
108
-		include_spip('inc/session');
109
-		session_set('session_autosave_' . $cle_autosave, null);
110
-	}
105
+    // si on poste 'autosave' c'est qu'on n'a plus besoin de sauvegarder :
106
+    // on elimine les donnees de la session
107
+    if ($cle_autosave = _request('autosave')) {
108
+        include_spip('inc/session');
109
+        session_set('session_autosave_' . $cle_autosave, null);
110
+    }
111 111
 
112
-	if (isset($GLOBALS['visiteur_session']) && $GLOBALS['visiteur_session']) {
113
-		// delai par defaut avant purge d'un backup de form : 72H
114
-		if (!defined('_AUTOSAVE_GB_DELAY')) {
115
-			define('_AUTOSAVE_GB_DELAY', 72 * 3600);
116
-		}
117
-		$time_too_old = time() - _AUTOSAVE_GB_DELAY;
118
-		// purger aussi toutes les vieilles autosave
119
-		$session = $GLOBALS['visiteur_session'];
120
-		foreach ($session as $k => $v) {
121
-			if (str_starts_with((string) $k, 'session_autosave_')) {
122
-				$timestamp = 0;
123
-				if (preg_match(',&__timestamp=(\d+)$,', (string) $v, $m)) {
124
-					$timestamp = (int) $m[1];
125
-				}
126
-				if ($timestamp < $time_too_old) {
127
-					session_set($k, null);
128
-				}
129
-			}
130
-		}
131
-	}
112
+    if (isset($GLOBALS['visiteur_session']) && $GLOBALS['visiteur_session']) {
113
+        // delai par defaut avant purge d'un backup de form : 72H
114
+        if (!defined('_AUTOSAVE_GB_DELAY')) {
115
+            define('_AUTOSAVE_GB_DELAY', 72 * 3600);
116
+        }
117
+        $time_too_old = time() - _AUTOSAVE_GB_DELAY;
118
+        // purger aussi toutes les vieilles autosave
119
+        $session = $GLOBALS['visiteur_session'];
120
+        foreach ($session as $k => $v) {
121
+            if (str_starts_with((string) $k, 'session_autosave_')) {
122
+                $timestamp = 0;
123
+                if (preg_match(',&__timestamp=(\d+)$,', (string) $v, $m)) {
124
+                    $timestamp = (int) $m[1];
125
+                }
126
+                if ($timestamp < $time_too_old) {
127
+                    session_set($k, null);
128
+                }
129
+            }
130
+        }
131
+    }
132 132
 
133
-	return $flux;
133
+    return $flux;
134 134
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -46,15 +46,15 @@  discard block
 block discarded – undo
46 46
 		$je_suis_poste = $flux['args']['je_suis_poste'];
47 47
 
48 48
 		$cle_autosave = serialize($cle_autosave);
49
-		$cle_autosave = $form . '_' . md5($cle_autosave);
49
+		$cle_autosave = $form.'_'.md5($cle_autosave);
50 50
 
51 51
 		// si on a un backup en session et qu'on est au premier chargement, non poste
52 52
 		// on restitue les donnees
53 53
 		if (
54
-			isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])
54
+			isset($GLOBALS['visiteur_session']['session_autosave_'.$cle_autosave])
55 55
 			&& !$je_suis_poste
56 56
 		) {
57
-			parse_str((string) $GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave], $vars);
57
+			parse_str((string) $GLOBALS['visiteur_session']['session_autosave_'.$cle_autosave], $vars);
58 58
 			foreach ($vars as $key => $val) {
59 59
 				if (isset($flux['data'][$key])) {
60 60
 					$flux['data'][$key] = (is_string($val) ? autosave_clean_value($val) : array_map(
@@ -70,8 +70,8 @@  discard block
 block discarded – undo
70 70
 		if ($je_suis_poste && _request('autosave') === $cle_autosave && function_exists('terminer_actualiser_sessions')) {
71 71
 			terminer_actualiser_sessions();
72 72
 			// et verifions si jamais l'autosave a fait un come back, dans ce cas on le revide
73
-			if (isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])) {
74
-				session_set('session_autosave_' . $cle_autosave, null);
73
+			if (isset($GLOBALS['visiteur_session']['session_autosave_'.$cle_autosave])) {
74
+				session_set('session_autosave_'.$cle_autosave, null);
75 75
 				// en court sleep pour etre certain que la concurrence est finie
76 76
 				sleep(1);
77 77
 				terminer_actualiser_sessions();
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 		 */
85 85
 		$flux['data']['_hidden'] .= "<input type='hidden' name='autosave' class='autosaveactive' value='$cle_autosave' />"
86 86
 			. '<script type="text/javascript">/*<![CDATA[*/if (window.jQuery) jQuery(function(){
87
-		  $("input.autosaveactive").closest("form:not(.autosaveon)").autosave({url:"' . $GLOBALS['meta']['adresse_site'] . '/"}).addClass("autosaveon");
87
+		  $("input.autosaveactive").closest("form:not(.autosaveon)").autosave({url:"' . $GLOBALS['meta']['adresse_site'].'/"}).addClass("autosaveon");
88 88
 			});/*]]>*/</script>';
89 89
 	}
90 90
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	// on elimine les donnees de la session
107 107
 	if ($cle_autosave = _request('autosave')) {
108 108
 		include_spip('inc/session');
109
-		session_set('session_autosave_' . $cle_autosave, null);
109
+		session_set('session_autosave_'.$cle_autosave, null);
110 110
 	}
111 111
 
112 112
 	if (isset($GLOBALS['visiteur_session']) && $GLOBALS['visiteur_session']) {
Please login to merge, or discard this patch.
ecrire/inc/filtres.php 3 patches
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -615,8 +615,7 @@  discard block
 block discarded – undo
615 615
 			if (!$srcSize) {
616 616
 				$poids_img[$src] = filesize($src);
617 617
 			}
618
-		}
619
-		elseif (str_contains($src, '<svg')) {
618
+		} elseif (str_contains($src, '<svg')) {
620 619
 			include_spip('inc/svg');
621 620
 			if ($attrs = svg_lire_attributs($src)) {
622 621
 				[$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs);
@@ -3421,8 +3420,7 @@  discard block
 block discarded – undo
3421 3420
 	}
3422 3421
 	if (!isset($options['chemin_image']) || $options['chemin_image'] == true) {
3423 3422
 		$img_file = chemin_image($img);
3424
-	}
3425
-	else {
3423
+	} else {
3426 3424
 		if (!isset($options['variante_svg_si_possible']) || $options['variante_svg_si_possible'] == true) {
3427 3425
 			$img_file = http_img_variante_svg_si_possible($img_file);
3428 3426
 		}
@@ -3449,11 +3447,9 @@  discard block
 block discarded – undo
3449 3447
 	}
3450 3448
 	if ($alt === false) {
3451 3449
 		$alt = '';
3452
-	}
3453
-	elseif ($alt || $alt === '') {
3450
+	} elseif ($alt || $alt === '') {
3454 3451
 		$alt = " alt='" . attribut_html($alt) . "'";
3455
-	}
3456
-	else {
3452
+	} else {
3457 3453
 		$alt = " alt='" . attribut_html($title) . "'";
3458 3454
 	}
3459 3455
 	return "<img src='" . attribut_html($img_file) . "'$alt"
@@ -3580,8 +3576,7 @@  discard block
 block discarded – undo
3580 3576
 		if (!is_null($class)) {
3581 3577
 			$img = strlen((string) $class) ? inserer_attribut($img, 'class', $class) : vider_attribut($img, 'class');
3582 3578
 		}
3583
-	}
3584
-	else {
3579
+	} else {
3585 3580
 		$img = http_img_pack(
3586 3581
 			$img,
3587 3582
 			$alt,
@@ -3689,8 +3684,7 @@  discard block
 block discarded – undo
3689 3684
 		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3690 3685
 		$title = "<title id=\"$id\">" . entites_html($alt) . "</title>\n";
3691 3686
 		$balise_svg .= $title;
3692
-	}
3693
-	else {
3687
+	} else {
3694 3688
 		$balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3695 3689
 	}
3696 3690
 
@@ -5081,8 +5075,7 @@  discard block
 block discarded – undo
5081 5075
 	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
5082 5076
 	if (isset($options['hash_on_content']) && $options['hash_on_content']) {
5083 5077
 		$hash = md5((string) ($contexte_implicite['host'] . '::' . $cache));
5084
-	}
5085
-	else {
5078
+	} else {
5086 5079
 		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
5087 5080
 		ksort($contexte);
5088 5081
 		$hash = md5($fond . json_encode($contexte_implicite, JSON_THROW_ON_ERROR) . json_encode($contexte, JSON_THROW_ON_ERROR) . $connect);
Please login to merge, or discard this patch.
Indentation   +2345 added lines, -2345 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
  * @package SPIP\Core\Filtres
16 16
  **/
17 17
 if (!defined('_ECRIRE_INC_VERSION')) {
18
-	return;
18
+    return;
19 19
 }
20 20
 
21 21
 include_spip('inc/charsets');
@@ -41,8 +41,8 @@  discard block
 block discarded – undo
41 41
  * @return string Fonction PHP correspondante du filtre
42 42
  */
43 43
 function charger_filtre($fonc, $default = 'filtre_identite_dist') {
44
-	include_fichiers_fonctions(); // inclure les fichiers fonctions
45
-	return chercher_filtre($fonc, $default);
44
+    include_fichiers_fonctions(); // inclure les fichiers fonctions
45
+    return chercher_filtre($fonc, $default);
46 46
 }
47 47
 
48 48
 /**
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
  * @return string texte
53 53
  **/
54 54
 function filtre_identite_dist($texte) {
55
- return $texte;
55
+    return $texte;
56 56
 }
57 57
 
58 58
 /**
@@ -76,33 +76,33 @@  discard block
 block discarded – undo
76 76
  *     Fonction PHP correspondante du filtre demandé
77 77
  */
78 78
 function chercher_filtre($fonc, $default = null) {
79
-	if (!$fonc) {
80
-		return $default;
81
-	}
82
-	// Cas des types mime, sans confondre avec les appels de fonction de classe
83
-	// Foo::Bar
84
-	// qui peuvent etre avec un namespace : space\Foo::Bar
85
-	if (preg_match(',^[\w]+/,', $fonc)) {
86
-		$nom = preg_replace(',\W,', '_', $fonc);
87
-		$f = chercher_filtre($nom);
88
-		// cas du sous-type MIME sans filtre associe, passer au type:
89
-		// si filtre_text_plain pas defini, passe a filtre_text
90
-		if (!$f && $nom !== $fonc) {
91
-			$f = chercher_filtre(preg_replace(',\W.*$,', '', $fonc));
92
-		}
93
-
94
-		return $f;
95
-	}
96
-
97
-	include_fichiers_fonctions();
98
-	foreach (['filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc] as $f) {
99
-		trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels
100
-		if (is_callable($f)) {
101
-			return $f;
102
-		}
103
-	}
104
-
105
-	return $default;
79
+    if (!$fonc) {
80
+        return $default;
81
+    }
82
+    // Cas des types mime, sans confondre avec les appels de fonction de classe
83
+    // Foo::Bar
84
+    // qui peuvent etre avec un namespace : space\Foo::Bar
85
+    if (preg_match(',^[\w]+/,', $fonc)) {
86
+        $nom = preg_replace(',\W,', '_', $fonc);
87
+        $f = chercher_filtre($nom);
88
+        // cas du sous-type MIME sans filtre associe, passer au type:
89
+        // si filtre_text_plain pas defini, passe a filtre_text
90
+        if (!$f && $nom !== $fonc) {
91
+            $f = chercher_filtre(preg_replace(',\W.*$,', '', $fonc));
92
+        }
93
+
94
+        return $f;
95
+    }
96
+
97
+    include_fichiers_fonctions();
98
+    foreach (['filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc] as $f) {
99
+        trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels
100
+        if (is_callable($f)) {
101
+            return $f;
102
+        }
103
+    }
104
+
105
+    return $default;
106 106
 }
107 107
 
108 108
 /**
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
  *     Chaîne vide sinon.
147 147
  **/
148 148
 function appliquer_filtre(mixed $arg, $filtre) {
149
-	$args = func_get_args();
150
-	return appliquer_filtre_sinon($arg, $filtre, $args, '');
149
+    $args = func_get_args();
150
+    return appliquer_filtre_sinon($arg, $filtre, $args, '');
151 151
 }
152 152
 
153 153
 /**
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
  *     texte d'origine sinon
173 173
  **/
174 174
 function appliquer_si_filtre(mixed $arg, $filtre) {
175
-	$args = func_get_args();
176
-	return appliquer_filtre_sinon($arg, $filtre, $args, $arg);
175
+    $args = func_get_args();
176
+    return appliquer_filtre_sinon($arg, $filtre, $args, $arg);
177 177
 }
178 178
 
179 179
 /**
@@ -189,12 +189,12 @@  discard block
 block discarded – undo
189 189
  *     Version de SPIP
190 190
  **/
191 191
 function spip_version() {
192
-	$version = $GLOBALS['spip_version_affichee'];
193
-	if ($vcs_version = version_vcs_courante(_DIR_RACINE)) {
194
-		$version .= " $vcs_version";
195
-	}
192
+    $version = $GLOBALS['spip_version_affichee'];
193
+    if ($vcs_version = version_vcs_courante(_DIR_RACINE)) {
194
+        $version .= " $vcs_version";
195
+    }
196 196
 
197
-	return $version;
197
+    return $version;
198 198
 }
199 199
 
200 200
 /**
@@ -206,11 +206,11 @@  discard block
 block discarded – undo
206 206
  * @return string
207 207
  */
208 208
 function header_silencieux($version): string {
209
-	if (isset($GLOBALS['spip_header_silencieux']) && (bool) $GLOBALS['spip_header_silencieux']) {
210
-		$version = '';
211
-	}
209
+    if (isset($GLOBALS['spip_header_silencieux']) && (bool) $GLOBALS['spip_header_silencieux']) {
210
+        $version = '';
211
+    }
212 212
 
213
-	return (string) $version;
213
+    return (string) $version;
214 214
 }
215 215
 
216 216
 /**
@@ -223,16 +223,16 @@  discard block
 block discarded – undo
223 223
  *    - string|null si $raw = false
224 224
  */
225 225
 function version_vcs_courante($dir, $raw = false) {
226
-	$desc = decrire_version_git($dir);
227
-	if ($desc === null || $raw) {
228
-		return $desc;
229
-	}
230
-	// affichage "GIT [master: abcdef]"
231
-	$commit = $desc['commit_short'] ?? $desc['commit'];
232
-	if ($desc['branch']) {
233
-		$commit = $desc['branch'] . ': ' . $commit;
234
-	}
235
-	return "{$desc['vcs']} [$commit]";
226
+    $desc = decrire_version_git($dir);
227
+    if ($desc === null || $raw) {
228
+        return $desc;
229
+    }
230
+    // affichage "GIT [master: abcdef]"
231
+    $commit = $desc['commit_short'] ?? $desc['commit'];
232
+    if ($desc['branch']) {
233
+        $commit = $desc['branch'] . ': ' . $commit;
234
+    }
235
+    return "{$desc['vcs']} [$commit]";
236 236
 }
237 237
 
238 238
 /**
@@ -244,26 +244,26 @@  discard block
 block discarded – undo
244 244
  *      array ['branch' => xx, 'commit' => yy] sinon.
245 245
  **/
246 246
 function decrire_version_git($dir) {
247
-	$c = null;
248
-	$hash = null;
249
-	if (!$dir) {
250
-		$dir = '.';
251
-	}
252
-
253
-	// version installee par GIT
254
-	if (lire_fichier($dir . '/.git/HEAD', $c)) {
255
-		$currentHead = trim(substr((string) $c, 4));
256
-		if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
257
-			return [
258
-				'vcs' => 'GIT',
259
-				'branch' => basename($currentHead),
260
-				'commit' => trim((string) $hash),
261
-				'commit_short' => substr(trim((string) $hash), 0, 8),
262
-			];
263
-		}
264
-	}
265
-
266
-	return null;
247
+    $c = null;
248
+    $hash = null;
249
+    if (!$dir) {
250
+        $dir = '.';
251
+    }
252
+
253
+    // version installee par GIT
254
+    if (lire_fichier($dir . '/.git/HEAD', $c)) {
255
+        $currentHead = trim(substr((string) $c, 4));
256
+        if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
257
+            return [
258
+                'vcs' => 'GIT',
259
+                'branch' => basename($currentHead),
260
+                'commit' => trim((string) $hash),
261
+                'commit_short' => substr(trim((string) $hash), 0, 8),
262
+            ];
263
+        }
264
+    }
265
+
266
+    return null;
267 267
 }
268 268
 
269 269
 // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images
@@ -310,18 +310,18 @@  discard block
 block discarded – undo
310 310
  *     Code HTML retourné par le filtre
311 311
  **/
312 312
 function filtrer($filtre) {
313
-	$tous = func_get_args();
314
-	if (trouver_filtre_matrice($filtre) && str_starts_with($filtre, 'image_')) {
315
-		return image_filtrer($tous);
316
-	} elseif ($f = chercher_filtre($filtre)) {
317
-		array_shift($tous);
318
-		return $f(...$tous);
319
-	} else {
320
-		// le filtre n'existe pas, on provoque une erreur
321
-		$msg = ['zbug_erreur_filtre', ['filtre' => texte_script($filtre)]];
322
-		erreur_squelette($msg);
323
-		return '';
324
-	}
313
+    $tous = func_get_args();
314
+    if (trouver_filtre_matrice($filtre) && str_starts_with($filtre, 'image_')) {
315
+        return image_filtrer($tous);
316
+    } elseif ($f = chercher_filtre($filtre)) {
317
+        array_shift($tous);
318
+        return $f(...$tous);
319
+    } else {
320
+        // le filtre n'existe pas, on provoque une erreur
321
+        $msg = ['zbug_erreur_filtre', ['filtre' => texte_script($filtre)]];
322
+        erreur_squelette($msg);
323
+        return '';
324
+    }
325 325
 }
326 326
 
327 327
 /**
@@ -338,11 +338,11 @@  discard block
 block discarded – undo
338 338
  * @return bool true si on trouve le filtre dans la matrice, false sinon.
339 339
  */
340 340
 function trouver_filtre_matrice($filtre) {
341
-	if (isset($GLOBALS['spip_matrice'][$filtre]) && is_string($f = $GLOBALS['spip_matrice'][$filtre])) {
342
-		find_in_path($f, '', true);
343
-		$GLOBALS['spip_matrice'][$filtre] = true;
344
-	}
345
-	return !empty($GLOBALS['spip_matrice'][$filtre]);
341
+    if (isset($GLOBALS['spip_matrice'][$filtre]) && is_string($f = $GLOBALS['spip_matrice'][$filtre])) {
342
+        find_in_path($f, '', true);
343
+        $GLOBALS['spip_matrice'][$filtre] = true;
344
+    }
345
+    return !empty($GLOBALS['spip_matrice'][$filtre]);
346 346
 }
347 347
 
348 348
 
@@ -370,8 +370,8 @@  discard block
 block discarded – undo
370 370
  * @return mixed
371 371
  */
372 372
 function filtre_set(&$Pile, mixed $val, $key, $continue = null) {
373
-	$Pile['vars'][$key] = $val;
374
-	return $continue ? $val : '';
373
+    $Pile['vars'][$key] = $val;
374
+    return $continue ? $val : '';
375 375
 }
376 376
 
377 377
 /**
@@ -397,8 +397,8 @@  discard block
 block discarded – undo
397 397
  * @return string|mixed Retourne `$val` si `$continue` présent, sinon ''.
398 398
  */
399 399
 function filtre_setenv(&$Pile, mixed $val, mixed $key, $continue = null) {
400
-	$Pile[0][$key] = $val;
401
-	return $continue ? $val : '';
400
+    $Pile[0][$key] = $val;
401
+    return $continue ? $val : '';
402 402
 }
403 403
 
404 404
 /**
@@ -407,8 +407,8 @@  discard block
 block discarded – undo
407 407
  * @return string
408 408
  */
409 409
 function filtre_sanitize_env(&$Pile, $keys) {
410
-	$Pile[0] = spip_sanitize_from_request($Pile[0], $keys);
411
-	return '';
410
+    $Pile[0] = spip_sanitize_from_request($Pile[0], $keys);
411
+    return '';
412 412
 }
413 413
 
414 414
 
@@ -431,18 +431,18 @@  discard block
 block discarded – undo
431 431
  * @return mixed Retourne la valeur (sans la modifier).
432 432
  */
433 433
 function filtre_debug(mixed $val, $key = null) {
434
-	$debug = (
435
-		is_null($key) ? '' : (var_export($key, true) . ' = ')
436
-		) . var_export($val, true);
434
+    $debug = (
435
+        is_null($key) ? '' : (var_export($key, true) . ' = ')
436
+        ) . var_export($val, true);
437 437
 
438
-	include_spip('inc/autoriser');
439
-	if (autoriser('webmestre')) {
440
-		echo "<div class='spip_debug'>\n", $debug, "</div>\n";
441
-	}
438
+    include_spip('inc/autoriser');
439
+    if (autoriser('webmestre')) {
440
+        echo "<div class='spip_debug'>\n", $debug, "</div>\n";
441
+    }
442 442
 
443
-	spip_log($debug, 'debug');
443
+    spip_log($debug, 'debug');
444 444
 
445
-	return $val;
445
+    return $val;
446 446
 }
447 447
 
448 448
 
@@ -472,81 +472,81 @@  discard block
 block discarded – undo
472 472
  *     texte qui a reçu les filtres
473 473
  **/
474 474
 function image_filtrer($args) {
475
-	$filtre = array_shift($args); # enlever $filtre
476
-	$texte = array_shift($args);
477
-	if ($texte === null || !strlen((string) $texte)) {
478
-		return '';
479
-	}
480
-	find_in_path('filtres_images_mini.php', 'inc/', true);
481
-	statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver
482
-	// Cas du nom de fichier local
483
-	$is_file = trim((string) $texte);
484
-	if (
485
-		str_contains(substr($is_file, strlen(_DIR_RACINE)), '..')
486
-		|| strpbrk($is_file, "<>\n\r\t") !== false
487
-		|| str_starts_with($is_file, '/')
488
-	) {
489
-		$is_file = false;
490
-	}
491
-	if ($is_file) {
492
-		$is_local_file = function ($path) {
493
-			if (str_contains($path, '?')) {
494
-				$path = supprimer_timestamp($path);
495
-				// remove ?24px added by find_in_theme on .svg files
496
-				$path = preg_replace(',\?[[:digit:]]+(px)$,', '', $path);
497
-			}
498
-			return file_exists($path);
499
-		};
500
-		if ($is_local_file($is_file) || tester_url_absolue($is_file)) {
501
-			$res = $filtre("<img src='$is_file' />", ...$args);
502
-			statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
503
-			return $res;
504
-		}
505
-	}
506
-
507
-	// Cas general : trier toutes les images, avec eventuellement leur <span>
508
-	if (
509
-		preg_match_all(
510
-			',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS',
511
-			(string) $texte,
512
-			$tags,
513
-			PREG_SET_ORDER
514
-		)
515
-	) {
516
-		foreach ($tags as $tag) {
517
-			$class = extraire_attribut($tag[3], 'class');
518
-			if (
519
-				(!$class || !str_contains($class, 'filtre_inactif')
520
-				&& !str_contains($class, 'no_image_filtrer')) && ($reduit = $filtre($tag[3], ...$args))
521
-			) {
522
-				// En cas de span spip_documents, modifier le style=...width:
523
-				if ($tag[1]) {
524
-					$w = extraire_attribut($reduit, 'width');
525
-					if (!$w && preg_match(',width:\s*(\d+)px,S', extraire_attribut($reduit, 'style'), $regs)) {
526
-						$w = $regs[1];
527
-					}
528
-					if ($w && ($style = extraire_attribut($tag[1], 'style'))) {
529
-						$style = preg_replace(',width:\s*\d+px,S', "width:{$w}px", $style);
530
-						$replace = inserer_attribut($tag[1], 'style', $style);
531
-						$texte = str_replace($tag[1], $replace, (string) $texte);
532
-					}
533
-				}
534
-				// traiter aussi un eventuel mouseover
535
-				if (
536
-					($mouseover = extraire_attribut($reduit, 'onmouseover'))
537
-					&& preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)
538
-				) {
539
-					$srcover = $match[1];
540
-					$srcover_filter = $filtre("<img src='" . $match[1] . "' />", ...$args);
541
-					$srcover_filter = extraire_attribut($srcover_filter, 'src');
542
-					$reduit = str_replace($srcover, $srcover_filter, (string) $reduit);
543
-				}
544
-				$texte = str_replace($tag[3], $reduit, (string) $texte);
545
-			}
546
-		}
547
-	}
548
-	statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
549
-	return $texte;
475
+    $filtre = array_shift($args); # enlever $filtre
476
+    $texte = array_shift($args);
477
+    if ($texte === null || !strlen((string) $texte)) {
478
+        return '';
479
+    }
480
+    find_in_path('filtres_images_mini.php', 'inc/', true);
481
+    statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver
482
+    // Cas du nom de fichier local
483
+    $is_file = trim((string) $texte);
484
+    if (
485
+        str_contains(substr($is_file, strlen(_DIR_RACINE)), '..')
486
+        || strpbrk($is_file, "<>\n\r\t") !== false
487
+        || str_starts_with($is_file, '/')
488
+    ) {
489
+        $is_file = false;
490
+    }
491
+    if ($is_file) {
492
+        $is_local_file = function ($path) {
493
+            if (str_contains($path, '?')) {
494
+                $path = supprimer_timestamp($path);
495
+                // remove ?24px added by find_in_theme on .svg files
496
+                $path = preg_replace(',\?[[:digit:]]+(px)$,', '', $path);
497
+            }
498
+            return file_exists($path);
499
+        };
500
+        if ($is_local_file($is_file) || tester_url_absolue($is_file)) {
501
+            $res = $filtre("<img src='$is_file' />", ...$args);
502
+            statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
503
+            return $res;
504
+        }
505
+    }
506
+
507
+    // Cas general : trier toutes les images, avec eventuellement leur <span>
508
+    if (
509
+        preg_match_all(
510
+            ',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS',
511
+            (string) $texte,
512
+            $tags,
513
+            PREG_SET_ORDER
514
+        )
515
+    ) {
516
+        foreach ($tags as $tag) {
517
+            $class = extraire_attribut($tag[3], 'class');
518
+            if (
519
+                (!$class || !str_contains($class, 'filtre_inactif')
520
+                && !str_contains($class, 'no_image_filtrer')) && ($reduit = $filtre($tag[3], ...$args))
521
+            ) {
522
+                // En cas de span spip_documents, modifier le style=...width:
523
+                if ($tag[1]) {
524
+                    $w = extraire_attribut($reduit, 'width');
525
+                    if (!$w && preg_match(',width:\s*(\d+)px,S', extraire_attribut($reduit, 'style'), $regs)) {
526
+                        $w = $regs[1];
527
+                    }
528
+                    if ($w && ($style = extraire_attribut($tag[1], 'style'))) {
529
+                        $style = preg_replace(',width:\s*\d+px,S', "width:{$w}px", $style);
530
+                        $replace = inserer_attribut($tag[1], 'style', $style);
531
+                        $texte = str_replace($tag[1], $replace, (string) $texte);
532
+                    }
533
+                }
534
+                // traiter aussi un eventuel mouseover
535
+                if (
536
+                    ($mouseover = extraire_attribut($reduit, 'onmouseover'))
537
+                    && preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)
538
+                ) {
539
+                    $srcover = $match[1];
540
+                    $srcover_filter = $filtre("<img src='" . $match[1] . "' />", ...$args);
541
+                    $srcover_filter = extraire_attribut($srcover_filter, 'src');
542
+                    $reduit = str_replace($srcover, $srcover_filter, (string) $reduit);
543
+                }
544
+                $texte = str_replace($tag[3], $reduit, (string) $texte);
545
+            }
546
+        }
547
+    }
548
+    statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
549
+    return $texte;
550 550
 }
551 551
 
552 552
 /**
@@ -563,94 +563,94 @@  discard block
 block discarded – undo
563 563
  **/
564 564
 function infos_image($img, $force_refresh = false) {
565 565
 
566
-	static $largeur_img = [], $hauteur_img = [], $poids_img = [];
567
-	$srcWidth = 0;
568
-	$srcHeight = 0;
569
-	$srcSize = null;
570
-	$valeurs = null;
571
-
572
-	$src = extraire_attribut($img, 'src');
573
-
574
-	if (!$src) {
575
-		$src = $img;
576
-	} else {
577
-		$srcWidth = extraire_attribut($img, 'width');
578
-		$srcHeight = extraire_attribut($img, 'height');
579
-		if (!ctype_digit((string) $srcWidth) || !ctype_digit((string) $srcHeight)) {
580
-			$srcWidth = $srcHeight = 0;
581
-		}
582
-	}
583
-
584
-	// ne jamais operer directement sur une image distante pour des raisons de perfo
585
-	// la copie locale a toutes les chances d'etre la ou de resservir
586
-	if (tester_url_absolue($src)) {
587
-		include_spip('inc/distant');
588
-		$fichier = copie_locale($src);
589
-		$src = $fichier ? _DIR_RACINE . $fichier : $src;
590
-	}
591
-	if (($p = strpos($src, '?')) !== false) {
592
-		$src = substr($src, 0, $p);
593
-	}
594
-
595
-	$imagesize = false;
596
-	if (isset($largeur_img[$src]) && !$force_refresh) {
597
-		$srcWidth = $largeur_img[$src];
598
-	}
599
-	if (isset($hauteur_img[$src]) && !$force_refresh) {
600
-		$srcHeight = $hauteur_img[$src];
601
-	}
602
-	if (isset($poids_img[$src]) && !$force_refresh) {
603
-		$srcSize = $poids_img[$src];
604
-	}
605
-	if (!$srcWidth || !$srcHeight || is_null($srcSize)) {
606
-		if (
607
-			file_exists($src) && ($imagesize = spip_getimagesize($src))
608
-		) {
609
-			if (!$srcWidth) {
610
-				$largeur_img[$src] = $srcWidth = $imagesize[0];
611
-			}
612
-			if (!$srcHeight) {
613
-				$hauteur_img[$src] = $srcHeight = $imagesize[1];
614
-			}
615
-			if (!$srcSize) {
616
-				$poids_img[$src] = filesize($src);
617
-			}
618
-		}
619
-		elseif (str_contains($src, '<svg')) {
620
-			include_spip('inc/svg');
621
-			if ($attrs = svg_lire_attributs($src)) {
622
-				[$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs);
623
-				if (!$srcWidth) {
624
-					$largeur_img[$src] = $srcWidth = $width;
625
-				}
626
-				if (!$srcHeight) {
627
-					$hauteur_img[$src] = $srcHeight = $height;
628
-				}
629
-				if (!$srcSize) {
630
-					$poids_img[$src] = $srcSize = strlen($src);
631
-				}
632
-			}
633
-		}
634
-		// $src peut etre une reference a une image temporaire dont a n'a que le log .src
635
-		// on s'y refere, l'image sera reconstruite en temps utile si necessaire
636
-		elseif (
637
-			@file_exists($f = "$src.src")
638
-			&& lire_fichier($f, $valeurs)
639
-			&& ($valeurs = unserialize($valeurs))
640
-		) {
641
-			if (!$srcWidth) {
642
-				$largeur_img[$src] = $srcWidth = $valeurs['largeur_dest'];
643
-			}
644
-			if (!$srcHeight) {
645
-				$hauteur_img[$src] = $srcHeight = $valeurs['hauteur_dest'];
646
-			}
647
-			if (!$srcSize) {
648
-				$poids_img[$src] = $srcSize = 0;
649
-			}
650
-		}
651
-	}
652
-
653
-	return ['hauteur' => $srcHeight, 'largeur' => $srcWidth, 'poids' => $srcSize];
566
+    static $largeur_img = [], $hauteur_img = [], $poids_img = [];
567
+    $srcWidth = 0;
568
+    $srcHeight = 0;
569
+    $srcSize = null;
570
+    $valeurs = null;
571
+
572
+    $src = extraire_attribut($img, 'src');
573
+
574
+    if (!$src) {
575
+        $src = $img;
576
+    } else {
577
+        $srcWidth = extraire_attribut($img, 'width');
578
+        $srcHeight = extraire_attribut($img, 'height');
579
+        if (!ctype_digit((string) $srcWidth) || !ctype_digit((string) $srcHeight)) {
580
+            $srcWidth = $srcHeight = 0;
581
+        }
582
+    }
583
+
584
+    // ne jamais operer directement sur une image distante pour des raisons de perfo
585
+    // la copie locale a toutes les chances d'etre la ou de resservir
586
+    if (tester_url_absolue($src)) {
587
+        include_spip('inc/distant');
588
+        $fichier = copie_locale($src);
589
+        $src = $fichier ? _DIR_RACINE . $fichier : $src;
590
+    }
591
+    if (($p = strpos($src, '?')) !== false) {
592
+        $src = substr($src, 0, $p);
593
+    }
594
+
595
+    $imagesize = false;
596
+    if (isset($largeur_img[$src]) && !$force_refresh) {
597
+        $srcWidth = $largeur_img[$src];
598
+    }
599
+    if (isset($hauteur_img[$src]) && !$force_refresh) {
600
+        $srcHeight = $hauteur_img[$src];
601
+    }
602
+    if (isset($poids_img[$src]) && !$force_refresh) {
603
+        $srcSize = $poids_img[$src];
604
+    }
605
+    if (!$srcWidth || !$srcHeight || is_null($srcSize)) {
606
+        if (
607
+            file_exists($src) && ($imagesize = spip_getimagesize($src))
608
+        ) {
609
+            if (!$srcWidth) {
610
+                $largeur_img[$src] = $srcWidth = $imagesize[0];
611
+            }
612
+            if (!$srcHeight) {
613
+                $hauteur_img[$src] = $srcHeight = $imagesize[1];
614
+            }
615
+            if (!$srcSize) {
616
+                $poids_img[$src] = filesize($src);
617
+            }
618
+        }
619
+        elseif (str_contains($src, '<svg')) {
620
+            include_spip('inc/svg');
621
+            if ($attrs = svg_lire_attributs($src)) {
622
+                [$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs);
623
+                if (!$srcWidth) {
624
+                    $largeur_img[$src] = $srcWidth = $width;
625
+                }
626
+                if (!$srcHeight) {
627
+                    $hauteur_img[$src] = $srcHeight = $height;
628
+                }
629
+                if (!$srcSize) {
630
+                    $poids_img[$src] = $srcSize = strlen($src);
631
+                }
632
+            }
633
+        }
634
+        // $src peut etre une reference a une image temporaire dont a n'a que le log .src
635
+        // on s'y refere, l'image sera reconstruite en temps utile si necessaire
636
+        elseif (
637
+            @file_exists($f = "$src.src")
638
+            && lire_fichier($f, $valeurs)
639
+            && ($valeurs = unserialize($valeurs))
640
+        ) {
641
+            if (!$srcWidth) {
642
+                $largeur_img[$src] = $srcWidth = $valeurs['largeur_dest'];
643
+            }
644
+            if (!$srcHeight) {
645
+                $hauteur_img[$src] = $srcHeight = $valeurs['hauteur_dest'];
646
+            }
647
+            if (!$srcSize) {
648
+                $poids_img[$src] = $srcSize = 0;
649
+            }
650
+        }
651
+    }
652
+
653
+    return ['hauteur' => $srcHeight, 'largeur' => $srcWidth, 'poids' => $srcSize];
654 654
 }
655 655
 
656 656
 /**
@@ -666,13 +666,13 @@  discard block
 block discarded – undo
666 666
  *     poids
667 667
  **/
668 668
 function poids_image($img, $force_refresh = false) {
669
-	$infos = infos_image($img, $force_refresh);
670
-	return $infos['poids'];
669
+    $infos = infos_image($img, $force_refresh);
670
+    return $infos['poids'];
671 671
 }
672 672
 
673 673
 function taille_image($img, $force_refresh = false) {
674
-	$infos = infos_image($img, $force_refresh);
675
-	return [$infos['hauteur'], $infos['largeur']];
674
+    $infos = infos_image($img, $force_refresh);
675
+    return [$infos['hauteur'], $infos['largeur']];
676 676
 }
677 677
 
678 678
 /**
@@ -689,12 +689,12 @@  discard block
 block discarded – undo
689 689
  *     Largeur en pixels, NULL ou 0 si aucune image.
690 690
  **/
691 691
 function largeur($img) {
692
-	if (!$img) {
693
-		return;
694
-	}
695
-	[$h, $l] = taille_image($img);
692
+    if (!$img) {
693
+        return;
694
+    }
695
+    [$h, $l] = taille_image($img);
696 696
 
697
-	return $l;
697
+    return $l;
698 698
 }
699 699
 
700 700
 /**
@@ -711,12 +711,12 @@  discard block
 block discarded – undo
711 711
  *     Hauteur en pixels, NULL ou 0 si aucune image.
712 712
  **/
713 713
 function hauteur($img) {
714
-	if (!$img) {
715
-		return;
716
-	}
717
-	[$h, $l] = taille_image($img);
714
+    if (!$img) {
715
+        return;
716
+    }
717
+    [$h, $l] = taille_image($img);
718 718
 
719
-	return $h;
719
+    return $h;
720 720
 }
721 721
 
722 722
 
@@ -736,11 +736,11 @@  discard block
 block discarded – undo
736 736
  * @return string
737 737
  **/
738 738
 function corriger_entites_html($texte) {
739
-	if (!str_contains($texte, '&amp;')) {
740
-		return $texte;
741
-	}
739
+    if (!str_contains($texte, '&amp;')) {
740
+        return $texte;
741
+    }
742 742
 
743
-	return preg_replace(',&amp;(#\d\d\d+;|amp;),iS', '&\1', $texte);
743
+    return preg_replace(',&amp;(#\d\d\d+;|amp;),iS', '&\1', $texte);
744 744
 }
745 745
 
746 746
 /**
@@ -755,11 +755,11 @@  discard block
 block discarded – undo
755 755
  * @return string
756 756
  **/
757 757
 function corriger_toutes_entites_html($texte) {
758
-	if (!str_contains($texte, '&amp;')) {
759
-		return $texte;
760
-	}
758
+    if (!str_contains($texte, '&amp;')) {
759
+        return $texte;
760
+    }
761 761
 
762
-	return preg_replace(',&amp;(#?[a-z0-9]+;),iS', '&\1', $texte);
762
+    return preg_replace(',&amp;(#?[a-z0-9]+;),iS', '&\1', $texte);
763 763
 }
764 764
 
765 765
 /**
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
  * @return string
770 770
  **/
771 771
 function proteger_amp($texte) {
772
-	return str_replace('&', '&amp;', $texte);
772
+    return str_replace('&', '&amp;', $texte);
773 773
 }
774 774
 
775 775
 
@@ -800,18 +800,18 @@  discard block
 block discarded – undo
800 800
  * @return mixed|string
801 801
  */
802 802
 function entites_html($texte, $tout = false, $quote = true) {
803
-	if (!is_string($texte) || !$texte || strpbrk($texte, "&\"'<>") == false) {
804
-		return $texte;
805
-	}
806
-	include_spip('inc/texte');
807
-	$flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES);
808
-	$flags |= ENT_HTML401;
809
-	$texte = spip_htmlspecialchars(echappe_retour(echappe_html($texte, '', true), '', 'proteger_amp'), $flags);
810
-	if ($tout) {
811
-		return corriger_toutes_entites_html($texte);
812
-	} else {
813
-		return corriger_entites_html($texte);
814
-	}
803
+    if (!is_string($texte) || !$texte || strpbrk($texte, "&\"'<>") == false) {
804
+        return $texte;
805
+    }
806
+    include_spip('inc/texte');
807
+    $flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES);
808
+    $flags |= ENT_HTML401;
809
+    $texte = spip_htmlspecialchars(echappe_retour(echappe_html($texte, '', true), '', 'proteger_amp'), $flags);
810
+    if ($tout) {
811
+        return corriger_toutes_entites_html($texte);
812
+    } else {
813
+        return corriger_entites_html($texte);
814
+    }
815 815
 }
816 816
 
817 817
 /**
@@ -830,38 +830,38 @@  discard block
 block discarded – undo
830 830
  *     texte converti
831 831
  **/
832 832
 function filtrer_entites(?string $texte): string {
833
-	$texte ??= '';
834
-	if (!str_contains($texte, '&')) {
835
-		return $texte;
836
-	}
837
-	// filtrer
838
-	$texte = html2unicode($texte);
839
-	// remettre le tout dans le charset cible
840
-	$texte = unicode2charset($texte);
841
-	// cas particulier des " et ' qu'il faut filtrer aussi
842
-	// (on le faisait deja avec un &quot;)
843
-	if (str_contains($texte, '&#')) {
844
-		$texte = str_replace(['&#039;', '&#39;', '&#034;', '&#34;'], ["'", "'", '"', '"'], $texte);
845
-	}
833
+    $texte ??= '';
834
+    if (!str_contains($texte, '&')) {
835
+        return $texte;
836
+    }
837
+    // filtrer
838
+    $texte = html2unicode($texte);
839
+    // remettre le tout dans le charset cible
840
+    $texte = unicode2charset($texte);
841
+    // cas particulier des " et ' qu'il faut filtrer aussi
842
+    // (on le faisait deja avec un &quot;)
843
+    if (str_contains($texte, '&#')) {
844
+        $texte = str_replace(['&#039;', '&#39;', '&#034;', '&#34;'], ["'", "'", '"', '"'], $texte);
845
+    }
846 846
 
847
-	return $texte;
847
+    return $texte;
848 848
 }
849 849
 
850 850
 
851 851
 if (!function_exists('filtre_filtrer_entites_dist')) {
852
-	/**
853
-	 * Version sécurisée de filtrer_entites
854
-	 *
855
-	 * @uses interdire_scripts()
856
-	 * @uses filtrer_entites()
857
-	 *
858
-	 * @param string $t
859
-	 * @return string
860
-	 */
861
-	function filtre_filtrer_entites_dist($t) {
862
-		include_spip('inc/texte');
863
-		return interdire_scripts(filtrer_entites($t));
864
-	}
852
+    /**
853
+     * Version sécurisée de filtrer_entites
854
+     *
855
+     * @uses interdire_scripts()
856
+     * @uses filtrer_entites()
857
+     *
858
+     * @param string $t
859
+     * @return string
860
+     */
861
+    function filtre_filtrer_entites_dist($t) {
862
+        include_spip('inc/texte');
863
+        return interdire_scripts(filtrer_entites($t));
864
+    }
865 865
 }
866 866
 
867 867
 
@@ -876,18 +876,18 @@  discard block
 block discarded – undo
876 876
  * @return string|array
877 877
  **/
878 878
 function supprimer_caracteres_illegaux($texte) {
879
-	static $from = "\x0\x1\x2\x3\x4\x5\x6\x7\x8\xB\xC\xE\xF\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F";
880
-	static $to = null;
879
+    static $from = "\x0\x1\x2\x3\x4\x5\x6\x7\x8\xB\xC\xE\xF\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F";
880
+    static $to = null;
881 881
 
882
-	if (is_array($texte)) {
883
-		return array_map('supprimer_caracteres_illegaux', $texte);
884
-	}
882
+    if (is_array($texte)) {
883
+        return array_map('supprimer_caracteres_illegaux', $texte);
884
+    }
885 885
 
886
-	if (!$to) {
887
-		$to = str_repeat('-', strlen((string) $from));
888
-	}
886
+    if (!$to) {
887
+        $to = str_repeat('-', strlen((string) $from));
888
+    }
889 889
 
890
-	return strtr($texte, $from, $to);
890
+    return strtr($texte, $from, $to);
891 891
 }
892 892
 
893 893
 /**
@@ -899,9 +899,9 @@  discard block
 block discarded – undo
899 899
  * @return string|array
900 900
  **/
901 901
 function corriger_caracteres($texte) {
902
-	$texte = corriger_caracteres_windows($texte);
902
+    $texte = corriger_caracteres_windows($texte);
903 903
 
904
-	return supprimer_caracteres_illegaux($texte);
904
+    return supprimer_caracteres_illegaux($texte);
905 905
 }
906 906
 
907 907
 /**
@@ -918,44 +918,44 @@  discard block
 block discarded – undo
918 918
  *     texte encodé pour XML
919 919
  */
920 920
 function texte_backend(string $texte): string {
921
-	if ($texte === '') {
922
-		return '';
923
-	}
921
+    if ($texte === '') {
922
+        return '';
923
+    }
924 924
 
925
-	static $apostrophe = ['&#8217;', "'"]; # n'allouer qu'une fois
925
+    static $apostrophe = ['&#8217;', "'"]; # n'allouer qu'une fois
926 926
 
927
-	// si on a des liens ou des images, les passer en absolu
928
-	$texte = liens_absolus($texte);
927
+    // si on a des liens ou des images, les passer en absolu
928
+    $texte = liens_absolus($texte);
929 929
 
930
-	// echapper les tags &gt; &lt;
931
-	$texte = preg_replace(',&(gt|lt);,S', '&amp;\1;', $texte);
930
+    // echapper les tags &gt; &lt;
931
+    $texte = preg_replace(',&(gt|lt);,S', '&amp;\1;', $texte);
932 932
 
933
-	// importer les &eacute;
934
-	$texte = filtrer_entites($texte);
933
+    // importer les &eacute;
934
+    $texte = filtrer_entites($texte);
935 935
 
936
-	// " -> &quot; et tout ce genre de choses
937
-	$u = $GLOBALS['meta']['pcre_u'];
938
-	$texte = str_replace('&nbsp;', ' ', $texte);
939
-	$texte = preg_replace('/\s{2,}/S' . $u, ' ', $texte);
940
-	// ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
941
-	$texte = entites_html($texte, false, false);
942
-	// mais bien echapper les double quotes !
943
-	$texte = str_replace('"', '&#034;', (string) $texte);
936
+    // " -> &quot; et tout ce genre de choses
937
+    $u = $GLOBALS['meta']['pcre_u'];
938
+    $texte = str_replace('&nbsp;', ' ', $texte);
939
+    $texte = preg_replace('/\s{2,}/S' . $u, ' ', $texte);
940
+    // ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
941
+    $texte = entites_html($texte, false, false);
942
+    // mais bien echapper les double quotes !
943
+    $texte = str_replace('"', '&#034;', (string) $texte);
944 944
 
945
-	// verifier le charset
946
-	$texte = charset2unicode($texte);
945
+    // verifier le charset
946
+    $texte = charset2unicode($texte);
947 947
 
948
-	// Caracteres problematiques en iso-latin 1
949
-	if (isset($GLOBALS['meta']['charset']) && $GLOBALS['meta']['charset'] == 'iso-8859-1') {
950
-		$texte = str_replace(chr(156), '&#156;', $texte);
951
-		$texte = str_replace(chr(140), '&#140;', $texte);
952
-		$texte = str_replace(chr(159), '&#159;', $texte);
953
-	}
948
+    // Caracteres problematiques en iso-latin 1
949
+    if (isset($GLOBALS['meta']['charset']) && $GLOBALS['meta']['charset'] == 'iso-8859-1') {
950
+        $texte = str_replace(chr(156), '&#156;', $texte);
951
+        $texte = str_replace(chr(140), '&#140;', $texte);
952
+        $texte = str_replace(chr(159), '&#159;', $texte);
953
+    }
954 954
 
955
-	// l'apostrophe curly pose probleme a certains lecteure de RSS
956
-	// et le caractere apostrophe alourdit les squelettes avec PHP
957
-	// ==> on les remplace par l'entite HTML
958
-	return str_replace($apostrophe, "'", $texte);
955
+    // l'apostrophe curly pose probleme a certains lecteure de RSS
956
+    // et le caractere apostrophe alourdit les squelettes avec PHP
957
+    // ==> on les remplace par l'entite HTML
958
+    return str_replace($apostrophe, "'", $texte);
959 959
 }
960 960
 
961 961
 /**
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
  *     texte encodé et quote pour XML
973 973
  */
974 974
 function texte_backendq(string $texte): string {
975
-	return addslashes(texte_backend($texte));
975
+    return addslashes(texte_backend($texte));
976 976
 }
977 977
 
978 978
 
@@ -994,14 +994,14 @@  discard block
 block discarded – undo
994 994
  *     Texte sans son numéro éventuel
995 995
  **/
996 996
 function supprimer_numero(?string $texte): string {
997
-	if ($texte === null) {
998
-		return '';
999
-	}
1000
-	return preg_replace(
1001
-		',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1002
-		'',
1003
-		$texte
1004
-	);
997
+    if ($texte === null) {
998
+        return '';
999
+    }
1000
+    return preg_replace(
1001
+        ',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1002
+        '',
1003
+        $texte
1004
+    );
1005 1005
 }
1006 1006
 
1007 1007
 /**
@@ -1024,18 +1024,18 @@  discard block
 block discarded – undo
1024 1024
  *     Numéro de titre, sinon chaîne vide
1025 1025
  **/
1026 1026
 function recuperer_numero(?string $texte): string {
1027
-	if (
1028
-		$texte
1029
-		&& preg_match(
1030
-			',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1031
-			$texte,
1032
-			$regs
1033
-		)
1034
-	) {
1035
-		return (string) $regs[1];
1036
-	} else {
1037
-		return '';
1038
-	}
1027
+    if (
1028
+        $texte
1029
+        && preg_match(
1030
+            ',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1031
+            $texte,
1032
+            $regs
1033
+        )
1034
+    ) {
1035
+        return (string) $regs[1];
1036
+    } else {
1037
+        return '';
1038
+    }
1039 1039
 }
1040 1040
 
1041 1041
 /**
@@ -1062,16 +1062,16 @@  discard block
 block discarded – undo
1062 1062
  *     texte ou tableau de textes converti
1063 1063
  **/
1064 1064
 function supprimer_tags($texte, $rempl = '') {
1065
-	if ($texte === null) {
1066
-		return '';
1067
-	}
1068
-	$texte = preg_replace(',<(!--|\w|/|!\[endif|!\[if)[^>]*>,US', $rempl, $texte);
1069
-	// ne pas oublier un < final non ferme car coupe
1070
-	$texte = preg_replace(',<(!--|\w|/).*$,US', $rempl, $texte);
1071
-	// mais qui peut aussi etre un simple signe plus petit que
1072
-	$texte = str_replace('<', '&lt;', $texte);
1065
+    if ($texte === null) {
1066
+        return '';
1067
+    }
1068
+    $texte = preg_replace(',<(!--|\w|/|!\[endif|!\[if)[^>]*>,US', $rempl, $texte);
1069
+    // ne pas oublier un < final non ferme car coupe
1070
+    $texte = preg_replace(',<(!--|\w|/).*$,US', $rempl, $texte);
1071
+    // mais qui peut aussi etre un simple signe plus petit que
1072
+    $texte = str_replace('<', '&lt;', $texte);
1073 1073
 
1074
-	return $texte;
1074
+    return $texte;
1075 1075
 }
1076 1076
 
1077 1077
 /**
@@ -1094,7 +1094,7 @@  discard block
 block discarded – undo
1094 1094
  *     texte converti
1095 1095
  **/
1096 1096
 function echapper_tags($texte, $rempl = '') {
1097
-	return preg_replace('/<([^>]*)>/', "&lt;\\1&gt;", $texte);
1097
+    return preg_replace('/<([^>]*)>/', "&lt;\\1&gt;", $texte);
1098 1098
 }
1099 1099
 
1100 1100
 /**
@@ -1115,18 +1115,18 @@  discard block
 block discarded – undo
1115 1115
  *     texte converti
1116 1116
  **/
1117 1117
 function textebrut($texte) {
1118
-	$u = $GLOBALS['meta']['pcre_u'];
1119
-	$texte = preg_replace('/\s+/S' . $u, ' ', $texte);
1120
-	$texte = preg_replace('/<(p|br)( [^>]*)?>/iS', "\n\n", $texte);
1121
-	$texte = preg_replace("/^\n+/", '', $texte);
1122
-	$texte = preg_replace("/\n+$/", '', $texte);
1123
-	$texte = preg_replace("/\n +/", "\n", $texte);
1124
-	$texte = supprimer_tags($texte);
1125
-	$texte = preg_replace('/(&nbsp;| )+/S', ' ', $texte);
1126
-	// nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail...
1127
-	$texte = str_replace('&#8217;', "'", $texte);
1118
+    $u = $GLOBALS['meta']['pcre_u'];
1119
+    $texte = preg_replace('/\s+/S' . $u, ' ', $texte);
1120
+    $texte = preg_replace('/<(p|br)( [^>]*)?>/iS', "\n\n", $texte);
1121
+    $texte = preg_replace("/^\n+/", '', $texte);
1122
+    $texte = preg_replace("/\n+$/", '', $texte);
1123
+    $texte = preg_replace("/\n +/", "\n", $texte);
1124
+    $texte = supprimer_tags($texte);
1125
+    $texte = preg_replace('/(&nbsp;| )+/S', ' ', $texte);
1126
+    // nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail...
1127
+    $texte = str_replace('&#8217;', "'", $texte);
1128 1128
 
1129
-	return $texte;
1129
+    return $texte;
1130 1130
 }
1131 1131
 
1132 1132
 
@@ -1142,23 +1142,23 @@  discard block
 block discarded – undo
1142 1142
  *     texte avec liens ouvrants
1143 1143
  **/
1144 1144
 function liens_ouvrants($texte) {
1145
-	if (
1146
-		preg_match_all(
1147
-			",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1148
-			$texte,
1149
-			$liens,
1150
-			PREG_PATTERN_ORDER
1151
-		)
1152
-	) {
1153
-		foreach ($liens[0] as $a) {
1154
-			$rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1155
-			$ablank = inserer_attribut($a, 'rel', $rel);
1156
-			$ablank = inserer_attribut($ablank, 'target', '_blank');
1157
-			$texte = str_replace($a, $ablank, $texte);
1158
-		}
1159
-	}
1160
-
1161
-	return $texte;
1145
+    if (
1146
+        preg_match_all(
1147
+            ",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1148
+            $texte,
1149
+            $liens,
1150
+            PREG_PATTERN_ORDER
1151
+        )
1152
+    ) {
1153
+        foreach ($liens[0] as $a) {
1154
+            $rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1155
+            $ablank = inserer_attribut($a, 'rel', $rel);
1156
+            $ablank = inserer_attribut($ablank, 'target', '_blank');
1157
+            $texte = str_replace($a, $ablank, $texte);
1158
+        }
1159
+    }
1160
+
1161
+    return $texte;
1162 1162
 }
1163 1163
 
1164 1164
 /**
@@ -1168,22 +1168,22 @@  discard block
 block discarded – undo
1168 1168
  * @return string
1169 1169
  */
1170 1170
 function liens_nofollow($texte) {
1171
-	if (stripos($texte, '<a') === false) {
1172
-		return $texte;
1173
-	}
1171
+    if (stripos($texte, '<a') === false) {
1172
+        return $texte;
1173
+    }
1174 1174
 
1175
-	if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) {
1176
-		foreach ($regs[0] as $a) {
1177
-			$rel = extraire_attribut($a, 'rel') ?? '';
1178
-			if (!str_contains($rel, 'nofollow')) {
1179
-				$rel = 'nofollow' . ($rel ? " $rel" : '');
1180
-				$anofollow = inserer_attribut($a, 'rel', $rel);
1181
-				$texte = str_replace($a, $anofollow, $texte);
1182
-			}
1183
-		}
1184
-	}
1175
+    if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) {
1176
+        foreach ($regs[0] as $a) {
1177
+            $rel = extraire_attribut($a, 'rel') ?? '';
1178
+            if (!str_contains($rel, 'nofollow')) {
1179
+                $rel = 'nofollow' . ($rel ? " $rel" : '');
1180
+                $anofollow = inserer_attribut($a, 'rel', $rel);
1181
+                $texte = str_replace($a, $anofollow, $texte);
1182
+            }
1183
+        }
1184
+    }
1185 1185
 
1186
-	return $texte;
1186
+    return $texte;
1187 1187
 }
1188 1188
 
1189 1189
 /**
@@ -1202,11 +1202,11 @@  discard block
 block discarded – undo
1202 1202
  *     texte sans paraghaphes
1203 1203
  **/
1204 1204
 function PtoBR($texte) {
1205
-	$u = $GLOBALS['meta']['pcre_u'];
1206
-	$texte = preg_replace('@</p>@iS', "\n", $texte);
1207
-	$texte = preg_replace("@<p\b.*>@UiS", '<br />', $texte);
1205
+    $u = $GLOBALS['meta']['pcre_u'];
1206
+    $texte = preg_replace('@</p>@iS', "\n", $texte);
1207
+    $texte = preg_replace("@<p\b.*>@UiS", '<br />', $texte);
1208 1208
 
1209
-	return preg_replace('@^\s*<br />@S' . $u, '', $texte);
1209
+    return preg_replace('@^\s*<br />@S' . $u, '', $texte);
1210 1210
 }
1211 1211
 
1212 1212
 /**
@@ -1225,30 +1225,30 @@  discard block
 block discarded – undo
1225 1225
  * @return string texte en majuscule
1226 1226
  */
1227 1227
 function majuscules($texte) {
1228
-	if (!strlen($texte)) {
1229
-		return '';
1230
-	}
1228
+    if (!strlen($texte)) {
1229
+        return '';
1230
+    }
1231 1231
 
1232
-	// Cas du turc
1233
-	if ($GLOBALS['spip_lang'] == 'tr') {
1234
-		# remplacer hors des tags et des entites
1235
-		if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) {
1236
-			foreach ($regs as $n => $match) {
1237
-				$texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte);
1238
-			}
1239
-		}
1232
+    // Cas du turc
1233
+    if ($GLOBALS['spip_lang'] == 'tr') {
1234
+        # remplacer hors des tags et des entites
1235
+        if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) {
1236
+            foreach ($regs as $n => $match) {
1237
+                $texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte);
1238
+            }
1239
+        }
1240 1240
 
1241
-		$texte = str_replace('i', '&#304;', $texte);
1241
+        $texte = str_replace('i', '&#304;', $texte);
1242 1242
 
1243
-		if ($regs) {
1244
-			foreach ($regs as $n => $match) {
1245
-				$texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte);
1246
-			}
1247
-		}
1248
-	}
1243
+        if ($regs) {
1244
+            foreach ($regs as $n => $match) {
1245
+                $texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte);
1246
+            }
1247
+        }
1248
+    }
1249 1249
 
1250
-	// Cas general
1251
-	return "<span style='text-transform: uppercase;'>$texte</span>";
1250
+    // Cas general
1251
+    return "<span style='text-transform: uppercase;'>$texte</span>";
1252 1252
 }
1253 1253
 
1254 1254
 /**
@@ -1270,38 +1270,38 @@  discard block
 block discarded – undo
1270 1270
  */
1271 1271
 function taille_en_octets($octets, $systeme = 'BI') {
1272 1272
 
1273
-	// Texte à afficher pour la taille
1274
-	$affichage = '';
1273
+    // Texte à afficher pour la taille
1274
+    $affichage = '';
1275 1275
 
1276
-	static $unites = ['octets', 'ko', 'mo', 'go'];
1277
-	static $precisions = [0, 1, 1, 2];
1276
+    static $unites = ['octets', 'ko', 'mo', 'go'];
1277
+    static $precisions = [0, 1, 1, 2];
1278 1278
 
1279
-	if ($octets >= 1) {
1280
-		// Déterminer le nombre d'octets représentant le kilo en fonction du système choisi
1281
-		$systeme = strtolower($systeme);
1282
-		if ($systeme === 'bi') {
1283
-			$kilo = 1024;
1284
-			$suffixe_item = "_$systeme";
1285
-		} elseif ($systeme === 'si') {
1286
-			$kilo = 1000;
1287
-			$suffixe_item = '';
1288
-		} else {
1289
-			return $affichage;
1290
-		}
1279
+    if ($octets >= 1) {
1280
+        // Déterminer le nombre d'octets représentant le kilo en fonction du système choisi
1281
+        $systeme = strtolower($systeme);
1282
+        if ($systeme === 'bi') {
1283
+            $kilo = 1024;
1284
+            $suffixe_item = "_$systeme";
1285
+        } elseif ($systeme === 'si') {
1286
+            $kilo = 1000;
1287
+            $suffixe_item = '';
1288
+        } else {
1289
+            return $affichage;
1290
+        }
1291 1291
 
1292
-		// Identification de la puissance en "kilo" correspondant à l'unité la plus appropriée
1293
-		$puissance = floor(log($octets, $kilo));
1292
+        // Identification de la puissance en "kilo" correspondant à l'unité la plus appropriée
1293
+        $puissance = floor(log($octets, $kilo));
1294 1294
 
1295
-		// Calcul de la taille et choix de l'unité
1296
-		$affichage = _T(
1297
-			'spip:taille_' . $unites[$puissance] . $suffixe_item,
1298
-			[
1299
-				'taille' => round($octets / $kilo ** $puissance, $precisions[$puissance])
1300
-			]
1301
-		);
1302
-	}
1295
+        // Calcul de la taille et choix de l'unité
1296
+        $affichage = _T(
1297
+            'spip:taille_' . $unites[$puissance] . $suffixe_item,
1298
+            [
1299
+                'taille' => round($octets / $kilo ** $puissance, $precisions[$puissance])
1300
+            ]
1301
+        );
1302
+    }
1303 1303
 
1304
-	return $affichage;
1304
+    return $affichage;
1305 1305
 }
1306 1306
 
1307 1307
 
@@ -1323,21 +1323,21 @@  discard block
 block discarded – undo
1323 1323
  *     texte prêt pour être utilisé en attribut HTML
1324 1324
  **/
1325 1325
 function attribut_html(?string $texte, $textebrut = true): string {
1326
-	if ($texte === null) {
1327
-		return '';
1328
-	}
1329
-	$u = $GLOBALS['meta']['pcre_u'];
1330
-	if ($textebrut) {
1331
-		$texte = preg_replace([",\n,", ',\s(?=\s),msS' . $u], [' ', ''], textebrut($texte));
1332
-	}
1333
-	$texte = texte_backend($texte);
1334
-	$texte = str_replace(["'", '"'], ['&#039;', '&#034;'], $texte);
1326
+    if ($texte === null) {
1327
+        return '';
1328
+    }
1329
+    $u = $GLOBALS['meta']['pcre_u'];
1330
+    if ($textebrut) {
1331
+        $texte = preg_replace([",\n,", ',\s(?=\s),msS' . $u], [' ', ''], textebrut($texte));
1332
+    }
1333
+    $texte = texte_backend($texte);
1334
+    $texte = str_replace(["'", '"'], ['&#039;', '&#034;'], $texte);
1335 1335
 
1336
-	return preg_replace(
1337
-		['/&(amp;|#38;)/', '/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/'],
1338
-		['&', '&#38;'],
1339
-		$texte
1340
-	);
1336
+    return preg_replace(
1337
+        ['/&(amp;|#38;)/', '/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/'],
1338
+        ['&', '&#38;'],
1339
+        $texte
1340
+    );
1341 1341
 }
1342 1342
 
1343 1343
 
@@ -1357,15 +1357,15 @@  discard block
 block discarded – undo
1357 1357
  *     URL ou chaîne vide
1358 1358
  **/
1359 1359
 function vider_url(?string $url, $entites = true): string {
1360
-	if ($url === null) {
1361
-		return '';
1362
-	}
1363
-	# un message pour abs_url
1364
-	$GLOBALS['mode_abs_url'] = 'url';
1365
-	$url = trim($url);
1366
-	$r = ',^(?:' . _PROTOCOLES_STD . '):?/?/?$,iS';
1360
+    if ($url === null) {
1361
+        return '';
1362
+    }
1363
+    # un message pour abs_url
1364
+    $GLOBALS['mode_abs_url'] = 'url';
1365
+    $url = trim($url);
1366
+    $r = ',^(?:' . _PROTOCOLES_STD . '):?/?/?$,iS';
1367 1367
 
1368
-	return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1368
+    return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1369 1369
 }
1370 1370
 
1371 1371
 
@@ -1380,10 +1380,10 @@  discard block
 block discarded – undo
1380 1380
  * @return string Adresse email maquillée
1381 1381
  **/
1382 1382
 function antispam($texte) {
1383
-	include_spip('inc/acces');
1384
-	$masque = creer_pass_aleatoire(3);
1383
+    include_spip('inc/acces');
1384
+    $masque = creer_pass_aleatoire(3);
1385 1385
 
1386
-	return preg_replace('/@/', " $masque ", $texte);
1386
+    return preg_replace('/@/', " $masque ", $texte);
1387 1387
 }
1388 1388
 
1389 1389
 /**
@@ -1415,8 +1415,8 @@  discard block
 block discarded – undo
1415 1415
  *     True si on a le droit d'accès, false sinon.
1416 1416
  **/
1417 1417
 function filtre_securiser_acces_dist($id_auteur, $cle, $dir, $op = '', $args = '') {
1418
-	include_spip('inc/acces');
1419
-	return securiser_acces_low_sec($id_auteur, $cle, $op ? "$dir $op $args" : $dir);
1418
+    include_spip('inc/acces');
1419
+    return securiser_acces_low_sec($id_auteur, $cle, $op ? "$dir $op $args" : $dir);
1420 1420
 }
1421 1421
 
1422 1422
 /**
@@ -1440,13 +1440,13 @@  discard block
 block discarded – undo
1440 1440
  *     Retourne $texte, sinon $sinon.
1441 1441
  **/
1442 1442
 function sinon(mixed $texte, mixed $sinon = '') {
1443
-	if ($texte) {
1444
-		return $texte;
1445
-	} elseif (is_scalar($texte) && strlen($texte)) {
1446
-		return $texte;
1447
-	} else {
1448
-		return $sinon;
1449
-	}
1443
+    if ($texte) {
1444
+        return $texte;
1445
+    } elseif (is_scalar($texte) && strlen($texte)) {
1446
+        return $texte;
1447
+    } else {
1448
+        return $sinon;
1449
+    }
1450 1450
 }
1451 1451
 
1452 1452
 /**
@@ -1470,7 +1470,7 @@  discard block
 block discarded – undo
1470 1470
  * @return mixed
1471 1471
  **/
1472 1472
 function choixsivide(mixed $a, mixed $vide, mixed $pasvide) {
1473
-	return $a ? $pasvide : $vide;
1473
+    return $a ? $pasvide : $vide;
1474 1474
 }
1475 1475
 
1476 1476
 /**
@@ -1494,7 +1494,7 @@  discard block
 block discarded – undo
1494 1494
  * @return mixed
1495 1495
  **/
1496 1496
 function choixsiegal(mixed $a1, mixed $a2, mixed $v, mixed $f) {
1497
-	return ($a1 == $a2) ? $v : $f;
1497
+    return ($a1 == $a2) ? $v : $f;
1498 1498
 }
1499 1499
 
1500 1500
 //
@@ -1513,12 +1513,12 @@  discard block
 block discarded – undo
1513 1513
  * @return string
1514 1514
  **/
1515 1515
 function filtrer_ical($texte) {
1516
-	#include_spip('inc/charsets');
1517
-	$texte = html2unicode($texte);
1518
-	$texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset']), 'utf-8');
1519
-	$texte = preg_replace("/\n/", ' ', $texte);
1516
+    #include_spip('inc/charsets');
1517
+    $texte = html2unicode($texte);
1518
+    $texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset']), 'utf-8');
1519
+    $texte = preg_replace("/\n/", ' ', $texte);
1520 1520
 
1521
-	return preg_replace('/,/', '\,', $texte);
1521
+    return preg_replace('/,/', '\,', $texte);
1522 1522
 }
1523 1523
 
1524 1524
 
@@ -1543,58 +1543,58 @@  discard block
 block discarded – undo
1543 1543
  * @return string
1544 1544
  **/
1545 1545
 function post_autobr($texte, $delim = "\n_ ") {
1546
-	if (!function_exists('echappe_html')) {
1547
-		include_spip('inc/texte_mini');
1548
-	}
1549
-	$texte = str_replace("\r\n", "\r", $texte);
1550
-	$texte = str_replace("\r", "\n", $texte);
1551
-
1552
-	if (preg_match(",\n+$,", $texte, $fin)) {
1553
-		$texte = substr($texte, 0, -strlen($fin = $fin[0]));
1554
-	} else {
1555
-		$fin = '';
1556
-	}
1557
-
1558
-	$texte = echappe_html($texte, '', true);
1559
-
1560
-	// echapper les modeles
1561
-	$collecteurModeles = null;
1562
-	if (str_contains($texte, '<')) {
1563
-		include_spip('src/Texte/Collecteur/AbstractCollecteur');
1564
-		include_spip('src/Texte/Collecteur/Modeles');
1565
-		$collecteurModeles = new Spip\Texte\Collecteur\Modeles();
1566
-		$texte = $collecteurModeles->echapper($texte);
1567
-	}
1568
-
1569
-	$debut = '';
1570
-	$suite = $texte;
1571
-	while ($t = strpos((string) ('-' . $suite), "\n", 1)) {
1572
-		$debut .= substr($suite, 0, $t - 1);
1573
-		$suite = substr($suite, $t);
1574
-		$car = substr($suite, 0, 1);
1575
-		if (
1576
-			$car != '-' && $car != '_' && $car != "\n" && $car != '|' && $car != '}'
1577
-			&& !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite))
1578
-			&& !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut)
1579
-		) {
1580
-			$debut .= $delim;
1581
-		} else {
1582
-			$debut .= "\n";
1583
-		}
1584
-		if (preg_match(",^\n+,", $suite, $regs)) {
1585
-			$debut .= $regs[0];
1586
-			$suite = substr($suite, strlen($regs[0]));
1587
-		}
1588
-	}
1589
-	$texte = $debut . $suite;
1590
-
1591
-	if ($collecteurModeles) {
1592
-		$texte = $collecteurModeles->retablir($texte);
1593
-	}
1594
-
1595
-	$texte = echappe_retour($texte);
1596
-
1597
-	return $texte . $fin;
1546
+    if (!function_exists('echappe_html')) {
1547
+        include_spip('inc/texte_mini');
1548
+    }
1549
+    $texte = str_replace("\r\n", "\r", $texte);
1550
+    $texte = str_replace("\r", "\n", $texte);
1551
+
1552
+    if (preg_match(",\n+$,", $texte, $fin)) {
1553
+        $texte = substr($texte, 0, -strlen($fin = $fin[0]));
1554
+    } else {
1555
+        $fin = '';
1556
+    }
1557
+
1558
+    $texte = echappe_html($texte, '', true);
1559
+
1560
+    // echapper les modeles
1561
+    $collecteurModeles = null;
1562
+    if (str_contains($texte, '<')) {
1563
+        include_spip('src/Texte/Collecteur/AbstractCollecteur');
1564
+        include_spip('src/Texte/Collecteur/Modeles');
1565
+        $collecteurModeles = new Spip\Texte\Collecteur\Modeles();
1566
+        $texte = $collecteurModeles->echapper($texte);
1567
+    }
1568
+
1569
+    $debut = '';
1570
+    $suite = $texte;
1571
+    while ($t = strpos((string) ('-' . $suite), "\n", 1)) {
1572
+        $debut .= substr($suite, 0, $t - 1);
1573
+        $suite = substr($suite, $t);
1574
+        $car = substr($suite, 0, 1);
1575
+        if (
1576
+            $car != '-' && $car != '_' && $car != "\n" && $car != '|' && $car != '}'
1577
+            && !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite))
1578
+            && !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut)
1579
+        ) {
1580
+            $debut .= $delim;
1581
+        } else {
1582
+            $debut .= "\n";
1583
+        }
1584
+        if (preg_match(",^\n+,", $suite, $regs)) {
1585
+            $debut .= $regs[0];
1586
+            $suite = substr($suite, strlen($regs[0]));
1587
+        }
1588
+    }
1589
+    $texte = $debut . $suite;
1590
+
1591
+    if ($collecteurModeles) {
1592
+        $texte = $collecteurModeles->retablir($texte);
1593
+    }
1594
+
1595
+    $texte = echappe_retour($texte);
1596
+
1597
+    return $texte . $fin;
1598 1598
 }
1599 1599
 
1600 1600
 
@@ -1629,26 +1629,26 @@  discard block
 block discarded – undo
1629 1629
  **/
1630 1630
 function extraire_idiome($letexte, $lang = null, $options = []) {
1631 1631
 
1632
-	if ($letexte && str_contains($letexte, '<:')) {
1633
-		if (!$lang) {
1634
-			$lang = $GLOBALS['spip_lang'];
1635
-		}
1636
-		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1637
-		if (is_bool($options)) {
1638
-			$options = ['echappe_span' => $options];
1639
-		}
1640
-		if (!isset($options['echappe_span'])) {
1641
-			$options = array_merge($options, ['echappe_span' => false]);
1642
-		}
1643
-		$options['lang'] = $lang;
1632
+    if ($letexte && str_contains($letexte, '<:')) {
1633
+        if (!$lang) {
1634
+            $lang = $GLOBALS['spip_lang'];
1635
+        }
1636
+        // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1637
+        if (is_bool($options)) {
1638
+            $options = ['echappe_span' => $options];
1639
+        }
1640
+        if (!isset($options['echappe_span'])) {
1641
+            $options = array_merge($options, ['echappe_span' => false]);
1642
+        }
1643
+        $options['lang'] = $lang;
1644 1644
 
1645
-		include_spip('src/Texte/Collecteur/AbstractCollecteur');
1646
-		include_spip('src/Texte/Collecteur/Idiomes');
1647
-		$collecteurIdiomes = new Spip\Texte\Collecteur\Idiomes();
1645
+        include_spip('src/Texte/Collecteur/AbstractCollecteur');
1646
+        include_spip('src/Texte/Collecteur/Idiomes');
1647
+        $collecteurIdiomes = new Spip\Texte\Collecteur\Idiomes();
1648 1648
 
1649
-		$letexte = $collecteurIdiomes->traiter($letexte, $options);
1650
-	}
1651
-	return $letexte;
1649
+        $letexte = $collecteurIdiomes->traiter($letexte, $options);
1650
+    }
1651
+    return $letexte;
1652 1652
 }
1653 1653
 
1654 1654
 /**
@@ -1686,31 +1686,31 @@  discard block
 block discarded – undo
1686 1686
  **/
1687 1687
 function extraire_multi($letexte, $lang = null, $options = []) {
1688 1688
 
1689
-	if ($letexte && stripos($letexte, '<multi') !== false) {
1690
-		if (!$lang) {
1691
-			$lang = $GLOBALS['spip_lang'];
1692
-		}
1689
+    if ($letexte && stripos($letexte, '<multi') !== false) {
1690
+        if (!$lang) {
1691
+            $lang = $GLOBALS['spip_lang'];
1692
+        }
1693 1693
 
1694
-		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1695
-		if (is_bool($options)) {
1696
-			$options = ['echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT];
1697
-		}
1698
-		if (!isset($options['echappe_span'])) {
1699
-			$options = array_merge($options, ['echappe_span' => false]);
1700
-		}
1701
-		if (!isset($options['lang_defaut'])) {
1702
-			$options = array_merge($options, ['lang_defaut' => _LANGUE_PAR_DEFAUT]);
1703
-		}
1704
-		$options['lang'] = $lang;
1694
+        // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1695
+        if (is_bool($options)) {
1696
+            $options = ['echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT];
1697
+        }
1698
+        if (!isset($options['echappe_span'])) {
1699
+            $options = array_merge($options, ['echappe_span' => false]);
1700
+        }
1701
+        if (!isset($options['lang_defaut'])) {
1702
+            $options = array_merge($options, ['lang_defaut' => _LANGUE_PAR_DEFAUT]);
1703
+        }
1704
+        $options['lang'] = $lang;
1705 1705
 
1706
-		include_spip('src/Texte/Collecteur/AbstractCollecteur');
1707
-		include_spip('src/Texte/Collecteur/Multis');
1708
-		$collecteurMultis = new Spip\Texte\Collecteur\Multis();
1706
+        include_spip('src/Texte/Collecteur/AbstractCollecteur');
1707
+        include_spip('src/Texte/Collecteur/Multis');
1708
+        $collecteurMultis = new Spip\Texte\Collecteur\Multis();
1709 1709
 
1710
-		$letexte = $collecteurMultis->traiter($letexte, $options);
1711
-	}
1710
+        $letexte = $collecteurMultis->traiter($letexte, $options);
1711
+    }
1712 1712
 
1713
-	return $letexte;
1713
+    return $letexte;
1714 1714
 }
1715 1715
 
1716 1716
 /**
@@ -1720,7 +1720,7 @@  discard block
 block discarded – undo
1720 1720
  * @return string L'initiale en majuscule
1721 1721
  */
1722 1722
 function filtre_initiale($nom) {
1723
-	return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1);
1723
+    return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1);
1724 1724
 }
1725 1725
 
1726 1726
 
@@ -1765,33 +1765,33 @@  discard block
 block discarded – undo
1765 1765
  *      - null (interne) : si on empile
1766 1766
  **/
1767 1767
 function unique($donnee, $famille = '', $cpt = false) {
1768
-	static $mem = [];
1769
-	// permettre de vider la pile et de la restaurer
1770
-	// pour le calcul de introduction...
1771
-	if ($famille == '_spip_raz_') {
1772
-		$tmp = $mem;
1773
-		$mem = [];
1774
-
1775
-		return $tmp;
1776
-	} elseif ($famille == '_spip_set_') {
1777
-		$mem = $donnee;
1778
-
1779
-		return;
1780
-	}
1781
-	// eviter une notice
1782
-	if (!isset($mem[$famille])) {
1783
-		$mem[$famille] = [];
1784
-	}
1785
-	if ($cpt) {
1786
-		return is_countable($mem[$famille]) ? count($mem[$famille]) : 0;
1787
-	}
1788
-	// eviter une notice
1789
-	if (!isset($mem[$famille][$donnee])) {
1790
-		$mem[$famille][$donnee] = 0;
1791
-	}
1792
-	if (!($mem[$famille][$donnee]++)) {
1793
-		return $donnee;
1794
-	}
1768
+    static $mem = [];
1769
+    // permettre de vider la pile et de la restaurer
1770
+    // pour le calcul de introduction...
1771
+    if ($famille == '_spip_raz_') {
1772
+        $tmp = $mem;
1773
+        $mem = [];
1774
+
1775
+        return $tmp;
1776
+    } elseif ($famille == '_spip_set_') {
1777
+        $mem = $donnee;
1778
+
1779
+        return;
1780
+    }
1781
+    // eviter une notice
1782
+    if (!isset($mem[$famille])) {
1783
+        $mem[$famille] = [];
1784
+    }
1785
+    if ($cpt) {
1786
+        return is_countable($mem[$famille]) ? count($mem[$famille]) : 0;
1787
+    }
1788
+    // eviter une notice
1789
+    if (!isset($mem[$famille][$donnee])) {
1790
+        $mem[$famille][$donnee] = 0;
1791
+    }
1792
+    if (!($mem[$famille][$donnee]++)) {
1793
+        return $donnee;
1794
+    }
1795 1795
 }
1796 1796
 
1797 1797
 
@@ -1821,20 +1821,20 @@  discard block
 block discarded – undo
1821 1821
  *     Une des valeurs en fonction du compteur.
1822 1822
  **/
1823 1823
 function alterner($i, ...$args) {
1824
-	// recuperer les arguments (attention fonctions un peu space)
1825
-	$num = count($args);
1824
+    // recuperer les arguments (attention fonctions un peu space)
1825
+    $num = count($args);
1826 1826
 
1827
-	if ($num === 1 && is_array($args[0])) {
1828
-		// un tableau de valeur dont les cles sont numerotees de 0 a num
1829
-		$args = array_values($args[0]);
1830
-		$num = count($args);
1831
-	}
1827
+    if ($num === 1 && is_array($args[0])) {
1828
+        // un tableau de valeur dont les cles sont numerotees de 0 a num
1829
+        $args = array_values($args[0]);
1830
+        $num = count($args);
1831
+    }
1832 1832
 
1833
-	// un index compris entre 0 et num exclus
1834
-	$i = (((int) $i - 1) % $num); // dans ]-$num;$num[
1835
-	$i = ($i + $num) % $num; // dans [0;$num[
1836
-	// renvoyer le i-ieme argument, modulo le nombre d'arguments
1837
-	return $args[$i];
1833
+    // un index compris entre 0 et num exclus
1834
+    $i = (((int) $i - 1) % $num); // dans ]-$num;$num[
1835
+    $i = ($i + $num) % $num; // dans [0;$num[
1836
+    // renvoyer le i-ieme argument, modulo le nombre d'arguments
1837
+    return $args[$i];
1838 1838
 }
1839 1839
 
1840 1840
 
@@ -1860,52 +1860,52 @@  discard block
 block discarded – undo
1860 1860
  *     - null lorsque l’attribut n’existe pas.
1861 1861
  **/
1862 1862
 function extraire_attribut($balise, $attribut, $complet = false) {
1863
-	if (is_array($balise)) {
1864
-		array_walk(
1865
-			$balise,
1866
-			function (&$a, $key, $t) {
1867
-				$a = extraire_attribut($a, $t);
1868
-			},
1869
-			$attribut
1870
-		);
1871
-
1872
-		return $balise;
1873
-	}
1874
-	if (
1875
-		$balise
1876
-		&& stripos($balise, $attribut) !== false
1877
-		&& preg_match(
1878
-			',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
1879
-			. $attribut
1880
-			. '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
1881
-			$balise,
1882
-			$r
1883
-		)
1884
-	) {
1885
-		if (isset($r[3][0]) && ($r[3][0] == '"' || $r[3][0] == "'")) {
1886
-			$r[4] = substr($r[3], 1, -1);
1887
-			$r[3] = $r[3][0];
1888
-		} elseif ($r[3] !== '') {
1889
-			$r[4] = $r[3];
1890
-			$r[3] = '';
1891
-		} else {
1892
-			$r[4] = trim($r[2]);
1893
-		}
1894
-		$att = $r[4];
1895
-		if (str_contains($att, '&#')) {
1896
-			$att = str_replace(['&#039;', '&#39;', '&#034;', '&#34;'], ["'", "'", '"', '"'], $att);
1897
-		}
1898
-		$att = filtrer_entites($att);
1899
-	} else {
1900
-		$att = null;
1901
-		$r = [];
1902
-	}
1903
-
1904
-	if ($complet) {
1905
-		return [$att, $r];
1906
-	} else {
1907
-		return $att;
1908
-	}
1863
+    if (is_array($balise)) {
1864
+        array_walk(
1865
+            $balise,
1866
+            function (&$a, $key, $t) {
1867
+                $a = extraire_attribut($a, $t);
1868
+            },
1869
+            $attribut
1870
+        );
1871
+
1872
+        return $balise;
1873
+    }
1874
+    if (
1875
+        $balise
1876
+        && stripos($balise, $attribut) !== false
1877
+        && preg_match(
1878
+            ',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
1879
+            . $attribut
1880
+            . '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
1881
+            $balise,
1882
+            $r
1883
+        )
1884
+    ) {
1885
+        if (isset($r[3][0]) && ($r[3][0] == '"' || $r[3][0] == "'")) {
1886
+            $r[4] = substr($r[3], 1, -1);
1887
+            $r[3] = $r[3][0];
1888
+        } elseif ($r[3] !== '') {
1889
+            $r[4] = $r[3];
1890
+            $r[3] = '';
1891
+        } else {
1892
+            $r[4] = trim($r[2]);
1893
+        }
1894
+        $att = $r[4];
1895
+        if (str_contains($att, '&#')) {
1896
+            $att = str_replace(['&#039;', '&#39;', '&#034;', '&#34;'], ["'", "'", '"', '"'], $att);
1897
+        }
1898
+        $att = filtrer_entites($att);
1899
+    } else {
1900
+        $att = null;
1901
+        $r = [];
1902
+    }
1903
+
1904
+    if ($complet) {
1905
+        return [$att, $r];
1906
+    } else {
1907
+        return $att;
1908
+    }
1909 1909
 }
1910 1910
 
1911 1911
 /**
@@ -1938,37 +1938,37 @@  discard block
 block discarded – undo
1938 1938
  **/
1939 1939
 function inserer_attribut(?string $balise, string $attribut, ?string $val, bool $proteger = true, bool $vider = false): string {
1940 1940
 
1941
-	if ($balise === null || $balise === '') {
1942
-		return '';
1943
-	}
1941
+    if ($balise === null || $balise === '') {
1942
+        return '';
1943
+    }
1944 1944
 
1945
-	// preparer l'attribut
1946
-	// supprimer les &nbsp; etc mais pas les balises html
1947
-	// qui ont un sens dans un attribut value d'un input
1948
-	if ($proteger) {
1949
-		$val = attribut_html($val, false);
1950
-	}
1945
+    // preparer l'attribut
1946
+    // supprimer les &nbsp; etc mais pas les balises html
1947
+    // qui ont un sens dans un attribut value d'un input
1948
+    if ($proteger) {
1949
+        $val = attribut_html($val, false);
1950
+    }
1951 1951
 
1952
-	// echapper les ' pour eviter tout bug
1953
-	$val = str_replace("'", '&#039;', $val ?? '');
1954
-	$insert = $vider && (string) $val === '' ? '' : " $attribut='$val'";
1952
+    // echapper les ' pour eviter tout bug
1953
+    $val = str_replace("'", '&#039;', $val ?? '');
1954
+    $insert = $vider && (string) $val === '' ? '' : " $attribut='$val'";
1955 1955
 
1956
-	[$old, $r] = extraire_attribut($balise, $attribut, true);
1956
+    [$old, $r] = extraire_attribut($balise, $attribut, true);
1957 1957
 
1958
-	if ($old !== null) {
1959
-		// Remplacer l'ancien attribut du meme nom
1960
-		$balise = $r[1] . $insert . $r[5];
1961
-	} else {
1962
-		// preferer une balise " />" (comme <img />)
1963
-		if (preg_match(',/>,', $balise)) {
1964
-			$balise = preg_replace(',\s?/>,S', $insert . ' />', $balise, 1);
1965
-		} // sinon une balise <a ...> ... </a>
1966
-		else {
1967
-			$balise = preg_replace(',\s?>,S', $insert . '>', $balise, 1);
1968
-		}
1969
-	}
1958
+    if ($old !== null) {
1959
+        // Remplacer l'ancien attribut du meme nom
1960
+        $balise = $r[1] . $insert . $r[5];
1961
+    } else {
1962
+        // preferer une balise " />" (comme <img />)
1963
+        if (preg_match(',/>,', $balise)) {
1964
+            $balise = preg_replace(',\s?/>,S', $insert . ' />', $balise, 1);
1965
+        } // sinon une balise <a ...> ... </a>
1966
+        else {
1967
+            $balise = preg_replace(',\s?>,S', $insert . '>', $balise, 1);
1968
+        }
1969
+    }
1970 1970
 
1971
-	return $balise;
1971
+    return $balise;
1972 1972
 }
1973 1973
 
1974 1974
 /**
@@ -1986,7 +1986,7 @@  discard block
 block discarded – undo
1986 1986
  * @return string Code HTML sans l'attribut
1987 1987
  **/
1988 1988
 function vider_attribut(?string $balise, string $attribut): string {
1989
-	return inserer_attribut($balise, $attribut, '', false, true);
1989
+    return inserer_attribut($balise, $attribut, '', false, true);
1990 1990
 }
1991 1991
 
1992 1992
 /**
@@ -1998,50 +1998,50 @@  discard block
 block discarded – undo
1998 1998
  * @return string
1999 1999
  */
2000 2000
 function modifier_class($balise, $class, $operation = 'ajouter') {
2001
-	if (is_string($class)) {
2002
-		$class = explode(' ', trim($class));
2003
-	}
2004
-	$class = array_filter($class);
2005
-	$class = array_unique($class);
2006
-	if (!$class) {
2007
-		return $balise;
2008
-	}
2009
-
2010
-	$class_courante = extraire_attribut($balise, 'class');
2011
-	$class_new = $class_courante;
2012
-	foreach ($class as $c) {
2013
-		$is_class_presente = false;
2014
-		if (
2015
-			$class_courante
2016
-			&& str_contains($class_courante, (string) $c)
2017
-			&& in_array($c, preg_split(',\s+,', $class_courante))
2018
-		) {
2019
-			$is_class_presente = true;
2020
-		}
2021
-		if (
2022
-			in_array($operation, ['ajouter', 'commuter'])
2023
-			&& !$is_class_presente
2024
-		) {
2025
-			$class_new = ltrim(rtrim($class_new ?? '') . ' ' . $c);
2026
-		} elseif (
2027
-			in_array($operation, ['supprimer', 'commuter'])
2028
-			&& $is_class_presente
2029
-		) {
2030
-			$class_new = preg_split(',\s+,', $class_new);
2031
-			$class_new = array_diff($class_new, [$c]);
2032
-			$class_new = implode(' ', $class_new);
2033
-		}
2034
-	}
2035
-
2036
-	if ($class_new !== $class_courante) {
2037
-		if (strlen($class_new)) {
2038
-			$balise = inserer_attribut($balise, 'class', $class_new);
2039
-		} elseif ($class_courante) {
2040
-			$balise = vider_attribut($balise, 'class');
2041
-		}
2042
-	}
2043
-
2044
-	return $balise;
2001
+    if (is_string($class)) {
2002
+        $class = explode(' ', trim($class));
2003
+    }
2004
+    $class = array_filter($class);
2005
+    $class = array_unique($class);
2006
+    if (!$class) {
2007
+        return $balise;
2008
+    }
2009
+
2010
+    $class_courante = extraire_attribut($balise, 'class');
2011
+    $class_new = $class_courante;
2012
+    foreach ($class as $c) {
2013
+        $is_class_presente = false;
2014
+        if (
2015
+            $class_courante
2016
+            && str_contains($class_courante, (string) $c)
2017
+            && in_array($c, preg_split(',\s+,', $class_courante))
2018
+        ) {
2019
+            $is_class_presente = true;
2020
+        }
2021
+        if (
2022
+            in_array($operation, ['ajouter', 'commuter'])
2023
+            && !$is_class_presente
2024
+        ) {
2025
+            $class_new = ltrim(rtrim($class_new ?? '') . ' ' . $c);
2026
+        } elseif (
2027
+            in_array($operation, ['supprimer', 'commuter'])
2028
+            && $is_class_presente
2029
+        ) {
2030
+            $class_new = preg_split(',\s+,', $class_new);
2031
+            $class_new = array_diff($class_new, [$c]);
2032
+            $class_new = implode(' ', $class_new);
2033
+        }
2034
+    }
2035
+
2036
+    if ($class_new !== $class_courante) {
2037
+        if (strlen($class_new)) {
2038
+            $balise = inserer_attribut($balise, 'class', $class_new);
2039
+        } elseif ($class_courante) {
2040
+            $balise = vider_attribut($balise, 'class');
2041
+        }
2042
+    }
2043
+
2044
+    return $balise;
2045 2045
 }
2046 2046
 
2047 2047
 /**
@@ -2051,7 +2051,7 @@  discard block
 block discarded – undo
2051 2051
  * @return string
2052 2052
  */
2053 2053
 function ajouter_class($balise, $class) {
2054
-	return modifier_class($balise, $class, 'ajouter');
2054
+    return modifier_class($balise, $class, 'ajouter');
2055 2055
 }
2056 2056
 
2057 2057
 /**
@@ -2061,7 +2061,7 @@  discard block
 block discarded – undo
2061 2061
  * @return string
2062 2062
  */
2063 2063
 function supprimer_class($balise, $class) {
2064
-	return modifier_class($balise, $class, 'supprimer');
2064
+    return modifier_class($balise, $class, 'supprimer');
2065 2065
 }
2066 2066
 
2067 2067
 /**
@@ -2072,7 +2072,7 @@  discard block
 block discarded – undo
2072 2072
  * @return string
2073 2073
  */
2074 2074
 function commuter_class($balise, $class) {
2075
-	return modifier_class($balise, $class, 'commuter');
2075
+    return modifier_class($balise, $class, 'commuter');
2076 2076
 }
2077 2077
 
2078 2078
 /**
@@ -2083,19 +2083,19 @@  discard block
 block discarded – undo
2083 2083
  * @return string
2084 2084
  */
2085 2085
 function tester_config($id, $mode = '') {
2086
-	include_spip('action/inscrire_auteur');
2086
+    include_spip('action/inscrire_auteur');
2087 2087
 
2088
-	return tester_statut_inscription($mode, $id);
2088
+    return tester_statut_inscription($mode, $id);
2089 2089
 }
2090 2090
 
2091 2091
 //
2092 2092
 // Quelques fonctions de calcul arithmetique
2093 2093
 //
2094 2094
 function floatstr($a) {
2095
-	return str_replace(',', '.', (string)(float) $a);
2095
+    return str_replace(',', '.', (string)(float) $a);
2096 2096
 }
2097 2097
 function strize($f, $a, $b) {
2098
-	return floatstr($f(floatstr($a), floatstr($b)));
2098
+    return floatstr($f(floatstr($a), floatstr($b)));
2099 2099
 }
2100 2100
 
2101 2101
 /**
@@ -2114,11 +2114,11 @@  discard block
 block discarded – undo
2114 2114
  * @return int $a+$b
2115 2115
  **/
2116 2116
 function plus($a, $b) {
2117
-	return $a + $b;
2117
+    return $a + $b;
2118 2118
 }
2119 2119
 
2120 2120
 function strplus($a, $b) {
2121
-	return strize('plus', $a, $b);
2121
+    return strize('plus', $a, $b);
2122 2122
 }
2123 2123
 
2124 2124
 /**
@@ -2137,11 +2137,11 @@  discard block
 block discarded – undo
2137 2137
  * @return int $a-$b
2138 2138
  **/
2139 2139
 function moins($a, $b) {
2140
-	return $a - $b;
2140
+    return $a - $b;
2141 2141
 }
2142 2142
 
2143 2143
 function strmoins($a, $b) {
2144
-	return strize('moins', $a, $b);
2144
+    return strize('moins', $a, $b);
2145 2145
 }
2146 2146
 
2147 2147
 /**
@@ -2161,11 +2161,11 @@  discard block
 block discarded – undo
2161 2161
  * @return int $a*$b
2162 2162
  **/
2163 2163
 function mult($a, $b) {
2164
-	return $a * $b;
2164
+    return $a * $b;
2165 2165
 }
2166 2166
 
2167 2167
 function strmult($a, $b) {
2168
-	return strize('mult', $a, $b);
2168
+    return strize('mult', $a, $b);
2169 2169
 }
2170 2170
 
2171 2171
 /**
@@ -2185,11 +2185,11 @@  discard block
 block discarded – undo
2185 2185
  * @return int $a/$b (ou 0 si $b est nul)
2186 2186
  **/
2187 2187
 function div($a, $b) {
2188
-	return $b ? $a / $b : 0;
2188
+    return $b ? $a / $b : 0;
2189 2189
 }
2190 2190
 
2191 2191
 function strdiv($a, $b) {
2192
-	return strize('div', $a, $b);
2192
+    return strize('div', $a, $b);
2193 2193
 }
2194 2194
 
2195 2195
 /**
@@ -2210,7 +2210,7 @@  discard block
 block discarded – undo
2210 2210
  * @return int ($nb % $mod) + $add
2211 2211
  **/
2212 2212
 function modulo($nb, $mod, $add = 0) {
2213
-	return ($mod ? $nb % $mod : 0) + $add;
2213
+    return ($mod ? $nb % $mod : 0) + $add;
2214 2214
 }
2215 2215
 
2216 2216
 
@@ -2225,26 +2225,26 @@  discard block
 block discarded – undo
2225 2225
  *      - true sinon
2226 2226
  **/
2227 2227
 function nom_acceptable($nom) {
2228
-	$remp2 = [];
2229
-	$remp1 = [];
2230
-	if (!is_string($nom)) {
2231
-		return false;
2232
-	}
2233
-	if (!defined('_TAGS_NOM_AUTEUR')) {
2234
-		define('_TAGS_NOM_AUTEUR', '');
2235
-	}
2236
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2237
-	foreach ($tags_acceptes as $tag) {
2238
-		if (strlen($tag)) {
2239
-			$remp1[] = '<' . trim($tag) . '>';
2240
-			$remp1[] = '</' . trim($tag) . '>';
2241
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2242
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2243
-		}
2244
-	}
2245
-	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2246
-
2247
-	return str_replace('&lt;', '<', $v_nom) == $nom;
2228
+    $remp2 = [];
2229
+    $remp1 = [];
2230
+    if (!is_string($nom)) {
2231
+        return false;
2232
+    }
2233
+    if (!defined('_TAGS_NOM_AUTEUR')) {
2234
+        define('_TAGS_NOM_AUTEUR', '');
2235
+    }
2236
+    $tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2237
+    foreach ($tags_acceptes as $tag) {
2238
+        if (strlen($tag)) {
2239
+            $remp1[] = '<' . trim($tag) . '>';
2240
+            $remp1[] = '</' . trim($tag) . '>';
2241
+            $remp2[] = '\x60' . trim($tag) . '\x61';
2242
+            $remp2[] = '\x60/' . trim($tag) . '\x61';
2243
+        }
2244
+    }
2245
+    $v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2246
+
2247
+    return str_replace('&lt;', '<', $v_nom) == $nom;
2248 2248
 }
2249 2249
 
2250 2250
 
@@ -2260,13 +2260,13 @@  discard block
 block discarded – undo
2260 2260
  *      - renvoie un tableau si l'entree est un tableau
2261 2261
  **/
2262 2262
 function email_valide($adresses) {
2263
-	if (is_array($adresses)) {
2264
-		$adresses = array_map('email_valide', $adresses);
2265
-		return array_filter($adresses);
2266
-	}
2263
+    if (is_array($adresses)) {
2264
+        $adresses = array_map('email_valide', $adresses);
2265
+        return array_filter($adresses);
2266
+    }
2267 2267
 
2268
-	$email_valide = charger_fonction('email_valide', 'inc');
2269
-	return $email_valide($adresses);
2268
+    $email_valide = charger_fonction('email_valide', 'inc');
2269
+    return $email_valide($adresses);
2270 2270
 }
2271 2271
 
2272 2272
 /**
@@ -2280,29 +2280,29 @@  discard block
 block discarded – undo
2280 2280
  * @return string texte
2281 2281
  **/
2282 2282
 function afficher_enclosures($tags) {
2283
-	$s = [];
2284
-	foreach (extraire_balises($tags, 'a') as $tag) {
2285
-		if (
2286
-			extraire_attribut($tag, 'rel') == 'enclosure'
2287
-			&& ($t = extraire_attribut($tag, 'href'))
2288
-		) {
2289
-			$s[] = preg_replace(
2290
-				',>[^<]+</a>,S',
2291
-				'>'
2292
-				. http_img_pack(
2293
-					'attachment-16.png',
2294
-					$t,
2295
-					'',
2296
-					$t,
2297
-					['utiliser_suffixe_size' => true]
2298
-				)
2299
-				. '</a>',
2300
-				(string) $tag
2301
-			);
2302
-		}
2303
-	}
2304
-
2305
-	return implode('&nbsp;', $s);
2283
+    $s = [];
2284
+    foreach (extraire_balises($tags, 'a') as $tag) {
2285
+        if (
2286
+            extraire_attribut($tag, 'rel') == 'enclosure'
2287
+            && ($t = extraire_attribut($tag, 'href'))
2288
+        ) {
2289
+            $s[] = preg_replace(
2290
+                ',>[^<]+</a>,S',
2291
+                '>'
2292
+                . http_img_pack(
2293
+                    'attachment-16.png',
2294
+                    $t,
2295
+                    '',
2296
+                    $t,
2297
+                    ['utiliser_suffixe_size' => true]
2298
+                )
2299
+                . '</a>',
2300
+                (string) $tag
2301
+            );
2302
+        }
2303
+    }
2304
+
2305
+    return implode('&nbsp;', $s);
2306 2306
 }
2307 2307
 
2308 2308
 /**
@@ -2317,15 +2317,15 @@  discard block
 block discarded – undo
2317 2317
  * @return string Liens trouvés
2318 2318
  **/
2319 2319
 function afficher_tags($tags, $rels = 'tag,directory') {
2320
-	$s = [];
2321
-	foreach (extraire_balises($tags, 'a') as $tag) {
2322
-		$rel = extraire_attribut($tag, 'rel');
2323
-		if (strstr(",$rels,", (string) ",$rel,")) {
2324
-			$s[] = $tag;
2325
-		}
2326
-	}
2320
+    $s = [];
2321
+    foreach (extraire_balises($tags, 'a') as $tag) {
2322
+        $rel = extraire_attribut($tag, 'rel');
2323
+        if (strstr(",$rels,", (string) ",$rel,")) {
2324
+            $s[] = $tag;
2325
+        }
2326
+    }
2327 2327
 
2328
-	return implode(', ', $s);
2328
+    return implode(', ', $s);
2329 2329
 }
2330 2330
 
2331 2331
 
@@ -2347,21 +2347,21 @@  discard block
 block discarded – undo
2347 2347
  * @return string Tag HTML `<a>` avec microformat.
2348 2348
  **/
2349 2349
 function enclosure2microformat($e) {
2350
-	if (!$url = filtrer_entites(extraire_attribut($e, 'url') ?? '')) {
2351
-		$url = filtrer_entites(extraire_attribut($e, 'href') ?? '');
2352
-	}
2353
-	$type = extraire_attribut($e, 'type');
2354
-	if (!$length = extraire_attribut($e, 'length')) {
2355
-		# <media:content : longeur dans fileSize. On tente.
2356
-		$length = extraire_attribut($e, 'fileSize');
2357
-	}
2358
-	$fichier = basename($url);
2350
+    if (!$url = filtrer_entites(extraire_attribut($e, 'url') ?? '')) {
2351
+        $url = filtrer_entites(extraire_attribut($e, 'href') ?? '');
2352
+    }
2353
+    $type = extraire_attribut($e, 'type');
2354
+    if (!$length = extraire_attribut($e, 'length')) {
2355
+        # <media:content : longeur dans fileSize. On tente.
2356
+        $length = extraire_attribut($e, 'fileSize');
2357
+    }
2358
+    $fichier = basename($url);
2359 2359
 
2360
-	return '<a rel="enclosure"'
2361
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2362
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2363
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2364
-	. '>' . $fichier . '</a>';
2360
+    return '<a rel="enclosure"'
2361
+    . ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2362
+    . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2363
+    . ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2364
+    . '>' . $fichier . '</a>';
2365 2365
 }
2366 2366
 
2367 2367
 /**
@@ -2379,24 +2379,24 @@  discard block
 block discarded – undo
2379 2379
  * @return string Tags RSS `<enclosure>`.
2380 2380
  **/
2381 2381
 function microformat2enclosure($tags) {
2382
-	$enclosures = [];
2383
-	foreach (extraire_balises($tags, 'a') as $e) {
2384
-		if (extraire_attribut($e, 'rel') == 'enclosure') {
2385
-			$url = filtrer_entites(extraire_attribut($e, 'href'));
2386
-			$type = extraire_attribut($e, 'type');
2387
-			if (!$length = (int) extraire_attribut($e, 'title')) {
2388
-				$length = (int) extraire_attribut($e, 'length');
2389
-			} # vieux data
2390
-			$fichier = basename($url);
2391
-			$enclosures[] = '<enclosure'
2392
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2393
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2394
-				. ($length ? ' length="' . $length . '"' : '')
2395
-				. ' />';
2396
-		}
2397
-	}
2382
+    $enclosures = [];
2383
+    foreach (extraire_balises($tags, 'a') as $e) {
2384
+        if (extraire_attribut($e, 'rel') == 'enclosure') {
2385
+            $url = filtrer_entites(extraire_attribut($e, 'href'));
2386
+            $type = extraire_attribut($e, 'type');
2387
+            if (!$length = (int) extraire_attribut($e, 'title')) {
2388
+                $length = (int) extraire_attribut($e, 'length');
2389
+            } # vieux data
2390
+            $fichier = basename($url);
2391
+            $enclosures[] = '<enclosure'
2392
+                . ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2393
+                . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2394
+                . ($length ? ' length="' . $length . '"' : '')
2395
+                . ' />';
2396
+        }
2397
+    }
2398 2398
 
2399
-	return implode("\n", $enclosures);
2399
+    return implode("\n", $enclosures);
2400 2400
 }
2401 2401
 
2402 2402
 
@@ -2412,16 +2412,16 @@  discard block
 block discarded – undo
2412 2412
  * @return string Tags RSS Atom `<dc:subject>`.
2413 2413
  **/
2414 2414
 function tags2dcsubject($tags) {
2415
-	$subjects = '';
2416
-	foreach (extraire_balises($tags, 'a') as $e) {
2417
-		if (extraire_attribut($e, 'rel') == 'tag') {
2418
-			$subjects .= '<dc:subject>'
2419
-				. texte_backend(textebrut($e))
2420
-				. '</dc:subject>' . "\n";
2421
-		}
2422
-	}
2415
+    $subjects = '';
2416
+    foreach (extraire_balises($tags, 'a') as $e) {
2417
+        if (extraire_attribut($e, 'rel') == 'tag') {
2418
+            $subjects .= '<dc:subject>'
2419
+                . texte_backend(textebrut($e))
2420
+                . '</dc:subject>' . "\n";
2421
+        }
2422
+    }
2423 2423
 
2424
-	return $subjects;
2424
+    return $subjects;
2425 2425
 }
2426 2426
 
2427 2427
 /**
@@ -2450,27 +2450,27 @@  discard block
 block discarded – undo
2450 2450
  *     - Tableau de résultats, si tableau en entrée.
2451 2451
  **/
2452 2452
 function extraire_balise($texte, $tag = 'a') {
2453
-	if (is_array($texte)) {
2454
-		array_walk(
2455
-			$texte,
2456
-			function (&$a, $key, $t) {
2457
-				$a = extraire_balise($a, $t);
2458
-			},
2459
-			$tag
2460
-		);
2461
-
2462
-		return $texte;
2463
-	}
2464
-
2465
-	if (
2466
-		preg_match(
2467
-			",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS",
2468
-			$texte,
2469
-			$regs
2470
-		)
2471
-	) {
2472
-		return $regs[0];
2473
-	}
2453
+    if (is_array($texte)) {
2454
+        array_walk(
2455
+            $texte,
2456
+            function (&$a, $key, $t) {
2457
+                $a = extraire_balise($a, $t);
2458
+            },
2459
+            $tag
2460
+        );
2461
+
2462
+        return $texte;
2463
+    }
2464
+
2465
+    if (
2466
+        preg_match(
2467
+            ",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS",
2468
+            $texte,
2469
+            $regs
2470
+        )
2471
+    ) {
2472
+        return $regs[0];
2473
+    }
2474 2474
 }
2475 2475
 
2476 2476
 /**
@@ -2498,30 +2498,30 @@  discard block
 block discarded – undo
2498 2498
  *     - Tableau de résultats, si tableau en entrée.
2499 2499
  **/
2500 2500
 function extraire_balises($texte, $tag = 'a') {
2501
-	if (is_array($texte)) {
2502
-		array_walk(
2503
-			$texte,
2504
-			function (&$a, $key, $t) {
2505
-				$a = extraire_balises($a, $t);
2506
-			},
2507
-			$tag
2508
-		);
2509
-
2510
-		return $texte;
2511
-	}
2512
-
2513
-	if (
2514
-		preg_match_all(
2515
-			",<{$tag}\b[^>]*(/>|>.*</{$tag}\b[^>]*>|>),UimsS",
2516
-			$texte,
2517
-			$regs,
2518
-			PREG_PATTERN_ORDER
2519
-		)
2520
-	) {
2521
-		return $regs[0];
2522
-	} else {
2523
-		return [];
2524
-	}
2501
+    if (is_array($texte)) {
2502
+        array_walk(
2503
+            $texte,
2504
+            function (&$a, $key, $t) {
2505
+                $a = extraire_balises($a, $t);
2506
+            },
2507
+            $tag
2508
+        );
2509
+
2510
+        return $texte;
2511
+    }
2512
+
2513
+    if (
2514
+        preg_match_all(
2515
+            ",<{$tag}\b[^>]*(/>|>.*</{$tag}\b[^>]*>|>),UimsS",
2516
+            $texte,
2517
+            $regs,
2518
+            PREG_PATTERN_ORDER
2519
+        )
2520
+    ) {
2521
+        return $regs[0];
2522
+    } else {
2523
+        return [];
2524
+    }
2525 2525
 }
2526 2526
 
2527 2527
 /**
@@ -2550,11 +2550,11 @@  discard block
 block discarded – undo
2550 2550
  *     - `$def` si on n'a pas transmis de tableau
2551 2551
  **/
2552 2552
 function in_any($val, $vals, $def = '') {
2553
-	if (!is_array($vals) && $vals && ($v = unserialize($vals))) {
2554
-		$vals = $v;
2555
-	}
2553
+    if (!is_array($vals) && $vals && ($v = unserialize($vals))) {
2554
+        $vals = $v;
2555
+    }
2556 2556
 
2557
-	return (is_array($vals) ? (in_array($val, $vals) ? ' ' : '') : ($def));
2557
+    return (is_array($vals) ? (in_array($val, $vals) ? ' ' : '') : ($def));
2558 2558
 }
2559 2559
 
2560 2560
 
@@ -2575,12 +2575,12 @@  discard block
 block discarded – undo
2575 2575
  *     Résultat du calcul
2576 2576
  **/
2577 2577
 function valeur_numerique($expr) {
2578
-	$a = 0;
2579
-	if (preg_match(',^\d+(\s*[+*-]\s*\d+)*$,S', trim($expr))) {
2580
-		eval("\$a = $expr;");
2581
-	}
2578
+    $a = 0;
2579
+    if (preg_match(',^\d+(\s*[+*-]\s*\d+)*$,S', trim($expr))) {
2580
+        eval("\$a = $expr;");
2581
+    }
2582 2582
 
2583
-	return (int) $a;
2583
+    return (int) $a;
2584 2584
 }
2585 2585
 
2586 2586
 /**
@@ -2599,7 +2599,7 @@  discard block
 block discarded – undo
2599 2599
  *      Retourne `$a*$b/$c`
2600 2600
  **/
2601 2601
 function regledetrois($a, $b, $c) {
2602
-	return round($a * $b / $c);
2602
+    return round($a * $b / $c);
2603 2603
 }
2604 2604
 
2605 2605
 
@@ -2622,79 +2622,79 @@  discard block
 block discarded – undo
2622 2622
  * @return string Suite de champs input hidden
2623 2623
  **/
2624 2624
 function form_hidden(?string $action = ''): string {
2625
-	$action ??= '';
2626
-
2627
-	$contexte = [];
2628
-	include_spip('inc/urls');
2629
-	if (
2630
-		($p = urls_decoder_url($action, ''))
2631
-		&& reset($p)
2632
-	) {
2633
-		$fond = array_shift($p);
2634
-		if ($fond != '404') {
2635
-			$contexte = array_shift($p);
2636
-			$contexte['page'] = $fond;
2637
-			$action = preg_replace('/([?]' . preg_quote((string) $fond, '/') . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2638
-		}
2639
-	}
2640
-	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2641
-	if (defined('_DEFINIR_CONTEXTE_TYPE') && _DEFINIR_CONTEXTE_TYPE) {
2642
-		unset($contexte['type']);
2643
-	}
2644
-	if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') || _DEFINIR_CONTEXTE_TYPE_PAGE) {
2645
-		unset($contexte['type-page']);
2646
-	}
2647
-
2648
-	// on va remplir un tableau de valeurs en prenant bien soin de ne pas
2649
-	// ecraser les elements de la forme mots[]=1&mots[]=2
2650
-	$values = [];
2651
-
2652
-	// d'abord avec celles de l'url
2653
-	if (false !== ($p = strpos($action, '?'))) {
2654
-		foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2655
-			$c = explode('=', (string) $c, 2);
2656
-			$var = array_shift($c);
2657
-			$val = array_shift($c) ?? '';
2658
-			if ($var) {
2659
-				$val = rawurldecode($val);
2660
-				$var = rawurldecode($var); // decoder les [] eventuels
2661
-				if (preg_match(',\[\]$,S', $var)) {
2662
-					$values[] = [$var, $val];
2663
-				} else {
2664
-					if (!isset($values[$var])) {
2665
-						$values[$var] = [$var, $val];
2666
-					}
2667
-				}
2668
-			}
2669
-		}
2670
-	}
2671
-
2672
-	// ensuite avec celles du contexte, sans doublonner !
2673
-	foreach ($contexte as $var => $val) {
2674
-		if (preg_match(',\[\]$,S', (string) $var)) {
2675
-			$values[] = [$var, $val];
2676
-		} else {
2677
-			if (!isset($values[$var])) {
2678
-				$values[$var] = [$var, $val];
2679
-			}
2680
-		}
2681
-	}
2682
-
2683
-	// puis on rassemble le tout
2684
-	$hidden = [];
2685
-	foreach ($values as $value) {
2686
-		[$var, $val] = $value;
2687
-		$hidden[] = '<input name="'
2688
-			. entites_html($var)
2689
-			. '"'
2690
-			. (is_null($val)
2691
-				? ''
2692
-				: ' value="' . entites_html($val) . '"'
2693
-			)
2694
-			. ' type="hidden"' . "\n/>";
2695
-	}
2696
-
2697
-	return implode('', $hidden);
2625
+    $action ??= '';
2626
+
2627
+    $contexte = [];
2628
+    include_spip('inc/urls');
2629
+    if (
2630
+        ($p = urls_decoder_url($action, ''))
2631
+        && reset($p)
2632
+    ) {
2633
+        $fond = array_shift($p);
2634
+        if ($fond != '404') {
2635
+            $contexte = array_shift($p);
2636
+            $contexte['page'] = $fond;
2637
+            $action = preg_replace('/([?]' . preg_quote((string) $fond, '/') . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2638
+        }
2639
+    }
2640
+    // defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2641
+    if (defined('_DEFINIR_CONTEXTE_TYPE') && _DEFINIR_CONTEXTE_TYPE) {
2642
+        unset($contexte['type']);
2643
+    }
2644
+    if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') || _DEFINIR_CONTEXTE_TYPE_PAGE) {
2645
+        unset($contexte['type-page']);
2646
+    }
2647
+
2648
+    // on va remplir un tableau de valeurs en prenant bien soin de ne pas
2649
+    // ecraser les elements de la forme mots[]=1&mots[]=2
2650
+    $values = [];
2651
+
2652
+    // d'abord avec celles de l'url
2653
+    if (false !== ($p = strpos($action, '?'))) {
2654
+        foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2655
+            $c = explode('=', (string) $c, 2);
2656
+            $var = array_shift($c);
2657
+            $val = array_shift($c) ?? '';
2658
+            if ($var) {
2659
+                $val = rawurldecode($val);
2660
+                $var = rawurldecode($var); // decoder les [] eventuels
2661
+                if (preg_match(',\[\]$,S', $var)) {
2662
+                    $values[] = [$var, $val];
2663
+                } else {
2664
+                    if (!isset($values[$var])) {
2665
+                        $values[$var] = [$var, $val];
2666
+                    }
2667
+                }
2668
+            }
2669
+        }
2670
+    }
2671
+
2672
+    // ensuite avec celles du contexte, sans doublonner !
2673
+    foreach ($contexte as $var => $val) {
2674
+        if (preg_match(',\[\]$,S', (string) $var)) {
2675
+            $values[] = [$var, $val];
2676
+        } else {
2677
+            if (!isset($values[$var])) {
2678
+                $values[$var] = [$var, $val];
2679
+            }
2680
+        }
2681
+    }
2682
+
2683
+    // puis on rassemble le tout
2684
+    $hidden = [];
2685
+    foreach ($values as $value) {
2686
+        [$var, $val] = $value;
2687
+        $hidden[] = '<input name="'
2688
+            . entites_html($var)
2689
+            . '"'
2690
+            . (is_null($val)
2691
+                ? ''
2692
+                : ' value="' . entites_html($val) . '"'
2693
+            )
2694
+            . ' type="hidden"' . "\n/>";
2695
+    }
2696
+
2697
+    return implode('', $hidden);
2698 2698
 }
2699 2699
 
2700 2700
 
@@ -2716,7 +2716,7 @@  discard block
 block discarded – undo
2716 2716
  *    - la première valeur du tableau sinon.
2717 2717
  **/
2718 2718
 function filtre_reset($array) {
2719
-	return is_array($array) ? reset($array) : null;
2719
+    return is_array($array) ? reset($array) : null;
2720 2720
 }
2721 2721
 
2722 2722
 /**
@@ -2737,7 +2737,7 @@  discard block
 block discarded – undo
2737 2737
  *    - la dernière valeur du tableau sinon.
2738 2738
  **/
2739 2739
 function filtre_end($array) {
2740
-	return is_array($array) ? end($array) : null;
2740
+    return is_array($array) ? end($array) : null;
2741 2741
 }
2742 2742
 
2743 2743
 /**
@@ -2757,11 +2757,11 @@  discard block
 block discarded – undo
2757 2757
  *
2758 2758
  **/
2759 2759
 function filtre_push($array, mixed $val) {
2760
-	if (!is_array($array) || !array_push($array, $val)) {
2761
-		return '';
2762
-	}
2760
+    if (!is_array($array) || !array_push($array, $val)) {
2761
+        return '';
2762
+    }
2763 2763
 
2764
-	return $array;
2764
+    return $array;
2765 2765
 }
2766 2766
 
2767 2767
 /**
@@ -2780,7 +2780,7 @@  discard block
 block discarded – undo
2780 2780
  *     - `true` si la valeur existe dans le tableau, `false` sinon.
2781 2781
  **/
2782 2782
 function filtre_find($array, mixed $val) {
2783
-	return (is_array($array) && in_array($val, $array));
2783
+    return (is_array($array) && in_array($val, $array));
2784 2784
 }
2785 2785
 
2786 2786
 
@@ -2797,13 +2797,13 @@  discard block
 block discarded – undo
2797 2797
  *     Contenu avec urls en absolus
2798 2798
  **/
2799 2799
 function urls_absolues_css($contenu, $source) {
2800
-	$path = suivre_lien(url_absolue($source), './');
2800
+    $path = suivre_lien(url_absolue($source), './');
2801 2801
 
2802
-	return preg_replace_callback(
2803
-		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2804
-		fn($x) => "url('" . suivre_lien($path, $x[1]) . "')",
2805
-		$contenu
2806
-	);
2802
+    return preg_replace_callback(
2803
+        ",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2804
+        fn($x) => "url('" . suivre_lien($path, $x[1]) . "')",
2805
+        $contenu
2806
+    );
2807 2807
 }
2808 2808
 
2809 2809
 
@@ -2832,120 +2832,120 @@  discard block
 block discarded – undo
2832 2832
  *     Chemin du fichier CSS inversé
2833 2833
  **/
2834 2834
 function direction_css($css, $voulue = '') {
2835
-	if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) {
2836
-		return $css;
2837
-	}
2838
-	include_spip('inc/lang');
2839
-	// si on a precise le sens voulu en argument, le prendre en compte
2840
-	if ($voulue = strtolower($voulue)) {
2841
-		if ($voulue != 'rtl' && $voulue != 'ltr') {
2842
-			$voulue = lang_dir($voulue);
2843
-		}
2844
-	} else {
2845
-		$voulue = lang_dir();
2846
-	}
2847
-
2848
-	$r = count($r) > 1;
2849
-	$right = $r ? 'left' : 'right'; // 'right' de la css lue en entree
2850
-	$dir = $r ? 'rtl' : 'ltr';
2851
-	$ndir = $r ? 'ltr' : 'rtl';
2852
-
2853
-	if ($voulue == $dir) {
2854
-		return $css;
2855
-	}
2856
-
2857
-	if (
2858
-		// url absolue
2859
-		preg_match(',^https?:,i', $css)
2860
-		// ou qui contient un ?
2861
-		|| ($p = strpos($css, '?')) !== false
2862
-	) {
2863
-		$distant = true;
2864
-		$cssf = parse_url($css);
2865
-		$cssf = $cssf['path'] . ($cssf['query'] ? '?' . $cssf['query'] : '');
2866
-		$cssf = preg_replace(',[?:&=],', '_', $cssf);
2867
-	} else {
2868
-		$distant = false;
2869
-		$cssf = $css;
2870
-		// 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2871
-		//propose (rien a faire dans ce cas)
2872
-		$f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2873
-		if (@file_exists($f)) {
2874
-			return $f;
2875
-		}
2876
-	}
2877
-
2878
-	// 2.
2879
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2880
-	$f = $dir_var
2881
-		. preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2882
-		. '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2883
-
2884
-	// la css peut etre distante (url absolue !)
2885
-	$contenu = null;
2886
-	if ($distant) {
2887
-		include_spip('inc/distant');
2888
-		$res = recuperer_url($css);
2889
-		if (!$res || !($contenu = $res['page'])) {
2890
-			return $css;
2891
-		}
2892
-	} else {
2893
-		if (
2894
-			@filemtime($f) > @filemtime($css)
2895
-			&& _VAR_MODE != 'recalcul'
2896
-		) {
2897
-			return $f;
2898
-		}
2899
-		if (!lire_fichier($css, $contenu)) {
2900
-			return $css;
2901
-		}
2902
-	}
2903
-
2904
-
2905
-	// Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands
2906
-	include_spip('lib/csstidy/class.csstidy');
2907
-	$parser = new csstidy();
2908
-	$parser->set_cfg('optimise_shorthands', 0);
2909
-	$parser->set_cfg('reverse_left_and_right', true);
2910
-	$parser->parse($contenu);
2911
-
2912
-	$contenu = $parser->print->plain();
2913
-
2914
-
2915
-	// reperer les @import auxquels il faut propager le direction_css
2916
-	preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", (string) $contenu, $regs);
2917
-	$src = [];
2918
-	$src_direction_css = [];
2919
-	$src_faux_abs = [];
2920
-	$d = dirname($css);
2921
-	foreach ($regs[1] as $k => $import_css) {
2922
-		$css_direction = direction_css("$d/$import_css", $voulue);
2923
-		// si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue
2924
-		if (substr($css_direction, 0, strlen($d) + 1) == "$d/") {
2925
-			$css_direction = substr($css_direction, strlen($d) + 1);
2926
-		} // si la css_direction commence par $dir_var on la fait passer pour une absolue
2927
-		elseif (str_starts_with($css_direction, $dir_var)) {
2928
-			$css_direction = substr($css_direction, strlen($dir_var));
2929
-			$src_faux_abs['/@@@@@@/' . $css_direction] = $css_direction;
2930
-			$css_direction = '/@@@@@@/' . $css_direction;
2931
-		}
2932
-		$src[] = $regs[0][$k];
2933
-		$src_direction_css[] = str_replace($import_css, $css_direction, (string) $regs[0][$k]);
2934
-	}
2935
-	$contenu = str_replace($src, $src_direction_css, (string) $contenu);
2936
-
2937
-	$contenu = urls_absolues_css($contenu, $css);
2938
-
2939
-	// virer les fausses url absolues que l'on a mis dans les import
2940
-	if ($src_faux_abs !== []) {
2941
-		$contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu);
2942
-	}
2943
-
2944
-	if (!ecrire_fichier($f, $contenu)) {
2945
-		return $css;
2946
-	}
2947
-
2948
-	return $f;
2835
+    if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) {
2836
+        return $css;
2837
+    }
2838
+    include_spip('inc/lang');
2839
+    // si on a precise le sens voulu en argument, le prendre en compte
2840
+    if ($voulue = strtolower($voulue)) {
2841
+        if ($voulue != 'rtl' && $voulue != 'ltr') {
2842
+            $voulue = lang_dir($voulue);
2843
+        }
2844
+    } else {
2845
+        $voulue = lang_dir();
2846
+    }
2847
+
2848
+    $r = count($r) > 1;
2849
+    $right = $r ? 'left' : 'right'; // 'right' de la css lue en entree
2850
+    $dir = $r ? 'rtl' : 'ltr';
2851
+    $ndir = $r ? 'ltr' : 'rtl';
2852
+
2853
+    if ($voulue == $dir) {
2854
+        return $css;
2855
+    }
2856
+
2857
+    if (
2858
+        // url absolue
2859
+        preg_match(',^https?:,i', $css)
2860
+        // ou qui contient un ?
2861
+        || ($p = strpos($css, '?')) !== false
2862
+    ) {
2863
+        $distant = true;
2864
+        $cssf = parse_url($css);
2865
+        $cssf = $cssf['path'] . ($cssf['query'] ? '?' . $cssf['query'] : '');
2866
+        $cssf = preg_replace(',[?:&=],', '_', $cssf);
2867
+    } else {
2868
+        $distant = false;
2869
+        $cssf = $css;
2870
+        // 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2871
+        //propose (rien a faire dans ce cas)
2872
+        $f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2873
+        if (@file_exists($f)) {
2874
+            return $f;
2875
+        }
2876
+    }
2877
+
2878
+    // 2.
2879
+    $dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2880
+    $f = $dir_var
2881
+        . preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2882
+        . '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2883
+
2884
+    // la css peut etre distante (url absolue !)
2885
+    $contenu = null;
2886
+    if ($distant) {
2887
+        include_spip('inc/distant');
2888
+        $res = recuperer_url($css);
2889
+        if (!$res || !($contenu = $res['page'])) {
2890
+            return $css;
2891
+        }
2892
+    } else {
2893
+        if (
2894
+            @filemtime($f) > @filemtime($css)
2895
+            && _VAR_MODE != 'recalcul'
2896
+        ) {
2897
+            return $f;
2898
+        }
2899
+        if (!lire_fichier($css, $contenu)) {
2900
+            return $css;
2901
+        }
2902
+    }
2903
+
2904
+
2905
+    // Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands
2906
+    include_spip('lib/csstidy/class.csstidy');
2907
+    $parser = new csstidy();
2908
+    $parser->set_cfg('optimise_shorthands', 0);
2909
+    $parser->set_cfg('reverse_left_and_right', true);
2910
+    $parser->parse($contenu);
2911
+
2912
+    $contenu = $parser->print->plain();
2913
+
2914
+
2915
+    // reperer les @import auxquels il faut propager le direction_css
2916
+    preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", (string) $contenu, $regs);
2917
+    $src = [];
2918
+    $src_direction_css = [];
2919
+    $src_faux_abs = [];
2920
+    $d = dirname($css);
2921
+    foreach ($regs[1] as $k => $import_css) {
2922
+        $css_direction = direction_css("$d/$import_css", $voulue);
2923
+        // si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue
2924
+        if (substr($css_direction, 0, strlen($d) + 1) == "$d/") {
2925
+            $css_direction = substr($css_direction, strlen($d) + 1);
2926
+        } // si la css_direction commence par $dir_var on la fait passer pour une absolue
2927
+        elseif (str_starts_with($css_direction, $dir_var)) {
2928
+            $css_direction = substr($css_direction, strlen($dir_var));
2929
+            $src_faux_abs['/@@@@@@/' . $css_direction] = $css_direction;
2930
+            $css_direction = '/@@@@@@/' . $css_direction;
2931
+        }
2932
+        $src[] = $regs[0][$k];
2933
+        $src_direction_css[] = str_replace($import_css, $css_direction, (string) $regs[0][$k]);
2934
+    }
2935
+    $contenu = str_replace($src, $src_direction_css, (string) $contenu);
2936
+
2937
+    $contenu = urls_absolues_css($contenu, $css);
2938
+
2939
+    // virer les fausses url absolues que l'on a mis dans les import
2940
+    if ($src_faux_abs !== []) {
2941
+        $contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu);
2942
+    }
2943
+
2944
+    if (!ecrire_fichier($f, $contenu)) {
2945
+        return $css;
2946
+    }
2947
+
2948
+    return $f;
2949 2949
 }
2950 2950
 
2951 2951
 
@@ -2968,47 +2968,47 @@  discard block
 block discarded – undo
2968 2968
  *     - Chemin ou URL du fichier CSS source sinon.
2969 2969
  **/
2970 2970
 function url_absolue_css($css) {
2971
-	if (!preg_match(',\.css$,i', $css, $r)) {
2972
-		return $css;
2973
-	}
2971
+    if (!preg_match(',\.css$,i', $css, $r)) {
2972
+        return $css;
2973
+    }
2974 2974
 
2975
-	$url_absolue_css = url_absolue($css);
2975
+    $url_absolue_css = url_absolue($css);
2976 2976
 
2977
-	$f = basename($css, '.css');
2978
-	$f = sous_repertoire(_DIR_VAR, 'cache-css')
2979
-		. preg_replace(',(.*?)(_rtl|_ltr)?$,', "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
2980
-		. '.css';
2977
+    $f = basename($css, '.css');
2978
+    $f = sous_repertoire(_DIR_VAR, 'cache-css')
2979
+        . preg_replace(',(.*?)(_rtl|_ltr)?$,', "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
2980
+        . '.css';
2981 2981
 
2982
-	if (@filemtime($f) > @filemtime($css) && _VAR_MODE != 'recalcul') {
2983
-		return $f;
2984
-	}
2982
+    if (@filemtime($f) > @filemtime($css) && _VAR_MODE != 'recalcul') {
2983
+        return $f;
2984
+    }
2985 2985
 
2986
-	$contenu = null;
2987
-	if ($url_absolue_css == $css) {
2988
-		if (
2989
-			strncmp((string) $GLOBALS['meta']['adresse_site'], $css, $l = strlen((string) $GLOBALS['meta']['adresse_site'])) != 0
2990
-			|| !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
2991
-		) {
2992
-			include_spip('inc/distant');
2993
-			$contenu = recuperer_url($css);
2994
-			$contenu = $contenu['page'] ?? '';
2995
-			if (!$contenu) {
2996
-				return $css;
2997
-			}
2998
-		}
2999
-	} elseif (!lire_fichier($css, $contenu)) {
3000
-		return $css;
3001
-	}
2986
+    $contenu = null;
2987
+    if ($url_absolue_css == $css) {
2988
+        if (
2989
+            strncmp((string) $GLOBALS['meta']['adresse_site'], $css, $l = strlen((string) $GLOBALS['meta']['adresse_site'])) != 0
2990
+            || !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
2991
+        ) {
2992
+            include_spip('inc/distant');
2993
+            $contenu = recuperer_url($css);
2994
+            $contenu = $contenu['page'] ?? '';
2995
+            if (!$contenu) {
2996
+                return $css;
2997
+            }
2998
+        }
2999
+    } elseif (!lire_fichier($css, $contenu)) {
3000
+        return $css;
3001
+    }
3002 3002
 
3003
-	// passer les url relatives a la css d'origine en url absolues
3004
-	$contenu = urls_absolues_css($contenu, $css);
3003
+    // passer les url relatives a la css d'origine en url absolues
3004
+    $contenu = urls_absolues_css($contenu, $css);
3005 3005
 
3006
-	// ecrire la css
3007
-	if (!ecrire_fichier($f, $contenu)) {
3008
-		return $css;
3009
-	}
3006
+    // ecrire la css
3007
+    if (!ecrire_fichier($f, $contenu)) {
3008
+        return $css;
3009
+    }
3010 3010
 
3011
-	return $f;
3011
+    return $f;
3012 3012
 }
3013 3013
 
3014 3014
 
@@ -3042,24 +3042,24 @@  discard block
 block discarded – undo
3042 3042
  *     Valeur trouvée ou valeur par défaut.
3043 3043
  **/
3044 3044
 function table_valeur(mixed $table, $cle, mixed $defaut = '', $conserver_null = false) {
3045
-	foreach (explode('/', $cle) as $k) {
3046
-		$table = (is_string($table) ? @unserialize($table) : $table);
3045
+    foreach (explode('/', $cle) as $k) {
3046
+        $table = (is_string($table) ? @unserialize($table) : $table);
3047 3047
 
3048
-		if (is_object($table)) {
3049
-			$table = ($k !== '' && isset($table->$k)) ? $table->$k : $defaut;
3050
-		} elseif (is_array($table)) {
3051
-			if ($conserver_null) {
3052
-				$table = array_key_exists($k, $table) ? $table[$k] : $defaut;
3053
-			} else {
3054
-				$table = ($table[$k] ?? $defaut);
3055
-			}
3056
-		} else {
3057
-			$table = $defaut;
3058
-			break;
3059
-		}
3060
-	}
3048
+        if (is_object($table)) {
3049
+            $table = ($k !== '' && isset($table->$k)) ? $table->$k : $defaut;
3050
+        } elseif (is_array($table)) {
3051
+            if ($conserver_null) {
3052
+                $table = array_key_exists($k, $table) ? $table[$k] : $defaut;
3053
+            } else {
3054
+                $table = ($table[$k] ?? $defaut);
3055
+            }
3056
+        } else {
3057
+            $table = $defaut;
3058
+            break;
3059
+        }
3060
+    }
3061 3061
 
3062
-	return $table;
3062
+    return $table;
3063 3063
 }
3064 3064
 
3065 3065
 /**
@@ -3092,22 +3092,22 @@  discard block
 block discarded – undo
3092 3092
  *     - string : expression trouvée.
3093 3093
  **/
3094 3094
 function filtre_match_dist(?string $texte, $expression, $modif = 'UuimsS', $capte = 0) {
3095
-	if ((int) $modif && $capte == 0) {
3096
-		$capte = $modif;
3097
-		$modif = 'UuimsS';
3098
-	}
3099
-	$expression = str_replace('\/', '/', $expression);
3100
-	$expression = str_replace('/', '\/', $expression);
3095
+    if ((int) $modif && $capte == 0) {
3096
+        $capte = $modif;
3097
+        $modif = 'UuimsS';
3098
+    }
3099
+    $expression = str_replace('\/', '/', $expression);
3100
+    $expression = str_replace('/', '\/', $expression);
3101 3101
 
3102
-	if (preg_match('/' . $expression . '/' . $modif, $texte ?? '', $r)) {
3103
-		if (isset($r[$capte])) {
3104
-			return $r[$capte];
3105
-		} else {
3106
-			return true;
3107
-		}
3108
-	}
3102
+    if (preg_match('/' . $expression . '/' . $modif, $texte ?? '', $r)) {
3103
+        if (isset($r[$capte])) {
3104
+            return $r[$capte];
3105
+        } else {
3106
+            return true;
3107
+        }
3108
+    }
3109 3109
 
3110
-	return false;
3110
+    return false;
3111 3111
 }
3112 3112
 
3113 3113
 
@@ -3134,14 +3134,14 @@  discard block
 block discarded – undo
3134 3134
  *     Texte
3135 3135
  **/
3136 3136
 function replace(?string $texte, string $expression, string $replace = '', string $modif = 'UimsS'): string {
3137
-	if (null === $texte) {
3138
-		return '';
3139
-	}
3137
+    if (null === $texte) {
3138
+        return '';
3139
+    }
3140 3140
 
3141
-	$expression = str_replace('\/', '/', $expression);
3142
-	$expression = str_replace('/', '\/', $expression);
3141
+    $expression = str_replace('\/', '/', $expression);
3142
+    $expression = str_replace('/', '\/', $expression);
3143 3143
 
3144
-	return (string) preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3144
+    return (string) preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3145 3145
 }
3146 3146
 
3147 3147
 
@@ -3159,25 +3159,25 @@  discard block
 block discarded – undo
3159 3159
  **/
3160 3160
 function traiter_doublons_documents(&$doublons, $letexte) {
3161 3161
 
3162
-	// Verifier dans le texte & les notes (pas beau, helas)
3163
-	$t = $letexte . $GLOBALS['les_notes'];
3162
+    // Verifier dans le texte & les notes (pas beau, helas)
3163
+    $t = $letexte . $GLOBALS['les_notes'];
3164 3164
 
3165
-	if (
3166
-		strstr($t, 'spip_document_')
3167
-		&& preg_match_all(
3168
-			',<[^>]+\sclass=["\']spip_document_(\d+)[\s"\'],imsS',
3169
-			$t,
3170
-			$matches,
3171
-			PREG_PATTERN_ORDER
3172
-		)
3173
-	) {
3174
-		if (!isset($doublons['documents'])) {
3175
-			$doublons['documents'] = '';
3176
-		}
3177
-		$doublons['documents'] .= ',' . implode(',', $matches[1]);
3178
-	}
3165
+    if (
3166
+        strstr($t, 'spip_document_')
3167
+        && preg_match_all(
3168
+            ',<[^>]+\sclass=["\']spip_document_(\d+)[\s"\'],imsS',
3169
+            $t,
3170
+            $matches,
3171
+            PREG_PATTERN_ORDER
3172
+        )
3173
+    ) {
3174
+        if (!isset($doublons['documents'])) {
3175
+            $doublons['documents'] = '';
3176
+        }
3177
+        $doublons['documents'] .= ',' . implode(',', $matches[1]);
3178
+    }
3179 3179
 
3180
-	return $letexte;
3180
+    return $letexte;
3181 3181
 }
3182 3182
 
3183 3183
 /**
@@ -3191,7 +3191,7 @@  discard block
 block discarded – undo
3191 3191
  * @return string Chaîne vide
3192 3192
  **/
3193 3193
 function vide(mixed $texte) {
3194
-	return '';
3194
+    return '';
3195 3195
 }
3196 3196
 
3197 3197
 //
@@ -3220,23 +3220,23 @@  discard block
 block discarded – undo
3220 3220
  *      Code HTML résultant
3221 3221
  **/
3222 3222
 function env_to_params($env, $ignore_params = []) {
3223
-	$ignore_params = array_merge(
3224
-		['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'],
3225
-		$ignore_params
3226
-	);
3227
-	if (!is_array($env)) {
3228
-		$env = unserialize($env);
3229
-	}
3230
-	$texte = '';
3231
-	if ($env) {
3232
-		foreach ($env as $i => $j) {
3233
-			if (is_string($j) && !in_array($i, $ignore_params)) {
3234
-				$texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3235
-			}
3236
-		}
3237
-	}
3238
-
3239
-	return $texte;
3223
+    $ignore_params = array_merge(
3224
+        ['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'],
3225
+        $ignore_params
3226
+    );
3227
+    if (!is_array($env)) {
3228
+        $env = unserialize($env);
3229
+    }
3230
+    $texte = '';
3231
+    if ($env) {
3232
+        foreach ($env as $i => $j) {
3233
+            if (is_string($j) && !in_array($i, $ignore_params)) {
3234
+                $texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3235
+            }
3236
+        }
3237
+    }
3238
+
3239
+    return $texte;
3240 3240
 }
3241 3241
 
3242 3242
 /**
@@ -3259,23 +3259,23 @@  discard block
 block discarded – undo
3259 3259
  *      Code HTML résultant
3260 3260
  **/
3261 3261
 function env_to_attributs($env, $ignore_params = []) {
3262
-	$ignore_params = array_merge(
3263
-		['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'],
3264
-		$ignore_params
3265
-	);
3266
-	if (!is_array($env)) {
3267
-		$env = unserialize($env);
3268
-	}
3269
-	$texte = '';
3270
-	if ($env) {
3271
-		foreach ($env as $i => $j) {
3272
-			if (is_string($j) && !in_array($i, $ignore_params)) {
3273
-				$texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3274
-			}
3275
-		}
3276
-	}
3262
+    $ignore_params = array_merge(
3263
+        ['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'],
3264
+        $ignore_params
3265
+    );
3266
+    if (!is_array($env)) {
3267
+        $env = unserialize($env);
3268
+    }
3269
+    $texte = '';
3270
+    if ($env) {
3271
+        foreach ($env as $i => $j) {
3272
+            if (is_string($j) && !in_array($i, $ignore_params)) {
3273
+                $texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3274
+            }
3275
+        }
3276
+    }
3277 3277
 
3278
-	return $texte;
3278
+    return $texte;
3279 3279
 }
3280 3280
 
3281 3281
 
@@ -3293,7 +3293,7 @@  discard block
 block discarded – undo
3293 3293
  * @return string Chaînes concaténés
3294 3294
  **/
3295 3295
 function concat(...$args): string {
3296
-	return implode('', $args);
3296
+    return implode('', $args);
3297 3297
 }
3298 3298
 
3299 3299
 
@@ -3313,23 +3313,23 @@  discard block
 block discarded – undo
3313 3313
  *     Contenu du ou des fichiers, concaténé
3314 3314
  **/
3315 3315
 function charge_scripts($files, $script = true) {
3316
-	$flux = '';
3317
-	foreach (is_array($files) ? $files : explode('|', $files) as $file) {
3318
-		if (!is_string($file)) {
3319
-			continue;
3320
-		}
3321
-		if ($script) {
3322
-			$file = preg_match(',^\w+$,', $file) ? "javascript/$file.js" : '';
3323
-		}
3324
-		if ($file) {
3325
-			$path = find_in_path($file);
3326
-			if ($path) {
3327
-				$flux .= spip_file_get_contents($path);
3328
-			}
3329
-		}
3330
-	}
3331
-
3332
-	return $flux;
3316
+    $flux = '';
3317
+    foreach (is_array($files) ? $files : explode('|', $files) as $file) {
3318
+        if (!is_string($file)) {
3319
+            continue;
3320
+        }
3321
+        if ($script) {
3322
+            $file = preg_match(',^\w+$,', $file) ? "javascript/$file.js" : '';
3323
+        }
3324
+        if ($file) {
3325
+            $path = find_in_path($file);
3326
+            if ($path) {
3327
+                $flux .= spip_file_get_contents($path);
3328
+            }
3329
+        }
3330
+    }
3331
+
3332
+    return $flux;
3333 3333
 }
3334 3334
 
3335 3335
 /**
@@ -3340,24 +3340,24 @@  discard block
 block discarded – undo
3340 3340
  * @return string
3341 3341
  */
3342 3342
 function http_img_variante_svg_si_possible($img_file) {
3343
-	// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3344
-	// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3345
-	if (
3346
-		preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3347
-		&& ($variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . '-xx.svg')
3348
-		&& file_exists($variante_svg_generique)
3349
-	) {
3350
-		if (
3351
-			($variante_svg_size = substr($variante_svg_generique, 0, -6) . $m[1] . '.svg')
3352
-			&& file_exists($variante_svg_size)
3353
-		) {
3354
-			$img_file = $variante_svg_size;
3355
-		} else {
3356
-			$img_file = $variante_svg_generique;
3357
-		}
3358
-	}
3359
-
3360
-	return $img_file;
3343
+    // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3344
+    // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3345
+    if (
3346
+        preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3347
+        && ($variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . '-xx.svg')
3348
+        && file_exists($variante_svg_generique)
3349
+    ) {
3350
+        if (
3351
+            ($variante_svg_size = substr($variante_svg_generique, 0, -6) . $m[1] . '.svg')
3352
+            && file_exists($variante_svg_size)
3353
+        ) {
3354
+            $img_file = $variante_svg_size;
3355
+        } else {
3356
+            $img_file = $variante_svg_generique;
3357
+        }
3358
+    }
3359
+
3360
+    return $img_file;
3361 3361
 }
3362 3362
 
3363 3363
 /**
@@ -3378,51 +3378,51 @@  discard block
 block discarded – undo
3378 3378
  */
3379 3379
 function http_img_pack($img, $alt, $atts = '', $title = '', $options = []) {
3380 3380
 
3381
-	$img_file = $img;
3382
-	if ($p = strpos($img_file, '?')) {
3383
-		$img_file = substr($img_file, 0, $p);
3384
-	}
3385
-	if (!isset($options['chemin_image']) || $options['chemin_image'] == true) {
3386
-		$img_file = chemin_image($img);
3387
-	}
3388
-	else {
3389
-		if (!isset($options['variante_svg_si_possible']) || $options['variante_svg_si_possible'] == true) {
3390
-			$img_file = http_img_variante_svg_si_possible($img_file);
3391
-		}
3392
-	}
3393
-	if (stripos($atts, 'width') === false) {
3394
-		// utiliser directement l'info de taille presente dans le nom
3395
-		if (
3396
-			(!isset($options['utiliser_suffixe_size']) || $options['utiliser_suffixe_size'] == true || str_contains($img_file, '-xx.svg'))
3397
-			&& (preg_match(',-(\d+)[.](png|gif|svg)$,', $img, $regs) || preg_match(',\?(\d+)px$,', $img, $regs))
3398
-		) {
3399
-			$largeur = $hauteur = (int) $regs[1];
3400
-		} else {
3401
-			$taille = taille_image($img_file);
3402
-			[$hauteur, $largeur] = $taille;
3403
-			if (!$hauteur || !$largeur) {
3404
-				return '';
3405
-			}
3406
-		}
3407
-		$atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3408
-	}
3409
-
3410
-	if (file_exists($img_file)) {
3411
-		$img_file = timestamp($img_file);
3412
-	}
3413
-	if ($alt === false) {
3414
-		$alt = '';
3415
-	}
3416
-	elseif ($alt || $alt === '') {
3417
-		$alt = " alt='" . attribut_html($alt) . "'";
3418
-	}
3419
-	else {
3420
-		$alt = " alt='" . attribut_html($title) . "'";
3421
-	}
3422
-	return "<img src='" . attribut_html($img_file) . "'$alt"
3423
-	. ($title ? ' title="' . attribut_html($title) . '"' : '')
3424
-	. ' ' . ltrim($atts)
3425
-	. ' />';
3381
+    $img_file = $img;
3382
+    if ($p = strpos($img_file, '?')) {
3383
+        $img_file = substr($img_file, 0, $p);
3384
+    }
3385
+    if (!isset($options['chemin_image']) || $options['chemin_image'] == true) {
3386
+        $img_file = chemin_image($img);
3387
+    }
3388
+    else {
3389
+        if (!isset($options['variante_svg_si_possible']) || $options['variante_svg_si_possible'] == true) {
3390
+            $img_file = http_img_variante_svg_si_possible($img_file);
3391
+        }
3392
+    }
3393
+    if (stripos($atts, 'width') === false) {
3394
+        // utiliser directement l'info de taille presente dans le nom
3395
+        if (
3396
+            (!isset($options['utiliser_suffixe_size']) || $options['utiliser_suffixe_size'] == true || str_contains($img_file, '-xx.svg'))
3397
+            && (preg_match(',-(\d+)[.](png|gif|svg)$,', $img, $regs) || preg_match(',\?(\d+)px$,', $img, $regs))
3398
+        ) {
3399
+            $largeur = $hauteur = (int) $regs[1];
3400
+        } else {
3401
+            $taille = taille_image($img_file);
3402
+            [$hauteur, $largeur] = $taille;
3403
+            if (!$hauteur || !$largeur) {
3404
+                return '';
3405
+            }
3406
+        }
3407
+        $atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3408
+    }
3409
+
3410
+    if (file_exists($img_file)) {
3411
+        $img_file = timestamp($img_file);
3412
+    }
3413
+    if ($alt === false) {
3414
+        $alt = '';
3415
+    }
3416
+    elseif ($alt || $alt === '') {
3417
+        $alt = " alt='" . attribut_html($alt) . "'";
3418
+    }
3419
+    else {
3420
+        $alt = " alt='" . attribut_html($title) . "'";
3421
+    }
3422
+    return "<img src='" . attribut_html($img_file) . "'$alt"
3423
+    . ($title ? ' title="' . attribut_html($title) . '"' : '')
3424
+    . ' ' . ltrim($atts)
3425
+    . ' />';
3426 3426
 }
3427 3427
 
3428 3428
 /**
@@ -3434,70 +3434,70 @@  discard block
 block discarded – undo
3434 3434
  * @return string
3435 3435
  */
3436 3436
 function http_style_background($img, $att = '', $size = null) {
3437
-	if ($size && is_numeric($size)) {
3438
-		$size = trim($size) . 'px';
3439
-	}
3440
-	return " style='background" .
3441
-		($att ? '' : '-image') . ': url("' . chemin_image($img) . '")' . ($att ? (' ' . $att) : '') . ';'
3442
-		. ($size ? "background-size:{$size};" : '')
3443
-		. "'";
3437
+    if ($size && is_numeric($size)) {
3438
+        $size = trim($size) . 'px';
3439
+    }
3440
+    return " style='background" .
3441
+        ($att ? '' : '-image') . ': url("' . chemin_image($img) . '")' . ($att ? (' ' . $att) : '') . ';'
3442
+        . ($size ? "background-size:{$size};" : '')
3443
+        . "'";
3444 3444
 }
3445 3445
 
3446 3446
 
3447 3447
 function helper_filtre_balise_img_svg_arguments($alt_or_size, $class_or_size, $size) {
3448
-	$args = [$alt_or_size, $class_or_size, $size];
3449
-	while (is_null(end($args)) && count($args)) {
3450
-		array_pop($args);
3451
-	}
3452
-	if ($args === []) {
3453
-		return [null, null, null];
3454
-	}
3455
-	if (count($args) < 3) {
3456
-		$maybe_size = array_pop($args);
3457
-		// @2x
3458
-		// @1.5x
3459
-		// 512
3460
-		// 512x*
3461
-		// 512x300
3462
-		if (
3463
-			!strlen((string) $maybe_size)
3464
-			|| !preg_match(',^(@\d+(\.\d+)?x|\d+(x\*)?|\d+x\d+)$,', trim((string) $maybe_size))
3465
-		) {
3466
-			$args[] = $maybe_size;
3467
-			$maybe_size = null;
3468
-		}
3469
-		while (count($args) < 2) {
3470
-			$args[] = null; // default alt or class
3471
-		}
3472
-		$args[] = $maybe_size;
3473
-	}
3474
-	return $args;
3448
+    $args = [$alt_or_size, $class_or_size, $size];
3449
+    while (is_null(end($args)) && count($args)) {
3450
+        array_pop($args);
3451
+    }
3452
+    if ($args === []) {
3453
+        return [null, null, null];
3454
+    }
3455
+    if (count($args) < 3) {
3456
+        $maybe_size = array_pop($args);
3457
+        // @2x
3458
+        // @1.5x
3459
+        // 512
3460
+        // 512x*
3461
+        // 512x300
3462
+        if (
3463
+            !strlen((string) $maybe_size)
3464
+            || !preg_match(',^(@\d+(\.\d+)?x|\d+(x\*)?|\d+x\d+)$,', trim((string) $maybe_size))
3465
+        ) {
3466
+            $args[] = $maybe_size;
3467
+            $maybe_size = null;
3468
+        }
3469
+        while (count($args) < 2) {
3470
+            $args[] = null; // default alt or class
3471
+        }
3472
+        $args[] = $maybe_size;
3473
+    }
3474
+    return $args;
3475 3475
 }
3476 3476
 
3477 3477
 function helper_filtre_balise_img_svg_size($img, $size) {
3478
-	// si size est de la forme '@2x' c'est un coeff multiplicateur sur la densite
3479
-	if (str_starts_with((string) $size, '@') && str_ends_with((string) $size, 'x')) {
3480
-		$coef = (float) substr((string) $size, 1, -1);
3481
-		[$h, $w] = taille_image($img);
3482
-		$height = (int) round($h / $coef);
3483
-		$width = (int) round($w / $coef);
3484
-	}
3485
-	// sinon c'est une valeur seule si image caree ou largeurxhauteur
3486
-	else {
3487
-		$size = explode('x', (string) $size, 2);
3488
-		$size = array_map('trim', $size);
3489
-		$height = $width = (int) array_shift($size);
3490
-
3491
-		if (count($size) && reset($size)) {
3492
-			$height = array_shift($size);
3493
-			if ($height === '*') {
3494
-				[$h, $w] = taille_image($img);
3495
-				$height = (int) round($h * $width / $w);
3496
-			}
3497
-		}
3498
-	}
3499
-
3500
-	return [$width, $height];
3478
+    // si size est de la forme '@2x' c'est un coeff multiplicateur sur la densite
3479
+    if (str_starts_with((string) $size, '@') && str_ends_with((string) $size, 'x')) {
3480
+        $coef = (float) substr((string) $size, 1, -1);
3481
+        [$h, $w] = taille_image($img);
3482
+        $height = (int) round($h / $coef);
3483
+        $width = (int) round($w / $coef);
3484
+    }
3485
+    // sinon c'est une valeur seule si image caree ou largeurxhauteur
3486
+    else {
3487
+        $size = explode('x', (string) $size, 2);
3488
+        $size = array_map('trim', $size);
3489
+        $height = $width = (int) array_shift($size);
3490
+
3491
+        if (count($size) && reset($size)) {
3492
+            $height = array_shift($size);
3493
+            if ($height === '*') {
3494
+                [$h, $w] = taille_image($img);
3495
+                $height = (int) round($h * $width / $w);
3496
+            }
3497
+        }
3498
+    }
3499
+
3500
+    return [$width, $height];
3501 3501
 }
3502 3502
 
3503 3503
 /**
@@ -3533,38 +3533,38 @@  discard block
 block discarded – undo
3533 3533
  */
3534 3534
 function filtre_balise_img_dist($img, $alt = '', $class = null, $size = null) {
3535 3535
 
3536
-	[$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3536
+    [$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3537 3537
 
3538
-	$img = trim((string) $img);
3539
-	if (str_starts_with($img, '<img')) {
3540
-		if (!is_null($alt)) {
3541
-			$img = inserer_attribut($img, 'alt', $alt);
3542
-		}
3543
-		if (!is_null($class)) {
3544
-			$img = strlen((string) $class) ? inserer_attribut($img, 'class', $class) : vider_attribut($img, 'class');
3545
-		}
3546
-	}
3547
-	else {
3548
-		$img = http_img_pack(
3549
-			$img,
3550
-			$alt,
3551
-			$class ? " class='" . attribut_html($class) . "'" : '',
3552
-			'',
3553
-			['chemin_image' => false, 'utiliser_suffixe_size' => false]
3554
-		);
3555
-		if (is_null($alt)) {
3556
-			$img = vider_attribut($img, 'alt');
3557
-		}
3558
-	}
3538
+    $img = trim((string) $img);
3539
+    if (str_starts_with($img, '<img')) {
3540
+        if (!is_null($alt)) {
3541
+            $img = inserer_attribut($img, 'alt', $alt);
3542
+        }
3543
+        if (!is_null($class)) {
3544
+            $img = strlen((string) $class) ? inserer_attribut($img, 'class', $class) : vider_attribut($img, 'class');
3545
+        }
3546
+    }
3547
+    else {
3548
+        $img = http_img_pack(
3549
+            $img,
3550
+            $alt,
3551
+            $class ? " class='" . attribut_html($class) . "'" : '',
3552
+            '',
3553
+            ['chemin_image' => false, 'utiliser_suffixe_size' => false]
3554
+        );
3555
+        if (is_null($alt)) {
3556
+            $img = vider_attribut($img, 'alt');
3557
+        }
3558
+    }
3559 3559
 
3560
-	if ($img && !is_null($size) && strlen($size = trim((string) $size))) {
3561
-		[$width, $height] = helper_filtre_balise_img_svg_size($img, $size);
3560
+    if ($img && !is_null($size) && strlen($size = trim((string) $size))) {
3561
+        [$width, $height] = helper_filtre_balise_img_svg_size($img, $size);
3562 3562
 
3563
-		$img = inserer_attribut($img, 'width', $width);
3564
-		$img = inserer_attribut($img, 'height', $height);
3565
-	}
3563
+        $img = inserer_attribut($img, 'width', $width);
3564
+        $img = inserer_attribut($img, 'height', $height);
3565
+    }
3566 3566
 
3567
-	return $img;
3567
+    return $img;
3568 3568
 }
3569 3569
 
3570 3570
 
@@ -3598,77 +3598,77 @@  discard block
 block discarded – undo
3598 3598
  */
3599 3599
 function filtre_balise_svg_dist($img, $alt = '', $class = null, $size = null) {
3600 3600
 
3601
-	$svg = null;
3602
-	$img = trim($img);
3603
-	$img_file = $img;
3604
-	if (!str_contains($img, '<svg')) {
3605
-		if ($p = strpos($img_file, '?')) {
3606
-			$img_file = substr($img_file, 0, $p);
3607
-		}
3608
-
3609
-		// ne jamais operer directement sur une image distante pour des raisons de perfo
3610
-		// la copie locale a toutes les chances d'etre la ou de resservir
3611
-		if (tester_url_absolue($img_file)) {
3612
-			include_spip('inc/distant');
3613
-			$fichier = copie_locale($img_file);
3614
-			$img_file = ($fichier ? _DIR_RACINE . $fichier : $img_file);
3615
-		}
3616
-
3617
-		if (
3618
-			!$img_file
3619
-			|| !file_exists($img_file)
3620
-			|| !$svg = file_get_contents($img_file)
3621
-		) {
3622
-			return '';
3623
-		}
3624
-	}
3625
-
3626
-	if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) {
3627
-		return '';
3628
-	}
3629
-
3630
-	[$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3631
-
3632
-	$balise_svg = $match[0];
3633
-	$balise_svg_source = $balise_svg;
3634
-
3635
-	// entete XML à supprimer
3636
-	$svg = preg_replace(',^\s*<\?xml[^>]*\?>,', '', $svg);
3637
-
3638
-	// IE est toujours mon ami
3639
-	$balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3640
-
3641
-	// regler la classe
3642
-	if (!is_null($class)) {
3643
-		$balise_svg = strlen((string) $class)
3644
-			? inserer_attribut($balise_svg, 'class', $class)
3645
-			: vider_attribut($balise_svg, 'class');
3646
-	}
3647
-
3648
-	// regler le alt
3649
-	if ($alt) {
3650
-		$balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3651
-		$id = 'img-svg-title-' . substr(md5("$img_file:$svg:$alt"), 0, 4);
3652
-		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3653
-		$title = "<title id=\"$id\">" . entites_html($alt) . "</title>\n";
3654
-		$balise_svg .= $title;
3655
-	}
3656
-	else {
3657
-		$balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3658
-	}
3659
-
3660
-	$svg = str_replace($balise_svg_source, $balise_svg, $svg);
3661
-
3662
-	if (!is_null($size) && strlen($size = trim((string) $size))) {
3663
-		[$width, $height] = helper_filtre_balise_img_svg_size($svg, $size);
3664
-
3665
-		if (!function_exists('svg_redimensionner')) {
3666
-			include_spip('inc/svg');
3667
-		}
3668
-		$svg = svg_redimensionner($svg, $width, $height);
3669
-	}
3670
-
3671
-	return $svg;
3601
+    $svg = null;
3602
+    $img = trim($img);
3603
+    $img_file = $img;
3604
+    if (!str_contains($img, '<svg')) {
3605
+        if ($p = strpos($img_file, '?')) {
3606
+            $img_file = substr($img_file, 0, $p);
3607
+        }
3608
+
3609
+        // ne jamais operer directement sur une image distante pour des raisons de perfo
3610
+        // la copie locale a toutes les chances d'etre la ou de resservir
3611
+        if (tester_url_absolue($img_file)) {
3612
+            include_spip('inc/distant');
3613
+            $fichier = copie_locale($img_file);
3614
+            $img_file = ($fichier ? _DIR_RACINE . $fichier : $img_file);
3615
+        }
3616
+
3617
+        if (
3618
+            !$img_file
3619
+            || !file_exists($img_file)
3620
+            || !$svg = file_get_contents($img_file)
3621
+        ) {
3622
+            return '';
3623
+        }
3624
+    }
3625
+
3626
+    if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) {
3627
+        return '';
3628
+    }
3629
+
3630
+    [$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3631
+
3632
+    $balise_svg = $match[0];
3633
+    $balise_svg_source = $balise_svg;
3634
+
3635
+    // entete XML à supprimer
3636
+    $svg = preg_replace(',^\s*<\?xml[^>]*\?>,', '', $svg);
3637
+
3638
+    // IE est toujours mon ami
3639
+    $balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3640
+
3641
+    // regler la classe
3642
+    if (!is_null($class)) {
3643
+        $balise_svg = strlen((string) $class)
3644
+            ? inserer_attribut($balise_svg, 'class', $class)
3645
+            : vider_attribut($balise_svg, 'class');
3646
+    }
3647
+
3648
+    // regler le alt
3649
+    if ($alt) {
3650
+        $balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3651
+        $id = 'img-svg-title-' . substr(md5("$img_file:$svg:$alt"), 0, 4);
3652
+        $balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3653
+        $title = "<title id=\"$id\">" . entites_html($alt) . "</title>\n";
3654
+        $balise_svg .= $title;
3655
+    }
3656
+    else {
3657
+        $balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3658
+    }
3659
+
3660
+    $svg = str_replace($balise_svg_source, $balise_svg, $svg);
3661
+
3662
+    if (!is_null($size) && strlen($size = trim((string) $size))) {
3663
+        [$width, $height] = helper_filtre_balise_img_svg_size($svg, $size);
3664
+
3665
+        if (!function_exists('svg_redimensionner')) {
3666
+            include_spip('inc/svg');
3667
+        }
3668
+        $svg = svg_redimensionner($svg, $width, $height);
3669
+    }
3670
+
3671
+    return $svg;
3672 3672
 }
3673 3673
 
3674 3674
 /**
@@ -3692,37 +3692,37 @@  discard block
 block discarded – undo
3692 3692
  *         - tout : retourne toutes les informations du plugin actif
3693 3693
  **/
3694 3694
 function filtre_info_plugin_dist($plugin, $type_info, $reload = false) {
3695
-	include_spip('inc/plugin');
3696
-	$plugin = strtoupper($plugin);
3697
-	$plugins_actifs = liste_plugin_actifs();
3698
-
3699
-	if (!$plugin) {
3700
-		return serialize(array_keys($plugins_actifs));
3701
-	} elseif (empty($plugins_actifs[$plugin]) && !$reload) {
3702
-		return '';
3703
-	} elseif ($type_info == 'est_actif' && !$reload) {
3704
-		return $plugins_actifs[$plugin] ? 1 : 0;
3705
-	} elseif (isset($plugins_actifs[$plugin][$type_info]) && !$reload) {
3706
-		return $plugins_actifs[$plugin][$type_info];
3707
-	} else {
3708
-		$get_infos = charger_fonction('get_infos', 'plugins');
3709
-		// On prend en compte les extensions
3710
-		if (!is_dir($plugins_actifs[$plugin]['dir_type'])) {
3711
-			$dir_plugins = constant($plugins_actifs[$plugin]['dir_type']);
3712
-		} else {
3713
-			$dir_plugins = $plugins_actifs[$plugin]['dir_type'];
3714
-		}
3715
-		if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) {
3716
-			return '';
3717
-		}
3718
-		if ($type_info == 'tout') {
3719
-			return $infos;
3720
-		} elseif ($type_info == 'est_actif') {
3721
-			return $infos ? 1 : 0;
3722
-		} else {
3723
-			return (string) $infos[$type_info];
3724
-		}
3725
-	}
3695
+    include_spip('inc/plugin');
3696
+    $plugin = strtoupper($plugin);
3697
+    $plugins_actifs = liste_plugin_actifs();
3698
+
3699
+    if (!$plugin) {
3700
+        return serialize(array_keys($plugins_actifs));
3701
+    } elseif (empty($plugins_actifs[$plugin]) && !$reload) {
3702
+        return '';
3703
+    } elseif ($type_info == 'est_actif' && !$reload) {
3704
+        return $plugins_actifs[$plugin] ? 1 : 0;
3705
+    } elseif (isset($plugins_actifs[$plugin][$type_info]) && !$reload) {
3706
+        return $plugins_actifs[$plugin][$type_info];
3707
+    } else {
3708
+        $get_infos = charger_fonction('get_infos', 'plugins');
3709
+        // On prend en compte les extensions
3710
+        if (!is_dir($plugins_actifs[$plugin]['dir_type'])) {
3711
+            $dir_plugins = constant($plugins_actifs[$plugin]['dir_type']);
3712
+        } else {
3713
+            $dir_plugins = $plugins_actifs[$plugin]['dir_type'];
3714
+        }
3715
+        if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) {
3716
+            return '';
3717
+        }
3718
+        if ($type_info == 'tout') {
3719
+            return $infos;
3720
+        } elseif ($type_info == 'est_actif') {
3721
+            return $infos ? 1 : 0;
3722
+        } else {
3723
+            return (string) $infos[$type_info];
3724
+        }
3725
+    }
3726 3726
 }
3727 3727
 
3728 3728
 
@@ -3749,9 +3749,9 @@  discard block
 block discarded – undo
3749 3749
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
3750 3750
  */
3751 3751
 function puce_changement_statut($id_objet, $statut, $id_rubrique, $type, $ajax = false) {
3752
-	$puce_statut = charger_fonction('puce_statut', 'inc');
3752
+    $puce_statut = charger_fonction('puce_statut', 'inc');
3753 3753
 
3754
-	return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax);
3754
+    return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax);
3755 3755
 }
3756 3756
 
3757 3757
 
@@ -3781,19 +3781,19 @@  discard block
 block discarded – undo
3781 3781
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
3782 3782
  */
3783 3783
 function filtre_puce_statut_dist($statut, $objet, $id_objet = 0, $id_parent = 0) {
3784
-	static $puce_statut = null;
3785
-	if (!$puce_statut) {
3786
-		$puce_statut = charger_fonction('puce_statut', 'inc');
3787
-	}
3784
+    static $puce_statut = null;
3785
+    if (!$puce_statut) {
3786
+        $puce_statut = charger_fonction('puce_statut', 'inc');
3787
+    }
3788 3788
 
3789
-	return $puce_statut(
3790
-		$id_objet,
3791
-		$statut,
3792
-		$id_parent,
3793
-		$objet,
3794
-		false,
3795
-		objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false
3796
-	);
3789
+    return $puce_statut(
3790
+        $id_objet,
3791
+        $statut,
3792
+        $id_parent,
3793
+        $objet,
3794
+        false,
3795
+        objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false
3796
+    );
3797 3797
 }
3798 3798
 
3799 3799
 
@@ -3820,95 +3820,95 @@  discard block
 block discarded – undo
3820 3820
  *   hash du contexte
3821 3821
  */
3822 3822
 function encoder_contexte_ajax($c, $form = '', $emboite = null, $ajaxid = '') {
3823
-	$env = null;
3824
-	if (is_string($c) && @unserialize($c) !== false) {
3825
-		$c = unserialize($c);
3826
-	}
3827
-
3828
-	// supprimer les parametres debut_x
3829
-	// pour que la pagination ajax ne soit pas plantee
3830
-	// si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0,
3831
-	// le debut_x=0 n'existe pas, et on resterait sur 1
3832
-	if (is_array($c)) {
3833
-		foreach (array_keys($c) as $k) {
3834
-			if (str_starts_with($k, 'debut_')) {
3835
-				unset($c[$k]);
3836
-			}
3837
-		}
3838
-	}
3839
-
3840
-	if (!function_exists('calculer_cle_action')) {
3841
-		include_spip('inc/securiser_action');
3842
-	}
3843
-
3844
-	$c = serialize($c);
3845
-	$cle = calculer_cle_action($form . $c);
3846
-	$c = "$cle:$c";
3847
-
3848
-	// on ne stocke pas les contextes dans des fichiers en cache
3849
-	// par defaut, sauf si cette configuration a été forcée
3850
-	// OU que la longueur de l’argument géneré est plus long
3851
-	// que ce qui est toléré.
3852
-	$cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') && _CACHE_CONTEXTES_AJAX);
3853
-	if (!$cache_contextes_ajax) {
3854
-		$env = $c;
3855
-		if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3856
-			$env = gzdeflate($env);
3857
-		}
3858
-		$env = _xor($env);
3859
-		$env = base64_encode($env);
3860
-		$len = strlen($env);
3861
-		// Si l’url est trop longue pour le navigateur
3862
-		$max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR;
3863
-		if ($len > $max_len) {
3864
-			$cache_contextes_ajax = true;
3865
-			spip_log(
3866
-				'Contextes AJAX forces en fichiers !'
3867
-				. ' Cela arrive lorsque la valeur du contexte'
3868
-				. " depasse la longueur maximale autorisee ($max_len). Ici : $len.",
3869
-				_LOG_AVERTISSEMENT
3870
-			);
3871
-		}
3872
-		// Sinon si Suhosin est actif et a une la valeur maximale des variables en GET...
3873
-		elseif (
3874
-			($max_len = @ini_get('suhosin.get.max_value_length'))
3875
-			&& $max_len < $len
3876
-		) {
3877
-			$cache_contextes_ajax = true;
3878
-			spip_log('Contextes AJAX forces en fichiers !'
3879
-				. ' Cela arrive lorsque la valeur du contexte'
3880
-				. ' depasse la longueur maximale autorisee par Suhosin'
3881
-				. " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len."
3882
-				. ' Vous devriez modifier les parametres de Suhosin'
3883
-				. ' pour accepter au moins 1024 caracteres.', _LOG_AVERTISSEMENT);
3884
-		}
3885
-	}
3886
-
3887
-	if ($cache_contextes_ajax) {
3888
-		$dir = sous_repertoire(_DIR_CACHE, 'contextes');
3889
-		// stocker les contextes sur disque et ne passer qu'un hash dans l'url
3890
-		$md5 = md5($c);
3891
-		ecrire_fichier("$dir/c$md5", $c);
3892
-		$env = $md5;
3893
-	}
3894
-
3895
-	if ($emboite === null) {
3896
-		return $env;
3897
-	}
3898
-	if (!trim($emboite)) {
3899
-		return '';
3900
-	}
3901
-	// toujours encoder l'url source dans le bloc ajax
3902
-	$r = self();
3903
-	$r = ' data-origin="' . $r . '"';
3904
-	$class = 'ajaxbloc';
3905
-	if ($ajaxid && is_string($ajaxid)) {
3906
-		// ajaxid est normalement conforme a un nom de classe css
3907
-		// on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3908
-		$class .= ' ajax-id-' . entites_html($ajaxid);
3909
-	}
3910
-
3911
-	return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3823
+    $env = null;
3824
+    if (is_string($c) && @unserialize($c) !== false) {
3825
+        $c = unserialize($c);
3826
+    }
3827
+
3828
+    // supprimer les parametres debut_x
3829
+    // pour que la pagination ajax ne soit pas plantee
3830
+    // si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0,
3831
+    // le debut_x=0 n'existe pas, et on resterait sur 1
3832
+    if (is_array($c)) {
3833
+        foreach (array_keys($c) as $k) {
3834
+            if (str_starts_with($k, 'debut_')) {
3835
+                unset($c[$k]);
3836
+            }
3837
+        }
3838
+    }
3839
+
3840
+    if (!function_exists('calculer_cle_action')) {
3841
+        include_spip('inc/securiser_action');
3842
+    }
3843
+
3844
+    $c = serialize($c);
3845
+    $cle = calculer_cle_action($form . $c);
3846
+    $c = "$cle:$c";
3847
+
3848
+    // on ne stocke pas les contextes dans des fichiers en cache
3849
+    // par defaut, sauf si cette configuration a été forcée
3850
+    // OU que la longueur de l’argument géneré est plus long
3851
+    // que ce qui est toléré.
3852
+    $cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') && _CACHE_CONTEXTES_AJAX);
3853
+    if (!$cache_contextes_ajax) {
3854
+        $env = $c;
3855
+        if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3856
+            $env = gzdeflate($env);
3857
+        }
3858
+        $env = _xor($env);
3859
+        $env = base64_encode($env);
3860
+        $len = strlen($env);
3861
+        // Si l’url est trop longue pour le navigateur
3862
+        $max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR;
3863
+        if ($len > $max_len) {
3864
+            $cache_contextes_ajax = true;
3865
+            spip_log(
3866
+                'Contextes AJAX forces en fichiers !'
3867
+                . ' Cela arrive lorsque la valeur du contexte'
3868
+                . " depasse la longueur maximale autorisee ($max_len). Ici : $len.",
3869
+                _LOG_AVERTISSEMENT
3870
+            );
3871
+        }
3872
+        // Sinon si Suhosin est actif et a une la valeur maximale des variables en GET...
3873
+        elseif (
3874
+            ($max_len = @ini_get('suhosin.get.max_value_length'))
3875
+            && $max_len < $len
3876
+        ) {
3877
+            $cache_contextes_ajax = true;
3878
+            spip_log('Contextes AJAX forces en fichiers !'
3879
+                . ' Cela arrive lorsque la valeur du contexte'
3880
+                . ' depasse la longueur maximale autorisee par Suhosin'
3881
+                . " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len."
3882
+                . ' Vous devriez modifier les parametres de Suhosin'
3883
+                . ' pour accepter au moins 1024 caracteres.', _LOG_AVERTISSEMENT);
3884
+        }
3885
+    }
3886
+
3887
+    if ($cache_contextes_ajax) {
3888
+        $dir = sous_repertoire(_DIR_CACHE, 'contextes');
3889
+        // stocker les contextes sur disque et ne passer qu'un hash dans l'url
3890
+        $md5 = md5($c);
3891
+        ecrire_fichier("$dir/c$md5", $c);
3892
+        $env = $md5;
3893
+    }
3894
+
3895
+    if ($emboite === null) {
3896
+        return $env;
3897
+    }
3898
+    if (!trim($emboite)) {
3899
+        return '';
3900
+    }
3901
+    // toujours encoder l'url source dans le bloc ajax
3902
+    $r = self();
3903
+    $r = ' data-origin="' . $r . '"';
3904
+    $class = 'ajaxbloc';
3905
+    if ($ajaxid && is_string($ajaxid)) {
3906
+        // ajaxid est normalement conforme a un nom de classe css
3907
+        // on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3908
+        $class .= ' ajax-id-' . entites_html($ajaxid);
3909
+    }
3910
+
3911
+    return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3912 3912
 }
3913 3913
 
3914 3914
 /**
@@ -3928,37 +3928,37 @@  discard block
 block discarded – undo
3928 3928
  *   - false : erreur de décodage
3929 3929
  */
3930 3930
 function decoder_contexte_ajax($c, $form = '') {
3931
-	$contexte = null;
3932
-	if (!function_exists('calculer_cle_action')) {
3933
-		include_spip('inc/securiser_action');
3934
-	}
3935
-	if (
3936
-		(defined('_CACHE_CONTEXTES_AJAX') && _CACHE_CONTEXTES_AJAX || strlen($c) == 32)
3937
-		&& ($dir = sous_repertoire(_DIR_CACHE, 'contextes'))
3938
-		&& lire_fichier("$dir/c$c", $contexte)
3939
-	) {
3940
-		$c = $contexte;
3941
-	} else {
3942
-		$c = @base64_decode($c);
3943
-		$c = _xor($c);
3944
-		if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3945
-			$c = @gzinflate($c);
3946
-		}
3947
-	}
3948
-
3949
-	// extraire la signature en debut de contexte
3950
-	// et la verifier avant de deserializer
3951
-	// format : signature:donneesserializees
3952
-	if ($p = strpos((string) $c, ':')) {
3953
-		$cle = substr((string) $c, 0, $p);
3954
-		$c = substr((string) $c, $p + 1);
3955
-
3956
-		if ($cle === calculer_cle_action($form . $c)) {
3957
-			return @unserialize($c);
3958
-		}
3959
-	}
3960
-
3961
-	return false;
3931
+    $contexte = null;
3932
+    if (!function_exists('calculer_cle_action')) {
3933
+        include_spip('inc/securiser_action');
3934
+    }
3935
+    if (
3936
+        (defined('_CACHE_CONTEXTES_AJAX') && _CACHE_CONTEXTES_AJAX || strlen($c) == 32)
3937
+        && ($dir = sous_repertoire(_DIR_CACHE, 'contextes'))
3938
+        && lire_fichier("$dir/c$c", $contexte)
3939
+    ) {
3940
+        $c = $contexte;
3941
+    } else {
3942
+        $c = @base64_decode($c);
3943
+        $c = _xor($c);
3944
+        if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3945
+            $c = @gzinflate($c);
3946
+        }
3947
+    }
3948
+
3949
+    // extraire la signature en debut de contexte
3950
+    // et la verifier avant de deserializer
3951
+    // format : signature:donneesserializees
3952
+    if ($p = strpos((string) $c, ':')) {
3953
+        $cle = substr((string) $c, 0, $p);
3954
+        $c = substr((string) $c, $p + 1);
3955
+
3956
+        if ($cle === calculer_cle_action($form . $c)) {
3957
+            return @unserialize($c);
3958
+        }
3959
+    }
3960
+
3961
+    return false;
3962 3962
 }
3963 3963
 
3964 3964
 
@@ -3976,20 +3976,20 @@  discard block
 block discarded – undo
3976 3976
  *    Message décrypté ou encrypté
3977 3977
  **/
3978 3978
 function _xor($message, $key = null) {
3979
-	if (is_null($key)) {
3980
-		if (!function_exists('calculer_cle_action')) {
3981
-			include_spip('inc/securiser_action');
3982
-		}
3983
-		$key = pack('H*', calculer_cle_action('_xor'));
3984
-	}
3979
+    if (is_null($key)) {
3980
+        if (!function_exists('calculer_cle_action')) {
3981
+            include_spip('inc/securiser_action');
3982
+        }
3983
+        $key = pack('H*', calculer_cle_action('_xor'));
3984
+    }
3985 3985
 
3986
-	$keylen = strlen($key);
3987
-	$messagelen = strlen($message);
3988
-	for ($i = 0; $i < $messagelen; $i++) {
3989
-		$message[$i] = ~($message[$i] ^ $key[$i % $keylen]);
3990
-	}
3986
+    $keylen = strlen($key);
3987
+    $messagelen = strlen($message);
3988
+    for ($i = 0; $i < $messagelen; $i++) {
3989
+        $message[$i] = ~($message[$i] ^ $key[$i % $keylen]);
3990
+    }
3991 3991
 
3992
-	return $message;
3992
+    return $message;
3993 3993
 }
3994 3994
 
3995 3995
 /**
@@ -4003,7 +4003,7 @@  discard block
 block discarded – undo
4003 4003
  * @return string
4004 4004
  */
4005 4005
 function url_reponse_forum($texte) {
4006
- return $texte;
4006
+    return $texte;
4007 4007
 }
4008 4008
 
4009 4009
 /**
@@ -4017,7 +4017,7 @@  discard block
 block discarded – undo
4017 4017
  * @return string
4018 4018
  */
4019 4019
 function url_rss_forum($texte) {
4020
- return $texte;
4020
+    return $texte;
4021 4021
 }
4022 4022
 
4023 4023
 
@@ -4056,37 +4056,37 @@  discard block
 block discarded – undo
4056 4056
  *   Code HTML
4057 4057
  */
4058 4058
 function lien_ou_expose($url, $libelle = null, $on = false, $class = '', $title = '', $rel = '', $evt = '') {
4059
-	if ($on) {
4060
-		$bal = 'strong';
4061
-		$class = '';
4062
-		$att = '';
4063
-		// si $on passe la balise et optionnelement une ou ++classe
4064
-		// a.active span.selected.active etc....
4065
-		if (is_string($on) && (str_starts_with($on, 'a') || str_starts_with($on, 'span') || str_starts_with($on, 'strong'))) {
4066
-			$on = explode('.', $on);
4067
-			// on verifie que c'est exactement une des 3 balises a, span ou strong
4068
-			if (in_array(reset($on), ['a', 'span', 'strong'])) {
4069
-				$bal = array_shift($on);
4070
-				$class = implode(' ', $on);
4071
-				if ($bal == 'a') {
4072
-					$att = 'href="#" ';
4073
-				}
4074
-			}
4075
-		}
4076
-		$att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"';
4077
-	} else {
4078
-		$bal = 'a';
4079
-		$att = "href='$url'"
4080
-			. ($title ? " title='" . attribut_html($title) . "'" : '')
4081
-			. ($class ? " class='" . attribut_html($class) . "'" : '')
4082
-			. ($rel ? " rel='" . attribut_html($rel) . "'" : '')
4083
-			. $evt;
4084
-	}
4085
-	if ($libelle === null) {
4086
-		$libelle = $url;
4087
-	}
4088
-
4089
-	return "<$bal $att>$libelle</$bal>";
4059
+    if ($on) {
4060
+        $bal = 'strong';
4061
+        $class = '';
4062
+        $att = '';
4063
+        // si $on passe la balise et optionnelement une ou ++classe
4064
+        // a.active span.selected.active etc....
4065
+        if (is_string($on) && (str_starts_with($on, 'a') || str_starts_with($on, 'span') || str_starts_with($on, 'strong'))) {
4066
+            $on = explode('.', $on);
4067
+            // on verifie que c'est exactement une des 3 balises a, span ou strong
4068
+            if (in_array(reset($on), ['a', 'span', 'strong'])) {
4069
+                $bal = array_shift($on);
4070
+                $class = implode(' ', $on);
4071
+                if ($bal == 'a') {
4072
+                    $att = 'href="#" ';
4073
+                }
4074
+            }
4075
+        }
4076
+        $att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"';
4077
+    } else {
4078
+        $bal = 'a';
4079
+        $att = "href='$url'"
4080
+            . ($title ? " title='" . attribut_html($title) . "'" : '')
4081
+            . ($class ? " class='" . attribut_html($class) . "'" : '')
4082
+            . ($rel ? " rel='" . attribut_html($rel) . "'" : '')
4083
+            . $evt;
4084
+    }
4085
+    if ($libelle === null) {
4086
+        $libelle = $url;
4087
+    }
4088
+
4089
+    return "<$bal $att>$libelle</$bal>";
4090 4090
 }
4091 4091
 
4092 4092
 
@@ -4103,39 +4103,39 @@  discard block
 block discarded – undo
4103 4103
  * @return string : la chaine de langue finale en utilisant la fonction _T()
4104 4104
  */
4105 4105
 function singulier_ou_pluriel($nb, $chaine_un, $chaine_plusieurs, $var = 'nb', $vars = []) {
4106
-	static $local_singulier_ou_pluriel = [];
4107
-
4108
-	// si nb=0 ou pas de $vars valide on retourne une chaine vide, a traiter par un |sinon
4109
-	if (!is_numeric($nb) || $nb == 0) {
4110
-		return '';
4111
-	}
4112
-	if (!is_array($vars)) {
4113
-		return '';
4114
-	}
4115
-
4116
-	$langue = $GLOBALS['spip_lang'];
4117
-	if (!isset($local_singulier_ou_pluriel[$langue])) {
4118
-		$local_singulier_ou_pluriel[$langue] = false;
4119
-		if (
4120
-			($f = charger_fonction("singulier_ou_pluriel_{$langue}", 'inc', true))
4121
-			|| ($f = charger_fonction('singulier_ou_pluriel', 'inc', true))
4122
-		) {
4123
-			$local_singulier_ou_pluriel[$langue] = $f;
4124
-		}
4125
-	}
4126
-
4127
-	// si on a une surcharge on l'utilise
4128
-	if ($local_singulier_ou_pluriel[$langue]) {
4129
-		return ($local_singulier_ou_pluriel[$langue])($nb, $chaine_un, $chaine_plusieurs, $var, $vars);
4130
-	}
4131
-
4132
-	// sinon traitement par defaut
4133
-	$vars[$var] = $nb;
4134
-	if ($nb >= 2) {
4135
-		return _T($chaine_plusieurs, $vars);
4136
-	} else {
4137
-		return _T($chaine_un, $vars);
4138
-	}
4106
+    static $local_singulier_ou_pluriel = [];
4107
+
4108
+    // si nb=0 ou pas de $vars valide on retourne une chaine vide, a traiter par un |sinon
4109
+    if (!is_numeric($nb) || $nb == 0) {
4110
+        return '';
4111
+    }
4112
+    if (!is_array($vars)) {
4113
+        return '';
4114
+    }
4115
+
4116
+    $langue = $GLOBALS['spip_lang'];
4117
+    if (!isset($local_singulier_ou_pluriel[$langue])) {
4118
+        $local_singulier_ou_pluriel[$langue] = false;
4119
+        if (
4120
+            ($f = charger_fonction("singulier_ou_pluriel_{$langue}", 'inc', true))
4121
+            || ($f = charger_fonction('singulier_ou_pluriel', 'inc', true))
4122
+        ) {
4123
+            $local_singulier_ou_pluriel[$langue] = $f;
4124
+        }
4125
+    }
4126
+
4127
+    // si on a une surcharge on l'utilise
4128
+    if ($local_singulier_ou_pluriel[$langue]) {
4129
+        return ($local_singulier_ou_pluriel[$langue])($nb, $chaine_un, $chaine_plusieurs, $var, $vars);
4130
+    }
4131
+
4132
+    // sinon traitement par defaut
4133
+    $vars[$var] = $nb;
4134
+    if ($nb >= 2) {
4135
+        return _T($chaine_plusieurs, $vars);
4136
+    } else {
4137
+        return _T($chaine_un, $vars);
4138
+    }
4139 4139
 }
4140 4140
 
4141 4141
 
@@ -4163,71 +4163,71 @@  discard block
 block discarded – undo
4163 4163
  */
4164 4164
 function prepare_icone_base($type, $lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') {
4165 4165
 
4166
-	$class_lien = $class_bouton = $class;
4167
-
4168
-	// Normaliser la fonction et compléter la classe en fonction
4169
-	if (in_array($fonction, ['del', 'supprimer.gif'])) {
4170
-		$class_lien .= ' danger';
4171
-		$class_bouton .= ' btn_danger';
4172
-	} elseif ($fonction == 'rien.gif') {
4173
-		$fonction = '';
4174
-	} elseif ($fonction == 'delsafe') {
4175
-		$fonction = 'del';
4176
-	}
4177
-
4178
-	$fond_origine = $fond;
4179
-	// Remappage des icone : article-24.png+new => article-new-24.png
4180
-	if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
4181
-		[$fond, $fonction] = $icone_renommer($fond, $fonction);
4182
-	}
4183
-
4184
-	// Ajouter le type d'objet dans la classe
4185
-	$objet_type = substr(basename((string) $fond), 0, -4);
4186
-	$class_lien .= " $objet_type";
4187
-	$class_bouton .= " $objet_type";
4188
-
4189
-	// texte
4190
-	$alt = attribut_html($texte);
4191
-	$title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
4192
-
4193
-	// Liens : préparer les classes ajax
4194
-	$ajax = '';
4195
-	if ($type === 'lien' && str_contains($class_lien, 'ajax')) {
4196
-		$ajax = 'ajax';
4197
-		if (str_contains($class_lien, 'preload')) {
4198
-			$ajax .= ' preload';
4199
-		}
4200
-		if (str_contains($class_lien, 'nocache')) {
4201
-			$ajax .= ' nocache';
4202
-		}
4203
-		$ajax = " class='$ajax'";
4204
-	}
4205
-
4206
-	// Repérer la taille et l'ajouter dans la classe
4207
-	$size = 24;
4208
-	if (
4209
-		preg_match('/-(\d{1,3})[.](gif|png|svg)$/i', (string) $fond, $match)
4210
-		|| preg_match('/-(\d{1,3})([.](gif|png|svg))?$/i', $fond_origine, $match)
4211
-	) {
4212
-		$size = $match[1];
4213
-	}
4214
-	$class_lien .= " s$size";
4215
-	$class_bouton .= " s$size";
4216
-
4217
-	// Icône
4218
-	$icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4219
-	$icone = '<span class="icone-image' . ($fonction ? " icone-fonction icone-fonction-$fonction" : '') . "\">$icone</span>";
4220
-
4221
-	// Markup final
4222
-	if ($type == 'lien') {
4223
-		return "<span class='icone $class_lien'>"
4224
-		. "<a href='$lien'$title$ajax$javascript>"
4225
-		. $icone
4226
-		. "<b>$texte</b>"
4227
-		. "</a></span>\n";
4228
-	} else {
4229
-		return bouton_action("$icone $texte", $lien, $class_bouton, $javascript, $alt);
4230
-	}
4166
+    $class_lien = $class_bouton = $class;
4167
+
4168
+    // Normaliser la fonction et compléter la classe en fonction
4169
+    if (in_array($fonction, ['del', 'supprimer.gif'])) {
4170
+        $class_lien .= ' danger';
4171
+        $class_bouton .= ' btn_danger';
4172
+    } elseif ($fonction == 'rien.gif') {
4173
+        $fonction = '';
4174
+    } elseif ($fonction == 'delsafe') {
4175
+        $fonction = 'del';
4176
+    }
4177
+
4178
+    $fond_origine = $fond;
4179
+    // Remappage des icone : article-24.png+new => article-new-24.png
4180
+    if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
4181
+        [$fond, $fonction] = $icone_renommer($fond, $fonction);
4182
+    }
4183
+
4184
+    // Ajouter le type d'objet dans la classe
4185
+    $objet_type = substr(basename((string) $fond), 0, -4);
4186
+    $class_lien .= " $objet_type";
4187
+    $class_bouton .= " $objet_type";
4188
+
4189
+    // texte
4190
+    $alt = attribut_html($texte);
4191
+    $title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
4192
+
4193
+    // Liens : préparer les classes ajax
4194
+    $ajax = '';
4195
+    if ($type === 'lien' && str_contains($class_lien, 'ajax')) {
4196
+        $ajax = 'ajax';
4197
+        if (str_contains($class_lien, 'preload')) {
4198
+            $ajax .= ' preload';
4199
+        }
4200
+        if (str_contains($class_lien, 'nocache')) {
4201
+            $ajax .= ' nocache';
4202
+        }
4203
+        $ajax = " class='$ajax'";
4204
+    }
4205
+
4206
+    // Repérer la taille et l'ajouter dans la classe
4207
+    $size = 24;
4208
+    if (
4209
+        preg_match('/-(\d{1,3})[.](gif|png|svg)$/i', (string) $fond, $match)
4210
+        || preg_match('/-(\d{1,3})([.](gif|png|svg))?$/i', $fond_origine, $match)
4211
+    ) {
4212
+        $size = $match[1];
4213
+    }
4214
+    $class_lien .= " s$size";
4215
+    $class_bouton .= " s$size";
4216
+
4217
+    // Icône
4218
+    $icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4219
+    $icone = '<span class="icone-image' . ($fonction ? " icone-fonction icone-fonction-$fonction" : '') . "\">$icone</span>";
4220
+
4221
+    // Markup final
4222
+    if ($type == 'lien') {
4223
+        return "<span class='icone $class_lien'>"
4224
+        . "<a href='$lien'$title$ajax$javascript>"
4225
+        . $icone
4226
+        . "<b>$texte</b>"
4227
+        . "</a></span>\n";
4228
+    } else {
4229
+        return bouton_action("$icone $texte", $lien, $class_bouton, $javascript, $alt);
4230
+    }
4231 4231
 }
4232 4232
 
4233 4233
 /**
@@ -4251,7 +4251,7 @@  discard block
 block discarded – undo
4251 4251
  *     Code HTML du lien
4252 4252
  **/
4253 4253
 function icone_base($lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') {
4254
-	return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript);
4254
+    return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript);
4255 4255
 }
4256 4256
 
4257 4257
 /**
@@ -4286,7 +4286,7 @@  discard block
 block discarded – undo
4286 4286
  *     Code HTML du lien
4287 4287
  **/
4288 4288
 function filtre_icone_verticale_dist($lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') {
4289
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript);
4289
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript);
4290 4290
 }
4291 4291
 
4292 4292
 /**
@@ -4331,7 +4331,7 @@  discard block
 block discarded – undo
4331 4331
  *     Code HTML du lien
4332 4332
  **/
4333 4333
 function filtre_icone_horizontale_dist($lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') {
4334
-	return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript);
4334
+    return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript);
4335 4335
 }
4336 4336
 
4337 4337
 /**
@@ -4362,7 +4362,7 @@  discard block
 block discarded – undo
4362 4362
  *     Code HTML du lien
4363 4363
  **/
4364 4364
 function filtre_bouton_action_horizontal_dist($lien, $texte, $fond, $fonction = '', $class = '', $confirm = '') {
4365
-	return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, $class, $confirm);
4365
+    return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, $class, $confirm);
4366 4366
 }
4367 4367
 
4368 4368
 /**
@@ -4393,7 +4393,7 @@  discard block
 block discarded – undo
4393 4393
  *     Code HTML du lien
4394 4394
  */
4395 4395
 function filtre_icone_dist($lien, $texte, $fond, $align = '', $fonction = '', $class = '', $javascript = '') {
4396
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript);
4396
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript);
4397 4397
 }
4398 4398
 
4399 4399
 
@@ -4415,7 +4415,7 @@  discard block
 block discarded – undo
4415 4415
  * @return array Liste des éléments
4416 4416
  */
4417 4417
 function filtre_explode_dist($a, $b) {
4418
-	return explode($b, (string) $a);
4418
+    return explode($b, (string) $a);
4419 4419
 }
4420 4420
 
4421 4421
 /**
@@ -4436,7 +4436,7 @@  discard block
 block discarded – undo
4436 4436
  * @return string texte
4437 4437
  */
4438 4438
 function filtre_implode_dist($a, $b) {
4439
-	return is_array($a) ? implode($b, $a) : $a;
4439
+    return is_array($a) ? implode($b, $a) : $a;
4440 4440
 }
4441 4441
 
4442 4442
 /**
@@ -4445,22 +4445,22 @@  discard block
 block discarded – undo
4445 4445
  * @return string Code CSS
4446 4446
  */
4447 4447
 function bando_images_background() {
4448
-	include_spip('inc/bandeau');
4449
-	// recuperer tous les boutons et leurs images
4450
-	$boutons = definir_barre_boutons(definir_barre_contexte(), true, false);
4448
+    include_spip('inc/bandeau');
4449
+    // recuperer tous les boutons et leurs images
4450
+    $boutons = definir_barre_boutons(definir_barre_contexte(), true, false);
4451 4451
 
4452
-	$res = '';
4453
-	foreach ($boutons as $page => $detail) {
4454
-		$selecteur = (in_array($page, ['outils_rapides', 'outils_collaboratifs']) ? '' : '.navigation_avec_icones ');
4455
-		foreach ($detail->sousmenu as $souspage => $sousdetail) {
4456
-			if ($sousdetail->icone && strlen(trim((string) $sousdetail->icone))) {
4457
-				$img = http_img_variante_svg_si_possible($sousdetail->icone);
4458
-				$res .= "\n$selecteur.bando2_$souspage {background-image:url($img);}";
4459
-			}
4460
-		}
4461
-	}
4452
+    $res = '';
4453
+    foreach ($boutons as $page => $detail) {
4454
+        $selecteur = (in_array($page, ['outils_rapides', 'outils_collaboratifs']) ? '' : '.navigation_avec_icones ');
4455
+        foreach ($detail->sousmenu as $souspage => $sousdetail) {
4456
+            if ($sousdetail->icone && strlen(trim((string) $sousdetail->icone))) {
4457
+                $img = http_img_variante_svg_si_possible($sousdetail->icone);
4458
+                $res .= "\n$selecteur.bando2_$souspage {background-image:url($img);}";
4459
+            }
4460
+        }
4461
+    }
4462 4462
 
4463
-	return $res;
4463
+    return $res;
4464 4464
 }
4465 4465
 
4466 4466
 /**
@@ -4485,23 +4485,23 @@  discard block
 block discarded – undo
4485 4485
  */
4486 4486
 function bouton_action($libelle, $url, $class = '', $confirm = '', $title = '', $callback = '') {
4487 4487
 
4488
-	// Classes : dispatcher `ajax` sur le formulaire
4489
-	$class_form = '';
4490
-	if (str_contains($class, 'ajax')) {
4491
-		$class_form = 'ajax';
4492
-		$class = str_replace('ajax', '', $class);
4493
-	}
4494
-	$class_btn = 'submit ' . trim($class);
4488
+    // Classes : dispatcher `ajax` sur le formulaire
4489
+    $class_form = '';
4490
+    if (str_contains($class, 'ajax')) {
4491
+        $class_form = 'ajax';
4492
+        $class = str_replace('ajax', '', $class);
4493
+    }
4494
+    $class_btn = 'submit ' . trim($class);
4495 4495
 
4496
-	if ($confirm) {
4497
-		$confirm = 'confirm("' . attribut_html($confirm) . '")';
4498
-		$callback = $callback ? "$confirm?($callback):false" : $confirm;
4499
-	}
4500
-	$onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : '';
4501
-	$title = $title ? " title='$title'" : '';
4496
+    if ($confirm) {
4497
+        $confirm = 'confirm("' . attribut_html($confirm) . '")';
4498
+        $callback = $callback ? "$confirm?($callback):false" : $confirm;
4499
+    }
4500
+    $onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : '';
4501
+    $title = $title ? " title='$title'" : '';
4502 4502
 
4503
-	return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>" . form_hidden($url)
4504
-	. "<button type='submit' class='$class_btn'$title$onclick>$libelle</button></div></form>";
4503
+    return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>" . form_hidden($url)
4504
+    . "<button type='submit' class='$class_btn'$title$onclick>$libelle</button></div></form>";
4505 4505
 }
4506 4506
 
4507 4507
 /**
@@ -4524,98 +4524,98 @@  discard block
 block discarded – undo
4524 4524
  * @return string
4525 4525
  */
4526 4526
 function generer_objet_info($id_objet, string $type_objet, string $info, string $etoile = '', array $params = []): string {
4527
-	static $trouver_table = null;
4528
-	static $objets;
4529
-
4530
-	// On verifie qu'on a tout ce qu'il faut
4531
-	$id_objet = (int) $id_objet;
4532
-	if (!($id_objet && $type_objet && $info)) {
4533
-		return '';
4534
-	}
4535
-
4536
-	// si on a deja note que l'objet n'existe pas, ne pas aller plus loin
4537
-	if (isset($objets[$type_objet]) && $objets[$type_objet] === false) {
4538
-		return '';
4539
-	}
4540
-
4541
-	// Si on demande l'url, on retourne direct la fonction
4542
-	if ($info == 'url') {
4543
-		return generer_objet_url($id_objet, $type_objet, ...$params);
4544
-	}
4545
-
4546
-	// Sinon on va tout chercher dans la table et on garde en memoire
4547
-	$demande_titre = ($info === 'titre');
4548
-	$demande_introduction = ($info === 'introduction');
4549
-
4550
-	// On ne fait la requete que si on a pas deja l'objet ou si on demande le titre mais qu'on ne l'a pas encore
4551
-	if (
4552
-		!isset($objets[$type_objet][$id_objet])
4553
-		|| $demande_titre && !isset($objets[$type_objet][$id_objet]['titre'])
4554
-	) {
4555
-		if (!$trouver_table) {
4556
-			$trouver_table = charger_fonction('trouver_table', 'base');
4557
-		}
4558
-		$desc = $trouver_table(table_objet_sql($type_objet));
4559
-		if (!$desc) {
4560
-			return $objets[$type_objet] = false;
4561
-		}
4562
-
4563
-		// Si on demande le titre, on le gere en interne
4564
-		$champ_titre = '';
4565
-		if ($demande_titre) {
4566
-			// si pas de titre declare mais champ titre, il sera peuple par le select *
4567
-			$champ_titre = (empty($desc['titre'])) ? '' : ', ' . $desc['titre'];
4568
-		}
4569
-		include_spip('base/abstract_sql');
4570
-		include_spip('base/connect_sql');
4571
-		$objets[$type_objet][$id_objet] = sql_fetsel(
4572
-			'*' . $champ_titre,
4573
-			$desc['table_sql'],
4574
-			id_table_objet($type_objet) . ' = ' . (int) $id_objet
4575
-		);
4576
-
4577
-		// Toujours noter la longueur d'introduction, même si pas demandé cette fois-ci
4578
-		$objets[$type_objet]['introduction_longueur'] = $desc['introduction_longueur'] ?? null;
4579
-	}
4580
-
4581
-	// Pour les fonction generer_xxx, si on demande l'introduction,
4582
-	// ajouter la longueur au début des params supplémentaires
4583
-	if ($demande_introduction) {
4584
-		$introduction_longueur = $objets[$type_objet]['introduction_longueur'];
4585
-		array_unshift($params, $introduction_longueur);
4586
-	}
4587
-
4588
-	// Si la fonction generer_TYPE_TRUC existe, on l'utilise pour formater $info_generee
4589
-	if (
4590
-		($generer = charger_fonction("generer_{$type_objet}_{$info}", '', true))
4591
-		|| ($generer = charger_fonction("generer_{$info}_{$type_objet}", '', true))
4592
-	) {
4593
-		$info_generee = $generer($id_objet, $objets[$type_objet][$id_objet], ...$params);
4594
-	}
4595
-	// Si la fonction generer_objet_TRUC existe, on l'utilise pour formater $info_generee
4596
-	elseif (
4597
-		($generer = charger_fonction("generer_objet_{$info}", '', true))
4598
-		|| ($generer = charger_fonction("generer_{$info}_entite", '', true))
4599
-	) {
4600
-		$info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet], ...$params);
4601
-	} // Sinon on prend directement le champ SQL tel quel
4602
-	else {
4603
-		$info_generee = ($objets[$type_objet][$id_objet][$info] ?? '');
4604
-	}
4605
-
4606
-	// On va ensuite appliquer les traitements automatiques si besoin
4607
-	if (!$etoile) {
4608
-		// FIXME: on fournit un ENV minimum avec id et type et connect=''
4609
-		// mais ce fonctionnement est a ameliorer !
4610
-		$info_generee = appliquer_traitement_champ(
4611
-			$info_generee,
4612
-			$info,
4613
-			table_objet($type_objet),
4614
-			['id_objet' => $id_objet, 'objet' => $type_objet, '']
4615
-		);
4616
-	}
4617
-
4618
-	return $info_generee;
4527
+    static $trouver_table = null;
4528
+    static $objets;
4529
+
4530
+    // On verifie qu'on a tout ce qu'il faut
4531
+    $id_objet = (int) $id_objet;
4532
+    if (!($id_objet && $type_objet && $info)) {
4533
+        return '';
4534
+    }
4535
+
4536
+    // si on a deja note que l'objet n'existe pas, ne pas aller plus loin
4537
+    if (isset($objets[$type_objet]) && $objets[$type_objet] === false) {
4538
+        return '';
4539
+    }
4540
+
4541
+    // Si on demande l'url, on retourne direct la fonction
4542
+    if ($info == 'url') {
4543
+        return generer_objet_url($id_objet, $type_objet, ...$params);
4544
+    }
4545
+
4546
+    // Sinon on va tout chercher dans la table et on garde en memoire
4547
+    $demande_titre = ($info === 'titre');
4548
+    $demande_introduction = ($info === 'introduction');
4549
+
4550
+    // On ne fait la requete que si on a pas deja l'objet ou si on demande le titre mais qu'on ne l'a pas encore
4551
+    if (
4552
+        !isset($objets[$type_objet][$id_objet])
4553
+        || $demande_titre && !isset($objets[$type_objet][$id_objet]['titre'])
4554
+    ) {
4555
+        if (!$trouver_table) {
4556
+            $trouver_table = charger_fonction('trouver_table', 'base');
4557
+        }
4558
+        $desc = $trouver_table(table_objet_sql($type_objet));
4559
+        if (!$desc) {
4560
+            return $objets[$type_objet] = false;
4561
+        }
4562
+
4563
+        // Si on demande le titre, on le gere en interne
4564
+        $champ_titre = '';
4565
+        if ($demande_titre) {
4566
+            // si pas de titre declare mais champ titre, il sera peuple par le select *
4567
+            $champ_titre = (empty($desc['titre'])) ? '' : ', ' . $desc['titre'];
4568
+        }
4569
+        include_spip('base/abstract_sql');
4570
+        include_spip('base/connect_sql');
4571
+        $objets[$type_objet][$id_objet] = sql_fetsel(
4572
+            '*' . $champ_titre,
4573
+            $desc['table_sql'],
4574
+            id_table_objet($type_objet) . ' = ' . (int) $id_objet
4575
+        );
4576
+
4577
+        // Toujours noter la longueur d'introduction, même si pas demandé cette fois-ci
4578
+        $objets[$type_objet]['introduction_longueur'] = $desc['introduction_longueur'] ?? null;
4579
+    }
4580
+
4581
+    // Pour les fonction generer_xxx, si on demande l'introduction,
4582
+    // ajouter la longueur au début des params supplémentaires
4583
+    if ($demande_introduction) {
4584
+        $introduction_longueur = $objets[$type_objet]['introduction_longueur'];
4585
+        array_unshift($params, $introduction_longueur);
4586
+    }
4587
+
4588
+    // Si la fonction generer_TYPE_TRUC existe, on l'utilise pour formater $info_generee
4589
+    if (
4590
+        ($generer = charger_fonction("generer_{$type_objet}_{$info}", '', true))
4591
+        || ($generer = charger_fonction("generer_{$info}_{$type_objet}", '', true))
4592
+    ) {
4593
+        $info_generee = $generer($id_objet, $objets[$type_objet][$id_objet], ...$params);
4594
+    }
4595
+    // Si la fonction generer_objet_TRUC existe, on l'utilise pour formater $info_generee
4596
+    elseif (
4597
+        ($generer = charger_fonction("generer_objet_{$info}", '', true))
4598
+        || ($generer = charger_fonction("generer_{$info}_entite", '', true))
4599
+    ) {
4600
+        $info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet], ...$params);
4601
+    } // Sinon on prend directement le champ SQL tel quel
4602
+    else {
4603
+        $info_generee = ($objets[$type_objet][$id_objet][$info] ?? '');
4604
+    }
4605
+
4606
+    // On va ensuite appliquer les traitements automatiques si besoin
4607
+    if (!$etoile) {
4608
+        // FIXME: on fournit un ENV minimum avec id et type et connect=''
4609
+        // mais ce fonctionnement est a ameliorer !
4610
+        $info_generee = appliquer_traitement_champ(
4611
+            $info_generee,
4612
+            $info,
4613
+            table_objet($type_objet),
4614
+            ['id_objet' => $id_objet, 'objet' => $type_objet, '']
4615
+        );
4616
+    }
4617
+
4618
+    return $info_generee;
4619 4619
 }
4620 4620
 
4621 4621
 /**
@@ -4648,34 +4648,34 @@  discard block
 block discarded – undo
4648 4648
  */
4649 4649
 function generer_objet_introduction(int $id_objet, string $type_objet, array $ligne_sql, ?int $introduction_longueur = null, $longueur_ou_suite = null, ?string $suite = null, string $connect = ''): string {
4650 4650
 
4651
-	$descriptif = $ligne_sql['descriptif'] ?? '';
4652
-	$texte = $ligne_sql['texte'] ?? '';
4653
-	// En absence de descriptif, on se rabat sur chapo + texte
4654
-	if (isset($ligne_sql['chapo'])) {
4655
-		$chapo = $ligne_sql['chapo'];
4656
-		$texte = strlen((string) $descriptif) ?
4657
-			'' :
4658
-			"$chapo \n\n $texte";
4659
-	}
4651
+    $descriptif = $ligne_sql['descriptif'] ?? '';
4652
+    $texte = $ligne_sql['texte'] ?? '';
4653
+    // En absence de descriptif, on se rabat sur chapo + texte
4654
+    if (isset($ligne_sql['chapo'])) {
4655
+        $chapo = $ligne_sql['chapo'];
4656
+        $texte = strlen((string) $descriptif) ?
4657
+            '' :
4658
+            "$chapo \n\n $texte";
4659
+    }
4660 4660
 
4661
-	// Longueur en paramètre, sinon celle renseignée dans la description de l'objet, sinon valeur en dur
4662
-	if (!(int) $longueur_ou_suite) {
4663
-		$longueur = (int) ($introduction_longueur ?: 600);
4664
-	} else {
4665
-		$longueur = (int) $longueur_ou_suite;
4666
-	}
4661
+    // Longueur en paramètre, sinon celle renseignée dans la description de l'objet, sinon valeur en dur
4662
+    if (!(int) $longueur_ou_suite) {
4663
+        $longueur = (int) ($introduction_longueur ?: 600);
4664
+    } else {
4665
+        $longueur = (int) $longueur_ou_suite;
4666
+    }
4667 4667
 
4668
-	// On peut optionnellement passer la suite en 1er paramètre de la balise
4669
-	// Ex : #INTRODUCTION{...}
4670
-	if (
4671
-		is_null($suite) && !(int) $longueur_ou_suite
4672
-	) {
4673
-		$suite = $longueur_ou_suite;
4674
-	}
4668
+    // On peut optionnellement passer la suite en 1er paramètre de la balise
4669
+    // Ex : #INTRODUCTION{...}
4670
+    if (
4671
+        is_null($suite) && !(int) $longueur_ou_suite
4672
+    ) {
4673
+        $suite = $longueur_ou_suite;
4674
+    }
4675 4675
 
4676
-	$f = chercher_filtre('introduction');
4676
+    $f = chercher_filtre('introduction');
4677 4677
 
4678
-	return $f($descriptif, $texte, $longueur, $connect, $suite);
4678
+    return $f($descriptif, $texte, $longueur, $connect, $suite);
4679 4679
 }
4680 4680
 
4681 4681
 /**
@@ -4688,49 +4688,49 @@  discard block
 block discarded – undo
4688 4688
  * @return string
4689 4689
  */
4690 4690
 function appliquer_traitement_champ($texte, $champ, $table_objet = '', $env = [], string $connect = '') {
4691
-	if (!$champ) {
4692
-		return $texte;
4693
-	}
4691
+    if (!$champ) {
4692
+        return $texte;
4693
+    }
4694 4694
 
4695
-	// On charge les définitions des traitements (inc/texte et fichiers de fonctions)
4696
-	// car il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4697
-	include_fichiers_fonctions();
4695
+    // On charge les définitions des traitements (inc/texte et fichiers de fonctions)
4696
+    // car il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4697
+    include_fichiers_fonctions();
4698 4698
 
4699
-	$champ = strtoupper($champ);
4700
-	$traitements = $GLOBALS['table_des_traitements'][$champ] ?? false;
4701
-	if (!$traitements || !is_array($traitements)) {
4702
-		return $texte;
4703
-	}
4699
+    $champ = strtoupper($champ);
4700
+    $traitements = $GLOBALS['table_des_traitements'][$champ] ?? false;
4701
+    if (!$traitements || !is_array($traitements)) {
4702
+        return $texte;
4703
+    }
4704 4704
 
4705
-	$traitement = '';
4706
-	if ($table_objet && (!isset($traitements[0]) || count($traitements) > 1)) {
4707
-		// necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4708
-		$table_objet = table_objet($table_objet);
4709
-		if (isset($traitements[$table_objet])) {
4710
-			$traitement = $traitements[$table_objet];
4711
-		}
4712
-	}
4713
-	if (!$traitement && isset($traitements[0])) {
4714
-		$traitement = $traitements[0];
4715
-	}
4716
-	// (sinon prendre le premier de la liste par defaut ?)
4705
+    $traitement = '';
4706
+    if ($table_objet && (!isset($traitements[0]) || count($traitements) > 1)) {
4707
+        // necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4708
+        $table_objet = table_objet($table_objet);
4709
+        if (isset($traitements[$table_objet])) {
4710
+            $traitement = $traitements[$table_objet];
4711
+        }
4712
+    }
4713
+    if (!$traitement && isset($traitements[0])) {
4714
+        $traitement = $traitements[0];
4715
+    }
4716
+    // (sinon prendre le premier de la liste par defaut ?)
4717 4717
 
4718
-	if (!$traitement) {
4719
-		return $texte;
4720
-	}
4718
+    if (!$traitement) {
4719
+        return $texte;
4720
+    }
4721 4721
 
4722
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", (string) $traitement);
4722
+    $traitement = str_replace('%s', "'" . texte_script($texte) . "'", (string) $traitement);
4723 4723
 
4724
-	// signaler qu'on est dans l'espace prive pour les filtres qui se servent de ce flag
4725
-	if (test_espace_prive()) {
4726
-		$env['espace_prive'] = 1;
4727
-	}
4724
+    // signaler qu'on est dans l'espace prive pour les filtres qui se servent de ce flag
4725
+    if (test_espace_prive()) {
4726
+        $env['espace_prive'] = 1;
4727
+    }
4728 4728
 
4729
-	// Fournir $connect et $Pile[0] au traitement si besoin
4730
-	$Pile = [0 => $env];
4731
-	eval("\$texte = $traitement;");
4729
+    // Fournir $connect et $Pile[0] au traitement si besoin
4730
+    $Pile = [0 => $env];
4731
+    eval("\$texte = $traitement;");
4732 4732
 
4733
-	return $texte;
4733
+    return $texte;
4734 4734
 }
4735 4735
 
4736 4736
 
@@ -4741,21 +4741,21 @@  discard block
 block discarded – undo
4741 4741
  * @return string
4742 4742
  */
4743 4743
 function generer_objet_lien(int $id_objet, string $objet, int $longueur = 80, string $connect = ''): string {
4744
-	include_spip('inc/liens');
4745
-	$titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4746
-	// lorsque l'objet n'est plus declare (plugin desactive par exemple)
4747
-	// le raccourcis n'est plus valide
4748
-	$titre = typo($titre['titre'] ?? '');
4749
-	// on essaye avec generer_objet_info ?
4750
-	if (!strlen($titre) && !$connect) {
4751
-		$titre = generer_objet_info($id_objet, $objet, 'titre');
4752
-	}
4753
-	if (!strlen($titre)) {
4754
-		$titre = _T('info_sans_titre');
4755
-	}
4756
-	$url = generer_objet_url($id_objet, $objet, '', '', null, '', $connect);
4744
+    include_spip('inc/liens');
4745
+    $titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4746
+    // lorsque l'objet n'est plus declare (plugin desactive par exemple)
4747
+    // le raccourcis n'est plus valide
4748
+    $titre = typo($titre['titre'] ?? '');
4749
+    // on essaye avec generer_objet_info ?
4750
+    if (!strlen($titre) && !$connect) {
4751
+        $titre = generer_objet_info($id_objet, $objet, 'titre');
4752
+    }
4753
+    if (!strlen($titre)) {
4754
+        $titre = _T('info_sans_titre');
4755
+    }
4756
+    $url = generer_objet_url($id_objet, $objet, '', '', null, '', $connect);
4757 4757
 
4758
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . '</a>';
4758
+    return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . '</a>';
4759 4759
 }
4760 4760
 
4761 4761
 /**
@@ -4771,15 +4771,15 @@  discard block
 block discarded – undo
4771 4771
  * @return string
4772 4772
  */
4773 4773
 function wrap($texte, $wrap) {
4774
-	$balises = extraire_balises($wrap);
4775
-	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4776
-		$texte = $wrap . $texte;
4777
-		$regs = array_reverse($regs[1]);
4778
-		$wrap = '</' . implode('></', $regs) . '>';
4779
-		$texte .= $wrap;
4780
-	}
4774
+    $balises = extraire_balises($wrap);
4775
+    if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4776
+        $texte = $wrap . $texte;
4777
+        $regs = array_reverse($regs[1]);
4778
+        $wrap = '</' . implode('></', $regs) . '>';
4779
+        $texte .= $wrap;
4780
+    }
4781 4781
 
4782
-	return $texte;
4782
+    return $texte;
4783 4783
 }
4784 4784
 
4785 4785
 
@@ -4799,42 +4799,42 @@  discard block
 block discarded – undo
4799 4799
  * @return array|mixed|string
4800 4800
  */
4801 4801
 function filtre_print_dist($u, $join = '<br />', $indent = 0) {
4802
-	if (is_string($u)) {
4803
-		return typo($u);
4804
-	}
4805
-
4806
-	// caster $u en array si besoin
4807
-	if (is_object($u)) {
4808
-		$u = (array)$u;
4809
-	}
4810
-
4811
-	if (is_array($u)) {
4812
-		$out = '';
4813
-		// toutes les cles sont numeriques ?
4814
-		// et aucun enfant n'est un tableau
4815
-		// liste simple separee par des virgules
4816
-		$numeric_keys = array_map('is_numeric', array_keys($u));
4817
-		$array_values = array_map('is_array', $u);
4818
-		$object_values = array_map('is_object', $u);
4819
-		if (
4820
-			array_sum($numeric_keys) == count($numeric_keys)
4821
-			&& !array_sum($array_values)
4822
-			&& !array_sum($object_values)
4823
-		) {
4824
-			return implode(', ', array_map('filtre_print_dist', $u));
4825
-		}
4826
-
4827
-		// sinon on passe a la ligne et on indente
4828
-		$i_str = str_pad('', $indent, ' ');
4829
-		foreach ($u as $k => $v) {
4830
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4831
-		}
4832
-
4833
-		return $out;
4834
-	}
4835
-
4836
-	// on sait pas quoi faire...
4837
-	return $u;
4802
+    if (is_string($u)) {
4803
+        return typo($u);
4804
+    }
4805
+
4806
+    // caster $u en array si besoin
4807
+    if (is_object($u)) {
4808
+        $u = (array)$u;
4809
+    }
4810
+
4811
+    if (is_array($u)) {
4812
+        $out = '';
4813
+        // toutes les cles sont numeriques ?
4814
+        // et aucun enfant n'est un tableau
4815
+        // liste simple separee par des virgules
4816
+        $numeric_keys = array_map('is_numeric', array_keys($u));
4817
+        $array_values = array_map('is_array', $u);
4818
+        $object_values = array_map('is_object', $u);
4819
+        if (
4820
+            array_sum($numeric_keys) == count($numeric_keys)
4821
+            && !array_sum($array_values)
4822
+            && !array_sum($object_values)
4823
+        ) {
4824
+            return implode(', ', array_map('filtre_print_dist', $u));
4825
+        }
4826
+
4827
+        // sinon on passe a la ligne et on indente
4828
+        $i_str = str_pad('', $indent, ' ');
4829
+        foreach ($u as $k => $v) {
4830
+            $out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4831
+        }
4832
+
4833
+        return $out;
4834
+    }
4835
+
4836
+    // on sait pas quoi faire...
4837
+    return $u;
4838 4838
 }
4839 4839
 
4840 4840
 
@@ -4847,10 +4847,10 @@  discard block
 block discarded – undo
4847 4847
  * @return string|array
4848 4848
  */
4849 4849
 function objet_info($objet, $info) {
4850
-	$table = table_objet_sql($objet);
4851
-	$infos = lister_tables_objets_sql($table);
4850
+    $table = table_objet_sql($objet);
4851
+    $infos = lister_tables_objets_sql($table);
4852 4852
 
4853
-	return ($infos[$info] ?? '');
4853
+    return ($infos[$info] ?? '');
4854 4854
 }
4855 4855
 
4856 4856
 /**
@@ -4865,11 +4865,11 @@  discard block
 block discarded – undo
4865 4865
  *     texte traduit du comptage, tel que '3 articles'
4866 4866
  */
4867 4867
 function objet_afficher_nb($nb, $objet) {
4868
-	if (!$nb) {
4869
-		return _T(objet_info($objet, 'info_aucun_objet'));
4870
-	} else {
4871
-		return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), ['nb' => $nb]);
4872
-	}
4868
+    if (!$nb) {
4869
+        return _T(objet_info($objet, 'info_aucun_objet'));
4870
+    } else {
4871
+        return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), ['nb' => $nb]);
4872
+    }
4873 4873
 }
4874 4874
 
4875 4875
 /**
@@ -4881,11 +4881,11 @@  discard block
 block discarded – undo
4881 4881
  * @return string
4882 4882
  */
4883 4883
 function objet_icone($objet, $taille = 24, $class = '') {
4884
-	$icone = objet_info($objet, 'icone_objet') . '-' . $taille . '.png';
4885
-	$icone = chemin_image($icone);
4886
-	$balise_img = charger_filtre('balise_img');
4884
+    $icone = objet_info($objet, 'icone_objet') . '-' . $taille . '.png';
4885
+    $icone = chemin_image($icone);
4886
+    $balise_img = charger_filtre('balise_img');
4887 4887
 
4888
-	return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : '';
4888
+    return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : '';
4889 4889
 }
4890 4890
 
4891 4891
 /**
@@ -4906,12 +4906,12 @@  discard block
 block discarded – undo
4906 4906
  * @return string
4907 4907
  */
4908 4908
 function objet_T($objet, $chaine, $args = [], $options = []) {
4909
-	$chaine = explode(':', $chaine);
4910
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, ['force' => false]))) {
4911
-		return $t;
4912
-	}
4913
-	$chaine = implode(':', $chaine);
4914
-	return _T($chaine, $args, $options);
4909
+    $chaine = explode(':', $chaine);
4910
+    if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, ['force' => false]))) {
4911
+        return $t;
4912
+    }
4913
+    $chaine = implode(':', $chaine);
4914
+    return _T($chaine, $args, $options);
4915 4915
 }
4916 4916
 
4917 4917
 /**
@@ -4925,18 +4925,18 @@  discard block
 block discarded – undo
4925 4925
  * @return string      Code HTML
4926 4926
  */
4927 4927
 function insert_head_css_conditionnel($flux) {
4928
-	if (
4929
-		!str_contains($flux, '<!-- insert_head_css -->')
4930
-		&& ($p = strpos($flux, '<!-- insert_head -->'))
4931
-	) {
4932
-		// plutot avant le premier js externe (jquery) pour etre non bloquant
4933
-		if (($p1 = stripos($flux, '<script src=')) && $p1 < $p) {
4934
-			$p = $p1;
4935
-		}
4936
-		$flux = substr_replace($flux, (string) pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
4937
-	}
4928
+    if (
4929
+        !str_contains($flux, '<!-- insert_head_css -->')
4930
+        && ($p = strpos($flux, '<!-- insert_head -->'))
4931
+    ) {
4932
+        // plutot avant le premier js externe (jquery) pour etre non bloquant
4933
+        if (($p1 = stripos($flux, '<script src=')) && $p1 < $p) {
4934
+            $p = $p1;
4935
+        }
4936
+        $flux = substr_replace($flux, (string) pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
4937
+    }
4938 4938
 
4939
-	return $flux;
4939
+    return $flux;
4940 4940
 }
4941 4941
 
4942 4942
 /**
@@ -4959,75 +4959,75 @@  discard block
 block discarded – undo
4959 4959
  * @return string
4960 4960
  */
4961 4961
 function produire_fond_statique($fond, $contexte = [], $options = [], string $connect = '') {
4962
-	if (isset($contexte['format'])) {
4963
-		$extension = $contexte['format'];
4964
-		unset($contexte['format']);
4965
-	} else {
4966
-		$extension = 'html';
4967
-		if (preg_match(',[.](css|js|json|xml|svg)$,', $fond, $m)) {
4968
-			$extension = $m[1];
4969
-		}
4970
-	}
4971
-	// recuperer le contenu produit par le squelette
4972
-	$options['raw'] = true;
4973
-	$cache = recuperer_fond($fond, $contexte, $options, $connect);
4974
-
4975
-	// calculer le nom de la css
4976
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4977
-	$nom_safe = preg_replace(',\W,', '_', str_replace('.', '_', $fond));
4978
-	$contexte_implicite = calculer_contexte_implicite();
4979
-
4980
-	// par defaut on hash selon les contextes qui sont a priori moins variables
4981
-	// mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
4982
-	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4983
-	if (isset($options['hash_on_content']) && $options['hash_on_content']) {
4984
-		$hash = md5((string) ($contexte_implicite['host'] . '::' . $cache));
4985
-	}
4986
-	else {
4987
-		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4988
-		ksort($contexte);
4989
-		$hash = md5($fond . json_encode($contexte_implicite, JSON_THROW_ON_ERROR) . json_encode($contexte, JSON_THROW_ON_ERROR) . $connect);
4990
-	}
4991
-	$filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
4992
-
4993
-	// mettre a jour le fichier si il n'existe pas
4994
-	// ou trop ancien
4995
-	// le dernier fichier produit est toujours suffixe par .last
4996
-	// et recopie sur le fichier cible uniquement si il change
4997
-	if (
4998
-		!file_exists($filename)
4999
-		|| !file_exists($filename . '.last')
5000
-		|| isset($cache['lastmodified']) && $cache['lastmodified'] && filemtime($filename . '.last') < $cache['lastmodified']
5001
-		|| defined('_VAR_MODE') && _VAR_MODE == 'recalcul'
5002
-	) {
5003
-		$contenu = $cache['texte'];
5004
-		// passer les urls en absolu si c'est une css
5005
-		if ($extension == 'css') {
5006
-			$contenu = urls_absolues_css(
5007
-				$contenu,
5008
-				test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond)
5009
-			);
5010
-		}
5011
-
5012
-		$comment = '';
5013
-		// ne pas insérer de commentaire sur certains formats
5014
-		if (!in_array($extension, ['json', 'xml', 'svg'])) {
5015
-			$comment = "/* #PRODUIRE{fond=$fond";
5016
-			foreach ($contexte as $k => $v) {
5017
-				if (is_array($v)) {
5018
-					$v = var_export($v, true);
5019
-				}
5020
-				$comment .= ",$k=$v";
5021
-			}
5022
-			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
5023
-			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
5024
-			$comment .= "}\n   md5:" . md5((string) $contenu) . " */\n";
5025
-		}
5026
-		// et ecrire le fichier si il change
5027
-		ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
5028
-	}
5029
-
5030
-	return timestamp($filename);
4962
+    if (isset($contexte['format'])) {
4963
+        $extension = $contexte['format'];
4964
+        unset($contexte['format']);
4965
+    } else {
4966
+        $extension = 'html';
4967
+        if (preg_match(',[.](css|js|json|xml|svg)$,', $fond, $m)) {
4968
+            $extension = $m[1];
4969
+        }
4970
+    }
4971
+    // recuperer le contenu produit par le squelette
4972
+    $options['raw'] = true;
4973
+    $cache = recuperer_fond($fond, $contexte, $options, $connect);
4974
+
4975
+    // calculer le nom de la css
4976
+    $dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4977
+    $nom_safe = preg_replace(',\W,', '_', str_replace('.', '_', $fond));
4978
+    $contexte_implicite = calculer_contexte_implicite();
4979
+
4980
+    // par defaut on hash selon les contextes qui sont a priori moins variables
4981
+    // mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
4982
+    // reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4983
+    if (isset($options['hash_on_content']) && $options['hash_on_content']) {
4984
+        $hash = md5((string) ($contexte_implicite['host'] . '::' . $cache));
4985
+    }
4986
+    else {
4987
+        unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4988
+        ksort($contexte);
4989
+        $hash = md5($fond . json_encode($contexte_implicite, JSON_THROW_ON_ERROR) . json_encode($contexte, JSON_THROW_ON_ERROR) . $connect);
4990
+    }
4991
+    $filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
4992
+
4993
+    // mettre a jour le fichier si il n'existe pas
4994
+    // ou trop ancien
4995
+    // le dernier fichier produit est toujours suffixe par .last
4996
+    // et recopie sur le fichier cible uniquement si il change
4997
+    if (
4998
+        !file_exists($filename)
4999
+        || !file_exists($filename . '.last')
5000
+        || isset($cache['lastmodified']) && $cache['lastmodified'] && filemtime($filename . '.last') < $cache['lastmodified']
5001
+        || defined('_VAR_MODE') && _VAR_MODE == 'recalcul'
5002
+    ) {
5003
+        $contenu = $cache['texte'];
5004
+        // passer les urls en absolu si c'est une css
5005
+        if ($extension == 'css') {
5006
+            $contenu = urls_absolues_css(
5007
+                $contenu,
5008
+                test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond)
5009
+            );
5010
+        }
5011
+
5012
+        $comment = '';
5013
+        // ne pas insérer de commentaire sur certains formats
5014
+        if (!in_array($extension, ['json', 'xml', 'svg'])) {
5015
+            $comment = "/* #PRODUIRE{fond=$fond";
5016
+            foreach ($contexte as $k => $v) {
5017
+                if (is_array($v)) {
5018
+                    $v = var_export($v, true);
5019
+                }
5020
+                $comment .= ",$k=$v";
5021
+            }
5022
+            // pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
5023
+            // mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
5024
+            $comment .= "}\n   md5:" . md5((string) $contenu) . " */\n";
5025
+        }
5026
+        // et ecrire le fichier si il change
5027
+        ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
5028
+    }
5029
+
5030
+    return timestamp($filename);
5031 5031
 }
5032 5032
 
5033 5033
 /**
@@ -5040,11 +5040,11 @@  discard block
 block discarded – undo
5040 5040
  *    $fichier auquel on a ajouté le timestamp
5041 5041
  */
5042 5042
 function timestamp($fichier) {
5043
-	if (!$fichier || !file_exists($fichier) || !$m = filemtime($fichier)) {
5044
-		return $fichier;
5045
-	}
5043
+    if (!$fichier || !file_exists($fichier) || !$m = filemtime($fichier)) {
5044
+        return $fichier;
5045
+    }
5046 5046
 
5047
-	return "$fichier?$m";
5047
+    return "$fichier?$m";
5048 5048
 }
5049 5049
 
5050 5050
 /**
@@ -5054,11 +5054,11 @@  discard block
 block discarded – undo
5054 5054
  * @return string
5055 5055
  */
5056 5056
 function supprimer_timestamp($url) {
5057
-	if (!str_contains($url, '?')) {
5058
-		return $url;
5059
-	}
5057
+    if (!str_contains($url, '?')) {
5058
+        return $url;
5059
+    }
5060 5060
 
5061
-	return preg_replace(',\?[[:digit:]]+$,', '', $url);
5061
+    return preg_replace(',\?[[:digit:]]+$,', '', $url);
5062 5062
 }
5063 5063
 
5064 5064
 /**
@@ -5073,15 +5073,15 @@  discard block
 block discarded – undo
5073 5073
  * @return string
5074 5074
  */
5075 5075
 function filtre_nettoyer_titre_email_dist($titre) {
5076
-	include_spip('inc/envoyer_mail');
5076
+    include_spip('inc/envoyer_mail');
5077 5077
 
5078
-	$titre = nettoyer_titre_email($titre);
5079
-	// on est dans un squelette : securiser le retour
5080
-	if (str_contains($titre, '<')) {
5081
-		$titre = interdire_scripts($titre);
5082
-	}
5078
+    $titre = nettoyer_titre_email($titre);
5079
+    // on est dans un squelette : securiser le retour
5080
+    if (str_contains($titre, '<')) {
5081
+        $titre = interdire_scripts($titre);
5082
+    }
5083 5083
 
5084
-	return $titre;
5084
+    return $titre;
5085 5085
 }
5086 5086
 
5087 5087
 /**
@@ -5103,27 +5103,27 @@  discard block
 block discarded – undo
5103 5103
  * @return string
5104 5104
  */
5105 5105
 function filtre_chercher_rubrique_dist(
5106
-	$titre,
5107
-	$id_objet,
5108
-	$id_parent,
5109
-	$objet,
5110
-	$id_secteur,
5111
-	$restreint,
5112
-	$actionable = false,
5113
-	$retour_sans_cadre = false
5106
+    $titre,
5107
+    $id_objet,
5108
+    $id_parent,
5109
+    $objet,
5110
+    $id_secteur,
5111
+    $restreint,
5112
+    $actionable = false,
5113
+    $retour_sans_cadre = false
5114 5114
 ) {
5115
-	include_spip('inc/filtres_ecrire');
5115
+    include_spip('inc/filtres_ecrire');
5116 5116
 
5117
-	return chercher_rubrique(
5118
-		$titre,
5119
-		$id_objet,
5120
-		$id_parent,
5121
-		$objet,
5122
-		$id_secteur,
5123
-		$restreint,
5124
-		$actionable,
5125
-		$retour_sans_cadre
5126
-	);
5117
+    return chercher_rubrique(
5118
+        $titre,
5119
+        $id_objet,
5120
+        $id_parent,
5121
+        $objet,
5122
+        $id_secteur,
5123
+        $restreint,
5124
+        $actionable,
5125
+        $retour_sans_cadre
5126
+    );
5127 5127
 }
5128 5128
 
5129 5129
 /**
@@ -5152,56 +5152,56 @@  discard block
 block discarded – undo
5152 5152
  *     Chaîne vide si l'accès est autorisé
5153 5153
  */
5154 5154
 function sinon_interdire_acces($ok = false, $url = '', $statut = 0, $message = null) {
5155
-	if ($ok) {
5156
-		return '';
5157
-	}
5158
-
5159
-	// Vider tous les tampons
5160
-	$level = @ob_get_level();
5161
-	while ($level--) {
5162
-		@ob_end_clean();
5163
-	}
5164
-
5165
-	include_spip('inc/headers');
5166
-
5167
-	// S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
5168
-	if ($url) {
5169
-		redirige_par_entete($url, '', $statut);
5170
-	}
5171
-
5172
-	// ecriture simplifiee avec message en 3eme argument (= statut 403)
5173
-	if (!is_numeric($statut) && is_null($message)) {
5174
-		$message = $statut;
5175
-		$statut = 0;
5176
-	}
5177
-	if (!$message) {
5178
-		$message = '';
5179
-	}
5180
-	$statut = (int) $statut;
5181
-
5182
-	// Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
5183
-	if (test_espace_prive()) {
5184
-		if (!$statut || !in_array($statut, [404, 403])) {
5185
-			$statut = 403;
5186
-		}
5187
-		http_response_code(403);
5188
-		$echec = charger_fonction('403', 'exec');
5189
-		$echec($message);
5190
-	} else {
5191
-		// Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
5192
-		if (!$statut) {
5193
-			$statut = 404;
5194
-		}
5195
-		// Dans tous les cas on modifie l'entité avec ce qui est demandé
5196
-		http_response_code($statut);
5197
-		// Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
5198
-		if ($statut >= 400) {
5199
-			echo recuperer_fond("$statut", ['erreur' => $message]);
5200
-		}
5201
-	}
5202
-
5203
-
5204
-	exit;
5155
+    if ($ok) {
5156
+        return '';
5157
+    }
5158
+
5159
+    // Vider tous les tampons
5160
+    $level = @ob_get_level();
5161
+    while ($level--) {
5162
+        @ob_end_clean();
5163
+    }
5164
+
5165
+    include_spip('inc/headers');
5166
+
5167
+    // S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
5168
+    if ($url) {
5169
+        redirige_par_entete($url, '', $statut);
5170
+    }
5171
+
5172
+    // ecriture simplifiee avec message en 3eme argument (= statut 403)
5173
+    if (!is_numeric($statut) && is_null($message)) {
5174
+        $message = $statut;
5175
+        $statut = 0;
5176
+    }
5177
+    if (!$message) {
5178
+        $message = '';
5179
+    }
5180
+    $statut = (int) $statut;
5181
+
5182
+    // Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
5183
+    if (test_espace_prive()) {
5184
+        if (!$statut || !in_array($statut, [404, 403])) {
5185
+            $statut = 403;
5186
+        }
5187
+        http_response_code(403);
5188
+        $echec = charger_fonction('403', 'exec');
5189
+        $echec($message);
5190
+    } else {
5191
+        // Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
5192
+        if (!$statut) {
5193
+            $statut = 404;
5194
+        }
5195
+        // Dans tous les cas on modifie l'entité avec ce qui est demandé
5196
+        http_response_code($statut);
5197
+        // Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
5198
+        if ($statut >= 400) {
5199
+            echo recuperer_fond("$statut", ['erreur' => $message]);
5200
+        }
5201
+    }
5202
+
5203
+
5204
+    exit;
5205 5205
 }
5206 5206
 
5207 5207
 /**
@@ -5212,11 +5212,11 @@  discard block
 block discarded – undo
5212 5212
  * @return string
5213 5213
  */
5214 5214
 function filtre_compacte_dist($source, $format = null) {
5215
-	if (function_exists('minifier')) {
5216
-		return minifier($source, $format);
5217
-	}
5215
+    if (function_exists('minifier')) {
5216
+        return minifier($source, $format);
5217
+    }
5218 5218
 
5219
-	return $source;
5219
+    return $source;
5220 5220
 }
5221 5221
 
5222 5222
 
@@ -5226,32 +5226,32 @@  discard block
 block discarded – undo
5226 5226
  * @return string
5227 5227
  */
5228 5228
 function spip_affiche_mot_de_passe_masque(#[\SensitiveParameter] ?string $passe, bool $afficher_partiellement = false, ?int $portion_pourcent = null): string {
5229
-	$passe ??= '';
5230
-	$l = strlen($passe);
5231
-
5232
-	if ($l <= 8 || !$afficher_partiellement) {
5233
-		if (!$l) {
5234
-			return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
5235
-		}
5236
-		return str_pad('', $afficher_partiellement ? $l : 16, '*');
5237
-	}
5238
-
5239
-	if (is_null($portion_pourcent)) {
5240
-		if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) {
5241
-			define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20%
5242
-		}
5243
-		$portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT;
5244
-	}
5245
-	if ($portion_pourcent >= 100) {
5246
-		return $passe;
5247
-	}
5248
-	$e = (int) ceil($l * $portion_pourcent / 100 / 2);
5249
-	$e = max($e, 0);
5250
-	$mid = str_pad('', $l - 2 * $e, '*');
5251
-	if ($e > 0 && strlen($mid) > 8) {
5252
-		$mid = '***...***';
5253
-	}
5254
-	return substr($passe, 0, $e) . $mid . ($e > 0 ? substr($passe, -$e) : '');
5229
+    $passe ??= '';
5230
+    $l = strlen($passe);
5231
+
5232
+    if ($l <= 8 || !$afficher_partiellement) {
5233
+        if (!$l) {
5234
+            return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
5235
+        }
5236
+        return str_pad('', $afficher_partiellement ? $l : 16, '*');
5237
+    }
5238
+
5239
+    if (is_null($portion_pourcent)) {
5240
+        if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) {
5241
+            define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20%
5242
+        }
5243
+        $portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT;
5244
+    }
5245
+    if ($portion_pourcent >= 100) {
5246
+        return $passe;
5247
+    }
5248
+    $e = (int) ceil($l * $portion_pourcent / 100 / 2);
5249
+    $e = max($e, 0);
5250
+    $mid = str_pad('', $l - 2 * $e, '*');
5251
+    if ($e > 0 && strlen($mid) > 8) {
5252
+        $mid = '***...***';
5253
+    }
5254
+    return substr($passe, 0, $e) . $mid . ($e > 0 ? substr($passe, -$e) : '');
5255 5255
 }
5256 5256
 
5257 5257
 
@@ -5272,64 +5272,64 @@  discard block
 block discarded – undo
5272 5272
  */
5273 5273
 function identifiant_slug($texte, $type = '', $options = []) {
5274 5274
 
5275
-	$original = $texte;
5276
-	$separateur = ($options['separateur'] ?? '_');
5277
-	$longueur_maxi = ($options['longueur_maxi'] ?? 60);
5278
-	$longueur_mini = ($options['longueur_mini'] ?? 0);
5275
+    $original = $texte;
5276
+    $separateur = ($options['separateur'] ?? '_');
5277
+    $longueur_maxi = ($options['longueur_maxi'] ?? 60);
5278
+    $longueur_mini = ($options['longueur_mini'] ?? 0);
5279 5279
 
5280
-	if (!function_exists('translitteration')) {
5281
-		include_spip('inc/charsets');
5282
-	}
5280
+    if (!function_exists('translitteration')) {
5281
+        include_spip('inc/charsets');
5282
+    }
5283 5283
 
5284
-	// pas de balise html
5285
-	if (str_contains($texte, '<')) {
5286
-		$texte = strip_tags($texte);
5287
-	}
5288
-	if (str_contains($texte, '&')) {
5289
-		$texte = unicode2charset($texte);
5290
-	}
5291
-	// On enlève les espaces indésirables
5292
-	$texte = trim($texte);
5284
+    // pas de balise html
5285
+    if (str_contains($texte, '<')) {
5286
+        $texte = strip_tags($texte);
5287
+    }
5288
+    if (str_contains($texte, '&')) {
5289
+        $texte = unicode2charset($texte);
5290
+    }
5291
+    // On enlève les espaces indésirables
5292
+    $texte = trim($texte);
5293 5293
 
5294
-	// On enlève les accents et cie
5295
-	$texte = translitteration($texte);
5294
+    // On enlève les accents et cie
5295
+    $texte = translitteration($texte);
5296 5296
 
5297
-	// On remplace tout ce qui n'est pas un mot par un séparateur
5298
-	$texte = preg_replace(',[\W_]+,ms', (string) $separateur, $texte);
5297
+    // On remplace tout ce qui n'est pas un mot par un séparateur
5298
+    $texte = preg_replace(',[\W_]+,ms', (string) $separateur, $texte);
5299 5299
 
5300
-	// nettoyer les doubles occurences du separateur si besoin
5301
-	while (str_contains($texte, (string) "$separateur$separateur")) {
5302
-		$texte = str_replace("$separateur$separateur", $separateur, $texte);
5303
-	}
5300
+    // nettoyer les doubles occurences du separateur si besoin
5301
+    while (str_contains($texte, (string) "$separateur$separateur")) {
5302
+        $texte = str_replace("$separateur$separateur", $separateur, $texte);
5303
+    }
5304 5304
 
5305
-	// pas de separateur au debut ni a la fin
5306
-	$texte = trim($texte, $separateur);
5305
+    // pas de separateur au debut ni a la fin
5306
+    $texte = trim($texte, $separateur);
5307 5307
 
5308
-	// en minuscules
5309
-	$texte = strtolower($texte);
5308
+    // en minuscules
5309
+    $texte = strtolower($texte);
5310 5310
 
5311
-	switch ($type) {
5312
-		case 'class':
5313
-		case 'id':
5314
-		case 'anchor':
5315
-			if (preg_match(',^\d,', $texte)) {
5316
-				$texte = substr($type, 0, 1) . $texte;
5317
-			}
5318
-	}
5311
+    switch ($type) {
5312
+        case 'class':
5313
+        case 'id':
5314
+        case 'anchor':
5315
+            if (preg_match(',^\d,', $texte)) {
5316
+                $texte = substr($type, 0, 1) . $texte;
5317
+            }
5318
+    }
5319 5319
 
5320
-	if (strlen($texte) > $longueur_maxi) {
5321
-		$texte = substr($texte, 0, $longueur_maxi);
5322
-	}
5320
+    if (strlen($texte) > $longueur_maxi) {
5321
+        $texte = substr($texte, 0, $longueur_maxi);
5322
+    }
5323 5323
 
5324
-	if (strlen($texte) < $longueur_mini && $longueur_mini < $longueur_maxi) {
5325
-		if (preg_match(',^\d,', $texte)) {
5326
-			$texte = ($type ? substr($type, 0, 1) : 's') . $texte;
5327
-		}
5328
-		$texte .= $separateur . md5($original);
5329
-		$texte = substr($texte, 0, $longueur_mini);
5330
-	}
5324
+    if (strlen($texte) < $longueur_mini && $longueur_mini < $longueur_maxi) {
5325
+        if (preg_match(',^\d,', $texte)) {
5326
+            $texte = ($type ? substr($type, 0, 1) : 's') . $texte;
5327
+        }
5328
+        $texte .= $separateur . md5($original);
5329
+        $texte = substr($texte, 0, $longueur_mini);
5330
+    }
5331 5331
 
5332
-	return $texte;
5332
+    return $texte;
5333 5333
 }
5334 5334
 
5335 5335
 
@@ -5350,11 +5350,11 @@  discard block
 block discarded – undo
5350 5350
  * @exemple `<:info_maximum|label_nettoyer:>`
5351 5351
  */
5352 5352
 function label_nettoyer(string $text, bool $ucfirst = true): string {
5353
-	$label = preg_replace('#([\s:]|\&nbsp;)+$#u', '', $text);
5354
-	if ($ucfirst) {
5355
-		$label = spip_ucfirst($label);
5356
-	}
5357
-	return $label;
5353
+    $label = preg_replace('#([\s:]|\&nbsp;)+$#u', '', $text);
5354
+    if ($ucfirst) {
5355
+        $label = spip_ucfirst($label);
5356
+    }
5357
+    return $label;
5358 5358
 }
5359 5359
 
5360 5360
 /**
@@ -5367,8 +5367,8 @@  discard block
 block discarded – undo
5367 5367
  * @exemple `<:info_maximum|label_ponctuer:>`
5368 5368
  */
5369 5369
 function label_ponctuer(string $text, bool $ucfirst = true): string {
5370
-	$label = label_nettoyer($text, $ucfirst);
5371
-	return _T('label_ponctuer', ['label' => $label]);
5370
+    $label = label_nettoyer($text, $ucfirst);
5371
+    return _T('label_ponctuer', ['label' => $label]);
5372 5372
 }
5373 5373
 
5374 5374
 
@@ -5381,19 +5381,19 @@  discard block
 block discarded – undo
5381 5381
  * @return array
5382 5382
  */
5383 5383
 function helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, $fonction) {
5384
-	if (!in_array($fonction, ['objet_lister_parents', 'objet_lister_enfants', 'objet_lister_parents_par_type', 'objet_lister_enfants_par_type'])) {
5385
-		return [];
5386
-	}
5384
+    if (!in_array($fonction, ['objet_lister_parents', 'objet_lister_enfants', 'objet_lister_parents_par_type', 'objet_lister_enfants_par_type'])) {
5385
+        return [];
5386
+    }
5387 5387
 
5388
-	// compatibilite signature inversee
5389
-	if (is_numeric($objet) && !is_numeric($id_objet)) {
5390
-		[$objet, $id_objet] = [$id_objet, $objet];
5391
-	}
5388
+    // compatibilite signature inversee
5389
+    if (is_numeric($objet) && !is_numeric($id_objet)) {
5390
+        [$objet, $id_objet] = [$id_objet, $objet];
5391
+    }
5392 5392
 
5393
-	if (!function_exists($fonction)) {
5394
-		include_spip('base/objets');
5395
-	}
5396
-	return $fonction($objet, $id_objet);
5393
+    if (!function_exists($fonction)) {
5394
+        include_spip('base/objets');
5395
+    }
5396
+    return $fonction($objet, $id_objet);
5397 5397
 }
5398 5398
 
5399 5399
 
@@ -5408,7 +5408,7 @@  discard block
 block discarded – undo
5408 5408
  * @return array
5409 5409
  */
5410 5410
 function filtre_objet_lister_parents_dist($objet, $id_objet) {
5411
-	return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents');
5411
+    return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents');
5412 5412
 }
5413 5413
 
5414 5414
 /**
@@ -5422,7 +5422,7 @@  discard block
 block discarded – undo
5422 5422
  * @return array
5423 5423
  */
5424 5424
 function filtre_objet_lister_parents_par_type_dist($objet, $id_objet) {
5425
-	return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents_par_type');
5425
+    return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents_par_type');
5426 5426
 }
5427 5427
 
5428 5428
 /**
@@ -5436,7 +5436,7 @@  discard block
 block discarded – undo
5436 5436
  * @return array
5437 5437
  */
5438 5438
 function filtre_objet_lister_enfants_dist($objet, $id_objet) {
5439
-	return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants');
5439
+    return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants');
5440 5440
 }
5441 5441
 
5442 5442
 /**
@@ -5450,5 +5450,5 @@  discard block
 block discarded – undo
5450 5450
  * @return array
5451 5451
  */
5452 5452
 function filtre_objet_lister_enfants_par_type_dist($objet, $id_objet) {
5453
-	return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants_par_type');
5453
+    return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants_par_type');
5454 5454
 }
Please login to merge, or discard this patch.
Spacing   +117 added lines, -118 removed lines patch added patch discarded remove patch
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 	}
96 96
 
97 97
 	include_fichiers_fonctions();
98
-	foreach (['filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc] as $f) {
98
+	foreach (['filtre_'.$fonc, 'filtre_'.$fonc.'_dist', $fonc] as $f) {
99 99
 		trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels
100 100
 		if (is_callable($f)) {
101 101
 			return $f;
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
 	// affichage "GIT [master: abcdef]"
231 231
 	$commit = $desc['commit_short'] ?? $desc['commit'];
232 232
 	if ($desc['branch']) {
233
-		$commit = $desc['branch'] . ': ' . $commit;
233
+		$commit = $desc['branch'].': '.$commit;
234 234
 	}
235 235
 	return "{$desc['vcs']} [$commit]";
236 236
 }
@@ -251,9 +251,9 @@  discard block
 block discarded – undo
251 251
 	}
252 252
 
253 253
 	// version installee par GIT
254
-	if (lire_fichier($dir . '/.git/HEAD', $c)) {
254
+	if (lire_fichier($dir.'/.git/HEAD', $c)) {
255 255
 		$currentHead = trim(substr((string) $c, 4));
256
-		if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
256
+		if (lire_fichier($dir.'/.git/'.$currentHead, $hash)) {
257 257
 			return [
258 258
 				'vcs' => 'GIT',
259 259
 				'branch' => basename($currentHead),
@@ -268,12 +268,12 @@  discard block
 block discarded – undo
268 268
 
269 269
 // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images
270 270
 // et laisser passer les fonctions personnelles baptisees image_...
271
-$GLOBALS['spip_matrice']['image_graver'] = true;//'inc/filtres_images_mini.php';
272
-$GLOBALS['spip_matrice']['image_select'] = true;//'inc/filtres_images_mini.php';
273
-$GLOBALS['spip_matrice']['image_reduire'] = true;//'inc/filtres_images_mini.php';
274
-$GLOBALS['spip_matrice']['image_reduire_par'] = true;//'inc/filtres_images_mini.php';
275
-$GLOBALS['spip_matrice']['image_passe_partout'] = true;//'inc/filtres_images_mini.php';
276
-$GLOBALS['spip_matrice']['image_recadre_avec_fallback'] = true;//'inc/filtres_images_mini.php';
271
+$GLOBALS['spip_matrice']['image_graver'] = true; //'inc/filtres_images_mini.php';
272
+$GLOBALS['spip_matrice']['image_select'] = true; //'inc/filtres_images_mini.php';
273
+$GLOBALS['spip_matrice']['image_reduire'] = true; //'inc/filtres_images_mini.php';
274
+$GLOBALS['spip_matrice']['image_reduire_par'] = true; //'inc/filtres_images_mini.php';
275
+$GLOBALS['spip_matrice']['image_passe_partout'] = true; //'inc/filtres_images_mini.php';
276
+$GLOBALS['spip_matrice']['image_recadre_avec_fallback'] = true; //'inc/filtres_images_mini.php';
277 277
 
278 278
 $GLOBALS['spip_matrice']['couleur_html_to_hex'] = 'inc/filtres_images_mini.php';
279 279
 $GLOBALS['spip_matrice']['couleur_hex_to_hsl'] = 'inc/filtres_images_mini.php';
@@ -432,8 +432,8 @@  discard block
 block discarded – undo
432 432
  */
433 433
 function filtre_debug(mixed $val, $key = null) {
434 434
 	$debug = (
435
-		is_null($key) ? '' : (var_export($key, true) . ' = ')
436
-		) . var_export($val, true);
435
+		is_null($key) ? '' : (var_export($key, true).' = ')
436
+		).var_export($val, true);
437 437
 
438 438
 	include_spip('inc/autoriser');
439 439
 	if (autoriser('webmestre')) {
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
 		$is_file = false;
490 490
 	}
491 491
 	if ($is_file) {
492
-		$is_local_file = function ($path) {
492
+		$is_local_file = function($path) {
493 493
 			if (str_contains($path, '?')) {
494 494
 				$path = supprimer_timestamp($path);
495 495
 				// remove ?24px added by find_in_theme on .svg files
@@ -537,7 +537,7 @@  discard block
 block discarded – undo
537 537
 					&& preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)
538 538
 				) {
539 539
 					$srcover = $match[1];
540
-					$srcover_filter = $filtre("<img src='" . $match[1] . "' />", ...$args);
540
+					$srcover_filter = $filtre("<img src='".$match[1]."' />", ...$args);
541 541
 					$srcover_filter = extraire_attribut($srcover_filter, 'src');
542 542
 					$reduit = str_replace($srcover, $srcover_filter, (string) $reduit);
543 543
 				}
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
 	// " -> &quot; et tout ce genre de choses
937 937
 	$u = $GLOBALS['meta']['pcre_u'];
938 938
 	$texte = str_replace('&nbsp;', ' ', $texte);
939
-	$texte = preg_replace('/\s{2,}/S' . $u, ' ', $texte);
939
+	$texte = preg_replace('/\s{2,}/S'.$u, ' ', $texte);
940 940
 	// ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
941 941
 	$texte = entites_html($texte, false, false);
942 942
 	// mais bien echapper les double quotes !
@@ -998,7 +998,7 @@  discard block
 block discarded – undo
998 998
 		return '';
999 999
 	}
1000 1000
 	return preg_replace(
1001
-		',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1001
+		',^[[:space:]]*([0-9]+)([.)]|'.chr(194).'?'.chr(176).')[[:space:]]+,S',
1002 1002
 		'',
1003 1003
 		$texte
1004 1004
 	);
@@ -1027,7 +1027,7 @@  discard block
 block discarded – undo
1027 1027
 	if (
1028 1028
 		$texte
1029 1029
 		&& preg_match(
1030
-			',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1030
+			',^[[:space:]]*([0-9]+)([.)]|'.chr(194).'?'.chr(176).')[[:space:]]+,S',
1031 1031
 			$texte,
1032 1032
 			$regs
1033 1033
 		)
@@ -1116,7 +1116,7 @@  discard block
 block discarded – undo
1116 1116
  **/
1117 1117
 function textebrut($texte) {
1118 1118
 	$u = $GLOBALS['meta']['pcre_u'];
1119
-	$texte = preg_replace('/\s+/S' . $u, ' ', $texte);
1119
+	$texte = preg_replace('/\s+/S'.$u, ' ', $texte);
1120 1120
 	$texte = preg_replace('/<(p|br)( [^>]*)?>/iS', "\n\n", $texte);
1121 1121
 	$texte = preg_replace("/^\n+/", '', $texte);
1122 1122
 	$texte = preg_replace("/\n+$/", '', $texte);
@@ -1151,7 +1151,7 @@  discard block
 block discarded – undo
1151 1151
 		)
1152 1152
 	) {
1153 1153
 		foreach ($liens[0] as $a) {
1154
-			$rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1154
+			$rel = 'noopener noreferrer '.extraire_attribut($a, 'rel');
1155 1155
 			$ablank = inserer_attribut($a, 'rel', $rel);
1156 1156
 			$ablank = inserer_attribut($ablank, 'target', '_blank');
1157 1157
 			$texte = str_replace($a, $ablank, $texte);
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
 		foreach ($regs[0] as $a) {
1177 1177
 			$rel = extraire_attribut($a, 'rel') ?? '';
1178 1178
 			if (!str_contains($rel, 'nofollow')) {
1179
-				$rel = 'nofollow' . ($rel ? " $rel" : '');
1179
+				$rel = 'nofollow'.($rel ? " $rel" : '');
1180 1180
 				$anofollow = inserer_attribut($a, 'rel', $rel);
1181 1181
 				$texte = str_replace($a, $anofollow, $texte);
1182 1182
 			}
@@ -1206,7 +1206,7 @@  discard block
 block discarded – undo
1206 1206
 	$texte = preg_replace('@</p>@iS', "\n", $texte);
1207 1207
 	$texte = preg_replace("@<p\b.*>@UiS", '<br />', $texte);
1208 1208
 
1209
-	return preg_replace('@^\s*<br />@S' . $u, '', $texte);
1209
+	return preg_replace('@^\s*<br />@S'.$u, '', $texte);
1210 1210
 }
1211 1211
 
1212 1212
 /**
@@ -1294,7 +1294,7 @@  discard block
 block discarded – undo
1294 1294
 
1295 1295
 		// Calcul de la taille et choix de l'unité
1296 1296
 		$affichage = _T(
1297
-			'spip:taille_' . $unites[$puissance] . $suffixe_item,
1297
+			'spip:taille_'.$unites[$puissance].$suffixe_item,
1298 1298
 			[
1299 1299
 				'taille' => round($octets / $kilo ** $puissance, $precisions[$puissance])
1300 1300
 			]
@@ -1328,7 +1328,7 @@  discard block
 block discarded – undo
1328 1328
 	}
1329 1329
 	$u = $GLOBALS['meta']['pcre_u'];
1330 1330
 	if ($textebrut) {
1331
-		$texte = preg_replace([",\n,", ',\s(?=\s),msS' . $u], [' ', ''], textebrut($texte));
1331
+		$texte = preg_replace([",\n,", ',\s(?=\s),msS'.$u], [' ', ''], textebrut($texte));
1332 1332
 	}
1333 1333
 	$texte = texte_backend($texte);
1334 1334
 	$texte = str_replace(["'", '"'], ['&#039;', '&#034;'], $texte);
@@ -1363,7 +1363,7 @@  discard block
 block discarded – undo
1363 1363
 	# un message pour abs_url
1364 1364
 	$GLOBALS['mode_abs_url'] = 'url';
1365 1365
 	$url = trim($url);
1366
-	$r = ',^(?:' . _PROTOCOLES_STD . '):?/?/?$,iS';
1366
+	$r = ',^(?:'._PROTOCOLES_STD.'):?/?/?$,iS';
1367 1367
 
1368 1368
 	return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1369 1369
 }
@@ -1568,7 +1568,7 @@  discard block
 block discarded – undo
1568 1568
 
1569 1569
 	$debut = '';
1570 1570
 	$suite = $texte;
1571
-	while ($t = strpos((string) ('-' . $suite), "\n", 1)) {
1571
+	while ($t = strpos((string) ('-'.$suite), "\n", 1)) {
1572 1572
 		$debut .= substr($suite, 0, $t - 1);
1573 1573
 		$suite = substr($suite, $t);
1574 1574
 		$car = substr($suite, 0, 1);
@@ -1586,7 +1586,7 @@  discard block
 block discarded – undo
1586 1586
 			$suite = substr($suite, strlen($regs[0]));
1587 1587
 		}
1588 1588
 	}
1589
-	$texte = $debut . $suite;
1589
+	$texte = $debut.$suite;
1590 1590
 
1591 1591
 	if ($collecteurModeles) {
1592 1592
 		$texte = $collecteurModeles->retablir($texte);
@@ -1594,7 +1594,7 @@  discard block
 block discarded – undo
1594 1594
 
1595 1595
 	$texte = echappe_retour($texte);
1596 1596
 
1597
-	return $texte . $fin;
1597
+	return $texte.$fin;
1598 1598
 }
1599 1599
 
1600 1600
 
@@ -1863,7 +1863,7 @@  discard block
 block discarded – undo
1863 1863
 	if (is_array($balise)) {
1864 1864
 		array_walk(
1865 1865
 			$balise,
1866
-			function (&$a, $key, $t) {
1866
+			function(&$a, $key, $t) {
1867 1867
 				$a = extraire_attribut($a, $t);
1868 1868
 			},
1869 1869
 			$attribut
@@ -1957,14 +1957,14 @@  discard block
 block discarded – undo
1957 1957
 
1958 1958
 	if ($old !== null) {
1959 1959
 		// Remplacer l'ancien attribut du meme nom
1960
-		$balise = $r[1] . $insert . $r[5];
1960
+		$balise = $r[1].$insert.$r[5];
1961 1961
 	} else {
1962 1962
 		// preferer une balise " />" (comme <img />)
1963 1963
 		if (preg_match(',/>,', $balise)) {
1964
-			$balise = preg_replace(',\s?/>,S', $insert . ' />', $balise, 1);
1964
+			$balise = preg_replace(',\s?/>,S', $insert.' />', $balise, 1);
1965 1965
 		} // sinon une balise <a ...> ... </a>
1966 1966
 		else {
1967
-			$balise = preg_replace(',\s?>,S', $insert . '>', $balise, 1);
1967
+			$balise = preg_replace(',\s?>,S', $insert.'>', $balise, 1);
1968 1968
 		}
1969 1969
 	}
1970 1970
 
@@ -2022,7 +2022,7 @@  discard block
 block discarded – undo
2022 2022
 			in_array($operation, ['ajouter', 'commuter'])
2023 2023
 			&& !$is_class_presente
2024 2024
 		) {
2025
-			$class_new = ltrim(rtrim($class_new ?? '') . ' ' . $c);
2025
+			$class_new = ltrim(rtrim($class_new ?? '').' '.$c);
2026 2026
 		} elseif (
2027 2027
 			in_array($operation, ['supprimer', 'commuter'])
2028 2028
 			&& $is_class_presente
@@ -2092,7 +2092,7 @@  discard block
 block discarded – undo
2092 2092
 // Quelques fonctions de calcul arithmetique
2093 2093
 //
2094 2094
 function floatstr($a) {
2095
-	return str_replace(',', '.', (string)(float) $a);
2095
+	return str_replace(',', '.', (string) (float) $a);
2096 2096
 }
2097 2097
 function strize($f, $a, $b) {
2098 2098
 	return floatstr($f(floatstr($a), floatstr($b)));
@@ -2233,13 +2233,13 @@  discard block
 block discarded – undo
2233 2233
 	if (!defined('_TAGS_NOM_AUTEUR')) {
2234 2234
 		define('_TAGS_NOM_AUTEUR', '');
2235 2235
 	}
2236
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2236
+	$tags_acceptes = array_unique(explode(',', 'multi,'._TAGS_NOM_AUTEUR));
2237 2237
 	foreach ($tags_acceptes as $tag) {
2238 2238
 		if (strlen($tag)) {
2239
-			$remp1[] = '<' . trim($tag) . '>';
2240
-			$remp1[] = '</' . trim($tag) . '>';
2241
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2242
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2239
+			$remp1[] = '<'.trim($tag).'>';
2240
+			$remp1[] = '</'.trim($tag).'>';
2241
+			$remp2[] = '\x60'.trim($tag).'\x61';
2242
+			$remp2[] = '\x60/'.trim($tag).'\x61';
2243 2243
 		}
2244 2244
 	}
2245 2245
 	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
@@ -2358,10 +2358,10 @@  discard block
 block discarded – undo
2358 2358
 	$fichier = basename($url);
2359 2359
 
2360 2360
 	return '<a rel="enclosure"'
2361
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2362
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2363
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2364
-	. '>' . $fichier . '</a>';
2361
+	. ($url ? ' href="'.spip_htmlspecialchars($url).'"' : '')
2362
+	. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2363
+	. ($length ? ' title="'.spip_htmlspecialchars($length).'"' : '')
2364
+	. '>'.$fichier.'</a>';
2365 2365
 }
2366 2366
 
2367 2367
 /**
@@ -2389,9 +2389,9 @@  discard block
 block discarded – undo
2389 2389
 			} # vieux data
2390 2390
 			$fichier = basename($url);
2391 2391
 			$enclosures[] = '<enclosure'
2392
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2393
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2394
-				. ($length ? ' length="' . $length . '"' : '')
2392
+				. ($url ? ' url="'.spip_htmlspecialchars($url).'"' : '')
2393
+				. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2394
+				. ($length ? ' length="'.$length.'"' : '')
2395 2395
 				. ' />';
2396 2396
 		}
2397 2397
 	}
@@ -2417,7 +2417,7 @@  discard block
 block discarded – undo
2417 2417
 		if (extraire_attribut($e, 'rel') == 'tag') {
2418 2418
 			$subjects .= '<dc:subject>'
2419 2419
 				. texte_backend(textebrut($e))
2420
-				. '</dc:subject>' . "\n";
2420
+				. '</dc:subject>'."\n";
2421 2421
 		}
2422 2422
 	}
2423 2423
 
@@ -2453,7 +2453,7 @@  discard block
 block discarded – undo
2453 2453
 	if (is_array($texte)) {
2454 2454
 		array_walk(
2455 2455
 			$texte,
2456
-			function (&$a, $key, $t) {
2456
+			function(&$a, $key, $t) {
2457 2457
 				$a = extraire_balise($a, $t);
2458 2458
 			},
2459 2459
 			$tag
@@ -2501,7 +2501,7 @@  discard block
 block discarded – undo
2501 2501
 	if (is_array($texte)) {
2502 2502
 		array_walk(
2503 2503
 			$texte,
2504
-			function (&$a, $key, $t) {
2504
+			function(&$a, $key, $t) {
2505 2505
 				$a = extraire_balises($a, $t);
2506 2506
 			},
2507 2507
 			$tag
@@ -2634,7 +2634,7 @@  discard block
 block discarded – undo
2634 2634
 		if ($fond != '404') {
2635 2635
 			$contexte = array_shift($p);
2636 2636
 			$contexte['page'] = $fond;
2637
-			$action = preg_replace('/([?]' . preg_quote((string) $fond, '/') . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2637
+			$action = preg_replace('/([?]'.preg_quote((string) $fond, '/').'[^&=]*[0-9]+)(&|$)/', '?&', $action);
2638 2638
 		}
2639 2639
 	}
2640 2640
 	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
@@ -2689,9 +2689,9 @@  discard block
 block discarded – undo
2689 2689
 			. '"'
2690 2690
 			. (is_null($val)
2691 2691
 				? ''
2692
-				: ' value="' . entites_html($val) . '"'
2692
+				: ' value="'.entites_html($val).'"'
2693 2693
 			)
2694
-			. ' type="hidden"' . "\n/>";
2694
+			. ' type="hidden"'."\n/>";
2695 2695
 	}
2696 2696
 
2697 2697
 	return implode('', $hidden);
@@ -2801,7 +2801,7 @@  discard block
 block discarded – undo
2801 2801
 
2802 2802
 	return preg_replace_callback(
2803 2803
 		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2804
-		fn($x) => "url('" . suivre_lien($path, $x[1]) . "')",
2804
+		fn($x) => "url('".suivre_lien($path, $x[1])."')",
2805 2805
 		$contenu
2806 2806
 	);
2807 2807
 }
@@ -2862,14 +2862,14 @@  discard block
 block discarded – undo
2862 2862
 	) {
2863 2863
 		$distant = true;
2864 2864
 		$cssf = parse_url($css);
2865
-		$cssf = $cssf['path'] . ($cssf['query'] ? '?' . $cssf['query'] : '');
2865
+		$cssf = $cssf['path'].($cssf['query'] ? '?'.$cssf['query'] : '');
2866 2866
 		$cssf = preg_replace(',[?:&=],', '_', $cssf);
2867 2867
 	} else {
2868 2868
 		$distant = false;
2869 2869
 		$cssf = $css;
2870 2870
 		// 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2871 2871
 		//propose (rien a faire dans ce cas)
2872
-		$f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2872
+		$f = preg_replace(',(_rtl)?\.css$,i', '_'.$ndir.'.css', $css);
2873 2873
 		if (@file_exists($f)) {
2874 2874
 			return $f;
2875 2875
 		}
@@ -2879,7 +2879,7 @@  discard block
 block discarded – undo
2879 2879
 	$dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2880 2880
 	$f = $dir_var
2881 2881
 		. preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2882
-		. '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2882
+		. '.'.substr(md5($cssf), 0, 4).'_'.$ndir.'.css';
2883 2883
 
2884 2884
 	// la css peut etre distante (url absolue !)
2885 2885
 	$contenu = null;
@@ -2926,8 +2926,8 @@  discard block
 block discarded – undo
2926 2926
 		} // si la css_direction commence par $dir_var on la fait passer pour une absolue
2927 2927
 		elseif (str_starts_with($css_direction, $dir_var)) {
2928 2928
 			$css_direction = substr($css_direction, strlen($dir_var));
2929
-			$src_faux_abs['/@@@@@@/' . $css_direction] = $css_direction;
2930
-			$css_direction = '/@@@@@@/' . $css_direction;
2929
+			$src_faux_abs['/@@@@@@/'.$css_direction] = $css_direction;
2930
+			$css_direction = '/@@@@@@/'.$css_direction;
2931 2931
 		}
2932 2932
 		$src[] = $regs[0][$k];
2933 2933
 		$src_direction_css[] = str_replace($import_css, $css_direction, (string) $regs[0][$k]);
@@ -2976,7 +2976,7 @@  discard block
 block discarded – undo
2976 2976
 
2977 2977
 	$f = basename($css, '.css');
2978 2978
 	$f = sous_repertoire(_DIR_VAR, 'cache-css')
2979
-		. preg_replace(',(.*?)(_rtl|_ltr)?$,', "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
2979
+		. preg_replace(',(.*?)(_rtl|_ltr)?$,', "\\1-urlabs-".substr(md5("$css-urlabs"), 0, 4)."\\2", $f)
2980 2980
 		. '.css';
2981 2981
 
2982 2982
 	if (@filemtime($f) > @filemtime($css) && _VAR_MODE != 'recalcul') {
@@ -2987,7 +2987,7 @@  discard block
 block discarded – undo
2987 2987
 	if ($url_absolue_css == $css) {
2988 2988
 		if (
2989 2989
 			strncmp((string) $GLOBALS['meta']['adresse_site'], $css, $l = strlen((string) $GLOBALS['meta']['adresse_site'])) != 0
2990
-			|| !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
2990
+			|| !lire_fichier(_DIR_RACINE.substr($css, $l), $contenu)
2991 2991
 		) {
2992 2992
 			include_spip('inc/distant');
2993 2993
 			$contenu = recuperer_url($css);
@@ -3099,7 +3099,7 @@  discard block
 block discarded – undo
3099 3099
 	$expression = str_replace('\/', '/', $expression);
3100 3100
 	$expression = str_replace('/', '\/', $expression);
3101 3101
 
3102
-	if (preg_match('/' . $expression . '/' . $modif, $texte ?? '', $r)) {
3102
+	if (preg_match('/'.$expression.'/'.$modif, $texte ?? '', $r)) {
3103 3103
 		if (isset($r[$capte])) {
3104 3104
 			return $r[$capte];
3105 3105
 		} else {
@@ -3141,7 +3141,7 @@  discard block
 block discarded – undo
3141 3141
 	$expression = str_replace('\/', '/', $expression);
3142 3142
 	$expression = str_replace('/', '\/', $expression);
3143 3143
 
3144
-	return (string) preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3144
+	return (string) preg_replace('/'.$expression.'/'.$modif, $replace, $texte);
3145 3145
 }
3146 3146
 
3147 3147
 
@@ -3160,7 +3160,7 @@  discard block
 block discarded – undo
3160 3160
 function traiter_doublons_documents(&$doublons, $letexte) {
3161 3161
 
3162 3162
 	// Verifier dans le texte & les notes (pas beau, helas)
3163
-	$t = $letexte . $GLOBALS['les_notes'];
3163
+	$t = $letexte.$GLOBALS['les_notes'];
3164 3164
 
3165 3165
 	if (
3166 3166
 		strstr($t, 'spip_document_')
@@ -3174,7 +3174,7 @@  discard block
 block discarded – undo
3174 3174
 		if (!isset($doublons['documents'])) {
3175 3175
 			$doublons['documents'] = '';
3176 3176
 		}
3177
-		$doublons['documents'] .= ',' . implode(',', $matches[1]);
3177
+		$doublons['documents'] .= ','.implode(',', $matches[1]);
3178 3178
 	}
3179 3179
 
3180 3180
 	return $letexte;
@@ -3231,7 +3231,7 @@  discard block
 block discarded – undo
3231 3231
 	if ($env) {
3232 3232
 		foreach ($env as $i => $j) {
3233 3233
 			if (is_string($j) && !in_array($i, $ignore_params)) {
3234
-				$texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3234
+				$texte .= "<param name='".attribut_html($i)."'\n\tvalue='".attribut_html($j)."' />";
3235 3235
 			}
3236 3236
 		}
3237 3237
 	}
@@ -3270,7 +3270,7 @@  discard block
 block discarded – undo
3270 3270
 	if ($env) {
3271 3271
 		foreach ($env as $i => $j) {
3272 3272
 			if (is_string($j) && !in_array($i, $ignore_params)) {
3273
-				$texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3273
+				$texte .= attribut_html($i)."='".attribut_html($j)."' ";
3274 3274
 			}
3275 3275
 		}
3276 3276
 	}
@@ -3344,11 +3344,11 @@  discard block
 block discarded – undo
3344 3344
 	// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3345 3345
 	if (
3346 3346
 		preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3347
-		&& ($variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . '-xx.svg')
3347
+		&& ($variante_svg_generique = substr($img_file, 0, -strlen($m[0])).'-xx.svg')
3348 3348
 		&& file_exists($variante_svg_generique)
3349 3349
 	) {
3350 3350
 		if (
3351
-			($variante_svg_size = substr($variante_svg_generique, 0, -6) . $m[1] . '.svg')
3351
+			($variante_svg_size = substr($variante_svg_generique, 0, -6).$m[1].'.svg')
3352 3352
 			&& file_exists($variante_svg_size)
3353 3353
 		) {
3354 3354
 			$img_file = $variante_svg_size;
@@ -3404,7 +3404,7 @@  discard block
 block discarded – undo
3404 3404
 				return '';
3405 3405
 			}
3406 3406
 		}
3407
-		$atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3407
+		$atts .= " width='".$largeur."' height='".$hauteur."'";
3408 3408
 	}
3409 3409
 
3410 3410
 	if (file_exists($img_file)) {
@@ -3414,14 +3414,14 @@  discard block
 block discarded – undo
3414 3414
 		$alt = '';
3415 3415
 	}
3416 3416
 	elseif ($alt || $alt === '') {
3417
-		$alt = " alt='" . attribut_html($alt) . "'";
3417
+		$alt = " alt='".attribut_html($alt)."'";
3418 3418
 	}
3419 3419
 	else {
3420
-		$alt = " alt='" . attribut_html($title) . "'";
3420
+		$alt = " alt='".attribut_html($title)."'";
3421 3421
 	}
3422
-	return "<img src='" . attribut_html($img_file) . "'$alt"
3423
-	. ($title ? ' title="' . attribut_html($title) . '"' : '')
3424
-	. ' ' . ltrim($atts)
3422
+	return "<img src='".attribut_html($img_file)."'$alt"
3423
+	. ($title ? ' title="'.attribut_html($title).'"' : '')
3424
+	. ' '.ltrim($atts)
3425 3425
 	. ' />';
3426 3426
 }
3427 3427
 
@@ -3435,10 +3435,10 @@  discard block
 block discarded – undo
3435 3435
  */
3436 3436
 function http_style_background($img, $att = '', $size = null) {
3437 3437
 	if ($size && is_numeric($size)) {
3438
-		$size = trim($size) . 'px';
3438
+		$size = trim($size).'px';
3439 3439
 	}
3440
-	return " style='background" .
3441
-		($att ? '' : '-image') . ': url("' . chemin_image($img) . '")' . ($att ? (' ' . $att) : '') . ';'
3440
+	return " style='background".
3441
+		($att ? '' : '-image').': url("'.chemin_image($img).'")'.($att ? (' '.$att) : '').';'
3442 3442
 		. ($size ? "background-size:{$size};" : '')
3443 3443
 		. "'";
3444 3444
 }
@@ -3548,7 +3548,7 @@  discard block
 block discarded – undo
3548 3548
 		$img = http_img_pack(
3549 3549
 			$img,
3550 3550
 			$alt,
3551
-			$class ? " class='" . attribut_html($class) . "'" : '',
3551
+			$class ? " class='".attribut_html($class)."'" : '',
3552 3552
 			'',
3553 3553
 			['chemin_image' => false, 'utiliser_suffixe_size' => false]
3554 3554
 		);
@@ -3648,9 +3648,9 @@  discard block
 block discarded – undo
3648 3648
 	// regler le alt
3649 3649
 	if ($alt) {
3650 3650
 		$balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3651
-		$id = 'img-svg-title-' . substr(md5("$img_file:$svg:$alt"), 0, 4);
3651
+		$id = 'img-svg-title-'.substr(md5("$img_file:$svg:$alt"), 0, 4);
3652 3652
 		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3653
-		$title = "<title id=\"$id\">" . entites_html($alt) . "</title>\n";
3653
+		$title = "<title id=\"$id\">".entites_html($alt)."</title>\n";
3654 3654
 		$balise_svg .= $title;
3655 3655
 	}
3656 3656
 	else {
@@ -3842,7 +3842,7 @@  discard block
 block discarded – undo
3842 3842
 	}
3843 3843
 
3844 3844
 	$c = serialize($c);
3845
-	$cle = calculer_cle_action($form . $c);
3845
+	$cle = calculer_cle_action($form.$c);
3846 3846
 	$c = "$cle:$c";
3847 3847
 
3848 3848
 	// on ne stocke pas les contextes dans des fichiers en cache
@@ -3900,15 +3900,15 @@  discard block
 block discarded – undo
3900 3900
 	}
3901 3901
 	// toujours encoder l'url source dans le bloc ajax
3902 3902
 	$r = self();
3903
-	$r = ' data-origin="' . $r . '"';
3903
+	$r = ' data-origin="'.$r.'"';
3904 3904
 	$class = 'ajaxbloc';
3905 3905
 	if ($ajaxid && is_string($ajaxid)) {
3906 3906
 		// ajaxid est normalement conforme a un nom de classe css
3907 3907
 		// on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3908
-		$class .= ' ajax-id-' . entites_html($ajaxid);
3908
+		$class .= ' ajax-id-'.entites_html($ajaxid);
3909 3909
 	}
3910 3910
 
3911
-	return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3911
+	return "<div class='$class' "."data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3912 3912
 }
3913 3913
 
3914 3914
 /**
@@ -3953,7 +3953,7 @@  discard block
 block discarded – undo
3953 3953
 		$cle = substr((string) $c, 0, $p);
3954 3954
 		$c = substr((string) $c, $p + 1);
3955 3955
 
3956
-		if ($cle === calculer_cle_action($form . $c)) {
3956
+		if ($cle === calculer_cle_action($form.$c)) {
3957 3957
 			return @unserialize($c);
3958 3958
 		}
3959 3959
 	}
@@ -4073,13 +4073,13 @@  discard block
 block discarded – undo
4073 4073
 				}
4074 4074
 			}
4075 4075
 		}
4076
-		$att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"';
4076
+		$att .= 'class="'.($class ? attribut_html($class).' ' : '').(defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on').'"';
4077 4077
 	} else {
4078 4078
 		$bal = 'a';
4079 4079
 		$att = "href='$url'"
4080
-			. ($title ? " title='" . attribut_html($title) . "'" : '')
4081
-			. ($class ? " class='" . attribut_html($class) . "'" : '')
4082
-			. ($rel ? " rel='" . attribut_html($rel) . "'" : '')
4080
+			. ($title ? " title='".attribut_html($title)."'" : '')
4081
+			. ($class ? " class='".attribut_html($class)."'" : '')
4082
+			. ($rel ? " rel='".attribut_html($rel)."'" : '')
4083 4083
 			. $evt;
4084 4084
 	}
4085 4085
 	if ($libelle === null) {
@@ -4216,7 +4216,7 @@  discard block
 block discarded – undo
4216 4216
 
4217 4217
 	// Icône
4218 4218
 	$icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4219
-	$icone = '<span class="icone-image' . ($fonction ? " icone-fonction icone-fonction-$fonction" : '') . "\">$icone</span>";
4219
+	$icone = '<span class="icone-image'.($fonction ? " icone-fonction icone-fonction-$fonction" : '')."\">$icone</span>";
4220 4220
 
4221 4221
 	// Markup final
4222 4222
 	if ($type == 'lien') {
@@ -4491,16 +4491,16 @@  discard block
 block discarded – undo
4491 4491
 		$class_form = 'ajax';
4492 4492
 		$class = str_replace('ajax', '', $class);
4493 4493
 	}
4494
-	$class_btn = 'submit ' . trim($class);
4494
+	$class_btn = 'submit '.trim($class);
4495 4495
 
4496 4496
 	if ($confirm) {
4497
-		$confirm = 'confirm("' . attribut_html($confirm) . '")';
4497
+		$confirm = 'confirm("'.attribut_html($confirm).'")';
4498 4498
 		$callback = $callback ? "$confirm?($callback):false" : $confirm;
4499 4499
 	}
4500
-	$onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : '';
4500
+	$onclick = $callback ? " onclick='return ".addcslashes($callback, "'")."'" : '';
4501 4501
 	$title = $title ? " title='$title'" : '';
4502 4502
 
4503
-	return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>" . form_hidden($url)
4503
+	return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>".form_hidden($url)
4504 4504
 	. "<button type='submit' class='$class_btn'$title$onclick>$libelle</button></div></form>";
4505 4505
 }
4506 4506
 
@@ -4564,14 +4564,14 @@  discard block
 block discarded – undo
4564 4564
 		$champ_titre = '';
4565 4565
 		if ($demande_titre) {
4566 4566
 			// si pas de titre declare mais champ titre, il sera peuple par le select *
4567
-			$champ_titre = (empty($desc['titre'])) ? '' : ', ' . $desc['titre'];
4567
+			$champ_titre = (empty($desc['titre'])) ? '' : ', '.$desc['titre'];
4568 4568
 		}
4569 4569
 		include_spip('base/abstract_sql');
4570 4570
 		include_spip('base/connect_sql');
4571 4571
 		$objets[$type_objet][$id_objet] = sql_fetsel(
4572
-			'*' . $champ_titre,
4572
+			'*'.$champ_titre,
4573 4573
 			$desc['table_sql'],
4574
-			id_table_objet($type_objet) . ' = ' . (int) $id_objet
4574
+			id_table_objet($type_objet).' = '.(int) $id_objet
4575 4575
 		);
4576 4576
 
4577 4577
 		// Toujours noter la longueur d'introduction, même si pas demandé cette fois-ci
@@ -4654,8 +4654,7 @@  discard block
 block discarded – undo
4654 4654
 	if (isset($ligne_sql['chapo'])) {
4655 4655
 		$chapo = $ligne_sql['chapo'];
4656 4656
 		$texte = strlen((string) $descriptif) ?
4657
-			'' :
4658
-			"$chapo \n\n $texte";
4657
+			'' : "$chapo \n\n $texte";
4659 4658
 	}
4660 4659
 
4661 4660
 	// Longueur en paramètre, sinon celle renseignée dans la description de l'objet, sinon valeur en dur
@@ -4719,7 +4718,7 @@  discard block
 block discarded – undo
4719 4718
 		return $texte;
4720 4719
 	}
4721 4720
 
4722
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", (string) $traitement);
4721
+	$traitement = str_replace('%s', "'".texte_script($texte)."'", (string) $traitement);
4723 4722
 
4724 4723
 	// signaler qu'on est dans l'espace prive pour les filtres qui se servent de ce flag
4725 4724
 	if (test_espace_prive()) {
@@ -4755,7 +4754,7 @@  discard block
 block discarded – undo
4755 4754
 	}
4756 4755
 	$url = generer_objet_url($id_objet, $objet, '', '', null, '', $connect);
4757 4756
 
4758
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . '</a>';
4757
+	return "<a href='$url' class='$objet'>".couper($titre, $longueur).'</a>';
4759 4758
 }
4760 4759
 
4761 4760
 /**
@@ -4773,9 +4772,9 @@  discard block
 block discarded – undo
4773 4772
 function wrap($texte, $wrap) {
4774 4773
 	$balises = extraire_balises($wrap);
4775 4774
 	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4776
-		$texte = $wrap . $texte;
4775
+		$texte = $wrap.$texte;
4777 4776
 		$regs = array_reverse($regs[1]);
4778
-		$wrap = '</' . implode('></', $regs) . '>';
4777
+		$wrap = '</'.implode('></', $regs).'>';
4779 4778
 		$texte .= $wrap;
4780 4779
 	}
4781 4780
 
@@ -4805,7 +4804,7 @@  discard block
 block discarded – undo
4805 4804
 
4806 4805
 	// caster $u en array si besoin
4807 4806
 	if (is_object($u)) {
4808
-		$u = (array)$u;
4807
+		$u = (array) $u;
4809 4808
 	}
4810 4809
 
4811 4810
 	if (is_array($u)) {
@@ -4827,7 +4826,7 @@  discard block
 block discarded – undo
4827 4826
 		// sinon on passe a la ligne et on indente
4828 4827
 		$i_str = str_pad('', $indent, ' ');
4829 4828
 		foreach ($u as $k => $v) {
4830
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4829
+			$out .= $join.$i_str."$k: ".filtre_print_dist($v, $join, $indent + 2);
4831 4830
 		}
4832 4831
 
4833 4832
 		return $out;
@@ -4881,7 +4880,7 @@  discard block
 block discarded – undo
4881 4880
  * @return string
4882 4881
  */
4883 4882
 function objet_icone($objet, $taille = 24, $class = '') {
4884
-	$icone = objet_info($objet, 'icone_objet') . '-' . $taille . '.png';
4883
+	$icone = objet_info($objet, 'icone_objet').'-'.$taille.'.png';
4885 4884
 	$icone = chemin_image($icone);
4886 4885
 	$balise_img = charger_filtre('balise_img');
4887 4886
 
@@ -4907,7 +4906,7 @@  discard block
 block discarded – undo
4907 4906
  */
4908 4907
 function objet_T($objet, $chaine, $args = [], $options = []) {
4909 4908
 	$chaine = explode(':', $chaine);
4910
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, ['force' => false]))) {
4909
+	if ($t = _T($objet.':'.end($chaine), $args, array_merge($options, ['force' => false]))) {
4911 4910
 		return $t;
4912 4911
 	}
4913 4912
 	$chaine = implode(':', $chaine);
@@ -4973,7 +4972,7 @@  discard block
 block discarded – undo
4973 4972
 	$cache = recuperer_fond($fond, $contexte, $options, $connect);
4974 4973
 
4975 4974
 	// calculer le nom de la css
4976
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4975
+	$dir_var = sous_repertoire(_DIR_VAR, 'cache-'.$extension);
4977 4976
 	$nom_safe = preg_replace(',\W,', '_', str_replace('.', '_', $fond));
4978 4977
 	$contexte_implicite = calculer_contexte_implicite();
4979 4978
 
@@ -4981,14 +4980,14 @@  discard block
 block discarded – undo
4981 4980
 	// mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
4982 4981
 	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4983 4982
 	if (isset($options['hash_on_content']) && $options['hash_on_content']) {
4984
-		$hash = md5((string) ($contexte_implicite['host'] . '::' . $cache));
4983
+		$hash = md5((string) ($contexte_implicite['host'].'::'.$cache));
4985 4984
 	}
4986 4985
 	else {
4987 4986
 		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4988 4987
 		ksort($contexte);
4989
-		$hash = md5($fond . json_encode($contexte_implicite, JSON_THROW_ON_ERROR) . json_encode($contexte, JSON_THROW_ON_ERROR) . $connect);
4988
+		$hash = md5($fond.json_encode($contexte_implicite, JSON_THROW_ON_ERROR).json_encode($contexte, JSON_THROW_ON_ERROR).$connect);
4990 4989
 	}
4991
-	$filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
4990
+	$filename = $dir_var.$extension."dyn-$nom_safe-".substr($hash, 0, 8).".$extension";
4992 4991
 
4993 4992
 	// mettre a jour le fichier si il n'existe pas
4994 4993
 	// ou trop ancien
@@ -4996,8 +4995,8 @@  discard block
 block discarded – undo
4996 4995
 	// et recopie sur le fichier cible uniquement si il change
4997 4996
 	if (
4998 4997
 		!file_exists($filename)
4999
-		|| !file_exists($filename . '.last')
5000
-		|| isset($cache['lastmodified']) && $cache['lastmodified'] && filemtime($filename . '.last') < $cache['lastmodified']
4998
+		|| !file_exists($filename.'.last')
4999
+		|| isset($cache['lastmodified']) && $cache['lastmodified'] && filemtime($filename.'.last') < $cache['lastmodified']
5001 5000
 		|| defined('_VAR_MODE') && _VAR_MODE == 'recalcul'
5002 5001
 	) {
5003 5002
 		$contenu = $cache['texte'];
@@ -5021,10 +5020,10 @@  discard block
 block discarded – undo
5021 5020
 			}
5022 5021
 			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
5023 5022
 			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
5024
-			$comment .= "}\n   md5:" . md5((string) $contenu) . " */\n";
5023
+			$comment .= "}\n   md5:".md5((string) $contenu)." */\n";
5025 5024
 		}
5026 5025
 		// et ecrire le fichier si il change
5027
-		ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
5026
+		ecrire_fichier_calcule_si_modifie($filename, $comment.$contenu, false, true);
5028 5027
 	}
5029 5028
 
5030 5029
 	return timestamp($filename);
@@ -5251,7 +5250,7 @@  discard block
 block discarded – undo
5251 5250
 	if ($e > 0 && strlen($mid) > 8) {
5252 5251
 		$mid = '***...***';
5253 5252
 	}
5254
-	return substr($passe, 0, $e) . $mid . ($e > 0 ? substr($passe, -$e) : '');
5253
+	return substr($passe, 0, $e).$mid.($e > 0 ? substr($passe, -$e) : '');
5255 5254
 }
5256 5255
 
5257 5256
 
@@ -5313,7 +5312,7 @@  discard block
 block discarded – undo
5313 5312
 		case 'id':
5314 5313
 		case 'anchor':
5315 5314
 			if (preg_match(',^\d,', $texte)) {
5316
-				$texte = substr($type, 0, 1) . $texte;
5315
+				$texte = substr($type, 0, 1).$texte;
5317 5316
 			}
5318 5317
 	}
5319 5318
 
@@ -5323,9 +5322,9 @@  discard block
 block discarded – undo
5323 5322
 
5324 5323
 	if (strlen($texte) < $longueur_mini && $longueur_mini < $longueur_maxi) {
5325 5324
 		if (preg_match(',^\d,', $texte)) {
5326
-			$texte = ($type ? substr($type, 0, 1) : 's') . $texte;
5325
+			$texte = ($type ? substr($type, 0, 1) : 's').$texte;
5327 5326
 		}
5328
-		$texte .= $separateur . md5($original);
5327
+		$texte .= $separateur.md5($original);
5329 5328
 		$texte = substr($texte, 0, $longueur_mini);
5330 5329
 	}
5331 5330
 
Please login to merge, or discard this patch.
ecrire/inc/plonger.php 2 patches
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -10,111 +10,111 @@
 block discarded – undo
10 10
 \***************************************************************************/
11 11
 
12 12
 if (!defined('_ECRIRE_INC_VERSION')) {
13
-	return;
13
+    return;
14 14
 }
15 15
 
16 16
 include_spip('inc/texte');
17 17
 
18 18
 function inc_plonger_dist($id_rubrique, $idom = '', $list = [], $col = 1, $exclu = 0, $do = 'aff') {
19 19
 
20
-	if ($list) {
21
-		$id_rubrique = $list[$col - 1];
22
-	}
20
+    if ($list) {
21
+        $id_rubrique = $list[$col - 1];
22
+    }
23 23
 
24
-	$ret = '';
24
+    $ret = '';
25 25
 
26
-	# recherche les filles et petites-filles de la rubrique donnee
27
-	# en excluant une eventuelle rubrique interdite (par exemple, lorsqu'on
28
-	# deplace une rubrique, on peut la deplacer partout a partir de la
29
-	# racine... sauf vers elle-meme ou sa propre branche)
30
-	$ordre = [];
31
-	$rub = [];
26
+    # recherche les filles et petites-filles de la rubrique donnee
27
+    # en excluant une eventuelle rubrique interdite (par exemple, lorsqu'on
28
+    # deplace une rubrique, on peut la deplacer partout a partir de la
29
+    # racine... sauf vers elle-meme ou sa propre branche)
30
+    $ordre = [];
31
+    $rub = [];
32 32
 
33
-	$res = sql_select(
34
-		'rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie, rub2.id_rubrique AS id_enfant',
35
-		'spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)',
36
-		'rub1.id_parent = ' . sql_quote($id_rubrique) . '
33
+    $res = sql_select(
34
+        'rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie, rub2.id_rubrique AS id_enfant',
35
+        'spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)',
36
+        'rub1.id_parent = ' . sql_quote($id_rubrique) . '
37 37
 			AND rub1.id_rubrique!=' . sql_quote($exclu) . '
38 38
 			AND (rub2.id_rubrique IS NULL OR rub2.id_rubrique!=' . sql_quote($exclu) . ')',
39
-		'',
40
-		'0+rub1.titre,rub1.titre'
41
-	);
39
+        '',
40
+        '0+rub1.titre,rub1.titre'
41
+    );
42 42
 
43
-	while ($row = sql_fetch($res)) {
44
-		if (autoriser('voir', 'rubrique', $row['id_rubrique'])) {
45
-			$rub[$row['id_rubrique']]['enfants'] = $row['id_enfant'];
46
-			if ($row['id_parent'] == $id_rubrique) {
47
-				$t = trim((string) typo(supprimer_numero($row['titre'])));
48
-				if ($row['langue_choisie'] != 'oui') {
49
-					$t .= ' <small title="'
50
-						. traduire_nom_langue($row['lang'])
51
-						. '">[' . $row['lang'] . ']</small>';
52
-				}
53
-				$ordre[$row['id_rubrique']] = $t;
54
-			}
55
-		}
56
-	}
57
-	$next = $list[$col] ?? 0;
58
-	if ($ordre) {
59
-		$rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=" . ($col + 1));
60
-		$info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
61
-		$args = "'$idom',this,$col,'" . $GLOBALS['spip_lang_left'] . "','$info',event";
43
+    while ($row = sql_fetch($res)) {
44
+        if (autoriser('voir', 'rubrique', $row['id_rubrique'])) {
45
+            $rub[$row['id_rubrique']]['enfants'] = $row['id_enfant'];
46
+            if ($row['id_parent'] == $id_rubrique) {
47
+                $t = trim((string) typo(supprimer_numero($row['titre'])));
48
+                if ($row['langue_choisie'] != 'oui') {
49
+                    $t .= ' <small title="'
50
+                        . traduire_nom_langue($row['lang'])
51
+                        . '">[' . $row['lang'] . ']</small>';
52
+                }
53
+                $ordre[$row['id_rubrique']] = $t;
54
+            }
55
+        }
56
+    }
57
+    $next = $list[$col] ?? 0;
58
+    if ($ordre) {
59
+        $rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=" . ($col + 1));
60
+        $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
61
+        $args = "'$idom',this,$col,'" . $GLOBALS['spip_lang_left'] . "','$info',event";
62 62
 
63
-		foreach ($ordre as $id => $titrebrut) {
64
-			$titre = supprimer_numero($titrebrut);
63
+        foreach ($ordre as $id => $titrebrut) {
64
+            $titre = supprimer_numero($titrebrut);
65 65
 
66
-			$classe1 = 'petit-item ' . ($id_rubrique ? 'petite-rubrique' : 'petit-secteur');
67
-			if (isset($rub[$id]['enfants'])) {
68
-				$classe2 = " class='rub-ouverte'";
69
-				$url = "\nhref='$rec&amp;id=$id'";
70
-			} else {
71
-				$classe2 = $url = '';
72
-				$url = "\nhref='javascript:void(0)'";
73
-			}
66
+            $classe1 = 'petit-item ' . ($id_rubrique ? 'petite-rubrique' : 'petit-secteur');
67
+            if (isset($rub[$id]['enfants'])) {
68
+                $classe2 = " class='rub-ouverte'";
69
+                $url = "\nhref='$rec&amp;id=$id'";
70
+            } else {
71
+                $classe2 = $url = '';
72
+                $url = "\nhref='javascript:void(0)'";
73
+            }
74 74
 
75
-			$js_func = $do . '_selection_titre';
76
-			$click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn "
77
-				. (is_array($list) ? "aff_selection_provisoire($id,$args)" : ' false')
75
+            $js_func = $do . '_selection_titre';
76
+            $click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn "
77
+                . (is_array($list) ? "aff_selection_provisoire($id,$args)" : ' false')
78 78
 # ce lien provoque la selection (directe) de la rubrique cliquee
79 79
 # et l'affichage de son titre dans le bandeau
80
-				. "\"\nondblclick=\""
81
-				. "$js_func(this."
82
-				. 'firstChild.nodeValue,'
83
-				. $id
84
-				. ",'selection_rubrique','id_parent');"
85
-				. "\nreturn aff_selection_provisoire($id,$args);"
86
-				. '"';
80
+                . "\"\nondblclick=\""
81
+                . "$js_func(this."
82
+                . 'firstChild.nodeValue,'
83
+                . $id
84
+                . ",'selection_rubrique','id_parent');"
85
+                . "\nreturn aff_selection_provisoire($id,$args);"
86
+                . '"';
87 87
 
88
-			$ret .= "<div class='"
89
-				. (($id == $next) ? 'item on' : 'item')
90
-				. "'><div class='"
91
-				. $classe1
92
-				. "'><div$classe2><a"
93
-				. $url
94
-				. $click
95
-				. '>'
96
-				. $titre
97
-				. '</a></div></div></div>';
98
-		}
99
-	}
88
+            $ret .= "<div class='"
89
+                . (($id == $next) ? 'item on' : 'item')
90
+                . "'><div class='"
91
+                . $classe1
92
+                . "'><div$classe2><a"
93
+                . $url
94
+                . $click
95
+                . '>'
96
+                . $titre
97
+                . '</a></div></div></div>';
98
+        }
99
+    }
100 100
 
101
-	$idom2 = $idom . '_col_' . ($col + 1);
102
-	$left = ($col * 250);
101
+    $idom2 = $idom . '_col_' . ($col + 1);
102
+    $left = ($col * 250);
103 103
 
104
-	return http_img_pack(
105
-		'loader.svg',
106
-		'',
107
-		"class='loader' style='visibility: hidden; position: absolute; " . $GLOBALS['spip_lang_left'] . ': '
108
-		. ($left - 30)
109
-		. "px; top: 2px; z-index: 2;' id='img_$idom2'"
110
-	)
111
-	. "<div style='width: 250px; height: 100%; overflow: auto; position: absolute; top: 0px; " . $GLOBALS['spip_lang_left'] . ': '
112
-	. ($left - 250)
113
-	. "px;'>"
114
-	. $ret
115
-	. "\n</div>\n<div id='$idom2'>"
116
-	. ($next
117
-		? inc_plonger_dist($id_rubrique, $idom, $list, $col + 1, $exclu)
118
-		: '')
119
-	. "\n</div>";
104
+    return http_img_pack(
105
+        'loader.svg',
106
+        '',
107
+        "class='loader' style='visibility: hidden; position: absolute; " . $GLOBALS['spip_lang_left'] . ': '
108
+        . ($left - 30)
109
+        . "px; top: 2px; z-index: 2;' id='img_$idom2'"
110
+    )
111
+    . "<div style='width: 250px; height: 100%; overflow: auto; position: absolute; top: 0px; " . $GLOBALS['spip_lang_left'] . ': '
112
+    . ($left - 250)
113
+    . "px;'>"
114
+    . $ret
115
+    . "\n</div>\n<div id='$idom2'>"
116
+    . ($next
117
+        ? inc_plonger_dist($id_rubrique, $idom, $list, $col + 1, $exclu)
118
+        : '')
119
+    . "\n</div>";
120 120
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
 	$res = sql_select(
34 34
 		'rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie, rub2.id_rubrique AS id_enfant',
35 35
 		'spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)',
36
-		'rub1.id_parent = ' . sql_quote($id_rubrique) . '
37
-			AND rub1.id_rubrique!=' . sql_quote($exclu) . '
38
-			AND (rub2.id_rubrique IS NULL OR rub2.id_rubrique!=' . sql_quote($exclu) . ')',
36
+		'rub1.id_parent = '.sql_quote($id_rubrique).'
37
+			AND rub1.id_rubrique!=' . sql_quote($exclu).'
38
+			AND (rub2.id_rubrique IS NULL OR rub2.id_rubrique!=' . sql_quote($exclu).')',
39 39
 		'',
40 40
 		'0+rub1.titre,rub1.titre'
41 41
 	);
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 				if ($row['langue_choisie'] != 'oui') {
49 49
 					$t .= ' <small title="'
50 50
 						. traduire_nom_langue($row['lang'])
51
-						. '">[' . $row['lang'] . ']</small>';
51
+						. '">['.$row['lang'].']</small>';
52 52
 				}
53 53
 				$ordre[$row['id_rubrique']] = $t;
54 54
 			}
@@ -56,14 +56,14 @@  discard block
 block discarded – undo
56 56
 	}
57 57
 	$next = $list[$col] ?? 0;
58 58
 	if ($ordre) {
59
-		$rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=" . ($col + 1));
59
+		$rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=".($col + 1));
60 60
 		$info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
61
-		$args = "'$idom',this,$col,'" . $GLOBALS['spip_lang_left'] . "','$info',event";
61
+		$args = "'$idom',this,$col,'".$GLOBALS['spip_lang_left']."','$info',event";
62 62
 
63 63
 		foreach ($ordre as $id => $titrebrut) {
64 64
 			$titre = supprimer_numero($titrebrut);
65 65
 
66
-			$classe1 = 'petit-item ' . ($id_rubrique ? 'petite-rubrique' : 'petit-secteur');
66
+			$classe1 = 'petit-item '.($id_rubrique ? 'petite-rubrique' : 'petit-secteur');
67 67
 			if (isset($rub[$id]['enfants'])) {
68 68
 				$classe2 = " class='rub-ouverte'";
69 69
 				$url = "\nhref='$rec&amp;id=$id'";
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 				$url = "\nhref='javascript:void(0)'";
73 73
 			}
74 74
 
75
-			$js_func = $do . '_selection_titre';
75
+			$js_func = $do.'_selection_titre';
76 76
 			$click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn "
77 77
 				. (is_array($list) ? "aff_selection_provisoire($id,$args)" : ' false')
78 78
 # ce lien provoque la selection (directe) de la rubrique cliquee
@@ -98,17 +98,17 @@  discard block
 block discarded – undo
98 98
 		}
99 99
 	}
100 100
 
101
-	$idom2 = $idom . '_col_' . ($col + 1);
101
+	$idom2 = $idom.'_col_'.($col + 1);
102 102
 	$left = ($col * 250);
103 103
 
104 104
 	return http_img_pack(
105 105
 		'loader.svg',
106 106
 		'',
107
-		"class='loader' style='visibility: hidden; position: absolute; " . $GLOBALS['spip_lang_left'] . ': '
107
+		"class='loader' style='visibility: hidden; position: absolute; ".$GLOBALS['spip_lang_left'].': '
108 108
 		. ($left - 30)
109 109
 		. "px; top: 2px; z-index: 2;' id='img_$idom2'"
110 110
 	)
111
-	. "<div style='width: 250px; height: 100%; overflow: auto; position: absolute; top: 0px; " . $GLOBALS['spip_lang_left'] . ': '
111
+	. "<div style='width: 250px; height: 100%; overflow: auto; position: absolute; top: 0px; ".$GLOBALS['spip_lang_left'].': '
112 112
 	. ($left - 250)
113 113
 	. "px;'>"
114 114
 	. $ret
Please login to merge, or discard this patch.
ecrire/inc/rechercher.php 2 patches
Indentation   +308 added lines, -308 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 defined('_RECHERCHE_LOCK_KEY') || define('_RECHERCHE_LOCK_KEY', 'fulltext');
@@ -34,195 +34,195 @@  discard block
 block discarded – undo
34 34
  * @return array Couples (type d'objet => Couples (champ => score))
35 35
  */
36 36
 function liste_des_champs() {
37
-	static $liste = null;
38
-	if (is_null($liste)) {
39
-		$liste = [];
40
-		// recuperer les tables_objets_sql declarees
41
-		include_spip('base/objets');
42
-		$tables_objets = lister_tables_objets_sql();
43
-		foreach ($tables_objets as $t => $infos) {
44
-			if ($infos['rechercher_champs']) {
45
-				$liste[$infos['type']] = $infos['rechercher_champs'];
46
-			}
47
-		}
48
-		// puis passer dans le pipeline
49
-		$liste = pipeline('rechercher_liste_des_champs', $liste);
50
-	}
51
-
52
-	return $liste;
37
+    static $liste = null;
38
+    if (is_null($liste)) {
39
+        $liste = [];
40
+        // recuperer les tables_objets_sql declarees
41
+        include_spip('base/objets');
42
+        $tables_objets = lister_tables_objets_sql();
43
+        foreach ($tables_objets as $t => $infos) {
44
+            if ($infos['rechercher_champs']) {
45
+                $liste[$infos['type']] = $infos['rechercher_champs'];
46
+            }
47
+        }
48
+        // puis passer dans le pipeline
49
+        $liste = pipeline('rechercher_liste_des_champs', $liste);
50
+    }
51
+
52
+    return $liste;
53 53
 }
54 54
 
55 55
 
56 56
 // Recherche des auteurs et mots-cles associes
57 57
 // en ne regardant que le titre ou le nom
58 58
 function liste_des_jointures() {
59
-	static $liste = null;
60
-	if (is_null($liste)) {
61
-		$liste = [];
62
-		// recuperer les tables_objets_sql declarees
63
-		include_spip('base/objets');
64
-		$tables_objets = lister_tables_objets_sql();
65
-		foreach ($tables_objets as $t => $infos) {
66
-			if ($infos['rechercher_jointures']) {
67
-				$liste[$infos['type']] = $infos['rechercher_jointures'];
68
-			}
69
-		}
70
-		// puis passer dans le pipeline
71
-		$liste = pipeline('rechercher_liste_des_jointures', $liste);
72
-	}
73
-
74
-	return $liste;
59
+    static $liste = null;
60
+    if (is_null($liste)) {
61
+        $liste = [];
62
+        // recuperer les tables_objets_sql declarees
63
+        include_spip('base/objets');
64
+        $tables_objets = lister_tables_objets_sql();
65
+        foreach ($tables_objets as $t => $infos) {
66
+            if ($infos['rechercher_jointures']) {
67
+                $liste[$infos['type']] = $infos['rechercher_jointures'];
68
+            }
69
+        }
70
+        // puis passer dans le pipeline
71
+        $liste = pipeline('rechercher_liste_des_jointures', $liste);
72
+    }
73
+
74
+    return $liste;
75 75
 }
76 76
 
77 77
 function expression_recherche($recherche, $options) {
78
-	// ne calculer qu'une seule fois l'expression par hit
79
-	// (meme si utilisee dans plusieurs boucles)
80
-	static $expression = [];
81
-	$key = serialize([$recherche, $options['preg_flags']]);
82
-	if (isset($expression[$key])) {
83
-		return $expression[$key];
84
-	}
85
-
86
-	$u = $GLOBALS['meta']['pcre_u'];
87
-	if ($u && !str_contains((string) $options['preg_flags'], (string) $u)) {
88
-		$options['preg_flags'] .= $u;
89
-	}
90
-	include_spip('inc/charsets');
91
-	$recherche = trim((string) $recherche);
92
-
93
-	// retirer les + de +truc et les * de truc*
94
-	$recherche = preg_replace(',(^|\s)\+(\w),Uims', '$1$2', $recherche);
95
-	$recherche = preg_replace(',(\w)\*($|\s),Uims', '$1$2', $recherche);
96
-
97
-	$is_preg = false;
98
-	if (str_starts_with($recherche, '/') && str_ends_with($recherche, '/') && strlen($recherche) > 2) {
99
-		// c'est une preg
100
-		$recherche_trans = translitteration($recherche);
101
-		$preg = $recherche_trans . $options['preg_flags'];
102
-		$is_preg = true;
103
-	} else {
104
-		// s'il y a plusieurs mots il faut les chercher tous : oblige REGEXP,
105
-		// sauf ceux de moins de 4 lettres (on supprime ainsi 'le', 'les', 'un',
106
-		// 'une', 'des' ...)
107
-
108
-		// attention : plusieurs mots entre guillemets sont a rechercher tels quels
109
-		$recherche_trans = $recherche_mod = $recherche_org = $recherche;
110
-
111
-		// les expressions entre " " sont un mot a chercher tel quel
112
-		// -> on remplace les espaces par un \x1 et on enleve les guillemets
113
-		if (preg_match(',["][^"]+["],Uims', $recherche_mod, $matches)) {
114
-			foreach ($matches as $match) {
115
-				$word = preg_replace(',\s+,Uims', "\x1", $match);
116
-				$word = trim($word, '"');
117
-				$recherche_mod = str_replace($match, $word, $recherche_mod);
118
-			}
119
-		}
120
-
121
-		if (preg_match(',\s+,' . $u, $recherche_mod)) {
122
-			$is_preg = true;
123
-
124
-			$recherche_inter = '|';
125
-			$recherche_mots = explode(' ', $recherche_mod);
126
-			$min_long = defined('_RECHERCHE_MIN_CAR') ? _RECHERCHE_MIN_CAR : 4;
127
-			$petits_mots = true;
128
-			foreach ($recherche_mots as $mot) {
129
-				if (strlen($mot) >= $min_long) {
130
-					// echapper les caracteres de regexp qui sont eventuellement dans la recherche
131
-					$recherche_inter .= preg_quote($mot) . ' ';
132
-					$petits_mots = false;
133
-				}
134
-			}
135
-			$recherche_inter = str_replace("\x1", '\s', $recherche_inter);
136
-
137
-			// mais on cherche quand même l'expression complète, même si elle
138
-			// comporte des mots de moins de quatre lettres
139
-			$recherche = trim(preg_replace(',\s+,' . $u, '|', $recherche_inter), '|');
140
-			if (!$recherche || $petits_mots) {
141
-				$recherche = preg_quote($recherche_org);
142
-			}
143
-			$recherche_trans = translitteration($recherche);
144
-		}
145
-
146
-		$preg = '/' . str_replace('/', '\\/', (string) $recherche_trans) . '/' . $options['preg_flags'];
147
-	}
148
-
149
-	// Si la chaine est inactive, on va utiliser LIKE pour aller plus vite
150
-	// ou si l'expression reguliere est invalide
151
-	if (!$is_preg || @preg_match($preg, '') === false) {
152
-		$methode = 'LIKE';
153
-		$u = $GLOBALS['meta']['pcre_u'];
154
-
155
-		// echapper les % et _
156
-		$q = str_replace(['%', '_'], ['\%', '\_'], trim($recherche));
157
-
158
-		// eviter les parentheses et autres caractères qui interferent avec pcre par la suite (dans le preg_match_all) s'il y a des reponses
159
-		$recherche = preg_quote($recherche, '/');
160
-		$recherche_trans = translitteration($recherche);
161
-		$recherche_mod = $recherche_trans;
162
-
163
-		// les expressions entre " " sont un mot a chercher tel quel
164
-		// -> on remplace les espaces par un _ et on enleve les guillemets
165
-		// corriger le like dans le $q
166
-		if (preg_match(',["][^"]+["],Uims', $q, $matches)) {
167
-			foreach ($matches as $match) {
168
-				$word = preg_replace(',\s+,Uims', '_', $match);
169
-				$word = trim($word, '"');
170
-				$q = str_replace($match, $word, $q);
171
-			}
172
-		}
173
-		// corriger la regexp
174
-		if (preg_match(',["][^"]+["],Uims', (string) $recherche_mod, $matches)) {
175
-			foreach ($matches as $match) {
176
-				$word = preg_replace(',\s+,Uims', '[\s]', $match);
177
-				$word = trim($word, '"');
178
-				$recherche_mod = str_replace($match, $word, (string) $recherche_mod);
179
-			}
180
-		}
181
-		$q = sql_quote(
182
-			'%'
183
-			. preg_replace(',\s+,' . $u, '%', $q)
184
-			. '%'
185
-		);
186
-
187
-		$preg = '/' . preg_replace(',\s+,' . $u, '.+', trim((string) $recherche_mod)) . '/' . $options['preg_flags'];
188
-	} else {
189
-		$methode = 'REGEXP';
190
-		$q = sql_quote(trim($recherche, '/'));
191
-	}
192
-
193
-	// tous les caracteres transliterables de $q sont remplaces par un joker
194
-	// permet de matcher en SQL meme si on est sensible aux accents (SQLite)
195
-	$q_t = $q;
196
-	for ($i = 0; $i < spip_strlen($q); $i++) {
197
-		$char = spip_substr($q, $i, 1);
198
-		if (
199
-			!is_ascii($char)
200
-			&& ($char_t = translitteration($char))
201
-			&& $char_t !== $char
202
-		) {
203
-			// on utilise ..?.? car le char utf peut etre encode sur 1, 2 ou 3 bytes
204
-			// mais c'est un pis aller cf #4354
205
-			$q_t = str_replace($char, $is_preg ? '..?.?' : '_', (string) $q_t);
206
-		}
207
-	}
208
-
209
-	$q = $q_t;
210
-
211
-	// fix : SQLite 3 est sensible aux accents, on jokerise les caracteres
212
-	// les plus frequents qui peuvent etre accentues
213
-	// (oui c'est tres dicustable...)
214
-	if (
215
-		isset($GLOBALS['connexions'][$options['serveur'] ?: 0]['type'])
216
-		&& str_starts_with((string) $GLOBALS['connexions'][$options['serveur'] ?: 0]['type'], 'sqlite')
217
-	) {
218
-		$q_t = strtr($q, 'aeuioc', $is_preg ? '......' : '______');
219
-		// si il reste au moins un char significatif...
220
-		if (preg_match(",[^'%_.],", $q_t)) {
221
-			$q = $q_t;
222
-		}
223
-	}
224
-
225
-	return $expression[$key] = [$methode, $q, $preg];
78
+    // ne calculer qu'une seule fois l'expression par hit
79
+    // (meme si utilisee dans plusieurs boucles)
80
+    static $expression = [];
81
+    $key = serialize([$recherche, $options['preg_flags']]);
82
+    if (isset($expression[$key])) {
83
+        return $expression[$key];
84
+    }
85
+
86
+    $u = $GLOBALS['meta']['pcre_u'];
87
+    if ($u && !str_contains((string) $options['preg_flags'], (string) $u)) {
88
+        $options['preg_flags'] .= $u;
89
+    }
90
+    include_spip('inc/charsets');
91
+    $recherche = trim((string) $recherche);
92
+
93
+    // retirer les + de +truc et les * de truc*
94
+    $recherche = preg_replace(',(^|\s)\+(\w),Uims', '$1$2', $recherche);
95
+    $recherche = preg_replace(',(\w)\*($|\s),Uims', '$1$2', $recherche);
96
+
97
+    $is_preg = false;
98
+    if (str_starts_with($recherche, '/') && str_ends_with($recherche, '/') && strlen($recherche) > 2) {
99
+        // c'est une preg
100
+        $recherche_trans = translitteration($recherche);
101
+        $preg = $recherche_trans . $options['preg_flags'];
102
+        $is_preg = true;
103
+    } else {
104
+        // s'il y a plusieurs mots il faut les chercher tous : oblige REGEXP,
105
+        // sauf ceux de moins de 4 lettres (on supprime ainsi 'le', 'les', 'un',
106
+        // 'une', 'des' ...)
107
+
108
+        // attention : plusieurs mots entre guillemets sont a rechercher tels quels
109
+        $recherche_trans = $recherche_mod = $recherche_org = $recherche;
110
+
111
+        // les expressions entre " " sont un mot a chercher tel quel
112
+        // -> on remplace les espaces par un \x1 et on enleve les guillemets
113
+        if (preg_match(',["][^"]+["],Uims', $recherche_mod, $matches)) {
114
+            foreach ($matches as $match) {
115
+                $word = preg_replace(',\s+,Uims', "\x1", $match);
116
+                $word = trim($word, '"');
117
+                $recherche_mod = str_replace($match, $word, $recherche_mod);
118
+            }
119
+        }
120
+
121
+        if (preg_match(',\s+,' . $u, $recherche_mod)) {
122
+            $is_preg = true;
123
+
124
+            $recherche_inter = '|';
125
+            $recherche_mots = explode(' ', $recherche_mod);
126
+            $min_long = defined('_RECHERCHE_MIN_CAR') ? _RECHERCHE_MIN_CAR : 4;
127
+            $petits_mots = true;
128
+            foreach ($recherche_mots as $mot) {
129
+                if (strlen($mot) >= $min_long) {
130
+                    // echapper les caracteres de regexp qui sont eventuellement dans la recherche
131
+                    $recherche_inter .= preg_quote($mot) . ' ';
132
+                    $petits_mots = false;
133
+                }
134
+            }
135
+            $recherche_inter = str_replace("\x1", '\s', $recherche_inter);
136
+
137
+            // mais on cherche quand même l'expression complète, même si elle
138
+            // comporte des mots de moins de quatre lettres
139
+            $recherche = trim(preg_replace(',\s+,' . $u, '|', $recherche_inter), '|');
140
+            if (!$recherche || $petits_mots) {
141
+                $recherche = preg_quote($recherche_org);
142
+            }
143
+            $recherche_trans = translitteration($recherche);
144
+        }
145
+
146
+        $preg = '/' . str_replace('/', '\\/', (string) $recherche_trans) . '/' . $options['preg_flags'];
147
+    }
148
+
149
+    // Si la chaine est inactive, on va utiliser LIKE pour aller plus vite
150
+    // ou si l'expression reguliere est invalide
151
+    if (!$is_preg || @preg_match($preg, '') === false) {
152
+        $methode = 'LIKE';
153
+        $u = $GLOBALS['meta']['pcre_u'];
154
+
155
+        // echapper les % et _
156
+        $q = str_replace(['%', '_'], ['\%', '\_'], trim($recherche));
157
+
158
+        // eviter les parentheses et autres caractères qui interferent avec pcre par la suite (dans le preg_match_all) s'il y a des reponses
159
+        $recherche = preg_quote($recherche, '/');
160
+        $recherche_trans = translitteration($recherche);
161
+        $recherche_mod = $recherche_trans;
162
+
163
+        // les expressions entre " " sont un mot a chercher tel quel
164
+        // -> on remplace les espaces par un _ et on enleve les guillemets
165
+        // corriger le like dans le $q
166
+        if (preg_match(',["][^"]+["],Uims', $q, $matches)) {
167
+            foreach ($matches as $match) {
168
+                $word = preg_replace(',\s+,Uims', '_', $match);
169
+                $word = trim($word, '"');
170
+                $q = str_replace($match, $word, $q);
171
+            }
172
+        }
173
+        // corriger la regexp
174
+        if (preg_match(',["][^"]+["],Uims', (string) $recherche_mod, $matches)) {
175
+            foreach ($matches as $match) {
176
+                $word = preg_replace(',\s+,Uims', '[\s]', $match);
177
+                $word = trim($word, '"');
178
+                $recherche_mod = str_replace($match, $word, (string) $recherche_mod);
179
+            }
180
+        }
181
+        $q = sql_quote(
182
+            '%'
183
+            . preg_replace(',\s+,' . $u, '%', $q)
184
+            . '%'
185
+        );
186
+
187
+        $preg = '/' . preg_replace(',\s+,' . $u, '.+', trim((string) $recherche_mod)) . '/' . $options['preg_flags'];
188
+    } else {
189
+        $methode = 'REGEXP';
190
+        $q = sql_quote(trim($recherche, '/'));
191
+    }
192
+
193
+    // tous les caracteres transliterables de $q sont remplaces par un joker
194
+    // permet de matcher en SQL meme si on est sensible aux accents (SQLite)
195
+    $q_t = $q;
196
+    for ($i = 0; $i < spip_strlen($q); $i++) {
197
+        $char = spip_substr($q, $i, 1);
198
+        if (
199
+            !is_ascii($char)
200
+            && ($char_t = translitteration($char))
201
+            && $char_t !== $char
202
+        ) {
203
+            // on utilise ..?.? car le char utf peut etre encode sur 1, 2 ou 3 bytes
204
+            // mais c'est un pis aller cf #4354
205
+            $q_t = str_replace($char, $is_preg ? '..?.?' : '_', (string) $q_t);
206
+        }
207
+    }
208
+
209
+    $q = $q_t;
210
+
211
+    // fix : SQLite 3 est sensible aux accents, on jokerise les caracteres
212
+    // les plus frequents qui peuvent etre accentues
213
+    // (oui c'est tres dicustable...)
214
+    if (
215
+        isset($GLOBALS['connexions'][$options['serveur'] ?: 0]['type'])
216
+        && str_starts_with((string) $GLOBALS['connexions'][$options['serveur'] ?: 0]['type'], 'sqlite')
217
+    ) {
218
+        $q_t = strtr($q, 'aeuioc', $is_preg ? '......' : '______');
219
+        // si il reste au moins un char significatif...
220
+        if (preg_match(",[^'%_.],", $q_t)) {
221
+            $q = $q_t;
222
+        }
223
+    }
224
+
225
+    return $expression[$key] = [$methode, $q, $preg];
226 226
 }
227 227
 
228 228
 
@@ -249,136 +249,136 @@  discard block
 block discarded – undo
249 249
  * @return array
250 250
  */
251 251
 function recherche_en_base($recherche = '', $tables = null, $options = [], $serveur = '') {
252
-	include_spip('base/abstract_sql');
253
-
254
-	if (!is_array($tables)) {
255
-		$liste = liste_des_champs();
256
-
257
-		if (is_string($tables) && $tables != '') {
258
-			$toutes = [];
259
-			foreach (explode(',', $tables) as $t) {
260
-				$t = trim($t);
261
-				if (isset($liste[$t])) {
262
-					$toutes[$t] = $liste[$t];
263
-				}
264
-			}
265
-			$tables = $toutes;
266
-			unset($toutes);
267
-		} else {
268
-			$tables = $liste;
269
-		}
270
-	}
271
-
272
-	if (!strlen($recherche) || $tables === []) {
273
-		return [];
274
-	}
275
-
276
-	include_spip('inc/autoriser');
277
-
278
-	// options par defaut
279
-	$options = array_merge(
280
-		[
281
-		'preg_flags' => 'UimsS',
282
-		'toutvoir' => false,
283
-		'champs' => false,
284
-		'score' => false,
285
-		'matches' => false,
286
-		'jointures' => false,
287
-		'serveur' => $serveur
288
-		],
289
-		$options
290
-	);
291
-
292
-	$results = [];
293
-
294
-	// Utiliser l'iterateur (DATA:recherche)
295
-	// pour recuperer les couples (id_objet, score)
296
-	// Le resultat est au format {
297
-	//      id1 = { 'score' => x, attrs => { } },
298
-	//      id2 = { 'score' => x, attrs => { } },
299
-	// }
300
-
301
-	include_spip('inc/recherche_to_array');
302
-
303
-	foreach ($tables as $table => $champs) {
304
-		# lock via memoization, si dispo
305
-		if (function_exists('cache_lock')) {
306
-			cache_lock($lock = _RECHERCHE_LOCK_KEY . ' ' . $table . ' ' . $recherche);
307
-		}
308
-
309
-		spip_timer('rech');
310
-
311
-		# TODO : ici plutot charger un iterateur via l'API iterateurs
312
-		$to_array = charger_fonction('recherche_to_array', 'inc');
313
-		$results[$table] = $to_array(
314
-			$recherche,
315
-			array_merge($options, ['table' => $table, 'champs' => $champs])
316
-		);
317
-		##var_dump($results[$table]);
318
-
319
-
320
-		spip_log(
321
-			"recherche $table ($recherche) : " . (is_countable($results[$table]) ? count($results[$table]) : 0) . ' resultats ' . spip_timer('rech'),
322
-			'recherche'
323
-		);
324
-
325
-		if (isset($lock)) {
326
-			cache_unlock($lock);
327
-		}
328
-	}
329
-
330
-	return $results;
252
+    include_spip('base/abstract_sql');
253
+
254
+    if (!is_array($tables)) {
255
+        $liste = liste_des_champs();
256
+
257
+        if (is_string($tables) && $tables != '') {
258
+            $toutes = [];
259
+            foreach (explode(',', $tables) as $t) {
260
+                $t = trim($t);
261
+                if (isset($liste[$t])) {
262
+                    $toutes[$t] = $liste[$t];
263
+                }
264
+            }
265
+            $tables = $toutes;
266
+            unset($toutes);
267
+        } else {
268
+            $tables = $liste;
269
+        }
270
+    }
271
+
272
+    if (!strlen($recherche) || $tables === []) {
273
+        return [];
274
+    }
275
+
276
+    include_spip('inc/autoriser');
277
+
278
+    // options par defaut
279
+    $options = array_merge(
280
+        [
281
+        'preg_flags' => 'UimsS',
282
+        'toutvoir' => false,
283
+        'champs' => false,
284
+        'score' => false,
285
+        'matches' => false,
286
+        'jointures' => false,
287
+        'serveur' => $serveur
288
+        ],
289
+        $options
290
+    );
291
+
292
+    $results = [];
293
+
294
+    // Utiliser l'iterateur (DATA:recherche)
295
+    // pour recuperer les couples (id_objet, score)
296
+    // Le resultat est au format {
297
+    //      id1 = { 'score' => x, attrs => { } },
298
+    //      id2 = { 'score' => x, attrs => { } },
299
+    // }
300
+
301
+    include_spip('inc/recherche_to_array');
302
+
303
+    foreach ($tables as $table => $champs) {
304
+        # lock via memoization, si dispo
305
+        if (function_exists('cache_lock')) {
306
+            cache_lock($lock = _RECHERCHE_LOCK_KEY . ' ' . $table . ' ' . $recherche);
307
+        }
308
+
309
+        spip_timer('rech');
310
+
311
+        # TODO : ici plutot charger un iterateur via l'API iterateurs
312
+        $to_array = charger_fonction('recherche_to_array', 'inc');
313
+        $results[$table] = $to_array(
314
+            $recherche,
315
+            array_merge($options, ['table' => $table, 'champs' => $champs])
316
+        );
317
+        ##var_dump($results[$table]);
318
+
319
+
320
+        spip_log(
321
+            "recherche $table ($recherche) : " . (is_countable($results[$table]) ? count($results[$table]) : 0) . ' resultats ' . spip_timer('rech'),
322
+            'recherche'
323
+        );
324
+
325
+        if (isset($lock)) {
326
+            cache_unlock($lock);
327
+        }
328
+    }
329
+
330
+    return $results;
331 331
 }
332 332
 
333 333
 
334 334
 // Effectue une recherche sur toutes les tables de la base de donnees
335 335
 function remplace_en_base($recherche = '', $remplace = null, $tables = null, $options = []) {
336
-	include_spip('inc/modifier');
337
-
338
-	// options par defaut
339
-	$options = array_merge(
340
-		[
341
-		'preg_flags' => 'UimsS',
342
-		'toutmodifier' => false
343
-		],
344
-		$options
345
-	);
346
-	$options['champs'] = true;
347
-
348
-
349
-	if (!is_array($tables)) {
350
-		$tables = liste_des_champs();
351
-	}
352
-
353
-	$results = recherche_en_base($recherche, $tables, $options);
354
-
355
-	$preg = '/' . str_replace('/', '\\/', (string) $recherche) . '/' . $options['preg_flags'];
356
-
357
-	foreach ($results as $table => $r) {
358
-		$_id_table = id_table_objet($table);
359
-		foreach ($r as $id => $x) {
360
-			if ($options['toutmodifier'] || autoriser('modifier', $table, $id)) {
361
-				$modifs = [];
362
-				foreach ($x['champs'] as $key => $val) {
363
-					if ($key == $_id_table) {
364
-						continue;
365
-					}
366
-					$repl = preg_replace($preg, (string) $remplace, (string) $val);
367
-					if ($repl != $val) {
368
-						$modifs[$key] = $repl;
369
-					}
370
-				}
371
-				if ($modifs) {
372
-					objet_modifier_champs(
373
-						$table,
374
-						$id,
375
-						[
376
-							'champs' => array_keys($modifs),
377
-						],
378
-						$modifs
379
-					);
380
-				}
381
-			}
382
-		}
383
-	}
336
+    include_spip('inc/modifier');
337
+
338
+    // options par defaut
339
+    $options = array_merge(
340
+        [
341
+        'preg_flags' => 'UimsS',
342
+        'toutmodifier' => false
343
+        ],
344
+        $options
345
+    );
346
+    $options['champs'] = true;
347
+
348
+
349
+    if (!is_array($tables)) {
350
+        $tables = liste_des_champs();
351
+    }
352
+
353
+    $results = recherche_en_base($recherche, $tables, $options);
354
+
355
+    $preg = '/' . str_replace('/', '\\/', (string) $recherche) . '/' . $options['preg_flags'];
356
+
357
+    foreach ($results as $table => $r) {
358
+        $_id_table = id_table_objet($table);
359
+        foreach ($r as $id => $x) {
360
+            if ($options['toutmodifier'] || autoriser('modifier', $table, $id)) {
361
+                $modifs = [];
362
+                foreach ($x['champs'] as $key => $val) {
363
+                    if ($key == $_id_table) {
364
+                        continue;
365
+                    }
366
+                    $repl = preg_replace($preg, (string) $remplace, (string) $val);
367
+                    if ($repl != $val) {
368
+                        $modifs[$key] = $repl;
369
+                    }
370
+                }
371
+                if ($modifs) {
372
+                    objet_modifier_champs(
373
+                        $table,
374
+                        $id,
375
+                        [
376
+                            'champs' => array_keys($modifs),
377
+                        ],
378
+                        $modifs
379
+                    );
380
+                }
381
+            }
382
+        }
383
+    }
384 384
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	if (str_starts_with($recherche, '/') && str_ends_with($recherche, '/') && strlen($recherche) > 2) {
99 99
 		// c'est une preg
100 100
 		$recherche_trans = translitteration($recherche);
101
-		$preg = $recherche_trans . $options['preg_flags'];
101
+		$preg = $recherche_trans.$options['preg_flags'];
102 102
 		$is_preg = true;
103 103
 	} else {
104 104
 		// s'il y a plusieurs mots il faut les chercher tous : oblige REGEXP,
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 			}
119 119
 		}
120 120
 
121
-		if (preg_match(',\s+,' . $u, $recherche_mod)) {
121
+		if (preg_match(',\s+,'.$u, $recherche_mod)) {
122 122
 			$is_preg = true;
123 123
 
124 124
 			$recherche_inter = '|';
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 			foreach ($recherche_mots as $mot) {
129 129
 				if (strlen($mot) >= $min_long) {
130 130
 					// echapper les caracteres de regexp qui sont eventuellement dans la recherche
131
-					$recherche_inter .= preg_quote($mot) . ' ';
131
+					$recherche_inter .= preg_quote($mot).' ';
132 132
 					$petits_mots = false;
133 133
 				}
134 134
 			}
@@ -136,14 +136,14 @@  discard block
 block discarded – undo
136 136
 
137 137
 			// mais on cherche quand même l'expression complète, même si elle
138 138
 			// comporte des mots de moins de quatre lettres
139
-			$recherche = trim(preg_replace(',\s+,' . $u, '|', $recherche_inter), '|');
139
+			$recherche = trim(preg_replace(',\s+,'.$u, '|', $recherche_inter), '|');
140 140
 			if (!$recherche || $petits_mots) {
141 141
 				$recherche = preg_quote($recherche_org);
142 142
 			}
143 143
 			$recherche_trans = translitteration($recherche);
144 144
 		}
145 145
 
146
-		$preg = '/' . str_replace('/', '\\/', (string) $recherche_trans) . '/' . $options['preg_flags'];
146
+		$preg = '/'.str_replace('/', '\\/', (string) $recherche_trans).'/'.$options['preg_flags'];
147 147
 	}
148 148
 
149 149
 	// Si la chaine est inactive, on va utiliser LIKE pour aller plus vite
@@ -180,11 +180,11 @@  discard block
 block discarded – undo
180 180
 		}
181 181
 		$q = sql_quote(
182 182
 			'%'
183
-			. preg_replace(',\s+,' . $u, '%', $q)
183
+			. preg_replace(',\s+,'.$u, '%', $q)
184 184
 			. '%'
185 185
 		);
186 186
 
187
-		$preg = '/' . preg_replace(',\s+,' . $u, '.+', trim((string) $recherche_mod)) . '/' . $options['preg_flags'];
187
+		$preg = '/'.preg_replace(',\s+,'.$u, '.+', trim((string) $recherche_mod)).'/'.$options['preg_flags'];
188 188
 	} else {
189 189
 		$methode = 'REGEXP';
190 190
 		$q = sql_quote(trim($recherche, '/'));
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 	foreach ($tables as $table => $champs) {
304 304
 		# lock via memoization, si dispo
305 305
 		if (function_exists('cache_lock')) {
306
-			cache_lock($lock = _RECHERCHE_LOCK_KEY . ' ' . $table . ' ' . $recherche);
306
+			cache_lock($lock = _RECHERCHE_LOCK_KEY.' '.$table.' '.$recherche);
307 307
 		}
308 308
 
309 309
 		spip_timer('rech');
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 
319 319
 
320 320
 		spip_log(
321
-			"recherche $table ($recherche) : " . (is_countable($results[$table]) ? count($results[$table]) : 0) . ' resultats ' . spip_timer('rech'),
321
+			"recherche $table ($recherche) : ".(is_countable($results[$table]) ? count($results[$table]) : 0).' resultats '.spip_timer('rech'),
322 322
 			'recherche'
323 323
 		);
324 324
 
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 
353 353
 	$results = recherche_en_base($recherche, $tables, $options);
354 354
 
355
-	$preg = '/' . str_replace('/', '\\/', (string) $recherche) . '/' . $options['preg_flags'];
355
+	$preg = '/'.str_replace('/', '\\/', (string) $recherche).'/'.$options['preg_flags'];
356 356
 
357 357
 	foreach ($results as $table => $r) {
358 358
 		$_id_table = id_table_objet($table);
Please login to merge, or discard this patch.
ecrire/inc/icone_renommer.php 2 patches
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -10,71 +10,71 @@
 block discarded – undo
10 10
 \***************************************************************************/
11 11
 
12 12
 if (!defined('_ECRIRE_INC_VERSION')) {
13
-	return;
13
+    return;
14 14
 }
15 15
 
16 16
 include_spip('inc/boutons');
17 17
 include_spip('base/objets');
18 18
 
19 19
 function inc_icone_renommer_dist($fond, $fonction) {
20
-	$size = 24;
21
-	if (
22
-		preg_match('/(?:-(\d{1,3}))?([.](gif|png|svg))?$/i', (string) $fond, $match)
23
-		&& (isset($match[0]) && $match[0] || isset($match[1]) && $match[1])
24
-	) {
25
-		if (isset($match[1]) && $match[1]) {
26
-			$size = $match[1];
27
-		}
28
-		$type = substr((string) $fond, 0, -strlen($match[0]));
29
-		if (!isset($match[2]) || !$match[2]) {
30
-			$fond .= '.png';
31
-		}
32
-	} else {
33
-		$type = $fond;
34
-		$fond .= '.png';
35
-	}
20
+    $size = 24;
21
+    if (
22
+        preg_match('/(?:-(\d{1,3}))?([.](gif|png|svg))?$/i', (string) $fond, $match)
23
+        && (isset($match[0]) && $match[0] || isset($match[1]) && $match[1])
24
+    ) {
25
+        if (isset($match[1]) && $match[1]) {
26
+            $size = $match[1];
27
+        }
28
+        $type = substr((string) $fond, 0, -strlen($match[0]));
29
+        if (!isset($match[2]) || !$match[2]) {
30
+            $fond .= '.png';
31
+        }
32
+    } else {
33
+        $type = $fond;
34
+        $fond .= '.png';
35
+    }
36 36
 
37
-	$rtl = false;
38
-	if (preg_match(',[-_]rtl$,i', (string) $type, $match)) {
39
-		$rtl = true;
40
-		$type = substr((string) $type, 0, -strlen($match[0]));
41
-	}
37
+    $rtl = false;
38
+    if (preg_match(',[-_]rtl$,i', (string) $type, $match)) {
39
+        $rtl = true;
40
+        $type = substr((string) $type, 0, -strlen($match[0]));
41
+    }
42 42
 
43
-	// objet_type garde invariant tout ce qui ne commence par par id_, spip_
44
-	// et ne finit pas par un s, sauf si c'est une exception declaree
45
-	$type = objet_type($type, false);
43
+    // objet_type garde invariant tout ce qui ne commence par par id_, spip_
44
+    // et ne finit pas par un s, sauf si c'est une exception declaree
45
+    $type = objet_type($type, false);
46 46
 
47
-	$dir = 'images/';
48
-	$f = "$type-$size.png";
49
-	if ($icone = find_in_theme($dir . $f)) {
50
-		$dir = dirname((string) $icone);
51
-		$fond = $icone;
47
+    $dir = 'images/';
48
+    $f = "$type-$size.png";
49
+    if ($icone = find_in_theme($dir . $f)) {
50
+        $dir = dirname((string) $icone);
51
+        $fond = $icone;
52 52
 
53
-		if (
54
-			$rtl
55
-			&& ($fr = $dir . '/' . str_replace("$type-", "$type-rtl-", basename((string) $icone)))
56
-			&& file_exists($fr)
57
-		) {
58
-			$fond = $fr;
59
-		}
53
+        if (
54
+            $rtl
55
+            && ($fr = $dir . '/' . str_replace("$type-", "$type-rtl-", basename((string) $icone)))
56
+            && file_exists($fr)
57
+        ) {
58
+            $fond = $fr;
59
+        }
60 60
 
61
-		$action = $fonction;
62
-		if ($action == 'supprimer.gif') {
63
-			$action = 'del';
64
-		} elseif ($action == 'creer.gif') {
65
-			$action = 'new';
66
-		} elseif ($action == 'edit.gif') {
67
-			$action = 'edit';
68
-		}
61
+        $action = $fonction;
62
+        if ($action == 'supprimer.gif') {
63
+            $action = 'del';
64
+        } elseif ($action == 'creer.gif') {
65
+            $action = 'new';
66
+        } elseif ($action == 'edit.gif') {
67
+            $action = 'edit';
68
+        }
69 69
 
70
-		$fonction = '';
71
-		if (in_array($action, ['add','del', 'new', 'edit', 'config'])) {
72
-			$fonction = $action;
73
-		}
70
+        $fonction = '';
71
+        if (in_array($action, ['add','del', 'new', 'edit', 'config'])) {
72
+            $fonction = $action;
73
+        }
74 74
 
75
-		// c'est bon !
76
-		return [$fond, $fonction];
77
-	}
75
+        // c'est bon !
76
+        return [$fond, $fonction];
77
+    }
78 78
 
79
-	return [$fond, $fonction];
79
+    return [$fond, $fonction];
80 80
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -46,13 +46,13 @@  discard block
 block discarded – undo
46 46
 
47 47
 	$dir = 'images/';
48 48
 	$f = "$type-$size.png";
49
-	if ($icone = find_in_theme($dir . $f)) {
49
+	if ($icone = find_in_theme($dir.$f)) {
50 50
 		$dir = dirname((string) $icone);
51 51
 		$fond = $icone;
52 52
 
53 53
 		if (
54 54
 			$rtl
55
-			&& ($fr = $dir . '/' . str_replace("$type-", "$type-rtl-", basename((string) $icone)))
55
+			&& ($fr = $dir.'/'.str_replace("$type-", "$type-rtl-", basename((string) $icone)))
56 56
 			&& file_exists($fr)
57 57
 		) {
58 58
 			$fond = $fr;
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 		}
69 69
 
70 70
 		$fonction = '';
71
-		if (in_array($action, ['add','del', 'new', 'edit', 'config'])) {
71
+		if (in_array($action, ['add', 'del', 'new', 'edit', 'config'])) {
72 72
 			$fonction = $action;
73 73
 		}
74 74
 
Please login to merge, or discard this patch.
ecrire/inc/auth.php 2 patches
Indentation   +442 added lines, -442 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 include_spip('base/abstract_sql');
@@ -34,33 +34,33 @@  discard block
 block discarded – undo
34 34
  *  - une chaîne vide si autorisation à pénétrer dans l'espace privé.
35 35
  */
36 36
 function inc_auth_dist() {
37
-	$row = auth_mode();
37
+    $row = auth_mode();
38 38
 
39
-	if ($row) {
40
-		return auth_init_droits($row);
41
-	}
39
+    if ($row) {
40
+        return auth_init_droits($row);
41
+    }
42 42
 
43
-	if (!$GLOBALS['connect_login']) {
44
-		return auth_a_loger();
45
-	}
43
+    if (!$GLOBALS['connect_login']) {
44
+        return auth_a_loger();
45
+    }
46 46
 
47
-	// Cas ou l'auteur a ete identifie mais on n'a pas d'info sur lui
48
-	// C'est soit parce que la base est inutilisable,
49
-	// soit parce que la table des auteurs a changee (restauration etc)
50
-	// Pas la peine d'insister.
51
-	// Renvoyer le nom fautif et une URL de remise a zero
47
+    // Cas ou l'auteur a ete identifie mais on n'a pas d'info sur lui
48
+    // C'est soit parce que la base est inutilisable,
49
+    // soit parce que la table des auteurs a changee (restauration etc)
50
+    // Pas la peine d'insister.
51
+    // Renvoyer le nom fautif et une URL de remise a zero
52 52
 
53
-	if (spip_connect()) {
54
-		return [
55
-			'login' => $GLOBALS['connect_login'],
56
-			'site' => generer_url_public('', 'action=logout&amp;logout=prive')
57
-		];
58
-	}
53
+    if (spip_connect()) {
54
+        return [
55
+            'login' => $GLOBALS['connect_login'],
56
+            'site' => generer_url_public('', 'action=logout&amp;logout=prive')
57
+        ];
58
+    }
59 59
 
60
-	$n = (int) sql_errno();
61
-	spip_log("Erreur base de donnees $n " . sql_error());
60
+    $n = (int) sql_errno();
61
+    spip_log("Erreur base de donnees $n " . sql_error());
62 62
 
63
-	return $n ?: 1;
63
+    return $n ?: 1;
64 64
 }
65 65
 
66 66
 /**
@@ -69,15 +69,15 @@  discard block
 block discarded – undo
69 69
  */
70 70
 function auth_controler_password_auteur_connecte(#[\SensitiveParameter] string $password): bool {
71 71
 
72
-	if (
73
-		empty($GLOBALS['visiteur_session']['id_auteur'])
74
-		|| empty($GLOBALS['visiteur_session']['login'])
75
-	) {
76
-		return false;
77
-	}
72
+    if (
73
+        empty($GLOBALS['visiteur_session']['id_auteur'])
74
+        || empty($GLOBALS['visiteur_session']['login'])
75
+    ) {
76
+        return false;
77
+    }
78 78
 
79
-	$auth = auth_identifier_login($GLOBALS['visiteur_session']['login'], $password, '', true);
80
-	return is_array($auth) && $auth['id_auteur'] == $GLOBALS['visiteur_session']['id_auteur'];
79
+    $auth = auth_identifier_login($GLOBALS['visiteur_session']['login'], $password, '', true);
80
+    return is_array($auth) && $auth['id_auteur'] == $GLOBALS['visiteur_session']['id_auteur'];
81 81
 }
82 82
 
83 83
 /**
@@ -89,47 +89,47 @@  discard block
 block discarded – undo
89 89
  * @return array|string
90 90
  */
91 91
 function auth_echec($raison) {
92
-	include_spip('inc/minipres');
93
-	include_spip('inc/headers');
94
-	// pas authentifie. Pourquoi ?
95
-	if (is_string($raison)) {
96
-		// redirection vers une page d'authentification
97
-		// on ne revient pas de cette fonction
98
-		// sauf si pb de header
99
-		$raison = redirige_formulaire($raison);
100
-	} elseif (is_int($raison)) {
101
-		// erreur SQL a afficher
102
-		$raison = minipres(
103
-			_T('info_travaux_titre'),
104
-			_T('titre_probleme_technique') . '<p><tt>' . sql_errno() . ' ' . sql_error() . '</tt></p>'
105
-		);
106
-	} elseif (@$raison['statut']) {
107
-		// un simple visiteur n'a pas acces a l'espace prive
108
-		spip_log('connexion refusee a ' . @$raison['id_auteur']);
109
-		$est_connecte = (!empty($GLOBALS['visiteur_session']['login']) && !empty($GLOBALS['visiteur_session']['statut'])); // idem test balise #URL_LOGOUT
110
-		$raison = minipres(
111
-			_T('avis_erreur_connexion'),
112
-			_T('avis_erreur_visiteur')
113
-				// Lien vers le site public
114
-				. '<br /><a href="' . url_de_base() . '">' . _T('login_retour_public') . '</a>'
115
-				// Si la personne est connectée, lien de déconnexion ramenant vers la page de login
116
-				. ($est_connecte ? ' | <a href="' . generer_url_public('', 'action=logout&amp;logout=prive') . '">' . _T('icone_deconnecter') . '</a>' : '')
117
-		);
118
-	} else {
119
-		// auteur en fin de droits ...
120
-		$h = $raison['site'];
121
-		$raison = minipres(
122
-			_T('avis_erreur_connexion'),
123
-			'<br /><br /><p>'
124
-			. _T('texte_inc_auth_1', ['auth_login' => $raison['login']])
125
-			. " <a href='$h'>"
126
-			. _T('texte_inc_auth_2')
127
-			. '</a>'
128
-			. _T('texte_inc_auth_3')
129
-		);
130
-	}
131
-
132
-	return $raison;
92
+    include_spip('inc/minipres');
93
+    include_spip('inc/headers');
94
+    // pas authentifie. Pourquoi ?
95
+    if (is_string($raison)) {
96
+        // redirection vers une page d'authentification
97
+        // on ne revient pas de cette fonction
98
+        // sauf si pb de header
99
+        $raison = redirige_formulaire($raison);
100
+    } elseif (is_int($raison)) {
101
+        // erreur SQL a afficher
102
+        $raison = minipres(
103
+            _T('info_travaux_titre'),
104
+            _T('titre_probleme_technique') . '<p><tt>' . sql_errno() . ' ' . sql_error() . '</tt></p>'
105
+        );
106
+    } elseif (@$raison['statut']) {
107
+        // un simple visiteur n'a pas acces a l'espace prive
108
+        spip_log('connexion refusee a ' . @$raison['id_auteur']);
109
+        $est_connecte = (!empty($GLOBALS['visiteur_session']['login']) && !empty($GLOBALS['visiteur_session']['statut'])); // idem test balise #URL_LOGOUT
110
+        $raison = minipres(
111
+            _T('avis_erreur_connexion'),
112
+            _T('avis_erreur_visiteur')
113
+                // Lien vers le site public
114
+                . '<br /><a href="' . url_de_base() . '">' . _T('login_retour_public') . '</a>'
115
+                // Si la personne est connectée, lien de déconnexion ramenant vers la page de login
116
+                . ($est_connecte ? ' | <a href="' . generer_url_public('', 'action=logout&amp;logout=prive') . '">' . _T('icone_deconnecter') . '</a>' : '')
117
+        );
118
+    } else {
119
+        // auteur en fin de droits ...
120
+        $h = $raison['site'];
121
+        $raison = minipres(
122
+            _T('avis_erreur_connexion'),
123
+            '<br /><br /><p>'
124
+            . _T('texte_inc_auth_1', ['auth_login' => $raison['login']])
125
+            . " <a href='$h'>"
126
+            . _T('texte_inc_auth_2')
127
+            . '</a>'
128
+            . _T('texte_inc_auth_3')
129
+        );
130
+    }
131
+
132
+    return $raison;
133 133
 }
134 134
 
135 135
 /**
@@ -139,79 +139,79 @@  discard block
 block discarded – undo
139 139
  * @return array|bool|string
140 140
  */
141 141
 function auth_mode() {
142
-	//
143
-	// Initialiser variables (eviter hacks par URL)
144
-	//
145
-	$GLOBALS['connect_login'] = '';
146
-	$id_auteur = null;
147
-	$GLOBALS['auth_can_disconnect'] = false;
148
-
149
-	//
150
-	// Recuperer les donnees d'identification
151
-	//
152
-	include_spip('inc/session');
153
-	// Session valide en cours ?
154
-	if (isset($_COOKIE['spip_session'])) {
155
-		$session = charger_fonction('session', 'inc');
156
-		if (
157
-			($id_auteur = $session()) || $id_auteur === 0 // reprise sur restauration
158
-		) {
159
-			$GLOBALS['auth_can_disconnect'] = true;
160
-			$GLOBALS['connect_login'] = session_get('login');
161
-		} else {
162
-			unset($_COOKIE['spip_session']);
163
-		}
164
-	}
165
-
166
-	// Essayer auth http si significatif
167
-	// (ignorer les login d'intranet independants de spip)
168
-	if (!$GLOBALS['ignore_auth_http']) {
169
-		if (
170
-			isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])
171
-				&& ($r = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']))
172
-			// Si auth http differtente de basic, PHP_AUTH_PW
173
-			// est indisponible mais tentons quand meme pour
174
-			// autocreation via LDAP
175
-			|| isset($_SERVER['REMOTE_USER'])
176
-				&& ($r = lire_php_auth($_SERVER['PHP_AUTH_USER'] = $_SERVER['REMOTE_USER'], ''))
177
-		) {
178
-			if (!$id_auteur) {
179
-				$_SERVER['PHP_AUTH_PW'] = '';
180
-				$GLOBALS['auth_can_disconnect'] = true;
181
-				$GLOBALS['visiteur_session'] = $r;
182
-				$GLOBALS['connect_login'] = session_get('login');
183
-				$id_auteur = $r['id_auteur'];
184
-			} else {
185
-				// cas de la session en plus de PHP_AUTH
186
-				/*				  if ($id_auteur != $r['id_auteur']){
142
+    //
143
+    // Initialiser variables (eviter hacks par URL)
144
+    //
145
+    $GLOBALS['connect_login'] = '';
146
+    $id_auteur = null;
147
+    $GLOBALS['auth_can_disconnect'] = false;
148
+
149
+    //
150
+    // Recuperer les donnees d'identification
151
+    //
152
+    include_spip('inc/session');
153
+    // Session valide en cours ?
154
+    if (isset($_COOKIE['spip_session'])) {
155
+        $session = charger_fonction('session', 'inc');
156
+        if (
157
+            ($id_auteur = $session()) || $id_auteur === 0 // reprise sur restauration
158
+        ) {
159
+            $GLOBALS['auth_can_disconnect'] = true;
160
+            $GLOBALS['connect_login'] = session_get('login');
161
+        } else {
162
+            unset($_COOKIE['spip_session']);
163
+        }
164
+    }
165
+
166
+    // Essayer auth http si significatif
167
+    // (ignorer les login d'intranet independants de spip)
168
+    if (!$GLOBALS['ignore_auth_http']) {
169
+        if (
170
+            isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])
171
+                && ($r = lire_php_auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']))
172
+            // Si auth http differtente de basic, PHP_AUTH_PW
173
+            // est indisponible mais tentons quand meme pour
174
+            // autocreation via LDAP
175
+            || isset($_SERVER['REMOTE_USER'])
176
+                && ($r = lire_php_auth($_SERVER['PHP_AUTH_USER'] = $_SERVER['REMOTE_USER'], ''))
177
+        ) {
178
+            if (!$id_auteur) {
179
+                $_SERVER['PHP_AUTH_PW'] = '';
180
+                $GLOBALS['auth_can_disconnect'] = true;
181
+                $GLOBALS['visiteur_session'] = $r;
182
+                $GLOBALS['connect_login'] = session_get('login');
183
+                $id_auteur = $r['id_auteur'];
184
+            } else {
185
+                // cas de la session en plus de PHP_AUTH
186
+                /*				  if ($id_auteur != $r['id_auteur']){
187 187
 					spip_log("vol de session $id_auteur" . join(', ', $r));
188 188
 				unset($_COOKIE['spip_session']);
189 189
 				$id_auteur = '';
190 190
 				} */
191
-			}
192
-		} else {
193
-			// Authentification .htaccess old style, car .htaccess semble
194
-			// souvent definir *aussi* PHP_AUTH_USER et PHP_AUTH_PW
195
-			if (isset($_SERVER['REMOTE_USER'])) {
196
-				$GLOBALS['connect_login'] = $_SERVER['REMOTE_USER'];
197
-			}
198
-		}
199
-	}
200
-
201
-	$where = (is_numeric($id_auteur)
202
-		/*AND $id_auteur>0*/ // reprise lors des restaurations
203
-	) ?
204
-		"id_auteur=$id_auteur" :
205
-		(strlen((string) $GLOBALS['connect_login']) ? 'login=' . sql_quote($GLOBALS['connect_login'], '', 'text') : '');
206
-
207
-	if (!$where) {
208
-		return '';
209
-	}
210
-
211
-	// Trouver les autres infos dans la table auteurs.
212
-	// le champ 'quand' est utilise par l'agenda
213
-
214
-	return sql_fetsel('*, en_ligne AS quand', 'spip_auteurs', "$where AND statut!='5poubelle'");
191
+            }
192
+        } else {
193
+            // Authentification .htaccess old style, car .htaccess semble
194
+            // souvent definir *aussi* PHP_AUTH_USER et PHP_AUTH_PW
195
+            if (isset($_SERVER['REMOTE_USER'])) {
196
+                $GLOBALS['connect_login'] = $_SERVER['REMOTE_USER'];
197
+            }
198
+        }
199
+    }
200
+
201
+    $where = (is_numeric($id_auteur)
202
+        /*AND $id_auteur>0*/ // reprise lors des restaurations
203
+    ) ?
204
+        "id_auteur=$id_auteur" :
205
+        (strlen((string) $GLOBALS['connect_login']) ? 'login=' . sql_quote($GLOBALS['connect_login'], '', 'text') : '');
206
+
207
+    if (!$where) {
208
+        return '';
209
+    }
210
+
211
+    // Trouver les autres infos dans la table auteurs.
212
+    // le champ 'quand' est utilise par l'agenda
213
+
214
+    return sql_fetsel('*, en_ligne AS quand', 'spip_auteurs', "$where AND statut!='5poubelle'");
215 215
 }
216 216
 
217 217
 /**
@@ -229,85 +229,85 @@  discard block
 block discarded – undo
229 229
  */
230 230
 function auth_init_droits($row) {
231 231
 
232
-	include_spip('inc/autoriser');
233
-	if (!autoriser('loger', '', 0, $row)) {
234
-		return false;
235
-	}
236
-
237
-
238
-	if ($row['statut'] == 'nouveau') {
239
-		include_spip('action/inscrire_auteur');
240
-		$row = confirmer_statut_inscription($row);
241
-	}
242
-
243
-	$GLOBALS['connect_id_auteur'] = $row['id_auteur'];
244
-	$GLOBALS['connect_login'] = $row['login'];
245
-	$GLOBALS['connect_statut'] = $row['statut'];
246
-
247
-	$GLOBALS['visiteur_session'] = array_merge((array)$GLOBALS['visiteur_session'], $row);
248
-
249
-	// au cas ou : ne pas memoriser les champs sensibles
250
-	unset($GLOBALS['visiteur_session']['pass']);
251
-	unset($GLOBALS['visiteur_session']['htpass']);
252
-	unset($GLOBALS['visiteur_session']['alea_actuel']);
253
-	unset($GLOBALS['visiteur_session']['alea_futur']);
254
-	unset($GLOBALS['visiteur_session']['ldap_password']);
255
-
256
-	// creer la session au besoin
257
-	if (!isset($_COOKIE['spip_session'])) {
258
-		$session = charger_fonction('session', 'inc');
259
-		$spip_session = $session($row);
260
-	}
261
-
262
-	// reinjecter les preferences_auteur apres le reset de spip_session
263
-	// car utilisees au retour par auth_loger()
264
-	$r = @unserialize($row['prefs']);
265
-	$GLOBALS['visiteur_session']['prefs'] = ($r ?: []);
266
-	// si prefs pas definies, les definir par defaut
267
-	if (!isset($GLOBALS['visiteur_session']['prefs']['couleur'])) {
268
-		$GLOBALS['visiteur_session']['prefs']['couleur'] = 2;
269
-		$GLOBALS['visiteur_session']['prefs']['display'] = 2;
270
-		$GLOBALS['visiteur_session']['prefs']['display_navigation'] = 'navigation_avec_icones';
271
-	}
272
-
273
-	$GLOBALS['visiteur_session'] = pipeline(
274
-		'preparer_visiteur_session',
275
-		['args' => ['row' => $row],
276
-		'data' => $GLOBALS['visiteur_session']]
277
-	);
278
-
279
-	// Etablir les droits selon le codage attendu
280
-	// dans ecrire/index.php ecrire/prive.php
281
-
282
-	// Pas autorise a acceder a ecrire ? renvoyer le tableau
283
-	// A noter : le premier appel a autoriser() a le bon gout
284
-	// d'initialiser $GLOBALS['visiteur_session']['restreint'],
285
-	// qui ne figure pas dans le fichier de session
286
-
287
-	if (!autoriser('ecrire')) {
288
-		return $row;
289
-	}
290
-
291
-	// autoriser('ecrire') ne laisse passer que les Admin et les Redac
292
-
293
-	auth_trace($row);
294
-
295
-	// Administrateurs
296
-	if (in_array($GLOBALS['connect_statut'], explode(',', _STATUT_AUTEUR_RUBRIQUE))) {
297
-		if (
298
-			isset($GLOBALS['visiteur_session']['restreint'])
299
-			&& is_array($GLOBALS['visiteur_session']['restreint'])
300
-		) {
301
-			$GLOBALS['connect_id_rubrique'] = $GLOBALS['visiteur_session']['restreint'];
302
-		}
303
-		if ($GLOBALS['connect_statut'] == '0minirezo') {
304
-			$GLOBALS['connect_toutes_rubriques'] = !$GLOBALS['connect_id_rubrique'];
305
-		}
306
-	}
307
-
308
-	// Pour les redacteurs, inc_version a fait l'initialisation minimale
309
-
310
-	return ''; // i.e. pas de pb.
232
+    include_spip('inc/autoriser');
233
+    if (!autoriser('loger', '', 0, $row)) {
234
+        return false;
235
+    }
236
+
237
+
238
+    if ($row['statut'] == 'nouveau') {
239
+        include_spip('action/inscrire_auteur');
240
+        $row = confirmer_statut_inscription($row);
241
+    }
242
+
243
+    $GLOBALS['connect_id_auteur'] = $row['id_auteur'];
244
+    $GLOBALS['connect_login'] = $row['login'];
245
+    $GLOBALS['connect_statut'] = $row['statut'];
246
+
247
+    $GLOBALS['visiteur_session'] = array_merge((array)$GLOBALS['visiteur_session'], $row);
248
+
249
+    // au cas ou : ne pas memoriser les champs sensibles
250
+    unset($GLOBALS['visiteur_session']['pass']);
251
+    unset($GLOBALS['visiteur_session']['htpass']);
252
+    unset($GLOBALS['visiteur_session']['alea_actuel']);
253
+    unset($GLOBALS['visiteur_session']['alea_futur']);
254
+    unset($GLOBALS['visiteur_session']['ldap_password']);
255
+
256
+    // creer la session au besoin
257
+    if (!isset($_COOKIE['spip_session'])) {
258
+        $session = charger_fonction('session', 'inc');
259
+        $spip_session = $session($row);
260
+    }
261
+
262
+    // reinjecter les preferences_auteur apres le reset de spip_session
263
+    // car utilisees au retour par auth_loger()
264
+    $r = @unserialize($row['prefs']);
265
+    $GLOBALS['visiteur_session']['prefs'] = ($r ?: []);
266
+    // si prefs pas definies, les definir par defaut
267
+    if (!isset($GLOBALS['visiteur_session']['prefs']['couleur'])) {
268
+        $GLOBALS['visiteur_session']['prefs']['couleur'] = 2;
269
+        $GLOBALS['visiteur_session']['prefs']['display'] = 2;
270
+        $GLOBALS['visiteur_session']['prefs']['display_navigation'] = 'navigation_avec_icones';
271
+    }
272
+
273
+    $GLOBALS['visiteur_session'] = pipeline(
274
+        'preparer_visiteur_session',
275
+        ['args' => ['row' => $row],
276
+        'data' => $GLOBALS['visiteur_session']]
277
+    );
278
+
279
+    // Etablir les droits selon le codage attendu
280
+    // dans ecrire/index.php ecrire/prive.php
281
+
282
+    // Pas autorise a acceder a ecrire ? renvoyer le tableau
283
+    // A noter : le premier appel a autoriser() a le bon gout
284
+    // d'initialiser $GLOBALS['visiteur_session']['restreint'],
285
+    // qui ne figure pas dans le fichier de session
286
+
287
+    if (!autoriser('ecrire')) {
288
+        return $row;
289
+    }
290
+
291
+    // autoriser('ecrire') ne laisse passer que les Admin et les Redac
292
+
293
+    auth_trace($row);
294
+
295
+    // Administrateurs
296
+    if (in_array($GLOBALS['connect_statut'], explode(',', _STATUT_AUTEUR_RUBRIQUE))) {
297
+        if (
298
+            isset($GLOBALS['visiteur_session']['restreint'])
299
+            && is_array($GLOBALS['visiteur_session']['restreint'])
300
+        ) {
301
+            $GLOBALS['connect_id_rubrique'] = $GLOBALS['visiteur_session']['restreint'];
302
+        }
303
+        if ($GLOBALS['connect_statut'] == '0minirezo') {
304
+            $GLOBALS['connect_toutes_rubriques'] = !$GLOBALS['connect_id_rubrique'];
305
+        }
306
+    }
307
+
308
+    // Pour les redacteurs, inc_version a fait l'initialisation minimale
309
+
310
+    return ''; // i.e. pas de pb.
311 311
 }
312 312
 
313 313
 /**
@@ -316,23 +316,23 @@  discard block
 block discarded – undo
316 316
  * @return string
317 317
  */
318 318
 function auth_a_loger() {
319
-	$redirect = generer_url_public('login', 'url=' . rawurlencode((string) self('&', true)), true);
320
-
321
-	// un echec au "bonjour" (login initial) quand le statut est
322
-	// inconnu signale sans doute un probleme de cookies
323
-	if (isset($_GET['bonjour'])) {
324
-		$redirect = parametre_url(
325
-			$redirect,
326
-			'var_erreur',
327
-			(isset($GLOBALS['visiteur_session']['statut'])
328
-				? 'statut'
329
-				: 'cookie'
330
-			),
331
-			'&'
332
-		);
333
-	}
334
-
335
-	return $redirect;
319
+    $redirect = generer_url_public('login', 'url=' . rawurlencode((string) self('&', true)), true);
320
+
321
+    // un echec au "bonjour" (login initial) quand le statut est
322
+    // inconnu signale sans doute un probleme de cookies
323
+    if (isset($_GET['bonjour'])) {
324
+        $redirect = parametre_url(
325
+            $redirect,
326
+            'var_erreur',
327
+            (isset($GLOBALS['visiteur_session']['statut'])
328
+                ? 'statut'
329
+                : 'cookie'
330
+            ),
331
+            '&'
332
+        );
333
+    }
334
+
335
+    return $redirect;
336 336
 }
337 337
 
338 338
 /**
@@ -344,19 +344,19 @@  discard block
 block discarded – undo
344 344
  * @param null|string $date
345 345
  */
346 346
 function auth_trace($row, $date = null) {
347
-	// Indiquer la connexion. A la minute pres ca suffit.
348
-	if (!is_numeric($connect_quand = $row['quand'] ?? '')) {
349
-		$connect_quand = strtotime((string) $connect_quand);
350
-	}
347
+    // Indiquer la connexion. A la minute pres ca suffit.
348
+    if (!is_numeric($connect_quand = $row['quand'] ?? '')) {
349
+        $connect_quand = strtotime((string) $connect_quand);
350
+    }
351 351
 
352
-	$date ??= date('Y-m-d H:i:s');
352
+    $date ??= date('Y-m-d H:i:s');
353 353
 
354
-	if (abs(strtotime($date) - $connect_quand) >= 60) {
355
-		sql_updateq('spip_auteurs', ['en_ligne' => $date], 'id_auteur=' . (int) $row['id_auteur']);
356
-		$row['en_ligne'] = $date;
357
-	}
354
+    if (abs(strtotime($date) - $connect_quand) >= 60) {
355
+        sql_updateq('spip_auteurs', ['en_ligne' => $date], 'id_auteur=' . (int) $row['id_auteur']);
356
+        $row['en_ligne'] = $date;
357
+    }
358 358
 
359
-	pipeline('trig_auth_trace', ['args' => ['row' => $row, 'date' => $date]]);
359
+    pipeline('trig_auth_trace', ['args' => ['row' => $row, 'date' => $date]]);
360 360
 }
361 361
 
362 362
 
@@ -382,27 +382,27 @@  discard block
 block discarded – undo
382 382
  * @return mixed
383 383
  */
384 384
 function auth_administrer($fonction, $args, mixed $defaut = false) {
385
-	$auth_methode = array_shift($args);
386
-	$auth_methode = $auth_methode ?: 'spip'; // valeur par defaut au cas ou
387
-	if (
388
-		($auth = charger_fonction($auth_methode, 'auth', true))
389
-		&& function_exists($f = "auth_{$auth_methode}_$fonction")
390
-	) {
391
-		$res = $f(...$args);
392
-	} else {
393
-		$res = $defaut;
394
-	}
395
-	return pipeline(
396
-		'auth_administrer',
397
-		[
398
-			'args' => [
399
-				'fonction' => $fonction,
400
-				'methode' => $auth_methode,
401
-				'args' => $args
402
-			],
403
-			'data' => $res
404
-		]
405
-	);
385
+    $auth_methode = array_shift($args);
386
+    $auth_methode = $auth_methode ?: 'spip'; // valeur par defaut au cas ou
387
+    if (
388
+        ($auth = charger_fonction($auth_methode, 'auth', true))
389
+        && function_exists($f = "auth_{$auth_methode}_$fonction")
390
+    ) {
391
+        $res = $f(...$args);
392
+    } else {
393
+        $res = $defaut;
394
+    }
395
+    return pipeline(
396
+        'auth_administrer',
397
+        [
398
+            'args' => [
399
+                'fonction' => $fonction,
400
+                'methode' => $auth_methode,
401
+                'args' => $args
402
+            ],
403
+            'data' => $res
404
+        ]
405
+    );
406 406
 }
407 407
 
408 408
 /**
@@ -412,11 +412,11 @@  discard block
 block discarded – undo
412 412
  * @return array
413 413
  */
414 414
 function auth_formulaire_login($flux) {
415
-	foreach ($GLOBALS['liste_des_authentifications'] as $methode) {
416
-		$flux = auth_administrer('formulaire_login', [$methode, $flux], $flux);
417
-	}
415
+    foreach ($GLOBALS['liste_des_authentifications'] as $methode) {
416
+        $flux = auth_administrer('formulaire_login', [$methode, $flux], $flux);
417
+    }
418 418
 
419
-	return $flux;
419
+    return $flux;
420 420
 }
421 421
 
422 422
 
@@ -430,19 +430,19 @@  discard block
 block discarded – undo
430 430
  * @return string/bool
431 431
  */
432 432
 function auth_retrouver_login($login, $serveur = '') {
433
-	if (!spip_connect($serveur)) {
434
-		include_spip('inc/minipres');
435
-		echo minipres(_T('info_travaux_titre'), _T('titre_probleme_technique'));
436
-		exit;
437
-	}
438
-
439
-	foreach ($GLOBALS['liste_des_authentifications'] as $methode) {
440
-		if ($auteur = auth_administrer('retrouver_login', [$methode, $login, $serveur])) {
441
-			return $auteur;
442
-		}
443
-	}
444
-
445
-	return false;
433
+    if (!spip_connect($serveur)) {
434
+        include_spip('inc/minipres');
435
+        echo minipres(_T('info_travaux_titre'), _T('titre_probleme_technique'));
436
+        exit;
437
+    }
438
+
439
+    foreach ($GLOBALS['liste_des_authentifications'] as $methode) {
440
+        if ($auteur = auth_administrer('retrouver_login', [$methode, $login, $serveur])) {
441
+            return $auteur;
442
+        }
443
+    }
444
+
445
+    return false;
446 446
 }
447 447
 
448 448
 /**
@@ -457,34 +457,34 @@  discard block
 block discarded – undo
457 457
  * @return array
458 458
  */
459 459
 function auth_informer_login($login, $serveur = '') {
460
-	if (
461
-		!$login
462
-		|| !($login_base = auth_retrouver_login($login, $serveur))
463
-		|| !($row = sql_fetsel('*', 'spip_auteurs', 'login=' . sql_quote($login_base, $serveur, 'text'), '', '', '', '', $serveur))
464
-	) {
465
-		// generer de fausses infos, mais credibles, pour eviter une attaque
466
-		// https://core.spip.net/issues/1758 + https://core.spip.net/issues/3691
467
-
468
-		$row = [
469
-			'login' => $login,
470
-			'cnx' => '0',
471
-			'logo' => '',
472
-		];
473
-
474
-		return $row;
475
-	}
476
-
477
-	$prefs = @unserialize($row['prefs']);
478
-	$infos = [
479
-		'id_auteur' => $row['id_auteur'],
480
-		'login' => $row['login'],
481
-		'cnx' => (isset($prefs['cnx']) && $prefs['cnx'] === 'perma') ? '1' : '0',
482
-		'logo' => recuperer_fond('formulaires/inc-logo_auteur', $row),
483
-	];
484
-
485
-	verifier_visiteur();
486
-
487
-	return auth_administrer('informer_login', [$row['source'], $infos, $row, $serveur], $infos);
460
+    if (
461
+        !$login
462
+        || !($login_base = auth_retrouver_login($login, $serveur))
463
+        || !($row = sql_fetsel('*', 'spip_auteurs', 'login=' . sql_quote($login_base, $serveur, 'text'), '', '', '', '', $serveur))
464
+    ) {
465
+        // generer de fausses infos, mais credibles, pour eviter une attaque
466
+        // https://core.spip.net/issues/1758 + https://core.spip.net/issues/3691
467
+
468
+        $row = [
469
+            'login' => $login,
470
+            'cnx' => '0',
471
+            'logo' => '',
472
+        ];
473
+
474
+        return $row;
475
+    }
476
+
477
+    $prefs = @unserialize($row['prefs']);
478
+    $infos = [
479
+        'id_auteur' => $row['id_auteur'],
480
+        'login' => $row['login'],
481
+        'cnx' => (isset($prefs['cnx']) && $prefs['cnx'] === 'perma') ? '1' : '0',
482
+        'logo' => recuperer_fond('formulaires/inc-logo_auteur', $row),
483
+    ];
484
+
485
+    verifier_visiteur();
486
+
487
+    return auth_administrer('informer_login', [$row['source'], $infos, $row, $serveur], $infos);
488 488
 }
489 489
 
490 490
 
@@ -498,21 +498,21 @@  discard block
 block discarded – undo
498 498
  * @return mixed
499 499
  */
500 500
 function auth_identifier_login($login, #[\SensitiveParameter] $password, $serveur = '', bool $phpauth = false) {
501
-	$erreur = '';
502
-	foreach ($GLOBALS['liste_des_authentifications'] as $methode) {
503
-		if ($auth = charger_fonction($methode, 'auth', true)) {
504
-			$auteur = $auth($login, $password, $serveur, $phpauth);
505
-			if (is_array($auteur) && count($auteur)) {
506
-				spip_log("connexion de $login par methode $methode");
507
-				$auteur['auth'] = $methode;
508
-				return $auteur;
509
-			} elseif (is_string($auteur)) {
510
-				$erreur .= "$auteur ";
511
-			}
512
-		}
513
-	}
514
-
515
-	return $erreur;
501
+    $erreur = '';
502
+    foreach ($GLOBALS['liste_des_authentifications'] as $methode) {
503
+        if ($auth = charger_fonction($methode, 'auth', true)) {
504
+            $auteur = $auth($login, $password, $serveur, $phpauth);
505
+            if (is_array($auteur) && count($auteur)) {
506
+                spip_log("connexion de $login par methode $methode");
507
+                $auteur['auth'] = $methode;
508
+                return $auteur;
509
+            } elseif (is_string($auteur)) {
510
+                $erreur .= "$auteur ";
511
+            }
512
+        }
513
+    }
514
+
515
+    return $erreur;
516 516
 }
517 517
 
518 518
 /**
@@ -526,8 +526,8 @@  discard block
 block discarded – undo
526 526
  * @return string
527 527
  */
528 528
 function auth_url_retour_login($auth_methode, $login, $redirect = '', $serveur = '') {
529
-	$securiser_action = charger_fonction('securiser_action', 'inc');
530
-	return $securiser_action('auth', "$auth_methode/$login", $redirect, true);
529
+    $securiser_action = charger_fonction('securiser_action', 'inc');
530
+    return $securiser_action('auth', "$auth_methode/$login", $redirect, true);
531 531
 }
532 532
 
533 533
 /**
@@ -541,8 +541,8 @@  discard block
 block discarded – undo
541 541
  * @return mixed
542 542
  */
543 543
 function auth_terminer_identifier_login($auth_methode, $login, $serveur = '') {
544
-	$args = func_get_args();
545
-	return auth_administrer('terminer_identifier_login', $args);
544
+    $args = func_get_args();
545
+    return auth_administrer('terminer_identifier_login', $args);
546 546
 }
547 547
 
548 548
 /**
@@ -552,29 +552,29 @@  discard block
 block discarded – undo
552 552
  * @return bool
553 553
  */
554 554
 function auth_loger($auteur) {
555
-	if (!is_array($auteur) || $auteur === []) {
556
-		return false;
557
-	}
558
-
559
-	// initialiser et poser le cookie de session
560
-	unset($_COOKIE['spip_session']);
561
-	if (auth_init_droits($auteur) === false) {
562
-		return false;
563
-	}
564
-
565
-	// initialiser les prefs
566
-	$p = $GLOBALS['visiteur_session']['prefs'];
567
-	$p['cnx'] = (isset($auteur['cookie']) && $auteur['cookie'] == 'oui') ? 'perma' : '';
568
-
569
-	sql_updateq(
570
-		'spip_auteurs',
571
-		['prefs' => serialize($p)],
572
-		'id_auteur=' . (int) $auteur['id_auteur']
573
-	);
574
-
575
-	//  bloquer ici le visiteur qui tente d'abuser de ses droits
576
-	verifier_visiteur();
577
-	return true;
555
+    if (!is_array($auteur) || $auteur === []) {
556
+        return false;
557
+    }
558
+
559
+    // initialiser et poser le cookie de session
560
+    unset($_COOKIE['spip_session']);
561
+    if (auth_init_droits($auteur) === false) {
562
+        return false;
563
+    }
564
+
565
+    // initialiser les prefs
566
+    $p = $GLOBALS['visiteur_session']['prefs'];
567
+    $p['cnx'] = (isset($auteur['cookie']) && $auteur['cookie'] == 'oui') ? 'perma' : '';
568
+
569
+    sql_updateq(
570
+        'spip_auteurs',
571
+        ['prefs' => serialize($p)],
572
+        'id_auteur=' . (int) $auteur['id_auteur']
573
+    );
574
+
575
+    //  bloquer ici le visiteur qui tente d'abuser de ses droits
576
+    verifier_visiteur();
577
+    return true;
578 578
 }
579 579
 
580 580
 /**
@@ -584,8 +584,8 @@  discard block
 block discarded – undo
584 584
  * return void
585 585
  **/
586 586
 function auth_deloger() {
587
-	$logout = charger_fonction('logout', 'action');
588
-	$logout();
587
+    $logout = charger_fonction('logout', 'action');
588
+    $logout();
589 589
 }
590 590
 
591 591
 /**
@@ -599,8 +599,8 @@  discard block
 block discarded – undo
599 599
  * @return bool
600 600
  */
601 601
 function auth_autoriser_modifier_login($auth_methode, $serveur = '') {
602
-	$args = func_get_args();
603
-	return auth_administrer('autoriser_modifier_login', $args);
602
+    $args = func_get_args();
603
+    return auth_administrer('autoriser_modifier_login', $args);
604 604
 }
605 605
 
606 606
 /**
@@ -615,8 +615,8 @@  discard block
 block discarded – undo
615 615
  *  message d'erreur ou chaine vide si pas d'erreur
616 616
  */
617 617
 function auth_verifier_login($auth_methode, $new_login, $id_auteur = 0, $serveur = '') {
618
-	$args = func_get_args();
619
-	return auth_administrer('verifier_login', $args, '');
618
+    $args = func_get_args();
619
+    return auth_administrer('verifier_login', $args, '');
620 620
 }
621 621
 
622 622
 /**
@@ -629,8 +629,8 @@  discard block
 block discarded – undo
629 629
  * @return bool
630 630
  */
631 631
 function auth_modifier_login($auth_methode, $new_login, $id_auteur, $serveur = '') {
632
-	$args = func_get_args();
633
-	return auth_administrer('modifier_login', $args);
632
+    $args = func_get_args();
633
+    return auth_administrer('modifier_login', $args);
634 634
 }
635 635
 
636 636
 /**
@@ -645,8 +645,8 @@  discard block
 block discarded – undo
645 645
  *  succès ou échec
646 646
  */
647 647
 function auth_autoriser_modifier_pass($auth_methode, $serveur = '') {
648
-	$args = func_get_args();
649
-	return auth_administrer('autoriser_modifier_pass', $args);
648
+    $args = func_get_args();
649
+    return auth_administrer('autoriser_modifier_pass', $args);
650 650
 }
651 651
 
652 652
 /**
@@ -662,8 +662,8 @@  discard block
 block discarded – undo
662 662
  *  message d'erreur ou chaine vide si pas d'erreur
663 663
  */
664 664
 function auth_verifier_pass($auth_methode, $login, #[\SensitiveParameter] $new_pass, $id_auteur = 0, $serveur = '') {
665
-	$args = func_get_args();
666
-	return auth_administrer('verifier_pass', $args, '');
665
+    $args = func_get_args();
666
+    return auth_administrer('verifier_pass', $args, '');
667 667
 }
668 668
 
669 669
 /**
@@ -679,8 +679,8 @@  discard block
 block discarded – undo
679 679
  *  succes ou echec
680 680
  */
681 681
 function auth_modifier_pass($auth_methode, $login, #[\SensitiveParameter] $new_pass, $id_auteur, $serveur = '') {
682
-	$args = func_get_args();
683
-	return auth_administrer('modifier_pass', $args);
682
+    $args = func_get_args();
683
+    return auth_administrer('modifier_pass', $args);
684 684
 }
685 685
 
686 686
 /**
@@ -696,24 +696,24 @@  discard block
 block discarded – undo
696 696
  * @return void
697 697
  */
698 698
 function auth_synchroniser_distant(
699
-	$auth_methode = true,
700
-	$id_auteur = 0,
701
-	$champs = [],
702
-	$options = [],
703
-	$serveur = ''
699
+    $auth_methode = true,
700
+    $id_auteur = 0,
701
+    $champs = [],
702
+    $options = [],
703
+    $serveur = ''
704 704
 ) {
705
-	$args = func_get_args();
706
-	if ($auth_methode === true || isset($options['all']) && $options['all'] == true) {
707
-		$options['all'] = true; // ajouter une option all=>true pour chaque auth
708
-		$args = [true, $id_auteur, $champs, $options, $serveur];
709
-		foreach ($GLOBALS['liste_des_authentifications'] as $methode) {
710
-			array_shift($args);
711
-			array_unshift($args, $methode);
712
-			auth_administrer('synchroniser_distant', $args);
713
-		}
714
-	} else {
715
-		auth_administrer('synchroniser_distant', $args);
716
-	}
705
+    $args = func_get_args();
706
+    if ($auth_methode === true || isset($options['all']) && $options['all'] == true) {
707
+        $options['all'] = true; // ajouter une option all=>true pour chaque auth
708
+        $args = [true, $id_auteur, $champs, $options, $serveur];
709
+        foreach ($GLOBALS['liste_des_authentifications'] as $methode) {
710
+            array_shift($args);
711
+            array_unshift($args, $methode);
712
+            auth_administrer('synchroniser_distant', $args);
713
+        }
714
+    } else {
715
+        auth_administrer('synchroniser_distant', $args);
716
+    }
717 717
 }
718 718
 
719 719
 
@@ -726,46 +726,46 @@  discard block
 block discarded – undo
726 726
  * @return array|bool
727 727
  */
728 728
 function lire_php_auth($login, #[\SensitiveParameter] $pw, $serveur = '') {
729
-	if (
730
-		!$login
731
-		|| !$login_base = auth_retrouver_login($login, $serveur)
732
-	) {
733
-		return false;
734
-	}
735
-
736
-	$row = sql_fetsel('*', 'spip_auteurs', 'login=' . sql_quote($login_base, $serveur, 'text'), '', '', '', '', $serveur);
737
-
738
-	if (!$row) {
739
-		if (
740
-			include_spip('inc/auth')
741
-			&& auth_ldap_connect($serveur)
742
-			&& ($auth_ldap = charger_fonction('ldap', 'auth', true))
743
-		) {
744
-			return $auth_ldap($login_base, $pw, $serveur, true);
745
-		}
746
-
747
-		return false;
748
-	}
749
-
750
-	// si pas de source definie
751
-	// ou auth/xxx introuvable, utiliser 'spip' ou autre et avec le login passé par PHP_AUTH_USER
752
-	if (
753
-		!($auth_methode = $row['source'])
754
-		|| !($auth = charger_fonction($auth_methode, 'auth', true))
755
-	) {
756
-		$auth = charger_fonction('spip', 'auth', true);
757
-	}
758
-
759
-	$auteur = '';
760
-	if ($auth) {
761
-		$auteur = $auth($login, $pw, $serveur, true);
762
-	}
763
-	// verifier que ce n'est pas un message d'erreur
764
-	if (is_array($auteur) && count($auteur)) {
765
-		return $auteur;
766
-	}
767
-
768
-	return false;
729
+    if (
730
+        !$login
731
+        || !$login_base = auth_retrouver_login($login, $serveur)
732
+    ) {
733
+        return false;
734
+    }
735
+
736
+    $row = sql_fetsel('*', 'spip_auteurs', 'login=' . sql_quote($login_base, $serveur, 'text'), '', '', '', '', $serveur);
737
+
738
+    if (!$row) {
739
+        if (
740
+            include_spip('inc/auth')
741
+            && auth_ldap_connect($serveur)
742
+            && ($auth_ldap = charger_fonction('ldap', 'auth', true))
743
+        ) {
744
+            return $auth_ldap($login_base, $pw, $serveur, true);
745
+        }
746
+
747
+        return false;
748
+    }
749
+
750
+    // si pas de source definie
751
+    // ou auth/xxx introuvable, utiliser 'spip' ou autre et avec le login passé par PHP_AUTH_USER
752
+    if (
753
+        !($auth_methode = $row['source'])
754
+        || !($auth = charger_fonction($auth_methode, 'auth', true))
755
+    ) {
756
+        $auth = charger_fonction('spip', 'auth', true);
757
+    }
758
+
759
+    $auteur = '';
760
+    if ($auth) {
761
+        $auteur = $auth($login, $pw, $serveur, true);
762
+    }
763
+    // verifier que ce n'est pas un message d'erreur
764
+    if (is_array($auteur) && count($auteur)) {
765
+        return $auteur;
766
+    }
767
+
768
+    return false;
769 769
 }
770 770
 
771 771
 /**
@@ -781,21 +781,21 @@  discard block
 block discarded – undo
781 781
  * @param string $lien
782 782
  */
783 783
 function ask_php_auth($pb, $raison, $retour = '', $url = '', $re = '', $lien = '') {
784
-	@Header('WWW-Authenticate: Basic realm="espace prive"');
785
-	@Header('HTTP/1.0 401 Unauthorized');
786
-	$corps = '';
787
-	$public = generer_url_public();
788
-	$ecrire = generer_url_ecrire();
789
-	$retour = $retour ?: _T('icone_retour');
790
-	$corps .= "<p>$raison</p>[<a href='$public'>$retour</a>] ";
791
-	if ($url) {
792
-		$corps .= "[<a href='" . generer_url_action('cookie', "essai_auth_http=oui&$url") . "'>$re</a>]";
793
-	}
794
-
795
-	if ($lien) {
796
-		$corps .= " [<a href='$ecrire'>" . _T('login_espace_prive') . '</a>]';
797
-	}
798
-	include_spip('inc/minipres');
799
-	echo minipres($pb, $corps);
800
-	exit;
784
+    @Header('WWW-Authenticate: Basic realm="espace prive"');
785
+    @Header('HTTP/1.0 401 Unauthorized');
786
+    $corps = '';
787
+    $public = generer_url_public();
788
+    $ecrire = generer_url_ecrire();
789
+    $retour = $retour ?: _T('icone_retour');
790
+    $corps .= "<p>$raison</p>[<a href='$public'>$retour</a>] ";
791
+    if ($url) {
792
+        $corps .= "[<a href='" . generer_url_action('cookie', "essai_auth_http=oui&$url") . "'>$re</a>]";
793
+    }
794
+
795
+    if ($lien) {
796
+        $corps .= " [<a href='$ecrire'>" . _T('login_espace_prive') . '</a>]';
797
+    }
798
+    include_spip('inc/minipres');
799
+    echo minipres($pb, $corps);
800
+    exit;
801 801
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -15 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	}
59 59
 
60 60
 	$n = (int) sql_errno();
61
-	spip_log("Erreur base de donnees $n " . sql_error());
61
+	spip_log("Erreur base de donnees $n ".sql_error());
62 62
 
63 63
 	return $n ?: 1;
64 64
 }
@@ -101,19 +101,19 @@  discard block
 block discarded – undo
101 101
 		// erreur SQL a afficher
102 102
 		$raison = minipres(
103 103
 			_T('info_travaux_titre'),
104
-			_T('titre_probleme_technique') . '<p><tt>' . sql_errno() . ' ' . sql_error() . '</tt></p>'
104
+			_T('titre_probleme_technique').'<p><tt>'.sql_errno().' '.sql_error().'</tt></p>'
105 105
 		);
106 106
 	} elseif (@$raison['statut']) {
107 107
 		// un simple visiteur n'a pas acces a l'espace prive
108
-		spip_log('connexion refusee a ' . @$raison['id_auteur']);
108
+		spip_log('connexion refusee a '.@$raison['id_auteur']);
109 109
 		$est_connecte = (!empty($GLOBALS['visiteur_session']['login']) && !empty($GLOBALS['visiteur_session']['statut'])); // idem test balise #URL_LOGOUT
110 110
 		$raison = minipres(
111 111
 			_T('avis_erreur_connexion'),
112 112
 			_T('avis_erreur_visiteur')
113 113
 				// Lien vers le site public
114
-				. '<br /><a href="' . url_de_base() . '">' . _T('login_retour_public') . '</a>'
114
+				. '<br /><a href="'.url_de_base().'">'._T('login_retour_public').'</a>'
115 115
 				// Si la personne est connectée, lien de déconnexion ramenant vers la page de login
116
-				. ($est_connecte ? ' | <a href="' . generer_url_public('', 'action=logout&amp;logout=prive') . '">' . _T('icone_deconnecter') . '</a>' : '')
116
+				. ($est_connecte ? ' | <a href="'.generer_url_public('', 'action=logout&amp;logout=prive').'">'._T('icone_deconnecter').'</a>' : '')
117 117
 		);
118 118
 	} else {
119 119
 		// auteur en fin de droits ...
@@ -201,8 +201,7 @@  discard block
 block discarded – undo
201 201
 	$where = (is_numeric($id_auteur)
202 202
 		/*AND $id_auteur>0*/ // reprise lors des restaurations
203 203
 	) ?
204
-		"id_auteur=$id_auteur" :
205
-		(strlen((string) $GLOBALS['connect_login']) ? 'login=' . sql_quote($GLOBALS['connect_login'], '', 'text') : '');
204
+		"id_auteur=$id_auteur" : (strlen((string) $GLOBALS['connect_login']) ? 'login='.sql_quote($GLOBALS['connect_login'], '', 'text') : '');
206 205
 
207 206
 	if (!$where) {
208 207
 		return '';
@@ -244,7 +243,7 @@  discard block
 block discarded – undo
244 243
 	$GLOBALS['connect_login'] = $row['login'];
245 244
 	$GLOBALS['connect_statut'] = $row['statut'];
246 245
 
247
-	$GLOBALS['visiteur_session'] = array_merge((array)$GLOBALS['visiteur_session'], $row);
246
+	$GLOBALS['visiteur_session'] = array_merge((array) $GLOBALS['visiteur_session'], $row);
248 247
 
249 248
 	// au cas ou : ne pas memoriser les champs sensibles
250 249
 	unset($GLOBALS['visiteur_session']['pass']);
@@ -316,7 +315,7 @@  discard block
 block discarded – undo
316 315
  * @return string
317 316
  */
318 317
 function auth_a_loger() {
319
-	$redirect = generer_url_public('login', 'url=' . rawurlencode((string) self('&', true)), true);
318
+	$redirect = generer_url_public('login', 'url='.rawurlencode((string) self('&', true)), true);
320 319
 
321 320
 	// un echec au "bonjour" (login initial) quand le statut est
322 321
 	// inconnu signale sans doute un probleme de cookies
@@ -352,7 +351,7 @@  discard block
 block discarded – undo
352 351
 	$date ??= date('Y-m-d H:i:s');
353 352
 
354 353
 	if (abs(strtotime($date) - $connect_quand) >= 60) {
355
-		sql_updateq('spip_auteurs', ['en_ligne' => $date], 'id_auteur=' . (int) $row['id_auteur']);
354
+		sql_updateq('spip_auteurs', ['en_ligne' => $date], 'id_auteur='.(int) $row['id_auteur']);
356 355
 		$row['en_ligne'] = $date;
357 356
 	}
358 357
 
@@ -460,7 +459,7 @@  discard block
 block discarded – undo
460 459
 	if (
461 460
 		!$login
462 461
 		|| !($login_base = auth_retrouver_login($login, $serveur))
463
-		|| !($row = sql_fetsel('*', 'spip_auteurs', 'login=' . sql_quote($login_base, $serveur, 'text'), '', '', '', '', $serveur))
462
+		|| !($row = sql_fetsel('*', 'spip_auteurs', 'login='.sql_quote($login_base, $serveur, 'text'), '', '', '', '', $serveur))
464 463
 	) {
465 464
 		// generer de fausses infos, mais credibles, pour eviter une attaque
466 465
 		// https://core.spip.net/issues/1758 + https://core.spip.net/issues/3691
@@ -569,7 +568,7 @@  discard block
 block discarded – undo
569 568
 	sql_updateq(
570 569
 		'spip_auteurs',
571 570
 		['prefs' => serialize($p)],
572
-		'id_auteur=' . (int) $auteur['id_auteur']
571
+		'id_auteur='.(int) $auteur['id_auteur']
573 572
 	);
574 573
 
575 574
 	//  bloquer ici le visiteur qui tente d'abuser de ses droits
@@ -733,7 +732,7 @@  discard block
 block discarded – undo
733 732
 		return false;
734 733
 	}
735 734
 
736
-	$row = sql_fetsel('*', 'spip_auteurs', 'login=' . sql_quote($login_base, $serveur, 'text'), '', '', '', '', $serveur);
735
+	$row = sql_fetsel('*', 'spip_auteurs', 'login='.sql_quote($login_base, $serveur, 'text'), '', '', '', '', $serveur);
737 736
 
738 737
 	if (!$row) {
739 738
 		if (
@@ -789,11 +788,11 @@  discard block
 block discarded – undo
789 788
 	$retour = $retour ?: _T('icone_retour');
790 789
 	$corps .= "<p>$raison</p>[<a href='$public'>$retour</a>] ";
791 790
 	if ($url) {
792
-		$corps .= "[<a href='" . generer_url_action('cookie', "essai_auth_http=oui&$url") . "'>$re</a>]";
791
+		$corps .= "[<a href='".generer_url_action('cookie', "essai_auth_http=oui&$url")."'>$re</a>]";
793 792
 	}
794 793
 
795 794
 	if ($lien) {
796
-		$corps .= " [<a href='$ecrire'>" . _T('login_espace_prive') . '</a>]';
795
+		$corps .= " [<a href='$ecrire'>"._T('login_espace_prive').'</a>]';
797 796
 	}
798 797
 	include_spip('inc/minipres');
799 798
 	echo minipres($pb, $corps);
Please login to merge, or discard this patch.
ecrire/inc/journal.php 2 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 \***************************************************************************/
11 11
 
12 12
 if (!defined('_ECRIRE_INC_VERSION')) {
13
-	return;
13
+    return;
14 14
 }
15 15
 
16 16
 
@@ -23,11 +23,11 @@  discard block
 block discarded – undo
23 23
  * @param array $opt
24 24
  */
25 25
 function inc_journal_dist($phrase, $opt = []) {
26
-	if (!strlen((string) $phrase)) {
27
-		return;
28
-	}
29
-	if ($opt) {
30
-		$phrase .= ' :: ' . str_replace("\n", ' ', implode(', ', $opt));
31
-	}
32
-	spip_log($phrase, 'journal');
26
+    if (!strlen((string) $phrase)) {
27
+        return;
28
+    }
29
+    if ($opt) {
30
+        $phrase .= ' :: ' . str_replace("\n", ' ', implode(', ', $opt));
31
+    }
32
+    spip_log($phrase, 'journal');
33 33
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@
 block discarded – undo
27 27
 		return;
28 28
 	}
29 29
 	if ($opt) {
30
-		$phrase .= ' :: ' . str_replace("\n", ' ', implode(', ', $opt));
30
+		$phrase .= ' :: '.str_replace("\n", ' ', implode(', ', $opt));
31 31
 	}
32 32
 	spip_log($phrase, 'journal');
33 33
 }
Please login to merge, or discard this patch.