Completed
Push — master ( ad9227...bd2221 )
by cam
01:15
created
ecrire/inc/couleurs.php 2 patches
Indentation   +63 added lines, -63 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
 /**
@@ -37,70 +37,70 @@  discard block
 block discarded – undo
37 37
  * @return array|string
38 38
  */
39 39
 function inc_couleurs_dist($choix = null, $ajouter = false) {
40
-	static $couleurs_spip = [
41
-		// Violet soutenu
42
-		9 => ['couleur_theme' => '#9a6ef2'],
43
-		// Violet rosé
44
-		4 => ['couleur_theme' => '#c464cb'],
45
-		// Rose interface SPIP
46
-		2 => ['couleur_theme' =>  '#F02364'],
47
-		// Rouge
48
-		8 => ['couleur_theme' => '#ff4524'],
49
-		// Orange
50
-		3 => ['couleur_theme' => '#c97500'],
51
-		// Vert SPIP
52
-		1 => ['couleur_theme' => '#9dba00'],
53
-		// Vert Troglo
54
-		7 => ['couleur_theme' => '#419a2c'],
55
-		// Bleu-vert
56
-		12 => ['couleur_theme' => '#269681'],
57
-		//  Bleu pastel
58
-		5 => ['couleur_theme' => '#3190ae'],
59
-		//  Bleu Kermesse
60
-		11 => ['couleur_theme' => '#288bdd'],
61
-		//  Gris bleuté
62
-		6 => ['couleur_theme' => '#7d90a2'],
63
-		//  Gris
64
-		10 => ['couleur_theme' => '#909090'],
65
-	];
40
+    static $couleurs_spip = [
41
+        // Violet soutenu
42
+        9 => ['couleur_theme' => '#9a6ef2'],
43
+        // Violet rosé
44
+        4 => ['couleur_theme' => '#c464cb'],
45
+        // Rose interface SPIP
46
+        2 => ['couleur_theme' =>  '#F02364'],
47
+        // Rouge
48
+        8 => ['couleur_theme' => '#ff4524'],
49
+        // Orange
50
+        3 => ['couleur_theme' => '#c97500'],
51
+        // Vert SPIP
52
+        1 => ['couleur_theme' => '#9dba00'],
53
+        // Vert Troglo
54
+        7 => ['couleur_theme' => '#419a2c'],
55
+        // Bleu-vert
56
+        12 => ['couleur_theme' => '#269681'],
57
+        //  Bleu pastel
58
+        5 => ['couleur_theme' => '#3190ae'],
59
+        //  Bleu Kermesse
60
+        11 => ['couleur_theme' => '#288bdd'],
61
+        //  Gris bleuté
62
+        6 => ['couleur_theme' => '#7d90a2'],
63
+        //  Gris
64
+        10 => ['couleur_theme' => '#909090'],
65
+    ];
66 66
 
67
-	if (is_numeric($choix)) {
68
-		$c = $couleurs_spip[$choix];
69
-		// compat < SPIP 3.3
70
-		include_spip('inc/filtres_images_mini');
71
-		$c['couleur_foncee'] = $c['couleur_theme'];
72
-		$c['couleur_claire'] = '#' . couleur_eclaircir($c['couleur_theme'], .5);
67
+    if (is_numeric($choix)) {
68
+        $c = $couleurs_spip[$choix];
69
+        // compat < SPIP 3.3
70
+        include_spip('inc/filtres_images_mini');
71
+        $c['couleur_foncee'] = $c['couleur_theme'];
72
+        $c['couleur_claire'] = '#' . couleur_eclaircir($c['couleur_theme'], .5);
73 73
 
74
-		return
75
-			'couleur_theme=' . substr((string) $c['couleur_theme'], 1)
76
-			// compat < SPIP 3.3
77
-			. '&couleur_claire=' . substr($c['couleur_claire'], 1)
78
-			. '&couleur_foncee=' . substr((string) $c['couleur_foncee'], 1);
79
-	} else {
80
-		if (is_array($choix)) {
81
-			// compat < SPIP 3.3
82
-			$compat_spip_33 = function ($c) {
83
-				if (!isset($c['couleur_theme'])) {
84
-					$c['couleur_theme'] = $c['couleur_foncee'];
85
-					unset($c['couleur_foncee']);
86
-					unset($c['couleur_claire']);
87
-					unset($c['couleur_lien']);
88
-					unset($c['couleur_lien_off']);
89
-				}
90
-				return $c;
91
-			};
92
-			if ($ajouter) {
93
-				foreach ($choix as $c) {
94
-					$couleurs_spip[] = $compat_spip_33($c);
95
-				}
74
+        return
75
+            'couleur_theme=' . substr((string) $c['couleur_theme'], 1)
76
+            // compat < SPIP 3.3
77
+            . '&couleur_claire=' . substr($c['couleur_claire'], 1)
78
+            . '&couleur_foncee=' . substr((string) $c['couleur_foncee'], 1);
79
+    } else {
80
+        if (is_array($choix)) {
81
+            // compat < SPIP 3.3
82
+            $compat_spip_33 = function ($c) {
83
+                if (!isset($c['couleur_theme'])) {
84
+                    $c['couleur_theme'] = $c['couleur_foncee'];
85
+                    unset($c['couleur_foncee']);
86
+                    unset($c['couleur_claire']);
87
+                    unset($c['couleur_lien']);
88
+                    unset($c['couleur_lien_off']);
89
+                }
90
+                return $c;
91
+            };
92
+            if ($ajouter) {
93
+                foreach ($choix as $c) {
94
+                    $couleurs_spip[] = $compat_spip_33($c);
95
+                }
96 96
 
97
-				return $couleurs_spip;
98
-			} else {
99
-				$choix = array_map($compat_spip_33, $choix);
100
-				return $couleurs_spip = $choix;
101
-			}
102
-		}
103
-	}
97
+                return $couleurs_spip;
98
+            } else {
99
+                $choix = array_map($compat_spip_33, $choix);
100
+                return $couleurs_spip = $choix;
101
+            }
102
+        }
103
+    }
104 104
 
105
-	return $couleurs_spip;
105
+    return $couleurs_spip;
106 106
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -69,17 +69,17 @@
 block discarded – undo
69 69
 		// compat < SPIP 3.3
70 70
 		include_spip('inc/filtres_images_mini');
71 71
 		$c['couleur_foncee'] = $c['couleur_theme'];
72
-		$c['couleur_claire'] = '#' . couleur_eclaircir($c['couleur_theme'], .5);
72
+		$c['couleur_claire'] = '#'.couleur_eclaircir($c['couleur_theme'], .5);
73 73
 
74 74
 		return
75
-			'couleur_theme=' . substr((string) $c['couleur_theme'], 1)
75
+			'couleur_theme='.substr((string) $c['couleur_theme'], 1)
76 76
 			// compat < SPIP 3.3
77
-			. '&couleur_claire=' . substr($c['couleur_claire'], 1)
78
-			. '&couleur_foncee=' . substr((string) $c['couleur_foncee'], 1);
77
+			. '&couleur_claire='.substr($c['couleur_claire'], 1)
78
+			. '&couleur_foncee='.substr((string) $c['couleur_foncee'], 1);
79 79
 	} else {
80 80
 		if (is_array($choix)) {
81 81
 			// compat < SPIP 3.3
82
-			$compat_spip_33 = function ($c) {
82
+			$compat_spip_33 = function($c) {
83 83
 				if (!isset($c['couleur_theme'])) {
84 84
 					$c['couleur_theme'] = $c['couleur_foncee'];
85 85
 					unset($c['couleur_foncee']);
Please login to merge, or discard this patch.
ecrire/inc/install.php 2 patches
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.
Indentation   +343 added lines, -343 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,74 +143,74 @@  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
-	if ($err) {
198
-		echo "<div class='error'>"
199
-			. '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>";
200
-		foreach ($err as $e) {
201
-			echo "<li><strong>$e</strong></li>\n";
202
-		}
203
-
204
-		# a priori ici on pourrait die(), mais il faut laisser la possibilite
205
-		# de forcer malgre tout (pour tester, ou si bug de detection)
206
-		echo "</ul></div>\n";
207
-	}
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
+    if ($err) {
198
+        echo "<div class='error'>"
199
+            . '<h3>' . _T('avis_attention') . '</h3><p>' . _T('install_echec_annonce') . "</p><ul class='spip'>";
200
+        foreach ($err as $e) {
201
+            echo "<li><strong>$e</strong></li>\n";
202
+        }
203
+
204
+        # a priori ici on pourrait die(), mais il faut laisser la possibilite
205
+        # de forcer malgre tout (pour tester, ou si bug de detection)
206
+        echo "</ul></div>\n";
207
+    }
208 208
 }
209 209
 
210 210
 
211 211
 function info_etape($titre, $complement = '') {
212
-	return '<h2>' . $titre . "</h2>\n" .
213
-	($complement ? '' . $complement . "\n" : '');
212
+    return '<h2>' . $titre . "</h2>\n" .
213
+    ($complement ? '' . $complement . "\n" : '');
214 214
 }
215 215
 
216 216
 /**
@@ -220,143 +220,143 @@  discard block
 block discarded – undo
220 220
  * @return string Code HTML du bouton
221 221
  **/
222 222
 function bouton_suivant($code = '') {
223
-	if ($code == '') {
224
-		$code = _T('bouton_suivant');
225
-	}
226
-	static $suivant = 0;
227
-	$id = 'suivant' . (($suivant > 0) ? (string) $suivant : '');
228
-	$suivant += 1;
229
-
230
-	return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" .
231
-	$code .
232
-	" >>\" /></p>\n";
223
+    if ($code == '') {
224
+        $code = _T('bouton_suivant');
225
+    }
226
+    static $suivant = 0;
227
+    $id = 'suivant' . (($suivant > 0) ? (string) $suivant : '');
228
+    $suivant += 1;
229
+
230
+    return "\n<p class='boutons suivant'><input id='" . $id . "' type='submit'\nvalue=\"" .
231
+    $code .
232
+    " >>\" /></p>\n";
233 233
 }
234 234
 
235 235
 function info_progression_etape($en_cours, $phase, $dir, $erreur = false) {
236
-	$intitule_etat = [];
237
-
238
-	$liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$');
239
-	$debut = 1;
240
-	$last = is_countable($liste) ? count($liste) : 0;
241
-
242
-	include_spip('inc/texte');
243
-	$intitule_etat['etape_'][1] = typo(_T('info_connexion_base_donnee'));
244
-	$intitule_etat['etape_'][2] = typo(_T('menu_aide_installation_choix_base'));
245
-	$intitule_etat['etape_'][3] = typo(_T('info_informations_personnelles'));
246
-	$intitule_etat['etape_'][4] = typo(_T('info_derniere_etape'));
247
-
248
-	$intitule_etat['etape_ldap'][1] = typo(_T('titre_connexion_ldap'));
249
-	$intitule_etat['etape_ldap'][2] = typo(_T('titre_connexion_ldap'));
250
-	$intitule_etat['etape_ldap'][3] = typo(_T('info_chemin_acces_1'));
251
-	$intitule_etat['etape_ldap'][4] = typo(_T('info_reglage_ldap'));
252
-	$intitule_etat['etape_ldap'][5] = typo(_T('info_ldap_ok'));
253
-
254
-	$aff_etapes = "<ul id='infos_etapes' class='infos_$phase$en_cours'>";
255
-
256
-	foreach (array_keys($liste) as $etape) {
257
-		if ($debut < $last) {
258
-			if ($debut == $en_cours && $erreur) {
259
-				$class = 'on erreur';
260
-			} else {
261
-				if ($debut == $en_cours) {
262
-					$class = 'on';
263
-				} else {
264
-					$class = $debut > $en_cours ? 'prochains' : 'valides';
265
-				}
266
-			}
267
-
268
-			$aff_etapes .= "<li class='$class'><div class='fond'>";
269
-			$aff_etapes .= '<em>' . _T('etape') . " </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
270
-			$aff_etapes .= '<' . (($debut == $en_cours) ? 'strong' : 'span') . ' class="label_etape">' . $intitule_etat["$phase"][$debut] . '</' . (($debut == $en_cours) ? 'strong' : 'span') . '>';
271
-			$aff_etapes .= '</div></li>';
272
-		}
273
-		$debut++;
274
-	}
275
-
276
-	return $aff_etapes . '</ul>';
236
+    $intitule_etat = [];
237
+
238
+    $liste = find_all_in_path($dir, $phase . '(([0-9])+|fin)[.]php$');
239
+    $debut = 1;
240
+    $last = is_countable($liste) ? count($liste) : 0;
241
+
242
+    include_spip('inc/texte');
243
+    $intitule_etat['etape_'][1] = typo(_T('info_connexion_base_donnee'));
244
+    $intitule_etat['etape_'][2] = typo(_T('menu_aide_installation_choix_base'));
245
+    $intitule_etat['etape_'][3] = typo(_T('info_informations_personnelles'));
246
+    $intitule_etat['etape_'][4] = typo(_T('info_derniere_etape'));
247
+
248
+    $intitule_etat['etape_ldap'][1] = typo(_T('titre_connexion_ldap'));
249
+    $intitule_etat['etape_ldap'][2] = typo(_T('titre_connexion_ldap'));
250
+    $intitule_etat['etape_ldap'][3] = typo(_T('info_chemin_acces_1'));
251
+    $intitule_etat['etape_ldap'][4] = typo(_T('info_reglage_ldap'));
252
+    $intitule_etat['etape_ldap'][5] = typo(_T('info_ldap_ok'));
253
+
254
+    $aff_etapes = "<ul id='infos_etapes' class='infos_$phase$en_cours'>";
255
+
256
+    foreach (array_keys($liste) as $etape) {
257
+        if ($debut < $last) {
258
+            if ($debut == $en_cours && $erreur) {
259
+                $class = 'on erreur';
260
+            } else {
261
+                if ($debut == $en_cours) {
262
+                    $class = 'on';
263
+                } else {
264
+                    $class = $debut > $en_cours ? 'prochains' : 'valides';
265
+                }
266
+            }
267
+
268
+            $aff_etapes .= "<li class='$class'><div class='fond'>";
269
+            $aff_etapes .= '<em>' . _T('etape') . " </em><span class='numero_etape'>$debut</span><em>&nbsp;: </em>";
270
+            $aff_etapes .= '<' . (($debut == $en_cours) ? 'strong' : 'span') . ' class="label_etape">' . $intitule_etat["$phase"][$debut] . '</' . (($debut == $en_cours) ? 'strong' : 'span') . '>';
271
+            $aff_etapes .= '</div></li>';
272
+        }
273
+        $debut++;
274
+    }
275
+
276
+    return $aff_etapes . '</ul>';
277 277
 }
278 278
 
279 279
 
280 280
 function fieldset($legend, $champs = [], $apres = '', $avant = '') {
281
-	return "<fieldset>\n" .
282
-	$avant .
283
-	($legend ? '<legend>' . $legend . "</legend>\n" : '') .
284
-	fieldset_champs($champs) .
285
-	$apres .
286
-	"</fieldset>\n";
281
+    return "<fieldset>\n" .
282
+    $avant .
283
+    ($legend ? '<legend>' . $legend . "</legend>\n" : '') .
284
+    fieldset_champs($champs) .
285
+    $apres .
286
+    "</fieldset>\n";
287 287
 }
288 288
 
289 289
 function fieldset_champs($champs = []) {
290
-	$fieldset = '';
291
-	foreach ($champs as $nom => $contenu) {
292
-		$type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', (string) $nom) ? 'password' : 'text');
293
-		$class = isset($contenu['hidden']) ? '' : "class='formo' size='40' ";
294
-		if (isset($contenu['alternatives'])) {
295
-			$fieldset .= $contenu['label'] . "\n";
296
-			foreach ($contenu['alternatives'] as $valeur => $label) {
297
-				$fieldset .= "<input type='radio' name='" . $nom .
298
-					"' id='$nom-$valeur' value='$valeur'"
299
-					. (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '')
300
-					. "/>\n";
301
-				$fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n";
302
-			}
303
-			$fieldset .= "<br />\n";
304
-		} else {
305
-			$fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n";
306
-			$fieldset .= '<input ' . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'"
307
-				. (preg_match(',^(pass|login),', (string) $nom) ? " autocomplete='off'" : '')
308
-				. ((isset($contenu['required']) && $contenu['required']) ? " required='required'" : '')
309
-				. " />\n";
310
-		}
311
-	}
312
-
313
-	return $fieldset;
290
+    $fieldset = '';
291
+    foreach ($champs as $nom => $contenu) {
292
+        $type = isset($contenu['hidden']) ? 'hidden' : (preg_match(',^pass,', (string) $nom) ? 'password' : 'text');
293
+        $class = isset($contenu['hidden']) ? '' : "class='formo' size='40' ";
294
+        if (isset($contenu['alternatives'])) {
295
+            $fieldset .= $contenu['label'] . "\n";
296
+            foreach ($contenu['alternatives'] as $valeur => $label) {
297
+                $fieldset .= "<input type='radio' name='" . $nom .
298
+                    "' id='$nom-$valeur' value='$valeur'"
299
+                    . (($valeur == $contenu['valeur']) ? "\nchecked='checked'" : '')
300
+                    . "/>\n";
301
+                $fieldset .= "<label for='$nom-$valeur'>" . $label . "</label>\n";
302
+            }
303
+            $fieldset .= "<br />\n";
304
+        } else {
305
+            $fieldset .= "<label for='" . $nom . "'>" . $contenu['label'] . "</label>\n";
306
+            $fieldset .= '<input ' . $class . "type='" . $type . "' id='" . $nom . "' name='" . $nom . "'\nvalue='" . $contenu['valeur'] . "'"
307
+                . (preg_match(',^(pass|login),', (string) $nom) ? " autocomplete='off'" : '')
308
+                . ((isset($contenu['required']) && $contenu['required']) ? " required='required'" : '')
309
+                . " />\n";
310
+        }
311
+    }
312
+
313
+    return $fieldset;
314 314
 }
315 315
 
316 316
 function install_select_serveur() {
317
-	$options = [];
318
-	$dir = _DIR_RESTREINT . 'req/';
319
-	$d = opendir($dir);
320
-	if (!$d) {
321
-		return [];
322
-	}
323
-	while (($f = readdir($d)) !== false) {
324
-		if (
325
-			preg_match('/^(.*)[.]php$/', $f, $s)
326
-			&& is_readable($f = $dir . $f)
327
-		) {
328
-			require_once($f);
329
-			$s = $s[1];
330
-			$v = 'spip_versions_' . $s;
331
-			if (function_exists($v) && $v()) {
332
-				$titre = _T("install_select_type_$s");
333
-				// proposer mysql par defaut si dispo
334
-				$checked = ($s == 'mysql' ? " checked='checked'" : '');
335
-				$options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>"
336
-					. "<label for='$s'>" . ($titre ?: $s) . '</label></li>';
337
-			} else {
338
-				spip_log("$s: portage indisponible");
339
-			}
340
-		}
341
-	}
342
-	sort($options);
343
-
344
-	return $options;
317
+    $options = [];
318
+    $dir = _DIR_RESTREINT . 'req/';
319
+    $d = opendir($dir);
320
+    if (!$d) {
321
+        return [];
322
+    }
323
+    while (($f = readdir($d)) !== false) {
324
+        if (
325
+            preg_match('/^(.*)[.]php$/', $f, $s)
326
+            && is_readable($f = $dir . $f)
327
+        ) {
328
+            require_once($f);
329
+            $s = $s[1];
330
+            $v = 'spip_versions_' . $s;
331
+            if (function_exists($v) && $v()) {
332
+                $titre = _T("install_select_type_$s");
333
+                // proposer mysql par defaut si dispo
334
+                $checked = ($s == 'mysql' ? " checked='checked'" : '');
335
+                $options[$s] = "<li><input type='radio' id='$s' value='$s' name='server_db'$checked>"
336
+                    . "<label for='$s'>" . ($titre ?: $s) . '</label></li>';
337
+            } else {
338
+                spip_log("$s: portage indisponible");
339
+            }
340
+        }
341
+    }
342
+    sort($options);
343
+
344
+    return $options;
345 345
 }
346 346
 
347 347
 function install_connexion_form($db, $login, #[\SensitiveParameter] $pass, $predef, $hidden, $etape, $jquery = true) {
348
-	$server_db = (is_string($predef[0])) ? $predef[0] : '';
349
-
350
-	return generer_form_ecrire('install', (
351
-		"\n<input type='hidden' name='etape' value='$etape' />"
352
-		. $hidden
353
-		. (_request('echec') ?
354
-			('<p><b>' . _T('avis_connexion_echec_1') .
355
-				'</b></p><p>' . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . '</p>')
356
-			: '')
357
-
358
-		. ($jquery ? http_script('', 'jquery.js') : '')
359
-		. http_script('
348
+    $server_db = (is_string($predef[0])) ? $predef[0] : '';
349
+
350
+    return generer_form_ecrire('install', (
351
+        "\n<input type='hidden' name='etape' value='$etape' />"
352
+        . $hidden
353
+        . (_request('echec') ?
354
+            ('<p><b>' . _T('avis_connexion_echec_1') .
355
+                '</b></p><p>' . _T('avis_connexion_echec_2') . "</p><p style='font-size: small;'>" . _T('avis_connexion_echec_3') . '</p>')
356
+            : '')
357
+
358
+        . ($jquery ? http_script('', 'jquery.js') : '')
359
+        . http_script('
360 360
 		jQuery(function($) {
361 361
 			$details_db = $("#install_adresse_base_hebergeur,#install_login_base_hebergeur,#install_pass_base_hebergeur");
362 362
 			$("input[type=hidden][name=server_db]").each(function(){
@@ -389,145 +389,145 @@  discard block
 block discarded – undo
389 389
 			});
390 390
 		});')
391 391
 
392
-		. ($server_db
393
-			? '<input type="hidden" name="server_db" value="' . $server_db . '" />'
394
-			. (($predef[0])
395
-				? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>')
396
-				: '')
397
-			: ('<fieldset><legend>'
398
-				. _T('install_select_type_db')
399
-				. '</legend>'
400
-				. '<p class="explication">'
401
-				. _T('install_types_db_connus')
402
-				// Passer l'avertissement SQLIte en  commentaire, on pourra facilement le supprimer par la suite sans changer les traductions.
403
-				// . "<br /><small>(". _T('install_types_db_connus_avertissement') .')</small>'
404
-				. '</p>'
405
-				. "\n<div class='p'>\n<ul>\n"
406
-				. implode("\n", install_select_serveur())
407
-				. "\n</ul>\n</div></fieldset>")
408
-		)
409
-		. '<div id="install_adresse_base_hebergeur">'
410
-		. '<p>' . _T('texte_connexion_mysql') . '</p>'
411
-		. ($predef[1]
412
-			? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>'
413
-			: fieldset(
414
-				_T('entree_base_donnee_1'),
415
-				[
416
-					'adresse_db' => [
417
-						'label' => $db[1],
418
-						'valeur' => $db[0]
419
-					],
420
-				]
421
-			)
422
-		)
423
-		. '</div>'
424
-
425
-		. '<div id="install_login_base_hebergeur">'
426
-		. ($predef[2]
427
-			? '<h3>' . _T('install_login_base_hebergeur') . '</h3>'
428
-			: fieldset(
429
-				_T('entree_login_connexion_1'),
430
-				[
431
-					'login_db' => [
432
-						'label' => $login[1],
433
-						'valeur' => $login[0]
434
-					],
435
-				]
436
-			)
437
-		)
438
-		. '</div>'
439
-
440
-		. '<div id="install_pass_base_hebergeur">'
441
-		. ($predef[3]
442
-			? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>'
443
-			: fieldset(
444
-				_T('entree_mot_passe_1'),
445
-				[
446
-					'pass_db' => [
447
-						'label' => $pass[1],
448
-						'valeur' => $pass[0]
449
-					],
450
-				]
451
-			)
452
-		)
453
-		. '</div>'
454
-
455
-		. bouton_suivant()));
392
+        . ($server_db
393
+            ? '<input type="hidden" name="server_db" value="' . $server_db . '" />'
394
+            . (($predef[0])
395
+                ? ('<h3>' . _T('install_serveur_hebergeur') . '</h3>')
396
+                : '')
397
+            : ('<fieldset><legend>'
398
+                . _T('install_select_type_db')
399
+                . '</legend>'
400
+                . '<p class="explication">'
401
+                . _T('install_types_db_connus')
402
+                // Passer l'avertissement SQLIte en  commentaire, on pourra facilement le supprimer par la suite sans changer les traductions.
403
+                // . "<br /><small>(". _T('install_types_db_connus_avertissement') .')</small>'
404
+                . '</p>'
405
+                . "\n<div class='p'>\n<ul>\n"
406
+                . implode("\n", install_select_serveur())
407
+                . "\n</ul>\n</div></fieldset>")
408
+        )
409
+        . '<div id="install_adresse_base_hebergeur">'
410
+        . '<p>' . _T('texte_connexion_mysql') . '</p>'
411
+        . ($predef[1]
412
+            ? '<h3>' . _T('install_adresse_base_hebergeur') . '</h3>'
413
+            : fieldset(
414
+                _T('entree_base_donnee_1'),
415
+                [
416
+                    'adresse_db' => [
417
+                        'label' => $db[1],
418
+                        'valeur' => $db[0]
419
+                    ],
420
+                ]
421
+            )
422
+        )
423
+        . '</div>'
424
+
425
+        . '<div id="install_login_base_hebergeur">'
426
+        . ($predef[2]
427
+            ? '<h3>' . _T('install_login_base_hebergeur') . '</h3>'
428
+            : fieldset(
429
+                _T('entree_login_connexion_1'),
430
+                [
431
+                    'login_db' => [
432
+                        'label' => $login[1],
433
+                        'valeur' => $login[0]
434
+                    ],
435
+                ]
436
+            )
437
+        )
438
+        . '</div>'
439
+
440
+        . '<div id="install_pass_base_hebergeur">'
441
+        . ($predef[3]
442
+            ? '<h3>' . _T('install_pass_base_hebergeur') . '</h3>'
443
+            : fieldset(
444
+                _T('entree_mot_passe_1'),
445
+                [
446
+                    'pass_db' => [
447
+                        'label' => $pass[1],
448
+                        'valeur' => $pass[0]
449
+                    ],
450
+                ]
451
+            )
452
+        )
453
+        . '</div>'
454
+
455
+        . bouton_suivant()));
456 456
 }
457 457
 
458 458
 // 4 valeurs qu'on reconduit d'un script a l'autre
459 459
 // sauf s'ils sont predefinis.
460 460
 
461 461
 function predef_ou_cache($adresse_db, $login_db, $pass_db, $server_db) {
462
-	return ((defined('_INSTALL_HOST_DB'))
463
-		? ''
464
-		: "\n<input type='hidden' name='adresse_db'  value=\"" . spip_htmlspecialchars($adresse_db) . '" />'
465
-	)
466
-	. ((defined('_INSTALL_USER_DB'))
467
-		? ''
468
-		: "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . '" />'
469
-	)
470
-	. ((defined('_INSTALL_PASS_DB'))
471
-		? ''
472
-		: "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . '" />'
473
-	)
474
-
475
-	. ((defined('_INSTALL_SERVER_DB'))
476
-		? ''
477
-		: "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . '" />'
478
-	);
462
+    return ((defined('_INSTALL_HOST_DB'))
463
+        ? ''
464
+        : "\n<input type='hidden' name='adresse_db'  value=\"" . spip_htmlspecialchars($adresse_db) . '" />'
465
+    )
466
+    . ((defined('_INSTALL_USER_DB'))
467
+        ? ''
468
+        : "\n<input type='hidden' name='login_db' value=\"" . spip_htmlspecialchars($login_db) . '" />'
469
+    )
470
+    . ((defined('_INSTALL_PASS_DB'))
471
+        ? ''
472
+        : "\n<input type='hidden' name='pass_db' value=\"" . spip_htmlspecialchars($pass_db) . '" />'
473
+    )
474
+
475
+    . ((defined('_INSTALL_SERVER_DB'))
476
+        ? ''
477
+        : "\n<input type='hidden' name='server_db' value=\"" . spip_htmlspecialchars($server_db) . '" />'
478
+    );
479 479
 }
480 480
 
481 481
 // presentation des bases existantes
482 482
 
483 483
 function install_etape_liste_bases($server_db, $login_db, $disabled = []) {
484
-	$bases = $checked = [];
485
-	$noms = sql_listdbs($server_db);
486
-	if (!$noms) {
487
-		return '';
488
-	}
489
-
490
-	foreach ($noms as $nom) {
491
-		$id = spip_htmlspecialchars($nom);
492
-		$dis = in_array($nom, $disabled) ? " disabled='disabled'" : '';
493
-		$base = ' name="choix_db" value="'
494
-			. $nom
495
-			. '"'
496
-			. $dis
497
-			. " type='radio' id='$id'";
498
-		$label = "<label for='$id'>"
499
-			. ($dis ? "<i>$nom</i>" : $nom)
500
-			. '</label>';
501
-
502
-		if (
503
-			!$checked
504
-			&& !$dis
505
-			&& ($nom == $login_db || $GLOBALS['table_prefix'] == $nom)
506
-		) {
507
-			$checked = "<input$base checked='checked' />\n$label";
508
-		} else {
509
-			$bases[] = "<input$base />\n$label";
510
-		}
511
-	}
512
-
513
-	if (!$bases && !$checked) {
514
-		return false;
515
-	}
516
-
517
-	if ($checked) {
518
-		array_unshift($bases, $checked);
519
-		$checked = true;
520
-	}
521
-
522
-	return [$checked, $bases];
484
+    $bases = $checked = [];
485
+    $noms = sql_listdbs($server_db);
486
+    if (!$noms) {
487
+        return '';
488
+    }
489
+
490
+    foreach ($noms as $nom) {
491
+        $id = spip_htmlspecialchars($nom);
492
+        $dis = in_array($nom, $disabled) ? " disabled='disabled'" : '';
493
+        $base = ' name="choix_db" value="'
494
+            . $nom
495
+            . '"'
496
+            . $dis
497
+            . " type='radio' id='$id'";
498
+        $label = "<label for='$id'>"
499
+            . ($dis ? "<i>$nom</i>" : $nom)
500
+            . '</label>';
501
+
502
+        if (
503
+            !$checked
504
+            && !$dis
505
+            && ($nom == $login_db || $GLOBALS['table_prefix'] == $nom)
506
+        ) {
507
+            $checked = "<input$base checked='checked' />\n$label";
508
+        } else {
509
+            $bases[] = "<input$base />\n$label";
510
+        }
511
+    }
512
+
513
+    if (!$bases && !$checked) {
514
+        return false;
515
+    }
516
+
517
+    if ($checked) {
518
+        array_unshift($bases, $checked);
519
+        $checked = true;
520
+    }
521
+
522
+    return [$checked, $bases];
523 523
 }
524 524
 
525 525
 function install_propager($hidden) {
526
-	$res = '';
527
-	foreach ($hidden as $k) {
528
-		$v = spip_htmlentities(_request($k));
529
-		$res .= "<input type='hidden' name='$k' value='$v' />";
530
-	}
526
+    $res = '';
527
+    foreach ($hidden as $k) {
528
+        $v = spip_htmlentities(_request($k));
529
+        $res .= "<input type='hidden' name='$k' value='$v' />";
530
+    }
531 531
 
532
-	return $res;
532
+    return $res;
533 533
 }
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   +2342 added lines, -2342 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
  * @package SPIP\Core\Filtres
21 21
  **/
22 22
 if (!defined('_ECRIRE_INC_VERSION')) {
23
-	return;
23
+    return;
24 24
 }
25 25
 
26 26
 include_spip('inc/charsets');
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
  * @return string Fonction PHP correspondante du filtre
47 47
  */
48 48
 function charger_filtre($fonc, $default = 'filtre_identite_dist') {
49
-	include_fichiers_fonctions(); // inclure les fichiers fonctions
50
-	return chercher_filtre($fonc, $default);
49
+    include_fichiers_fonctions(); // inclure les fichiers fonctions
50
+    return chercher_filtre($fonc, $default);
51 51
 }
52 52
 
53 53
 /**
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
  * @return string texte
58 58
  **/
59 59
 function filtre_identite_dist($texte) {
60
- return $texte;
60
+    return $texte;
61 61
 }
62 62
 
63 63
 /**
@@ -81,33 +81,33 @@  discard block
 block discarded – undo
81 81
  *     Fonction PHP correspondante du filtre demandé
82 82
  */
83 83
 function chercher_filtre($fonc, $default = null) {
84
-	if (!$fonc) {
85
-		return $default;
86
-	}
87
-	// Cas des types mime, sans confondre avec les appels de fonction de classe
88
-	// Foo::Bar
89
-	// qui peuvent etre avec un namespace : space\Foo::Bar
90
-	if (preg_match(',^[\w]+/,', $fonc)) {
91
-		$nom = preg_replace(',\W,', '_', $fonc);
92
-		$f = chercher_filtre($nom);
93
-		// cas du sous-type MIME sans filtre associe, passer au type:
94
-		// si filtre_text_plain pas defini, passe a filtre_text
95
-		if (!$f && $nom !== $fonc) {
96
-			$f = chercher_filtre(preg_replace(',\W.*$,', '', $fonc));
97
-		}
98
-
99
-		return $f;
100
-	}
101
-
102
-	include_fichiers_fonctions();
103
-	foreach (['filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc] as $f) {
104
-		trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels
105
-		if (is_callable($f)) {
106
-			return $f;
107
-		}
108
-	}
109
-
110
-	return $default;
84
+    if (!$fonc) {
85
+        return $default;
86
+    }
87
+    // Cas des types mime, sans confondre avec les appels de fonction de classe
88
+    // Foo::Bar
89
+    // qui peuvent etre avec un namespace : space\Foo::Bar
90
+    if (preg_match(',^[\w]+/,', $fonc)) {
91
+        $nom = preg_replace(',\W,', '_', $fonc);
92
+        $f = chercher_filtre($nom);
93
+        // cas du sous-type MIME sans filtre associe, passer au type:
94
+        // si filtre_text_plain pas defini, passe a filtre_text
95
+        if (!$f && $nom !== $fonc) {
96
+            $f = chercher_filtre(preg_replace(',\W.*$,', '', $fonc));
97
+        }
98
+
99
+        return $f;
100
+    }
101
+
102
+    include_fichiers_fonctions();
103
+    foreach (['filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc] as $f) {
104
+        trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels
105
+        if (is_callable($f)) {
106
+            return $f;
107
+        }
108
+    }
109
+
110
+    return $default;
111 111
 }
112 112
 
113 113
 /**
@@ -151,8 +151,8 @@  discard block
 block discarded – undo
151 151
  *     Chaîne vide sinon.
152 152
  **/
153 153
 function appliquer_filtre(mixed $arg, $filtre) {
154
-	$args = func_get_args();
155
-	return appliquer_filtre_sinon($arg, $filtre, $args, '');
154
+    $args = func_get_args();
155
+    return appliquer_filtre_sinon($arg, $filtre, $args, '');
156 156
 }
157 157
 
158 158
 /**
@@ -177,8 +177,8 @@  discard block
 block discarded – undo
177 177
  *     texte d'origine sinon
178 178
  **/
179 179
 function appliquer_si_filtre(mixed $arg, $filtre) {
180
-	$args = func_get_args();
181
-	return appliquer_filtre_sinon($arg, $filtre, $args, $arg);
180
+    $args = func_get_args();
181
+    return appliquer_filtre_sinon($arg, $filtre, $args, $arg);
182 182
 }
183 183
 
184 184
 /**
@@ -194,12 +194,12 @@  discard block
 block discarded – undo
194 194
  *     Version de SPIP
195 195
  **/
196 196
 function spip_version() {
197
-	$version = $GLOBALS['spip_version_affichee'];
198
-	if ($vcs_version = version_vcs_courante(_DIR_RACINE)) {
199
-		$version .= " $vcs_version";
200
-	}
197
+    $version = $GLOBALS['spip_version_affichee'];
198
+    if ($vcs_version = version_vcs_courante(_DIR_RACINE)) {
199
+        $version .= " $vcs_version";
200
+    }
201 201
 
202
-	return $version;
202
+    return $version;
203 203
 }
204 204
 
205 205
 /**
@@ -211,11 +211,11 @@  discard block
 block discarded – undo
211 211
  * @return string
212 212
  */
213 213
 function header_silencieux($version): string {
214
-	if (isset($GLOBALS['spip_header_silencieux']) && (bool) $GLOBALS['spip_header_silencieux']) {
215
-		$version = '';
216
-	}
214
+    if (isset($GLOBALS['spip_header_silencieux']) && (bool) $GLOBALS['spip_header_silencieux']) {
215
+        $version = '';
216
+    }
217 217
 
218
-	return (string) $version;
218
+    return (string) $version;
219 219
 }
220 220
 
221 221
 /**
@@ -228,16 +228,16 @@  discard block
 block discarded – undo
228 228
  *    - string|null si $raw = false
229 229
  */
230 230
 function version_vcs_courante($dir, $raw = false) {
231
-	$desc = decrire_version_git($dir);
232
-	if ($desc === null || $raw) {
233
-		return $desc;
234
-	}
235
-	// affichage "GIT [master: abcdef]"
236
-	$commit = $desc['commit_short'] ?? $desc['commit'];
237
-	if ($desc['branch']) {
238
-		$commit = $desc['branch'] . ': ' . $commit;
239
-	}
240
-	return "{$desc['vcs']} [$commit]";
231
+    $desc = decrire_version_git($dir);
232
+    if ($desc === null || $raw) {
233
+        return $desc;
234
+    }
235
+    // affichage "GIT [master: abcdef]"
236
+    $commit = $desc['commit_short'] ?? $desc['commit'];
237
+    if ($desc['branch']) {
238
+        $commit = $desc['branch'] . ': ' . $commit;
239
+    }
240
+    return "{$desc['vcs']} [$commit]";
241 241
 }
242 242
 
243 243
 /**
@@ -249,26 +249,26 @@  discard block
 block discarded – undo
249 249
  *      array ['branch' => xx, 'commit' => yy] sinon.
250 250
  **/
251 251
 function decrire_version_git($dir) {
252
-	$c = null;
253
-	$hash = null;
254
-	if (!$dir) {
255
-		$dir = '.';
256
-	}
257
-
258
-	// version installee par GIT
259
-	if (lire_fichier($dir . '/.git/HEAD', $c)) {
260
-		$currentHead = trim(substr((string) $c, 4));
261
-		if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
262
-			return [
263
-				'vcs' => 'GIT',
264
-				'branch' => basename($currentHead),
265
-				'commit' => trim((string) $hash),
266
-				'commit_short' => substr(trim((string) $hash), 0, 8),
267
-			];
268
-		}
269
-	}
270
-
271
-	return null;
252
+    $c = null;
253
+    $hash = null;
254
+    if (!$dir) {
255
+        $dir = '.';
256
+    }
257
+
258
+    // version installee par GIT
259
+    if (lire_fichier($dir . '/.git/HEAD', $c)) {
260
+        $currentHead = trim(substr((string) $c, 4));
261
+        if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
262
+            return [
263
+                'vcs' => 'GIT',
264
+                'branch' => basename($currentHead),
265
+                'commit' => trim((string) $hash),
266
+                'commit_short' => substr(trim((string) $hash), 0, 8),
267
+            ];
268
+        }
269
+    }
270
+
271
+    return null;
272 272
 }
273 273
 
274 274
 // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images
@@ -315,18 +315,18 @@  discard block
 block discarded – undo
315 315
  *     Code HTML retourné par le filtre
316 316
  **/
317 317
 function filtrer($filtre) {
318
-	$tous = func_get_args();
319
-	if (trouver_filtre_matrice($filtre) && str_starts_with($filtre, 'image_')) {
320
-		return image_filtrer($tous);
321
-	} elseif ($f = chercher_filtre($filtre)) {
322
-		array_shift($tous);
323
-		return $f(...$tous);
324
-	} else {
325
-		// le filtre n'existe pas, on provoque une erreur
326
-		$msg = ['zbug_erreur_filtre', ['filtre' => texte_script($filtre)]];
327
-		erreur_squelette($msg);
328
-		return '';
329
-	}
318
+    $tous = func_get_args();
319
+    if (trouver_filtre_matrice($filtre) && str_starts_with($filtre, 'image_')) {
320
+        return image_filtrer($tous);
321
+    } elseif ($f = chercher_filtre($filtre)) {
322
+        array_shift($tous);
323
+        return $f(...$tous);
324
+    } else {
325
+        // le filtre n'existe pas, on provoque une erreur
326
+        $msg = ['zbug_erreur_filtre', ['filtre' => texte_script($filtre)]];
327
+        erreur_squelette($msg);
328
+        return '';
329
+    }
330 330
 }
331 331
 
332 332
 /**
@@ -343,11 +343,11 @@  discard block
 block discarded – undo
343 343
  * @return bool true si on trouve le filtre dans la matrice, false sinon.
344 344
  */
345 345
 function trouver_filtre_matrice($filtre) {
346
-	if (isset($GLOBALS['spip_matrice'][$filtre]) && is_string($f = $GLOBALS['spip_matrice'][$filtre])) {
347
-		find_in_path($f, '', true);
348
-		$GLOBALS['spip_matrice'][$filtre] = true;
349
-	}
350
-	return !empty($GLOBALS['spip_matrice'][$filtre]);
346
+    if (isset($GLOBALS['spip_matrice'][$filtre]) && is_string($f = $GLOBALS['spip_matrice'][$filtre])) {
347
+        find_in_path($f, '', true);
348
+        $GLOBALS['spip_matrice'][$filtre] = true;
349
+    }
350
+    return !empty($GLOBALS['spip_matrice'][$filtre]);
351 351
 }
352 352
 
353 353
 
@@ -375,8 +375,8 @@  discard block
 block discarded – undo
375 375
  * @return mixed
376 376
  */
377 377
 function filtre_set(&$Pile, mixed $val, $key, $continue = null) {
378
-	$Pile['vars'][$key] = $val;
379
-	return $continue ? $val : '';
378
+    $Pile['vars'][$key] = $val;
379
+    return $continue ? $val : '';
380 380
 }
381 381
 
382 382
 /**
@@ -402,8 +402,8 @@  discard block
 block discarded – undo
402 402
  * @return string|mixed Retourne `$val` si `$continue` présent, sinon ''.
403 403
  */
404 404
 function filtre_setenv(&$Pile, mixed $val, mixed $key, $continue = null) {
405
-	$Pile[0][$key] = $val;
406
-	return $continue ? $val : '';
405
+    $Pile[0][$key] = $val;
406
+    return $continue ? $val : '';
407 407
 }
408 408
 
409 409
 /**
@@ -412,8 +412,8 @@  discard block
 block discarded – undo
412 412
  * @return string
413 413
  */
414 414
 function filtre_sanitize_env(&$Pile, $keys) {
415
-	$Pile[0] = spip_sanitize_from_request($Pile[0], $keys);
416
-	return '';
415
+    $Pile[0] = spip_sanitize_from_request($Pile[0], $keys);
416
+    return '';
417 417
 }
418 418
 
419 419
 
@@ -436,18 +436,18 @@  discard block
 block discarded – undo
436 436
  * @return mixed Retourne la valeur (sans la modifier).
437 437
  */
438 438
 function filtre_debug(mixed $val, $key = null) {
439
-	$debug = (
440
-		is_null($key) ? '' : (var_export($key, true) . ' = ')
441
-		) . var_export($val, true);
439
+    $debug = (
440
+        is_null($key) ? '' : (var_export($key, true) . ' = ')
441
+        ) . var_export($val, true);
442 442
 
443
-	include_spip('inc/autoriser');
444
-	if (autoriser('webmestre')) {
445
-		echo "<div class='spip_debug'>\n", $debug, "</div>\n";
446
-	}
443
+    include_spip('inc/autoriser');
444
+    if (autoriser('webmestre')) {
445
+        echo "<div class='spip_debug'>\n", $debug, "</div>\n";
446
+    }
447 447
 
448
-	spip_log($debug, 'debug');
448
+    spip_log($debug, 'debug');
449 449
 
450
-	return $val;
450
+    return $val;
451 451
 }
452 452
 
453 453
 
@@ -477,81 +477,81 @@  discard block
 block discarded – undo
477 477
  *     texte qui a reçu les filtres
478 478
  **/
479 479
 function image_filtrer($args) {
480
-	$filtre = array_shift($args); # enlever $filtre
481
-	$texte = array_shift($args);
482
-	if ($texte === null || !strlen((string) $texte)) {
483
-		return '';
484
-	}
485
-	find_in_path('filtres_images_mini.php', 'inc/', true);
486
-	statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver
487
-	// Cas du nom de fichier local
488
-	$is_file = trim((string) $texte);
489
-	if (
490
-		str_contains(substr($is_file, strlen(_DIR_RACINE)), '..')
491
-		|| strpbrk($is_file, "<>\n\r\t") !== false
492
-		|| str_starts_with($is_file, '/')
493
-	) {
494
-		$is_file = false;
495
-	}
496
-	if ($is_file) {
497
-		$is_local_file = function ($path) {
498
-			if (str_contains($path, '?')) {
499
-				$path = supprimer_timestamp($path);
500
-				// remove ?24px added by find_in_theme on .svg files
501
-				$path = preg_replace(',\?[[:digit:]]+(px)$,', '', $path);
502
-			}
503
-			return file_exists($path);
504
-		};
505
-		if ($is_local_file($is_file) || tester_url_absolue($is_file)) {
506
-			$res = $filtre("<img src='$is_file' />", ...$args);
507
-			statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
508
-			return $res;
509
-		}
510
-	}
511
-
512
-	// Cas general : trier toutes les images, avec eventuellement leur <span>
513
-	if (
514
-		preg_match_all(
515
-			',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS',
516
-			(string) $texte,
517
-			$tags,
518
-			PREG_SET_ORDER
519
-		)
520
-	) {
521
-		foreach ($tags as $tag) {
522
-			$class = extraire_attribut($tag[3], 'class');
523
-			if (
524
-				(!$class || !str_contains($class, 'filtre_inactif'))
525
-				&& ($reduit = $filtre($tag[3], ...$args))
526
-			) {
527
-				// En cas de span spip_documents, modifier le style=...width:
528
-				if ($tag[1]) {
529
-					$w = extraire_attribut($reduit, 'width');
530
-					if (!$w && preg_match(',width:\s*(\d+)px,S', extraire_attribut($reduit, 'style'), $regs)) {
531
-						$w = $regs[1];
532
-					}
533
-					if ($w && ($style = extraire_attribut($tag[1], 'style'))) {
534
-						$style = preg_replace(',width:\s*\d+px,S', "width:{$w}px", $style);
535
-						$replace = inserer_attribut($tag[1], 'style', $style);
536
-						$texte = str_replace($tag[1], $replace, (string) $texte);
537
-					}
538
-				}
539
-				// traiter aussi un eventuel mouseover
540
-				if (
541
-					($mouseover = extraire_attribut($reduit, 'onmouseover'))
542
-					&& preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)
543
-				) {
544
-					$srcover = $match[1];
545
-					$srcover_filter = $filtre("<img src='" . $match[1] . "' />", ...$args);
546
-					$srcover_filter = extraire_attribut($srcover_filter, 'src');
547
-					$reduit = str_replace($srcover, $srcover_filter, (string) $reduit);
548
-				}
549
-				$texte = str_replace($tag[3], $reduit, (string) $texte);
550
-			}
551
-		}
552
-	}
553
-	statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
554
-	return $texte;
480
+    $filtre = array_shift($args); # enlever $filtre
481
+    $texte = array_shift($args);
482
+    if ($texte === null || !strlen((string) $texte)) {
483
+        return '';
484
+    }
485
+    find_in_path('filtres_images_mini.php', 'inc/', true);
486
+    statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver
487
+    // Cas du nom de fichier local
488
+    $is_file = trim((string) $texte);
489
+    if (
490
+        str_contains(substr($is_file, strlen(_DIR_RACINE)), '..')
491
+        || strpbrk($is_file, "<>\n\r\t") !== false
492
+        || str_starts_with($is_file, '/')
493
+    ) {
494
+        $is_file = false;
495
+    }
496
+    if ($is_file) {
497
+        $is_local_file = function ($path) {
498
+            if (str_contains($path, '?')) {
499
+                $path = supprimer_timestamp($path);
500
+                // remove ?24px added by find_in_theme on .svg files
501
+                $path = preg_replace(',\?[[:digit:]]+(px)$,', '', $path);
502
+            }
503
+            return file_exists($path);
504
+        };
505
+        if ($is_local_file($is_file) || tester_url_absolue($is_file)) {
506
+            $res = $filtre("<img src='$is_file' />", ...$args);
507
+            statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
508
+            return $res;
509
+        }
510
+    }
511
+
512
+    // Cas general : trier toutes les images, avec eventuellement leur <span>
513
+    if (
514
+        preg_match_all(
515
+            ',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS',
516
+            (string) $texte,
517
+            $tags,
518
+            PREG_SET_ORDER
519
+        )
520
+    ) {
521
+        foreach ($tags as $tag) {
522
+            $class = extraire_attribut($tag[3], 'class');
523
+            if (
524
+                (!$class || !str_contains($class, 'filtre_inactif'))
525
+                && ($reduit = $filtre($tag[3], ...$args))
526
+            ) {
527
+                // En cas de span spip_documents, modifier le style=...width:
528
+                if ($tag[1]) {
529
+                    $w = extraire_attribut($reduit, 'width');
530
+                    if (!$w && preg_match(',width:\s*(\d+)px,S', extraire_attribut($reduit, 'style'), $regs)) {
531
+                        $w = $regs[1];
532
+                    }
533
+                    if ($w && ($style = extraire_attribut($tag[1], 'style'))) {
534
+                        $style = preg_replace(',width:\s*\d+px,S', "width:{$w}px", $style);
535
+                        $replace = inserer_attribut($tag[1], 'style', $style);
536
+                        $texte = str_replace($tag[1], $replace, (string) $texte);
537
+                    }
538
+                }
539
+                // traiter aussi un eventuel mouseover
540
+                if (
541
+                    ($mouseover = extraire_attribut($reduit, 'onmouseover'))
542
+                    && preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)
543
+                ) {
544
+                    $srcover = $match[1];
545
+                    $srcover_filter = $filtre("<img src='" . $match[1] . "' />", ...$args);
546
+                    $srcover_filter = extraire_attribut($srcover_filter, 'src');
547
+                    $reduit = str_replace($srcover, $srcover_filter, (string) $reduit);
548
+                }
549
+                $texte = str_replace($tag[3], $reduit, (string) $texte);
550
+            }
551
+        }
552
+    }
553
+    statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
554
+    return $texte;
555 555
 }
556 556
 
557 557
 /**
@@ -568,94 +568,94 @@  discard block
 block discarded – undo
568 568
  **/
569 569
 function infos_image($img, $force_refresh = false) {
570 570
 
571
-	static $largeur_img = [], $hauteur_img = [], $poids_img = [];
572
-	$srcWidth = 0;
573
-	$srcHeight = 0;
574
-	$srcSize = null;
575
-	$valeurs = null;
576
-
577
-	$src = extraire_attribut($img, 'src');
578
-
579
-	if (!$src) {
580
-		$src = $img;
581
-	} else {
582
-		$srcWidth = extraire_attribut($img, 'width');
583
-		$srcHeight = extraire_attribut($img, 'height');
584
-		if (!ctype_digit((string) $srcWidth) || !ctype_digit((string) $srcHeight)) {
585
-			$srcWidth = $srcHeight = 0;
586
-		}
587
-	}
588
-
589
-	// ne jamais operer directement sur une image distante pour des raisons de perfo
590
-	// la copie locale a toutes les chances d'etre la ou de resservir
591
-	if (tester_url_absolue($src)) {
592
-		include_spip('inc/distant');
593
-		$fichier = copie_locale($src);
594
-		$src = $fichier ? _DIR_RACINE . $fichier : $src;
595
-	}
596
-	if (($p = strpos($src, '?')) !== false) {
597
-		$src = substr($src, 0, $p);
598
-	}
599
-
600
-	$imagesize = false;
601
-	if (isset($largeur_img[$src]) && !$force_refresh) {
602
-		$srcWidth = $largeur_img[$src];
603
-	}
604
-	if (isset($hauteur_img[$src]) && !$force_refresh) {
605
-		$srcHeight = $hauteur_img[$src];
606
-	}
607
-	if (isset($poids_img[$src]) && !$force_refresh) {
608
-		$srcSize = $poids_img[$src];
609
-	}
610
-	if (!$srcWidth || !$srcHeight || is_null($srcSize)) {
611
-		if (
612
-			file_exists($src) && ($imagesize = spip_getimagesize($src))
613
-		) {
614
-			if (!$srcWidth) {
615
-				$largeur_img[$src] = $srcWidth = $imagesize[0];
616
-			}
617
-			if (!$srcHeight) {
618
-				$hauteur_img[$src] = $srcHeight = $imagesize[1];
619
-			}
620
-			if (!$srcSize) {
621
-				$poids_img[$src] = filesize($src);
622
-			}
623
-		}
624
-		elseif (str_contains($src, '<svg')) {
625
-			include_spip('inc/svg');
626
-			if ($attrs = svg_lire_attributs($src)) {
627
-				[$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs);
628
-				if (!$srcWidth) {
629
-					$largeur_img[$src] = $srcWidth = $width;
630
-				}
631
-				if (!$srcHeight) {
632
-					$hauteur_img[$src] = $srcHeight = $height;
633
-				}
634
-				if (!$srcSize) {
635
-					$poids_img[$src] = $srcSize = strlen($src);
636
-				}
637
-			}
638
-		}
639
-		// $src peut etre une reference a une image temporaire dont a n'a que le log .src
640
-		// on s'y refere, l'image sera reconstruite en temps utile si necessaire
641
-		elseif (
642
-			@file_exists($f = "$src.src")
643
-			&& lire_fichier($f, $valeurs)
644
-			&& ($valeurs = unserialize($valeurs))
645
-		) {
646
-			if (!$srcWidth) {
647
-				$largeur_img[$src] = $srcWidth = $valeurs['largeur_dest'];
648
-			}
649
-			if (!$srcHeight) {
650
-				$hauteur_img[$src] = $srcHeight = $valeurs['hauteur_dest'];
651
-			}
652
-			if (!$srcSize) {
653
-				$poids_img[$src] = $srcSize = 0;
654
-			}
655
-		}
656
-	}
657
-
658
-	return ['hauteur' => $srcHeight, 'largeur' => $srcWidth, 'poids' => $srcSize];
571
+    static $largeur_img = [], $hauteur_img = [], $poids_img = [];
572
+    $srcWidth = 0;
573
+    $srcHeight = 0;
574
+    $srcSize = null;
575
+    $valeurs = null;
576
+
577
+    $src = extraire_attribut($img, 'src');
578
+
579
+    if (!$src) {
580
+        $src = $img;
581
+    } else {
582
+        $srcWidth = extraire_attribut($img, 'width');
583
+        $srcHeight = extraire_attribut($img, 'height');
584
+        if (!ctype_digit((string) $srcWidth) || !ctype_digit((string) $srcHeight)) {
585
+            $srcWidth = $srcHeight = 0;
586
+        }
587
+    }
588
+
589
+    // ne jamais operer directement sur une image distante pour des raisons de perfo
590
+    // la copie locale a toutes les chances d'etre la ou de resservir
591
+    if (tester_url_absolue($src)) {
592
+        include_spip('inc/distant');
593
+        $fichier = copie_locale($src);
594
+        $src = $fichier ? _DIR_RACINE . $fichier : $src;
595
+    }
596
+    if (($p = strpos($src, '?')) !== false) {
597
+        $src = substr($src, 0, $p);
598
+    }
599
+
600
+    $imagesize = false;
601
+    if (isset($largeur_img[$src]) && !$force_refresh) {
602
+        $srcWidth = $largeur_img[$src];
603
+    }
604
+    if (isset($hauteur_img[$src]) && !$force_refresh) {
605
+        $srcHeight = $hauteur_img[$src];
606
+    }
607
+    if (isset($poids_img[$src]) && !$force_refresh) {
608
+        $srcSize = $poids_img[$src];
609
+    }
610
+    if (!$srcWidth || !$srcHeight || is_null($srcSize)) {
611
+        if (
612
+            file_exists($src) && ($imagesize = spip_getimagesize($src))
613
+        ) {
614
+            if (!$srcWidth) {
615
+                $largeur_img[$src] = $srcWidth = $imagesize[0];
616
+            }
617
+            if (!$srcHeight) {
618
+                $hauteur_img[$src] = $srcHeight = $imagesize[1];
619
+            }
620
+            if (!$srcSize) {
621
+                $poids_img[$src] = filesize($src);
622
+            }
623
+        }
624
+        elseif (str_contains($src, '<svg')) {
625
+            include_spip('inc/svg');
626
+            if ($attrs = svg_lire_attributs($src)) {
627
+                [$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs);
628
+                if (!$srcWidth) {
629
+                    $largeur_img[$src] = $srcWidth = $width;
630
+                }
631
+                if (!$srcHeight) {
632
+                    $hauteur_img[$src] = $srcHeight = $height;
633
+                }
634
+                if (!$srcSize) {
635
+                    $poids_img[$src] = $srcSize = strlen($src);
636
+                }
637
+            }
638
+        }
639
+        // $src peut etre une reference a une image temporaire dont a n'a que le log .src
640
+        // on s'y refere, l'image sera reconstruite en temps utile si necessaire
641
+        elseif (
642
+            @file_exists($f = "$src.src")
643
+            && lire_fichier($f, $valeurs)
644
+            && ($valeurs = unserialize($valeurs))
645
+        ) {
646
+            if (!$srcWidth) {
647
+                $largeur_img[$src] = $srcWidth = $valeurs['largeur_dest'];
648
+            }
649
+            if (!$srcHeight) {
650
+                $hauteur_img[$src] = $srcHeight = $valeurs['hauteur_dest'];
651
+            }
652
+            if (!$srcSize) {
653
+                $poids_img[$src] = $srcSize = 0;
654
+            }
655
+        }
656
+    }
657
+
658
+    return ['hauteur' => $srcHeight, 'largeur' => $srcWidth, 'poids' => $srcSize];
659 659
 }
660 660
 
661 661
 /**
@@ -671,13 +671,13 @@  discard block
 block discarded – undo
671 671
  *     poids
672 672
  **/
673 673
 function poids_image($img, $force_refresh = false) {
674
-	$infos = infos_image($img, $force_refresh);
675
-	return $infos['poids'];
674
+    $infos = infos_image($img, $force_refresh);
675
+    return $infos['poids'];
676 676
 }
677 677
 
678 678
 function taille_image($img, $force_refresh = false) {
679
-	$infos = infos_image($img, $force_refresh);
680
-	return [$infos['hauteur'], $infos['largeur']];
679
+    $infos = infos_image($img, $force_refresh);
680
+    return [$infos['hauteur'], $infos['largeur']];
681 681
 }
682 682
 
683 683
 /**
@@ -694,12 +694,12 @@  discard block
 block discarded – undo
694 694
  *     Largeur en pixels, NULL ou 0 si aucune image.
695 695
  **/
696 696
 function largeur($img) {
697
-	if (!$img) {
698
-		return;
699
-	}
700
-	[$h, $l] = taille_image($img);
697
+    if (!$img) {
698
+        return;
699
+    }
700
+    [$h, $l] = taille_image($img);
701 701
 
702
-	return $l;
702
+    return $l;
703 703
 }
704 704
 
705 705
 /**
@@ -716,12 +716,12 @@  discard block
 block discarded – undo
716 716
  *     Hauteur en pixels, NULL ou 0 si aucune image.
717 717
  **/
718 718
 function hauteur($img) {
719
-	if (!$img) {
720
-		return;
721
-	}
722
-	[$h, $l] = taille_image($img);
719
+    if (!$img) {
720
+        return;
721
+    }
722
+    [$h, $l] = taille_image($img);
723 723
 
724
-	return $h;
724
+    return $h;
725 725
 }
726 726
 
727 727
 
@@ -741,11 +741,11 @@  discard block
 block discarded – undo
741 741
  * @return string
742 742
  **/
743 743
 function corriger_entites_html($texte) {
744
-	if (!str_contains($texte, '&amp;')) {
745
-		return $texte;
746
-	}
744
+    if (!str_contains($texte, '&amp;')) {
745
+        return $texte;
746
+    }
747 747
 
748
-	return preg_replace(',&amp;(#\d\d\d+;|amp;),iS', '&\1', $texte);
748
+    return preg_replace(',&amp;(#\d\d\d+;|amp;),iS', '&\1', $texte);
749 749
 }
750 750
 
751 751
 /**
@@ -760,11 +760,11 @@  discard block
 block discarded – undo
760 760
  * @return string
761 761
  **/
762 762
 function corriger_toutes_entites_html($texte) {
763
-	if (!str_contains($texte, '&amp;')) {
764
-		return $texte;
765
-	}
763
+    if (!str_contains($texte, '&amp;')) {
764
+        return $texte;
765
+    }
766 766
 
767
-	return preg_replace(',&amp;(#?[a-z0-9]+;),iS', '&\1', $texte);
767
+    return preg_replace(',&amp;(#?[a-z0-9]+;),iS', '&\1', $texte);
768 768
 }
769 769
 
770 770
 /**
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
  * @return string
775 775
  **/
776 776
 function proteger_amp($texte) {
777
-	return str_replace('&', '&amp;', $texte);
777
+    return str_replace('&', '&amp;', $texte);
778 778
 }
779 779
 
780 780
 
@@ -805,20 +805,20 @@  discard block
 block discarded – undo
805 805
  * @return mixed|string
806 806
  */
807 807
 function entites_html($texte, $tout = false, $quote = true) {
808
-	if (!is_string($texte) || !$texte || strpbrk($texte, "&\"'<>") == false) {
809
-		return $texte;
810
-	}
811
-	include_spip('inc/texte');
812
-	$flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES);
813
-	$flags |= ENT_HTML401;
814
-	$texte = CollecteurHtmlTag::proteger_balisesHtml($texte);
815
-	$texte = CollecteurHtmlTag::retablir_depuisHtmlBase64($texte, '', 'proteger_amp');
816
-	$texte = spip_htmlspecialchars($texte, $flags);
817
-	if ($tout) {
818
-		return corriger_toutes_entites_html($texte);
819
-	} else {
820
-		return corriger_entites_html($texte);
821
-	}
808
+    if (!is_string($texte) || !$texte || strpbrk($texte, "&\"'<>") == false) {
809
+        return $texte;
810
+    }
811
+    include_spip('inc/texte');
812
+    $flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES);
813
+    $flags |= ENT_HTML401;
814
+    $texte = CollecteurHtmlTag::proteger_balisesHtml($texte);
815
+    $texte = CollecteurHtmlTag::retablir_depuisHtmlBase64($texte, '', 'proteger_amp');
816
+    $texte = spip_htmlspecialchars($texte, $flags);
817
+    if ($tout) {
818
+        return corriger_toutes_entites_html($texte);
819
+    } else {
820
+        return corriger_entites_html($texte);
821
+    }
822 822
 }
823 823
 
824 824
 /**
@@ -837,38 +837,38 @@  discard block
 block discarded – undo
837 837
  *     texte converti
838 838
  **/
839 839
 function filtrer_entites(?string $texte): string {
840
-	$texte ??= '';
841
-	if (!str_contains($texte, '&')) {
842
-		return $texte;
843
-	}
844
-	// filtrer
845
-	$texte = html2unicode($texte);
846
-	// remettre le tout dans le charset cible
847
-	$texte = unicode2charset($texte);
848
-	// cas particulier des " et ' qu'il faut filtrer aussi
849
-	// (on le faisait deja avec un &quot;)
850
-	if (str_contains($texte, '&#')) {
851
-		$texte = str_replace(['&#039;', '&#39;', '&#034;', '&#34;'], ["'", "'", '"', '"'], $texte);
852
-	}
840
+    $texte ??= '';
841
+    if (!str_contains($texte, '&')) {
842
+        return $texte;
843
+    }
844
+    // filtrer
845
+    $texte = html2unicode($texte);
846
+    // remettre le tout dans le charset cible
847
+    $texte = unicode2charset($texte);
848
+    // cas particulier des " et ' qu'il faut filtrer aussi
849
+    // (on le faisait deja avec un &quot;)
850
+    if (str_contains($texte, '&#')) {
851
+        $texte = str_replace(['&#039;', '&#39;', '&#034;', '&#34;'], ["'", "'", '"', '"'], $texte);
852
+    }
853 853
 
854
-	return $texte;
854
+    return $texte;
855 855
 }
856 856
 
857 857
 
858 858
 if (!function_exists('filtre_filtrer_entites_dist')) {
859
-	/**
860
-	 * Version sécurisée de filtrer_entites
861
-	 *
862
-	 * @uses interdire_scripts()
863
-	 * @uses filtrer_entites()
864
-	 *
865
-	 * @param string $t
866
-	 * @return string
867
-	 */
868
-	function filtre_filtrer_entites_dist($t) {
869
-		include_spip('inc/texte');
870
-		return interdire_scripts(filtrer_entites($t));
871
-	}
859
+    /**
860
+     * Version sécurisée de filtrer_entites
861
+     *
862
+     * @uses interdire_scripts()
863
+     * @uses filtrer_entites()
864
+     *
865
+     * @param string $t
866
+     * @return string
867
+     */
868
+    function filtre_filtrer_entites_dist($t) {
869
+        include_spip('inc/texte');
870
+        return interdire_scripts(filtrer_entites($t));
871
+    }
872 872
 }
873 873
 
874 874
 
@@ -883,18 +883,18 @@  discard block
 block discarded – undo
883 883
  * @return string|array
884 884
  **/
885 885
 function supprimer_caracteres_illegaux($texte) {
886
-	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";
887
-	static $to = null;
886
+    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";
887
+    static $to = null;
888 888
 
889
-	if (is_array($texte)) {
890
-		return array_map('supprimer_caracteres_illegaux', $texte);
891
-	}
889
+    if (is_array($texte)) {
890
+        return array_map('supprimer_caracteres_illegaux', $texte);
891
+    }
892 892
 
893
-	if (!$to) {
894
-		$to = str_repeat('-', strlen((string) $from));
895
-	}
893
+    if (!$to) {
894
+        $to = str_repeat('-', strlen((string) $from));
895
+    }
896 896
 
897
-	return strtr($texte, $from, $to);
897
+    return strtr($texte, $from, $to);
898 898
 }
899 899
 
900 900
 /**
@@ -906,9 +906,9 @@  discard block
 block discarded – undo
906 906
  * @return string|array
907 907
  **/
908 908
 function corriger_caracteres($texte) {
909
-	$texte = corriger_caracteres_windows($texte);
909
+    $texte = corriger_caracteres_windows($texte);
910 910
 
911
-	return supprimer_caracteres_illegaux($texte);
911
+    return supprimer_caracteres_illegaux($texte);
912 912
 }
913 913
 
914 914
 /**
@@ -925,44 +925,44 @@  discard block
 block discarded – undo
925 925
  *     texte encodé pour XML
926 926
  */
927 927
 function texte_backend(?string $texte): string {
928
-	if ($texte === null || $texte === '') {
929
-		return '';
930
-	}
928
+    if ($texte === null || $texte === '') {
929
+        return '';
930
+    }
931 931
 
932
-	static $apostrophe = ['&#8217;', "'"]; # n'allouer qu'une fois
932
+    static $apostrophe = ['&#8217;', "'"]; # n'allouer qu'une fois
933 933
 
934
-	// si on a des liens ou des images, les passer en absolu
935
-	$texte = liens_absolus($texte);
934
+    // si on a des liens ou des images, les passer en absolu
935
+    $texte = liens_absolus($texte);
936 936
 
937
-	// echapper les tags &gt; &lt;
938
-	$texte = preg_replace(',&(gt|lt);,S', '&amp;\1;', $texte);
937
+    // echapper les tags &gt; &lt;
938
+    $texte = preg_replace(',&(gt|lt);,S', '&amp;\1;', $texte);
939 939
 
940
-	// importer les &eacute;
941
-	$texte = filtrer_entites($texte);
940
+    // importer les &eacute;
941
+    $texte = filtrer_entites($texte);
942 942
 
943
-	// " -> &quot; et tout ce genre de choses
944
-	$u = $GLOBALS['meta']['pcre_u'];
945
-	$texte = str_replace('&nbsp;', ' ', $texte);
946
-	$texte = preg_replace('/\s{2,}/S' . $u, ' ', $texte);
947
-	// ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
948
-	$texte = entites_html($texte, false, false);
949
-	// mais bien echapper les double quotes !
950
-	$texte = str_replace('"', '&#034;', (string) $texte);
943
+    // " -> &quot; et tout ce genre de choses
944
+    $u = $GLOBALS['meta']['pcre_u'];
945
+    $texte = str_replace('&nbsp;', ' ', $texte);
946
+    $texte = preg_replace('/\s{2,}/S' . $u, ' ', $texte);
947
+    // ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
948
+    $texte = entites_html($texte, false, false);
949
+    // mais bien echapper les double quotes !
950
+    $texte = str_replace('"', '&#034;', (string) $texte);
951 951
 
952
-	// verifier le charset
953
-	$texte = charset2unicode($texte);
952
+    // verifier le charset
953
+    $texte = charset2unicode($texte);
954 954
 
955
-	// Caracteres problematiques en iso-latin 1
956
-	if (isset($GLOBALS['meta']['charset']) && $GLOBALS['meta']['charset'] == 'iso-8859-1') {
957
-		$texte = str_replace(chr(156), '&#156;', $texte);
958
-		$texte = str_replace(chr(140), '&#140;', $texte);
959
-		$texte = str_replace(chr(159), '&#159;', $texte);
960
-	}
955
+    // Caracteres problematiques en iso-latin 1
956
+    if (isset($GLOBALS['meta']['charset']) && $GLOBALS['meta']['charset'] == 'iso-8859-1') {
957
+        $texte = str_replace(chr(156), '&#156;', $texte);
958
+        $texte = str_replace(chr(140), '&#140;', $texte);
959
+        $texte = str_replace(chr(159), '&#159;', $texte);
960
+    }
961 961
 
962
-	// l'apostrophe curly pose probleme a certains lecteure de RSS
963
-	// et le caractere apostrophe alourdit les squelettes avec PHP
964
-	// ==> on les remplace par l'entite HTML
965
-	return str_replace($apostrophe, "'", $texte);
962
+    // l'apostrophe curly pose probleme a certains lecteure de RSS
963
+    // et le caractere apostrophe alourdit les squelettes avec PHP
964
+    // ==> on les remplace par l'entite HTML
965
+    return str_replace($apostrophe, "'", $texte);
966 966
 }
967 967
 
968 968
 /**
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
  *     texte encodé et quote pour XML
980 980
  */
981 981
 function texte_backendq(?string $texte): string {
982
-	return addslashes(texte_backend($texte));
982
+    return addslashes(texte_backend($texte));
983 983
 }
984 984
 
985 985
 
@@ -1001,14 +1001,14 @@  discard block
 block discarded – undo
1001 1001
  *     Texte sans son numéro éventuel
1002 1002
  **/
1003 1003
 function supprimer_numero(?string $texte): string {
1004
-	if ($texte === null || $texte === '') {
1005
-		return '';
1006
-	}
1007
-	return preg_replace(
1008
-		',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1009
-		'',
1010
-		$texte
1011
-	);
1004
+    if ($texte === null || $texte === '') {
1005
+        return '';
1006
+    }
1007
+    return preg_replace(
1008
+        ',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1009
+        '',
1010
+        $texte
1011
+    );
1012 1012
 }
1013 1013
 
1014 1014
 /**
@@ -1031,19 +1031,19 @@  discard block
 block discarded – undo
1031 1031
  *     Numéro de titre, sinon chaîne vide
1032 1032
  **/
1033 1033
 function recuperer_numero(?string $texte): string {
1034
-	if ($texte === null || $texte === '') {
1035
-		return '';
1036
-	}
1037
-	if (preg_match(
1038
-			',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1039
-			$texte,
1040
-			$regs
1041
-		)
1042
-	) {
1043
-		return (string) $regs[1];
1044
-	}
1034
+    if ($texte === null || $texte === '') {
1035
+        return '';
1036
+    }
1037
+    if (preg_match(
1038
+            ',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1039
+            $texte,
1040
+            $regs
1041
+        )
1042
+    ) {
1043
+        return (string) $regs[1];
1044
+    }
1045 1045
 
1046
-	return '';
1046
+    return '';
1047 1047
 }
1048 1048
 
1049 1049
 /**
@@ -1070,16 +1070,16 @@  discard block
 block discarded – undo
1070 1070
  *     texte ou tableau de textes converti
1071 1071
  **/
1072 1072
 function supprimer_tags($texte, $rempl = '') {
1073
-	if ($texte === null || $texte === '') {
1074
-		return '';
1075
-	}
1076
-	$texte = preg_replace(',<(!--|\w|/|!\[endif|!\[if)[^>]*>,US', $rempl, $texte);
1077
-	// ne pas oublier un < final non ferme car coupe
1078
-	$texte = preg_replace(',<(!--|\w|/).*$,US', $rempl, $texte);
1079
-	// mais qui peut aussi etre un simple signe plus petit que
1080
-	$texte = str_replace('<', '&lt;', $texte);
1073
+    if ($texte === null || $texte === '') {
1074
+        return '';
1075
+    }
1076
+    $texte = preg_replace(',<(!--|\w|/|!\[endif|!\[if)[^>]*>,US', $rempl, $texte);
1077
+    // ne pas oublier un < final non ferme car coupe
1078
+    $texte = preg_replace(',<(!--|\w|/).*$,US', $rempl, $texte);
1079
+    // mais qui peut aussi etre un simple signe plus petit que
1080
+    $texte = str_replace('<', '&lt;', $texte);
1081 1081
 
1082
-	return $texte;
1082
+    return $texte;
1083 1083
 }
1084 1084
 
1085 1085
 /**
@@ -1102,7 +1102,7 @@  discard block
 block discarded – undo
1102 1102
  *     texte converti
1103 1103
  **/
1104 1104
 function echapper_tags($texte, $rempl = '') {
1105
-	return preg_replace('/<([^>]*)>/', "&lt;\\1&gt;", $texte);
1105
+    return preg_replace('/<([^>]*)>/', "&lt;\\1&gt;", $texte);
1106 1106
 }
1107 1107
 
1108 1108
 /**
@@ -1123,21 +1123,21 @@  discard block
 block discarded – undo
1123 1123
  *     texte converti
1124 1124
  **/
1125 1125
 function textebrut($texte) {
1126
-	if ($texte === null || $texte === '') {
1127
-		return '';
1128
-	}
1129
-	$u = $GLOBALS['meta']['pcre_u'];
1130
-	$texte = preg_replace('/\s+/S' . $u, ' ', $texte);
1131
-	$texte = preg_replace('/<(p|br)( [^>]*)?>/iS', "\n\n", $texte);
1132
-	$texte = preg_replace("/^\n+/", '', $texte);
1133
-	$texte = preg_replace("/\n+$/", '', $texte);
1134
-	$texte = preg_replace("/\n +/", "\n", $texte);
1135
-	$texte = supprimer_tags($texte);
1136
-	$texte = preg_replace('/(&nbsp;| )+/S', ' ', $texte);
1137
-	// nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail...
1138
-	$texte = str_replace('&#8217;', "'", $texte);
1126
+    if ($texte === null || $texte === '') {
1127
+        return '';
1128
+    }
1129
+    $u = $GLOBALS['meta']['pcre_u'];
1130
+    $texte = preg_replace('/\s+/S' . $u, ' ', $texte);
1131
+    $texte = preg_replace('/<(p|br)( [^>]*)?>/iS', "\n\n", $texte);
1132
+    $texte = preg_replace("/^\n+/", '', $texte);
1133
+    $texte = preg_replace("/\n+$/", '', $texte);
1134
+    $texte = preg_replace("/\n +/", "\n", $texte);
1135
+    $texte = supprimer_tags($texte);
1136
+    $texte = preg_replace('/(&nbsp;| )+/S', ' ', $texte);
1137
+    // nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail...
1138
+    $texte = str_replace('&#8217;', "'", $texte);
1139 1139
 
1140
-	return $texte;
1140
+    return $texte;
1141 1141
 }
1142 1142
 
1143 1143
 
@@ -1153,26 +1153,26 @@  discard block
 block discarded – undo
1153 1153
  *     texte avec liens ouvrants
1154 1154
  **/
1155 1155
 function liens_ouvrants($texte) {
1156
-	if ($texte === null || $texte === '') {
1157
-		return '';
1158
-	}
1159
-	if (
1160
-		preg_match_all(
1161
-			",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1162
-			$texte,
1163
-			$liens,
1164
-			PREG_PATTERN_ORDER
1165
-		)
1166
-	) {
1167
-		foreach ($liens[0] as $a) {
1168
-			$rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1169
-			$ablank = inserer_attribut($a, 'rel', $rel);
1170
-			$ablank = inserer_attribut($ablank, 'target', '_blank');
1171
-			$texte = str_replace($a, $ablank, $texte);
1172
-		}
1173
-	}
1174
-
1175
-	return $texte;
1156
+    if ($texte === null || $texte === '') {
1157
+        return '';
1158
+    }
1159
+    if (
1160
+        preg_match_all(
1161
+            ",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1162
+            $texte,
1163
+            $liens,
1164
+            PREG_PATTERN_ORDER
1165
+        )
1166
+    ) {
1167
+        foreach ($liens[0] as $a) {
1168
+            $rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1169
+            $ablank = inserer_attribut($a, 'rel', $rel);
1170
+            $ablank = inserer_attribut($ablank, 'target', '_blank');
1171
+            $texte = str_replace($a, $ablank, $texte);
1172
+        }
1173
+    }
1174
+
1175
+    return $texte;
1176 1176
 }
1177 1177
 
1178 1178
 /**
@@ -1182,25 +1182,25 @@  discard block
 block discarded – undo
1182 1182
  * @return string
1183 1183
  */
1184 1184
 function liens_nofollow($texte) {
1185
-	if ($texte === null || $texte === '') {
1186
-		return '';
1187
-	}
1188
-	if (stripos($texte, '<a') === false) {
1189
-		return $texte;
1190
-	}
1185
+    if ($texte === null || $texte === '') {
1186
+        return '';
1187
+    }
1188
+    if (stripos($texte, '<a') === false) {
1189
+        return $texte;
1190
+    }
1191 1191
 
1192
-	if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) {
1193
-		foreach ($regs[0] as $a) {
1194
-			$rel = extraire_attribut($a, 'rel') ?? '';
1195
-			if (!str_contains($rel, 'nofollow')) {
1196
-				$rel = 'nofollow' . ($rel ? " $rel" : '');
1197
-				$anofollow = inserer_attribut($a, 'rel', $rel);
1198
-				$texte = str_replace($a, $anofollow, $texte);
1199
-			}
1200
-		}
1201
-	}
1192
+    if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) {
1193
+        foreach ($regs[0] as $a) {
1194
+            $rel = extraire_attribut($a, 'rel') ?? '';
1195
+            if (!str_contains($rel, 'nofollow')) {
1196
+                $rel = 'nofollow' . ($rel ? " $rel" : '');
1197
+                $anofollow = inserer_attribut($a, 'rel', $rel);
1198
+                $texte = str_replace($a, $anofollow, $texte);
1199
+            }
1200
+        }
1201
+    }
1202 1202
 
1203
-	return $texte;
1203
+    return $texte;
1204 1204
 }
1205 1205
 
1206 1206
 /**
@@ -1219,14 +1219,14 @@  discard block
 block discarded – undo
1219 1219
  *     texte sans paraghaphes
1220 1220
  **/
1221 1221
 function PtoBR($texte) {
1222
-	if ($texte === null || $texte === '') {
1223
-		return '';
1224
-	}
1225
-	$u = $GLOBALS['meta']['pcre_u'];
1226
-	$texte = preg_replace('@</p>@iS', "\n", $texte);
1227
-	$texte = preg_replace("@<p\b.*>@UiS", '<br />', $texte);
1222
+    if ($texte === null || $texte === '') {
1223
+        return '';
1224
+    }
1225
+    $u = $GLOBALS['meta']['pcre_u'];
1226
+    $texte = preg_replace('@</p>@iS', "\n", $texte);
1227
+    $texte = preg_replace("@<p\b.*>@UiS", '<br />', $texte);
1228 1228
 
1229
-	return preg_replace('@^\s*<br />@S' . $u, '', $texte);
1229
+    return preg_replace('@^\s*<br />@S' . $u, '', $texte);
1230 1230
 }
1231 1231
 
1232 1232
 /**
@@ -1245,30 +1245,30 @@  discard block
 block discarded – undo
1245 1245
  * @return string texte en majuscule
1246 1246
  */
1247 1247
 function majuscules($texte) {
1248
-	if ($texte === null || $texte === '') {
1249
-		return '';
1250
-	}
1248
+    if ($texte === null || $texte === '') {
1249
+        return '';
1250
+    }
1251 1251
 
1252
-	// Cas du turc
1253
-	if ($GLOBALS['spip_lang'] == 'tr') {
1254
-		# remplacer hors des tags et des entites
1255
-		if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) {
1256
-			foreach ($regs as $n => $match) {
1257
-				$texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte);
1258
-			}
1259
-		}
1252
+    // Cas du turc
1253
+    if ($GLOBALS['spip_lang'] == 'tr') {
1254
+        # remplacer hors des tags et des entites
1255
+        if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) {
1256
+            foreach ($regs as $n => $match) {
1257
+                $texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte);
1258
+            }
1259
+        }
1260 1260
 
1261
-		$texte = str_replace('i', '&#304;', $texte);
1261
+        $texte = str_replace('i', '&#304;', $texte);
1262 1262
 
1263
-		if ($regs) {
1264
-			foreach ($regs as $n => $match) {
1265
-				$texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte);
1266
-			}
1267
-		}
1268
-	}
1263
+        if ($regs) {
1264
+            foreach ($regs as $n => $match) {
1265
+                $texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte);
1266
+            }
1267
+        }
1268
+    }
1269 1269
 
1270
-	// Cas general
1271
-	return "<span style='text-transform: uppercase;'>$texte</span>";
1270
+    // Cas general
1271
+    return "<span style='text-transform: uppercase;'>$texte</span>";
1272 1272
 }
1273 1273
 
1274 1274
 /**
@@ -1290,38 +1290,38 @@  discard block
 block discarded – undo
1290 1290
  */
1291 1291
 function taille_en_octets($octets, $systeme = 'BI') {
1292 1292
 
1293
-	// Texte à afficher pour la taille
1294
-	$affichage = '';
1293
+    // Texte à afficher pour la taille
1294
+    $affichage = '';
1295 1295
 
1296
-	static $unites = ['octets', 'ko', 'mo', 'go'];
1297
-	static $precisions = [0, 1, 1, 2];
1296
+    static $unites = ['octets', 'ko', 'mo', 'go'];
1297
+    static $precisions = [0, 1, 1, 2];
1298 1298
 
1299
-	if ($octets >= 1) {
1300
-		// Déterminer le nombre d'octets représentant le kilo en fonction du système choisi
1301
-		$systeme = strtolower($systeme);
1302
-		if ($systeme === 'bi') {
1303
-			$kilo = 1024;
1304
-			$suffixe_item = "_$systeme";
1305
-		} elseif ($systeme === 'si') {
1306
-			$kilo = 1000;
1307
-			$suffixe_item = '';
1308
-		} else {
1309
-			return $affichage;
1310
-		}
1299
+    if ($octets >= 1) {
1300
+        // Déterminer le nombre d'octets représentant le kilo en fonction du système choisi
1301
+        $systeme = strtolower($systeme);
1302
+        if ($systeme === 'bi') {
1303
+            $kilo = 1024;
1304
+            $suffixe_item = "_$systeme";
1305
+        } elseif ($systeme === 'si') {
1306
+            $kilo = 1000;
1307
+            $suffixe_item = '';
1308
+        } else {
1309
+            return $affichage;
1310
+        }
1311 1311
 
1312
-		// Identification de la puissance en "kilo" correspondant à l'unité la plus appropriée
1313
-		$puissance = floor(log($octets, $kilo));
1312
+        // Identification de la puissance en "kilo" correspondant à l'unité la plus appropriée
1313
+        $puissance = floor(log($octets, $kilo));
1314 1314
 
1315
-		// Calcul de la taille et choix de l'unité
1316
-		$affichage = _T(
1317
-			'spip:taille_' . $unites[$puissance] . $suffixe_item,
1318
-			[
1319
-				'taille' => round($octets / $kilo ** $puissance, $precisions[$puissance])
1320
-			]
1321
-		);
1322
-	}
1315
+        // Calcul de la taille et choix de l'unité
1316
+        $affichage = _T(
1317
+            'spip:taille_' . $unites[$puissance] . $suffixe_item,
1318
+            [
1319
+                'taille' => round($octets / $kilo ** $puissance, $precisions[$puissance])
1320
+            ]
1321
+        );
1322
+    }
1323 1323
 
1324
-	return $affichage;
1324
+    return $affichage;
1325 1325
 }
1326 1326
 
1327 1327
 
@@ -1343,21 +1343,21 @@  discard block
 block discarded – undo
1343 1343
  *     texte prêt pour être utilisé en attribut HTML
1344 1344
  **/
1345 1345
 function attribut_html(?string $texte, $textebrut = true): string {
1346
-	if ($texte === null || $texte === '') {
1347
-		return '';
1348
-	}
1349
-	$u = $GLOBALS['meta']['pcre_u'];
1350
-	if ($textebrut) {
1351
-		$texte = preg_replace([",\n,", ',\s(?=\s),msS' . $u], [' ', ''], textebrut($texte));
1352
-	}
1353
-	$texte = texte_backend($texte);
1354
-	$texte = str_replace(["'", '"'], ['&#039;', '&#034;'], $texte);
1346
+    if ($texte === null || $texte === '') {
1347
+        return '';
1348
+    }
1349
+    $u = $GLOBALS['meta']['pcre_u'];
1350
+    if ($textebrut) {
1351
+        $texte = preg_replace([",\n,", ',\s(?=\s),msS' . $u], [' ', ''], textebrut($texte));
1352
+    }
1353
+    $texte = texte_backend($texte);
1354
+    $texte = str_replace(["'", '"'], ['&#039;', '&#034;'], $texte);
1355 1355
 
1356
-	return preg_replace(
1357
-		['/&(amp;|#38;)/', '/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/'],
1358
-		['&', '&#38;'],
1359
-		$texte
1360
-	);
1356
+    return preg_replace(
1357
+        ['/&(amp;|#38;)/', '/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/'],
1358
+        ['&', '&#38;'],
1359
+        $texte
1360
+    );
1361 1361
 }
1362 1362
 
1363 1363
 
@@ -1377,15 +1377,15 @@  discard block
 block discarded – undo
1377 1377
  *     URL ou chaîne vide
1378 1378
  **/
1379 1379
 function vider_url(?string $url, $entites = true): string {
1380
-	if ($url === null || $url === '') {
1381
-		return '';
1382
-	}
1383
-	# un message pour abs_url
1384
-	$GLOBALS['mode_abs_url'] = 'url';
1385
-	$url = trim($url);
1386
-	$r = ',^(?:' . _PROTOCOLES_STD . '):?/?/?$,iS';
1380
+    if ($url === null || $url === '') {
1381
+        return '';
1382
+    }
1383
+    # un message pour abs_url
1384
+    $GLOBALS['mode_abs_url'] = 'url';
1385
+    $url = trim($url);
1386
+    $r = ',^(?:' . _PROTOCOLES_STD . '):?/?/?$,iS';
1387 1387
 
1388
-	return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1388
+    return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1389 1389
 }
1390 1390
 
1391 1391
 
@@ -1400,10 +1400,10 @@  discard block
 block discarded – undo
1400 1400
  * @return string Adresse email maquillée
1401 1401
  **/
1402 1402
 function antispam($texte) {
1403
-	include_spip('inc/acces');
1404
-	$masque = creer_pass_aleatoire(3);
1403
+    include_spip('inc/acces');
1404
+    $masque = creer_pass_aleatoire(3);
1405 1405
 
1406
-	return preg_replace('/@/', " $masque ", $texte);
1406
+    return preg_replace('/@/', " $masque ", $texte);
1407 1407
 }
1408 1408
 
1409 1409
 /**
@@ -1435,8 +1435,8 @@  discard block
 block discarded – undo
1435 1435
  *     True si on a le droit d'accès, false sinon.
1436 1436
  **/
1437 1437
 function filtre_securiser_acces_dist($id_auteur, $cle, $dir, $op = '', $args = '') {
1438
-	include_spip('inc/acces');
1439
-	return securiser_acces_low_sec($id_auteur, $cle, $op ? "$dir $op $args" : $dir);
1438
+    include_spip('inc/acces');
1439
+    return securiser_acces_low_sec($id_auteur, $cle, $op ? "$dir $op $args" : $dir);
1440 1440
 }
1441 1441
 
1442 1442
 /**
@@ -1460,13 +1460,13 @@  discard block
 block discarded – undo
1460 1460
  *     Retourne $texte, sinon $sinon.
1461 1461
  **/
1462 1462
 function sinon(mixed $texte, mixed $sinon = '') {
1463
-	if ($texte) {
1464
-		return $texte;
1465
-	} elseif (is_scalar($texte) && strlen($texte)) {
1466
-		return $texte;
1467
-	}
1463
+    if ($texte) {
1464
+        return $texte;
1465
+    } elseif (is_scalar($texte) && strlen($texte)) {
1466
+        return $texte;
1467
+    }
1468 1468
 
1469
-	return $sinon;
1469
+    return $sinon;
1470 1470
 }
1471 1471
 
1472 1472
 /**
@@ -1490,7 +1490,7 @@  discard block
 block discarded – undo
1490 1490
  * @return mixed
1491 1491
  **/
1492 1492
 function choixsivide(mixed $a, mixed $vide, mixed $pasvide) {
1493
-	return $a ? $pasvide : $vide;
1493
+    return $a ? $pasvide : $vide;
1494 1494
 }
1495 1495
 
1496 1496
 /**
@@ -1514,7 +1514,7 @@  discard block
 block discarded – undo
1514 1514
  * @return mixed
1515 1515
  **/
1516 1516
 function choixsiegal(mixed $a1, mixed $a2, mixed $v, mixed $f) {
1517
-	return ($a1 == $a2) ? $v : $f;
1517
+    return ($a1 == $a2) ? $v : $f;
1518 1518
 }
1519 1519
 
1520 1520
 //
@@ -1533,15 +1533,15 @@  discard block
 block discarded – undo
1533 1533
  * @return string
1534 1534
  **/
1535 1535
 function filtrer_ical($texte) {
1536
-	if ($texte === null || $texte === '') {
1537
-		return '';
1538
-	}
1539
-	#include_spip('inc/charsets');
1540
-	$texte = html2unicode($texte);
1541
-	$texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset']), 'utf-8');
1542
-	$texte = preg_replace("/\n/", ' ', $texte);
1536
+    if ($texte === null || $texte === '') {
1537
+        return '';
1538
+    }
1539
+    #include_spip('inc/charsets');
1540
+    $texte = html2unicode($texte);
1541
+    $texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset']), 'utf-8');
1542
+    $texte = preg_replace("/\n/", ' ', $texte);
1543 1543
 
1544
-	return preg_replace('/,/', '\,', $texte);
1544
+    return preg_replace('/,/', '\,', $texte);
1545 1545
 }
1546 1546
 
1547 1547
 
@@ -1566,56 +1566,56 @@  discard block
 block discarded – undo
1566 1566
  * @return string
1567 1567
  **/
1568 1568
 function post_autobr($texte, $delim = "\n_ ") {
1569
-	if (!function_exists('echappe_html')) {
1570
-		include_spip('inc/texte_mini');
1571
-	}
1572
-	$texte = str_replace("\r\n", "\r", $texte);
1573
-	$texte = str_replace("\r", "\n", $texte);
1574
-
1575
-	if (preg_match(",\n+$,", $texte, $fin)) {
1576
-		$texte = substr($texte, 0, -strlen($fin = $fin[0]));
1577
-	} else {
1578
-		$fin = '';
1579
-	}
1580
-
1581
-	$texte = CollecteurHtmlTag::proteger_balisesHtml($texte);
1582
-
1583
-	// echapper les modeles
1584
-	$collecteurModeles = null;
1585
-	if (str_contains($texte, '<')) {
1586
-		$collecteurModeles = new CollecteurModeles();
1587
-		$texte = $collecteurModeles->echapper($texte);
1588
-	}
1589
-
1590
-	$debut = '';
1591
-	$suite = $texte;
1592
-	while ($t = strpos((string) ('-' . $suite), "\n", 1)) {
1593
-		$debut .= substr($suite, 0, $t - 1);
1594
-		$suite = substr($suite, $t);
1595
-		$car = substr($suite, 0, 1);
1596
-		if (
1597
-			$car != '-' && $car != '_' && $car != "\n" && $car != '|' && $car != '}'
1598
-			&& !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite))
1599
-			&& !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut)
1600
-		) {
1601
-			$debut .= $delim;
1602
-		} else {
1603
-			$debut .= "\n";
1604
-		}
1605
-		if (preg_match(",^\n+,", $suite, $regs)) {
1606
-			$debut .= $regs[0];
1607
-			$suite = substr($suite, strlen($regs[0]));
1608
-		}
1609
-	}
1610
-	$texte = $debut . $suite;
1611
-
1612
-	if ($collecteurModeles) {
1613
-		$texte = $collecteurModeles->retablir($texte);
1614
-	}
1615
-
1616
-	$texte = CollecteurHtmlTag::retablir_depuisHtmlBase64($texte);
1617
-
1618
-	return $texte . $fin;
1569
+    if (!function_exists('echappe_html')) {
1570
+        include_spip('inc/texte_mini');
1571
+    }
1572
+    $texte = str_replace("\r\n", "\r", $texte);
1573
+    $texte = str_replace("\r", "\n", $texte);
1574
+
1575
+    if (preg_match(",\n+$,", $texte, $fin)) {
1576
+        $texte = substr($texte, 0, -strlen($fin = $fin[0]));
1577
+    } else {
1578
+        $fin = '';
1579
+    }
1580
+
1581
+    $texte = CollecteurHtmlTag::proteger_balisesHtml($texte);
1582
+
1583
+    // echapper les modeles
1584
+    $collecteurModeles = null;
1585
+    if (str_contains($texte, '<')) {
1586
+        $collecteurModeles = new CollecteurModeles();
1587
+        $texte = $collecteurModeles->echapper($texte);
1588
+    }
1589
+
1590
+    $debut = '';
1591
+    $suite = $texte;
1592
+    while ($t = strpos((string) ('-' . $suite), "\n", 1)) {
1593
+        $debut .= substr($suite, 0, $t - 1);
1594
+        $suite = substr($suite, $t);
1595
+        $car = substr($suite, 0, 1);
1596
+        if (
1597
+            $car != '-' && $car != '_' && $car != "\n" && $car != '|' && $car != '}'
1598
+            && !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite))
1599
+            && !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut)
1600
+        ) {
1601
+            $debut .= $delim;
1602
+        } else {
1603
+            $debut .= "\n";
1604
+        }
1605
+        if (preg_match(",^\n+,", $suite, $regs)) {
1606
+            $debut .= $regs[0];
1607
+            $suite = substr($suite, strlen($regs[0]));
1608
+        }
1609
+    }
1610
+    $texte = $debut . $suite;
1611
+
1612
+    if ($collecteurModeles) {
1613
+        $texte = $collecteurModeles->retablir($texte);
1614
+    }
1615
+
1616
+    $texte = CollecteurHtmlTag::retablir_depuisHtmlBase64($texte);
1617
+
1618
+    return $texte . $fin;
1619 1619
 }
1620 1620
 
1621 1621
 
@@ -1648,25 +1648,25 @@  discard block
 block discarded – undo
1648 1648
  **/
1649 1649
 function extraire_idiome($letexte, $lang = null, $options = []) {
1650 1650
 
1651
-	if ($letexte && str_contains($letexte, '<:')) {
1652
-		if (!$lang) {
1653
-			$lang = $GLOBALS['spip_lang'];
1654
-		}
1655
-		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1656
-		if (is_bool($options)) {
1657
-			trigger_deprecation('spip', '5.0', 'Using boolean $options parameter in "%s()" function is deprecated. Use %s array parameter instead.', __FUNCTION__, '[\'echappe_span\' => ' . var_export($options, true) . ']');
1658
-			$options = ['echappe_span' => $options];
1659
-		}
1660
-		if (!isset($options['echappe_span'])) {
1661
-			$options = array_merge($options, ['echappe_span' => false]);
1662
-		}
1663
-		$options['lang'] = $lang;
1651
+    if ($letexte && str_contains($letexte, '<:')) {
1652
+        if (!$lang) {
1653
+            $lang = $GLOBALS['spip_lang'];
1654
+        }
1655
+        // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1656
+        if (is_bool($options)) {
1657
+            trigger_deprecation('spip', '5.0', 'Using boolean $options parameter in "%s()" function is deprecated. Use %s array parameter instead.', __FUNCTION__, '[\'echappe_span\' => ' . var_export($options, true) . ']');
1658
+            $options = ['echappe_span' => $options];
1659
+        }
1660
+        if (!isset($options['echappe_span'])) {
1661
+            $options = array_merge($options, ['echappe_span' => false]);
1662
+        }
1663
+        $options['lang'] = $lang;
1664 1664
 
1665
-		$collecteurIdiomes = new CollecteurIdiomes();
1665
+        $collecteurIdiomes = new CollecteurIdiomes();
1666 1666
 
1667
-		$letexte = $collecteurIdiomes->traiter($letexte, $options);
1668
-	}
1669
-	return $letexte;
1667
+        $letexte = $collecteurIdiomes->traiter($letexte, $options);
1668
+    }
1669
+    return $letexte;
1670 1670
 }
1671 1671
 
1672 1672
 /**
@@ -1704,30 +1704,30 @@  discard block
 block discarded – undo
1704 1704
  **/
1705 1705
 function extraire_multi($letexte, $lang = null, $options = []) {
1706 1706
 
1707
-	if ($letexte && stripos($letexte, '<multi') !== false) {
1708
-		if (!$lang) {
1709
-			$lang = $GLOBALS['spip_lang'];
1710
-		}
1707
+    if ($letexte && stripos($letexte, '<multi') !== false) {
1708
+        if (!$lang) {
1709
+            $lang = $GLOBALS['spip_lang'];
1710
+        }
1711 1711
 
1712
-		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1713
-		if (is_bool($options)) {
1714
-			trigger_deprecation('spip', '5.0', 'Using boolean $options parameter in "%s()" function is deprecated. Use %s array parameter instead.', __FUNCTION__, '[\'echappe_span\' => ' . var_export($options, true) . ']');
1715
-			$options = ['echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT];
1716
-		}
1717
-		if (!isset($options['echappe_span'])) {
1718
-			$options = array_merge($options, ['echappe_span' => false]);
1719
-		}
1720
-		if (!isset($options['lang_defaut'])) {
1721
-			$options = array_merge($options, ['lang_defaut' => _LANGUE_PAR_DEFAUT]);
1722
-		}
1723
-		$options['lang'] = $lang;
1712
+        // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1713
+        if (is_bool($options)) {
1714
+            trigger_deprecation('spip', '5.0', 'Using boolean $options parameter in "%s()" function is deprecated. Use %s array parameter instead.', __FUNCTION__, '[\'echappe_span\' => ' . var_export($options, true) . ']');
1715
+            $options = ['echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT];
1716
+        }
1717
+        if (!isset($options['echappe_span'])) {
1718
+            $options = array_merge($options, ['echappe_span' => false]);
1719
+        }
1720
+        if (!isset($options['lang_defaut'])) {
1721
+            $options = array_merge($options, ['lang_defaut' => _LANGUE_PAR_DEFAUT]);
1722
+        }
1723
+        $options['lang'] = $lang;
1724 1724
 
1725
-		$collecteurMultis = new CollecteurMultis();
1725
+        $collecteurMultis = new CollecteurMultis();
1726 1726
 
1727
-		$letexte = $collecteurMultis->traiter($letexte, $options);
1728
-	}
1727
+        $letexte = $collecteurMultis->traiter($letexte, $options);
1728
+    }
1729 1729
 
1730
-	return $letexte;
1730
+    return $letexte;
1731 1731
 }
1732 1732
 
1733 1733
 /**
@@ -1737,7 +1737,7 @@  discard block
 block discarded – undo
1737 1737
  * @return string L'initiale en majuscule
1738 1738
  */
1739 1739
 function filtre_initiale($nom) {
1740
-	return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1);
1740
+    return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1);
1741 1741
 }
1742 1742
 
1743 1743
 
@@ -1782,33 +1782,33 @@  discard block
 block discarded – undo
1782 1782
  *      - null (interne) : si on empile
1783 1783
  **/
1784 1784
 function unique($donnee, $famille = '', $cpt = false) {
1785
-	static $mem = [];
1786
-	// permettre de vider la pile et de la restaurer
1787
-	// pour le calcul de introduction...
1788
-	if ($famille == '_spip_raz_') {
1789
-		$tmp = $mem;
1790
-		$mem = [];
1791
-
1792
-		return $tmp;
1793
-	} elseif ($famille == '_spip_set_') {
1794
-		$mem = $donnee;
1795
-
1796
-		return;
1797
-	}
1798
-	// eviter une notice
1799
-	if (!isset($mem[$famille])) {
1800
-		$mem[$famille] = [];
1801
-	}
1802
-	if ($cpt) {
1803
-		return is_countable($mem[$famille]) ? count($mem[$famille]) : 0;
1804
-	}
1805
-	// eviter une notice
1806
-	if (!isset($mem[$famille][$donnee])) {
1807
-		$mem[$famille][$donnee] = 0;
1808
-	}
1809
-	if (!($mem[$famille][$donnee]++)) {
1810
-		return $donnee;
1811
-	}
1785
+    static $mem = [];
1786
+    // permettre de vider la pile et de la restaurer
1787
+    // pour le calcul de introduction...
1788
+    if ($famille == '_spip_raz_') {
1789
+        $tmp = $mem;
1790
+        $mem = [];
1791
+
1792
+        return $tmp;
1793
+    } elseif ($famille == '_spip_set_') {
1794
+        $mem = $donnee;
1795
+
1796
+        return;
1797
+    }
1798
+    // eviter une notice
1799
+    if (!isset($mem[$famille])) {
1800
+        $mem[$famille] = [];
1801
+    }
1802
+    if ($cpt) {
1803
+        return is_countable($mem[$famille]) ? count($mem[$famille]) : 0;
1804
+    }
1805
+    // eviter une notice
1806
+    if (!isset($mem[$famille][$donnee])) {
1807
+        $mem[$famille][$donnee] = 0;
1808
+    }
1809
+    if (!($mem[$famille][$donnee]++)) {
1810
+        return $donnee;
1811
+    }
1812 1812
 }
1813 1813
 
1814 1814
 
@@ -1838,20 +1838,20 @@  discard block
 block discarded – undo
1838 1838
  *     Une des valeurs en fonction du compteur.
1839 1839
  **/
1840 1840
 function alterner($i, ...$args) {
1841
-	// recuperer les arguments (attention fonctions un peu space)
1842
-	$num = count($args);
1841
+    // recuperer les arguments (attention fonctions un peu space)
1842
+    $num = count($args);
1843 1843
 
1844
-	if ($num === 1 && is_array($args[0])) {
1845
-		// un tableau de valeur dont les cles sont numerotees de 0 a num
1846
-		$args = array_values($args[0]);
1847
-		$num = count($args);
1848
-	}
1844
+    if ($num === 1 && is_array($args[0])) {
1845
+        // un tableau de valeur dont les cles sont numerotees de 0 a num
1846
+        $args = array_values($args[0]);
1847
+        $num = count($args);
1848
+    }
1849 1849
 
1850
-	// un index compris entre 0 et num exclus
1851
-	$i = (((int) $i - 1) % $num); // dans ]-$num;$num[
1852
-	$i = ($i + $num) % $num; // dans [0;$num[
1853
-	// renvoyer le i-ieme argument, modulo le nombre d'arguments
1854
-	return $args[$i];
1850
+    // un index compris entre 0 et num exclus
1851
+    $i = (((int) $i - 1) % $num); // dans ]-$num;$num[
1852
+    $i = ($i + $num) % $num; // dans [0;$num[
1853
+    // renvoyer le i-ieme argument, modulo le nombre d'arguments
1854
+    return $args[$i];
1855 1855
 }
1856 1856
 
1857 1857
 
@@ -1877,52 +1877,52 @@  discard block
 block discarded – undo
1877 1877
  *     - null lorsque l’attribut n’existe pas.
1878 1878
  **/
1879 1879
 function extraire_attribut($balise, $attribut, $complet = false) {
1880
-	if (is_array($balise)) {
1881
-		array_walk(
1882
-			$balise,
1883
-			function (&$a, $key, $t) {
1884
-				$a = extraire_attribut($a, $t);
1885
-			},
1886
-			$attribut
1887
-		);
1888
-
1889
-		return $balise;
1890
-	}
1891
-	if (
1892
-		$balise
1893
-		&& stripos($balise, $attribut) !== false
1894
-		&& preg_match(
1895
-			',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
1896
-			. $attribut
1897
-			. '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
1898
-			$balise,
1899
-			$r
1900
-		)
1901
-	) {
1902
-		if (isset($r[3][0]) && ($r[3][0] == '"' || $r[3][0] == "'")) {
1903
-			$r[4] = substr($r[3], 1, -1);
1904
-			$r[3] = $r[3][0];
1905
-		} elseif ($r[3] !== '') {
1906
-			$r[4] = $r[3];
1907
-			$r[3] = '';
1908
-		} else {
1909
-			$r[4] = trim($r[2]);
1910
-		}
1911
-		$att = $r[4];
1912
-		if (str_contains($att, '&#')) {
1913
-			$att = str_replace(['&#039;', '&#39;', '&#034;', '&#34;'], ["'", "'", '"', '"'], $att);
1914
-		}
1915
-		$att = filtrer_entites($att);
1916
-	} else {
1917
-		$att = null;
1918
-		$r = [];
1919
-	}
1920
-
1921
-	if ($complet) {
1922
-		return [$att, $r];
1923
-	} else {
1924
-		return $att;
1925
-	}
1880
+    if (is_array($balise)) {
1881
+        array_walk(
1882
+            $balise,
1883
+            function (&$a, $key, $t) {
1884
+                $a = extraire_attribut($a, $t);
1885
+            },
1886
+            $attribut
1887
+        );
1888
+
1889
+        return $balise;
1890
+    }
1891
+    if (
1892
+        $balise
1893
+        && stripos($balise, $attribut) !== false
1894
+        && preg_match(
1895
+            ',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
1896
+            . $attribut
1897
+            . '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
1898
+            $balise,
1899
+            $r
1900
+        )
1901
+    ) {
1902
+        if (isset($r[3][0]) && ($r[3][0] == '"' || $r[3][0] == "'")) {
1903
+            $r[4] = substr($r[3], 1, -1);
1904
+            $r[3] = $r[3][0];
1905
+        } elseif ($r[3] !== '') {
1906
+            $r[4] = $r[3];
1907
+            $r[3] = '';
1908
+        } else {
1909
+            $r[4] = trim($r[2]);
1910
+        }
1911
+        $att = $r[4];
1912
+        if (str_contains($att, '&#')) {
1913
+            $att = str_replace(['&#039;', '&#39;', '&#034;', '&#34;'], ["'", "'", '"', '"'], $att);
1914
+        }
1915
+        $att = filtrer_entites($att);
1916
+    } else {
1917
+        $att = null;
1918
+        $r = [];
1919
+    }
1920
+
1921
+    if ($complet) {
1922
+        return [$att, $r];
1923
+    } else {
1924
+        return $att;
1925
+    }
1926 1926
 }
1927 1927
 
1928 1928
 /**
@@ -1955,37 +1955,37 @@  discard block
 block discarded – undo
1955 1955
  **/
1956 1956
 function inserer_attribut(?string $balise, string $attribut, ?string $val, bool $proteger = true, bool $vider = false): string {
1957 1957
 
1958
-	if ($balise === null || $balise === '') {
1959
-		return '';
1960
-	}
1958
+    if ($balise === null || $balise === '') {
1959
+        return '';
1960
+    }
1961 1961
 
1962
-	// preparer l'attribut
1963
-	// supprimer les &nbsp; etc mais pas les balises html
1964
-	// qui ont un sens dans un attribut value d'un input
1965
-	if ($proteger) {
1966
-		$val = attribut_html($val, false);
1967
-	}
1962
+    // preparer l'attribut
1963
+    // supprimer les &nbsp; etc mais pas les balises html
1964
+    // qui ont un sens dans un attribut value d'un input
1965
+    if ($proteger) {
1966
+        $val = attribut_html($val, false);
1967
+    }
1968 1968
 
1969
-	// echapper les ' pour eviter tout bug
1970
-	$val = str_replace("'", '&#039;', $val ?? '');
1971
-	$insert = $vider && (string) $val === '' ? '' : " $attribut='$val'";
1969
+    // echapper les ' pour eviter tout bug
1970
+    $val = str_replace("'", '&#039;', $val ?? '');
1971
+    $insert = $vider && (string) $val === '' ? '' : " $attribut='$val'";
1972 1972
 
1973
-	[$old, $r] = extraire_attribut($balise, $attribut, true);
1973
+    [$old, $r] = extraire_attribut($balise, $attribut, true);
1974 1974
 
1975
-	if ($old !== null) {
1976
-		// Remplacer l'ancien attribut du meme nom
1977
-		$balise = $r[1] . $insert . $r[5];
1978
-	} else {
1979
-		// preferer une balise " />" (comme <img />)
1980
-		if (preg_match(',/>,', $balise)) {
1981
-			$balise = preg_replace(',\s?/>,S', $insert . ' />', $balise, 1);
1982
-		} // sinon une balise <a ...> ... </a>
1983
-		else {
1984
-			$balise = preg_replace(',\s?>,S', $insert . '>', $balise, 1);
1985
-		}
1986
-	}
1975
+    if ($old !== null) {
1976
+        // Remplacer l'ancien attribut du meme nom
1977
+        $balise = $r[1] . $insert . $r[5];
1978
+    } else {
1979
+        // preferer une balise " />" (comme <img />)
1980
+        if (preg_match(',/>,', $balise)) {
1981
+            $balise = preg_replace(',\s?/>,S', $insert . ' />', $balise, 1);
1982
+        } // sinon une balise <a ...> ... </a>
1983
+        else {
1984
+            $balise = preg_replace(',\s?>,S', $insert . '>', $balise, 1);
1985
+        }
1986
+    }
1987 1987
 
1988
-	return $balise;
1988
+    return $balise;
1989 1989
 }
1990 1990
 
1991 1991
 /**
@@ -2003,7 +2003,7 @@  discard block
 block discarded – undo
2003 2003
  * @return string Code HTML sans l'attribut
2004 2004
  **/
2005 2005
 function vider_attribut(?string $balise, string $attribut): string {
2006
-	return inserer_attribut($balise, $attribut, '', false, true);
2006
+    return inserer_attribut($balise, $attribut, '', false, true);
2007 2007
 }
2008 2008
 
2009 2009
 /**
@@ -2015,50 +2015,50 @@  discard block
 block discarded – undo
2015 2015
  * @return string
2016 2016
  */
2017 2017
 function modifier_class($balise, $class, $operation = 'ajouter') {
2018
-	if (is_string($class)) {
2019
-		$class = explode(' ', trim($class));
2020
-	}
2021
-	$class = array_filter($class);
2022
-	$class = array_unique($class);
2023
-	if (!$class) {
2024
-		return $balise;
2025
-	}
2026
-
2027
-	$class_courante = extraire_attribut($balise, 'class');
2028
-	$class_new = $class_courante;
2029
-	foreach ($class as $c) {
2030
-		$is_class_presente = false;
2031
-		if (
2032
-			$class_courante
2033
-			&& str_contains($class_courante, (string) $c)
2034
-			&& in_array($c, preg_split(',\s+,', $class_courante))
2035
-		) {
2036
-			$is_class_presente = true;
2037
-		}
2038
-		if (
2039
-			in_array($operation, ['ajouter', 'commuter'])
2040
-			&& !$is_class_presente
2041
-		) {
2042
-			$class_new = ltrim(rtrim($class_new ?? '') . ' ' . $c);
2043
-		} elseif (
2044
-			in_array($operation, ['supprimer', 'commuter'])
2045
-			&& $is_class_presente
2046
-		) {
2047
-			$class_new = preg_split(',\s+,', $class_new);
2048
-			$class_new = array_diff($class_new, [$c]);
2049
-			$class_new = implode(' ', $class_new);
2050
-		}
2051
-	}
2052
-
2053
-	if ($class_new !== $class_courante) {
2054
-		if (strlen($class_new)) {
2055
-			$balise = inserer_attribut($balise, 'class', $class_new);
2056
-		} elseif ($class_courante) {
2057
-			$balise = vider_attribut($balise, 'class');
2058
-		}
2059
-	}
2060
-
2061
-	return $balise;
2018
+    if (is_string($class)) {
2019
+        $class = explode(' ', trim($class));
2020
+    }
2021
+    $class = array_filter($class);
2022
+    $class = array_unique($class);
2023
+    if (!$class) {
2024
+        return $balise;
2025
+    }
2026
+
2027
+    $class_courante = extraire_attribut($balise, 'class');
2028
+    $class_new = $class_courante;
2029
+    foreach ($class as $c) {
2030
+        $is_class_presente = false;
2031
+        if (
2032
+            $class_courante
2033
+            && str_contains($class_courante, (string) $c)
2034
+            && in_array($c, preg_split(',\s+,', $class_courante))
2035
+        ) {
2036
+            $is_class_presente = true;
2037
+        }
2038
+        if (
2039
+            in_array($operation, ['ajouter', 'commuter'])
2040
+            && !$is_class_presente
2041
+        ) {
2042
+            $class_new = ltrim(rtrim($class_new ?? '') . ' ' . $c);
2043
+        } elseif (
2044
+            in_array($operation, ['supprimer', 'commuter'])
2045
+            && $is_class_presente
2046
+        ) {
2047
+            $class_new = preg_split(',\s+,', $class_new);
2048
+            $class_new = array_diff($class_new, [$c]);
2049
+            $class_new = implode(' ', $class_new);
2050
+        }
2051
+    }
2052
+
2053
+    if ($class_new !== $class_courante) {
2054
+        if (strlen($class_new)) {
2055
+            $balise = inserer_attribut($balise, 'class', $class_new);
2056
+        } elseif ($class_courante) {
2057
+            $balise = vider_attribut($balise, 'class');
2058
+        }
2059
+    }
2060
+
2061
+    return $balise;
2062 2062
 }
2063 2063
 
2064 2064
 /**
@@ -2068,7 +2068,7 @@  discard block
 block discarded – undo
2068 2068
  * @return string
2069 2069
  */
2070 2070
 function ajouter_class($balise, $class) {
2071
-	return modifier_class($balise, $class, 'ajouter');
2071
+    return modifier_class($balise, $class, 'ajouter');
2072 2072
 }
2073 2073
 
2074 2074
 /**
@@ -2078,7 +2078,7 @@  discard block
 block discarded – undo
2078 2078
  * @return string
2079 2079
  */
2080 2080
 function supprimer_class($balise, $class) {
2081
-	return modifier_class($balise, $class, 'supprimer');
2081
+    return modifier_class($balise, $class, 'supprimer');
2082 2082
 }
2083 2083
 
2084 2084
 /**
@@ -2089,7 +2089,7 @@  discard block
 block discarded – undo
2089 2089
  * @return string
2090 2090
  */
2091 2091
 function commuter_class($balise, $class) {
2092
-	return modifier_class($balise, $class, 'commuter');
2092
+    return modifier_class($balise, $class, 'commuter');
2093 2093
 }
2094 2094
 
2095 2095
 /**
@@ -2100,19 +2100,19 @@  discard block
 block discarded – undo
2100 2100
  * @return string
2101 2101
  */
2102 2102
 function tester_config($id, $mode = '') {
2103
-	include_spip('action/inscrire_auteur');
2103
+    include_spip('action/inscrire_auteur');
2104 2104
 
2105
-	return tester_statut_inscription($mode, $id);
2105
+    return tester_statut_inscription($mode, $id);
2106 2106
 }
2107 2107
 
2108 2108
 //
2109 2109
 // Quelques fonctions de calcul arithmetique
2110 2110
 //
2111 2111
 function floatstr($a) {
2112
-	return str_replace(',', '.', (string)(float) $a);
2112
+    return str_replace(',', '.', (string)(float) $a);
2113 2113
 }
2114 2114
 function strize($f, $a, $b) {
2115
-	return floatstr($f(floatstr($a), floatstr($b)));
2115
+    return floatstr($f(floatstr($a), floatstr($b)));
2116 2116
 }
2117 2117
 
2118 2118
 /**
@@ -2131,11 +2131,11 @@  discard block
 block discarded – undo
2131 2131
  * @return int $a+$b
2132 2132
  **/
2133 2133
 function plus($a, $b) {
2134
-	return $a + $b;
2134
+    return $a + $b;
2135 2135
 }
2136 2136
 
2137 2137
 function strplus($a, $b) {
2138
-	return strize('plus', $a, $b);
2138
+    return strize('plus', $a, $b);
2139 2139
 }
2140 2140
 
2141 2141
 /**
@@ -2154,11 +2154,11 @@  discard block
 block discarded – undo
2154 2154
  * @return int $a-$b
2155 2155
  **/
2156 2156
 function moins($a, $b) {
2157
-	return $a - $b;
2157
+    return $a - $b;
2158 2158
 }
2159 2159
 
2160 2160
 function strmoins($a, $b) {
2161
-	return strize('moins', $a, $b);
2161
+    return strize('moins', $a, $b);
2162 2162
 }
2163 2163
 
2164 2164
 /**
@@ -2178,11 +2178,11 @@  discard block
 block discarded – undo
2178 2178
  * @return int $a*$b
2179 2179
  **/
2180 2180
 function mult($a, $b) {
2181
-	return $a * $b;
2181
+    return $a * $b;
2182 2182
 }
2183 2183
 
2184 2184
 function strmult($a, $b) {
2185
-	return strize('mult', $a, $b);
2185
+    return strize('mult', $a, $b);
2186 2186
 }
2187 2187
 
2188 2188
 /**
@@ -2202,11 +2202,11 @@  discard block
 block discarded – undo
2202 2202
  * @return int $a/$b (ou 0 si $b est nul)
2203 2203
  **/
2204 2204
 function div($a, $b) {
2205
-	return $b ? $a / $b : 0;
2205
+    return $b ? $a / $b : 0;
2206 2206
 }
2207 2207
 
2208 2208
 function strdiv($a, $b) {
2209
-	return strize('div', $a, $b);
2209
+    return strize('div', $a, $b);
2210 2210
 }
2211 2211
 
2212 2212
 /**
@@ -2227,7 +2227,7 @@  discard block
 block discarded – undo
2227 2227
  * @return int ($nb % $mod) + $add
2228 2228
  **/
2229 2229
 function modulo($nb, $mod, $add = 0) {
2230
-	return ($mod ? $nb % $mod : 0) + $add;
2230
+    return ($mod ? $nb % $mod : 0) + $add;
2231 2231
 }
2232 2232
 
2233 2233
 
@@ -2242,26 +2242,26 @@  discard block
 block discarded – undo
2242 2242
  *      - true sinon
2243 2243
  **/
2244 2244
 function nom_acceptable($nom) {
2245
-	$remp2 = [];
2246
-	$remp1 = [];
2247
-	if (!is_string($nom)) {
2248
-		return false;
2249
-	}
2250
-	if (!defined('_TAGS_NOM_AUTEUR')) {
2251
-		define('_TAGS_NOM_AUTEUR', '');
2252
-	}
2253
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2254
-	foreach ($tags_acceptes as $tag) {
2255
-		if (strlen($tag)) {
2256
-			$remp1[] = '<' . trim($tag) . '>';
2257
-			$remp1[] = '</' . trim($tag) . '>';
2258
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2259
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2260
-		}
2261
-	}
2262
-	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2263
-
2264
-	return str_replace('&lt;', '<', $v_nom) == $nom;
2245
+    $remp2 = [];
2246
+    $remp1 = [];
2247
+    if (!is_string($nom)) {
2248
+        return false;
2249
+    }
2250
+    if (!defined('_TAGS_NOM_AUTEUR')) {
2251
+        define('_TAGS_NOM_AUTEUR', '');
2252
+    }
2253
+    $tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2254
+    foreach ($tags_acceptes as $tag) {
2255
+        if (strlen($tag)) {
2256
+            $remp1[] = '<' . trim($tag) . '>';
2257
+            $remp1[] = '</' . trim($tag) . '>';
2258
+            $remp2[] = '\x60' . trim($tag) . '\x61';
2259
+            $remp2[] = '\x60/' . trim($tag) . '\x61';
2260
+        }
2261
+    }
2262
+    $v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2263
+
2264
+    return str_replace('&lt;', '<', $v_nom) == $nom;
2265 2265
 }
2266 2266
 
2267 2267
 
@@ -2277,13 +2277,13 @@  discard block
 block discarded – undo
2277 2277
  *      - renvoie un tableau si l'entree est un tableau
2278 2278
  **/
2279 2279
 function email_valide($adresses) {
2280
-	if (is_array($adresses)) {
2281
-		$adresses = array_map('email_valide', $adresses);
2282
-		return array_filter($adresses);
2283
-	}
2280
+    if (is_array($adresses)) {
2281
+        $adresses = array_map('email_valide', $adresses);
2282
+        return array_filter($adresses);
2283
+    }
2284 2284
 
2285
-	$email_valide = charger_fonction('email_valide', 'inc');
2286
-	return $email_valide($adresses);
2285
+    $email_valide = charger_fonction('email_valide', 'inc');
2286
+    return $email_valide($adresses);
2287 2287
 }
2288 2288
 
2289 2289
 /**
@@ -2297,29 +2297,29 @@  discard block
 block discarded – undo
2297 2297
  * @return string texte
2298 2298
  **/
2299 2299
 function afficher_enclosures($tags) {
2300
-	$s = [];
2301
-	foreach (extraire_balises($tags, 'a') as $tag) {
2302
-		if (
2303
-			extraire_attribut($tag, 'rel') == 'enclosure'
2304
-			&& ($t = extraire_attribut($tag, 'href'))
2305
-		) {
2306
-			$s[] = preg_replace(
2307
-				',>[^<]+</a>,S',
2308
-				'>'
2309
-				. http_img_pack(
2310
-					'attachment-16.png',
2311
-					$t,
2312
-					'',
2313
-					$t,
2314
-					['utiliser_suffixe_size' => true]
2315
-				)
2316
-				. '</a>',
2317
-				(string) $tag
2318
-			);
2319
-		}
2320
-	}
2321
-
2322
-	return implode('&nbsp;', $s);
2300
+    $s = [];
2301
+    foreach (extraire_balises($tags, 'a') as $tag) {
2302
+        if (
2303
+            extraire_attribut($tag, 'rel') == 'enclosure'
2304
+            && ($t = extraire_attribut($tag, 'href'))
2305
+        ) {
2306
+            $s[] = preg_replace(
2307
+                ',>[^<]+</a>,S',
2308
+                '>'
2309
+                . http_img_pack(
2310
+                    'attachment-16.png',
2311
+                    $t,
2312
+                    '',
2313
+                    $t,
2314
+                    ['utiliser_suffixe_size' => true]
2315
+                )
2316
+                . '</a>',
2317
+                (string) $tag
2318
+            );
2319
+        }
2320
+    }
2321
+
2322
+    return implode('&nbsp;', $s);
2323 2323
 }
2324 2324
 
2325 2325
 /**
@@ -2334,15 +2334,15 @@  discard block
 block discarded – undo
2334 2334
  * @return string Liens trouvés
2335 2335
  **/
2336 2336
 function afficher_tags($tags, $rels = 'tag,directory') {
2337
-	$s = [];
2338
-	foreach (extraire_balises($tags, 'a') as $tag) {
2339
-		$rel = extraire_attribut($tag, 'rel');
2340
-		if (strstr(",$rels,", (string) ",$rel,")) {
2341
-			$s[] = $tag;
2342
-		}
2343
-	}
2337
+    $s = [];
2338
+    foreach (extraire_balises($tags, 'a') as $tag) {
2339
+        $rel = extraire_attribut($tag, 'rel');
2340
+        if (strstr(",$rels,", (string) ",$rel,")) {
2341
+            $s[] = $tag;
2342
+        }
2343
+    }
2344 2344
 
2345
-	return implode(', ', $s);
2345
+    return implode(', ', $s);
2346 2346
 }
2347 2347
 
2348 2348
 
@@ -2364,21 +2364,21 @@  discard block
 block discarded – undo
2364 2364
  * @return string Tag HTML `<a>` avec microformat.
2365 2365
  **/
2366 2366
 function enclosure2microformat($e) {
2367
-	if (!$url = filtrer_entites(extraire_attribut($e, 'url') ?? '')) {
2368
-		$url = filtrer_entites(extraire_attribut($e, 'href') ?? '');
2369
-	}
2370
-	$type = extraire_attribut($e, 'type');
2371
-	if (!$length = extraire_attribut($e, 'length')) {
2372
-		# <media:content : longeur dans fileSize. On tente.
2373
-		$length = extraire_attribut($e, 'fileSize');
2374
-	}
2375
-	$fichier = basename($url);
2367
+    if (!$url = filtrer_entites(extraire_attribut($e, 'url') ?? '')) {
2368
+        $url = filtrer_entites(extraire_attribut($e, 'href') ?? '');
2369
+    }
2370
+    $type = extraire_attribut($e, 'type');
2371
+    if (!$length = extraire_attribut($e, 'length')) {
2372
+        # <media:content : longeur dans fileSize. On tente.
2373
+        $length = extraire_attribut($e, 'fileSize');
2374
+    }
2375
+    $fichier = basename($url);
2376 2376
 
2377
-	return '<a rel="enclosure"'
2378
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2379
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2380
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2381
-	. '>' . $fichier . '</a>';
2377
+    return '<a rel="enclosure"'
2378
+    . ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2379
+    . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2380
+    . ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2381
+    . '>' . $fichier . '</a>';
2382 2382
 }
2383 2383
 
2384 2384
 /**
@@ -2396,24 +2396,24 @@  discard block
 block discarded – undo
2396 2396
  * @return string Tags RSS `<enclosure>`.
2397 2397
  **/
2398 2398
 function microformat2enclosure($tags) {
2399
-	$enclosures = [];
2400
-	foreach (extraire_balises($tags, 'a') as $e) {
2401
-		if (extraire_attribut($e, 'rel') == 'enclosure') {
2402
-			$url = filtrer_entites(extraire_attribut($e, 'href'));
2403
-			$type = extraire_attribut($e, 'type');
2404
-			if (!$length = (int) extraire_attribut($e, 'title')) {
2405
-				$length = (int) extraire_attribut($e, 'length');
2406
-			} # vieux data
2407
-			$fichier = basename($url);
2408
-			$enclosures[] = '<enclosure'
2409
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2410
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2411
-				. ($length ? ' length="' . $length . '"' : '')
2412
-				. ' />';
2413
-		}
2414
-	}
2399
+    $enclosures = [];
2400
+    foreach (extraire_balises($tags, 'a') as $e) {
2401
+        if (extraire_attribut($e, 'rel') == 'enclosure') {
2402
+            $url = filtrer_entites(extraire_attribut($e, 'href'));
2403
+            $type = extraire_attribut($e, 'type');
2404
+            if (!$length = (int) extraire_attribut($e, 'title')) {
2405
+                $length = (int) extraire_attribut($e, 'length');
2406
+            } # vieux data
2407
+            $fichier = basename($url);
2408
+            $enclosures[] = '<enclosure'
2409
+                . ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2410
+                . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2411
+                . ($length ? ' length="' . $length . '"' : '')
2412
+                . ' />';
2413
+        }
2414
+    }
2415 2415
 
2416
-	return implode("\n", $enclosures);
2416
+    return implode("\n", $enclosures);
2417 2417
 }
2418 2418
 
2419 2419
 
@@ -2429,16 +2429,16 @@  discard block
 block discarded – undo
2429 2429
  * @return string Tags RSS Atom `<dc:subject>`.
2430 2430
  **/
2431 2431
 function tags2dcsubject($tags) {
2432
-	$subjects = '';
2433
-	foreach (extraire_balises($tags, 'a') as $e) {
2434
-		if (extraire_attribut($e, 'rel') == 'tag') {
2435
-			$subjects .= '<dc:subject>'
2436
-				. texte_backend(textebrut($e))
2437
-				. '</dc:subject>' . "\n";
2438
-		}
2439
-	}
2432
+    $subjects = '';
2433
+    foreach (extraire_balises($tags, 'a') as $e) {
2434
+        if (extraire_attribut($e, 'rel') == 'tag') {
2435
+            $subjects .= '<dc:subject>'
2436
+                . texte_backend(textebrut($e))
2437
+                . '</dc:subject>' . "\n";
2438
+        }
2439
+    }
2440 2440
 
2441
-	return $subjects;
2441
+    return $subjects;
2442 2442
 }
2443 2443
 
2444 2444
 /**
@@ -2467,12 +2467,12 @@  discard block
 block discarded – undo
2467 2467
  *     - Tableau de résultats, si tableau en entrée.
2468 2468
  **/
2469 2469
 function extraire_balise($texte, $tag = 'a', $profondeur = 1) {
2470
-	$balises = extraire_balises($texte, $tag, ['nb_max' => 1, 'profondeur' => $profondeur]);
2471
-	if (is_array($texte)) {
2472
-		return array_map(fn (array $a) => empty($a) ? '' : reset($a), $balises);
2473
-	}
2470
+    $balises = extraire_balises($texte, $tag, ['nb_max' => 1, 'profondeur' => $profondeur]);
2471
+    if (is_array($texte)) {
2472
+        return array_map(fn (array $a) => empty($a) ? '' : reset($a), $balises);
2473
+    }
2474 2474
 
2475
-	return (empty($balises) ? '' : reset($balises));
2475
+    return (empty($balises) ? '' : reset($balises));
2476 2476
 }
2477 2477
 
2478 2478
 /**
@@ -2500,25 +2500,25 @@  discard block
 block discarded – undo
2500 2500
  *     - Tableau de résultats, si tableau en entrée.
2501 2501
  **/
2502 2502
 function extraire_balises($texte, $tag = 'a', $options = []) {
2503
-	if (is_array($texte)) {
2504
-		array_walk(
2505
-			$texte,
2506
-			function (&$a, $key, $t) {
2507
-				$a = extraire_balises($a, $t);
2508
-			},
2509
-			$tag
2510
-		);
2503
+    if (is_array($texte)) {
2504
+        array_walk(
2505
+            $texte,
2506
+            function (&$a, $key, $t) {
2507
+                $a = extraire_balises($a, $t);
2508
+            },
2509
+            $tag
2510
+        );
2511 2511
 
2512
-		return $texte;
2513
-	}
2512
+        return $texte;
2513
+    }
2514 2514
 
2515
-	$htmlTagCollecteur = new CollecteurHtmlTag($tag);
2516
-	$collection = $htmlTagCollecteur->collecter($texte, $options);
2517
-	if (!empty($collection)) {
2518
-		return array_column($collection, 'raw');
2519
-	}
2515
+    $htmlTagCollecteur = new CollecteurHtmlTag($tag);
2516
+    $collection = $htmlTagCollecteur->collecter($texte, $options);
2517
+    if (!empty($collection)) {
2518
+        return array_column($collection, 'raw');
2519
+    }
2520 2520
 
2521
-	return [];
2521
+    return [];
2522 2522
 }
2523 2523
 
2524 2524
 /**
@@ -2547,11 +2547,11 @@  discard block
 block discarded – undo
2547 2547
  *     - `$def` si on n'a pas transmis de tableau
2548 2548
  **/
2549 2549
 function in_any($val, $vals, $def = '') {
2550
-	if (!is_array($vals) && $vals && ($v = unserialize($vals))) {
2551
-		$vals = $v;
2552
-	}
2550
+    if (!is_array($vals) && $vals && ($v = unserialize($vals))) {
2551
+        $vals = $v;
2552
+    }
2553 2553
 
2554
-	return (is_array($vals) ? (in_array($val, $vals) ? ' ' : '') : ($def));
2554
+    return (is_array($vals) ? (in_array($val, $vals) ? ' ' : '') : ($def));
2555 2555
 }
2556 2556
 
2557 2557
 
@@ -2572,12 +2572,12 @@  discard block
 block discarded – undo
2572 2572
  *     Résultat du calcul
2573 2573
  **/
2574 2574
 function valeur_numerique($expr) {
2575
-	$a = 0;
2576
-	if (preg_match(',^\d+(\s*[+*-]\s*\d+)*$,S', trim($expr))) {
2577
-		eval("\$a = $expr;");
2578
-	}
2575
+    $a = 0;
2576
+    if (preg_match(',^\d+(\s*[+*-]\s*\d+)*$,S', trim($expr))) {
2577
+        eval("\$a = $expr;");
2578
+    }
2579 2579
 
2580
-	return (int) $a;
2580
+    return (int) $a;
2581 2581
 }
2582 2582
 
2583 2583
 /**
@@ -2596,7 +2596,7 @@  discard block
 block discarded – undo
2596 2596
  *      Retourne `$a*$b/$c`
2597 2597
  **/
2598 2598
 function regledetrois($a, $b, $c) {
2599
-	return round($a * $b / $c);
2599
+    return round($a * $b / $c);
2600 2600
 }
2601 2601
 
2602 2602
 
@@ -2619,79 +2619,79 @@  discard block
 block discarded – undo
2619 2619
  * @return string Suite de champs input hidden
2620 2620
  **/
2621 2621
 function form_hidden(?string $action = ''): string {
2622
-	$action ??= '';
2623
-
2624
-	$contexte = [];
2625
-	include_spip('inc/urls');
2626
-	if (
2627
-		($p = urls_decoder_url($action, ''))
2628
-		&& reset($p)
2629
-	) {
2630
-		$fond = array_shift($p);
2631
-		if ($fond != '404') {
2632
-			$contexte = array_shift($p);
2633
-			$contexte['page'] = $fond;
2634
-			$action = preg_replace('/([?]' . preg_quote((string) $fond, '/') . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2635
-		}
2636
-	}
2637
-	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2638
-	if (defined('_DEFINIR_CONTEXTE_TYPE') && _DEFINIR_CONTEXTE_TYPE) {
2639
-		unset($contexte['type']);
2640
-	}
2641
-	if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') || _DEFINIR_CONTEXTE_TYPE_PAGE) {
2642
-		unset($contexte['type-page']);
2643
-	}
2644
-
2645
-	// on va remplir un tableau de valeurs en prenant bien soin de ne pas
2646
-	// ecraser les elements de la forme mots[]=1&mots[]=2
2647
-	$values = [];
2648
-
2649
-	// d'abord avec celles de l'url
2650
-	if (false !== ($p = strpos($action, '?'))) {
2651
-		foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2652
-			$c = explode('=', (string) $c, 2);
2653
-			$var = array_shift($c);
2654
-			$val = array_shift($c) ?? '';
2655
-			if ($var) {
2656
-				$val = rawurldecode($val);
2657
-				$var = rawurldecode($var); // decoder les [] eventuels
2658
-				if (preg_match(',\[\]$,S', $var)) {
2659
-					$values[] = [$var, $val];
2660
-				} else {
2661
-					if (!isset($values[$var])) {
2662
-						$values[$var] = [$var, $val];
2663
-					}
2664
-				}
2665
-			}
2666
-		}
2667
-	}
2668
-
2669
-	// ensuite avec celles du contexte, sans doublonner !
2670
-	foreach ($contexte as $var => $val) {
2671
-		if (preg_match(',\[\]$,S', (string) $var)) {
2672
-			$values[] = [$var, $val];
2673
-		} else {
2674
-			if (!isset($values[$var])) {
2675
-				$values[$var] = [$var, $val];
2676
-			}
2677
-		}
2678
-	}
2679
-
2680
-	// puis on rassemble le tout
2681
-	$hidden = [];
2682
-	foreach ($values as $value) {
2683
-		[$var, $val] = $value;
2684
-		$hidden[] = '<input name="'
2685
-			. entites_html($var)
2686
-			. '"'
2687
-			. (is_null($val)
2688
-				? ''
2689
-				: ' value="' . entites_html($val) . '"'
2690
-			)
2691
-			. ' type="hidden"' . "\n/>";
2692
-	}
2693
-
2694
-	return implode('', $hidden);
2622
+    $action ??= '';
2623
+
2624
+    $contexte = [];
2625
+    include_spip('inc/urls');
2626
+    if (
2627
+        ($p = urls_decoder_url($action, ''))
2628
+        && reset($p)
2629
+    ) {
2630
+        $fond = array_shift($p);
2631
+        if ($fond != '404') {
2632
+            $contexte = array_shift($p);
2633
+            $contexte['page'] = $fond;
2634
+            $action = preg_replace('/([?]' . preg_quote((string) $fond, '/') . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2635
+        }
2636
+    }
2637
+    // defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2638
+    if (defined('_DEFINIR_CONTEXTE_TYPE') && _DEFINIR_CONTEXTE_TYPE) {
2639
+        unset($contexte['type']);
2640
+    }
2641
+    if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') || _DEFINIR_CONTEXTE_TYPE_PAGE) {
2642
+        unset($contexte['type-page']);
2643
+    }
2644
+
2645
+    // on va remplir un tableau de valeurs en prenant bien soin de ne pas
2646
+    // ecraser les elements de la forme mots[]=1&mots[]=2
2647
+    $values = [];
2648
+
2649
+    // d'abord avec celles de l'url
2650
+    if (false !== ($p = strpos($action, '?'))) {
2651
+        foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2652
+            $c = explode('=', (string) $c, 2);
2653
+            $var = array_shift($c);
2654
+            $val = array_shift($c) ?? '';
2655
+            if ($var) {
2656
+                $val = rawurldecode($val);
2657
+                $var = rawurldecode($var); // decoder les [] eventuels
2658
+                if (preg_match(',\[\]$,S', $var)) {
2659
+                    $values[] = [$var, $val];
2660
+                } else {
2661
+                    if (!isset($values[$var])) {
2662
+                        $values[$var] = [$var, $val];
2663
+                    }
2664
+                }
2665
+            }
2666
+        }
2667
+    }
2668
+
2669
+    // ensuite avec celles du contexte, sans doublonner !
2670
+    foreach ($contexte as $var => $val) {
2671
+        if (preg_match(',\[\]$,S', (string) $var)) {
2672
+            $values[] = [$var, $val];
2673
+        } else {
2674
+            if (!isset($values[$var])) {
2675
+                $values[$var] = [$var, $val];
2676
+            }
2677
+        }
2678
+    }
2679
+
2680
+    // puis on rassemble le tout
2681
+    $hidden = [];
2682
+    foreach ($values as $value) {
2683
+        [$var, $val] = $value;
2684
+        $hidden[] = '<input name="'
2685
+            . entites_html($var)
2686
+            . '"'
2687
+            . (is_null($val)
2688
+                ? ''
2689
+                : ' value="' . entites_html($val) . '"'
2690
+            )
2691
+            . ' type="hidden"' . "\n/>";
2692
+    }
2693
+
2694
+    return implode('', $hidden);
2695 2695
 }
2696 2696
 
2697 2697
 
@@ -2713,7 +2713,7 @@  discard block
 block discarded – undo
2713 2713
  *    - la première valeur du tableau sinon.
2714 2714
  **/
2715 2715
 function filtre_reset($array) {
2716
-	return is_array($array) ? reset($array) : null;
2716
+    return is_array($array) ? reset($array) : null;
2717 2717
 }
2718 2718
 
2719 2719
 /**
@@ -2734,7 +2734,7 @@  discard block
 block discarded – undo
2734 2734
  *    - la dernière valeur du tableau sinon.
2735 2735
  **/
2736 2736
 function filtre_end($array) {
2737
-	return is_array($array) ? end($array) : null;
2737
+    return is_array($array) ? end($array) : null;
2738 2738
 }
2739 2739
 
2740 2740
 /**
@@ -2754,11 +2754,11 @@  discard block
 block discarded – undo
2754 2754
  *
2755 2755
  **/
2756 2756
 function filtre_push($array, mixed $val) {
2757
-	if (!is_array($array) || !array_push($array, $val)) {
2758
-		return '';
2759
-	}
2757
+    if (!is_array($array) || !array_push($array, $val)) {
2758
+        return '';
2759
+    }
2760 2760
 
2761
-	return $array;
2761
+    return $array;
2762 2762
 }
2763 2763
 
2764 2764
 /**
@@ -2777,7 +2777,7 @@  discard block
 block discarded – undo
2777 2777
  *     - `true` si la valeur existe dans le tableau, `false` sinon.
2778 2778
  **/
2779 2779
 function filtre_find($array, mixed $val) {
2780
-	return (is_array($array) && in_array($val, $array));
2780
+    return (is_array($array) && in_array($val, $array));
2781 2781
 }
2782 2782
 
2783 2783
 
@@ -2794,13 +2794,13 @@  discard block
 block discarded – undo
2794 2794
  *     Contenu avec urls en absolus
2795 2795
  **/
2796 2796
 function urls_absolues_css($contenu, $source) {
2797
-	$path = suivre_lien(url_absolue($source), './');
2797
+    $path = suivre_lien(url_absolue($source), './');
2798 2798
 
2799
-	return preg_replace_callback(
2800
-		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2801
-		fn($x) => "url('" . suivre_lien($path, $x[1]) . "')",
2802
-		$contenu
2803
-	);
2799
+    return preg_replace_callback(
2800
+        ",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2801
+        fn($x) => "url('" . suivre_lien($path, $x[1]) . "')",
2802
+        $contenu
2803
+    );
2804 2804
 }
2805 2805
 
2806 2806
 
@@ -2829,123 +2829,123 @@  discard block
 block discarded – undo
2829 2829
  *     Chemin du fichier CSS inversé
2830 2830
  **/
2831 2831
 function direction_css($css, $voulue = '') {
2832
-	if (!$css) {
2833
-		return '';
2834
-	}
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;
2832
+    if (!$css) {
2833
+        return '';
2834
+    }
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,104 +4524,104 @@  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
-	$row = ($objets[$type_objet][$id_objet] ?? []) ?: [];
4589
-	// Si la fonction generer_TYPE_TRUC existe, on l'utilise pour formater $info_generee
4590
-	if ($generer = charger_fonction("generer_{$type_objet}_{$info}", '', true)) {
4591
-		$info_generee = $generer($id_objet, $row, ...$params);
4592
-	}
4593
-	// @deprecated 4.1 generer_TRUC_TYPE
4594
-	elseif ($generer = charger_fonction("generer_{$info}_{$type_objet}", '', true)) {
4595
-		trigger_deprecation('spip', '4.1', 'Using "%s" function naming is deprecated, rename "%s" instead', "generer_{$info}_{$type_objet}", "generer_{$type_objet}_{$info}");
4596
-		$info_generee = $generer($id_objet, $row, ...$params);
4597
-	}
4598
-	// Si la fonction generer_objet_TRUC existe, on l'utilise pour formater $info_generee
4599
-	elseif ($generer = charger_fonction("generer_objet_{$info}", '', true)) {
4600
-		$info_generee = $generer($id_objet, $type_objet, $row, ...$params);
4601
-	}
4602
-	// @deprecated 4.1 generer_TRUC_entite
4603
-	elseif ($generer = charger_fonction("generer_{$info}_entite", '', true)) {
4604
-		trigger_deprecation('spip', '4.1', 'Using "%s" function naming is deprecated, rename "%s" instead', "generer_{$info}_entite", "generer_objet_{$info}");
4605
-		$info_generee = $generer($id_objet, $type_objet, $row, ...$params);
4606
-	}
4607
-	// Sinon on prend directement le champ SQL tel quel
4608
-	else {
4609
-		$info_generee = ($objets[$type_objet][$id_objet][$info] ?? '');
4610
-	}
4611
-
4612
-	// On va ensuite appliquer les traitements automatiques si besoin
4613
-	if (!$etoile) {
4614
-		// FIXME: on fournit un ENV minimum avec id et type et connect=''
4615
-		// mais ce fonctionnement est a ameliorer !
4616
-		$info_generee = appliquer_traitement_champ(
4617
-			$info_generee,
4618
-			$info,
4619
-			table_objet($type_objet),
4620
-			['id_objet' => $id_objet, 'objet' => $type_objet, '']
4621
-		);
4622
-	}
4623
-
4624
-	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
+    $row = ($objets[$type_objet][$id_objet] ?? []) ?: [];
4589
+    // Si la fonction generer_TYPE_TRUC existe, on l'utilise pour formater $info_generee
4590
+    if ($generer = charger_fonction("generer_{$type_objet}_{$info}", '', true)) {
4591
+        $info_generee = $generer($id_objet, $row, ...$params);
4592
+    }
4593
+    // @deprecated 4.1 generer_TRUC_TYPE
4594
+    elseif ($generer = charger_fonction("generer_{$info}_{$type_objet}", '', true)) {
4595
+        trigger_deprecation('spip', '4.1', 'Using "%s" function naming is deprecated, rename "%s" instead', "generer_{$info}_{$type_objet}", "generer_{$type_objet}_{$info}");
4596
+        $info_generee = $generer($id_objet, $row, ...$params);
4597
+    }
4598
+    // Si la fonction generer_objet_TRUC existe, on l'utilise pour formater $info_generee
4599
+    elseif ($generer = charger_fonction("generer_objet_{$info}", '', true)) {
4600
+        $info_generee = $generer($id_objet, $type_objet, $row, ...$params);
4601
+    }
4602
+    // @deprecated 4.1 generer_TRUC_entite
4603
+    elseif ($generer = charger_fonction("generer_{$info}_entite", '', true)) {
4604
+        trigger_deprecation('spip', '4.1', 'Using "%s" function naming is deprecated, rename "%s" instead', "generer_{$info}_entite", "generer_objet_{$info}");
4605
+        $info_generee = $generer($id_objet, $type_objet, $row, ...$params);
4606
+    }
4607
+    // Sinon on prend directement le champ SQL tel quel
4608
+    else {
4609
+        $info_generee = ($objets[$type_objet][$id_objet][$info] ?? '');
4610
+    }
4611
+
4612
+    // On va ensuite appliquer les traitements automatiques si besoin
4613
+    if (!$etoile) {
4614
+        // FIXME: on fournit un ENV minimum avec id et type et connect=''
4615
+        // mais ce fonctionnement est a ameliorer !
4616
+        $info_generee = appliquer_traitement_champ(
4617
+            $info_generee,
4618
+            $info,
4619
+            table_objet($type_objet),
4620
+            ['id_objet' => $id_objet, 'objet' => $type_objet, '']
4621
+        );
4622
+    }
4623
+
4624
+    return $info_generee;
4625 4625
 }
4626 4626
 
4627 4627
 /**
@@ -4654,34 +4654,34 @@  discard block
 block discarded – undo
4654 4654
  */
4655 4655
 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 {
4656 4656
 
4657
-	$descriptif = $ligne_sql['descriptif'] ?? '';
4658
-	$texte = $ligne_sql['texte'] ?? '';
4659
-	// En absence de descriptif, on se rabat sur chapo + texte
4660
-	if (isset($ligne_sql['chapo'])) {
4661
-		$chapo = $ligne_sql['chapo'];
4662
-		$texte = strlen((string) $descriptif) ?
4663
-			'' :
4664
-			"$chapo \n\n $texte";
4665
-	}
4657
+    $descriptif = $ligne_sql['descriptif'] ?? '';
4658
+    $texte = $ligne_sql['texte'] ?? '';
4659
+    // En absence de descriptif, on se rabat sur chapo + texte
4660
+    if (isset($ligne_sql['chapo'])) {
4661
+        $chapo = $ligne_sql['chapo'];
4662
+        $texte = strlen((string) $descriptif) ?
4663
+            '' :
4664
+            "$chapo \n\n $texte";
4665
+    }
4666 4666
 
4667
-	// Longueur en paramètre, sinon celle renseignée dans la description de l'objet, sinon valeur en dur
4668
-	if (!(int) $longueur_ou_suite) {
4669
-		$longueur = (int) ($introduction_longueur ?: 600);
4670
-	} else {
4671
-		$longueur = (int) $longueur_ou_suite;
4672
-	}
4667
+    // Longueur en paramètre, sinon celle renseignée dans la description de l'objet, sinon valeur en dur
4668
+    if (!(int) $longueur_ou_suite) {
4669
+        $longueur = (int) ($introduction_longueur ?: 600);
4670
+    } else {
4671
+        $longueur = (int) $longueur_ou_suite;
4672
+    }
4673 4673
 
4674
-	// On peut optionnellement passer la suite en 1er paramètre de la balise
4675
-	// Ex : #INTRODUCTION{...}
4676
-	if (
4677
-		is_null($suite) && !(int) $longueur_ou_suite
4678
-	) {
4679
-		$suite = $longueur_ou_suite;
4680
-	}
4674
+    // On peut optionnellement passer la suite en 1er paramètre de la balise
4675
+    // Ex : #INTRODUCTION{...}
4676
+    if (
4677
+        is_null($suite) && !(int) $longueur_ou_suite
4678
+    ) {
4679
+        $suite = $longueur_ou_suite;
4680
+    }
4681 4681
 
4682
-	$f = chercher_filtre('introduction');
4682
+    $f = chercher_filtre('introduction');
4683 4683
 
4684
-	return $f($descriptif, $texte, $longueur, $connect, $suite);
4684
+    return $f($descriptif, $texte, $longueur, $connect, $suite);
4685 4685
 }
4686 4686
 
4687 4687
 /**
@@ -4694,49 +4694,49 @@  discard block
 block discarded – undo
4694 4694
  * @return string
4695 4695
  */
4696 4696
 function appliquer_traitement_champ($texte, $champ, $table_objet = '', $env = [], string $connect = '') {
4697
-	if (!$champ) {
4698
-		return $texte;
4699
-	}
4697
+    if (!$champ) {
4698
+        return $texte;
4699
+    }
4700 4700
 
4701
-	// On charge les définitions des traitements (inc/texte et fichiers de fonctions)
4702
-	// car il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4703
-	include_fichiers_fonctions();
4701
+    // On charge les définitions des traitements (inc/texte et fichiers de fonctions)
4702
+    // car il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4703
+    include_fichiers_fonctions();
4704 4704
 
4705
-	$champ = strtoupper($champ);
4706
-	$traitements = $GLOBALS['table_des_traitements'][$champ] ?? false;
4707
-	if (!$traitements || !is_array($traitements)) {
4708
-		return $texte;
4709
-	}
4705
+    $champ = strtoupper($champ);
4706
+    $traitements = $GLOBALS['table_des_traitements'][$champ] ?? false;
4707
+    if (!$traitements || !is_array($traitements)) {
4708
+        return $texte;
4709
+    }
4710 4710
 
4711
-	$traitement = '';
4712
-	if ($table_objet && (!isset($traitements[0]) || count($traitements) > 1)) {
4713
-		// necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4714
-		$table_objet = table_objet($table_objet);
4715
-		if (isset($traitements[$table_objet])) {
4716
-			$traitement = $traitements[$table_objet];
4717
-		}
4718
-	}
4719
-	if (!$traitement && isset($traitements[0])) {
4720
-		$traitement = $traitements[0];
4721
-	}
4722
-	// (sinon prendre le premier de la liste par defaut ?)
4711
+    $traitement = '';
4712
+    if ($table_objet && (!isset($traitements[0]) || count($traitements) > 1)) {
4713
+        // necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4714
+        $table_objet = table_objet($table_objet);
4715
+        if (isset($traitements[$table_objet])) {
4716
+            $traitement = $traitements[$table_objet];
4717
+        }
4718
+    }
4719
+    if (!$traitement && isset($traitements[0])) {
4720
+        $traitement = $traitements[0];
4721
+    }
4722
+    // (sinon prendre le premier de la liste par defaut ?)
4723 4723
 
4724
-	if (!$traitement) {
4725
-		return $texte;
4726
-	}
4724
+    if (!$traitement) {
4725
+        return $texte;
4726
+    }
4727 4727
 
4728
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", (string) $traitement);
4728
+    $traitement = str_replace('%s', "'" . texte_script($texte) . "'", (string) $traitement);
4729 4729
 
4730
-	// signaler qu'on est dans l'espace prive pour les filtres qui se servent de ce flag
4731
-	if (test_espace_prive()) {
4732
-		$env['espace_prive'] = 1;
4733
-	}
4730
+    // signaler qu'on est dans l'espace prive pour les filtres qui se servent de ce flag
4731
+    if (test_espace_prive()) {
4732
+        $env['espace_prive'] = 1;
4733
+    }
4734 4734
 
4735
-	// Fournir $connect et $Pile[0] au traitement si besoin
4736
-	$Pile = [0 => $env];
4737
-	eval("\$texte = $traitement;");
4735
+    // Fournir $connect et $Pile[0] au traitement si besoin
4736
+    $Pile = [0 => $env];
4737
+    eval("\$texte = $traitement;");
4738 4738
 
4739
-	return $texte;
4739
+    return $texte;
4740 4740
 }
4741 4741
 
4742 4742
 
@@ -4747,21 +4747,21 @@  discard block
 block discarded – undo
4747 4747
  * @return string
4748 4748
  */
4749 4749
 function generer_objet_lien(int $id_objet, string $objet, int $longueur = 80, string $connect = ''): string {
4750
-	include_spip('inc/liens');
4751
-	$titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4752
-	// lorsque l'objet n'est plus declare (plugin desactive par exemple)
4753
-	// le raccourcis n'est plus valide
4754
-	$titre = typo($titre['titre'] ?? '');
4755
-	// on essaye avec generer_objet_info ?
4756
-	if (!strlen($titre) && !$connect) {
4757
-		$titre = generer_objet_info($id_objet, $objet, 'titre');
4758
-	}
4759
-	if (!strlen($titre)) {
4760
-		$titre = _T('info_sans_titre');
4761
-	}
4762
-	$url = generer_objet_url($id_objet, $objet, '', '', null, '', $connect);
4750
+    include_spip('inc/liens');
4751
+    $titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4752
+    // lorsque l'objet n'est plus declare (plugin desactive par exemple)
4753
+    // le raccourcis n'est plus valide
4754
+    $titre = typo($titre['titre'] ?? '');
4755
+    // on essaye avec generer_objet_info ?
4756
+    if (!strlen($titre) && !$connect) {
4757
+        $titre = generer_objet_info($id_objet, $objet, 'titre');
4758
+    }
4759
+    if (!strlen($titre)) {
4760
+        $titre = _T('info_sans_titre');
4761
+    }
4762
+    $url = generer_objet_url($id_objet, $objet, '', '', null, '', $connect);
4763 4763
 
4764
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . '</a>';
4764
+    return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . '</a>';
4765 4765
 }
4766 4766
 
4767 4767
 /**
@@ -4777,15 +4777,15 @@  discard block
 block discarded – undo
4777 4777
  * @return string
4778 4778
  */
4779 4779
 function wrap($texte, $wrap) {
4780
-	$balises = extraire_balises($wrap);
4781
-	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4782
-		$texte = $wrap . $texte;
4783
-		$regs = array_reverse($regs[1]);
4784
-		$wrap = '</' . implode('></', $regs) . '>';
4785
-		$texte .= $wrap;
4786
-	}
4780
+    $balises = extraire_balises($wrap);
4781
+    if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4782
+        $texte = $wrap . $texte;
4783
+        $regs = array_reverse($regs[1]);
4784
+        $wrap = '</' . implode('></', $regs) . '>';
4785
+        $texte .= $wrap;
4786
+    }
4787 4787
 
4788
-	return $texte;
4788
+    return $texte;
4789 4789
 }
4790 4790
 
4791 4791
 
@@ -4805,42 +4805,42 @@  discard block
 block discarded – undo
4805 4805
  * @return array|mixed|string
4806 4806
  */
4807 4807
 function filtre_print_dist($u, $join = '<br />', $indent = 0) {
4808
-	if (is_string($u)) {
4809
-		return typo($u);
4810
-	}
4811
-
4812
-	// caster $u en array si besoin
4813
-	if (is_object($u)) {
4814
-		$u = (array)$u;
4815
-	}
4816
-
4817
-	if (is_array($u)) {
4818
-		$out = '';
4819
-		// toutes les cles sont numeriques ?
4820
-		// et aucun enfant n'est un tableau
4821
-		// liste simple separee par des virgules
4822
-		$numeric_keys = array_map('is_numeric', array_keys($u));
4823
-		$array_values = array_map('is_array', $u);
4824
-		$object_values = array_map('is_object', $u);
4825
-		if (
4826
-			array_sum($numeric_keys) == count($numeric_keys)
4827
-			&& !array_sum($array_values)
4828
-			&& !array_sum($object_values)
4829
-		) {
4830
-			return implode(', ', array_map('filtre_print_dist', $u));
4831
-		}
4832
-
4833
-		// sinon on passe a la ligne et on indente
4834
-		$i_str = str_pad('', $indent, ' ');
4835
-		foreach ($u as $k => $v) {
4836
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4837
-		}
4838
-
4839
-		return $out;
4840
-	}
4841
-
4842
-	// on sait pas quoi faire...
4843
-	return $u;
4808
+    if (is_string($u)) {
4809
+        return typo($u);
4810
+    }
4811
+
4812
+    // caster $u en array si besoin
4813
+    if (is_object($u)) {
4814
+        $u = (array)$u;
4815
+    }
4816
+
4817
+    if (is_array($u)) {
4818
+        $out = '';
4819
+        // toutes les cles sont numeriques ?
4820
+        // et aucun enfant n'est un tableau
4821
+        // liste simple separee par des virgules
4822
+        $numeric_keys = array_map('is_numeric', array_keys($u));
4823
+        $array_values = array_map('is_array', $u);
4824
+        $object_values = array_map('is_object', $u);
4825
+        if (
4826
+            array_sum($numeric_keys) == count($numeric_keys)
4827
+            && !array_sum($array_values)
4828
+            && !array_sum($object_values)
4829
+        ) {
4830
+            return implode(', ', array_map('filtre_print_dist', $u));
4831
+        }
4832
+
4833
+        // sinon on passe a la ligne et on indente
4834
+        $i_str = str_pad('', $indent, ' ');
4835
+        foreach ($u as $k => $v) {
4836
+            $out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4837
+        }
4838
+
4839
+        return $out;
4840
+    }
4841
+
4842
+    // on sait pas quoi faire...
4843
+    return $u;
4844 4844
 }
4845 4845
 
4846 4846
 
@@ -4853,10 +4853,10 @@  discard block
 block discarded – undo
4853 4853
  * @return string|array
4854 4854
  */
4855 4855
 function objet_info($objet, $info) {
4856
-	$table = table_objet_sql($objet);
4857
-	$infos = lister_tables_objets_sql($table);
4856
+    $table = table_objet_sql($objet);
4857
+    $infos = lister_tables_objets_sql($table);
4858 4858
 
4859
-	return ($infos[$info] ?? '');
4859
+    return ($infos[$info] ?? '');
4860 4860
 }
4861 4861
 
4862 4862
 /**
@@ -4871,11 +4871,11 @@  discard block
 block discarded – undo
4871 4871
  *     texte traduit du comptage, tel que '3 articles'
4872 4872
  */
4873 4873
 function objet_afficher_nb($nb, $objet) {
4874
-	if (!$nb) {
4875
-		return _T(objet_info($objet, 'info_aucun_objet'));
4876
-	} else {
4877
-		return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), ['nb' => $nb]);
4878
-	}
4874
+    if (!$nb) {
4875
+        return _T(objet_info($objet, 'info_aucun_objet'));
4876
+    } else {
4877
+        return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), ['nb' => $nb]);
4878
+    }
4879 4879
 }
4880 4880
 
4881 4881
 /**
@@ -4887,11 +4887,11 @@  discard block
 block discarded – undo
4887 4887
  * @return string
4888 4888
  */
4889 4889
 function objet_icone($objet, $taille = 24, $class = '') {
4890
-	$icone = objet_info($objet, 'icone_objet') . '-' . $taille . '.png';
4891
-	$icone = chemin_image($icone);
4892
-	$balise_img = charger_filtre('balise_img');
4890
+    $icone = objet_info($objet, 'icone_objet') . '-' . $taille . '.png';
4891
+    $icone = chemin_image($icone);
4892
+    $balise_img = charger_filtre('balise_img');
4893 4893
 
4894
-	return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : '';
4894
+    return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : '';
4895 4895
 }
4896 4896
 
4897 4897
 /**
@@ -4912,12 +4912,12 @@  discard block
 block discarded – undo
4912 4912
  * @return string
4913 4913
  */
4914 4914
 function objet_T($objet, $chaine, $args = [], $options = []) {
4915
-	$chaine = explode(':', $chaine);
4916
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, ['force' => false]))) {
4917
-		return $t;
4918
-	}
4919
-	$chaine = implode(':', $chaine);
4920
-	return _T($chaine, $args, $options);
4915
+    $chaine = explode(':', $chaine);
4916
+    if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, ['force' => false]))) {
4917
+        return $t;
4918
+    }
4919
+    $chaine = implode(':', $chaine);
4920
+    return _T($chaine, $args, $options);
4921 4921
 }
4922 4922
 
4923 4923
 /**
@@ -4931,18 +4931,18 @@  discard block
 block discarded – undo
4931 4931
  * @return string      Code HTML
4932 4932
  */
4933 4933
 function insert_head_css_conditionnel($flux) {
4934
-	if (
4935
-		!str_contains($flux, '<!-- insert_head_css -->')
4936
-		&& ($p = strpos($flux, '<!-- insert_head -->'))
4937
-	) {
4938
-		// plutot avant le premier js externe (jquery) pour etre non bloquant
4939
-		if (($p1 = stripos($flux, '<script src=')) && $p1 < $p) {
4940
-			$p = $p1;
4941
-		}
4942
-		$flux = substr_replace($flux, (string) pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
4943
-	}
4934
+    if (
4935
+        !str_contains($flux, '<!-- insert_head_css -->')
4936
+        && ($p = strpos($flux, '<!-- insert_head -->'))
4937
+    ) {
4938
+        // plutot avant le premier js externe (jquery) pour etre non bloquant
4939
+        if (($p1 = stripos($flux, '<script src=')) && $p1 < $p) {
4940
+            $p = $p1;
4941
+        }
4942
+        $flux = substr_replace($flux, (string) pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
4943
+    }
4944 4944
 
4945
-	return $flux;
4945
+    return $flux;
4946 4946
 }
4947 4947
 
4948 4948
 /**
@@ -4965,75 +4965,75 @@  discard block
 block discarded – undo
4965 4965
  * @return string
4966 4966
  */
4967 4967
 function produire_fond_statique($fond, $contexte = [], $options = [], string $connect = '') {
4968
-	if (isset($contexte['format'])) {
4969
-		$extension = $contexte['format'];
4970
-		unset($contexte['format']);
4971
-	} else {
4972
-		$extension = 'html';
4973
-		if (preg_match(',[.](css|js|json|xml|svg)$,', $fond, $m)) {
4974
-			$extension = $m[1];
4975
-		}
4976
-	}
4977
-	// recuperer le contenu produit par le squelette
4978
-	$options['raw'] = true;
4979
-	$cache = recuperer_fond($fond, $contexte, $options, $connect);
4980
-
4981
-	// calculer le nom de la css
4982
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4983
-	$nom_safe = preg_replace(',\W,', '_', str_replace('.', '_', $fond));
4984
-	$contexte_implicite = calculer_contexte_implicite();
4985
-
4986
-	// par defaut on hash selon les contextes qui sont a priori moins variables
4987
-	// mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
4988
-	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4989
-	if (isset($options['hash_on_content']) && $options['hash_on_content']) {
4990
-		$hash = md5((string) ($contexte_implicite['host'] . '::' . $cache));
4991
-	}
4992
-	else {
4993
-		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4994
-		ksort($contexte);
4995
-		$hash = md5($fond . json_encode($contexte_implicite, JSON_THROW_ON_ERROR) . json_encode($contexte, JSON_THROW_ON_ERROR) . $connect);
4996
-	}
4997
-	$filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
4998
-
4999
-	// mettre a jour le fichier si il n'existe pas
5000
-	// ou trop ancien
5001
-	// le dernier fichier produit est toujours suffixe par .last
5002
-	// et recopie sur le fichier cible uniquement si il change
5003
-	if (
5004
-		!file_exists($filename)
5005
-		|| !file_exists($filename . '.last')
5006
-		|| isset($cache['lastmodified']) && $cache['lastmodified'] && filemtime($filename . '.last') < $cache['lastmodified']
5007
-		|| defined('_VAR_MODE') && _VAR_MODE == 'recalcul'
5008
-	) {
5009
-		$contenu = $cache['texte'];
5010
-		// passer les urls en absolu si c'est une css
5011
-		if ($extension == 'css') {
5012
-			$contenu = urls_absolues_css(
5013
-				$contenu,
5014
-				test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond)
5015
-			);
5016
-		}
5017
-
5018
-		$comment = '';
5019
-		// ne pas insérer de commentaire sur certains formats
5020
-		if (!in_array($extension, ['json', 'xml', 'svg'])) {
5021
-			$comment = "/* #PRODUIRE{fond=$fond";
5022
-			foreach ($contexte as $k => $v) {
5023
-				if (is_array($v)) {
5024
-					$v = var_export($v, true);
5025
-				}
5026
-				$comment .= ",$k=$v";
5027
-			}
5028
-			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
5029
-			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
5030
-			$comment .= "}\n   md5:" . md5((string) $contenu) . " */\n";
5031
-		}
5032
-		// et ecrire le fichier si il change
5033
-		ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
5034
-	}
5035
-
5036
-	return timestamp($filename);
4968
+    if (isset($contexte['format'])) {
4969
+        $extension = $contexte['format'];
4970
+        unset($contexte['format']);
4971
+    } else {
4972
+        $extension = 'html';
4973
+        if (preg_match(',[.](css|js|json|xml|svg)$,', $fond, $m)) {
4974
+            $extension = $m[1];
4975
+        }
4976
+    }
4977
+    // recuperer le contenu produit par le squelette
4978
+    $options['raw'] = true;
4979
+    $cache = recuperer_fond($fond, $contexte, $options, $connect);
4980
+
4981
+    // calculer le nom de la css
4982
+    $dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4983
+    $nom_safe = preg_replace(',\W,', '_', str_replace('.', '_', $fond));
4984
+    $contexte_implicite = calculer_contexte_implicite();
4985
+
4986
+    // par defaut on hash selon les contextes qui sont a priori moins variables
4987
+    // mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
4988
+    // reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4989
+    if (isset($options['hash_on_content']) && $options['hash_on_content']) {
4990
+        $hash = md5((string) ($contexte_implicite['host'] . '::' . $cache));
4991
+    }
4992
+    else {
4993
+        unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4994
+        ksort($contexte);
4995
+        $hash = md5($fond . json_encode($contexte_implicite, JSON_THROW_ON_ERROR) . json_encode($contexte, JSON_THROW_ON_ERROR) . $connect);
4996
+    }
4997
+    $filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
4998
+
4999
+    // mettre a jour le fichier si il n'existe pas
5000
+    // ou trop ancien
5001
+    // le dernier fichier produit est toujours suffixe par .last
5002
+    // et recopie sur le fichier cible uniquement si il change
5003
+    if (
5004
+        !file_exists($filename)
5005
+        || !file_exists($filename . '.last')
5006
+        || isset($cache['lastmodified']) && $cache['lastmodified'] && filemtime($filename . '.last') < $cache['lastmodified']
5007
+        || defined('_VAR_MODE') && _VAR_MODE == 'recalcul'
5008
+    ) {
5009
+        $contenu = $cache['texte'];
5010
+        // passer les urls en absolu si c'est une css
5011
+        if ($extension == 'css') {
5012
+            $contenu = urls_absolues_css(
5013
+                $contenu,
5014
+                test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond)
5015
+            );
5016
+        }
5017
+
5018
+        $comment = '';
5019
+        // ne pas insérer de commentaire sur certains formats
5020
+        if (!in_array($extension, ['json', 'xml', 'svg'])) {
5021
+            $comment = "/* #PRODUIRE{fond=$fond";
5022
+            foreach ($contexte as $k => $v) {
5023
+                if (is_array($v)) {
5024
+                    $v = var_export($v, true);
5025
+                }
5026
+                $comment .= ",$k=$v";
5027
+            }
5028
+            // pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
5029
+            // mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
5030
+            $comment .= "}\n   md5:" . md5((string) $contenu) . " */\n";
5031
+        }
5032
+        // et ecrire le fichier si il change
5033
+        ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
5034
+    }
5035
+
5036
+    return timestamp($filename);
5037 5037
 }
5038 5038
 
5039 5039
 /**
@@ -5046,11 +5046,11 @@  discard block
 block discarded – undo
5046 5046
  *    $fichier auquel on a ajouté le timestamp
5047 5047
  */
5048 5048
 function timestamp($fichier) {
5049
-	if (!$fichier || !file_exists($fichier) || !$m = filemtime($fichier)) {
5050
-		return $fichier;
5051
-	}
5049
+    if (!$fichier || !file_exists($fichier) || !$m = filemtime($fichier)) {
5050
+        return $fichier;
5051
+    }
5052 5052
 
5053
-	return "$fichier?$m";
5053
+    return "$fichier?$m";
5054 5054
 }
5055 5055
 
5056 5056
 /**
@@ -5060,11 +5060,11 @@  discard block
 block discarded – undo
5060 5060
  * @return string
5061 5061
  */
5062 5062
 function supprimer_timestamp($url) {
5063
-	if (!str_contains($url, '?')) {
5064
-		return $url;
5065
-	}
5063
+    if (!str_contains($url, '?')) {
5064
+        return $url;
5065
+    }
5066 5066
 
5067
-	return preg_replace(',\?[[:digit:]]+$,', '', $url);
5067
+    return preg_replace(',\?[[:digit:]]+$,', '', $url);
5068 5068
 }
5069 5069
 
5070 5070
 /**
@@ -5079,15 +5079,15 @@  discard block
 block discarded – undo
5079 5079
  * @return string
5080 5080
  */
5081 5081
 function filtre_nettoyer_titre_email_dist($titre) {
5082
-	include_spip('inc/envoyer_mail');
5082
+    include_spip('inc/envoyer_mail');
5083 5083
 
5084
-	$titre = nettoyer_titre_email($titre);
5085
-	// on est dans un squelette : securiser le retour
5086
-	if (str_contains($titre, '<')) {
5087
-		$titre = interdire_scripts($titre);
5088
-	}
5084
+    $titre = nettoyer_titre_email($titre);
5085
+    // on est dans un squelette : securiser le retour
5086
+    if (str_contains($titre, '<')) {
5087
+        $titre = interdire_scripts($titre);
5088
+    }
5089 5089
 
5090
-	return $titre;
5090
+    return $titre;
5091 5091
 }
5092 5092
 
5093 5093
 /**
@@ -5109,27 +5109,27 @@  discard block
 block discarded – undo
5109 5109
  * @return string
5110 5110
  */
5111 5111
 function filtre_chercher_rubrique_dist(
5112
-	$titre,
5113
-	$id_objet,
5114
-	$id_parent,
5115
-	$objet,
5116
-	$id_secteur,
5117
-	$restreint,
5118
-	$actionable = false,
5119
-	$retour_sans_cadre = false
5112
+    $titre,
5113
+    $id_objet,
5114
+    $id_parent,
5115
+    $objet,
5116
+    $id_secteur,
5117
+    $restreint,
5118
+    $actionable = false,
5119
+    $retour_sans_cadre = false
5120 5120
 ) {
5121
-	include_spip('inc/filtres_ecrire');
5121
+    include_spip('inc/filtres_ecrire');
5122 5122
 
5123
-	return chercher_rubrique(
5124
-		$titre,
5125
-		$id_objet,
5126
-		$id_parent,
5127
-		$objet,
5128
-		$id_secteur,
5129
-		$restreint,
5130
-		$actionable,
5131
-		$retour_sans_cadre
5132
-	);
5123
+    return chercher_rubrique(
5124
+        $titre,
5125
+        $id_objet,
5126
+        $id_parent,
5127
+        $objet,
5128
+        $id_secteur,
5129
+        $restreint,
5130
+        $actionable,
5131
+        $retour_sans_cadre
5132
+    );
5133 5133
 }
5134 5134
 
5135 5135
 /**
@@ -5158,56 +5158,56 @@  discard block
 block discarded – undo
5158 5158
  *     Chaîne vide si l'accès est autorisé
5159 5159
  */
5160 5160
 function sinon_interdire_acces($ok = false, $url = '', $statut = 0, $message = null) {
5161
-	if ($ok) {
5162
-		return '';
5163
-	}
5164
-
5165
-	// Vider tous les tampons
5166
-	$level = @ob_get_level();
5167
-	while ($level--) {
5168
-		@ob_end_clean();
5169
-	}
5170
-
5171
-	include_spip('inc/headers');
5172
-
5173
-	// S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
5174
-	if ($url) {
5175
-		redirige_par_entete($url, '', $statut);
5176
-	}
5177
-
5178
-	// ecriture simplifiee avec message en 3eme argument (= statut 403)
5179
-	if (!is_numeric($statut) && is_null($message)) {
5180
-		$message = $statut;
5181
-		$statut = 0;
5182
-	}
5183
-	if (!$message) {
5184
-		$message = '';
5185
-	}
5186
-	$statut = (int) $statut;
5187
-
5188
-	// Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
5189
-	if (test_espace_prive()) {
5190
-		if (!$statut || !in_array($statut, [404, 403])) {
5191
-			$statut = 403;
5192
-		}
5193
-		http_response_code(403);
5194
-		$echec = charger_fonction('403', 'exec');
5195
-		$echec($message);
5196
-	} else {
5197
-		// Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
5198
-		if (!$statut) {
5199
-			$statut = 404;
5200
-		}
5201
-		// Dans tous les cas on modifie l'entité avec ce qui est demandé
5202
-		http_response_code($statut);
5203
-		// Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
5204
-		if ($statut >= 400) {
5205
-			echo recuperer_fond("$statut", ['erreur' => $message]);
5206
-		}
5207
-	}
5208
-
5209
-
5210
-	exit;
5161
+    if ($ok) {
5162
+        return '';
5163
+    }
5164
+
5165
+    // Vider tous les tampons
5166
+    $level = @ob_get_level();
5167
+    while ($level--) {
5168
+        @ob_end_clean();
5169
+    }
5170
+
5171
+    include_spip('inc/headers');
5172
+
5173
+    // S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
5174
+    if ($url) {
5175
+        redirige_par_entete($url, '', $statut);
5176
+    }
5177
+
5178
+    // ecriture simplifiee avec message en 3eme argument (= statut 403)
5179
+    if (!is_numeric($statut) && is_null($message)) {
5180
+        $message = $statut;
5181
+        $statut = 0;
5182
+    }
5183
+    if (!$message) {
5184
+        $message = '';
5185
+    }
5186
+    $statut = (int) $statut;
5187
+
5188
+    // Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
5189
+    if (test_espace_prive()) {
5190
+        if (!$statut || !in_array($statut, [404, 403])) {
5191
+            $statut = 403;
5192
+        }
5193
+        http_response_code(403);
5194
+        $echec = charger_fonction('403', 'exec');
5195
+        $echec($message);
5196
+    } else {
5197
+        // Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
5198
+        if (!$statut) {
5199
+            $statut = 404;
5200
+        }
5201
+        // Dans tous les cas on modifie l'entité avec ce qui est demandé
5202
+        http_response_code($statut);
5203
+        // Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
5204
+        if ($statut >= 400) {
5205
+            echo recuperer_fond("$statut", ['erreur' => $message]);
5206
+        }
5207
+    }
5208
+
5209
+
5210
+    exit;
5211 5211
 }
5212 5212
 
5213 5213
 /**
@@ -5218,11 +5218,11 @@  discard block
 block discarded – undo
5218 5218
  * @return string
5219 5219
  */
5220 5220
 function filtre_compacte_dist($source, $format = null) {
5221
-	if (function_exists('minifier')) {
5222
-		return minifier($source, $format);
5223
-	}
5221
+    if (function_exists('minifier')) {
5222
+        return minifier($source, $format);
5223
+    }
5224 5224
 
5225
-	return $source;
5225
+    return $source;
5226 5226
 }
5227 5227
 
5228 5228
 
@@ -5232,32 +5232,32 @@  discard block
 block discarded – undo
5232 5232
  * @return string
5233 5233
  */
5234 5234
 function spip_affiche_mot_de_passe_masque(#[\SensitiveParameter] ?string $passe, bool $afficher_partiellement = false, ?int $portion_pourcent = null): string {
5235
-	$passe ??= '';
5236
-	$l = strlen($passe);
5237
-
5238
-	if ($l <= 8 || !$afficher_partiellement) {
5239
-		if (!$l) {
5240
-			return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
5241
-		}
5242
-		return str_pad('', $afficher_partiellement ? $l : 16, '*');
5243
-	}
5244
-
5245
-	if (is_null($portion_pourcent)) {
5246
-		if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) {
5247
-			define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20%
5248
-		}
5249
-		$portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT;
5250
-	}
5251
-	if ($portion_pourcent >= 100) {
5252
-		return $passe;
5253
-	}
5254
-	$e = (int) ceil($l * $portion_pourcent / 100 / 2);
5255
-	$e = max($e, 0);
5256
-	$mid = str_pad('', $l - 2 * $e, '*');
5257
-	if ($e > 0 && strlen($mid) > 8) {
5258
-		$mid = '***...***';
5259
-	}
5260
-	return substr($passe, 0, $e) . $mid . ($e > 0 ? substr($passe, -$e) : '');
5235
+    $passe ??= '';
5236
+    $l = strlen($passe);
5237
+
5238
+    if ($l <= 8 || !$afficher_partiellement) {
5239
+        if (!$l) {
5240
+            return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
5241
+        }
5242
+        return str_pad('', $afficher_partiellement ? $l : 16, '*');
5243
+    }
5244
+
5245
+    if (is_null($portion_pourcent)) {
5246
+        if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) {
5247
+            define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20%
5248
+        }
5249
+        $portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT;
5250
+    }
5251
+    if ($portion_pourcent >= 100) {
5252
+        return $passe;
5253
+    }
5254
+    $e = (int) ceil($l * $portion_pourcent / 100 / 2);
5255
+    $e = max($e, 0);
5256
+    $mid = str_pad('', $l - 2 * $e, '*');
5257
+    if ($e > 0 && strlen($mid) > 8) {
5258
+        $mid = '***...***';
5259
+    }
5260
+    return substr($passe, 0, $e) . $mid . ($e > 0 ? substr($passe, -$e) : '');
5261 5261
 }
5262 5262
 
5263 5263
 
@@ -5278,64 +5278,64 @@  discard block
 block discarded – undo
5278 5278
  */
5279 5279
 function identifiant_slug($texte, $type = '', $options = []) {
5280 5280
 
5281
-	$original = $texte;
5282
-	$separateur = ($options['separateur'] ?? '_');
5283
-	$longueur_maxi = ($options['longueur_maxi'] ?? 60);
5284
-	$longueur_mini = ($options['longueur_mini'] ?? 0);
5281
+    $original = $texte;
5282
+    $separateur = ($options['separateur'] ?? '_');
5283
+    $longueur_maxi = ($options['longueur_maxi'] ?? 60);
5284
+    $longueur_mini = ($options['longueur_mini'] ?? 0);
5285 5285
 
5286
-	if (!function_exists('translitteration')) {
5287
-		include_spip('inc/charsets');
5288
-	}
5286
+    if (!function_exists('translitteration')) {
5287
+        include_spip('inc/charsets');
5288
+    }
5289 5289
 
5290
-	// pas de balise html
5291
-	if (str_contains($texte, '<')) {
5292
-		$texte = strip_tags($texte);
5293
-	}
5294
-	if (str_contains($texte, '&')) {
5295
-		$texte = unicode2charset($texte);
5296
-	}
5297
-	// On enlève les espaces indésirables
5298
-	$texte = trim($texte);
5290
+    // pas de balise html
5291
+    if (str_contains($texte, '<')) {
5292
+        $texte = strip_tags($texte);
5293
+    }
5294
+    if (str_contains($texte, '&')) {
5295
+        $texte = unicode2charset($texte);
5296
+    }
5297
+    // On enlève les espaces indésirables
5298
+    $texte = trim($texte);
5299 5299
 
5300
-	// On enlève les accents et cie
5301
-	$texte = translitteration($texte);
5300
+    // On enlève les accents et cie
5301
+    $texte = translitteration($texte);
5302 5302
 
5303
-	// On remplace tout ce qui n'est pas un mot par un séparateur
5304
-	$texte = preg_replace(',[\W_]+,ms', (string) $separateur, $texte);
5303
+    // On remplace tout ce qui n'est pas un mot par un séparateur
5304
+    $texte = preg_replace(',[\W_]+,ms', (string) $separateur, $texte);
5305 5305
 
5306
-	// nettoyer les doubles occurences du separateur si besoin
5307
-	while (str_contains($texte, (string) "$separateur$separateur")) {
5308
-		$texte = str_replace("$separateur$separateur", $separateur, $texte);
5309
-	}
5306
+    // nettoyer les doubles occurences du separateur si besoin
5307
+    while (str_contains($texte, (string) "$separateur$separateur")) {
5308
+        $texte = str_replace("$separateur$separateur", $separateur, $texte);
5309
+    }
5310 5310
 
5311
-	// pas de separateur au debut ni a la fin
5312
-	$texte = trim($texte, $separateur);
5311
+    // pas de separateur au debut ni a la fin
5312
+    $texte = trim($texte, $separateur);
5313 5313
 
5314
-	// en minuscules
5315
-	$texte = strtolower($texte);
5314
+    // en minuscules
5315
+    $texte = strtolower($texte);
5316 5316
 
5317
-	switch ($type) {
5318
-		case 'class':
5319
-		case 'id':
5320
-		case 'anchor':
5321
-			if (preg_match(',^\d,', $texte)) {
5322
-				$texte = substr($type, 0, 1) . $texte;
5323
-			}
5324
-	}
5317
+    switch ($type) {
5318
+        case 'class':
5319
+        case 'id':
5320
+        case 'anchor':
5321
+            if (preg_match(',^\d,', $texte)) {
5322
+                $texte = substr($type, 0, 1) . $texte;
5323
+            }
5324
+    }
5325 5325
 
5326
-	if (strlen($texte) > $longueur_maxi) {
5327
-		$texte = substr($texte, 0, $longueur_maxi);
5328
-	}
5326
+    if (strlen($texte) > $longueur_maxi) {
5327
+        $texte = substr($texte, 0, $longueur_maxi);
5328
+    }
5329 5329
 
5330
-	if (strlen($texte) < $longueur_mini && $longueur_mini < $longueur_maxi) {
5331
-		if (preg_match(',^\d,', $texte)) {
5332
-			$texte = ($type ? substr($type, 0, 1) : 's') . $texte;
5333
-		}
5334
-		$texte .= $separateur . md5($original);
5335
-		$texte = substr($texte, 0, $longueur_mini);
5336
-	}
5330
+    if (strlen($texte) < $longueur_mini && $longueur_mini < $longueur_maxi) {
5331
+        if (preg_match(',^\d,', $texte)) {
5332
+            $texte = ($type ? substr($type, 0, 1) : 's') . $texte;
5333
+        }
5334
+        $texte .= $separateur . md5($original);
5335
+        $texte = substr($texte, 0, $longueur_mini);
5336
+    }
5337 5337
 
5338
-	return $texte;
5338
+    return $texte;
5339 5339
 }
5340 5340
 
5341 5341
 
@@ -5356,11 +5356,11 @@  discard block
 block discarded – undo
5356 5356
  * @exemple `<:info_maximum|label_nettoyer:>`
5357 5357
  */
5358 5358
 function label_nettoyer(string $text, bool $ucfirst = true): string {
5359
-	$label = preg_replace('#([\s:]|\&nbsp;)+$#u', '', $text);
5360
-	if ($ucfirst) {
5361
-		$label = spip_ucfirst($label);
5362
-	}
5363
-	return $label;
5359
+    $label = preg_replace('#([\s:]|\&nbsp;)+$#u', '', $text);
5360
+    if ($ucfirst) {
5361
+        $label = spip_ucfirst($label);
5362
+    }
5363
+    return $label;
5364 5364
 }
5365 5365
 
5366 5366
 /**
@@ -5373,8 +5373,8 @@  discard block
 block discarded – undo
5373 5373
  * @exemple `<:info_maximum|label_ponctuer:>`
5374 5374
  */
5375 5375
 function label_ponctuer(string $text, bool $ucfirst = true): string {
5376
-	$label = label_nettoyer($text, $ucfirst);
5377
-	return _T('label_ponctuer', ['label' => $label]);
5376
+    $label = label_nettoyer($text, $ucfirst);
5377
+    return _T('label_ponctuer', ['label' => $label]);
5378 5378
 }
5379 5379
 
5380 5380
 
@@ -5387,19 +5387,19 @@  discard block
 block discarded – undo
5387 5387
  * @return array
5388 5388
  */
5389 5389
 function helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, $fonction) {
5390
-	if (!in_array($fonction, ['objet_lister_parents', 'objet_lister_enfants', 'objet_lister_parents_par_type', 'objet_lister_enfants_par_type'])) {
5391
-		return [];
5392
-	}
5390
+    if (!in_array($fonction, ['objet_lister_parents', 'objet_lister_enfants', 'objet_lister_parents_par_type', 'objet_lister_enfants_par_type'])) {
5391
+        return [];
5392
+    }
5393 5393
 
5394
-	// compatibilite signature inversee
5395
-	if (is_numeric($objet) && !is_numeric($id_objet)) {
5396
-		[$objet, $id_objet] = [$id_objet, $objet];
5397
-	}
5394
+    // compatibilite signature inversee
5395
+    if (is_numeric($objet) && !is_numeric($id_objet)) {
5396
+        [$objet, $id_objet] = [$id_objet, $objet];
5397
+    }
5398 5398
 
5399
-	if (!function_exists($fonction)) {
5400
-		include_spip('base/objets');
5401
-	}
5402
-	return $fonction($objet, $id_objet);
5399
+    if (!function_exists($fonction)) {
5400
+        include_spip('base/objets');
5401
+    }
5402
+    return $fonction($objet, $id_objet);
5403 5403
 }
5404 5404
 
5405 5405
 
@@ -5414,7 +5414,7 @@  discard block
 block discarded – undo
5414 5414
  * @return array
5415 5415
  */
5416 5416
 function filtre_objet_lister_parents_dist($objet, $id_objet) {
5417
-	return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents');
5417
+    return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents');
5418 5418
 }
5419 5419
 
5420 5420
 /**
@@ -5428,7 +5428,7 @@  discard block
 block discarded – undo
5428 5428
  * @return array
5429 5429
  */
5430 5430
 function filtre_objet_lister_parents_par_type_dist($objet, $id_objet) {
5431
-	return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents_par_type');
5431
+    return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents_par_type');
5432 5432
 }
5433 5433
 
5434 5434
 /**
@@ -5442,7 +5442,7 @@  discard block
 block discarded – undo
5442 5442
  * @return array
5443 5443
  */
5444 5444
 function filtre_objet_lister_enfants_dist($objet, $id_objet) {
5445
-	return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants');
5445
+    return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants');
5446 5446
 }
5447 5447
 
5448 5448
 /**
@@ -5456,5 +5456,5 @@  discard block
 block discarded – undo
5456 5456
  * @return array
5457 5457
  */
5458 5458
 function filtre_objet_lister_enfants_par_type_dist($objet, $id_objet) {
5459
-	return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants_par_type');
5459
+    return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants_par_type');
5460 5460
 }
Please login to merge, or discard this patch.
Spacing   +118 added lines, -119 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	}
101 101
 
102 102
 	include_fichiers_fonctions();
103
-	foreach (['filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc] as $f) {
103
+	foreach (['filtre_'.$fonc, 'filtre_'.$fonc.'_dist', $fonc] as $f) {
104 104
 		trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels
105 105
 		if (is_callable($f)) {
106 106
 			return $f;
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 	// affichage "GIT [master: abcdef]"
236 236
 	$commit = $desc['commit_short'] ?? $desc['commit'];
237 237
 	if ($desc['branch']) {
238
-		$commit = $desc['branch'] . ': ' . $commit;
238
+		$commit = $desc['branch'].': '.$commit;
239 239
 	}
240 240
 	return "{$desc['vcs']} [$commit]";
241 241
 }
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
 	}
257 257
 
258 258
 	// version installee par GIT
259
-	if (lire_fichier($dir . '/.git/HEAD', $c)) {
259
+	if (lire_fichier($dir.'/.git/HEAD', $c)) {
260 260
 		$currentHead = trim(substr((string) $c, 4));
261
-		if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
261
+		if (lire_fichier($dir.'/.git/'.$currentHead, $hash)) {
262 262
 			return [
263 263
 				'vcs' => 'GIT',
264 264
 				'branch' => basename($currentHead),
@@ -273,12 +273,12 @@  discard block
 block discarded – undo
273 273
 
274 274
 // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images
275 275
 // et laisser passer les fonctions personnelles baptisees image_...
276
-$GLOBALS['spip_matrice']['image_graver'] = true;//'inc/filtres_images_mini.php';
277
-$GLOBALS['spip_matrice']['image_select'] = true;//'inc/filtres_images_mini.php';
278
-$GLOBALS['spip_matrice']['image_reduire'] = true;//'inc/filtres_images_mini.php';
279
-$GLOBALS['spip_matrice']['image_reduire_par'] = true;//'inc/filtres_images_mini.php';
280
-$GLOBALS['spip_matrice']['image_passe_partout'] = true;//'inc/filtres_images_mini.php';
281
-$GLOBALS['spip_matrice']['image_recadre_avec_fallback'] = true;//'inc/filtres_images_mini.php';
276
+$GLOBALS['spip_matrice']['image_graver'] = true; //'inc/filtres_images_mini.php';
277
+$GLOBALS['spip_matrice']['image_select'] = true; //'inc/filtres_images_mini.php';
278
+$GLOBALS['spip_matrice']['image_reduire'] = true; //'inc/filtres_images_mini.php';
279
+$GLOBALS['spip_matrice']['image_reduire_par'] = true; //'inc/filtres_images_mini.php';
280
+$GLOBALS['spip_matrice']['image_passe_partout'] = true; //'inc/filtres_images_mini.php';
281
+$GLOBALS['spip_matrice']['image_recadre_avec_fallback'] = true; //'inc/filtres_images_mini.php';
282 282
 
283 283
 $GLOBALS['spip_matrice']['couleur_html_to_hex'] = 'inc/filtres_images_mini.php';
284 284
 $GLOBALS['spip_matrice']['couleur_hex_to_hsl'] = 'inc/filtres_images_mini.php';
@@ -437,8 +437,8 @@  discard block
 block discarded – undo
437 437
  */
438 438
 function filtre_debug(mixed $val, $key = null) {
439 439
 	$debug = (
440
-		is_null($key) ? '' : (var_export($key, true) . ' = ')
441
-		) . var_export($val, true);
440
+		is_null($key) ? '' : (var_export($key, true).' = ')
441
+		).var_export($val, true);
442 442
 
443 443
 	include_spip('inc/autoriser');
444 444
 	if (autoriser('webmestre')) {
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 		$is_file = false;
495 495
 	}
496 496
 	if ($is_file) {
497
-		$is_local_file = function ($path) {
497
+		$is_local_file = function($path) {
498 498
 			if (str_contains($path, '?')) {
499 499
 				$path = supprimer_timestamp($path);
500 500
 				// remove ?24px added by find_in_theme on .svg files
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
 					&& preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)
543 543
 				) {
544 544
 					$srcover = $match[1];
545
-					$srcover_filter = $filtre("<img src='" . $match[1] . "' />", ...$args);
545
+					$srcover_filter = $filtre("<img src='".$match[1]."' />", ...$args);
546 546
 					$srcover_filter = extraire_attribut($srcover_filter, 'src');
547 547
 					$reduit = str_replace($srcover, $srcover_filter, (string) $reduit);
548 548
 				}
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
 	// " -> &quot; et tout ce genre de choses
944 944
 	$u = $GLOBALS['meta']['pcre_u'];
945 945
 	$texte = str_replace('&nbsp;', ' ', $texte);
946
-	$texte = preg_replace('/\s{2,}/S' . $u, ' ', $texte);
946
+	$texte = preg_replace('/\s{2,}/S'.$u, ' ', $texte);
947 947
 	// ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
948 948
 	$texte = entites_html($texte, false, false);
949 949
 	// mais bien echapper les double quotes !
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
 		return '';
1006 1006
 	}
1007 1007
 	return preg_replace(
1008
-		',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1008
+		',^[[:space:]]*([0-9]+)([.)]|'.chr(194).'?'.chr(176).')[[:space:]]+,S',
1009 1009
 		'',
1010 1010
 		$texte
1011 1011
 	);
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
 		return '';
1036 1036
 	}
1037 1037
 	if (preg_match(
1038
-			',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1038
+			',^[[:space:]]*([0-9]+)([.)]|'.chr(194).'?'.chr(176).')[[:space:]]+,S',
1039 1039
 			$texte,
1040 1040
 			$regs
1041 1041
 		)
@@ -1127,7 +1127,7 @@  discard block
 block discarded – undo
1127 1127
 		return '';
1128 1128
 	}
1129 1129
 	$u = $GLOBALS['meta']['pcre_u'];
1130
-	$texte = preg_replace('/\s+/S' . $u, ' ', $texte);
1130
+	$texte = preg_replace('/\s+/S'.$u, ' ', $texte);
1131 1131
 	$texte = preg_replace('/<(p|br)( [^>]*)?>/iS', "\n\n", $texte);
1132 1132
 	$texte = preg_replace("/^\n+/", '', $texte);
1133 1133
 	$texte = preg_replace("/\n+$/", '', $texte);
@@ -1165,7 +1165,7 @@  discard block
 block discarded – undo
1165 1165
 		)
1166 1166
 	) {
1167 1167
 		foreach ($liens[0] as $a) {
1168
-			$rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1168
+			$rel = 'noopener noreferrer '.extraire_attribut($a, 'rel');
1169 1169
 			$ablank = inserer_attribut($a, 'rel', $rel);
1170 1170
 			$ablank = inserer_attribut($ablank, 'target', '_blank');
1171 1171
 			$texte = str_replace($a, $ablank, $texte);
@@ -1193,7 +1193,7 @@  discard block
 block discarded – undo
1193 1193
 		foreach ($regs[0] as $a) {
1194 1194
 			$rel = extraire_attribut($a, 'rel') ?? '';
1195 1195
 			if (!str_contains($rel, 'nofollow')) {
1196
-				$rel = 'nofollow' . ($rel ? " $rel" : '');
1196
+				$rel = 'nofollow'.($rel ? " $rel" : '');
1197 1197
 				$anofollow = inserer_attribut($a, 'rel', $rel);
1198 1198
 				$texte = str_replace($a, $anofollow, $texte);
1199 1199
 			}
@@ -1226,7 +1226,7 @@  discard block
 block discarded – undo
1226 1226
 	$texte = preg_replace('@</p>@iS', "\n", $texte);
1227 1227
 	$texte = preg_replace("@<p\b.*>@UiS", '<br />', $texte);
1228 1228
 
1229
-	return preg_replace('@^\s*<br />@S' . $u, '', $texte);
1229
+	return preg_replace('@^\s*<br />@S'.$u, '', $texte);
1230 1230
 }
1231 1231
 
1232 1232
 /**
@@ -1314,7 +1314,7 @@  discard block
 block discarded – undo
1314 1314
 
1315 1315
 		// Calcul de la taille et choix de l'unité
1316 1316
 		$affichage = _T(
1317
-			'spip:taille_' . $unites[$puissance] . $suffixe_item,
1317
+			'spip:taille_'.$unites[$puissance].$suffixe_item,
1318 1318
 			[
1319 1319
 				'taille' => round($octets / $kilo ** $puissance, $precisions[$puissance])
1320 1320
 			]
@@ -1348,7 +1348,7 @@  discard block
 block discarded – undo
1348 1348
 	}
1349 1349
 	$u = $GLOBALS['meta']['pcre_u'];
1350 1350
 	if ($textebrut) {
1351
-		$texte = preg_replace([",\n,", ',\s(?=\s),msS' . $u], [' ', ''], textebrut($texte));
1351
+		$texte = preg_replace([",\n,", ',\s(?=\s),msS'.$u], [' ', ''], textebrut($texte));
1352 1352
 	}
1353 1353
 	$texte = texte_backend($texte);
1354 1354
 	$texte = str_replace(["'", '"'], ['&#039;', '&#034;'], $texte);
@@ -1383,7 +1383,7 @@  discard block
 block discarded – undo
1383 1383
 	# un message pour abs_url
1384 1384
 	$GLOBALS['mode_abs_url'] = 'url';
1385 1385
 	$url = trim($url);
1386
-	$r = ',^(?:' . _PROTOCOLES_STD . '):?/?/?$,iS';
1386
+	$r = ',^(?:'._PROTOCOLES_STD.'):?/?/?$,iS';
1387 1387
 
1388 1388
 	return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1389 1389
 }
@@ -1589,7 +1589,7 @@  discard block
 block discarded – undo
1589 1589
 
1590 1590
 	$debut = '';
1591 1591
 	$suite = $texte;
1592
-	while ($t = strpos((string) ('-' . $suite), "\n", 1)) {
1592
+	while ($t = strpos((string) ('-'.$suite), "\n", 1)) {
1593 1593
 		$debut .= substr($suite, 0, $t - 1);
1594 1594
 		$suite = substr($suite, $t);
1595 1595
 		$car = substr($suite, 0, 1);
@@ -1607,7 +1607,7 @@  discard block
 block discarded – undo
1607 1607
 			$suite = substr($suite, strlen($regs[0]));
1608 1608
 		}
1609 1609
 	}
1610
-	$texte = $debut . $suite;
1610
+	$texte = $debut.$suite;
1611 1611
 
1612 1612
 	if ($collecteurModeles) {
1613 1613
 		$texte = $collecteurModeles->retablir($texte);
@@ -1615,7 +1615,7 @@  discard block
 block discarded – undo
1615 1615
 
1616 1616
 	$texte = CollecteurHtmlTag::retablir_depuisHtmlBase64($texte);
1617 1617
 
1618
-	return $texte . $fin;
1618
+	return $texte.$fin;
1619 1619
 }
1620 1620
 
1621 1621
 
@@ -1654,7 +1654,7 @@  discard block
 block discarded – undo
1654 1654
 		}
1655 1655
 		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1656 1656
 		if (is_bool($options)) {
1657
-			trigger_deprecation('spip', '5.0', 'Using boolean $options parameter in "%s()" function is deprecated. Use %s array parameter instead.', __FUNCTION__, '[\'echappe_span\' => ' . var_export($options, true) . ']');
1657
+			trigger_deprecation('spip', '5.0', 'Using boolean $options parameter in "%s()" function is deprecated. Use %s array parameter instead.', __FUNCTION__, '[\'echappe_span\' => '.var_export($options, true).']');
1658 1658
 			$options = ['echappe_span' => $options];
1659 1659
 		}
1660 1660
 		if (!isset($options['echappe_span'])) {
@@ -1711,7 +1711,7 @@  discard block
 block discarded – undo
1711 1711
 
1712 1712
 		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1713 1713
 		if (is_bool($options)) {
1714
-			trigger_deprecation('spip', '5.0', 'Using boolean $options parameter in "%s()" function is deprecated. Use %s array parameter instead.', __FUNCTION__, '[\'echappe_span\' => ' . var_export($options, true) . ']');
1714
+			trigger_deprecation('spip', '5.0', 'Using boolean $options parameter in "%s()" function is deprecated. Use %s array parameter instead.', __FUNCTION__, '[\'echappe_span\' => '.var_export($options, true).']');
1715 1715
 			$options = ['echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT];
1716 1716
 		}
1717 1717
 		if (!isset($options['echappe_span'])) {
@@ -1880,7 +1880,7 @@  discard block
 block discarded – undo
1880 1880
 	if (is_array($balise)) {
1881 1881
 		array_walk(
1882 1882
 			$balise,
1883
-			function (&$a, $key, $t) {
1883
+			function(&$a, $key, $t) {
1884 1884
 				$a = extraire_attribut($a, $t);
1885 1885
 			},
1886 1886
 			$attribut
@@ -1974,14 +1974,14 @@  discard block
 block discarded – undo
1974 1974
 
1975 1975
 	if ($old !== null) {
1976 1976
 		// Remplacer l'ancien attribut du meme nom
1977
-		$balise = $r[1] . $insert . $r[5];
1977
+		$balise = $r[1].$insert.$r[5];
1978 1978
 	} else {
1979 1979
 		// preferer une balise " />" (comme <img />)
1980 1980
 		if (preg_match(',/>,', $balise)) {
1981
-			$balise = preg_replace(',\s?/>,S', $insert . ' />', $balise, 1);
1981
+			$balise = preg_replace(',\s?/>,S', $insert.' />', $balise, 1);
1982 1982
 		} // sinon une balise <a ...> ... </a>
1983 1983
 		else {
1984
-			$balise = preg_replace(',\s?>,S', $insert . '>', $balise, 1);
1984
+			$balise = preg_replace(',\s?>,S', $insert.'>', $balise, 1);
1985 1985
 		}
1986 1986
 	}
1987 1987
 
@@ -2039,7 +2039,7 @@  discard block
 block discarded – undo
2039 2039
 			in_array($operation, ['ajouter', 'commuter'])
2040 2040
 			&& !$is_class_presente
2041 2041
 		) {
2042
-			$class_new = ltrim(rtrim($class_new ?? '') . ' ' . $c);
2042
+			$class_new = ltrim(rtrim($class_new ?? '').' '.$c);
2043 2043
 		} elseif (
2044 2044
 			in_array($operation, ['supprimer', 'commuter'])
2045 2045
 			&& $is_class_presente
@@ -2109,7 +2109,7 @@  discard block
 block discarded – undo
2109 2109
 // Quelques fonctions de calcul arithmetique
2110 2110
 //
2111 2111
 function floatstr($a) {
2112
-	return str_replace(',', '.', (string)(float) $a);
2112
+	return str_replace(',', '.', (string) (float) $a);
2113 2113
 }
2114 2114
 function strize($f, $a, $b) {
2115 2115
 	return floatstr($f(floatstr($a), floatstr($b)));
@@ -2250,13 +2250,13 @@  discard block
 block discarded – undo
2250 2250
 	if (!defined('_TAGS_NOM_AUTEUR')) {
2251 2251
 		define('_TAGS_NOM_AUTEUR', '');
2252 2252
 	}
2253
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2253
+	$tags_acceptes = array_unique(explode(',', 'multi,'._TAGS_NOM_AUTEUR));
2254 2254
 	foreach ($tags_acceptes as $tag) {
2255 2255
 		if (strlen($tag)) {
2256
-			$remp1[] = '<' . trim($tag) . '>';
2257
-			$remp1[] = '</' . trim($tag) . '>';
2258
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2259
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2256
+			$remp1[] = '<'.trim($tag).'>';
2257
+			$remp1[] = '</'.trim($tag).'>';
2258
+			$remp2[] = '\x60'.trim($tag).'\x61';
2259
+			$remp2[] = '\x60/'.trim($tag).'\x61';
2260 2260
 		}
2261 2261
 	}
2262 2262
 	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
@@ -2375,10 +2375,10 @@  discard block
 block discarded – undo
2375 2375
 	$fichier = basename($url);
2376 2376
 
2377 2377
 	return '<a rel="enclosure"'
2378
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2379
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2380
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2381
-	. '>' . $fichier . '</a>';
2378
+	. ($url ? ' href="'.spip_htmlspecialchars($url).'"' : '')
2379
+	. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2380
+	. ($length ? ' title="'.spip_htmlspecialchars($length).'"' : '')
2381
+	. '>'.$fichier.'</a>';
2382 2382
 }
2383 2383
 
2384 2384
 /**
@@ -2406,9 +2406,9 @@  discard block
 block discarded – undo
2406 2406
 			} # vieux data
2407 2407
 			$fichier = basename($url);
2408 2408
 			$enclosures[] = '<enclosure'
2409
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2410
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2411
-				. ($length ? ' length="' . $length . '"' : '')
2409
+				. ($url ? ' url="'.spip_htmlspecialchars($url).'"' : '')
2410
+				. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2411
+				. ($length ? ' length="'.$length.'"' : '')
2412 2412
 				. ' />';
2413 2413
 		}
2414 2414
 	}
@@ -2434,7 +2434,7 @@  discard block
 block discarded – undo
2434 2434
 		if (extraire_attribut($e, 'rel') == 'tag') {
2435 2435
 			$subjects .= '<dc:subject>'
2436 2436
 				. texte_backend(textebrut($e))
2437
-				. '</dc:subject>' . "\n";
2437
+				. '</dc:subject>'."\n";
2438 2438
 		}
2439 2439
 	}
2440 2440
 
@@ -2503,7 +2503,7 @@  discard block
 block discarded – undo
2503 2503
 	if (is_array($texte)) {
2504 2504
 		array_walk(
2505 2505
 			$texte,
2506
-			function (&$a, $key, $t) {
2506
+			function(&$a, $key, $t) {
2507 2507
 				$a = extraire_balises($a, $t);
2508 2508
 			},
2509 2509
 			$tag
@@ -2631,7 +2631,7 @@  discard block
 block discarded – undo
2631 2631
 		if ($fond != '404') {
2632 2632
 			$contexte = array_shift($p);
2633 2633
 			$contexte['page'] = $fond;
2634
-			$action = preg_replace('/([?]' . preg_quote((string) $fond, '/') . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2634
+			$action = preg_replace('/([?]'.preg_quote((string) $fond, '/').'[^&=]*[0-9]+)(&|$)/', '?&', $action);
2635 2635
 		}
2636 2636
 	}
2637 2637
 	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
@@ -2686,9 +2686,9 @@  discard block
 block discarded – undo
2686 2686
 			. '"'
2687 2687
 			. (is_null($val)
2688 2688
 				? ''
2689
-				: ' value="' . entites_html($val) . '"'
2689
+				: ' value="'.entites_html($val).'"'
2690 2690
 			)
2691
-			. ' type="hidden"' . "\n/>";
2691
+			. ' type="hidden"'."\n/>";
2692 2692
 	}
2693 2693
 
2694 2694
 	return implode('', $hidden);
@@ -2798,7 +2798,7 @@  discard block
 block discarded – undo
2798 2798
 
2799 2799
 	return preg_replace_callback(
2800 2800
 		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2801
-		fn($x) => "url('" . suivre_lien($path, $x[1]) . "')",
2801
+		fn($x) => "url('".suivre_lien($path, $x[1])."')",
2802 2802
 		$contenu
2803 2803
 	);
2804 2804
 }
@@ -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
@@ -4660,8 +4660,7 @@  discard block
 block discarded – undo
4660 4660
 	if (isset($ligne_sql['chapo'])) {
4661 4661
 		$chapo = $ligne_sql['chapo'];
4662 4662
 		$texte = strlen((string) $descriptif) ?
4663
-			'' :
4664
-			"$chapo \n\n $texte";
4663
+			'' : "$chapo \n\n $texte";
4665 4664
 	}
4666 4665
 
4667 4666
 	// Longueur en paramètre, sinon celle renseignée dans la description de l'objet, sinon valeur en dur
@@ -4725,7 +4724,7 @@  discard block
 block discarded – undo
4725 4724
 		return $texte;
4726 4725
 	}
4727 4726
 
4728
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", (string) $traitement);
4727
+	$traitement = str_replace('%s', "'".texte_script($texte)."'", (string) $traitement);
4729 4728
 
4730 4729
 	// signaler qu'on est dans l'espace prive pour les filtres qui se servent de ce flag
4731 4730
 	if (test_espace_prive()) {
@@ -4761,7 +4760,7 @@  discard block
 block discarded – undo
4761 4760
 	}
4762 4761
 	$url = generer_objet_url($id_objet, $objet, '', '', null, '', $connect);
4763 4762
 
4764
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . '</a>';
4763
+	return "<a href='$url' class='$objet'>".couper($titre, $longueur).'</a>';
4765 4764
 }
4766 4765
 
4767 4766
 /**
@@ -4779,9 +4778,9 @@  discard block
 block discarded – undo
4779 4778
 function wrap($texte, $wrap) {
4780 4779
 	$balises = extraire_balises($wrap);
4781 4780
 	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4782
-		$texte = $wrap . $texte;
4781
+		$texte = $wrap.$texte;
4783 4782
 		$regs = array_reverse($regs[1]);
4784
-		$wrap = '</' . implode('></', $regs) . '>';
4783
+		$wrap = '</'.implode('></', $regs).'>';
4785 4784
 		$texte .= $wrap;
4786 4785
 	}
4787 4786
 
@@ -4811,7 +4810,7 @@  discard block
 block discarded – undo
4811 4810
 
4812 4811
 	// caster $u en array si besoin
4813 4812
 	if (is_object($u)) {
4814
-		$u = (array)$u;
4813
+		$u = (array) $u;
4815 4814
 	}
4816 4815
 
4817 4816
 	if (is_array($u)) {
@@ -4833,7 +4832,7 @@  discard block
 block discarded – undo
4833 4832
 		// sinon on passe a la ligne et on indente
4834 4833
 		$i_str = str_pad('', $indent, ' ');
4835 4834
 		foreach ($u as $k => $v) {
4836
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4835
+			$out .= $join.$i_str."$k: ".filtre_print_dist($v, $join, $indent + 2);
4837 4836
 		}
4838 4837
 
4839 4838
 		return $out;
@@ -4887,7 +4886,7 @@  discard block
 block discarded – undo
4887 4886
  * @return string
4888 4887
  */
4889 4888
 function objet_icone($objet, $taille = 24, $class = '') {
4890
-	$icone = objet_info($objet, 'icone_objet') . '-' . $taille . '.png';
4889
+	$icone = objet_info($objet, 'icone_objet').'-'.$taille.'.png';
4891 4890
 	$icone = chemin_image($icone);
4892 4891
 	$balise_img = charger_filtre('balise_img');
4893 4892
 
@@ -4913,7 +4912,7 @@  discard block
 block discarded – undo
4913 4912
  */
4914 4913
 function objet_T($objet, $chaine, $args = [], $options = []) {
4915 4914
 	$chaine = explode(':', $chaine);
4916
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, ['force' => false]))) {
4915
+	if ($t = _T($objet.':'.end($chaine), $args, array_merge($options, ['force' => false]))) {
4917 4916
 		return $t;
4918 4917
 	}
4919 4918
 	$chaine = implode(':', $chaine);
@@ -4979,7 +4978,7 @@  discard block
 block discarded – undo
4979 4978
 	$cache = recuperer_fond($fond, $contexte, $options, $connect);
4980 4979
 
4981 4980
 	// calculer le nom de la css
4982
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4981
+	$dir_var = sous_repertoire(_DIR_VAR, 'cache-'.$extension);
4983 4982
 	$nom_safe = preg_replace(',\W,', '_', str_replace('.', '_', $fond));
4984 4983
 	$contexte_implicite = calculer_contexte_implicite();
4985 4984
 
@@ -4987,14 +4986,14 @@  discard block
 block discarded – undo
4987 4986
 	// mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
4988 4987
 	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4989 4988
 	if (isset($options['hash_on_content']) && $options['hash_on_content']) {
4990
-		$hash = md5((string) ($contexte_implicite['host'] . '::' . $cache));
4989
+		$hash = md5((string) ($contexte_implicite['host'].'::'.$cache));
4991 4990
 	}
4992 4991
 	else {
4993 4992
 		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4994 4993
 		ksort($contexte);
4995
-		$hash = md5($fond . json_encode($contexte_implicite, JSON_THROW_ON_ERROR) . json_encode($contexte, JSON_THROW_ON_ERROR) . $connect);
4994
+		$hash = md5($fond.json_encode($contexte_implicite, JSON_THROW_ON_ERROR).json_encode($contexte, JSON_THROW_ON_ERROR).$connect);
4996 4995
 	}
4997
-	$filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
4996
+	$filename = $dir_var.$extension."dyn-$nom_safe-".substr($hash, 0, 8).".$extension";
4998 4997
 
4999 4998
 	// mettre a jour le fichier si il n'existe pas
5000 4999
 	// ou trop ancien
@@ -5002,8 +5001,8 @@  discard block
 block discarded – undo
5002 5001
 	// et recopie sur le fichier cible uniquement si il change
5003 5002
 	if (
5004 5003
 		!file_exists($filename)
5005
-		|| !file_exists($filename . '.last')
5006
-		|| isset($cache['lastmodified']) && $cache['lastmodified'] && filemtime($filename . '.last') < $cache['lastmodified']
5004
+		|| !file_exists($filename.'.last')
5005
+		|| isset($cache['lastmodified']) && $cache['lastmodified'] && filemtime($filename.'.last') < $cache['lastmodified']
5007 5006
 		|| defined('_VAR_MODE') && _VAR_MODE == 'recalcul'
5008 5007
 	) {
5009 5008
 		$contenu = $cache['texte'];
@@ -5027,10 +5026,10 @@  discard block
 block discarded – undo
5027 5026
 			}
5028 5027
 			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
5029 5028
 			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
5030
-			$comment .= "}\n   md5:" . md5((string) $contenu) . " */\n";
5029
+			$comment .= "}\n   md5:".md5((string) $contenu)." */\n";
5031 5030
 		}
5032 5031
 		// et ecrire le fichier si il change
5033
-		ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
5032
+		ecrire_fichier_calcule_si_modifie($filename, $comment.$contenu, false, true);
5034 5033
 	}
5035 5034
 
5036 5035
 	return timestamp($filename);
@@ -5257,7 +5256,7 @@  discard block
 block discarded – undo
5257 5256
 	if ($e > 0 && strlen($mid) > 8) {
5258 5257
 		$mid = '***...***';
5259 5258
 	}
5260
-	return substr($passe, 0, $e) . $mid . ($e > 0 ? substr($passe, -$e) : '');
5259
+	return substr($passe, 0, $e).$mid.($e > 0 ? substr($passe, -$e) : '');
5261 5260
 }
5262 5261
 
5263 5262
 
@@ -5319,7 +5318,7 @@  discard block
 block discarded – undo
5319 5318
 		case 'id':
5320 5319
 		case 'anchor':
5321 5320
 			if (preg_match(',^\d,', $texte)) {
5322
-				$texte = substr($type, 0, 1) . $texte;
5321
+				$texte = substr($type, 0, 1).$texte;
5323 5322
 			}
5324 5323
 	}
5325 5324
 
@@ -5329,9 +5328,9 @@  discard block
 block discarded – undo
5329 5328
 
5330 5329
 	if (strlen($texte) < $longueur_mini && $longueur_mini < $longueur_maxi) {
5331 5330
 		if (preg_match(',^\d,', $texte)) {
5332
-			$texte = ($type ? substr($type, 0, 1) : 's') . $texte;
5331
+			$texte = ($type ? substr($type, 0, 1) : 's').$texte;
5333 5332
 		}
5334
-		$texte .= $separateur . md5($original);
5333
+		$texte .= $separateur.md5($original);
5335 5334
 		$texte = substr($texte, 0, $longueur_mini);
5336 5335
 	}
5337 5336
 
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/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.