Completed
Push — master ( 190d73...9bf890 )
by cam
01:11
created
ecrire/inc/filtres.php 3 patches
Indentation   +2468 added lines, -2468 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Filtres
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 include_spip('inc/charsets');
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
  * @return string Fonction PHP correspondante du filtre
43 43
  */
44 44
 function charger_filtre($fonc, $default = 'filtre_identite_dist') {
45
-	include_fichiers_fonctions(); // inclure les fichiers fonctions
46
-	return chercher_filtre($fonc, $default);
45
+    include_fichiers_fonctions(); // inclure les fichiers fonctions
46
+    return chercher_filtre($fonc, $default);
47 47
 }
48 48
 
49 49
 /**
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
  * @return string Texte
54 54
  **/
55 55
 function filtre_identite_dist($texte) {
56
- return $texte;
56
+    return $texte;
57 57
 }
58 58
 
59 59
 /**
@@ -77,38 +77,38 @@  discard block
 block discarded – undo
77 77
  *     Fonction PHP correspondante du filtre demandé
78 78
  */
79 79
 function chercher_filtre($fonc, $default = null) {
80
-	if (!$fonc) {
81
-		return $default;
82
-	}
83
-	// Cas des types mime, sans confondre avec les appels de fonction de classe
84
-	// Foo::Bar
85
-	// qui peuvent etre avec un namespace : space\Foo::Bar
86
-	if (preg_match(',^[\w]+/,', $fonc)) {
87
-		$nom = preg_replace(',\W,', '_', $fonc);
88
-		$f = chercher_filtre($nom);
89
-		// cas du sous-type MIME sans filtre associe, passer au type:
90
-		// si filtre_text_plain pas defini, passe a filtre_text
91
-		if (!$f and $nom !== $fonc) {
92
-			$f = chercher_filtre(preg_replace(',\W.*$,', '', $fonc));
93
-		}
94
-
95
-		return $f;
96
-	}
97
-
98
-	include_fichiers_fonctions();
99
-	foreach (['filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc] as $f) {
100
-		trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels
101
-		// fonction ou name\space\fonction
102
-		if (is_callable($f)) {
103
-			return $f;
104
-		}
105
-		// méthode statique d'une classe Classe::methode ou name\space\Classe::methode
106
-		elseif (false === strpos($f, '::') and is_callable([$f])) {
107
-			return $f;
108
-		}
109
-	}
110
-
111
-	return $default;
80
+    if (!$fonc) {
81
+        return $default;
82
+    }
83
+    // Cas des types mime, sans confondre avec les appels de fonction de classe
84
+    // Foo::Bar
85
+    // qui peuvent etre avec un namespace : space\Foo::Bar
86
+    if (preg_match(',^[\w]+/,', $fonc)) {
87
+        $nom = preg_replace(',\W,', '_', $fonc);
88
+        $f = chercher_filtre($nom);
89
+        // cas du sous-type MIME sans filtre associe, passer au type:
90
+        // si filtre_text_plain pas defini, passe a filtre_text
91
+        if (!$f and $nom !== $fonc) {
92
+            $f = chercher_filtre(preg_replace(',\W.*$,', '', $fonc));
93
+        }
94
+
95
+        return $f;
96
+    }
97
+
98
+    include_fichiers_fonctions();
99
+    foreach (['filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc] as $f) {
100
+        trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels
101
+        // fonction ou name\space\fonction
102
+        if (is_callable($f)) {
103
+            return $f;
104
+        }
105
+        // méthode statique d'une classe Classe::methode ou name\space\Classe::methode
106
+        elseif (false === strpos($f, '::') and is_callable([$f])) {
107
+            return $f;
108
+        }
109
+    }
110
+
111
+    return $default;
112 112
 }
113 113
 
114 114
 /**
@@ -152,8 +152,8 @@  discard block
 block discarded – undo
152 152
  *     Chaîne vide sinon.
153 153
  **/
154 154
 function appliquer_filtre($arg, $filtre) {
155
-	$args = func_get_args();
156
-	return appliquer_filtre_sinon($arg, $filtre, $args, '');
155
+    $args = func_get_args();
156
+    return appliquer_filtre_sinon($arg, $filtre, $args, '');
157 157
 }
158 158
 
159 159
 /**
@@ -178,8 +178,8 @@  discard block
 block discarded – undo
178 178
  *     Texte d'origine sinon
179 179
  **/
180 180
 function appliquer_si_filtre($arg, $filtre) {
181
-	$args = func_get_args();
182
-	return appliquer_filtre_sinon($arg, $filtre, $args, $arg);
181
+    $args = func_get_args();
182
+    return appliquer_filtre_sinon($arg, $filtre, $args, $arg);
183 183
 }
184 184
 
185 185
 /**
@@ -195,12 +195,12 @@  discard block
 block discarded – undo
195 195
  *     Version de SPIP
196 196
  **/
197 197
 function spip_version() {
198
-	$version = $GLOBALS['spip_version_affichee'];
199
-	if ($vcs_version = version_vcs_courante(_DIR_RACINE)) {
200
-		$version .= " $vcs_version";
201
-	}
198
+    $version = $GLOBALS['spip_version_affichee'];
199
+    if ($vcs_version = version_vcs_courante(_DIR_RACINE)) {
200
+        $version .= " $vcs_version";
201
+    }
202 202
 
203
-	return $version;
203
+    return $version;
204 204
 }
205 205
 
206 206
 /**
@@ -213,19 +213,19 @@  discard block
 block discarded – undo
213 213
  *    - string|null si $raw = false
214 214
  */
215 215
 function version_vcs_courante($dir, $raw = false) {
216
-	$desc = decrire_version_git($dir);
217
-	if ($desc === null) {
218
-		$desc = decrire_version_svn($dir);
219
-	}
220
-	if ($desc === null or $raw) {
221
-		return $desc;
222
-	}
223
-	// affichage "GIT [master: abcdef]"
224
-	$commit = $desc['commit_short'] ?? $desc['commit'];
225
-	if ($desc['branch']) {
226
-		$commit = $desc['branch'] . ': ' . $commit;
227
-	}
228
-	return "{$desc['vcs']} [$commit]";
216
+    $desc = decrire_version_git($dir);
217
+    if ($desc === null) {
218
+        $desc = decrire_version_svn($dir);
219
+    }
220
+    if ($desc === null or $raw) {
221
+        return $desc;
222
+    }
223
+    // affichage "GIT [master: abcdef]"
224
+    $commit = $desc['commit_short'] ?? $desc['commit'];
225
+    if ($desc['branch']) {
226
+        $commit = $desc['branch'] . ': ' . $commit;
227
+    }
228
+    return "{$desc['vcs']} [$commit]";
229 229
 }
230 230
 
231 231
 /**
@@ -237,24 +237,24 @@  discard block
 block discarded – undo
237 237
  *      array ['branch' => xx, 'commit' => yy] sinon.
238 238
  **/
239 239
 function decrire_version_git($dir) {
240
-	if (!$dir) {
241
-		$dir = '.';
242
-	}
240
+    if (!$dir) {
241
+        $dir = '.';
242
+    }
243 243
 
244
-	// version installee par GIT
245
-	if (lire_fichier($dir . '/.git/HEAD', $c)) {
246
-		$currentHead = trim(substr($c, 4));
247
-		if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
248
-			return [
249
-				'vcs' => 'GIT',
250
-				'branch' => basename($currentHead),
251
-				'commit' => trim($hash),
252
-				'commit_short' => substr(trim($hash), 0, 8),
253
-			];
254
-		}
255
-	}
244
+    // version installee par GIT
245
+    if (lire_fichier($dir . '/.git/HEAD', $c)) {
246
+        $currentHead = trim(substr($c, 4));
247
+        if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
248
+            return [
249
+                'vcs' => 'GIT',
250
+                'branch' => basename($currentHead),
251
+                'commit' => trim($hash),
252
+                'commit_short' => substr(trim($hash), 0, 8),
253
+            ];
254
+        }
255
+    }
256 256
 
257
-	return null;
257
+    return null;
258 258
 }
259 259
 
260 260
 
@@ -267,25 +267,25 @@  discard block
 block discarded – undo
267 267
  *      array ['commit' => yy, 'date' => xx, 'author' => xx] sinon.
268 268
  **/
269 269
 function decrire_version_svn($dir) {
270
-	if (!$dir) {
271
-		$dir = '.';
272
-	}
273
-	// version installee par SVN
274
-	if (file_exists($dir . '/.svn/wc.db') && class_exists(\SQLite3::class)) {
275
-		$db = new SQLite3($dir . '/.svn/wc.db');
276
-		$result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1');
277
-		if ($result) {
278
-			$row = $result->fetchArray();
279
-			if ($row['changed_revision'] != '') {
280
-				return [
281
-					'vcs' => 'SVN',
282
-					'branch' => '',
283
-					'commit' => $row['changed_revision'],
284
-				];
285
-			}
286
-		}
287
-	}
288
-	return null;
270
+    if (!$dir) {
271
+        $dir = '.';
272
+    }
273
+    // version installee par SVN
274
+    if (file_exists($dir . '/.svn/wc.db') && class_exists(\SQLite3::class)) {
275
+        $db = new SQLite3($dir . '/.svn/wc.db');
276
+        $result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1');
277
+        if ($result) {
278
+            $row = $result->fetchArray();
279
+            if ($row['changed_revision'] != '') {
280
+                return [
281
+                    'vcs' => 'SVN',
282
+                    'branch' => '',
283
+                    'commit' => $row['changed_revision'],
284
+                ];
285
+            }
286
+        }
287
+    }
288
+    return null;
289 289
 }
290 290
 
291 291
 // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images
@@ -332,18 +332,18 @@  discard block
 block discarded – undo
332 332
  *     Code HTML retourné par le filtre
333 333
  **/
334 334
 function filtrer($filtre) {
335
-	$tous = func_get_args();
336
-	if (trouver_filtre_matrice($filtre) and substr($filtre, 0, 6) == 'image_') {
337
-		return image_filtrer($tous);
338
-	} elseif ($f = chercher_filtre($filtre)) {
339
-		array_shift($tous);
340
-		return call_user_func_array($f, $tous);
341
-	} else {
342
-		// le filtre n'existe pas, on provoque une erreur
343
-		$msg = ['zbug_erreur_filtre', ['filtre' => texte_script($filtre)]];
344
-		erreur_squelette($msg);
345
-		return '';
346
-	}
335
+    $tous = func_get_args();
336
+    if (trouver_filtre_matrice($filtre) and substr($filtre, 0, 6) == 'image_') {
337
+        return image_filtrer($tous);
338
+    } elseif ($f = chercher_filtre($filtre)) {
339
+        array_shift($tous);
340
+        return call_user_func_array($f, $tous);
341
+    } else {
342
+        // le filtre n'existe pas, on provoque une erreur
343
+        $msg = ['zbug_erreur_filtre', ['filtre' => texte_script($filtre)]];
344
+        erreur_squelette($msg);
345
+        return '';
346
+    }
347 347
 }
348 348
 
349 349
 /**
@@ -360,11 +360,11 @@  discard block
 block discarded – undo
360 360
  * @return bool true si on trouve le filtre dans la matrice, false sinon.
361 361
  */
362 362
 function trouver_filtre_matrice($filtre) {
363
-	if (isset($GLOBALS['spip_matrice'][$filtre]) and is_string($f = $GLOBALS['spip_matrice'][$filtre])) {
364
-		find_in_path($f, '', true);
365
-		$GLOBALS['spip_matrice'][$filtre] = true;
366
-	}
367
-	return !empty($GLOBALS['spip_matrice'][$filtre]);
363
+    if (isset($GLOBALS['spip_matrice'][$filtre]) and is_string($f = $GLOBALS['spip_matrice'][$filtre])) {
364
+        find_in_path($f, '', true);
365
+        $GLOBALS['spip_matrice'][$filtre] = true;
366
+    }
367
+    return !empty($GLOBALS['spip_matrice'][$filtre]);
368 368
 }
369 369
 
370 370
 
@@ -392,8 +392,8 @@  discard block
 block discarded – undo
392 392
  * @return mixed
393 393
  */
394 394
 function filtre_set(&$Pile, $val, $key, $continue = null) {
395
-	$Pile['vars'][$key] = $val;
396
-	return $continue ? $val : '';
395
+    $Pile['vars'][$key] = $val;
396
+    return $continue ? $val : '';
397 397
 }
398 398
 
399 399
 /**
@@ -419,8 +419,8 @@  discard block
 block discarded – undo
419 419
  * @return string|mixed Retourne `$val` si `$continue` présent, sinon ''.
420 420
  */
421 421
 function filtre_setenv(&$Pile, $val, $key, $continue = null) {
422
-	$Pile[0][$key] = $val;
423
-	return $continue ? $val : '';
422
+    $Pile[0][$key] = $val;
423
+    return $continue ? $val : '';
424 424
 }
425 425
 
426 426
 /**
@@ -429,8 +429,8 @@  discard block
 block discarded – undo
429 429
  * @return string
430 430
  */
431 431
 function filtre_sanitize_env(&$Pile, $keys) {
432
-	$Pile[0] = spip_sanitize_from_request($Pile[0], $keys);
433
-	return '';
432
+    $Pile[0] = spip_sanitize_from_request($Pile[0], $keys);
433
+    return '';
434 434
 }
435 435
 
436 436
 
@@ -453,18 +453,18 @@  discard block
 block discarded – undo
453 453
  * @return mixed Retourne la valeur (sans la modifier).
454 454
  */
455 455
 function filtre_debug($val, $key = null) {
456
-	$debug = (
457
-		is_null($key) ? '' : (var_export($key, true) . ' = ')
458
-		) . var_export($val, true);
456
+    $debug = (
457
+        is_null($key) ? '' : (var_export($key, true) . ' = ')
458
+        ) . var_export($val, true);
459 459
 
460
-	include_spip('inc/autoriser');
461
-	if (autoriser('webmestre')) {
462
-		echo "<div class='spip_debug'>\n", $debug, "</div>\n";
463
-	}
460
+    include_spip('inc/autoriser');
461
+    if (autoriser('webmestre')) {
462
+        echo "<div class='spip_debug'>\n", $debug, "</div>\n";
463
+    }
464 464
 
465
-	spip_log($debug, 'debug');
465
+    spip_log($debug, 'debug');
466 466
 
467
-	return $val;
467
+    return $val;
468 468
 }
469 469
 
470 470
 
@@ -492,89 +492,89 @@  discard block
 block discarded – undo
492 492
  *     Texte qui a reçu les filtres
493 493
  **/
494 494
 function image_filtrer($args) {
495
-	$filtre = array_shift($args); # enlever $filtre
496
-	$texte = array_shift($args);
497
-	if ($texte === null || !strlen($texte)) {
498
-		return;
499
-	}
500
-	find_in_path('filtres_images_mini.php', 'inc/', true);
501
-	statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver
502
-	// Cas du nom de fichier local
503
-	$is_file = trim($texte);
504
-	if (
505
-		strpos(substr($is_file, strlen(_DIR_RACINE)), '..') !== false
506
-		  or strpbrk($is_file, "<>\n\r\t") !== false
507
-		  or strpos($is_file, '/') === 0
508
-	) {
509
-		$is_file = false;
510
-	}
511
-	if ($is_file) {
512
-		$is_local_file = function ($path) {
513
-			if (strpos($path, '?') !== false) {
514
-				$path = supprimer_timestamp($path);
515
-				// remove ?24px added by find_in_theme on .svg files
516
-				$path = preg_replace(',\?[[:digit:]]+(px)$,', '', $path);
517
-			}
518
-			return file_exists($path);
519
-		};
520
-		if ($is_local_file($is_file) or tester_url_absolue($is_file)) {
521
-			array_unshift($args, "<img src='$is_file' />");
522
-			$res = call_user_func_array($filtre, $args);
523
-			statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
524
-			return $res;
525
-		}
526
-	}
527
-
528
-	// Cas general : trier toutes les images, avec eventuellement leur <span>
529
-	if (
530
-		preg_match_all(
531
-			',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS',
532
-			$texte,
533
-			$tags,
534
-			PREG_SET_ORDER
535
-		)
536
-	) {
537
-		foreach ($tags as $tag) {
538
-			$class = extraire_attribut($tag[3], 'class');
539
-			if (
540
-				!$class or
541
-				(strpos($class, 'filtre_inactif') === false
542
-					// compat historique a virer en 3.2
543
-					and strpos($class, 'no_image_filtrer') === false)
544
-			) {
545
-				array_unshift($args, $tag[3]);
546
-				if ($reduit = call_user_func_array($filtre, $args)) {
547
-					// En cas de span spip_documents, modifier le style=...width:
548
-					if ($tag[1]) {
549
-						$w = extraire_attribut($reduit, 'width');
550
-						if (!$w and preg_match(',width:\s*(\d+)px,S', extraire_attribut($reduit, 'style'), $regs)) {
551
-							$w = $regs[1];
552
-						}
553
-						if ($w and ($style = extraire_attribut($tag[1], 'style'))) {
554
-							$style = preg_replace(',width:\s*\d+px,S', "width:${w}px", $style);
555
-							$replace = inserer_attribut($tag[1], 'style', $style);
556
-							$texte = str_replace($tag[1], $replace, $texte);
557
-						}
558
-					}
559
-					// traiter aussi un eventuel mouseover
560
-					if ($mouseover = extraire_attribut($reduit, 'onmouseover')) {
561
-						if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) {
562
-							$srcover = $match[1];
563
-							array_shift($args);
564
-							array_unshift($args, "<img src='" . $match[1] . "' />");
565
-							$srcover_filter = call_user_func_array($filtre, $args);
566
-							$srcover_filter = extraire_attribut($srcover_filter, 'src');
567
-							$reduit = str_replace($srcover, $srcover_filter, $reduit);
568
-						}
569
-					}
570
-					$texte = str_replace($tag[3], $reduit, $texte);
571
-				}
572
-				array_shift($args);
573
-			}
574
-		}
575
-	}
576
-	statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
577
-	return $texte;
495
+    $filtre = array_shift($args); # enlever $filtre
496
+    $texte = array_shift($args);
497
+    if ($texte === null || !strlen($texte)) {
498
+        return;
499
+    }
500
+    find_in_path('filtres_images_mini.php', 'inc/', true);
501
+    statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver
502
+    // Cas du nom de fichier local
503
+    $is_file = trim($texte);
504
+    if (
505
+        strpos(substr($is_file, strlen(_DIR_RACINE)), '..') !== false
506
+          or strpbrk($is_file, "<>\n\r\t") !== false
507
+          or strpos($is_file, '/') === 0
508
+    ) {
509
+        $is_file = false;
510
+    }
511
+    if ($is_file) {
512
+        $is_local_file = function ($path) {
513
+            if (strpos($path, '?') !== false) {
514
+                $path = supprimer_timestamp($path);
515
+                // remove ?24px added by find_in_theme on .svg files
516
+                $path = preg_replace(',\?[[:digit:]]+(px)$,', '', $path);
517
+            }
518
+            return file_exists($path);
519
+        };
520
+        if ($is_local_file($is_file) or tester_url_absolue($is_file)) {
521
+            array_unshift($args, "<img src='$is_file' />");
522
+            $res = call_user_func_array($filtre, $args);
523
+            statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
524
+            return $res;
525
+        }
526
+    }
527
+
528
+    // Cas general : trier toutes les images, avec eventuellement leur <span>
529
+    if (
530
+        preg_match_all(
531
+            ',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS',
532
+            $texte,
533
+            $tags,
534
+            PREG_SET_ORDER
535
+        )
536
+    ) {
537
+        foreach ($tags as $tag) {
538
+            $class = extraire_attribut($tag[3], 'class');
539
+            if (
540
+                !$class or
541
+                (strpos($class, 'filtre_inactif') === false
542
+                    // compat historique a virer en 3.2
543
+                    and strpos($class, 'no_image_filtrer') === false)
544
+            ) {
545
+                array_unshift($args, $tag[3]);
546
+                if ($reduit = call_user_func_array($filtre, $args)) {
547
+                    // En cas de span spip_documents, modifier le style=...width:
548
+                    if ($tag[1]) {
549
+                        $w = extraire_attribut($reduit, 'width');
550
+                        if (!$w and preg_match(',width:\s*(\d+)px,S', extraire_attribut($reduit, 'style'), $regs)) {
551
+                            $w = $regs[1];
552
+                        }
553
+                        if ($w and ($style = extraire_attribut($tag[1], 'style'))) {
554
+                            $style = preg_replace(',width:\s*\d+px,S', "width:${w}px", $style);
555
+                            $replace = inserer_attribut($tag[1], 'style', $style);
556
+                            $texte = str_replace($tag[1], $replace, $texte);
557
+                        }
558
+                    }
559
+                    // traiter aussi un eventuel mouseover
560
+                    if ($mouseover = extraire_attribut($reduit, 'onmouseover')) {
561
+                        if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) {
562
+                            $srcover = $match[1];
563
+                            array_shift($args);
564
+                            array_unshift($args, "<img src='" . $match[1] . "' />");
565
+                            $srcover_filter = call_user_func_array($filtre, $args);
566
+                            $srcover_filter = extraire_attribut($srcover_filter, 'src');
567
+                            $reduit = str_replace($srcover, $srcover_filter, $reduit);
568
+                        }
569
+                    }
570
+                    $texte = str_replace($tag[3], $reduit, $texte);
571
+                }
572
+                array_shift($args);
573
+            }
574
+        }
575
+    }
576
+    statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
577
+    return $texte;
578 578
 }
579 579
 
580 580
 /**
@@ -591,91 +591,91 @@  discard block
 block discarded – undo
591 591
  **/
592 592
 function infos_image($img, $force_refresh = false) {
593 593
 
594
-	static $largeur_img = [], $hauteur_img = [], $poids_img = [];
595
-	$srcWidth = 0;
596
-	$srcHeight = 0;
597
-	$srcSize = null;
598
-
599
-	$src = extraire_attribut($img, 'src');
600
-
601
-	if (!$src) {
602
-		$src = $img;
603
-	} else {
604
-		$srcWidth = extraire_attribut($img, 'width');
605
-		$srcHeight = extraire_attribut($img, 'height');
606
-	}
607
-
608
-	// ne jamais operer directement sur une image distante pour des raisons de perfo
609
-	// la copie locale a toutes les chances d'etre la ou de resservir
610
-	if (tester_url_absolue($src)) {
611
-		include_spip('inc/distant');
612
-		$fichier = copie_locale($src);
613
-		$src = $fichier ? _DIR_RACINE . $fichier : $src;
614
-	}
615
-	if (($p = strpos($src, '?')) !== false) {
616
-		$src = substr($src, 0, $p);
617
-	}
618
-
619
-	$imagesize = false;
620
-	if (isset($largeur_img[$src]) and !$force_refresh) {
621
-		$srcWidth = $largeur_img[$src];
622
-	}
623
-	if (isset($hauteur_img[$src]) and !$force_refresh) {
624
-		$srcHeight = $hauteur_img[$src];
625
-	}
626
-	if (isset($poids_img[$src]) and !$force_refresh) {
627
-		$srcSize = $poids_img[$src];
628
-	}
629
-	if (!$srcWidth or !$srcHeight or is_null($srcSize)) {
630
-		if (
631
-			file_exists($src)
632
-			and $imagesize = spip_getimagesize($src)
633
-		) {
634
-			if (!$srcWidth) {
635
-				$largeur_img[$src] = $srcWidth = $imagesize[0];
636
-			}
637
-			if (!$srcHeight) {
638
-				$hauteur_img[$src] = $srcHeight = $imagesize[1];
639
-			}
640
-			if (!$srcSize){
641
-				$poids_img[$src] = filesize($src);
642
-			}
643
-		}
644
-		elseif (strpos($src, '<svg') !== false) {
645
-			include_spip('inc/svg');
646
-			if ($attrs = svg_lire_attributs($src)) {
647
-				[$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs);
648
-				if (!$srcWidth) {
649
-					$largeur_img[$src] = $srcWidth = $width;
650
-				}
651
-				if (!$srcHeight) {
652
-					$hauteur_img[$src] = $srcHeight = $height;
653
-				}
654
-				if (!$srcSize){
655
-					$poids_img[$src] = $srcSize = strlen($src);
656
-				}
657
-			}
658
-		}
659
-		// $src peut etre une reference a une image temporaire dont a n'a que le log .src
660
-		// on s'y refere, l'image sera reconstruite en temps utile si necessaire
661
-		elseif (
662
-			@file_exists($f = "$src.src")
663
-			and lire_fichier($f, $valeurs)
664
-			and $valeurs = unserialize($valeurs)
665
-		) {
666
-			if (!$srcWidth) {
667
-				$largeur_img[$src] = $srcWidth = $valeurs['largeur_dest'];
668
-			}
669
-			if (!$srcHeight) {
670
-				$hauteur_img[$src] = $srcHeight = $valeurs['hauteur_dest'];
671
-			}
672
-			if (!$srcSize){
673
-				$poids_img[$src] = $srcSize = 0;
674
-			}
675
-		}
676
-	}
677
-
678
-	return ['hauteur' => $srcHeight, 'largeur' => $srcWidth, 'poids' => $srcSize];
594
+    static $largeur_img = [], $hauteur_img = [], $poids_img = [];
595
+    $srcWidth = 0;
596
+    $srcHeight = 0;
597
+    $srcSize = null;
598
+
599
+    $src = extraire_attribut($img, 'src');
600
+
601
+    if (!$src) {
602
+        $src = $img;
603
+    } else {
604
+        $srcWidth = extraire_attribut($img, 'width');
605
+        $srcHeight = extraire_attribut($img, 'height');
606
+    }
607
+
608
+    // ne jamais operer directement sur une image distante pour des raisons de perfo
609
+    // la copie locale a toutes les chances d'etre la ou de resservir
610
+    if (tester_url_absolue($src)) {
611
+        include_spip('inc/distant');
612
+        $fichier = copie_locale($src);
613
+        $src = $fichier ? _DIR_RACINE . $fichier : $src;
614
+    }
615
+    if (($p = strpos($src, '?')) !== false) {
616
+        $src = substr($src, 0, $p);
617
+    }
618
+
619
+    $imagesize = false;
620
+    if (isset($largeur_img[$src]) and !$force_refresh) {
621
+        $srcWidth = $largeur_img[$src];
622
+    }
623
+    if (isset($hauteur_img[$src]) and !$force_refresh) {
624
+        $srcHeight = $hauteur_img[$src];
625
+    }
626
+    if (isset($poids_img[$src]) and !$force_refresh) {
627
+        $srcSize = $poids_img[$src];
628
+    }
629
+    if (!$srcWidth or !$srcHeight or is_null($srcSize)) {
630
+        if (
631
+            file_exists($src)
632
+            and $imagesize = spip_getimagesize($src)
633
+        ) {
634
+            if (!$srcWidth) {
635
+                $largeur_img[$src] = $srcWidth = $imagesize[0];
636
+            }
637
+            if (!$srcHeight) {
638
+                $hauteur_img[$src] = $srcHeight = $imagesize[1];
639
+            }
640
+            if (!$srcSize){
641
+                $poids_img[$src] = filesize($src);
642
+            }
643
+        }
644
+        elseif (strpos($src, '<svg') !== false) {
645
+            include_spip('inc/svg');
646
+            if ($attrs = svg_lire_attributs($src)) {
647
+                [$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs);
648
+                if (!$srcWidth) {
649
+                    $largeur_img[$src] = $srcWidth = $width;
650
+                }
651
+                if (!$srcHeight) {
652
+                    $hauteur_img[$src] = $srcHeight = $height;
653
+                }
654
+                if (!$srcSize){
655
+                    $poids_img[$src] = $srcSize = strlen($src);
656
+                }
657
+            }
658
+        }
659
+        // $src peut etre une reference a une image temporaire dont a n'a que le log .src
660
+        // on s'y refere, l'image sera reconstruite en temps utile si necessaire
661
+        elseif (
662
+            @file_exists($f = "$src.src")
663
+            and lire_fichier($f, $valeurs)
664
+            and $valeurs = unserialize($valeurs)
665
+        ) {
666
+            if (!$srcWidth) {
667
+                $largeur_img[$src] = $srcWidth = $valeurs['largeur_dest'];
668
+            }
669
+            if (!$srcHeight) {
670
+                $hauteur_img[$src] = $srcHeight = $valeurs['hauteur_dest'];
671
+            }
672
+            if (!$srcSize){
673
+                $poids_img[$src] = $srcSize = 0;
674
+            }
675
+        }
676
+    }
677
+
678
+    return ['hauteur' => $srcHeight, 'largeur' => $srcWidth, 'poids' => $srcSize];
679 679
 }
680 680
 
681 681
 /**
@@ -691,13 +691,13 @@  discard block
 block discarded – undo
691 691
  *     poids
692 692
  **/
693 693
 function poids_image($img, $force_refresh = false) {
694
-	$infos = infos_image($img, $force_refresh);
695
-	return $infos['poids'];
694
+    $infos = infos_image($img, $force_refresh);
695
+    return $infos['poids'];
696 696
 }
697 697
 
698 698
 function taille_image($img, $force_refresh = false){
699
-	$infos = infos_image($img, $force_refresh);
700
-	return [$infos['hauteur'], $infos['largeur']];
699
+    $infos = infos_image($img, $force_refresh);
700
+    return [$infos['hauteur'], $infos['largeur']];
701 701
 }
702 702
 
703 703
 /**
@@ -714,12 +714,12 @@  discard block
 block discarded – undo
714 714
  *     Largeur en pixels, NULL ou 0 si aucune image.
715 715
  **/
716 716
 function largeur($img) {
717
-	if (!$img) {
718
-		return;
719
-	}
720
-	[$h, $l] = taille_image($img);
717
+    if (!$img) {
718
+        return;
719
+    }
720
+    [$h, $l] = taille_image($img);
721 721
 
722
-	return $l;
722
+    return $l;
723 723
 }
724 724
 
725 725
 /**
@@ -736,12 +736,12 @@  discard block
 block discarded – undo
736 736
  *     Hauteur en pixels, NULL ou 0 si aucune image.
737 737
  **/
738 738
 function hauteur($img) {
739
-	if (!$img) {
740
-		return;
741
-	}
742
-	[$h, $l] = taille_image($img);
739
+    if (!$img) {
740
+        return;
741
+    }
742
+    [$h, $l] = taille_image($img);
743 743
 
744
-	return $h;
744
+    return $h;
745 745
 }
746 746
 
747 747
 
@@ -761,11 +761,11 @@  discard block
 block discarded – undo
761 761
  * @return string
762 762
  **/
763 763
 function corriger_entites_html($texte) {
764
-	if (strpos($texte, '&amp;') === false) {
765
-		return $texte;
766
-	}
764
+    if (strpos($texte, '&amp;') === false) {
765
+        return $texte;
766
+    }
767 767
 
768
-	return preg_replace(',&amp;(#[0-9][0-9][0-9]+;|amp;),iS', '&\1', $texte);
768
+    return preg_replace(',&amp;(#[0-9][0-9][0-9]+;|amp;),iS', '&\1', $texte);
769 769
 }
770 770
 
771 771
 /**
@@ -780,11 +780,11 @@  discard block
 block discarded – undo
780 780
  * @return string
781 781
  **/
782 782
 function corriger_toutes_entites_html($texte) {
783
-	if (strpos($texte, '&amp;') === false) {
784
-		return $texte;
785
-	}
783
+    if (strpos($texte, '&amp;') === false) {
784
+        return $texte;
785
+    }
786 786
 
787
-	return preg_replace(',&amp;(#?[a-z0-9]+;),iS', '&\1', $texte);
787
+    return preg_replace(',&amp;(#?[a-z0-9]+;),iS', '&\1', $texte);
788 788
 }
789 789
 
790 790
 /**
@@ -794,7 +794,7 @@  discard block
 block discarded – undo
794 794
  * @return string
795 795
  **/
796 796
 function proteger_amp($texte) {
797
-	return str_replace('&', '&amp;', $texte);
797
+    return str_replace('&', '&amp;', $texte);
798 798
 }
799 799
 
800 800
 
@@ -825,21 +825,21 @@  discard block
 block discarded – undo
825 825
  * @return mixed|string
826 826
  */
827 827
 function entites_html($texte, $tout = false, $quote = true) {
828
-	if (
829
-		!is_string($texte) or !$texte
830
-		or strpbrk($texte, "&\"'<>") == false
831
-	) {
832
-		return $texte;
833
-	}
834
-	include_spip('inc/texte');
835
-	$flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES);
836
-	$flags |= ENT_HTML401;
837
-	$texte = spip_htmlspecialchars(echappe_retour(echappe_html($texte, '', true), '', 'proteger_amp'), $flags);
838
-	if ($tout) {
839
-		return corriger_toutes_entites_html($texte);
840
-	} else {
841
-		return corriger_entites_html($texte);
842
-	}
828
+    if (
829
+        !is_string($texte) or !$texte
830
+        or strpbrk($texte, "&\"'<>") == false
831
+    ) {
832
+        return $texte;
833
+    }
834
+    include_spip('inc/texte');
835
+    $flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES);
836
+    $flags |= ENT_HTML401;
837
+    $texte = spip_htmlspecialchars(echappe_retour(echappe_html($texte, '', true), '', 'proteger_amp'), $flags);
838
+    if ($tout) {
839
+        return corriger_toutes_entites_html($texte);
840
+    } else {
841
+        return corriger_entites_html($texte);
842
+    }
843 843
 }
844 844
 
845 845
 /**
@@ -858,37 +858,37 @@  discard block
 block discarded – undo
858 858
  *     Texte converti
859 859
  **/
860 860
 function filtrer_entites($texte) {
861
-	if (strpos($texte, '&') === false) {
862
-		return $texte;
863
-	}
864
-	// filtrer
865
-	$texte = html2unicode($texte);
866
-	// remettre le tout dans le charset cible
867
-	$texte = unicode2charset($texte);
868
-	// cas particulier des " et ' qu'il faut filtrer aussi
869
-	// (on le faisait deja avec un &quot;)
870
-	if (strpos($texte, '&#') !== false) {
871
-		$texte = str_replace(['&#039;', '&#39;', '&#034;', '&#34;'], ["'", "'", '"', '"'], $texte);
872
-	}
861
+    if (strpos($texte, '&') === false) {
862
+        return $texte;
863
+    }
864
+    // filtrer
865
+    $texte = html2unicode($texte);
866
+    // remettre le tout dans le charset cible
867
+    $texte = unicode2charset($texte);
868
+    // cas particulier des " et ' qu'il faut filtrer aussi
869
+    // (on le faisait deja avec un &quot;)
870
+    if (strpos($texte, '&#') !== false) {
871
+        $texte = str_replace(['&#039;', '&#39;', '&#034;', '&#34;'], ["'", "'", '"', '"'], $texte);
872
+    }
873 873
 
874
-	return $texte;
874
+    return $texte;
875 875
 }
876 876
 
877 877
 
878 878
 if (!function_exists('filtre_filtrer_entites_dist')) {
879
-	/**
880
-	 * Version sécurisée de filtrer_entites
881
-	 *
882
-	 * @uses interdire_scripts()
883
-	 * @uses filtrer_entites()
884
-	 *
885
-	 * @param string $t
886
-	 * @return string
887
-	 */
888
-	function filtre_filtrer_entites_dist($t) {
889
-		include_spip('inc/texte');
890
-		return interdire_scripts(filtrer_entites($t));
891
-	}
879
+    /**
880
+     * Version sécurisée de filtrer_entites
881
+     *
882
+     * @uses interdire_scripts()
883
+     * @uses filtrer_entites()
884
+     *
885
+     * @param string $t
886
+     * @return string
887
+     */
888
+    function filtre_filtrer_entites_dist($t) {
889
+        include_spip('inc/texte');
890
+        return interdire_scripts(filtrer_entites($t));
891
+    }
892 892
 }
893 893
 
894 894
 
@@ -903,18 +903,18 @@  discard block
 block discarded – undo
903 903
  * @return string|array
904 904
  **/
905 905
 function supprimer_caracteres_illegaux($texte) {
906
-	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";
907
-	static $to = null;
906
+    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";
907
+    static $to = null;
908 908
 
909
-	if (is_array($texte)) {
910
-		return array_map('supprimer_caracteres_illegaux', $texte);
911
-	}
909
+    if (is_array($texte)) {
910
+        return array_map('supprimer_caracteres_illegaux', $texte);
911
+    }
912 912
 
913
-	if (!$to) {
914
-		$to = str_repeat('-', strlen($from));
915
-	}
913
+    if (!$to) {
914
+        $to = str_repeat('-', strlen($from));
915
+    }
916 916
 
917
-	return strtr($texte, $from, $to);
917
+    return strtr($texte, $from, $to);
918 918
 }
919 919
 
920 920
 /**
@@ -926,10 +926,10 @@  discard block
 block discarded – undo
926 926
  * @return string|array
927 927
  **/
928 928
 function corriger_caracteres($texte) {
929
-	$texte = corriger_caracteres_windows($texte);
930
-	$texte = supprimer_caracteres_illegaux($texte);
929
+    $texte = corriger_caracteres_windows($texte);
930
+    $texte = supprimer_caracteres_illegaux($texte);
931 931
 
932
-	return $texte;
932
+    return $texte;
933 933
 }
934 934
 
935 935
 /**
@@ -946,44 +946,44 @@  discard block
 block discarded – undo
946 946
  *     Texte encodé pour XML
947 947
  */
948 948
 function texte_backend(string $texte): string {
949
-	if ($texte === '') {
950
-		return '';
951
-	}
949
+    if ($texte === '') {
950
+        return '';
951
+    }
952 952
 
953
-	static $apostrophe = ['&#8217;', "'"]; # n'allouer qu'une fois
953
+    static $apostrophe = ['&#8217;', "'"]; # n'allouer qu'une fois
954 954
 
955
-	// si on a des liens ou des images, les passer en absolu
956
-	$texte = liens_absolus($texte);
955
+    // si on a des liens ou des images, les passer en absolu
956
+    $texte = liens_absolus($texte);
957 957
 
958
-	// echapper les tags &gt; &lt;
959
-	$texte = preg_replace(',&(gt|lt);,S', '&amp;\1;', $texte);
958
+    // echapper les tags &gt; &lt;
959
+    $texte = preg_replace(',&(gt|lt);,S', '&amp;\1;', $texte);
960 960
 
961
-	// importer les &eacute;
962
-	$texte = filtrer_entites($texte);
961
+    // importer les &eacute;
962
+    $texte = filtrer_entites($texte);
963 963
 
964
-	// " -> &quot; et tout ce genre de choses
965
-	$u = $GLOBALS['meta']['pcre_u'];
966
-	$texte = str_replace('&nbsp;', ' ', $texte);
967
-	$texte = preg_replace('/\s{2,}/S' . $u, ' ', $texte);
968
-	// ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
969
-	$texte = entites_html($texte, false, false);
970
-	// mais bien echapper les double quotes !
971
-	$texte = str_replace('"', '&#034;', $texte);
964
+    // " -> &quot; et tout ce genre de choses
965
+    $u = $GLOBALS['meta']['pcre_u'];
966
+    $texte = str_replace('&nbsp;', ' ', $texte);
967
+    $texte = preg_replace('/\s{2,}/S' . $u, ' ', $texte);
968
+    // ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
969
+    $texte = entites_html($texte, false, false);
970
+    // mais bien echapper les double quotes !
971
+    $texte = str_replace('"', '&#034;', $texte);
972 972
 
973
-	// verifier le charset
974
-	$texte = charset2unicode($texte);
973
+    // verifier le charset
974
+    $texte = charset2unicode($texte);
975 975
 
976
-	// Caracteres problematiques en iso-latin 1
977
-	if (isset($GLOBALS['meta']['charset']) and $GLOBALS['meta']['charset'] == 'iso-8859-1') {
978
-		$texte = str_replace(chr(156), '&#156;', $texte);
979
-		$texte = str_replace(chr(140), '&#140;', $texte);
980
-		$texte = str_replace(chr(159), '&#159;', $texte);
981
-	}
976
+    // Caracteres problematiques en iso-latin 1
977
+    if (isset($GLOBALS['meta']['charset']) and $GLOBALS['meta']['charset'] == 'iso-8859-1') {
978
+        $texte = str_replace(chr(156), '&#156;', $texte);
979
+        $texte = str_replace(chr(140), '&#140;', $texte);
980
+        $texte = str_replace(chr(159), '&#159;', $texte);
981
+    }
982 982
 
983
-	// l'apostrophe curly pose probleme a certains lecteure de RSS
984
-	// et le caractere apostrophe alourdit les squelettes avec PHP
985
-	// ==> on les remplace par l'entite HTML
986
-	return str_replace($apostrophe, "'", $texte);
983
+    // l'apostrophe curly pose probleme a certains lecteure de RSS
984
+    // et le caractere apostrophe alourdit les squelettes avec PHP
985
+    // ==> on les remplace par l'entite HTML
986
+    return str_replace($apostrophe, "'", $texte);
987 987
 }
988 988
 
989 989
 /**
@@ -1000,7 +1000,7 @@  discard block
 block discarded – undo
1000 1000
  *     Texte encodé et quote pour XML
1001 1001
  */
1002 1002
 function texte_backendq(string $texte): string {
1003
-	return addslashes(texte_backend($texte));
1003
+    return addslashes(texte_backend($texte));
1004 1004
 }
1005 1005
 
1006 1006
 
@@ -1023,11 +1023,11 @@  discard block
 block discarded – undo
1023 1023
  *     Numéro de titre, sinon chaîne vide
1024 1024
  **/
1025 1025
 function supprimer_numero($texte) {
1026
-	return preg_replace(
1027
-		',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1028
-		'',
1029
-		$texte
1030
-	);
1026
+    return preg_replace(
1027
+        ',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1028
+        '',
1029
+        $texte
1030
+    );
1031 1031
 }
1032 1032
 
1033 1033
 /**
@@ -1050,17 +1050,17 @@  discard block
 block discarded – undo
1050 1050
  *     Numéro de titre, sinon chaîne vide
1051 1051
  **/
1052 1052
 function recuperer_numero($texte) {
1053
-	if (
1054
-		preg_match(
1055
-			',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1056
-			$texte,
1057
-			$regs
1058
-		)
1059
-	) {
1060
-		return strval($regs[1]);
1061
-	} else {
1062
-		return '';
1063
-	}
1053
+    if (
1054
+        preg_match(
1055
+            ',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1056
+            $texte,
1057
+            $regs
1058
+        )
1059
+    ) {
1060
+        return strval($regs[1]);
1061
+    } else {
1062
+        return '';
1063
+    }
1064 1064
 }
1065 1065
 
1066 1066
 /**
@@ -1087,16 +1087,16 @@  discard block
 block discarded – undo
1087 1087
  *     Texte converti
1088 1088
  **/
1089 1089
 function supprimer_tags(?string $texte, $rempl = ''): string {
1090
-	if ($texte === null || !strlen($texte)) {
1091
-		return '';
1092
-	}
1093
-	$texte = preg_replace(',<(!--|\w|/|!\[endif|!\[if)[^>]*>,US', $rempl, $texte);
1094
-	// ne pas oublier un < final non ferme car coupe
1095
-	$texte = preg_replace(',<(!--|\w|/).*$,US', $rempl, $texte);
1096
-	// mais qui peut aussi etre un simple signe plus petit que
1097
-	$texte = str_replace('<', '&lt;', $texte);
1090
+    if ($texte === null || !strlen($texte)) {
1091
+        return '';
1092
+    }
1093
+    $texte = preg_replace(',<(!--|\w|/|!\[endif|!\[if)[^>]*>,US', $rempl, $texte);
1094
+    // ne pas oublier un < final non ferme car coupe
1095
+    $texte = preg_replace(',<(!--|\w|/).*$,US', $rempl, $texte);
1096
+    // mais qui peut aussi etre un simple signe plus petit que
1097
+    $texte = str_replace('<', '&lt;', $texte);
1098 1098
 
1099
-	return $texte;
1099
+    return $texte;
1100 1100
 }
1101 1101
 
1102 1102
 /**
@@ -1119,9 +1119,9 @@  discard block
 block discarded – undo
1119 1119
  *     Texte converti
1120 1120
  **/
1121 1121
 function echapper_tags($texte, $rempl = '') {
1122
-	$texte = preg_replace('/<([^>]*)>/', "&lt;\\1&gt;", $texte);
1122
+    $texte = preg_replace('/<([^>]*)>/', "&lt;\\1&gt;", $texte);
1123 1123
 
1124
-	return $texte;
1124
+    return $texte;
1125 1125
 }
1126 1126
 
1127 1127
 /**
@@ -1142,18 +1142,18 @@  discard block
 block discarded – undo
1142 1142
  *     Texte converti
1143 1143
  **/
1144 1144
 function textebrut($texte) {
1145
-	$u = $GLOBALS['meta']['pcre_u'];
1146
-	$texte = preg_replace('/\s+/S' . $u, ' ', $texte);
1147
-	$texte = preg_replace('/<(p|br)( [^>]*)?' . '>/iS', "\n\n", $texte);
1148
-	$texte = preg_replace("/^\n+/", '', $texte);
1149
-	$texte = preg_replace("/\n+$/", '', $texte);
1150
-	$texte = preg_replace("/\n +/", "\n", $texte);
1151
-	$texte = supprimer_tags($texte);
1152
-	$texte = preg_replace('/(&nbsp;| )+/S', ' ', $texte);
1153
-	// nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail...
1154
-	$texte = str_replace('&#8217;', "'", $texte);
1145
+    $u = $GLOBALS['meta']['pcre_u'];
1146
+    $texte = preg_replace('/\s+/S' . $u, ' ', $texte);
1147
+    $texte = preg_replace('/<(p|br)( [^>]*)?' . '>/iS', "\n\n", $texte);
1148
+    $texte = preg_replace("/^\n+/", '', $texte);
1149
+    $texte = preg_replace("/\n+$/", '', $texte);
1150
+    $texte = preg_replace("/\n +/", "\n", $texte);
1151
+    $texte = supprimer_tags($texte);
1152
+    $texte = preg_replace('/(&nbsp;| )+/S', ' ', $texte);
1153
+    // nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail...
1154
+    $texte = str_replace('&#8217;', "'", $texte);
1155 1155
 
1156
-	return $texte;
1156
+    return $texte;
1157 1157
 }
1158 1158
 
1159 1159
 
@@ -1169,23 +1169,23 @@  discard block
 block discarded – undo
1169 1169
  *     Texte avec liens ouvrants
1170 1170
  **/
1171 1171
 function liens_ouvrants($texte) {
1172
-	if (
1173
-		preg_match_all(
1174
-			",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1175
-			$texte,
1176
-			$liens,
1177
-			PREG_PATTERN_ORDER
1178
-		)
1179
-	) {
1180
-		foreach ($liens[0] as $a) {
1181
-			$rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1182
-			$ablank = inserer_attribut($a, 'rel', $rel);
1183
-			$ablank = inserer_attribut($ablank, 'target', '_blank');
1184
-			$texte = str_replace($a, $ablank, $texte);
1185
-		}
1186
-	}
1187
-
1188
-	return $texte;
1172
+    if (
1173
+        preg_match_all(
1174
+            ",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1175
+            $texte,
1176
+            $liens,
1177
+            PREG_PATTERN_ORDER
1178
+        )
1179
+    ) {
1180
+        foreach ($liens[0] as $a) {
1181
+            $rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1182
+            $ablank = inserer_attribut($a, 'rel', $rel);
1183
+            $ablank = inserer_attribut($ablank, 'target', '_blank');
1184
+            $texte = str_replace($a, $ablank, $texte);
1185
+        }
1186
+    }
1187
+
1188
+    return $texte;
1189 1189
 }
1190 1190
 
1191 1191
 /**
@@ -1195,22 +1195,22 @@  discard block
 block discarded – undo
1195 1195
  * @return string
1196 1196
  */
1197 1197
 function liens_nofollow($texte) {
1198
-	if (stripos($texte, '<a') === false) {
1199
-		return $texte;
1200
-	}
1198
+    if (stripos($texte, '<a') === false) {
1199
+        return $texte;
1200
+    }
1201 1201
 
1202
-	if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) {
1203
-		foreach ($regs[0] as $a) {
1204
-			$rel = extraire_attribut($a, 'rel');
1205
-			if (strpos($rel, 'nofollow') === false) {
1206
-				$rel = 'nofollow' . ($rel ? " $rel" : '');
1207
-				$anofollow = inserer_attribut($a, 'rel', $rel);
1208
-				$texte = str_replace($a, $anofollow, $texte);
1209
-			}
1210
-		}
1211
-	}
1202
+    if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) {
1203
+        foreach ($regs[0] as $a) {
1204
+            $rel = extraire_attribut($a, 'rel');
1205
+            if (strpos($rel, 'nofollow') === false) {
1206
+                $rel = 'nofollow' . ($rel ? " $rel" : '');
1207
+                $anofollow = inserer_attribut($a, 'rel', $rel);
1208
+                $texte = str_replace($a, $anofollow, $texte);
1209
+            }
1210
+        }
1211
+    }
1212 1212
 
1213
-	return $texte;
1213
+    return $texte;
1214 1214
 }
1215 1215
 
1216 1216
 /**
@@ -1229,12 +1229,12 @@  discard block
 block discarded – undo
1229 1229
  *     Texte sans paraghaphes
1230 1230
  **/
1231 1231
 function PtoBR($texte) {
1232
-	$u = $GLOBALS['meta']['pcre_u'];
1233
-	$texte = preg_replace('@</p>@iS', "\n", $texte);
1234
-	$texte = preg_replace("@<p\b.*>@UiS", '<br />', $texte);
1235
-	$texte = preg_replace('@^\s*<br />@S' . $u, '', $texte);
1232
+    $u = $GLOBALS['meta']['pcre_u'];
1233
+    $texte = preg_replace('@</p>@iS', "\n", $texte);
1234
+    $texte = preg_replace("@<p\b.*>@UiS", '<br />', $texte);
1235
+    $texte = preg_replace('@^\s*<br />@S' . $u, '', $texte);
1236 1236
 
1237
-	return $texte;
1237
+    return $texte;
1238 1238
 }
1239 1239
 
1240 1240
 
@@ -1259,14 +1259,14 @@  discard block
 block discarded – undo
1259 1259
  * @return string Texte encadré du style CSS
1260 1260
  */
1261 1261
 function lignes_longues($texte) {
1262
-	if (!strlen(trim($texte))) {
1263
-		return $texte;
1264
-	}
1265
-	include_spip('inc/texte');
1266
-	$tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1267
-		'div' : 'span';
1262
+    if (!strlen(trim($texte))) {
1263
+        return $texte;
1264
+    }
1265
+    include_spip('inc/texte');
1266
+    $tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1267
+        'div' : 'span';
1268 1268
 
1269
-	return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
1269
+    return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
1270 1270
 }
1271 1271
 
1272 1272
 /**
@@ -1285,30 +1285,30 @@  discard block
 block discarded – undo
1285 1285
  * @return string Texte en majuscule
1286 1286
  */
1287 1287
 function majuscules($texte) {
1288
-	if (!strlen($texte)) {
1289
-		return '';
1290
-	}
1288
+    if (!strlen($texte)) {
1289
+        return '';
1290
+    }
1291 1291
 
1292
-	// Cas du turc
1293
-	if ($GLOBALS['spip_lang'] == 'tr') {
1294
-		# remplacer hors des tags et des entites
1295
-		if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) {
1296
-			foreach ($regs as $n => $match) {
1297
-				$texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte);
1298
-			}
1299
-		}
1292
+    // Cas du turc
1293
+    if ($GLOBALS['spip_lang'] == 'tr') {
1294
+        # remplacer hors des tags et des entites
1295
+        if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) {
1296
+            foreach ($regs as $n => $match) {
1297
+                $texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte);
1298
+            }
1299
+        }
1300 1300
 
1301
-		$texte = str_replace('i', '&#304;', $texte);
1301
+        $texte = str_replace('i', '&#304;', $texte);
1302 1302
 
1303
-		if ($regs) {
1304
-			foreach ($regs as $n => $match) {
1305
-				$texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte);
1306
-			}
1307
-		}
1308
-	}
1303
+        if ($regs) {
1304
+            foreach ($regs as $n => $match) {
1305
+                $texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte);
1306
+            }
1307
+        }
1308
+    }
1309 1309
 
1310
-	// Cas general
1311
-	return "<span style='text-transform: uppercase;'>$texte</span>";
1310
+    // Cas general
1311
+    return "<span style='text-transform: uppercase;'>$texte</span>";
1312 1312
 }
1313 1313
 
1314 1314
 /**
@@ -1326,29 +1326,29 @@  discard block
 block discarded – undo
1326 1326
  * @return string
1327 1327
  **/
1328 1328
 function taille_en_octets($taille) {
1329
-	if (!defined('_KILOBYTE')) {
1330
-		/**
1331
-		 * Définit le nombre d'octets dans un Kilobyte
1332
-		 *
1333
-		 * @var int
1334
-		 **/
1335
-		define('_KILOBYTE', 1024);
1336
-	}
1329
+    if (!defined('_KILOBYTE')) {
1330
+        /**
1331
+         * Définit le nombre d'octets dans un Kilobyte
1332
+         *
1333
+         * @var int
1334
+         **/
1335
+        define('_KILOBYTE', 1024);
1336
+    }
1337 1337
 
1338
-	if ($taille < 1) {
1339
-		return '';
1340
-	}
1341
-	if ($taille < _KILOBYTE) {
1342
-		$taille = _T('taille_octets', ['taille' => $taille]);
1343
-	} elseif ($taille < _KILOBYTE * _KILOBYTE) {
1344
-		$taille = _T('taille_ko', ['taille' => round($taille / _KILOBYTE, 1)]);
1345
-	} elseif ($taille < _KILOBYTE * _KILOBYTE * _KILOBYTE) {
1346
-		$taille = _T('taille_mo', ['taille' => round($taille / _KILOBYTE / _KILOBYTE, 1)]);
1347
-	} else {
1348
-		$taille = _T('taille_go', ['taille' => round($taille / _KILOBYTE / _KILOBYTE / _KILOBYTE, 2)]);
1349
-	}
1338
+    if ($taille < 1) {
1339
+        return '';
1340
+    }
1341
+    if ($taille < _KILOBYTE) {
1342
+        $taille = _T('taille_octets', ['taille' => $taille]);
1343
+    } elseif ($taille < _KILOBYTE * _KILOBYTE) {
1344
+        $taille = _T('taille_ko', ['taille' => round($taille / _KILOBYTE, 1)]);
1345
+    } elseif ($taille < _KILOBYTE * _KILOBYTE * _KILOBYTE) {
1346
+        $taille = _T('taille_mo', ['taille' => round($taille / _KILOBYTE / _KILOBYTE, 1)]);
1347
+    } else {
1348
+        $taille = _T('taille_go', ['taille' => round($taille / _KILOBYTE / _KILOBYTE / _KILOBYTE, 2)]);
1349
+    }
1350 1350
 
1351
-	return $taille;
1351
+    return $taille;
1352 1352
 }
1353 1353
 
1354 1354
 
@@ -1370,21 +1370,21 @@  discard block
 block discarded – undo
1370 1370
  *     Texte prêt pour être utilisé en attribut HTML
1371 1371
  **/
1372 1372
 function attribut_html(?string $texte, $textebrut = true): string {
1373
-	if ($texte === null) {
1374
-		return '';
1375
-	}
1376
-	$u = $GLOBALS['meta']['pcre_u'];
1377
-	if ($textebrut) {
1378
-		$texte = preg_replace([",\n,", ',\s(?=\s),msS' . $u], [' ', ''], textebrut($texte));
1379
-	}
1380
-	$texte = texte_backend($texte);
1381
-	$texte = str_replace(["'", '"'], ['&#039;', '&#034;'], $texte);
1373
+    if ($texte === null) {
1374
+        return '';
1375
+    }
1376
+    $u = $GLOBALS['meta']['pcre_u'];
1377
+    if ($textebrut) {
1378
+        $texte = preg_replace([",\n,", ',\s(?=\s),msS' . $u], [' ', ''], textebrut($texte));
1379
+    }
1380
+    $texte = texte_backend($texte);
1381
+    $texte = str_replace(["'", '"'], ['&#039;', '&#034;'], $texte);
1382 1382
 
1383
-	return preg_replace(
1384
-		['/&(amp;|#38;)/', '/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/'],
1385
-		['&', '&#38;'],
1386
-		$texte
1387
-	);
1383
+    return preg_replace(
1384
+        ['/&(amp;|#38;)/', '/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/'],
1385
+        ['&', '&#38;'],
1386
+        $texte
1387
+    );
1388 1388
 }
1389 1389
 
1390 1390
 
@@ -1404,15 +1404,15 @@  discard block
 block discarded – undo
1404 1404
  *     URL ou chaîne vide
1405 1405
  **/
1406 1406
 function vider_url(?string $url, $entites = true): string {
1407
-	if ($url === null) {
1408
-		return '';
1409
-	}
1410
-	# un message pour abs_url
1411
-	$GLOBALS['mode_abs_url'] = 'url';
1412
-	$url = trim($url);
1413
-	$r = ',^(?:' . _PROTOCOLES_STD . '):?/?/?$,iS';
1407
+    if ($url === null) {
1408
+        return '';
1409
+    }
1410
+    # un message pour abs_url
1411
+    $GLOBALS['mode_abs_url'] = 'url';
1412
+    $url = trim($url);
1413
+    $r = ',^(?:' . _PROTOCOLES_STD . '):?/?/?$,iS';
1414 1414
 
1415
-	return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1415
+    return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1416 1416
 }
1417 1417
 
1418 1418
 
@@ -1427,10 +1427,10 @@  discard block
 block discarded – undo
1427 1427
  * @return string Adresse email maquillée
1428 1428
  **/
1429 1429
 function antispam($texte) {
1430
-	include_spip('inc/acces');
1431
-	$masque = creer_pass_aleatoire(3);
1430
+    include_spip('inc/acces');
1431
+    $masque = creer_pass_aleatoire(3);
1432 1432
 
1433
-	return preg_replace('/@/', " $masque ", $texte);
1433
+    return preg_replace('/@/', " $masque ", $texte);
1434 1434
 }
1435 1435
 
1436 1436
 /**
@@ -1462,12 +1462,12 @@  discard block
 block discarded – undo
1462 1462
  *     True si on a le droit d'accès, false sinon.
1463 1463
  **/
1464 1464
 function securiser_acces($id_auteur, $cle, $dir, $op = '', $args = '') {
1465
-	include_spip('inc/acces');
1466
-	if ($op) {
1467
-		$dir .= " $op $args";
1468
-	}
1465
+    include_spip('inc/acces');
1466
+    if ($op) {
1467
+        $dir .= " $op $args";
1468
+    }
1469 1469
 
1470
-	return verifier_low_sec($id_auteur, $cle, $dir);
1470
+    return verifier_low_sec($id_auteur, $cle, $dir);
1471 1471
 }
1472 1472
 
1473 1473
 /**
@@ -1492,13 +1492,13 @@  discard block
 block discarded – undo
1492 1492
  *     Retourne $texte, sinon $sinon.
1493 1493
  **/
1494 1494
 function sinon($texte, $sinon = '') {
1495
-	if ($texte) {
1496
-		return $texte;
1497
-	} elseif (is_scalar($texte) and strlen($texte)) {
1498
-		return $texte;
1499
-	} else {
1500
-		return $sinon;
1501
-	}
1495
+    if ($texte) {
1496
+        return $texte;
1497
+    } elseif (is_scalar($texte) and strlen($texte)) {
1498
+        return $texte;
1499
+    } else {
1500
+        return $sinon;
1501
+    }
1502 1502
 }
1503 1503
 
1504 1504
 /**
@@ -1522,7 +1522,7 @@  discard block
 block discarded – undo
1522 1522
  * @return mixed
1523 1523
  **/
1524 1524
 function choixsivide($a, $vide, $pasvide) {
1525
-	return $a ? $pasvide : $vide;
1525
+    return $a ? $pasvide : $vide;
1526 1526
 }
1527 1527
 
1528 1528
 /**
@@ -1546,7 +1546,7 @@  discard block
 block discarded – undo
1546 1546
  * @return mixed
1547 1547
  **/
1548 1548
 function choixsiegal($a1, $a2, $v, $f) {
1549
-	return ($a1 == $a2) ? $v : $f;
1549
+    return ($a1 == $a2) ? $v : $f;
1550 1550
 }
1551 1551
 
1552 1552
 //
@@ -1565,13 +1565,13 @@  discard block
 block discarded – undo
1565 1565
  * @return string
1566 1566
  **/
1567 1567
 function filtrer_ical($texte) {
1568
-	#include_spip('inc/charsets');
1569
-	$texte = html2unicode($texte);
1570
-	$texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset']), 'utf-8');
1571
-	$texte = preg_replace("/\n/", ' ', $texte);
1572
-	$texte = preg_replace('/,/', '\,', $texte);
1568
+    #include_spip('inc/charsets');
1569
+    $texte = html2unicode($texte);
1570
+    $texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset']), 'utf-8');
1571
+    $texte = preg_replace("/\n/", ' ', $texte);
1572
+    $texte = preg_replace('/,/', '\,', $texte);
1573 1573
 
1574
-	return $texte;
1574
+    return $texte;
1575 1575
 }
1576 1576
 
1577 1577
 
@@ -1596,54 +1596,54 @@  discard block
 block discarded – undo
1596 1596
  * @return string
1597 1597
  **/
1598 1598
 function post_autobr($texte, $delim = "\n_ ") {
1599
-	if (!function_exists('echappe_html')) {
1600
-		include_spip('inc/texte_mini');
1601
-	}
1602
-	$texte = str_replace("\r\n", "\r", $texte);
1603
-	$texte = str_replace("\r", "\n", $texte);
1604
-
1605
-	if (preg_match(",\n+$,", $texte, $fin)) {
1606
-		$texte = substr($texte, 0, -strlen($fin = $fin[0]));
1607
-	} else {
1608
-		$fin = '';
1609
-	}
1610
-
1611
-	$texte = echappe_html($texte, '', true);
1612
-
1613
-	// echapper les modeles
1614
-	if (strpos($texte, '<') !== false) {
1615
-		include_spip('inc/lien');
1616
-		if (defined('_PREG_MODELE')) {
1617
-			$preg_modeles = '@' . _PREG_MODELE . '@imsS';
1618
-			$texte = echappe_html($texte, '', true, $preg_modeles);
1619
-		}
1620
-	}
1621
-
1622
-	$debut = '';
1623
-	$suite = $texte;
1624
-	while ($t = strpos('-' . $suite, "\n", 1)) {
1625
-		$debut .= substr($suite, 0, $t - 1);
1626
-		$suite = substr($suite, $t);
1627
-		$car = substr($suite, 0, 1);
1628
-		if (
1629
-			($car <> '-') and ($car <> '_') and ($car <> "\n") and ($car <> '|') and ($car <> '}')
1630
-			and !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite))
1631
-			and !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut)
1632
-		) {
1633
-			$debut .= $delim;
1634
-		} else {
1635
-			$debut .= "\n";
1636
-		}
1637
-		if (preg_match(",^\n+,", $suite, $regs)) {
1638
-			$debut .= $regs[0];
1639
-			$suite = substr($suite, strlen($regs[0]));
1640
-		}
1641
-	}
1642
-	$texte = $debut . $suite;
1643
-
1644
-	$texte = echappe_retour($texte);
1645
-
1646
-	return $texte . $fin;
1599
+    if (!function_exists('echappe_html')) {
1600
+        include_spip('inc/texte_mini');
1601
+    }
1602
+    $texte = str_replace("\r\n", "\r", $texte);
1603
+    $texte = str_replace("\r", "\n", $texte);
1604
+
1605
+    if (preg_match(",\n+$,", $texte, $fin)) {
1606
+        $texte = substr($texte, 0, -strlen($fin = $fin[0]));
1607
+    } else {
1608
+        $fin = '';
1609
+    }
1610
+
1611
+    $texte = echappe_html($texte, '', true);
1612
+
1613
+    // echapper les modeles
1614
+    if (strpos($texte, '<') !== false) {
1615
+        include_spip('inc/lien');
1616
+        if (defined('_PREG_MODELE')) {
1617
+            $preg_modeles = '@' . _PREG_MODELE . '@imsS';
1618
+            $texte = echappe_html($texte, '', true, $preg_modeles);
1619
+        }
1620
+    }
1621
+
1622
+    $debut = '';
1623
+    $suite = $texte;
1624
+    while ($t = strpos('-' . $suite, "\n", 1)) {
1625
+        $debut .= substr($suite, 0, $t - 1);
1626
+        $suite = substr($suite, $t);
1627
+        $car = substr($suite, 0, 1);
1628
+        if (
1629
+            ($car <> '-') and ($car <> '_') and ($car <> "\n") and ($car <> '|') and ($car <> '}')
1630
+            and !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite))
1631
+            and !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut)
1632
+        ) {
1633
+            $debut .= $delim;
1634
+        } else {
1635
+            $debut .= "\n";
1636
+        }
1637
+        if (preg_match(",^\n+,", $suite, $regs)) {
1638
+            $debut .= $regs[0];
1639
+            $suite = substr($suite, strlen($regs[0]));
1640
+        }
1641
+    }
1642
+    $texte = $debut . $suite;
1643
+
1644
+    $texte = echappe_retour($texte);
1645
+
1646
+    return $texte . $fin;
1647 1647
 }
1648 1648
 
1649 1649
 
@@ -1684,47 +1684,47 @@  discard block
 block discarded – undo
1684 1684
  * @return string
1685 1685
  **/
1686 1686
 function extraire_idiome($letexte, $lang = null, $options = []) {
1687
-	static $traduire = false;
1688
-	if (
1689
-		$letexte
1690
-		and preg_match_all(_EXTRAIRE_IDIOME, $letexte, $regs, PREG_SET_ORDER)
1691
-	) {
1692
-		if (!$traduire) {
1693
-			$traduire = charger_fonction('traduire', 'inc');
1694
-			include_spip('inc/lang');
1695
-		}
1696
-		if (!$lang) {
1697
-			$lang = $GLOBALS['spip_lang'];
1698
-		}
1699
-		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1700
-		if (is_bool($options)) {
1701
-			$options = ['echappe_span' => $options];
1702
-		}
1703
-		if (!isset($options['echappe_span'])) {
1704
-			$options = array_merge($options, ['echappe_span' => false]);
1705
-		}
1706
-
1707
-		foreach ($regs as $reg) {
1708
-			$cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2];
1709
-			$desc = $traduire($cle, $lang, true);
1710
-			$l = $desc->langue;
1711
-			// si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte.
1712
-			if (strlen($desc->texte)) {
1713
-				$trad = code_echappement($desc->texte, 'idiome', false);
1714
-				if ($l !== $lang) {
1715
-					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1716
-				}
1717
-				if (lang_dir($l) !== lang_dir($lang)) {
1718
-					$trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1719
-				}
1720
-				if (!$options['echappe_span']) {
1721
-					$trad = echappe_retour($trad, 'idiome');
1722
-				}
1723
-				$letexte = str_replace($reg[0], $trad, $letexte);
1724
-			}
1725
-		}
1726
-	}
1727
-	return $letexte;
1687
+    static $traduire = false;
1688
+    if (
1689
+        $letexte
1690
+        and preg_match_all(_EXTRAIRE_IDIOME, $letexte, $regs, PREG_SET_ORDER)
1691
+    ) {
1692
+        if (!$traduire) {
1693
+            $traduire = charger_fonction('traduire', 'inc');
1694
+            include_spip('inc/lang');
1695
+        }
1696
+        if (!$lang) {
1697
+            $lang = $GLOBALS['spip_lang'];
1698
+        }
1699
+        // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1700
+        if (is_bool($options)) {
1701
+            $options = ['echappe_span' => $options];
1702
+        }
1703
+        if (!isset($options['echappe_span'])) {
1704
+            $options = array_merge($options, ['echappe_span' => false]);
1705
+        }
1706
+
1707
+        foreach ($regs as $reg) {
1708
+            $cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2];
1709
+            $desc = $traduire($cle, $lang, true);
1710
+            $l = $desc->langue;
1711
+            // si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte.
1712
+            if (strlen($desc->texte)) {
1713
+                $trad = code_echappement($desc->texte, 'idiome', false);
1714
+                if ($l !== $lang) {
1715
+                    $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1716
+                }
1717
+                if (lang_dir($l) !== lang_dir($lang)) {
1718
+                    $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1719
+                }
1720
+                if (!$options['echappe_span']) {
1721
+                    $trad = echappe_retour($trad, 'idiome');
1722
+                }
1723
+                $letexte = str_replace($reg[0], $trad, $letexte);
1724
+            }
1725
+        }
1726
+    }
1727
+    return $letexte;
1728 1728
 }
1729 1729
 
1730 1730
 /**
@@ -1776,68 +1776,68 @@  discard block
 block discarded – undo
1776 1776
  **/
1777 1777
 function extraire_multi($letexte, $lang = null, $options = []) {
1778 1778
 
1779
-	if (
1780
-		$letexte
1781
-		and preg_match_all(_EXTRAIRE_MULTI, $letexte, $regs, PREG_SET_ORDER)
1782
-	) {
1783
-		if (!$lang) {
1784
-			$lang = $GLOBALS['spip_lang'];
1785
-		}
1786
-
1787
-		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1788
-		if (is_bool($options)) {
1789
-			$options = ['echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT];
1790
-		}
1791
-		if (!isset($options['echappe_span'])) {
1792
-			$options = array_merge($options, ['echappe_span' => false]);
1793
-		}
1794
-		if (!isset($options['lang_defaut'])) {
1795
-			$options = array_merge($options, ['lang_defaut' => _LANGUE_PAR_DEFAUT]);
1796
-		}
1797
-
1798
-		include_spip('inc/lang');
1799
-		foreach ($regs as $reg) {
1800
-			// chercher la version de la langue courante
1801
-			$trads = extraire_trads($reg[1]);
1802
-			if ($l = approcher_langue($trads, $lang)) {
1803
-				$trad = $trads[$l];
1804
-			} else {
1805
-				if ($options['lang_defaut'] == 'aucune') {
1806
-					$trad = '';
1807
-				} else {
1808
-					// langue absente, prendre le fr ou une langue précisée (meme comportement que inc/traduire.php)
1809
-					// ou la premiere dispo
1810
-					// mais typographier le texte selon les regles de celle-ci
1811
-					// Attention aux blocs multi sur plusieurs lignes
1812
-					if (!$l = approcher_langue($trads, $options['lang_defaut'])) {
1813
-						$l = key($trads);
1814
-					}
1815
-					$trad = $trads[$l];
1816
-					$typographie = charger_fonction(lang_typo($l), 'typographie');
1817
-					$trad = $typographie($trad);
1818
-					// Tester si on echappe en span ou en div
1819
-					// il ne faut pas echapper en div si propre produit un seul paragraphe
1820
-					include_spip('inc/texte');
1821
-					$trad_propre = preg_replace(',(^<p[^>]*>|</p>$),Uims', '', propre($trad));
1822
-					$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1823
-					if ($mode === 'div') {
1824
-						$trad = rtrim($trad) . "\n\n";
1825
-					}
1826
-					$trad = code_echappement($trad, 'multi', false, $mode);
1827
-					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1828
-					if (lang_dir($l) !== lang_dir($lang)) {
1829
-						$trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1830
-					}
1831
-					if (!$options['echappe_span']) {
1832
-						$trad = echappe_retour($trad, 'multi');
1833
-					}
1834
-				}
1835
-			}
1836
-			$letexte = str_replace($reg[0], $trad, $letexte);
1837
-		}
1838
-	}
1839
-
1840
-	return $letexte;
1779
+    if (
1780
+        $letexte
1781
+        and preg_match_all(_EXTRAIRE_MULTI, $letexte, $regs, PREG_SET_ORDER)
1782
+    ) {
1783
+        if (!$lang) {
1784
+            $lang = $GLOBALS['spip_lang'];
1785
+        }
1786
+
1787
+        // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1788
+        if (is_bool($options)) {
1789
+            $options = ['echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT];
1790
+        }
1791
+        if (!isset($options['echappe_span'])) {
1792
+            $options = array_merge($options, ['echappe_span' => false]);
1793
+        }
1794
+        if (!isset($options['lang_defaut'])) {
1795
+            $options = array_merge($options, ['lang_defaut' => _LANGUE_PAR_DEFAUT]);
1796
+        }
1797
+
1798
+        include_spip('inc/lang');
1799
+        foreach ($regs as $reg) {
1800
+            // chercher la version de la langue courante
1801
+            $trads = extraire_trads($reg[1]);
1802
+            if ($l = approcher_langue($trads, $lang)) {
1803
+                $trad = $trads[$l];
1804
+            } else {
1805
+                if ($options['lang_defaut'] == 'aucune') {
1806
+                    $trad = '';
1807
+                } else {
1808
+                    // langue absente, prendre le fr ou une langue précisée (meme comportement que inc/traduire.php)
1809
+                    // ou la premiere dispo
1810
+                    // mais typographier le texte selon les regles de celle-ci
1811
+                    // Attention aux blocs multi sur plusieurs lignes
1812
+                    if (!$l = approcher_langue($trads, $options['lang_defaut'])) {
1813
+                        $l = key($trads);
1814
+                    }
1815
+                    $trad = $trads[$l];
1816
+                    $typographie = charger_fonction(lang_typo($l), 'typographie');
1817
+                    $trad = $typographie($trad);
1818
+                    // Tester si on echappe en span ou en div
1819
+                    // il ne faut pas echapper en div si propre produit un seul paragraphe
1820
+                    include_spip('inc/texte');
1821
+                    $trad_propre = preg_replace(',(^<p[^>]*>|</p>$),Uims', '', propre($trad));
1822
+                    $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1823
+                    if ($mode === 'div') {
1824
+                        $trad = rtrim($trad) . "\n\n";
1825
+                    }
1826
+                    $trad = code_echappement($trad, 'multi', false, $mode);
1827
+                    $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1828
+                    if (lang_dir($l) !== lang_dir($lang)) {
1829
+                        $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1830
+                    }
1831
+                    if (!$options['echappe_span']) {
1832
+                        $trad = echappe_retour($trad, 'multi');
1833
+                    }
1834
+                }
1835
+            }
1836
+            $letexte = str_replace($reg[0], $trad, $letexte);
1837
+        }
1838
+    }
1839
+
1840
+    return $letexte;
1841 1841
 }
1842 1842
 
1843 1843
 /**
@@ -1853,21 +1853,21 @@  discard block
 block discarded – undo
1853 1853
  *     Peut retourner un code de langue vide, lorsqu'un texte par défaut est indiqué.
1854 1854
  **/
1855 1855
 function extraire_trads($bloc) {
1856
-	$trads = [];
1857
-	$lang = '';
1856
+    $trads = [];
1857
+    $lang = '';
1858 1858
 // ce reg fait planter l'analyse multi s'il y a de l'{italique} dans le champ
1859 1859
 //	while (preg_match("/^(.*?)[{\[]([a-z_]+)[}\]]/siS", $bloc, $regs)) {
1860
-	while (preg_match('/^(.*?)[\[]([a-z_]+)[\]]/siS', $bloc, $regs)) {
1861
-		$texte = trim($regs[1]);
1862
-		if ($texte or $lang) {
1863
-			$trads[$lang] = $texte;
1864
-		}
1865
-		$bloc = substr($bloc, strlen($regs[0]));
1866
-		$lang = $regs[2];
1867
-	}
1868
-	$trads[$lang] = $bloc;
1860
+    while (preg_match('/^(.*?)[\[]([a-z_]+)[\]]/siS', $bloc, $regs)) {
1861
+        $texte = trim($regs[1]);
1862
+        if ($texte or $lang) {
1863
+            $trads[$lang] = $texte;
1864
+        }
1865
+        $bloc = substr($bloc, strlen($regs[0]));
1866
+        $lang = $regs[2];
1867
+    }
1868
+    $trads[$lang] = $bloc;
1869 1869
 
1870
-	return $trads;
1870
+    return $trads;
1871 1871
 }
1872 1872
 
1873 1873
 
@@ -1878,7 +1878,7 @@  discard block
 block discarded – undo
1878 1878
  * @return string L'initiale en majuscule
1879 1879
  */
1880 1880
 function filtre_initiale($nom) {
1881
-	return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1);
1881
+    return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1);
1882 1882
 }
1883 1883
 
1884 1884
 
@@ -1923,33 +1923,33 @@  discard block
 block discarded – undo
1923 1923
  *      - null (interne) : si on empile
1924 1924
  **/
1925 1925
 function unique($donnee, $famille = '', $cpt = false) {
1926
-	static $mem = [];
1927
-	// permettre de vider la pile et de la restaurer
1928
-	// pour le calcul de introduction...
1929
-	if ($famille == '_spip_raz_') {
1930
-		$tmp = $mem;
1931
-		$mem = [];
1932
-
1933
-		return $tmp;
1934
-	} elseif ($famille == '_spip_set_') {
1935
-		$mem = $donnee;
1936
-
1937
-		return;
1938
-	}
1939
-	// eviter une notice
1940
-	if (!isset($mem[$famille])) {
1941
-		$mem[$famille] = [];
1942
-	}
1943
-	if ($cpt) {
1944
-		return is_countable($mem[$famille]) ? count($mem[$famille]) : 0;
1945
-	}
1946
-	// eviter une notice
1947
-	if (!isset($mem[$famille][$donnee])) {
1948
-		$mem[$famille][$donnee] = 0;
1949
-	}
1950
-	if (!($mem[$famille][$donnee]++)) {
1951
-		return $donnee;
1952
-	}
1926
+    static $mem = [];
1927
+    // permettre de vider la pile et de la restaurer
1928
+    // pour le calcul de introduction...
1929
+    if ($famille == '_spip_raz_') {
1930
+        $tmp = $mem;
1931
+        $mem = [];
1932
+
1933
+        return $tmp;
1934
+    } elseif ($famille == '_spip_set_') {
1935
+        $mem = $donnee;
1936
+
1937
+        return;
1938
+    }
1939
+    // eviter une notice
1940
+    if (!isset($mem[$famille])) {
1941
+        $mem[$famille] = [];
1942
+    }
1943
+    if ($cpt) {
1944
+        return is_countable($mem[$famille]) ? count($mem[$famille]) : 0;
1945
+    }
1946
+    // eviter une notice
1947
+    if (!isset($mem[$famille][$donnee])) {
1948
+        $mem[$famille][$donnee] = 0;
1949
+    }
1950
+    if (!($mem[$famille][$donnee]++)) {
1951
+        return $donnee;
1952
+    }
1953 1953
 }
1954 1954
 
1955 1955
 
@@ -1979,16 +1979,16 @@  discard block
 block discarded – undo
1979 1979
  *     Une des valeurs en fonction du compteur.
1980 1980
  **/
1981 1981
 function alterner($i, ...$args) {
1982
-	// recuperer les arguments (attention fonctions un peu space)
1983
-	$num = count($args);
1982
+    // recuperer les arguments (attention fonctions un peu space)
1983
+    $num = count($args);
1984 1984
 
1985
-	if ($num === 1 && is_array($args[0])) {
1986
-		$args = $args[0];
1987
-		$num = count($args);
1988
-	}
1985
+    if ($num === 1 && is_array($args[0])) {
1986
+        $args = $args[0];
1987
+        $num = count($args);
1988
+    }
1989 1989
 
1990
-	// renvoyer le i-ieme argument, modulo le nombre d'arguments
1991
-	return $args[(intval($i) - 1) % $num];
1990
+    // renvoyer le i-ieme argument, modulo le nombre d'arguments
1991
+    return $args[(intval($i) - 1) % $num];
1992 1992
 }
1993 1993
 
1994 1994
 
@@ -2014,51 +2014,51 @@  discard block
 block discarded – undo
2014 2014
  *     - null lorsque l’attribut n’existe pas.
2015 2015
  **/
2016 2016
 function extraire_attribut($balise, $attribut, $complet = false) {
2017
-	if (is_array($balise)) {
2018
-		array_walk(
2019
-			$balise,
2020
-			function (&$a, $key, $t) {
2021
-				$a = extraire_attribut($a, $t);
2022
-			},
2023
-			$attribut
2024
-		);
2025
-
2026
-		return $balise;
2027
-	}
2028
-	if (
2029
-		$balise
2030
-		&& preg_match(
2031
-			',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
2032
-			. $attribut
2033
-			. '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
2034
-			$balise,
2035
-			$r
2036
-		)
2037
-	) {
2038
-		if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) {
2039
-			$r[4] = substr($r[3], 1, -1);
2040
-			$r[3] = $r[3][0];
2041
-		} elseif ($r[3] !== '') {
2042
-			$r[4] = $r[3];
2043
-			$r[3] = '';
2044
-		} else {
2045
-			$r[4] = trim($r[2]);
2046
-		}
2047
-		$att = $r[4];
2048
-		if (strpos($att, '&#') !== false) {
2049
-			$att = str_replace(['&#039;', '&#39;', '&#034;', '&#34;'], ["'", "'", '"', '"'], $att);
2050
-		}
2051
-		$att = filtrer_entites($att);
2052
-	} else {
2053
-		$att = null;
2054
-		$r = [];
2055
-	}
2056
-
2057
-	if ($complet) {
2058
-		return [$att, $r];
2059
-	} else {
2060
-		return $att;
2061
-	}
2017
+    if (is_array($balise)) {
2018
+        array_walk(
2019
+            $balise,
2020
+            function (&$a, $key, $t) {
2021
+                $a = extraire_attribut($a, $t);
2022
+            },
2023
+            $attribut
2024
+        );
2025
+
2026
+        return $balise;
2027
+    }
2028
+    if (
2029
+        $balise
2030
+        && preg_match(
2031
+            ',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
2032
+            . $attribut
2033
+            . '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
2034
+            $balise,
2035
+            $r
2036
+        )
2037
+    ) {
2038
+        if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) {
2039
+            $r[4] = substr($r[3], 1, -1);
2040
+            $r[3] = $r[3][0];
2041
+        } elseif ($r[3] !== '') {
2042
+            $r[4] = $r[3];
2043
+            $r[3] = '';
2044
+        } else {
2045
+            $r[4] = trim($r[2]);
2046
+        }
2047
+        $att = $r[4];
2048
+        if (strpos($att, '&#') !== false) {
2049
+            $att = str_replace(['&#039;', '&#39;', '&#034;', '&#34;'], ["'", "'", '"', '"'], $att);
2050
+        }
2051
+        $att = filtrer_entites($att);
2052
+    } else {
2053
+        $att = null;
2054
+        $r = [];
2055
+    }
2056
+
2057
+    if ($complet) {
2058
+        return [$att, $r];
2059
+    } else {
2060
+        return $att;
2061
+    }
2062 2062
 }
2063 2063
 
2064 2064
 /**
@@ -2091,41 +2091,41 @@  discard block
 block discarded – undo
2091 2091
  **/
2092 2092
 function inserer_attribut(?string $balise, string $attribut, string $val, bool $proteger = true, bool $vider = false): string {
2093 2093
 
2094
-	if ($balise === null or $balise === '') {
2095
-		return '';
2096
-	}
2094
+    if ($balise === null or $balise === '') {
2095
+        return '';
2096
+    }
2097 2097
 
2098
-	// preparer l'attribut
2099
-	// supprimer les &nbsp; etc mais pas les balises html
2100
-	// qui ont un sens dans un attribut value d'un input
2101
-	if ($proteger) {
2102
-		$val = attribut_html($val, false);
2103
-	}
2098
+    // preparer l'attribut
2099
+    // supprimer les &nbsp; etc mais pas les balises html
2100
+    // qui ont un sens dans un attribut value d'un input
2101
+    if ($proteger) {
2102
+        $val = attribut_html($val, false);
2103
+    }
2104 2104
 
2105
-	// echapper les ' pour eviter tout bug
2106
-	$val = str_replace("'", '&#039;', $val);
2107
-	if ($vider and strlen($val) === 0) {
2108
-		$insert = '';
2109
-	} else {
2110
-		$insert = " $attribut='$val'";
2111
-	}
2105
+    // echapper les ' pour eviter tout bug
2106
+    $val = str_replace("'", '&#039;', $val);
2107
+    if ($vider and strlen($val) === 0) {
2108
+        $insert = '';
2109
+    } else {
2110
+        $insert = " $attribut='$val'";
2111
+    }
2112 2112
 
2113
-	[$old, $r] = extraire_attribut($balise, $attribut, true);
2113
+    [$old, $r] = extraire_attribut($balise, $attribut, true);
2114 2114
 
2115
-	if ($old !== null) {
2116
-		// Remplacer l'ancien attribut du meme nom
2117
-		$balise = $r[1] . $insert . $r[5];
2118
-	} else {
2119
-		// preferer une balise " />" (comme <img />)
2120
-		if (preg_match(',/>,', $balise)) {
2121
-			$balise = preg_replace(',\s?/>,S', $insert . ' />', $balise, 1);
2122
-		} // sinon une balise <a ...> ... </a>
2123
-		else {
2124
-			$balise = preg_replace(',\s?>,S', $insert . '>', $balise, 1);
2125
-		}
2126
-	}
2115
+    if ($old !== null) {
2116
+        // Remplacer l'ancien attribut du meme nom
2117
+        $balise = $r[1] . $insert . $r[5];
2118
+    } else {
2119
+        // preferer une balise " />" (comme <img />)
2120
+        if (preg_match(',/>,', $balise)) {
2121
+            $balise = preg_replace(',\s?/>,S', $insert . ' />', $balise, 1);
2122
+        } // sinon une balise <a ...> ... </a>
2123
+        else {
2124
+            $balise = preg_replace(',\s?>,S', $insert . '>', $balise, 1);
2125
+        }
2126
+    }
2127 2127
 
2128
-	return $balise;
2128
+    return $balise;
2129 2129
 }
2130 2130
 
2131 2131
 /**
@@ -2143,7 +2143,7 @@  discard block
 block discarded – undo
2143 2143
  * @return string Code HTML sans l'attribut
2144 2144
  **/
2145 2145
 function vider_attribut(?string $balise, string $attribut): string {
2146
-	return inserer_attribut($balise, $attribut, '', false, true);
2146
+    return inserer_attribut($balise, $attribut, '', false, true);
2147 2147
 }
2148 2148
 
2149 2149
 /**
@@ -2155,53 +2155,53 @@  discard block
 block discarded – undo
2155 2155
  * @return string
2156 2156
  */
2157 2157
 function modifier_class($balise, $class, $operation = 'ajouter') {
2158
-	if (is_string($class)) {
2159
-		$class = explode(' ', trim($class));
2160
-	}
2161
-	$class = array_filter($class);
2162
-	$class = array_unique($class);
2163
-	if (!$class) {
2164
-		return $balise;
2165
-	}
2166
-
2167
-	// si la ou les classes ont des caracteres invalides on ne fait rien
2168
-	if (preg_match(',[^\w-],', implode('', $class))) {
2169
-		return $balise;
2170
-	}
2171
-
2172
-	$class_courante = extraire_attribut($balise, 'class');
2173
-	$class_new = $class_courante;
2174
-	foreach ($class as $c) {
2175
-		$is_class_presente = false;
2176
-		if (
2177
-			$class_courante
2178
-			and strpos($class_courante, (string) $c) !== false
2179
-			and preg_match('/(^|\s)' . preg_quote($c) . '($|\s)/', $class_courante)
2180
-		) {
2181
-			$is_class_presente = true;
2182
-		}
2183
-		if (
2184
-			in_array($operation, ['ajouter', 'commuter'])
2185
-			and !$is_class_presente
2186
-		) {
2187
-			$class_new = ltrim(rtrim($class_new ?? '') . ' ' . $c);
2188
-		} elseif (
2189
-			in_array($operation, ['supprimer', 'commuter'])
2190
-			and $is_class_presente
2191
-		) {
2192
-			$class_new = trim(preg_replace('/(^|\s)' . preg_quote($c) . '($|\s)/', "\\1", $class_new));
2193
-		}
2194
-	}
2195
-
2196
-	if ($class_new !== $class_courante) {
2197
-		if (strlen($class_new)) {
2198
-			$balise = inserer_attribut($balise, 'class', $class_new);
2199
-		} elseif ($class_courante) {
2200
-			$balise = vider_attribut($balise, 'class');
2201
-		}
2202
-	}
2203
-
2204
-	return $balise;
2158
+    if (is_string($class)) {
2159
+        $class = explode(' ', trim($class));
2160
+    }
2161
+    $class = array_filter($class);
2162
+    $class = array_unique($class);
2163
+    if (!$class) {
2164
+        return $balise;
2165
+    }
2166
+
2167
+    // si la ou les classes ont des caracteres invalides on ne fait rien
2168
+    if (preg_match(',[^\w-],', implode('', $class))) {
2169
+        return $balise;
2170
+    }
2171
+
2172
+    $class_courante = extraire_attribut($balise, 'class');
2173
+    $class_new = $class_courante;
2174
+    foreach ($class as $c) {
2175
+        $is_class_presente = false;
2176
+        if (
2177
+            $class_courante
2178
+            and strpos($class_courante, (string) $c) !== false
2179
+            and preg_match('/(^|\s)' . preg_quote($c) . '($|\s)/', $class_courante)
2180
+        ) {
2181
+            $is_class_presente = true;
2182
+        }
2183
+        if (
2184
+            in_array($operation, ['ajouter', 'commuter'])
2185
+            and !$is_class_presente
2186
+        ) {
2187
+            $class_new = ltrim(rtrim($class_new ?? '') . ' ' . $c);
2188
+        } elseif (
2189
+            in_array($operation, ['supprimer', 'commuter'])
2190
+            and $is_class_presente
2191
+        ) {
2192
+            $class_new = trim(preg_replace('/(^|\s)' . preg_quote($c) . '($|\s)/', "\\1", $class_new));
2193
+        }
2194
+    }
2195
+
2196
+    if ($class_new !== $class_courante) {
2197
+        if (strlen($class_new)) {
2198
+            $balise = inserer_attribut($balise, 'class', $class_new);
2199
+        } elseif ($class_courante) {
2200
+            $balise = vider_attribut($balise, 'class');
2201
+        }
2202
+    }
2203
+
2204
+    return $balise;
2205 2205
 }
2206 2206
 
2207 2207
 /**
@@ -2211,7 +2211,7 @@  discard block
 block discarded – undo
2211 2211
  * @return string
2212 2212
  */
2213 2213
 function ajouter_class($balise, $class) {
2214
-	return modifier_class($balise, $class, 'ajouter');
2214
+    return modifier_class($balise, $class, 'ajouter');
2215 2215
 }
2216 2216
 
2217 2217
 /**
@@ -2221,7 +2221,7 @@  discard block
 block discarded – undo
2221 2221
  * @return string
2222 2222
  */
2223 2223
 function supprimer_class($balise, $class) {
2224
-	return modifier_class($balise, $class, 'supprimer');
2224
+    return modifier_class($balise, $class, 'supprimer');
2225 2225
 }
2226 2226
 
2227 2227
 /**
@@ -2232,7 +2232,7 @@  discard block
 block discarded – undo
2232 2232
  * @return string
2233 2233
  */
2234 2234
 function commuter_class($balise, $class) {
2235
-	return modifier_class($balise, $class, 'commuter');
2235
+    return modifier_class($balise, $class, 'commuter');
2236 2236
 }
2237 2237
 
2238 2238
 /**
@@ -2243,19 +2243,19 @@  discard block
 block discarded – undo
2243 2243
  * @return string
2244 2244
  */
2245 2245
 function tester_config($id, $mode = '') {
2246
-	include_spip('action/inscrire_auteur');
2246
+    include_spip('action/inscrire_auteur');
2247 2247
 
2248
-	return tester_statut_inscription($mode, $id);
2248
+    return tester_statut_inscription($mode, $id);
2249 2249
 }
2250 2250
 
2251 2251
 //
2252 2252
 // Quelques fonctions de calcul arithmetique
2253 2253
 //
2254 2254
 function floatstr($a) {
2255
- return str_replace(',', '.', (string)floatval($a));
2255
+    return str_replace(',', '.', (string)floatval($a));
2256 2256
 }
2257 2257
 function strize($f, $a, $b) {
2258
- return floatstr($f(floatstr($a), floatstr($b)));
2258
+    return floatstr($f(floatstr($a), floatstr($b)));
2259 2259
 }
2260 2260
 
2261 2261
 /**
@@ -2274,7 +2274,7 @@  discard block
 block discarded – undo
2274 2274
  * @return int $a+$b
2275 2275
  **/
2276 2276
 function plus($a, $b) {
2277
-	return $a + $b;
2277
+    return $a + $b;
2278 2278
 }
2279 2279
 function strplus($a, $b) {
2280 2280
 return strize('plus', $a, $b);
@@ -2295,7 +2295,7 @@  discard block
 block discarded – undo
2295 2295
  * @return int $a-$b
2296 2296
  **/
2297 2297
 function moins($a, $b) {
2298
-	return $a - $b;
2298
+    return $a - $b;
2299 2299
 }
2300 2300
 function strmoins($a, $b) {
2301 2301
 return strize('moins', $a, $b);
@@ -2318,7 +2318,7 @@  discard block
 block discarded – undo
2318 2318
  * @return int $a*$b
2319 2319
  **/
2320 2320
 function mult($a, $b) {
2321
-	return $a * $b;
2321
+    return $a * $b;
2322 2322
 }
2323 2323
 function strmult($a, $b) {
2324 2324
 return strize('mult', $a, $b);
@@ -2341,7 +2341,7 @@  discard block
 block discarded – undo
2341 2341
  * @return int $a/$b (ou 0 si $b est nul)
2342 2342
  **/
2343 2343
 function div($a, $b) {
2344
-	return $b ? $a / $b : 0;
2344
+    return $b ? $a / $b : 0;
2345 2345
 }
2346 2346
 function strdiv($a, $b) {
2347 2347
 return strize('div', $a, $b);
@@ -2365,7 +2365,7 @@  discard block
 block discarded – undo
2365 2365
  * @return int ($nb % $mod) + $add
2366 2366
  **/
2367 2367
 function modulo($nb, $mod, $add = 0) {
2368
-	return ($mod ? $nb % $mod : 0) + $add;
2368
+    return ($mod ? $nb % $mod : 0) + $add;
2369 2369
 }
2370 2370
 
2371 2371
 
@@ -2380,26 +2380,26 @@  discard block
 block discarded – undo
2380 2380
  *      - true sinon
2381 2381
  **/
2382 2382
 function nom_acceptable($nom) {
2383
-	$remp2 = [];
2384
-	$remp1 = [];
2385
-	if (!is_string($nom)) {
2386
-		return false;
2387
-	}
2388
-	if (!defined('_TAGS_NOM_AUTEUR')) {
2389
-		define('_TAGS_NOM_AUTEUR', '');
2390
-	}
2391
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2392
-	foreach ($tags_acceptes as $tag) {
2393
-		if (strlen($tag)) {
2394
-			$remp1[] = '<' . trim($tag) . '>';
2395
-			$remp1[] = '</' . trim($tag) . '>';
2396
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2397
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2398
-		}
2399
-	}
2400
-	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2401
-
2402
-	return str_replace('&lt;', '<', $v_nom) == $nom;
2383
+    $remp2 = [];
2384
+    $remp1 = [];
2385
+    if (!is_string($nom)) {
2386
+        return false;
2387
+    }
2388
+    if (!defined('_TAGS_NOM_AUTEUR')) {
2389
+        define('_TAGS_NOM_AUTEUR', '');
2390
+    }
2391
+    $tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2392
+    foreach ($tags_acceptes as $tag) {
2393
+        if (strlen($tag)) {
2394
+            $remp1[] = '<' . trim($tag) . '>';
2395
+            $remp1[] = '</' . trim($tag) . '>';
2396
+            $remp2[] = '\x60' . trim($tag) . '\x61';
2397
+            $remp2[] = '\x60/' . trim($tag) . '\x61';
2398
+        }
2399
+    }
2400
+    $v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2401
+
2402
+    return str_replace('&lt;', '<', $v_nom) == $nom;
2403 2403
 }
2404 2404
 
2405 2405
 
@@ -2415,14 +2415,14 @@  discard block
 block discarded – undo
2415 2415
  *      - renvoie un tableau si l'entree est un tableau
2416 2416
  **/
2417 2417
 function email_valide($adresses) {
2418
-	if (is_array($adresses)) {
2419
-		$adresses = array_map('email_valide', $adresses);
2420
-		$adresses = array_filter($adresses);
2421
-		return $adresses;
2422
-	}
2418
+    if (is_array($adresses)) {
2419
+        $adresses = array_map('email_valide', $adresses);
2420
+        $adresses = array_filter($adresses);
2421
+        return $adresses;
2422
+    }
2423 2423
 
2424
-	$email_valide = charger_fonction('email_valide', 'inc');
2425
-	return $email_valide($adresses);
2424
+    $email_valide = charger_fonction('email_valide', 'inc');
2425
+    return $email_valide($adresses);
2426 2426
 }
2427 2427
 
2428 2428
 /**
@@ -2436,27 +2436,27 @@  discard block
 block discarded – undo
2436 2436
  * @return string Texte
2437 2437
  **/
2438 2438
 function afficher_enclosures($tags) {
2439
-	$s = [];
2440
-	foreach (extraire_balises($tags, 'a') as $tag) {
2441
-		if (
2442
-			extraire_attribut($tag, 'rel') == 'enclosure'
2443
-			and $t = extraire_attribut($tag, 'href')
2444
-		) {
2445
-			$s[] = preg_replace(
2446
-				',>[^<]+</a>,S',
2447
-				'>'
2448
-				. http_img_pack(
2449
-					'attachment-16.png',
2450
-					$t,
2451
-					'title="' . attribut_html($t) . '"'
2452
-				)
2453
-				. '</a>',
2454
-				$tag
2455
-			);
2456
-		}
2457
-	}
2458
-
2459
-	return join('&nbsp;', $s);
2439
+    $s = [];
2440
+    foreach (extraire_balises($tags, 'a') as $tag) {
2441
+        if (
2442
+            extraire_attribut($tag, 'rel') == 'enclosure'
2443
+            and $t = extraire_attribut($tag, 'href')
2444
+        ) {
2445
+            $s[] = preg_replace(
2446
+                ',>[^<]+</a>,S',
2447
+                '>'
2448
+                . http_img_pack(
2449
+                    'attachment-16.png',
2450
+                    $t,
2451
+                    'title="' . attribut_html($t) . '"'
2452
+                )
2453
+                . '</a>',
2454
+                $tag
2455
+            );
2456
+        }
2457
+    }
2458
+
2459
+    return join('&nbsp;', $s);
2460 2460
 }
2461 2461
 
2462 2462
 /**
@@ -2471,15 +2471,15 @@  discard block
 block discarded – undo
2471 2471
  * @return string Liens trouvés
2472 2472
  **/
2473 2473
 function afficher_tags($tags, $rels = 'tag,directory') {
2474
-	$s = [];
2475
-	foreach (extraire_balises($tags, 'a') as $tag) {
2476
-		$rel = extraire_attribut($tag, 'rel');
2477
-		if (strstr(",$rels,", (string) ",$rel,")) {
2478
-			$s[] = $tag;
2479
-		}
2480
-	}
2474
+    $s = [];
2475
+    foreach (extraire_balises($tags, 'a') as $tag) {
2476
+        $rel = extraire_attribut($tag, 'rel');
2477
+        if (strstr(",$rels,", (string) ",$rel,")) {
2478
+            $s[] = $tag;
2479
+        }
2480
+    }
2481 2481
 
2482
-	return join(', ', $s);
2482
+    return join(', ', $s);
2483 2483
 }
2484 2484
 
2485 2485
 
@@ -2501,21 +2501,21 @@  discard block
 block discarded – undo
2501 2501
  * @return string Tag HTML `<a>` avec microformat.
2502 2502
  **/
2503 2503
 function enclosure2microformat($e) {
2504
-	if (!$url = filtrer_entites(extraire_attribut($e, 'url'))) {
2505
-		$url = filtrer_entites(extraire_attribut($e, 'href'));
2506
-	}
2507
-	$type = extraire_attribut($e, 'type');
2508
-	if (!$length = extraire_attribut($e, 'length')) {
2509
-		# <media:content : longeur dans fileSize. On tente.
2510
-		$length = extraire_attribut($e, 'fileSize');
2511
-	}
2512
-	$fichier = basename($url);
2504
+    if (!$url = filtrer_entites(extraire_attribut($e, 'url'))) {
2505
+        $url = filtrer_entites(extraire_attribut($e, 'href'));
2506
+    }
2507
+    $type = extraire_attribut($e, 'type');
2508
+    if (!$length = extraire_attribut($e, 'length')) {
2509
+        # <media:content : longeur dans fileSize. On tente.
2510
+        $length = extraire_attribut($e, 'fileSize');
2511
+    }
2512
+    $fichier = basename($url);
2513 2513
 
2514
-	return '<a rel="enclosure"'
2515
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2516
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2517
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2518
-	. '>' . $fichier . '</a>';
2514
+    return '<a rel="enclosure"'
2515
+    . ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2516
+    . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2517
+    . ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2518
+    . '>' . $fichier . '</a>';
2519 2519
 }
2520 2520
 
2521 2521
 /**
@@ -2533,24 +2533,24 @@  discard block
 block discarded – undo
2533 2533
  * @return string Tags RSS `<enclosure>`.
2534 2534
  **/
2535 2535
 function microformat2enclosure($tags) {
2536
-	$enclosures = [];
2537
-	foreach (extraire_balises($tags, 'a') as $e) {
2538
-		if (extraire_attribut($e, 'rel') == 'enclosure') {
2539
-			$url = filtrer_entites(extraire_attribut($e, 'href'));
2540
-			$type = extraire_attribut($e, 'type');
2541
-			if (!$length = intval(extraire_attribut($e, 'title'))) {
2542
-				$length = intval(extraire_attribut($e, 'length'));
2543
-			} # vieux data
2544
-			$fichier = basename($url);
2545
-			$enclosures[] = '<enclosure'
2546
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2547
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2548
-				. ($length ? ' length="' . $length . '"' : '')
2549
-				. ' />';
2550
-		}
2551
-	}
2536
+    $enclosures = [];
2537
+    foreach (extraire_balises($tags, 'a') as $e) {
2538
+        if (extraire_attribut($e, 'rel') == 'enclosure') {
2539
+            $url = filtrer_entites(extraire_attribut($e, 'href'));
2540
+            $type = extraire_attribut($e, 'type');
2541
+            if (!$length = intval(extraire_attribut($e, 'title'))) {
2542
+                $length = intval(extraire_attribut($e, 'length'));
2543
+            } # vieux data
2544
+            $fichier = basename($url);
2545
+            $enclosures[] = '<enclosure'
2546
+                . ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2547
+                . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2548
+                . ($length ? ' length="' . $length . '"' : '')
2549
+                . ' />';
2550
+        }
2551
+    }
2552 2552
 
2553
-	return join("\n", $enclosures);
2553
+    return join("\n", $enclosures);
2554 2554
 }
2555 2555
 
2556 2556
 
@@ -2566,16 +2566,16 @@  discard block
 block discarded – undo
2566 2566
  * @return string Tags RSS Atom `<dc:subject>`.
2567 2567
  **/
2568 2568
 function tags2dcsubject($tags) {
2569
-	$subjects = '';
2570
-	foreach (extraire_balises($tags, 'a') as $e) {
2571
-		if (extraire_attribut($e, 'rel') == 'tag') {
2572
-			$subjects .= '<dc:subject>'
2573
-				. texte_backend(textebrut($e))
2574
-				. '</dc:subject>' . "\n";
2575
-		}
2576
-	}
2569
+    $subjects = '';
2570
+    foreach (extraire_balises($tags, 'a') as $e) {
2571
+        if (extraire_attribut($e, 'rel') == 'tag') {
2572
+            $subjects .= '<dc:subject>'
2573
+                . texte_backend(textebrut($e))
2574
+                . '</dc:subject>' . "\n";
2575
+        }
2576
+    }
2577 2577
 
2578
-	return $subjects;
2578
+    return $subjects;
2579 2579
 }
2580 2580
 
2581 2581
 /**
@@ -2604,27 +2604,27 @@  discard block
 block discarded – undo
2604 2604
  *     - Tableau de résultats, si tableau en entrée.
2605 2605
  **/
2606 2606
 function extraire_balise($texte, $tag = 'a') {
2607
-	if (is_array($texte)) {
2608
-		array_walk(
2609
-			$texte,
2610
-			function (&$a, $key, $t) {
2611
-				$a = extraire_balise($a, $t);
2612
-			},
2613
-			$tag
2614
-		);
2615
-
2616
-		return $texte;
2617
-	}
2618
-
2619
-	if (
2620
-		preg_match(
2621
-			",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS",
2622
-			$texte,
2623
-			$regs
2624
-		)
2625
-	) {
2626
-		return $regs[0];
2627
-	}
2607
+    if (is_array($texte)) {
2608
+        array_walk(
2609
+            $texte,
2610
+            function (&$a, $key, $t) {
2611
+                $a = extraire_balise($a, $t);
2612
+            },
2613
+            $tag
2614
+        );
2615
+
2616
+        return $texte;
2617
+    }
2618
+
2619
+    if (
2620
+        preg_match(
2621
+            ",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS",
2622
+            $texte,
2623
+            $regs
2624
+        )
2625
+    ) {
2626
+        return $regs[0];
2627
+    }
2628 2628
 }
2629 2629
 
2630 2630
 /**
@@ -2652,30 +2652,30 @@  discard block
 block discarded – undo
2652 2652
  *     - Tableau de résultats, si tableau en entrée.
2653 2653
  **/
2654 2654
 function extraire_balises($texte, $tag = 'a') {
2655
-	if (is_array($texte)) {
2656
-		array_walk(
2657
-			$texte,
2658
-			function (&$a, $key, $t) {
2659
-				$a = extraire_balises($a, $t);
2660
-			},
2661
-			$tag
2662
-		);
2663
-
2664
-		return $texte;
2665
-	}
2666
-
2667
-	if (
2668
-		preg_match_all(
2669
-			",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS",
2670
-			$texte,
2671
-			$regs,
2672
-			PREG_PATTERN_ORDER
2673
-		)
2674
-	) {
2675
-		return $regs[0];
2676
-	} else {
2677
-		return [];
2678
-	}
2655
+    if (is_array($texte)) {
2656
+        array_walk(
2657
+            $texte,
2658
+            function (&$a, $key, $t) {
2659
+                $a = extraire_balises($a, $t);
2660
+            },
2661
+            $tag
2662
+        );
2663
+
2664
+        return $texte;
2665
+    }
2666
+
2667
+    if (
2668
+        preg_match_all(
2669
+            ",<${tag}\b[^>]*(/>|>.*</${tag}\b[^>]*>|>),UimsS",
2670
+            $texte,
2671
+            $regs,
2672
+            PREG_PATTERN_ORDER
2673
+        )
2674
+    ) {
2675
+        return $regs[0];
2676
+    } else {
2677
+        return [];
2678
+    }
2679 2679
 }
2680 2680
 
2681 2681
 /**
@@ -2704,11 +2704,11 @@  discard block
 block discarded – undo
2704 2704
  *     - `$def` si on n'a pas transmis de tableau
2705 2705
  **/
2706 2706
 function in_any($val, $vals, $def = '') {
2707
-	if (!is_array($vals) and $vals and $v = unserialize($vals)) {
2708
-		$vals = $v;
2709
-	}
2707
+    if (!is_array($vals) and $vals and $v = unserialize($vals)) {
2708
+        $vals = $v;
2709
+    }
2710 2710
 
2711
-	return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : ''));
2711
+    return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : ''));
2712 2712
 }
2713 2713
 
2714 2714
 
@@ -2729,12 +2729,12 @@  discard block
 block discarded – undo
2729 2729
  *     Résultat du calcul
2730 2730
  **/
2731 2731
 function valeur_numerique($expr) {
2732
-	$a = 0;
2733
-	if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) {
2734
-		eval("\$a = $expr;");
2735
-	}
2732
+    $a = 0;
2733
+    if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) {
2734
+        eval("\$a = $expr;");
2735
+    }
2736 2736
 
2737
-	return intval($a);
2737
+    return intval($a);
2738 2738
 }
2739 2739
 
2740 2740
 /**
@@ -2753,7 +2753,7 @@  discard block
 block discarded – undo
2753 2753
  *      Retourne `$a*$b/$c`
2754 2754
  **/
2755 2755
 function regledetrois($a, $b, $c) {
2756
-	return round($a * $b / $c);
2756
+    return round($a * $b / $c);
2757 2757
 }
2758 2758
 
2759 2759
 
@@ -2776,79 +2776,79 @@  discard block
 block discarded – undo
2776 2776
  * @return string Suite de champs input hidden
2777 2777
  **/
2778 2778
 function form_hidden(?string $action = ''): string {
2779
-	$action ??= '';
2780
-
2781
-	$contexte = [];
2782
-	include_spip('inc/urls');
2783
-	if (
2784
-		$p = urls_decoder_url($action, '')
2785
-		and reset($p)
2786
-	) {
2787
-		$fond = array_shift($p);
2788
-		if ($fond != '404') {
2789
-			$contexte = array_shift($p);
2790
-			$contexte['page'] = $fond;
2791
-			$action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2792
-		}
2793
-	}
2794
-	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2795
-	if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
2796
-		unset($contexte['type']);
2797
-	}
2798
-	if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') or _DEFINIR_CONTEXTE_TYPE_PAGE) {
2799
-		unset($contexte['type-page']);
2800
-	}
2801
-
2802
-	// on va remplir un tableau de valeurs en prenant bien soin de ne pas
2803
-	// ecraser les elements de la forme mots[]=1&mots[]=2
2804
-	$values = [];
2805
-
2806
-	// d'abord avec celles de l'url
2807
-	if (false !== ($p = strpos($action, '?'))) {
2808
-		foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2809
-			$c = explode('=', $c, 2);
2810
-			$var = array_shift($c);
2811
-			$val = array_shift($c);
2812
-			if ($var) {
2813
-				$val = rawurldecode($val);
2814
-				$var = rawurldecode($var); // decoder les [] eventuels
2815
-				if (preg_match(',\[\]$,S', $var)) {
2816
-					$values[] = [$var, $val];
2817
-				} else {
2818
-					if (!isset($values[$var])) {
2819
-						$values[$var] = [$var, $val];
2820
-					}
2821
-				}
2822
-			}
2823
-		}
2824
-	}
2825
-
2826
-	// ensuite avec celles du contexte, sans doublonner !
2827
-	foreach ($contexte as $var => $val) {
2828
-		if (preg_match(',\[\]$,S', $var)) {
2829
-			$values[] = [$var, $val];
2830
-		} else {
2831
-			if (!isset($values[$var])) {
2832
-				$values[$var] = [$var, $val];
2833
-			}
2834
-		}
2835
-	}
2836
-
2837
-	// puis on rassemble le tout
2838
-	$hidden = [];
2839
-	foreach ($values as $value) {
2840
-		[$var, $val] = $value;
2841
-		$hidden[] = '<input name="'
2842
-			. entites_html($var)
2843
-			. '"'
2844
-			. (is_null($val)
2845
-				? ''
2846
-				: ' value="' . entites_html($val) . '"'
2847
-			)
2848
-			. ' type="hidden"' . "\n/>";
2849
-	}
2850
-
2851
-	return join('', $hidden);
2779
+    $action ??= '';
2780
+
2781
+    $contexte = [];
2782
+    include_spip('inc/urls');
2783
+    if (
2784
+        $p = urls_decoder_url($action, '')
2785
+        and reset($p)
2786
+    ) {
2787
+        $fond = array_shift($p);
2788
+        if ($fond != '404') {
2789
+            $contexte = array_shift($p);
2790
+            $contexte['page'] = $fond;
2791
+            $action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2792
+        }
2793
+    }
2794
+    // defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2795
+    if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
2796
+        unset($contexte['type']);
2797
+    }
2798
+    if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') or _DEFINIR_CONTEXTE_TYPE_PAGE) {
2799
+        unset($contexte['type-page']);
2800
+    }
2801
+
2802
+    // on va remplir un tableau de valeurs en prenant bien soin de ne pas
2803
+    // ecraser les elements de la forme mots[]=1&mots[]=2
2804
+    $values = [];
2805
+
2806
+    // d'abord avec celles de l'url
2807
+    if (false !== ($p = strpos($action, '?'))) {
2808
+        foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2809
+            $c = explode('=', $c, 2);
2810
+            $var = array_shift($c);
2811
+            $val = array_shift($c);
2812
+            if ($var) {
2813
+                $val = rawurldecode($val);
2814
+                $var = rawurldecode($var); // decoder les [] eventuels
2815
+                if (preg_match(',\[\]$,S', $var)) {
2816
+                    $values[] = [$var, $val];
2817
+                } else {
2818
+                    if (!isset($values[$var])) {
2819
+                        $values[$var] = [$var, $val];
2820
+                    }
2821
+                }
2822
+            }
2823
+        }
2824
+    }
2825
+
2826
+    // ensuite avec celles du contexte, sans doublonner !
2827
+    foreach ($contexte as $var => $val) {
2828
+        if (preg_match(',\[\]$,S', $var)) {
2829
+            $values[] = [$var, $val];
2830
+        } else {
2831
+            if (!isset($values[$var])) {
2832
+                $values[$var] = [$var, $val];
2833
+            }
2834
+        }
2835
+    }
2836
+
2837
+    // puis on rassemble le tout
2838
+    $hidden = [];
2839
+    foreach ($values as $value) {
2840
+        [$var, $val] = $value;
2841
+        $hidden[] = '<input name="'
2842
+            . entites_html($var)
2843
+            . '"'
2844
+            . (is_null($val)
2845
+                ? ''
2846
+                : ' value="' . entites_html($val) . '"'
2847
+            )
2848
+            . ' type="hidden"' . "\n/>";
2849
+    }
2850
+
2851
+    return join('', $hidden);
2852 2852
 }
2853 2853
 
2854 2854
 
@@ -2870,7 +2870,7 @@  discard block
 block discarded – undo
2870 2870
  *    - la première valeur du tableau sinon.
2871 2871
  **/
2872 2872
 function filtre_reset($array) {
2873
-	return !is_array($array) ? null : reset($array);
2873
+    return !is_array($array) ? null : reset($array);
2874 2874
 }
2875 2875
 
2876 2876
 /**
@@ -2891,7 +2891,7 @@  discard block
 block discarded – undo
2891 2891
  *    - la dernière valeur du tableau sinon.
2892 2892
  **/
2893 2893
 function filtre_end($array) {
2894
-	return !is_array($array) ? null : end($array);
2894
+    return !is_array($array) ? null : end($array);
2895 2895
 }
2896 2896
 
2897 2897
 /**
@@ -2911,11 +2911,11 @@  discard block
 block discarded – undo
2911 2911
  *
2912 2912
  **/
2913 2913
 function filtre_push($array, $val) {
2914
-	if (!is_array($array) or !array_push($array, $val)) {
2915
-		return '';
2916
-	}
2914
+    if (!is_array($array) or !array_push($array, $val)) {
2915
+        return '';
2916
+    }
2917 2917
 
2918
-	return $array;
2918
+    return $array;
2919 2919
 }
2920 2920
 
2921 2921
 /**
@@ -2934,7 +2934,7 @@  discard block
 block discarded – undo
2934 2934
  *     - `true` si la valeur existe dans le tableau, `false` sinon.
2935 2935
  **/
2936 2936
 function filtre_find($array, $val) {
2937
-	return (is_array($array) and in_array($val, $array));
2937
+    return (is_array($array) and in_array($val, $array));
2938 2938
 }
2939 2939
 
2940 2940
 
@@ -2951,13 +2951,13 @@  discard block
 block discarded – undo
2951 2951
  *     Contenu avec urls en absolus
2952 2952
  **/
2953 2953
 function urls_absolues_css($contenu, $source) {
2954
-	$path = suivre_lien(url_absolue($source), './');
2954
+    $path = suivre_lien(url_absolue($source), './');
2955 2955
 
2956
-	return preg_replace_callback(
2957
-		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2958
-		fn($x) => "url('" . suivre_lien($path, $x[1]) . "')",
2959
-		$contenu
2960
-	);
2956
+    return preg_replace_callback(
2957
+        ",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2958
+        fn($x) => "url('" . suivre_lien($path, $x[1]) . "')",
2959
+        $contenu
2960
+    );
2961 2961
 }
2962 2962
 
2963 2963
 
@@ -2986,119 +2986,119 @@  discard block
 block discarded – undo
2986 2986
  *     Chemin du fichier CSS inversé
2987 2987
  **/
2988 2988
 function direction_css($css, $voulue = '') {
2989
-	if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) {
2990
-		return $css;
2991
-	}
2992
-	include_spip('inc/lang');
2993
-	// si on a precise le sens voulu en argument, le prendre en compte
2994
-	if ($voulue = strtolower($voulue)) {
2995
-		if ($voulue != 'rtl' and $voulue != 'ltr') {
2996
-			$voulue = lang_dir($voulue);
2997
-		}
2998
-	} else {
2999
-		$voulue = lang_dir();
3000
-	}
3001
-
3002
-	$r = count($r) > 1;
3003
-	$right = $r ? 'left' : 'right'; // 'right' de la css lue en entree
3004
-	$dir = $r ? 'rtl' : 'ltr';
3005
-	$ndir = $r ? 'ltr' : 'rtl';
3006
-
3007
-	if ($voulue == $dir) {
3008
-		return $css;
3009
-	}
3010
-
3011
-	if (
3012
-		// url absolue
3013
-		preg_match(',^https?:,i', $css)
3014
-		// ou qui contient un ?
3015
-		or (($p = strpos($css, '?')) !== false)
3016
-	) {
3017
-		$distant = true;
3018
-		$cssf = parse_url($css);
3019
-		$cssf = $cssf['path'] . ($cssf['query'] ? '?' . $cssf['query'] : '');
3020
-		$cssf = preg_replace(',[?:&=],', '_', $cssf);
3021
-	} else {
3022
-		$distant = false;
3023
-		$cssf = $css;
3024
-		// 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
3025
-		//propose (rien a faire dans ce cas)
3026
-		$f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
3027
-		if (@file_exists($f)) {
3028
-			return $f;
3029
-		}
3030
-	}
3031
-
3032
-	// 2.
3033
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
3034
-	$f = $dir_var
3035
-		. preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
3036
-		. '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
3037
-
3038
-	// la css peut etre distante (url absolue !)
3039
-	if ($distant) {
3040
-		include_spip('inc/distant');
3041
-		$res = recuperer_url($css);
3042
-		if (!$res or !$contenu = $res['page']) {
3043
-			return $css;
3044
-		}
3045
-	} else {
3046
-		if (
3047
-			(@filemtime($f) > @filemtime($css))
3048
-			and (_VAR_MODE != 'recalcul')
3049
-		) {
3050
-			return $f;
3051
-		}
3052
-		if (!lire_fichier($css, $contenu)) {
3053
-			return $css;
3054
-		}
3055
-	}
3056
-
3057
-
3058
-	// Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands
3059
-	include_spip('lib/csstidy/class.csstidy');
3060
-	$parser = new csstidy();
3061
-	$parser->set_cfg('optimise_shorthands', 0);
3062
-	$parser->set_cfg('reverse_left_and_right', true);
3063
-	$parser->parse($contenu);
3064
-
3065
-	$contenu = $parser->print->plain();
3066
-
3067
-
3068
-	// reperer les @import auxquels il faut propager le direction_css
3069
-	preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs);
3070
-	$src = [];
3071
-	$src_direction_css = [];
3072
-	$src_faux_abs = [];
3073
-	$d = dirname($css);
3074
-	foreach ($regs[1] as $k => $import_css) {
3075
-		$css_direction = direction_css("$d/$import_css", $voulue);
3076
-		// si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue
3077
-		if (substr($css_direction, 0, strlen($d) + 1) == "$d/") {
3078
-			$css_direction = substr($css_direction, strlen($d) + 1);
3079
-		} // si la css_direction commence par $dir_var on la fait passer pour une absolue
3080
-		elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
3081
-			$css_direction = substr($css_direction, strlen($dir_var));
3082
-			$src_faux_abs['/@@@@@@/' . $css_direction] = $css_direction;
3083
-			$css_direction = '/@@@@@@/' . $css_direction;
3084
-		}
3085
-		$src[] = $regs[0][$k];
3086
-		$src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
3087
-	}
3088
-	$contenu = str_replace($src, $src_direction_css, $contenu);
3089
-
3090
-	$contenu = urls_absolues_css($contenu, $css);
3091
-
3092
-	// virer les fausses url absolues que l'on a mis dans les import
3093
-	if (count($src_faux_abs)) {
3094
-		$contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu);
3095
-	}
3096
-
3097
-	if (!ecrire_fichier($f, $contenu)) {
3098
-		return $css;
3099
-	}
3100
-
3101
-	return $f;
2989
+    if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) {
2990
+        return $css;
2991
+    }
2992
+    include_spip('inc/lang');
2993
+    // si on a precise le sens voulu en argument, le prendre en compte
2994
+    if ($voulue = strtolower($voulue)) {
2995
+        if ($voulue != 'rtl' and $voulue != 'ltr') {
2996
+            $voulue = lang_dir($voulue);
2997
+        }
2998
+    } else {
2999
+        $voulue = lang_dir();
3000
+    }
3001
+
3002
+    $r = count($r) > 1;
3003
+    $right = $r ? 'left' : 'right'; // 'right' de la css lue en entree
3004
+    $dir = $r ? 'rtl' : 'ltr';
3005
+    $ndir = $r ? 'ltr' : 'rtl';
3006
+
3007
+    if ($voulue == $dir) {
3008
+        return $css;
3009
+    }
3010
+
3011
+    if (
3012
+        // url absolue
3013
+        preg_match(',^https?:,i', $css)
3014
+        // ou qui contient un ?
3015
+        or (($p = strpos($css, '?')) !== false)
3016
+    ) {
3017
+        $distant = true;
3018
+        $cssf = parse_url($css);
3019
+        $cssf = $cssf['path'] . ($cssf['query'] ? '?' . $cssf['query'] : '');
3020
+        $cssf = preg_replace(',[?:&=],', '_', $cssf);
3021
+    } else {
3022
+        $distant = false;
3023
+        $cssf = $css;
3024
+        // 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
3025
+        //propose (rien a faire dans ce cas)
3026
+        $f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
3027
+        if (@file_exists($f)) {
3028
+            return $f;
3029
+        }
3030
+    }
3031
+
3032
+    // 2.
3033
+    $dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
3034
+    $f = $dir_var
3035
+        . preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
3036
+        . '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
3037
+
3038
+    // la css peut etre distante (url absolue !)
3039
+    if ($distant) {
3040
+        include_spip('inc/distant');
3041
+        $res = recuperer_url($css);
3042
+        if (!$res or !$contenu = $res['page']) {
3043
+            return $css;
3044
+        }
3045
+    } else {
3046
+        if (
3047
+            (@filemtime($f) > @filemtime($css))
3048
+            and (_VAR_MODE != 'recalcul')
3049
+        ) {
3050
+            return $f;
3051
+        }
3052
+        if (!lire_fichier($css, $contenu)) {
3053
+            return $css;
3054
+        }
3055
+    }
3056
+
3057
+
3058
+    // Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands
3059
+    include_spip('lib/csstidy/class.csstidy');
3060
+    $parser = new csstidy();
3061
+    $parser->set_cfg('optimise_shorthands', 0);
3062
+    $parser->set_cfg('reverse_left_and_right', true);
3063
+    $parser->parse($contenu);
3064
+
3065
+    $contenu = $parser->print->plain();
3066
+
3067
+
3068
+    // reperer les @import auxquels il faut propager le direction_css
3069
+    preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs);
3070
+    $src = [];
3071
+    $src_direction_css = [];
3072
+    $src_faux_abs = [];
3073
+    $d = dirname($css);
3074
+    foreach ($regs[1] as $k => $import_css) {
3075
+        $css_direction = direction_css("$d/$import_css", $voulue);
3076
+        // si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue
3077
+        if (substr($css_direction, 0, strlen($d) + 1) == "$d/") {
3078
+            $css_direction = substr($css_direction, strlen($d) + 1);
3079
+        } // si la css_direction commence par $dir_var on la fait passer pour une absolue
3080
+        elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
3081
+            $css_direction = substr($css_direction, strlen($dir_var));
3082
+            $src_faux_abs['/@@@@@@/' . $css_direction] = $css_direction;
3083
+            $css_direction = '/@@@@@@/' . $css_direction;
3084
+        }
3085
+        $src[] = $regs[0][$k];
3086
+        $src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
3087
+    }
3088
+    $contenu = str_replace($src, $src_direction_css, $contenu);
3089
+
3090
+    $contenu = urls_absolues_css($contenu, $css);
3091
+
3092
+    // virer les fausses url absolues que l'on a mis dans les import
3093
+    if (count($src_faux_abs)) {
3094
+        $contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu);
3095
+    }
3096
+
3097
+    if (!ecrire_fichier($f, $contenu)) {
3098
+        return $css;
3099
+    }
3100
+
3101
+    return $f;
3102 3102
 }
3103 3103
 
3104 3104
 
@@ -3121,46 +3121,46 @@  discard block
 block discarded – undo
3121 3121
  *     - Chemin ou URL du fichier CSS source sinon.
3122 3122
  **/
3123 3123
 function url_absolue_css($css) {
3124
-	if (!preg_match(',\.css$,i', $css, $r)) {
3125
-		return $css;
3126
-	}
3124
+    if (!preg_match(',\.css$,i', $css, $r)) {
3125
+        return $css;
3126
+    }
3127 3127
 
3128
-	$url_absolue_css = url_absolue($css);
3128
+    $url_absolue_css = url_absolue($css);
3129 3129
 
3130
-	$f = basename($css, '.css');
3131
-	$f = sous_repertoire(_DIR_VAR, 'cache-css')
3132
-		. preg_replace(',(.*?)(_rtl|_ltr)?$,', "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
3133
-		. '.css';
3130
+    $f = basename($css, '.css');
3131
+    $f = sous_repertoire(_DIR_VAR, 'cache-css')
3132
+        . preg_replace(',(.*?)(_rtl|_ltr)?$,', "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
3133
+        . '.css';
3134 3134
 
3135
-	if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
3136
-		return $f;
3137
-	}
3135
+    if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
3136
+        return $f;
3137
+    }
3138 3138
 
3139
-	if ($url_absolue_css == $css) {
3140
-		if (
3141
-			strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
3142
-			or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
3143
-		) {
3144
-			include_spip('inc/distant');
3145
-			$contenu = recuperer_url($css);
3146
-			$contenu = $contenu['page'] ?? '';
3147
-			if (!$contenu) {
3148
-				return $css;
3149
-			}
3150
-		}
3151
-	} elseif (!lire_fichier($css, $contenu)) {
3152
-		return $css;
3153
-	}
3139
+    if ($url_absolue_css == $css) {
3140
+        if (
3141
+            strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
3142
+            or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
3143
+        ) {
3144
+            include_spip('inc/distant');
3145
+            $contenu = recuperer_url($css);
3146
+            $contenu = $contenu['page'] ?? '';
3147
+            if (!$contenu) {
3148
+                return $css;
3149
+            }
3150
+        }
3151
+    } elseif (!lire_fichier($css, $contenu)) {
3152
+        return $css;
3153
+    }
3154 3154
 
3155
-	// passer les url relatives a la css d'origine en url absolues
3156
-	$contenu = urls_absolues_css($contenu, $css);
3155
+    // passer les url relatives a la css d'origine en url absolues
3156
+    $contenu = urls_absolues_css($contenu, $css);
3157 3157
 
3158
-	// ecrire la css
3159
-	if (!ecrire_fichier($f, $contenu)) {
3160
-		return $css;
3161
-	}
3158
+    // ecrire la css
3159
+    if (!ecrire_fichier($f, $contenu)) {
3160
+        return $css;
3161
+    }
3162 3162
 
3163
-	return $f;
3163
+    return $f;
3164 3164
 }
3165 3165
 
3166 3166
 
@@ -3194,24 +3194,24 @@  discard block
 block discarded – undo
3194 3194
  *     Valeur trouvée ou valeur par défaut.
3195 3195
  **/
3196 3196
 function table_valeur($table, $cle, $defaut = '', $conserver_null = false) {
3197
-	foreach (explode('/', $cle) as $k) {
3198
-		$table = (is_string($table) ? @unserialize($table) : $table);
3197
+    foreach (explode('/', $cle) as $k) {
3198
+        $table = (is_string($table) ? @unserialize($table) : $table);
3199 3199
 
3200
-		if (is_object($table)) {
3201
-			$table = (($k !== '') and isset($table->$k)) ? $table->$k : $defaut;
3202
-		} elseif (is_array($table)) {
3203
-			if ($conserver_null) {
3204
-				$table = array_key_exists($k, $table) ? $table[$k] : $defaut;
3205
-			} else {
3206
-				$table = ($table[$k] ?? $defaut);
3207
-			}
3208
-		} else {
3209
-			$table = $defaut;
3210
-			break;
3211
-		}
3212
-	}
3200
+        if (is_object($table)) {
3201
+            $table = (($k !== '') and isset($table->$k)) ? $table->$k : $defaut;
3202
+        } elseif (is_array($table)) {
3203
+            if ($conserver_null) {
3204
+                $table = array_key_exists($k, $table) ? $table[$k] : $defaut;
3205
+            } else {
3206
+                $table = ($table[$k] ?? $defaut);
3207
+            }
3208
+        } else {
3209
+            $table = $defaut;
3210
+            break;
3211
+        }
3212
+    }
3213 3213
 
3214
-	return $table;
3214
+    return $table;
3215 3215
 }
3216 3216
 
3217 3217
 /**
@@ -3244,22 +3244,22 @@  discard block
 block discarded – undo
3244 3244
  *     - string : expression trouvée.
3245 3245
  **/
3246 3246
 function filtre_match_dist(?string $texte, $expression, $modif = 'UimsS', $capte = 0) {
3247
-	if (intval($modif) and $capte == 0) {
3248
-		$capte = $modif;
3249
-		$modif = 'UimsS';
3250
-	}
3251
-	$expression = str_replace('\/', '/', $expression);
3252
-	$expression = str_replace('/', '\/', $expression);
3247
+    if (intval($modif) and $capte == 0) {
3248
+        $capte = $modif;
3249
+        $modif = 'UimsS';
3250
+    }
3251
+    $expression = str_replace('\/', '/', $expression);
3252
+    $expression = str_replace('/', '\/', $expression);
3253 3253
 
3254
-	if (preg_match('/' . $expression . '/' . $modif, $texte ?? '', $r)) {
3255
-		if (isset($r[$capte])) {
3256
-			return $r[$capte];
3257
-		} else {
3258
-			return true;
3259
-		}
3260
-	}
3254
+    if (preg_match('/' . $expression . '/' . $modif, $texte ?? '', $r)) {
3255
+        if (isset($r[$capte])) {
3256
+            return $r[$capte];
3257
+        } else {
3258
+            return true;
3259
+        }
3260
+    }
3261 3261
 
3262
-	return false;
3262
+    return false;
3263 3263
 }
3264 3264
 
3265 3265
 
@@ -3286,10 +3286,10 @@  discard block
 block discarded – undo
3286 3286
  *     Texte
3287 3287
  **/
3288 3288
 function replace($texte, $expression, $replace = '', $modif = 'UimsS') {
3289
-	$expression = str_replace('\/', '/', $expression);
3290
-	$expression = str_replace('/', '\/', $expression);
3289
+    $expression = str_replace('\/', '/', $expression);
3290
+    $expression = str_replace('/', '\/', $expression);
3291 3291
 
3292
-	return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3292
+    return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3293 3293
 }
3294 3294
 
3295 3295
 
@@ -3307,25 +3307,25 @@  discard block
 block discarded – undo
3307 3307
  **/
3308 3308
 function traiter_doublons_documents(&$doublons, $letexte) {
3309 3309
 
3310
-	// Verifier dans le texte & les notes (pas beau, helas)
3311
-	$t = $letexte . $GLOBALS['les_notes'];
3310
+    // Verifier dans le texte & les notes (pas beau, helas)
3311
+    $t = $letexte . $GLOBALS['les_notes'];
3312 3312
 
3313
-	if (
3314
-		strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3315
-		and preg_match_all(
3316
-			',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS',
3317
-			$t,
3318
-			$matches,
3319
-			PREG_PATTERN_ORDER
3320
-		)
3321
-	) {
3322
-		if (!isset($doublons['documents'])) {
3323
-			$doublons['documents'] = '';
3324
-		}
3325
-		$doublons['documents'] .= ',' . join(',', $matches[1]);
3326
-	}
3313
+    if (
3314
+        strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3315
+        and preg_match_all(
3316
+            ',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS',
3317
+            $t,
3318
+            $matches,
3319
+            PREG_PATTERN_ORDER
3320
+        )
3321
+    ) {
3322
+        if (!isset($doublons['documents'])) {
3323
+            $doublons['documents'] = '';
3324
+        }
3325
+        $doublons['documents'] .= ',' . join(',', $matches[1]);
3326
+    }
3327 3327
 
3328
-	return $letexte;
3328
+    return $letexte;
3329 3329
 }
3330 3330
 
3331 3331
 /**
@@ -3339,7 +3339,7 @@  discard block
 block discarded – undo
3339 3339
  * @return string Chaîne vide
3340 3340
  **/
3341 3341
 function vide($texte) {
3342
-	return '';
3342
+    return '';
3343 3343
 }
3344 3344
 
3345 3345
 //
@@ -3368,23 +3368,23 @@  discard block
 block discarded – undo
3368 3368
  *      Code HTML résultant
3369 3369
  **/
3370 3370
 function env_to_params($env, $ignore_params = []) {
3371
-	$ignore_params = array_merge(
3372
-		['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'],
3373
-		$ignore_params
3374
-	);
3375
-	if (!is_array($env)) {
3376
-		$env = unserialize($env);
3377
-	}
3378
-	$texte = '';
3379
-	if ($env) {
3380
-		foreach ($env as $i => $j) {
3381
-			if (is_string($j) and !in_array($i, $ignore_params)) {
3382
-				$texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3383
-			}
3384
-		}
3385
-	}
3386
-
3387
-	return $texte;
3371
+    $ignore_params = array_merge(
3372
+        ['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'],
3373
+        $ignore_params
3374
+    );
3375
+    if (!is_array($env)) {
3376
+        $env = unserialize($env);
3377
+    }
3378
+    $texte = '';
3379
+    if ($env) {
3380
+        foreach ($env as $i => $j) {
3381
+            if (is_string($j) and !in_array($i, $ignore_params)) {
3382
+                $texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3383
+            }
3384
+        }
3385
+    }
3386
+
3387
+    return $texte;
3388 3388
 }
3389 3389
 
3390 3390
 /**
@@ -3407,23 +3407,23 @@  discard block
 block discarded – undo
3407 3407
  *      Code HTML résultant
3408 3408
  **/
3409 3409
 function env_to_attributs($env, $ignore_params = []) {
3410
-	$ignore_params = array_merge(
3411
-		['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'],
3412
-		$ignore_params
3413
-	);
3414
-	if (!is_array($env)) {
3415
-		$env = unserialize($env);
3416
-	}
3417
-	$texte = '';
3418
-	if ($env) {
3419
-		foreach ($env as $i => $j) {
3420
-			if (is_string($j) and !in_array($i, $ignore_params)) {
3421
-				$texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3422
-			}
3423
-		}
3424
-	}
3410
+    $ignore_params = array_merge(
3411
+        ['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'],
3412
+        $ignore_params
3413
+    );
3414
+    if (!is_array($env)) {
3415
+        $env = unserialize($env);
3416
+    }
3417
+    $texte = '';
3418
+    if ($env) {
3419
+        foreach ($env as $i => $j) {
3420
+            if (is_string($j) and !in_array($i, $ignore_params)) {
3421
+                $texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3422
+            }
3423
+        }
3424
+    }
3425 3425
 
3426
-	return $texte;
3426
+    return $texte;
3427 3427
 }
3428 3428
 
3429 3429
 
@@ -3441,7 +3441,7 @@  discard block
 block discarded – undo
3441 3441
  * @return string Chaînes concaténés
3442 3442
  **/
3443 3443
 function concat(...$args): string {
3444
-	return join('', $args);
3444
+    return join('', $args);
3445 3445
 }
3446 3446
 
3447 3447
 
@@ -3461,23 +3461,23 @@  discard block
 block discarded – undo
3461 3461
  *     Contenu du ou des fichiers, concaténé
3462 3462
  **/
3463 3463
 function charge_scripts($files, $script = true) {
3464
-	$flux = '';
3465
-	foreach (is_array($files) ? $files : explode('|', $files) as $file) {
3466
-		if (!is_string($file)) {
3467
-			continue;
3468
-		}
3469
-		if ($script) {
3470
-			$file = preg_match(',^\w+$,', $file) ? "javascript/$file.js" : '';
3471
-		}
3472
-		if ($file) {
3473
-			$path = find_in_path($file);
3474
-			if ($path) {
3475
-				$flux .= spip_file_get_contents($path);
3476
-			}
3477
-		}
3478
-	}
3479
-
3480
-	return $flux;
3464
+    $flux = '';
3465
+    foreach (is_array($files) ? $files : explode('|', $files) as $file) {
3466
+        if (!is_string($file)) {
3467
+            continue;
3468
+        }
3469
+        if ($script) {
3470
+            $file = preg_match(',^\w+$,', $file) ? "javascript/$file.js" : '';
3471
+        }
3472
+        if ($file) {
3473
+            $path = find_in_path($file);
3474
+            if ($path) {
3475
+                $flux .= spip_file_get_contents($path);
3476
+            }
3477
+        }
3478
+    }
3479
+
3480
+    return $flux;
3481 3481
 }
3482 3482
 
3483 3483
 /**
@@ -3488,22 +3488,22 @@  discard block
 block discarded – undo
3488 3488
  * @return string
3489 3489
  */
3490 3490
 function http_img_variante_svg_si_possible($img_file) {
3491
-	// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3492
-	// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3493
-	if (
3494
-		preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3495
-		and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . '-xx.svg'
3496
-		and file_exists($variante_svg_generique)
3497
-	) {
3498
-		if ($variante_svg_size = substr($variante_svg_generique, 0, -6) . $m[1] . '.svg' and file_exists($variante_svg_size)) {
3499
-			$img_file = $variante_svg_size;
3500
-		}
3501
-		else {
3502
-			$img_file = $variante_svg_generique;
3503
-		}
3504
-	}
3491
+    // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3492
+    // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3493
+    if (
3494
+        preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3495
+        and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . '-xx.svg'
3496
+        and file_exists($variante_svg_generique)
3497
+    ) {
3498
+        if ($variante_svg_size = substr($variante_svg_generique, 0, -6) . $m[1] . '.svg' and file_exists($variante_svg_size)) {
3499
+            $img_file = $variante_svg_size;
3500
+        }
3501
+        else {
3502
+            $img_file = $variante_svg_generique;
3503
+        }
3504
+    }
3505 3505
 
3506
-	return $img_file;
3506
+    return $img_file;
3507 3507
 }
3508 3508
 
3509 3509
 /**
@@ -3524,54 +3524,54 @@  discard block
 block discarded – undo
3524 3524
  */
3525 3525
 function http_img_pack($img, $alt, $atts = '', $title = '', $options = []) {
3526 3526
 
3527
-	$img_file = $img;
3528
-	if ($p = strpos($img_file, '?')) {
3529
-		$img_file = substr($img_file, 0, $p);
3530
-	}
3531
-	if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3532
-		$img_file = chemin_image($img);
3533
-	}
3534
-	else {
3535
-		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true) {
3536
-			$img_file = http_img_variante_svg_si_possible($img_file);
3537
-		}
3538
-	}
3539
-	if (stripos($atts, 'width') === false) {
3540
-		// utiliser directement l'info de taille presente dans le nom
3541
-		if (
3542
-			(!isset($options['utiliser_suffixe_size'])
3543
-				or $options['utiliser_suffixe_size'] == true
3544
-			  or strpos($img_file, '-xx.svg') !== false)
3545
-			and (preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs)
3546
-					 or preg_match(',\?([0-9]+)px$,', $img, $regs))
3547
-		) {
3548
-			$largeur = $hauteur = intval($regs[1]);
3549
-		} else {
3550
-			$taille = taille_image($img_file);
3551
-			[$hauteur, $largeur] = $taille;
3552
-			if (!$hauteur or !$largeur) {
3553
-				return '';
3554
-			}
3555
-		}
3556
-		$atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3557
-	}
3558
-
3559
-	if (file_exists($img_file)) {
3560
-		$img_file = timestamp($img_file);
3561
-	}
3562
-	if ($alt === false) {
3563
-		$alt = '';
3564
-	}
3565
-	elseif ($alt or $alt === '') {
3566
-		$alt = " alt='" . attribut_html($alt) . "'";
3567
-	}
3568
-	else {
3569
-		$alt = " alt='" . attribut_html($title) . "'";
3570
-	}
3571
-	return "<img src='$img_file'$alt"
3572
-	. ($title ? ' title="' . attribut_html($title) . '"' : '')
3573
-	. ' ' . ltrim($atts)
3574
-	. ' />';
3527
+    $img_file = $img;
3528
+    if ($p = strpos($img_file, '?')) {
3529
+        $img_file = substr($img_file, 0, $p);
3530
+    }
3531
+    if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3532
+        $img_file = chemin_image($img);
3533
+    }
3534
+    else {
3535
+        if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true) {
3536
+            $img_file = http_img_variante_svg_si_possible($img_file);
3537
+        }
3538
+    }
3539
+    if (stripos($atts, 'width') === false) {
3540
+        // utiliser directement l'info de taille presente dans le nom
3541
+        if (
3542
+            (!isset($options['utiliser_suffixe_size'])
3543
+                or $options['utiliser_suffixe_size'] == true
3544
+              or strpos($img_file, '-xx.svg') !== false)
3545
+            and (preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs)
3546
+                     or preg_match(',\?([0-9]+)px$,', $img, $regs))
3547
+        ) {
3548
+            $largeur = $hauteur = intval($regs[1]);
3549
+        } else {
3550
+            $taille = taille_image($img_file);
3551
+            [$hauteur, $largeur] = $taille;
3552
+            if (!$hauteur or !$largeur) {
3553
+                return '';
3554
+            }
3555
+        }
3556
+        $atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3557
+    }
3558
+
3559
+    if (file_exists($img_file)) {
3560
+        $img_file = timestamp($img_file);
3561
+    }
3562
+    if ($alt === false) {
3563
+        $alt = '';
3564
+    }
3565
+    elseif ($alt or $alt === '') {
3566
+        $alt = " alt='" . attribut_html($alt) . "'";
3567
+    }
3568
+    else {
3569
+        $alt = " alt='" . attribut_html($title) . "'";
3570
+    }
3571
+    return "<img src='$img_file'$alt"
3572
+    . ($title ? ' title="' . attribut_html($title) . '"' : '')
3573
+    . ' ' . ltrim($atts)
3574
+    . ' />';
3575 3575
 }
3576 3576
 
3577 3577
 /**
@@ -3583,70 +3583,70 @@  discard block
 block discarded – undo
3583 3583
  * @return string
3584 3584
  */
3585 3585
 function http_style_background($img, $att = '', $size = null) {
3586
-	if ($size and is_numeric($size)) {
3587
-		$size = trim($size) . 'px';
3588
-	}
3589
-	return " style='background" .
3590
-		($att ? '' : '-image') . ': url("' . chemin_image($img) . '")' . ($att ? (' ' . $att) : '') . ';'
3591
-		. ($size ? "background-size:{$size};" : '')
3592
-		. "'";
3586
+    if ($size and is_numeric($size)) {
3587
+        $size = trim($size) . 'px';
3588
+    }
3589
+    return " style='background" .
3590
+        ($att ? '' : '-image') . ': url("' . chemin_image($img) . '")' . ($att ? (' ' . $att) : '') . ';'
3591
+        . ($size ? "background-size:{$size};" : '')
3592
+        . "'";
3593 3593
 }
3594 3594
 
3595 3595
 
3596 3596
 function helper_filtre_balise_img_svg_arguments($alt_or_size, $class_or_size, $size) {
3597
-	$args = [$alt_or_size, $class_or_size, $size];
3598
-	while (is_null(end($args)) and count($args)) {
3599
-		array_pop($args);
3600
-	}
3601
-	if (!count($args)) {
3602
-		return [null, null, null];
3603
-	}
3604
-	if (count($args) < 3) {
3605
-		$maybe_size = array_pop($args);
3606
-		// @2x
3607
-		// @1.5x
3608
-		// 512
3609
-		// 512x*
3610
-		// 512x300
3611
-		if (
3612
-			!strlen($maybe_size)
3613
-			or !preg_match(',^(@\d+(\.\d+)?x|\d+(x\*)?|\d+x\d+)$,', trim($maybe_size))
3614
-		) {
3615
-			$args[] = $maybe_size;
3616
-			$maybe_size = null;
3617
-		}
3618
-		while (count($args) < 2) {
3619
-			$args[] = null; // default alt or class
3620
-		}
3621
-		$args[] = $maybe_size;
3622
-	}
3623
-	return $args;
3597
+    $args = [$alt_or_size, $class_or_size, $size];
3598
+    while (is_null(end($args)) and count($args)) {
3599
+        array_pop($args);
3600
+    }
3601
+    if (!count($args)) {
3602
+        return [null, null, null];
3603
+    }
3604
+    if (count($args) < 3) {
3605
+        $maybe_size = array_pop($args);
3606
+        // @2x
3607
+        // @1.5x
3608
+        // 512
3609
+        // 512x*
3610
+        // 512x300
3611
+        if (
3612
+            !strlen($maybe_size)
3613
+            or !preg_match(',^(@\d+(\.\d+)?x|\d+(x\*)?|\d+x\d+)$,', trim($maybe_size))
3614
+        ) {
3615
+            $args[] = $maybe_size;
3616
+            $maybe_size = null;
3617
+        }
3618
+        while (count($args) < 2) {
3619
+            $args[] = null; // default alt or class
3620
+        }
3621
+        $args[] = $maybe_size;
3622
+    }
3623
+    return $args;
3624 3624
 }
3625 3625
 
3626 3626
 function helper_filtre_balise_img_svg_size($img, $size) {
3627
-	// si size est de la forme '@2x' c'est un coeff multiplicateur sur la densite
3628
-	if (strpos($size, '@') === 0 and substr($size, -1) === 'x') {
3629
-		$coef = floatval(substr($size, 1, -1));
3630
-		[$h, $w] = taille_image($img);
3631
-		$height = intval(round($h / $coef));
3632
-		$width = intval(round($w / $coef));
3633
-	}
3634
-	// sinon c'est une valeur seule si image caree ou largeurxhauteur
3635
-	else {
3636
-		$size = explode('x', $size, 2);
3637
-		$size = array_map('trim', $size);
3638
-		$height = $width = intval(array_shift($size));
3639
-
3640
-		if (count($size) and reset($size)) {
3641
-			$height = array_shift($size);
3642
-			if ($height === '*') {
3643
-				[$h, $w] = taille_image($img);
3644
-				$height = intval(round($h * $width / $w));
3645
-			}
3646
-		}
3647
-	}
3648
-
3649
-	return [$width, $height];
3627
+    // si size est de la forme '@2x' c'est un coeff multiplicateur sur la densite
3628
+    if (strpos($size, '@') === 0 and substr($size, -1) === 'x') {
3629
+        $coef = floatval(substr($size, 1, -1));
3630
+        [$h, $w] = taille_image($img);
3631
+        $height = intval(round($h / $coef));
3632
+        $width = intval(round($w / $coef));
3633
+    }
3634
+    // sinon c'est une valeur seule si image caree ou largeurxhauteur
3635
+    else {
3636
+        $size = explode('x', $size, 2);
3637
+        $size = array_map('trim', $size);
3638
+        $height = $width = intval(array_shift($size));
3639
+
3640
+        if (count($size) and reset($size)) {
3641
+            $height = array_shift($size);
3642
+            if ($height === '*') {
3643
+                [$h, $w] = taille_image($img);
3644
+                $height = intval(round($h * $width / $w));
3645
+            }
3646
+        }
3647
+    }
3648
+
3649
+    return [$width, $height];
3650 3650
 }
3651 3651
 
3652 3652
 /**
@@ -3682,43 +3682,43 @@  discard block
 block discarded – undo
3682 3682
  */
3683 3683
 function filtre_balise_img_dist($img, $alt = '', $class = null, $size = null) {
3684 3684
 
3685
-	[$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3686
-
3687
-	$img = trim($img);
3688
-	if (strpos($img, '<img') === 0) {
3689
-		if (!is_null($alt)) {
3690
-			$img = inserer_attribut($img, 'alt', $alt);
3691
-		}
3692
-		if (!is_null($class)) {
3693
-			if (strlen($class)) {
3694
-				$img = inserer_attribut($img, 'class', $class);
3695
-			}
3696
-			else {
3697
-				$img = vider_attribut($img, 'class');
3698
-			}
3699
-		}
3700
-	}
3701
-	else {
3702
-		$img = http_img_pack(
3703
-			$img,
3704
-			$alt,
3705
-			$class ? " class='" . attribut_html($class) . "'" : '',
3706
-			'',
3707
-			['chemin_image' => false, 'utiliser_suffixe_size' => false]
3708
-		);
3709
-		if (is_null($alt)) {
3710
-			$img = vider_attribut($img, 'alt');
3711
-		}
3712
-	}
3713
-
3714
-	if ($img and !is_null($size) and strlen($size = trim($size))) {
3715
-		[$width, $height] = helper_filtre_balise_img_svg_size($img, $size);
3716
-
3717
-		$img = inserer_attribut($img, 'width', $width);
3718
-		$img = inserer_attribut($img, 'height', $height);
3719
-	}
3720
-
3721
-	return $img;
3685
+    [$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3686
+
3687
+    $img = trim($img);
3688
+    if (strpos($img, '<img') === 0) {
3689
+        if (!is_null($alt)) {
3690
+            $img = inserer_attribut($img, 'alt', $alt);
3691
+        }
3692
+        if (!is_null($class)) {
3693
+            if (strlen($class)) {
3694
+                $img = inserer_attribut($img, 'class', $class);
3695
+            }
3696
+            else {
3697
+                $img = vider_attribut($img, 'class');
3698
+            }
3699
+        }
3700
+    }
3701
+    else {
3702
+        $img = http_img_pack(
3703
+            $img,
3704
+            $alt,
3705
+            $class ? " class='" . attribut_html($class) . "'" : '',
3706
+            '',
3707
+            ['chemin_image' => false, 'utiliser_suffixe_size' => false]
3708
+        );
3709
+        if (is_null($alt)) {
3710
+            $img = vider_attribut($img, 'alt');
3711
+        }
3712
+    }
3713
+
3714
+    if ($img and !is_null($size) and strlen($size = trim($size))) {
3715
+        [$width, $height] = helper_filtre_balise_img_svg_size($img, $size);
3716
+
3717
+        $img = inserer_attribut($img, 'width', $width);
3718
+        $img = inserer_attribut($img, 'height', $height);
3719
+    }
3720
+
3721
+    return $img;
3722 3722
 }
3723 3723
 
3724 3724
 
@@ -3752,80 +3752,80 @@  discard block
 block discarded – undo
3752 3752
  */
3753 3753
 function filtre_balise_svg_dist($img, $alt = '', $class = null, $size = null) {
3754 3754
 
3755
-	$svg = null;
3756
-	$img = trim($img);
3757
-	$img_file = $img;
3758
-	if (strpos($img, '<svg') === false) {
3759
-		if ($p = strpos($img_file, '?')) {
3760
-			$img_file = substr($img_file, 0, $p);
3761
-		}
3762
-
3763
-		// ne jamais operer directement sur une image distante pour des raisons de perfo
3764
-		// la copie locale a toutes les chances d'etre la ou de resservir
3765
-		if (tester_url_absolue($img_file)) {
3766
-			include_spip('inc/distant');
3767
-			$fichier = copie_locale($img_file);
3768
-			$img_file = ($fichier ? _DIR_RACINE . $fichier : $img_file);
3769
-		}
3770
-
3771
-		if (
3772
-			!$img_file
3773
-			or !file_exists($img_file)
3774
-			or !$svg = file_get_contents($img_file)
3775
-		) {
3776
-			return '';
3777
-		}
3778
-	}
3779
-
3780
-	if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) {
3781
-		return '';
3782
-	}
3783
-
3784
-	[$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3785
-
3786
-	$balise_svg = $match[0];
3787
-	$balise_svg_source = $balise_svg;
3788
-
3789
-	// entete XML à supprimer
3790
-	$svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3791
-
3792
-	// IE est toujours mon ami
3793
-	$balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3794
-
3795
-	// regler la classe
3796
-	if (!is_null($class)) {
3797
-		if (strlen($class)) {
3798
-			$balise_svg = inserer_attribut($balise_svg, 'class', $class);
3799
-		}
3800
-		else {
3801
-			$balise_svg = vider_attribut($balise_svg, 'class');
3802
-		}
3803
-	}
3804
-
3805
-	// regler le alt
3806
-	if ($alt) {
3807
-		$balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3808
-		$id = 'img-svg-title-' . substr(md5("$img_file:$svg:$alt"), 0, 4);
3809
-		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3810
-		$title = "<title id=\"$id\">" . entites_html($alt) . "</title>\n";
3811
-		$balise_svg .= $title;
3812
-	}
3813
-	else {
3814
-		$balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3815
-	}
3816
-
3817
-	$svg = str_replace($balise_svg_source, $balise_svg, $svg);
3818
-
3819
-	if (!is_null($size) and strlen($size = trim($size))) {
3820
-		[$width, $height] = helper_filtre_balise_img_svg_size($svg, $size);
3821
-
3822
-		if (!function_exists('svg_redimensionner')) {
3823
-			include_spip('inc/svg');
3824
-		}
3825
-		$svg = svg_redimensionner($svg, $width, $height);
3826
-	}
3827
-
3828
-	return $svg;
3755
+    $svg = null;
3756
+    $img = trim($img);
3757
+    $img_file = $img;
3758
+    if (strpos($img, '<svg') === false) {
3759
+        if ($p = strpos($img_file, '?')) {
3760
+            $img_file = substr($img_file, 0, $p);
3761
+        }
3762
+
3763
+        // ne jamais operer directement sur une image distante pour des raisons de perfo
3764
+        // la copie locale a toutes les chances d'etre la ou de resservir
3765
+        if (tester_url_absolue($img_file)) {
3766
+            include_spip('inc/distant');
3767
+            $fichier = copie_locale($img_file);
3768
+            $img_file = ($fichier ? _DIR_RACINE . $fichier : $img_file);
3769
+        }
3770
+
3771
+        if (
3772
+            !$img_file
3773
+            or !file_exists($img_file)
3774
+            or !$svg = file_get_contents($img_file)
3775
+        ) {
3776
+            return '';
3777
+        }
3778
+    }
3779
+
3780
+    if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) {
3781
+        return '';
3782
+    }
3783
+
3784
+    [$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3785
+
3786
+    $balise_svg = $match[0];
3787
+    $balise_svg_source = $balise_svg;
3788
+
3789
+    // entete XML à supprimer
3790
+    $svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3791
+
3792
+    // IE est toujours mon ami
3793
+    $balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3794
+
3795
+    // regler la classe
3796
+    if (!is_null($class)) {
3797
+        if (strlen($class)) {
3798
+            $balise_svg = inserer_attribut($balise_svg, 'class', $class);
3799
+        }
3800
+        else {
3801
+            $balise_svg = vider_attribut($balise_svg, 'class');
3802
+        }
3803
+    }
3804
+
3805
+    // regler le alt
3806
+    if ($alt) {
3807
+        $balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3808
+        $id = 'img-svg-title-' . substr(md5("$img_file:$svg:$alt"), 0, 4);
3809
+        $balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3810
+        $title = "<title id=\"$id\">" . entites_html($alt) . "</title>\n";
3811
+        $balise_svg .= $title;
3812
+    }
3813
+    else {
3814
+        $balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3815
+    }
3816
+
3817
+    $svg = str_replace($balise_svg_source, $balise_svg, $svg);
3818
+
3819
+    if (!is_null($size) and strlen($size = trim($size))) {
3820
+        [$width, $height] = helper_filtre_balise_img_svg_size($svg, $size);
3821
+
3822
+        if (!function_exists('svg_redimensionner')) {
3823
+            include_spip('inc/svg');
3824
+        }
3825
+        $svg = svg_redimensionner($svg, $width, $height);
3826
+    }
3827
+
3828
+    return $svg;
3829 3829
 }
3830 3830
 
3831 3831
 
@@ -3851,18 +3851,18 @@  discard block
 block discarded – undo
3851 3851
  *     Code HTML résultant
3852 3852
  **/
3853 3853
 function filtre_foreach_dist($tableau, $modele = 'foreach') {
3854
-	$texte = '';
3855
-	if (is_array($tableau)) {
3856
-		foreach ($tableau as $k => $v) {
3857
-			$res = recuperer_fond(
3858
-				'modeles/' . $modele,
3859
-				array_merge(['cle' => $k], (is_array($v) ? $v : ['valeur' => $v]))
3860
-			);
3861
-			$texte .= $res;
3862
-		}
3863
-	}
3854
+    $texte = '';
3855
+    if (is_array($tableau)) {
3856
+        foreach ($tableau as $k => $v) {
3857
+            $res = recuperer_fond(
3858
+                'modeles/' . $modele,
3859
+                array_merge(['cle' => $k], (is_array($v) ? $v : ['valeur' => $v]))
3860
+            );
3861
+            $texte .= $res;
3862
+        }
3863
+    }
3864 3864
 
3865
-	return $texte;
3865
+    return $texte;
3866 3866
 }
3867 3867
 
3868 3868
 
@@ -3887,37 +3887,37 @@  discard block
 block discarded – undo
3887 3887
  *         - tout : retourne toutes les informations du plugin actif
3888 3888
  **/
3889 3889
 function filtre_info_plugin_dist($plugin, $type_info, $reload = false) {
3890
-	include_spip('inc/plugin');
3891
-	$plugin = strtoupper($plugin);
3892
-	$plugins_actifs = liste_plugin_actifs();
3893
-
3894
-	if (!$plugin) {
3895
-		return serialize(array_keys($plugins_actifs));
3896
-	} elseif (empty($plugins_actifs[$plugin]) and !$reload) {
3897
-		return '';
3898
-	} elseif (($type_info == 'est_actif') and !$reload) {
3899
-		return $plugins_actifs[$plugin] ? 1 : 0;
3900
-	} elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) {
3901
-		return $plugins_actifs[$plugin][$type_info];
3902
-	} else {
3903
-		$get_infos = charger_fonction('get_infos', 'plugins');
3904
-		// On prend en compte les extensions
3905
-		if (!is_dir($plugins_actifs[$plugin]['dir_type'])) {
3906
-			$dir_plugins = constant($plugins_actifs[$plugin]['dir_type']);
3907
-		} else {
3908
-			$dir_plugins = $plugins_actifs[$plugin]['dir_type'];
3909
-		}
3910
-		if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) {
3911
-			return '';
3912
-		}
3913
-		if ($type_info == 'tout') {
3914
-			return $infos;
3915
-		} elseif ($type_info == 'est_actif') {
3916
-			return $infos ? 1 : 0;
3917
-		} else {
3918
-			return strval($infos[$type_info]);
3919
-		}
3920
-	}
3890
+    include_spip('inc/plugin');
3891
+    $plugin = strtoupper($plugin);
3892
+    $plugins_actifs = liste_plugin_actifs();
3893
+
3894
+    if (!$plugin) {
3895
+        return serialize(array_keys($plugins_actifs));
3896
+    } elseif (empty($plugins_actifs[$plugin]) and !$reload) {
3897
+        return '';
3898
+    } elseif (($type_info == 'est_actif') and !$reload) {
3899
+        return $plugins_actifs[$plugin] ? 1 : 0;
3900
+    } elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) {
3901
+        return $plugins_actifs[$plugin][$type_info];
3902
+    } else {
3903
+        $get_infos = charger_fonction('get_infos', 'plugins');
3904
+        // On prend en compte les extensions
3905
+        if (!is_dir($plugins_actifs[$plugin]['dir_type'])) {
3906
+            $dir_plugins = constant($plugins_actifs[$plugin]['dir_type']);
3907
+        } else {
3908
+            $dir_plugins = $plugins_actifs[$plugin]['dir_type'];
3909
+        }
3910
+        if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) {
3911
+            return '';
3912
+        }
3913
+        if ($type_info == 'tout') {
3914
+            return $infos;
3915
+        } elseif ($type_info == 'est_actif') {
3916
+            return $infos ? 1 : 0;
3917
+        } else {
3918
+            return strval($infos[$type_info]);
3919
+        }
3920
+    }
3921 3921
 }
3922 3922
 
3923 3923
 
@@ -3944,9 +3944,9 @@  discard block
 block discarded – undo
3944 3944
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
3945 3945
  */
3946 3946
 function puce_changement_statut($id_objet, $statut, $id_rubrique, $type, $ajax = false) {
3947
-	$puce_statut = charger_fonction('puce_statut', 'inc');
3947
+    $puce_statut = charger_fonction('puce_statut', 'inc');
3948 3948
 
3949
-	return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax);
3949
+    return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax);
3950 3950
 }
3951 3951
 
3952 3952
 
@@ -3976,19 +3976,19 @@  discard block
 block discarded – undo
3976 3976
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
3977 3977
  */
3978 3978
 function filtre_puce_statut_dist($statut, $objet, $id_objet = 0, $id_parent = 0) {
3979
-	static $puce_statut = null;
3980
-	if (!$puce_statut) {
3981
-		$puce_statut = charger_fonction('puce_statut', 'inc');
3982
-	}
3979
+    static $puce_statut = null;
3980
+    if (!$puce_statut) {
3981
+        $puce_statut = charger_fonction('puce_statut', 'inc');
3982
+    }
3983 3983
 
3984
-	return $puce_statut(
3985
-		$id_objet,
3986
-		$statut,
3987
-		$id_parent,
3988
-		$objet,
3989
-		false,
3990
-		objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false
3991
-	);
3984
+    return $puce_statut(
3985
+        $id_objet,
3986
+        $statut,
3987
+        $id_parent,
3988
+        $objet,
3989
+        false,
3990
+        objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false
3991
+    );
3992 3992
 }
3993 3993
 
3994 3994
 
@@ -4015,98 +4015,98 @@  discard block
 block discarded – undo
4015 4015
  *   hash du contexte
4016 4016
  */
4017 4017
 function encoder_contexte_ajax($c, $form = '', $emboite = null, $ajaxid = '') {
4018
-	$env = null;
4019
-	if (
4020
-		is_string($c)
4021
-		and @unserialize($c) !== false
4022
-	) {
4023
-		$c = unserialize($c);
4024
-	}
4025
-
4026
-	// supprimer les parametres debut_x
4027
-	// pour que la pagination ajax ne soit pas plantee
4028
-	// si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0,
4029
-	// le debut_x=0 n'existe pas, et on resterait sur 1
4030
-	if (is_array($c)) {
4031
-		foreach ($c as $k => $v) {
4032
-			if (strpos($k, 'debut_') === 0) {
4033
-				unset($c[$k]);
4034
-			}
4035
-		}
4036
-	}
4037
-
4038
-	if (!function_exists('calculer_cle_action')) {
4039
-		include_spip('inc/securiser_action');
4040
-	}
4041
-
4042
-	$c = serialize($c);
4043
-	$cle = calculer_cle_action($form . $c);
4044
-	$c = "$cle:$c";
4045
-
4046
-	// on ne stocke pas les contextes dans des fichiers en cache
4047
-	// par defaut, sauf si cette configuration a été forcée
4048
-	// OU que la longueur de l’argument géneré est plus long
4049
-	// que ce qui est toléré.
4050
-	$cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX);
4051
-	if (!$cache_contextes_ajax) {
4052
-		$env = $c;
4053
-		if (function_exists('gzdeflate') && function_exists('gzinflate')) {
4054
-			$env = gzdeflate($env);
4055
-		}
4056
-		$env = _xor($env);
4057
-		$env = base64_encode($env);
4058
-		$len = strlen($env);
4059
-		// Si l’url est trop longue pour le navigateur
4060
-		$max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR;
4061
-		if ($len > $max_len) {
4062
-			$cache_contextes_ajax = true;
4063
-			spip_log(
4064
-				'Contextes AJAX forces en fichiers !'
4065
-				. ' Cela arrive lorsque la valeur du contexte'
4066
-				. " depasse la longueur maximale autorisee ($max_len). Ici : $len.",
4067
-				_LOG_AVERTISSEMENT
4068
-			);
4069
-		}
4070
-		// Sinon si Suhosin est actif et a une la valeur maximale des variables en GET...
4071
-		elseif (
4072
-			$max_len = @ini_get('suhosin.get.max_value_length')
4073
-			and $max_len < $len
4074
-		) {
4075
-			$cache_contextes_ajax = true;
4076
-			spip_log('Contextes AJAX forces en fichiers !'
4077
-				. ' Cela arrive lorsque la valeur du contexte'
4078
-				. ' depasse la longueur maximale autorisee par Suhosin'
4079
-				. " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len."
4080
-				. ' Vous devriez modifier les parametres de Suhosin'
4081
-				. ' pour accepter au moins 1024 caracteres.', _LOG_AVERTISSEMENT);
4082
-		}
4083
-	}
4084
-
4085
-	if ($cache_contextes_ajax) {
4086
-		$dir = sous_repertoire(_DIR_CACHE, 'contextes');
4087
-		// stocker les contextes sur disque et ne passer qu'un hash dans l'url
4088
-		$md5 = md5($c);
4089
-		ecrire_fichier("$dir/c$md5", $c);
4090
-		$env = $md5;
4091
-	}
4092
-
4093
-	if ($emboite === null) {
4094
-		return $env;
4095
-	}
4096
-	if (!trim($emboite)) {
4097
-		return '';
4098
-	}
4099
-	// toujours encoder l'url source dans le bloc ajax
4100
-	$r = self();
4101
-	$r = ' data-origin="' . $r . '"';
4102
-	$class = 'ajaxbloc';
4103
-	if ($ajaxid and is_string($ajaxid)) {
4104
-		// ajaxid est normalement conforme a un nom de classe css
4105
-		// on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
4106
-		$class .= ' ajax-id-' . entites_html($ajaxid);
4107
-	}
4108
-
4109
-	return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
4018
+    $env = null;
4019
+    if (
4020
+        is_string($c)
4021
+        and @unserialize($c) !== false
4022
+    ) {
4023
+        $c = unserialize($c);
4024
+    }
4025
+
4026
+    // supprimer les parametres debut_x
4027
+    // pour que la pagination ajax ne soit pas plantee
4028
+    // si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0,
4029
+    // le debut_x=0 n'existe pas, et on resterait sur 1
4030
+    if (is_array($c)) {
4031
+        foreach ($c as $k => $v) {
4032
+            if (strpos($k, 'debut_') === 0) {
4033
+                unset($c[$k]);
4034
+            }
4035
+        }
4036
+    }
4037
+
4038
+    if (!function_exists('calculer_cle_action')) {
4039
+        include_spip('inc/securiser_action');
4040
+    }
4041
+
4042
+    $c = serialize($c);
4043
+    $cle = calculer_cle_action($form . $c);
4044
+    $c = "$cle:$c";
4045
+
4046
+    // on ne stocke pas les contextes dans des fichiers en cache
4047
+    // par defaut, sauf si cette configuration a été forcée
4048
+    // OU que la longueur de l’argument géneré est plus long
4049
+    // que ce qui est toléré.
4050
+    $cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX);
4051
+    if (!$cache_contextes_ajax) {
4052
+        $env = $c;
4053
+        if (function_exists('gzdeflate') && function_exists('gzinflate')) {
4054
+            $env = gzdeflate($env);
4055
+        }
4056
+        $env = _xor($env);
4057
+        $env = base64_encode($env);
4058
+        $len = strlen($env);
4059
+        // Si l’url est trop longue pour le navigateur
4060
+        $max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR;
4061
+        if ($len > $max_len) {
4062
+            $cache_contextes_ajax = true;
4063
+            spip_log(
4064
+                'Contextes AJAX forces en fichiers !'
4065
+                . ' Cela arrive lorsque la valeur du contexte'
4066
+                . " depasse la longueur maximale autorisee ($max_len). Ici : $len.",
4067
+                _LOG_AVERTISSEMENT
4068
+            );
4069
+        }
4070
+        // Sinon si Suhosin est actif et a une la valeur maximale des variables en GET...
4071
+        elseif (
4072
+            $max_len = @ini_get('suhosin.get.max_value_length')
4073
+            and $max_len < $len
4074
+        ) {
4075
+            $cache_contextes_ajax = true;
4076
+            spip_log('Contextes AJAX forces en fichiers !'
4077
+                . ' Cela arrive lorsque la valeur du contexte'
4078
+                . ' depasse la longueur maximale autorisee par Suhosin'
4079
+                . " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len."
4080
+                . ' Vous devriez modifier les parametres de Suhosin'
4081
+                . ' pour accepter au moins 1024 caracteres.', _LOG_AVERTISSEMENT);
4082
+        }
4083
+    }
4084
+
4085
+    if ($cache_contextes_ajax) {
4086
+        $dir = sous_repertoire(_DIR_CACHE, 'contextes');
4087
+        // stocker les contextes sur disque et ne passer qu'un hash dans l'url
4088
+        $md5 = md5($c);
4089
+        ecrire_fichier("$dir/c$md5", $c);
4090
+        $env = $md5;
4091
+    }
4092
+
4093
+    if ($emboite === null) {
4094
+        return $env;
4095
+    }
4096
+    if (!trim($emboite)) {
4097
+        return '';
4098
+    }
4099
+    // toujours encoder l'url source dans le bloc ajax
4100
+    $r = self();
4101
+    $r = ' data-origin="' . $r . '"';
4102
+    $class = 'ajaxbloc';
4103
+    if ($ajaxid and is_string($ajaxid)) {
4104
+        // ajaxid est normalement conforme a un nom de classe css
4105
+        // on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
4106
+        $class .= ' ajax-id-' . entites_html($ajaxid);
4107
+    }
4108
+
4109
+    return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
4110 4110
 }
4111 4111
 
4112 4112
 /**
@@ -4126,37 +4126,37 @@  discard block
 block discarded – undo
4126 4126
  *   - false : erreur de décodage
4127 4127
  */
4128 4128
 function decoder_contexte_ajax($c, $form = '') {
4129
-	if (!function_exists('calculer_cle_action')) {
4130
-		include_spip('inc/securiser_action');
4131
-	}
4132
-	if (
4133
-		((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32)
4134
-		and $dir = sous_repertoire(_DIR_CACHE, 'contextes')
4135
-		and lire_fichier("$dir/c$c", $contexte)
4136
-	) {
4137
-		$c = $contexte;
4138
-	} else {
4139
-		$c = @base64_decode($c);
4140
-		$c = _xor($c);
4141
-		if (function_exists('gzdeflate') && function_exists('gzinflate')) {
4142
-			$c = @gzinflate($c);
4143
-		}
4144
-	}
4145
-
4146
-	// extraire la signature en debut de contexte
4147
-	// et la verifier avant de deserializer
4148
-	// format : signature:donneesserializees
4149
-	if ($p = strpos($c, ':')) {
4150
-		$cle = substr($c, 0, $p);
4151
-		$c = substr($c, $p + 1);
4152
-
4153
-		if ($cle == calculer_cle_action($form . $c)) {
4154
-			$env = @unserialize($c);
4155
-			return $env;
4156
-		}
4157
-	}
4158
-
4159
-	return false;
4129
+    if (!function_exists('calculer_cle_action')) {
4130
+        include_spip('inc/securiser_action');
4131
+    }
4132
+    if (
4133
+        ((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32)
4134
+        and $dir = sous_repertoire(_DIR_CACHE, 'contextes')
4135
+        and lire_fichier("$dir/c$c", $contexte)
4136
+    ) {
4137
+        $c = $contexte;
4138
+    } else {
4139
+        $c = @base64_decode($c);
4140
+        $c = _xor($c);
4141
+        if (function_exists('gzdeflate') && function_exists('gzinflate')) {
4142
+            $c = @gzinflate($c);
4143
+        }
4144
+    }
4145
+
4146
+    // extraire la signature en debut de contexte
4147
+    // et la verifier avant de deserializer
4148
+    // format : signature:donneesserializees
4149
+    if ($p = strpos($c, ':')) {
4150
+        $cle = substr($c, 0, $p);
4151
+        $c = substr($c, $p + 1);
4152
+
4153
+        if ($cle == calculer_cle_action($form . $c)) {
4154
+            $env = @unserialize($c);
4155
+            return $env;
4156
+        }
4157
+    }
4158
+
4159
+    return false;
4160 4160
 }
4161 4161
 
4162 4162
 
@@ -4174,20 +4174,20 @@  discard block
 block discarded – undo
4174 4174
  *    Message décrypté ou encrypté
4175 4175
  **/
4176 4176
 function _xor($message, $key = null) {
4177
-	if (is_null($key)) {
4178
-		if (!function_exists('calculer_cle_action')) {
4179
-			include_spip('inc/securiser_action');
4180
-		}
4181
-		$key = pack('H*', calculer_cle_action('_xor'));
4182
-	}
4177
+    if (is_null($key)) {
4178
+        if (!function_exists('calculer_cle_action')) {
4179
+            include_spip('inc/securiser_action');
4180
+        }
4181
+        $key = pack('H*', calculer_cle_action('_xor'));
4182
+    }
4183 4183
 
4184
-	$keylen = strlen($key);
4185
-	$messagelen = strlen($message);
4186
-	for ($i = 0; $i < $messagelen; $i++) {
4187
-		$message[$i] = ~($message[$i] ^ $key[$i % $keylen]);
4188
-	}
4184
+    $keylen = strlen($key);
4185
+    $messagelen = strlen($message);
4186
+    for ($i = 0; $i < $messagelen; $i++) {
4187
+        $message[$i] = ~($message[$i] ^ $key[$i % $keylen]);
4188
+    }
4189 4189
 
4190
-	return $message;
4190
+    return $message;
4191 4191
 }
4192 4192
 
4193 4193
 /**
@@ -4201,7 +4201,7 @@  discard block
 block discarded – undo
4201 4201
  * @return string
4202 4202
  */
4203 4203
 function url_reponse_forum($texte) {
4204
- return $texte;
4204
+    return $texte;
4205 4205
 }
4206 4206
 
4207 4207
 /**
@@ -4215,7 +4215,7 @@  discard block
 block discarded – undo
4215 4215
  * @return string
4216 4216
  */
4217 4217
 function url_rss_forum($texte) {
4218
- return $texte;
4218
+    return $texte;
4219 4219
 }
4220 4220
 
4221 4221
 
@@ -4254,37 +4254,37 @@  discard block
 block discarded – undo
4254 4254
  *   Code HTML
4255 4255
  */
4256 4256
 function lien_ou_expose($url, $libelle = null, $on = false, $class = '', $title = '', $rel = '', $evt = '') {
4257
-	if ($on) {
4258
-		$bal = 'strong';
4259
-		$class = '';
4260
-		$att = '';
4261
-		// si $on passe la balise et optionnelement une ou ++classe
4262
-		// a.active span.selected.active etc....
4263
-		if (is_string($on) and (strncmp($on, 'a', 1) == 0 or strncmp($on, 'span', 4) == 0 or strncmp($on, 'strong', 6) == 0)) {
4264
-			$on = explode('.', $on);
4265
-			// on verifie que c'est exactement une des 3 balises a, span ou strong
4266
-			if (in_array(reset($on), ['a', 'span', 'strong'])) {
4267
-				$bal = array_shift($on);
4268
-				$class = implode(' ', $on);
4269
-				if ($bal == 'a') {
4270
-					$att = 'href="#" ';
4271
-				}
4272
-			}
4273
-		}
4274
-		$att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"';
4275
-	} else {
4276
-		$bal = 'a';
4277
-		$att = "href='$url'"
4278
-			. ($title ? " title='" . attribut_html($title) . "'" : '')
4279
-			. ($class ? " class='" . attribut_html($class) . "'" : '')
4280
-			. ($rel ? " rel='" . attribut_html($rel) . "'" : '')
4281
-			. $evt;
4282
-	}
4283
-	if ($libelle === null) {
4284
-		$libelle = $url;
4285
-	}
4286
-
4287
-	return "<$bal $att>$libelle</$bal>";
4257
+    if ($on) {
4258
+        $bal = 'strong';
4259
+        $class = '';
4260
+        $att = '';
4261
+        // si $on passe la balise et optionnelement une ou ++classe
4262
+        // a.active span.selected.active etc....
4263
+        if (is_string($on) and (strncmp($on, 'a', 1) == 0 or strncmp($on, 'span', 4) == 0 or strncmp($on, 'strong', 6) == 0)) {
4264
+            $on = explode('.', $on);
4265
+            // on verifie que c'est exactement une des 3 balises a, span ou strong
4266
+            if (in_array(reset($on), ['a', 'span', 'strong'])) {
4267
+                $bal = array_shift($on);
4268
+                $class = implode(' ', $on);
4269
+                if ($bal == 'a') {
4270
+                    $att = 'href="#" ';
4271
+                }
4272
+            }
4273
+        }
4274
+        $att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"';
4275
+    } else {
4276
+        $bal = 'a';
4277
+        $att = "href='$url'"
4278
+            . ($title ? " title='" . attribut_html($title) . "'" : '')
4279
+            . ($class ? " class='" . attribut_html($class) . "'" : '')
4280
+            . ($rel ? " rel='" . attribut_html($rel) . "'" : '')
4281
+            . $evt;
4282
+    }
4283
+    if ($libelle === null) {
4284
+        $libelle = $url;
4285
+    }
4286
+
4287
+    return "<$bal $att>$libelle</$bal>";
4288 4288
 }
4289 4289
 
4290 4290
 
@@ -4301,39 +4301,39 @@  discard block
 block discarded – undo
4301 4301
  * @return string : la chaine de langue finale en utilisant la fonction _T()
4302 4302
  */
4303 4303
 function singulier_ou_pluriel($nb, $chaine_un, $chaine_plusieurs, $var = 'nb', $vars = []) {
4304
-	static $local_singulier_ou_pluriel = [];
4305
-
4306
-	// si nb=0 ou pas de $vars valide on retourne une chaine vide, a traiter par un |sinon
4307
-	if (!is_numeric($nb) or $nb == 0) {
4308
-		return '';
4309
-	}
4310
-	if (!is_array($vars)) {
4311
-		return '';
4312
-	}
4313
-
4314
-	$langue = $GLOBALS['spip_lang'];
4315
-	if (!isset($local_singulier_ou_pluriel[$langue])) {
4316
-		$local_singulier_ou_pluriel[$langue] = false;
4317
-		if (
4318
-			$f = charger_fonction("singulier_ou_pluriel_${langue}", 'inc', true)
4319
-			or $f = charger_fonction('singulier_ou_pluriel', 'inc', true)
4320
-		) {
4321
-			$local_singulier_ou_pluriel[$langue] = $f;
4322
-		}
4323
-	}
4324
-
4325
-	// si on a une surcharge on l'utilise
4326
-	if ($local_singulier_ou_pluriel[$langue]) {
4327
-		return ($local_singulier_ou_pluriel[$langue])($nb, $chaine_un, $chaine_plusieurs, $var, $vars);
4328
-	}
4329
-
4330
-	// sinon traitement par defaut
4331
-	$vars[$var] = $nb;
4332
-	if ($nb >= 2) {
4333
-		return _T($chaine_plusieurs, $vars);
4334
-	} else {
4335
-		return _T($chaine_un, $vars);
4336
-	}
4304
+    static $local_singulier_ou_pluriel = [];
4305
+
4306
+    // si nb=0 ou pas de $vars valide on retourne une chaine vide, a traiter par un |sinon
4307
+    if (!is_numeric($nb) or $nb == 0) {
4308
+        return '';
4309
+    }
4310
+    if (!is_array($vars)) {
4311
+        return '';
4312
+    }
4313
+
4314
+    $langue = $GLOBALS['spip_lang'];
4315
+    if (!isset($local_singulier_ou_pluriel[$langue])) {
4316
+        $local_singulier_ou_pluriel[$langue] = false;
4317
+        if (
4318
+            $f = charger_fonction("singulier_ou_pluriel_${langue}", 'inc', true)
4319
+            or $f = charger_fonction('singulier_ou_pluriel', 'inc', true)
4320
+        ) {
4321
+            $local_singulier_ou_pluriel[$langue] = $f;
4322
+        }
4323
+    }
4324
+
4325
+    // si on a une surcharge on l'utilise
4326
+    if ($local_singulier_ou_pluriel[$langue]) {
4327
+        return ($local_singulier_ou_pluriel[$langue])($nb, $chaine_un, $chaine_plusieurs, $var, $vars);
4328
+    }
4329
+
4330
+    // sinon traitement par defaut
4331
+    $vars[$var] = $nb;
4332
+    if ($nb >= 2) {
4333
+        return _T($chaine_plusieurs, $vars);
4334
+    } else {
4335
+        return _T($chaine_un, $vars);
4336
+    }
4337 4337
 }
4338 4338
 
4339 4339
 
@@ -4361,73 +4361,73 @@  discard block
 block discarded – undo
4361 4361
  */
4362 4362
 function prepare_icone_base($type, $lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') {
4363 4363
 
4364
-	$class_lien = $class_bouton = $class;
4365
-
4366
-	// Normaliser la fonction et compléter la classe en fonction
4367
-	if (in_array($fonction, ['del', 'supprimer.gif'])) {
4368
-		$class_lien .= ' danger';
4369
-		$class_bouton .= ' btn_danger';
4370
-	} elseif ($fonction == 'rien.gif') {
4371
-		$fonction = '';
4372
-	} elseif ($fonction == 'delsafe') {
4373
-		$fonction = 'del';
4374
-	}
4375
-
4376
-	$fond_origine = $fond;
4377
-	// Remappage des icone : article-24.png+new => article-new-24.png
4378
-	if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
4379
-		[$fond, $fonction] = $icone_renommer($fond, $fonction);
4380
-	}
4381
-
4382
-	// Ajouter le type d'objet dans la classe
4383
-	$objet_type = substr(basename($fond), 0, -4);
4384
-	$class_lien .= " $objet_type";
4385
-	$class_bouton .= " $objet_type";
4386
-
4387
-	// Texte
4388
-	$alt = attribut_html($texte);
4389
-	$title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
4390
-
4391
-	// Liens : préparer les classes ajax
4392
-	$ajax = '';
4393
-	if ($type === 'lien') {
4394
-		if (strpos($class_lien, 'ajax') !== false) {
4395
-			$ajax = 'ajax';
4396
-			if (strpos($class_lien, 'preload') !== false) {
4397
-				$ajax .= ' preload';
4398
-			}
4399
-			if (strpos($class_lien, 'nocache') !== false) {
4400
-				$ajax .= ' nocache';
4401
-			}
4402
-			$ajax = " class='$ajax'";
4403
-		}
4404
-	}
4405
-
4406
-	// Repérer la taille et l'ajouter dans la classe
4407
-	$size = 24;
4408
-	if (
4409
-		preg_match('/-([0-9]{1,3})[.](gif|png|svg)$/i', $fond, $match)
4410
-		or preg_match('/-([0-9]{1,3})([.](gif|png|svg))?$/i', $fond_origine, $match)
4411
-	) {
4412
-		$size = $match[1];
4413
-	}
4414
-	$class_lien .= " s$size";
4415
-	$class_bouton .= " s$size";
4416
-
4417
-	// Icône
4418
-	$icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4419
-	$icone = '<span class="icone-image' . ($fonction ? " icone-fonction icone-fonction-$fonction" : '') . "\">$icone</span>";
4420
-
4421
-	// Markup final
4422
-	if ($type == 'lien') {
4423
-		return "<span class='icone $class_lien'>"
4424
-		. "<a href='$lien'$title$ajax$javascript>"
4425
-		. $icone
4426
-		. "<b>$texte</b>"
4427
-		. "</a></span>\n";
4428
-	} else {
4429
-		return bouton_action("$icone $texte", $lien, $class_bouton, $javascript, $alt);
4430
-	}
4364
+    $class_lien = $class_bouton = $class;
4365
+
4366
+    // Normaliser la fonction et compléter la classe en fonction
4367
+    if (in_array($fonction, ['del', 'supprimer.gif'])) {
4368
+        $class_lien .= ' danger';
4369
+        $class_bouton .= ' btn_danger';
4370
+    } elseif ($fonction == 'rien.gif') {
4371
+        $fonction = '';
4372
+    } elseif ($fonction == 'delsafe') {
4373
+        $fonction = 'del';
4374
+    }
4375
+
4376
+    $fond_origine = $fond;
4377
+    // Remappage des icone : article-24.png+new => article-new-24.png
4378
+    if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
4379
+        [$fond, $fonction] = $icone_renommer($fond, $fonction);
4380
+    }
4381
+
4382
+    // Ajouter le type d'objet dans la classe
4383
+    $objet_type = substr(basename($fond), 0, -4);
4384
+    $class_lien .= " $objet_type";
4385
+    $class_bouton .= " $objet_type";
4386
+
4387
+    // Texte
4388
+    $alt = attribut_html($texte);
4389
+    $title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
4390
+
4391
+    // Liens : préparer les classes ajax
4392
+    $ajax = '';
4393
+    if ($type === 'lien') {
4394
+        if (strpos($class_lien, 'ajax') !== false) {
4395
+            $ajax = 'ajax';
4396
+            if (strpos($class_lien, 'preload') !== false) {
4397
+                $ajax .= ' preload';
4398
+            }
4399
+            if (strpos($class_lien, 'nocache') !== false) {
4400
+                $ajax .= ' nocache';
4401
+            }
4402
+            $ajax = " class='$ajax'";
4403
+        }
4404
+    }
4405
+
4406
+    // Repérer la taille et l'ajouter dans la classe
4407
+    $size = 24;
4408
+    if (
4409
+        preg_match('/-([0-9]{1,3})[.](gif|png|svg)$/i', $fond, $match)
4410
+        or preg_match('/-([0-9]{1,3})([.](gif|png|svg))?$/i', $fond_origine, $match)
4411
+    ) {
4412
+        $size = $match[1];
4413
+    }
4414
+    $class_lien .= " s$size";
4415
+    $class_bouton .= " s$size";
4416
+
4417
+    // Icône
4418
+    $icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4419
+    $icone = '<span class="icone-image' . ($fonction ? " icone-fonction icone-fonction-$fonction" : '') . "\">$icone</span>";
4420
+
4421
+    // Markup final
4422
+    if ($type == 'lien') {
4423
+        return "<span class='icone $class_lien'>"
4424
+        . "<a href='$lien'$title$ajax$javascript>"
4425
+        . $icone
4426
+        . "<b>$texte</b>"
4427
+        . "</a></span>\n";
4428
+    } else {
4429
+        return bouton_action("$icone $texte", $lien, $class_bouton, $javascript, $alt);
4430
+    }
4431 4431
 }
4432 4432
 
4433 4433
 /**
@@ -4451,7 +4451,7 @@  discard block
 block discarded – undo
4451 4451
  *     Code HTML du lien
4452 4452
  **/
4453 4453
 function icone_base($lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') {
4454
-	return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript);
4454
+    return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript);
4455 4455
 }
4456 4456
 
4457 4457
 /**
@@ -4486,7 +4486,7 @@  discard block
 block discarded – undo
4486 4486
  *     Code HTML du lien
4487 4487
  **/
4488 4488
 function filtre_icone_verticale_dist($lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') {
4489
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript);
4489
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript);
4490 4490
 }
4491 4491
 
4492 4492
 /**
@@ -4531,7 +4531,7 @@  discard block
 block discarded – undo
4531 4531
  *     Code HTML du lien
4532 4532
  **/
4533 4533
 function filtre_icone_horizontale_dist($lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') {
4534
-	return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript);
4534
+    return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript);
4535 4535
 }
4536 4536
 
4537 4537
 /**
@@ -4562,7 +4562,7 @@  discard block
 block discarded – undo
4562 4562
  *     Code HTML du lien
4563 4563
  **/
4564 4564
 function filtre_bouton_action_horizontal_dist($lien, $texte, $fond, $fonction = '', $class = '', $confirm = '') {
4565
-	return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, $class, $confirm);
4565
+    return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, $class, $confirm);
4566 4566
 }
4567 4567
 
4568 4568
 /**
@@ -4593,7 +4593,7 @@  discard block
 block discarded – undo
4593 4593
  *     Code HTML du lien
4594 4594
  */
4595 4595
 function filtre_icone_dist($lien, $texte, $fond, $align = '', $fonction = '', $class = '', $javascript = '') {
4596
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript);
4596
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript);
4597 4597
 }
4598 4598
 
4599 4599
 
@@ -4615,7 +4615,7 @@  discard block
 block discarded – undo
4615 4615
  * @return array Liste des éléments
4616 4616
  */
4617 4617
 function filtre_explode_dist($a, $b) {
4618
-	return explode($b, (string) $a);
4618
+    return explode($b, (string) $a);
4619 4619
 }
4620 4620
 
4621 4621
 /**
@@ -4636,7 +4636,7 @@  discard block
 block discarded – undo
4636 4636
  * @return string Texte
4637 4637
  */
4638 4638
 function filtre_implode_dist($a, $b) {
4639
-	return is_array($a) ? implode($b, $a) : $a;
4639
+    return is_array($a) ? implode($b, $a) : $a;
4640 4640
 }
4641 4641
 
4642 4642
 /**
@@ -4645,24 +4645,24 @@  discard block
 block discarded – undo
4645 4645
  * @return string Code CSS
4646 4646
  */
4647 4647
 function bando_images_background() {
4648
-	include_spip('inc/bandeau');
4649
-	// recuperer tous les boutons et leurs images
4650
-	$boutons = definir_barre_boutons(definir_barre_contexte(), true, false);
4648
+    include_spip('inc/bandeau');
4649
+    // recuperer tous les boutons et leurs images
4650
+    $boutons = definir_barre_boutons(definir_barre_contexte(), true, false);
4651 4651
 
4652
-	$res = '';
4653
-	foreach ($boutons as $page => $detail) {
4654
-		$selecteur = (in_array($page, ['outils_rapides', 'outils_collaboratifs']) ? '' : '.navigation_avec_icones ');
4655
-		if (is_array($detail->sousmenu)) {
4656
-			foreach ($detail->sousmenu as $souspage => $sousdetail) {
4657
-				if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4658
-					$img = http_img_variante_svg_si_possible($sousdetail->icone);
4659
-					$res .= "\n$selecteur.bando2_$souspage {background-image:url($img);}";
4660
-				}
4661
-			}
4662
-		}
4663
-	}
4652
+    $res = '';
4653
+    foreach ($boutons as $page => $detail) {
4654
+        $selecteur = (in_array($page, ['outils_rapides', 'outils_collaboratifs']) ? '' : '.navigation_avec_icones ');
4655
+        if (is_array($detail->sousmenu)) {
4656
+            foreach ($detail->sousmenu as $souspage => $sousdetail) {
4657
+                if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4658
+                    $img = http_img_variante_svg_si_possible($sousdetail->icone);
4659
+                    $res .= "\n$selecteur.bando2_$souspage {background-image:url($img);}";
4660
+                }
4661
+            }
4662
+        }
4663
+    }
4664 4664
 
4665
-	return $res;
4665
+    return $res;
4666 4666
 }
4667 4667
 
4668 4668
 /**
@@ -4687,27 +4687,27 @@  discard block
 block discarded – undo
4687 4687
  */
4688 4688
 function bouton_action($libelle, $url, $class = '', $confirm = '', $title = '', $callback = '') {
4689 4689
 
4690
-	// Classes : dispatcher `ajax` sur le formulaire
4691
-	$class_form = '';
4692
-	if (strpos($class, 'ajax') !== false) {
4693
-		$class_form = 'ajax';
4694
-		$class = str_replace('ajax', '', $class);
4695
-	}
4696
-	$class_btn = 'submit ' . trim($class);
4690
+    // Classes : dispatcher `ajax` sur le formulaire
4691
+    $class_form = '';
4692
+    if (strpos($class, 'ajax') !== false) {
4693
+        $class_form = 'ajax';
4694
+        $class = str_replace('ajax', '', $class);
4695
+    }
4696
+    $class_btn = 'submit ' . trim($class);
4697 4697
 
4698
-	if ($confirm) {
4699
-		$confirm = 'confirm("' . attribut_html($confirm) . '")';
4700
-		if ($callback) {
4701
-			$callback = "$confirm?($callback):false";
4702
-		} else {
4703
-			$callback = $confirm;
4704
-		}
4705
-	}
4706
-	$onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : '';
4707
-	$title = $title ? " title='$title'" : '';
4698
+    if ($confirm) {
4699
+        $confirm = 'confirm("' . attribut_html($confirm) . '")';
4700
+        if ($callback) {
4701
+            $callback = "$confirm?($callback):false";
4702
+        } else {
4703
+            $callback = $confirm;
4704
+        }
4705
+    }
4706
+    $onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : '';
4707
+    $title = $title ? " title='$title'" : '';
4708 4708
 
4709
-	return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>" . form_hidden($url)
4710
-	. "<button type='submit' class='$class_btn'$title$onclick>$libelle</button></div></form>";
4709
+    return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>" . form_hidden($url)
4710
+    . "<button type='submit' class='$class_btn'$title$onclick>$libelle</button></div></form>";
4711 4711
 }
4712 4712
 
4713 4713
 /**
@@ -4730,101 +4730,101 @@  discard block
 block discarded – undo
4730 4730
  * @return string
4731 4731
  */
4732 4732
 function generer_objet_info($id_objet, string $type_objet, string $info, string $etoile = '', array $params = []): string {
4733
-	static $trouver_table = null;
4734
-	static $objets;
4735
-
4736
-	// On verifie qu'on a tout ce qu'il faut
4737
-	$id_objet = intval($id_objet);
4738
-	if (!($id_objet and $type_objet and $info)) {
4739
-		return '';
4740
-	}
4741
-
4742
-	// si on a deja note que l'objet n'existe pas, ne pas aller plus loin
4743
-	if (isset($objets[$type_objet]) and $objets[$type_objet] === false) {
4744
-		return '';
4745
-	}
4746
-
4747
-	// Si on demande l'url, on retourne direct la fonction
4748
-	if ($info == 'url') {
4749
-		return generer_objet_url($id_objet, $type_objet, ...$params);
4750
-	}
4751
-
4752
-	// Sinon on va tout chercher dans la table et on garde en memoire
4753
-	$demande_titre = ($info === 'titre');
4754
-	$demande_introduction = ($info === 'introduction');
4755
-
4756
-	// 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
4757
-	if (
4758
-		!isset($objets[$type_objet][$id_objet])
4759
-		or
4760
-		($demande_titre and !isset($objets[$type_objet][$id_objet]['titre']))
4761
-	) {
4762
-		if (!$trouver_table) {
4763
-			$trouver_table = charger_fonction('trouver_table', 'base');
4764
-		}
4765
-		$desc = $trouver_table(table_objet_sql($type_objet));
4766
-		if (!$desc) {
4767
-			return $objets[$type_objet] = false;
4768
-		}
4769
-
4770
-		// Si on demande le titre, on le gere en interne
4771
-		$champ_titre = '';
4772
-		if ($demande_titre) {
4773
-			// si pas de titre declare mais champ titre, il sera peuple par le select *
4774
-			$champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4775
-		}
4776
-		include_spip('base/abstract_sql');
4777
-		include_spip('base/connect_sql');
4778
-		$objets[$type_objet][$id_objet] = sql_fetsel(
4779
-			'*' . $champ_titre,
4780
-			$desc['table_sql'],
4781
-			id_table_objet($type_objet) . ' = ' . intval($id_objet)
4782
-		);
4783
-
4784
-		// Toujours noter la longueur d'introduction, même si pas demandé cette fois-ci
4785
-		$objets[$type_objet]['introduction_longueur'] = $desc['introduction_longueur'] ?? null;
4786
-	}
4787
-
4788
-	// Pour les fonction generer_xxx, si on demande l'introduction,
4789
-	// ajouter la longueur au début des params supplémentaires
4790
-	if ($demande_introduction) {
4791
-		$introduction_longueur = $objets[$type_objet]['introduction_longueur'];
4792
-		array_unshift($params, $introduction_longueur);
4793
-	}
4794
-
4795
-	// Si la fonction generer_TYPE_TRUC existe, on l'utilise pour formater $info_generee
4796
-	if (
4797
-		$generer = charger_fonction("generer_${type_objet}_${info}", '', true)
4798
-		// @deprecated 4.1 generer_TRUC_TYPE
4799
-		or $generer = charger_fonction("generer_${info}_${type_objet}", '', true)
4800
-	) {
4801
-		$info_generee = $generer($id_objet, $objets[$type_objet][$id_objet], ...$params);
4802
-	}
4803
-	// Si la fonction generer_objet_TRUC existe, on l'utilise pour formater $info_generee
4804
-	elseif (
4805
-		$generer = charger_fonction("generer_objet_${info}", '', true)
4806
-		// @deprecated 4.1 generer_TRUC_entite
4807
-		or $generer = charger_fonction("generer_${info}_entite", '', true)
4808
-	) {
4809
-		$info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet], ...$params);
4810
-	} // Sinon on prend directement le champ SQL tel quel
4811
-	else {
4812
-		$info_generee = ($objets[$type_objet][$id_objet][$info] ?? '');
4813
-	}
4814
-
4815
-	// On va ensuite appliquer les traitements automatiques si besoin
4816
-	if (!$etoile) {
4817
-		// FIXME: on fournit un ENV minimum avec id et type et connect=''
4818
-		// mais ce fonctionnement est a ameliorer !
4819
-		$info_generee = appliquer_traitement_champ(
4820
-			$info_generee,
4821
-			$info,
4822
-			table_objet($type_objet),
4823
-			['id_objet' => $id_objet, 'objet' => $type_objet, '']
4824
-		);
4825
-	}
4826
-
4827
-	return $info_generee;
4733
+    static $trouver_table = null;
4734
+    static $objets;
4735
+
4736
+    // On verifie qu'on a tout ce qu'il faut
4737
+    $id_objet = intval($id_objet);
4738
+    if (!($id_objet and $type_objet and $info)) {
4739
+        return '';
4740
+    }
4741
+
4742
+    // si on a deja note que l'objet n'existe pas, ne pas aller plus loin
4743
+    if (isset($objets[$type_objet]) and $objets[$type_objet] === false) {
4744
+        return '';
4745
+    }
4746
+
4747
+    // Si on demande l'url, on retourne direct la fonction
4748
+    if ($info == 'url') {
4749
+        return generer_objet_url($id_objet, $type_objet, ...$params);
4750
+    }
4751
+
4752
+    // Sinon on va tout chercher dans la table et on garde en memoire
4753
+    $demande_titre = ($info === 'titre');
4754
+    $demande_introduction = ($info === 'introduction');
4755
+
4756
+    // 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
4757
+    if (
4758
+        !isset($objets[$type_objet][$id_objet])
4759
+        or
4760
+        ($demande_titre and !isset($objets[$type_objet][$id_objet]['titre']))
4761
+    ) {
4762
+        if (!$trouver_table) {
4763
+            $trouver_table = charger_fonction('trouver_table', 'base');
4764
+        }
4765
+        $desc = $trouver_table(table_objet_sql($type_objet));
4766
+        if (!$desc) {
4767
+            return $objets[$type_objet] = false;
4768
+        }
4769
+
4770
+        // Si on demande le titre, on le gere en interne
4771
+        $champ_titre = '';
4772
+        if ($demande_titre) {
4773
+            // si pas de titre declare mais champ titre, il sera peuple par le select *
4774
+            $champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4775
+        }
4776
+        include_spip('base/abstract_sql');
4777
+        include_spip('base/connect_sql');
4778
+        $objets[$type_objet][$id_objet] = sql_fetsel(
4779
+            '*' . $champ_titre,
4780
+            $desc['table_sql'],
4781
+            id_table_objet($type_objet) . ' = ' . intval($id_objet)
4782
+        );
4783
+
4784
+        // Toujours noter la longueur d'introduction, même si pas demandé cette fois-ci
4785
+        $objets[$type_objet]['introduction_longueur'] = $desc['introduction_longueur'] ?? null;
4786
+    }
4787
+
4788
+    // Pour les fonction generer_xxx, si on demande l'introduction,
4789
+    // ajouter la longueur au début des params supplémentaires
4790
+    if ($demande_introduction) {
4791
+        $introduction_longueur = $objets[$type_objet]['introduction_longueur'];
4792
+        array_unshift($params, $introduction_longueur);
4793
+    }
4794
+
4795
+    // Si la fonction generer_TYPE_TRUC existe, on l'utilise pour formater $info_generee
4796
+    if (
4797
+        $generer = charger_fonction("generer_${type_objet}_${info}", '', true)
4798
+        // @deprecated 4.1 generer_TRUC_TYPE
4799
+        or $generer = charger_fonction("generer_${info}_${type_objet}", '', true)
4800
+    ) {
4801
+        $info_generee = $generer($id_objet, $objets[$type_objet][$id_objet], ...$params);
4802
+    }
4803
+    // Si la fonction generer_objet_TRUC existe, on l'utilise pour formater $info_generee
4804
+    elseif (
4805
+        $generer = charger_fonction("generer_objet_${info}", '', true)
4806
+        // @deprecated 4.1 generer_TRUC_entite
4807
+        or $generer = charger_fonction("generer_${info}_entite", '', true)
4808
+    ) {
4809
+        $info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet], ...$params);
4810
+    } // Sinon on prend directement le champ SQL tel quel
4811
+    else {
4812
+        $info_generee = ($objets[$type_objet][$id_objet][$info] ?? '');
4813
+    }
4814
+
4815
+    // On va ensuite appliquer les traitements automatiques si besoin
4816
+    if (!$etoile) {
4817
+        // FIXME: on fournit un ENV minimum avec id et type et connect=''
4818
+        // mais ce fonctionnement est a ameliorer !
4819
+        $info_generee = appliquer_traitement_champ(
4820
+            $info_generee,
4821
+            $info,
4822
+            table_objet($type_objet),
4823
+            ['id_objet' => $id_objet, 'objet' => $type_objet, '']
4824
+        );
4825
+    }
4826
+
4827
+    return $info_generee;
4828 4828
 }
4829 4829
 
4830 4830
 /**
@@ -4832,7 +4832,7 @@  discard block
 block discarded – undo
4832 4832
  * @see generer_objet_info
4833 4833
  */
4834 4834
 function generer_info_entite($id_objet, $type_objet, $info, $etoile = '', $params = []) {
4835
-	return generer_objet_info(intval($id_objet), $type_objet, $info, $etoile, $params);
4835
+    return generer_objet_info(intval($id_objet), $type_objet, $info, $etoile, $params);
4836 4836
 }
4837 4837
 
4838 4838
 /**
@@ -4865,36 +4865,36 @@  discard block
 block discarded – undo
4865 4865
  */
4866 4866
 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 {
4867 4867
 
4868
-	$descriptif = $ligne_sql['descriptif'] ?? '';
4869
-	$texte = $ligne_sql['texte'] ?? '';
4870
-	// En absence de descriptif, on se rabat sur chapo + texte
4871
-	if (isset($ligne_sql['chapo'])) {
4872
-		$chapo = $ligne_sql['chapo'];
4873
-		$texte = strlen($descriptif) ?
4874
-			'' :
4875
-			"$chapo \n\n $texte";
4876
-	}
4868
+    $descriptif = $ligne_sql['descriptif'] ?? '';
4869
+    $texte = $ligne_sql['texte'] ?? '';
4870
+    // En absence de descriptif, on se rabat sur chapo + texte
4871
+    if (isset($ligne_sql['chapo'])) {
4872
+        $chapo = $ligne_sql['chapo'];
4873
+        $texte = strlen($descriptif) ?
4874
+            '' :
4875
+            "$chapo \n\n $texte";
4876
+    }
4877 4877
 
4878
-	// Longueur en paramètre, sinon celle renseignée dans la description de l'objet, sinon valeur en dur
4879
-	if (!intval($longueur_ou_suite)) {
4880
-		$longueur = intval($introduction_longueur ?: 600);
4881
-	} else {
4882
-		$longueur = intval($longueur_ou_suite);
4883
-	}
4878
+    // Longueur en paramètre, sinon celle renseignée dans la description de l'objet, sinon valeur en dur
4879
+    if (!intval($longueur_ou_suite)) {
4880
+        $longueur = intval($introduction_longueur ?: 600);
4881
+    } else {
4882
+        $longueur = intval($longueur_ou_suite);
4883
+    }
4884 4884
 
4885
-	// On peut optionnellement passer la suite en 1er paramètre de la balise
4886
-	// Ex : #INTRODUCTION{...}
4887
-	if (
4888
-		is_null($suite)
4889
-		and !intval($longueur_ou_suite)
4890
-	) {
4891
-		$suite = $longueur_ou_suite;
4892
-	}
4885
+    // On peut optionnellement passer la suite en 1er paramètre de la balise
4886
+    // Ex : #INTRODUCTION{...}
4887
+    if (
4888
+        is_null($suite)
4889
+        and !intval($longueur_ou_suite)
4890
+    ) {
4891
+        $suite = $longueur_ou_suite;
4892
+    }
4893 4893
 
4894
-	$f = chercher_filtre('introduction');
4895
-	$introduction = $f($descriptif, $texte, $longueur, $connect, $suite);
4894
+    $f = chercher_filtre('introduction');
4895
+    $introduction = $f($descriptif, $texte, $longueur, $connect, $suite);
4896 4896
 
4897
-	return $introduction;
4897
+    return $introduction;
4898 4898
 }
4899 4899
 
4900 4900
 /**
@@ -4902,7 +4902,7 @@  discard block
 block discarded – undo
4902 4902
  * @see generer_objet_introduction
4903 4903
  */
4904 4904
 function generer_introduction_entite($id_objet, $type_objet, $ligne_sql, $introduction_longueur = null, $longueur_ou_suite = null, $suite = null, string $connect = '') {
4905
-	return generer_objet_introduction(intval($id_objet), $type_objet, $ligne_sql, $introduction_longueur, $longueur_ou_suite, $suite, $connect);
4905
+    return generer_objet_introduction(intval($id_objet), $type_objet, $ligne_sql, $introduction_longueur, $longueur_ou_suite, $suite, $connect);
4906 4906
 }
4907 4907
 
4908 4908
 /**
@@ -4916,44 +4916,44 @@  discard block
 block discarded – undo
4916 4916
  * @return string
4917 4917
  */
4918 4918
 function appliquer_traitement_champ($texte, $champ, $table_objet = '', $env = [], string $connect = '') {
4919
-	if (!$champ) {
4920
-		return $texte;
4921
-	}
4919
+    if (!$champ) {
4920
+        return $texte;
4921
+    }
4922 4922
 
4923
-	// On charge les définitions des traitements (inc/texte et fichiers de fonctions)
4924
-	// car il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4925
-	include_fichiers_fonctions();
4923
+    // On charge les définitions des traitements (inc/texte et fichiers de fonctions)
4924
+    // car il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4925
+    include_fichiers_fonctions();
4926 4926
 
4927
-	$champ = strtoupper($champ);
4928
-	$traitements = $GLOBALS['table_des_traitements'][$champ] ?? false;
4929
-	if (!$traitements or !is_array($traitements)) {
4930
-		return $texte;
4931
-	}
4927
+    $champ = strtoupper($champ);
4928
+    $traitements = $GLOBALS['table_des_traitements'][$champ] ?? false;
4929
+    if (!$traitements or !is_array($traitements)) {
4930
+        return $texte;
4931
+    }
4932 4932
 
4933
-	$traitement = '';
4934
-	if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) {
4935
-		// necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4936
-		$table_objet = table_objet($table_objet);
4937
-		if (isset($traitements[$table_objet])) {
4938
-			$traitement = $traitements[$table_objet];
4939
-		}
4940
-	}
4941
-	if (!$traitement and isset($traitements[0])) {
4942
-		$traitement = $traitements[0];
4943
-	}
4944
-	// (sinon prendre le premier de la liste par defaut ?)
4933
+    $traitement = '';
4934
+    if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) {
4935
+        // necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4936
+        $table_objet = table_objet($table_objet);
4937
+        if (isset($traitements[$table_objet])) {
4938
+            $traitement = $traitements[$table_objet];
4939
+        }
4940
+    }
4941
+    if (!$traitement and isset($traitements[0])) {
4942
+        $traitement = $traitements[0];
4943
+    }
4944
+    // (sinon prendre le premier de la liste par defaut ?)
4945 4945
 
4946
-	if (!$traitement) {
4947
-		return $texte;
4948
-	}
4946
+    if (!$traitement) {
4947
+        return $texte;
4948
+    }
4949 4949
 
4950
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4950
+    $traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4951 4951
 
4952
-	// Fournir $connect et $Pile[0] au traitement si besoin
4953
-	$Pile = [0 => $env];
4954
-	eval("\$texte = $traitement;");
4952
+    // Fournir $connect et $Pile[0] au traitement si besoin
4953
+    $Pile = [0 => $env];
4954
+    eval("\$texte = $traitement;");
4955 4955
 
4956
-	return $texte;
4956
+    return $texte;
4957 4957
 }
4958 4958
 
4959 4959
 
@@ -4967,21 +4967,21 @@  discard block
 block discarded – undo
4967 4967
  * @return string
4968 4968
  */
4969 4969
 function generer_objet_lien(int $id_objet, string $objet, int $longueur = 80, string $connect = ''): string {
4970
-	include_spip('inc/liens');
4971
-	$titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4972
-	// lorsque l'objet n'est plus declare (plugin desactive par exemple)
4973
-	// le raccourcis n'est plus valide
4974
-	$titre = typo($titre['titre']) ?? '';
4975
-	// on essaye avec generer_info_entite ?
4976
-	if (!strlen($titre) and !$connect) {
4977
-		$titre = generer_objet_info($id_objet, $objet, 'titre');
4978
-	}
4979
-	if (!strlen($titre)) {
4980
-		$titre = _T('info_sans_titre');
4981
-	}
4982
-	$url = generer_objet_url($id_objet, $objet, '', '', null, '', $connect);
4970
+    include_spip('inc/liens');
4971
+    $titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4972
+    // lorsque l'objet n'est plus declare (plugin desactive par exemple)
4973
+    // le raccourcis n'est plus valide
4974
+    $titre = typo($titre['titre']) ?? '';
4975
+    // on essaye avec generer_info_entite ?
4976
+    if (!strlen($titre) and !$connect) {
4977
+        $titre = generer_objet_info($id_objet, $objet, 'titre');
4978
+    }
4979
+    if (!strlen($titre)) {
4980
+        $titre = _T('info_sans_titre');
4981
+    }
4982
+    $url = generer_objet_url($id_objet, $objet, '', '', null, '', $connect);
4983 4983
 
4984
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . '</a>';
4984
+    return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . '</a>';
4985 4985
 }
4986 4986
 
4987 4987
 /**
@@ -4989,7 +4989,7 @@  discard block
 block discarded – undo
4989 4989
  * @see generer_objet_lien
4990 4990
  */
4991 4991
 function generer_lien_entite($id_objet, $objet, $longueur = 80, $connect = null) {
4992
-	return generer_objet_lien(intval($id_objet), $objet, $longueur, $connect ?? '');
4992
+    return generer_objet_lien(intval($id_objet), $objet, $longueur, $connect ?? '');
4993 4993
 }
4994 4994
 
4995 4995
 /**
@@ -5005,15 +5005,15 @@  discard block
 block discarded – undo
5005 5005
  * @return string
5006 5006
  */
5007 5007
 function wrap($texte, $wrap) {
5008
-	$balises = extraire_balises($wrap);
5009
-	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
5010
-		$texte = $wrap . $texte;
5011
-		$regs = array_reverse($regs[1]);
5012
-		$wrap = '</' . implode('></', $regs) . '>';
5013
-		$texte = $texte . $wrap;
5014
-	}
5008
+    $balises = extraire_balises($wrap);
5009
+    if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
5010
+        $texte = $wrap . $texte;
5011
+        $regs = array_reverse($regs[1]);
5012
+        $wrap = '</' . implode('></', $regs) . '>';
5013
+        $texte = $texte . $wrap;
5014
+    }
5015 5015
 
5016
-	return $texte;
5016
+    return $texte;
5017 5017
 }
5018 5018
 
5019 5019
 
@@ -5033,44 +5033,44 @@  discard block
 block discarded – undo
5033 5033
  * @return array|mixed|string
5034 5034
  */
5035 5035
 function filtre_print_dist($u, $join = '<br />', $indent = 0) {
5036
-	if (is_string($u)) {
5037
-		$u = typo($u);
5036
+    if (is_string($u)) {
5037
+        $u = typo($u);
5038 5038
 
5039
-		return $u;
5040
-	}
5039
+        return $u;
5040
+    }
5041 5041
 
5042
-	// caster $u en array si besoin
5043
-	if (is_object($u)) {
5044
-		$u = (array)$u;
5045
-	}
5042
+    // caster $u en array si besoin
5043
+    if (is_object($u)) {
5044
+        $u = (array)$u;
5045
+    }
5046 5046
 
5047
-	if (is_array($u)) {
5048
-		$out = '';
5049
-		// toutes les cles sont numeriques ?
5050
-		// et aucun enfant n'est un tableau
5051
-		// liste simple separee par des virgules
5052
-		$numeric_keys = array_map('is_numeric', array_keys($u));
5053
-		$array_values = array_map('is_array', $u);
5054
-		$object_values = array_map('is_object', $u);
5055
-		if (
5056
-			array_sum($numeric_keys) == count($numeric_keys)
5057
-			and !array_sum($array_values)
5058
-			and !array_sum($object_values)
5059
-		) {
5060
-			return join(', ', array_map('filtre_print_dist', $u));
5061
-		}
5047
+    if (is_array($u)) {
5048
+        $out = '';
5049
+        // toutes les cles sont numeriques ?
5050
+        // et aucun enfant n'est un tableau
5051
+        // liste simple separee par des virgules
5052
+        $numeric_keys = array_map('is_numeric', array_keys($u));
5053
+        $array_values = array_map('is_array', $u);
5054
+        $object_values = array_map('is_object', $u);
5055
+        if (
5056
+            array_sum($numeric_keys) == count($numeric_keys)
5057
+            and !array_sum($array_values)
5058
+            and !array_sum($object_values)
5059
+        ) {
5060
+            return join(', ', array_map('filtre_print_dist', $u));
5061
+        }
5062 5062
 
5063
-		// sinon on passe a la ligne et on indente
5064
-		$i_str = str_pad('', $indent, ' ');
5065
-		foreach ($u as $k => $v) {
5066
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
5067
-		}
5063
+        // sinon on passe a la ligne et on indente
5064
+        $i_str = str_pad('', $indent, ' ');
5065
+        foreach ($u as $k => $v) {
5066
+            $out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
5067
+        }
5068 5068
 
5069
-		return $out;
5070
-	}
5069
+        return $out;
5070
+    }
5071 5071
 
5072
-	// on sait pas quoi faire...
5073
-	return $u;
5072
+    // on sait pas quoi faire...
5073
+    return $u;
5074 5074
 }
5075 5075
 
5076 5076
 
@@ -5083,10 +5083,10 @@  discard block
 block discarded – undo
5083 5083
  * @return string|array
5084 5084
  */
5085 5085
 function objet_info($objet, $info) {
5086
-	$table = table_objet_sql($objet);
5087
-	$infos = lister_tables_objets_sql($table);
5086
+    $table = table_objet_sql($objet);
5087
+    $infos = lister_tables_objets_sql($table);
5088 5088
 
5089
-	return ($infos[$info] ?? '');
5089
+    return ($infos[$info] ?? '');
5090 5090
 }
5091 5091
 
5092 5092
 /**
@@ -5101,11 +5101,11 @@  discard block
 block discarded – undo
5101 5101
  *     Texte traduit du comptage, tel que '3 articles'
5102 5102
  */
5103 5103
 function objet_afficher_nb($nb, $objet) {
5104
-	if (!$nb) {
5105
-		return _T(objet_info($objet, 'info_aucun_objet'));
5106
-	} else {
5107
-		return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), ['nb' => $nb]);
5108
-	}
5104
+    if (!$nb) {
5105
+        return _T(objet_info($objet, 'info_aucun_objet'));
5106
+    } else {
5107
+        return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), ['nb' => $nb]);
5108
+    }
5109 5109
 }
5110 5110
 
5111 5111
 /**
@@ -5117,11 +5117,11 @@  discard block
 block discarded – undo
5117 5117
  * @return string
5118 5118
  */
5119 5119
 function objet_icone($objet, $taille = 24, $class = '') {
5120
-	$icone = objet_info($objet, 'icone_objet') . '-' . $taille . '.png';
5121
-	$icone = chemin_image($icone);
5122
-	$balise_img = charger_filtre('balise_img');
5120
+    $icone = objet_info($objet, 'icone_objet') . '-' . $taille . '.png';
5121
+    $icone = chemin_image($icone);
5122
+    $balise_img = charger_filtre('balise_img');
5123 5123
 
5124
-	return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : '';
5124
+    return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : '';
5125 5125
 }
5126 5126
 
5127 5127
 /**
@@ -5142,12 +5142,12 @@  discard block
 block discarded – undo
5142 5142
  * @return string
5143 5143
  */
5144 5144
 function objet_T($objet, $chaine, $args = [], $options = []) {
5145
-	$chaine = explode(':', $chaine);
5146
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, ['force' => false]))) {
5147
-		return $t;
5148
-	}
5149
-	$chaine = implode(':', $chaine);
5150
-	return _T($chaine, $args, $options);
5145
+    $chaine = explode(':', $chaine);
5146
+    if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, ['force' => false]))) {
5147
+        return $t;
5148
+    }
5149
+    $chaine = implode(':', $chaine);
5150
+    return _T($chaine, $args, $options);
5151 5151
 }
5152 5152
 
5153 5153
 /**
@@ -5161,18 +5161,18 @@  discard block
 block discarded – undo
5161 5161
  * @return string      Code HTML
5162 5162
  */
5163 5163
 function insert_head_css_conditionnel($flux) {
5164
-	if (
5165
-		strpos($flux, '<!-- insert_head_css -->') === false
5166
-		and $p = strpos($flux, '<!-- insert_head -->')
5167
-	) {
5168
-		// plutot avant le premier js externe (jquery) pour etre non bloquant
5169
-		if ($p1 = stripos($flux, '<script src=') and $p1 < $p) {
5170
-			$p = $p1;
5171
-		}
5172
-		$flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
5173
-	}
5164
+    if (
5165
+        strpos($flux, '<!-- insert_head_css -->') === false
5166
+        and $p = strpos($flux, '<!-- insert_head -->')
5167
+    ) {
5168
+        // plutot avant le premier js externe (jquery) pour etre non bloquant
5169
+        if ($p1 = stripos($flux, '<script src=') and $p1 < $p) {
5170
+            $p = $p1;
5171
+        }
5172
+        $flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
5173
+    }
5174 5174
 
5175
-	return $flux;
5175
+    return $flux;
5176 5176
 }
5177 5177
 
5178 5178
 /**
@@ -5195,72 +5195,72 @@  discard block
 block discarded – undo
5195 5195
  * @return string
5196 5196
  */
5197 5197
 function produire_fond_statique($fond, $contexte = [], $options = [], string $connect = '') {
5198
-	if (isset($contexte['format'])) {
5199
-		$extension = $contexte['format'];
5200
-		unset($contexte['format']);
5201
-	} else {
5202
-		$extension = 'html';
5203
-		if (preg_match(',[.](css|js|json|xml|svg)$,', $fond, $m)) {
5204
-			$extension = $m[1];
5205
-		}
5206
-	}
5207
-	// recuperer le contenu produit par le squelette
5208
-	$options['raw'] = true;
5209
-	$cache = recuperer_fond($fond, $contexte, $options, $connect);
5210
-
5211
-	// calculer le nom de la css
5212
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
5213
-	$nom_safe = preg_replace(',\W,', '_', str_replace('.', '_', $fond));
5214
-	$contexte_implicite = calculer_contexte_implicite();
5215
-
5216
-	// par defaut on hash selon les contextes qui sont a priori moins variables
5217
-	// mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
5218
-	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
5219
-	if (isset($options['hash_on_content']) and $options['hash_on_content']) {
5220
-		$hash = md5($contexte_implicite['host'] . '::' . $cache);
5221
-	}
5222
-	else {
5223
-		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
5224
-		ksort($contexte);
5225
-		$hash = md5($fond . json_encode($contexte_implicite, JSON_THROW_ON_ERROR) . json_encode($contexte, JSON_THROW_ON_ERROR) . $connect);
5226
-	}
5227
-	$filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
5228
-
5229
-	// mettre a jour le fichier si il n'existe pas
5230
-	// ou trop ancien
5231
-	// le dernier fichier produit est toujours suffixe par .last
5232
-	// et recopie sur le fichier cible uniquement si il change
5233
-	if (
5234
-		!file_exists($filename)
5235
-		or !file_exists($filename . '.last')
5236
-		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . '.last') < $cache['lastmodified'])
5237
-		or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
5238
-	) {
5239
-		$contenu = $cache['texte'];
5240
-		// passer les urls en absolu si c'est une css
5241
-		if ($extension == 'css') {
5242
-			$contenu = urls_absolues_css(
5243
-				$contenu,
5244
-				test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond)
5245
-			);
5246
-		}
5247
-
5248
-		$comment = '';
5249
-		// ne pas insérer de commentaire sur certains formats
5250
-		if (!in_array($extension, ['json', 'xml', 'svg'])) {
5251
-			$comment = "/* #PRODUIRE{fond=$fond";
5252
-			foreach ($contexte as $k => $v) {
5253
-				$comment .= ",$k=$v";
5254
-			}
5255
-			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
5256
-			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
5257
-			$comment .= "}\n   md5:" . md5($contenu) . " */\n";
5258
-		}
5259
-		// et ecrire le fichier si il change
5260
-		ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
5261
-	}
5262
-
5263
-	return timestamp($filename);
5198
+    if (isset($contexte['format'])) {
5199
+        $extension = $contexte['format'];
5200
+        unset($contexte['format']);
5201
+    } else {
5202
+        $extension = 'html';
5203
+        if (preg_match(',[.](css|js|json|xml|svg)$,', $fond, $m)) {
5204
+            $extension = $m[1];
5205
+        }
5206
+    }
5207
+    // recuperer le contenu produit par le squelette
5208
+    $options['raw'] = true;
5209
+    $cache = recuperer_fond($fond, $contexte, $options, $connect);
5210
+
5211
+    // calculer le nom de la css
5212
+    $dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
5213
+    $nom_safe = preg_replace(',\W,', '_', str_replace('.', '_', $fond));
5214
+    $contexte_implicite = calculer_contexte_implicite();
5215
+
5216
+    // par defaut on hash selon les contextes qui sont a priori moins variables
5217
+    // mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
5218
+    // reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
5219
+    if (isset($options['hash_on_content']) and $options['hash_on_content']) {
5220
+        $hash = md5($contexte_implicite['host'] . '::' . $cache);
5221
+    }
5222
+    else {
5223
+        unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
5224
+        ksort($contexte);
5225
+        $hash = md5($fond . json_encode($contexte_implicite, JSON_THROW_ON_ERROR) . json_encode($contexte, JSON_THROW_ON_ERROR) . $connect);
5226
+    }
5227
+    $filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
5228
+
5229
+    // mettre a jour le fichier si il n'existe pas
5230
+    // ou trop ancien
5231
+    // le dernier fichier produit est toujours suffixe par .last
5232
+    // et recopie sur le fichier cible uniquement si il change
5233
+    if (
5234
+        !file_exists($filename)
5235
+        or !file_exists($filename . '.last')
5236
+        or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . '.last') < $cache['lastmodified'])
5237
+        or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
5238
+    ) {
5239
+        $contenu = $cache['texte'];
5240
+        // passer les urls en absolu si c'est une css
5241
+        if ($extension == 'css') {
5242
+            $contenu = urls_absolues_css(
5243
+                $contenu,
5244
+                test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond)
5245
+            );
5246
+        }
5247
+
5248
+        $comment = '';
5249
+        // ne pas insérer de commentaire sur certains formats
5250
+        if (!in_array($extension, ['json', 'xml', 'svg'])) {
5251
+            $comment = "/* #PRODUIRE{fond=$fond";
5252
+            foreach ($contexte as $k => $v) {
5253
+                $comment .= ",$k=$v";
5254
+            }
5255
+            // pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
5256
+            // mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
5257
+            $comment .= "}\n   md5:" . md5($contenu) . " */\n";
5258
+        }
5259
+        // et ecrire le fichier si il change
5260
+        ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
5261
+    }
5262
+
5263
+    return timestamp($filename);
5264 5264
 }
5265 5265
 
5266 5266
 /**
@@ -5273,15 +5273,15 @@  discard block
 block discarded – undo
5273 5273
  *    $fichier auquel on a ajouté le timestamp
5274 5274
  */
5275 5275
 function timestamp($fichier) {
5276
-	if (
5277
-		!$fichier
5278
-		or !file_exists($fichier)
5279
-		or !$m = filemtime($fichier)
5280
-	) {
5281
-		return $fichier;
5282
-	}
5276
+    if (
5277
+        !$fichier
5278
+        or !file_exists($fichier)
5279
+        or !$m = filemtime($fichier)
5280
+    ) {
5281
+        return $fichier;
5282
+    }
5283 5283
 
5284
-	return "$fichier?$m";
5284
+    return "$fichier?$m";
5285 5285
 }
5286 5286
 
5287 5287
 /**
@@ -5291,11 +5291,11 @@  discard block
 block discarded – undo
5291 5291
  * @return string
5292 5292
  */
5293 5293
 function supprimer_timestamp($url) {
5294
-	if (strpos($url, '?') === false) {
5295
-		return $url;
5296
-	}
5294
+    if (strpos($url, '?') === false) {
5295
+        return $url;
5296
+    }
5297 5297
 
5298
-	return preg_replace(',\?[[:digit:]]+$,', '', $url);
5298
+    return preg_replace(',\?[[:digit:]]+$,', '', $url);
5299 5299
 }
5300 5300
 
5301 5301
 /**
@@ -5310,9 +5310,9 @@  discard block
 block discarded – undo
5310 5310
  * @return string
5311 5311
  */
5312 5312
 function filtre_nettoyer_titre_email_dist($titre) {
5313
-	include_spip('inc/envoyer_mail');
5313
+    include_spip('inc/envoyer_mail');
5314 5314
 
5315
-	return nettoyer_titre_email($titre);
5315
+    return nettoyer_titre_email($titre);
5316 5316
 }
5317 5317
 
5318 5318
 /**
@@ -5334,27 +5334,27 @@  discard block
 block discarded – undo
5334 5334
  * @return string
5335 5335
  */
5336 5336
 function filtre_chercher_rubrique_dist(
5337
-	$titre,
5338
-	$id_objet,
5339
-	$id_parent,
5340
-	$objet,
5341
-	$id_secteur,
5342
-	$restreint,
5343
-	$actionable = false,
5344
-	$retour_sans_cadre = false
5337
+    $titre,
5338
+    $id_objet,
5339
+    $id_parent,
5340
+    $objet,
5341
+    $id_secteur,
5342
+    $restreint,
5343
+    $actionable = false,
5344
+    $retour_sans_cadre = false
5345 5345
 ) {
5346
-	include_spip('inc/filtres_ecrire');
5346
+    include_spip('inc/filtres_ecrire');
5347 5347
 
5348
-	return chercher_rubrique(
5349
-		$titre,
5350
-		$id_objet,
5351
-		$id_parent,
5352
-		$objet,
5353
-		$id_secteur,
5354
-		$restreint,
5355
-		$actionable,
5356
-		$retour_sans_cadre
5357
-	);
5348
+    return chercher_rubrique(
5349
+        $titre,
5350
+        $id_objet,
5351
+        $id_parent,
5352
+        $objet,
5353
+        $id_secteur,
5354
+        $restreint,
5355
+        $actionable,
5356
+        $retour_sans_cadre
5357
+    );
5358 5358
 }
5359 5359
 
5360 5360
 /**
@@ -5383,56 +5383,56 @@  discard block
 block discarded – undo
5383 5383
  *     Chaîne vide si l'accès est autorisé
5384 5384
  */
5385 5385
 function sinon_interdire_acces($ok = false, $url = '', $statut = 0, $message = null) {
5386
-	if ($ok) {
5387
-		return '';
5388
-	}
5389
-
5390
-	// Vider tous les tampons
5391
-	$level = @ob_get_level();
5392
-	while ($level--) {
5393
-		@ob_end_clean();
5394
-	}
5395
-
5396
-	include_spip('inc/headers');
5397
-
5398
-	// S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
5399
-	if ($url) {
5400
-		redirige_par_entete($url, '', $statut);
5401
-	}
5402
-
5403
-	// ecriture simplifiee avec message en 3eme argument (= statut 403)
5404
-	if (!is_numeric($statut) and is_null($message)) {
5405
-		$message = $statut;
5406
-		$statut = 0;
5407
-	}
5408
-	if (!$message) {
5409
-		$message = '';
5410
-	}
5411
-	$statut = intval($statut);
5412
-
5413
-	// Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
5414
-	if (test_espace_prive()) {
5415
-		if (!$statut or !in_array($statut, [404, 403])) {
5416
-			$statut = 403;
5417
-		}
5418
-		http_response_code(403);
5419
-		$echec = charger_fonction('403', 'exec');
5420
-		$echec($message);
5421
-	} else {
5422
-		// Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
5423
-		if (!$statut) {
5424
-			$statut = 404;
5425
-		}
5426
-		// Dans tous les cas on modifie l'entité avec ce qui est demandé
5427
-		http_response_code($statut);
5428
-		// Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
5429
-		if ($statut >= 400) {
5430
-			echo recuperer_fond("$statut", ['erreur' => $message]);
5431
-		}
5432
-	}
5433
-
5434
-
5435
-	exit;
5386
+    if ($ok) {
5387
+        return '';
5388
+    }
5389
+
5390
+    // Vider tous les tampons
5391
+    $level = @ob_get_level();
5392
+    while ($level--) {
5393
+        @ob_end_clean();
5394
+    }
5395
+
5396
+    include_spip('inc/headers');
5397
+
5398
+    // S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
5399
+    if ($url) {
5400
+        redirige_par_entete($url, '', $statut);
5401
+    }
5402
+
5403
+    // ecriture simplifiee avec message en 3eme argument (= statut 403)
5404
+    if (!is_numeric($statut) and is_null($message)) {
5405
+        $message = $statut;
5406
+        $statut = 0;
5407
+    }
5408
+    if (!$message) {
5409
+        $message = '';
5410
+    }
5411
+    $statut = intval($statut);
5412
+
5413
+    // Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
5414
+    if (test_espace_prive()) {
5415
+        if (!$statut or !in_array($statut, [404, 403])) {
5416
+            $statut = 403;
5417
+        }
5418
+        http_response_code(403);
5419
+        $echec = charger_fonction('403', 'exec');
5420
+        $echec($message);
5421
+    } else {
5422
+        // Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
5423
+        if (!$statut) {
5424
+            $statut = 404;
5425
+        }
5426
+        // Dans tous les cas on modifie l'entité avec ce qui est demandé
5427
+        http_response_code($statut);
5428
+        // Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
5429
+        if ($statut >= 400) {
5430
+            echo recuperer_fond("$statut", ['erreur' => $message]);
5431
+        }
5432
+    }
5433
+
5434
+
5435
+    exit;
5436 5436
 }
5437 5437
 
5438 5438
 /**
@@ -5443,11 +5443,11 @@  discard block
 block discarded – undo
5443 5443
  * @return string
5444 5444
  */
5445 5445
 function filtre_compacte_dist($source, $format = null) {
5446
-	if (function_exists('compacte')) {
5447
-		return compacte($source, $format);
5448
-	}
5446
+    if (function_exists('compacte')) {
5447
+        return compacte($source, $format);
5448
+    }
5449 5449
 
5450
-	return $source;
5450
+    return $source;
5451 5451
 }
5452 5452
 
5453 5453
 
@@ -5459,31 +5459,31 @@  discard block
 block discarded – undo
5459 5459
  * @return string
5460 5460
  */
5461 5461
 function spip_affiche_mot_de_passe_masque($passe, $afficher_partiellement = false, $portion_pourcent = null) {
5462
-	$l = strlen($passe);
5463
-
5464
-	if ($l <= 8 or !$afficher_partiellement) {
5465
-		if (!$l) {
5466
-			return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
5467
-		}
5468
-		return str_pad('', $afficher_partiellement ? $l : 16, '*');
5469
-	}
5470
-
5471
-	if (is_null($portion_pourcent)) {
5472
-		if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) {
5473
-			define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20%
5474
-		}
5475
-		$portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT;
5476
-	}
5477
-	if ($portion_pourcent >= 100) {
5478
-		return $passe;
5479
-	}
5480
-	$e = intval(ceil($l * $portion_pourcent / 100 / 2));
5481
-	$e = max($e, 0);
5482
-	$mid = str_pad('', $l - 2 * $e, '*');
5483
-	if ($e > 0 and strlen($mid) > 8) {
5484
-		$mid = '***...***';
5485
-	}
5486
-	return substr($passe, 0, $e) . $mid . ($e > 0 ? substr($passe, -$e) : '');
5462
+    $l = strlen($passe);
5463
+
5464
+    if ($l <= 8 or !$afficher_partiellement) {
5465
+        if (!$l) {
5466
+            return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
5467
+        }
5468
+        return str_pad('', $afficher_partiellement ? $l : 16, '*');
5469
+    }
5470
+
5471
+    if (is_null($portion_pourcent)) {
5472
+        if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) {
5473
+            define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20%
5474
+        }
5475
+        $portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT;
5476
+    }
5477
+    if ($portion_pourcent >= 100) {
5478
+        return $passe;
5479
+    }
5480
+    $e = intval(ceil($l * $portion_pourcent / 100 / 2));
5481
+    $e = max($e, 0);
5482
+    $mid = str_pad('', $l - 2 * $e, '*');
5483
+    if ($e > 0 and strlen($mid) > 8) {
5484
+        $mid = '***...***';
5485
+    }
5486
+    return substr($passe, 0, $e) . $mid . ($e > 0 ? substr($passe, -$e) : '');
5487 5487
 }
5488 5488
 
5489 5489
 
@@ -5504,64 +5504,64 @@  discard block
 block discarded – undo
5504 5504
  */
5505 5505
 function identifiant_slug($texte, $type = '', $options = []) {
5506 5506
 
5507
-	$original = $texte;
5508
-	$separateur = ($options['separateur'] ?? '_');
5509
-	$longueur_maxi = ($options['longueur_maxi'] ?? 60);
5510
-	$longueur_mini = ($options['longueur_mini'] ?? 0);
5507
+    $original = $texte;
5508
+    $separateur = ($options['separateur'] ?? '_');
5509
+    $longueur_maxi = ($options['longueur_maxi'] ?? 60);
5510
+    $longueur_mini = ($options['longueur_mini'] ?? 0);
5511 5511
 
5512
-	if (!function_exists('translitteration')) {
5513
-		include_spip('inc/charsets');
5514
-	}
5512
+    if (!function_exists('translitteration')) {
5513
+        include_spip('inc/charsets');
5514
+    }
5515 5515
 
5516
-	// pas de balise html
5517
-	if (strpos($texte, '<') !== false) {
5518
-		$texte = strip_tags($texte);
5519
-	}
5520
-	if (strpos($texte, '&') !== false) {
5521
-		$texte = unicode2charset($texte);
5522
-	}
5523
-	// On enlève les espaces indésirables
5524
-	$texte = trim($texte);
5516
+    // pas de balise html
5517
+    if (strpos($texte, '<') !== false) {
5518
+        $texte = strip_tags($texte);
5519
+    }
5520
+    if (strpos($texte, '&') !== false) {
5521
+        $texte = unicode2charset($texte);
5522
+    }
5523
+    // On enlève les espaces indésirables
5524
+    $texte = trim($texte);
5525 5525
 
5526
-	// On enlève les accents et cie
5527
-	$texte = translitteration($texte);
5526
+    // On enlève les accents et cie
5527
+    $texte = translitteration($texte);
5528 5528
 
5529
-	// On remplace tout ce qui n'est pas un mot par un séparateur
5530
-	$texte = preg_replace(',[\W_]+,ms', $separateur, $texte);
5529
+    // On remplace tout ce qui n'est pas un mot par un séparateur
5530
+    $texte = preg_replace(',[\W_]+,ms', $separateur, $texte);
5531 5531
 
5532
-	// nettoyer les doubles occurences du separateur si besoin
5533
-	while (strpos($texte, (string) "$separateur$separateur") !== false) {
5534
-		$texte = str_replace("$separateur$separateur", $separateur, $texte);
5535
-	}
5532
+    // nettoyer les doubles occurences du separateur si besoin
5533
+    while (strpos($texte, (string) "$separateur$separateur") !== false) {
5534
+        $texte = str_replace("$separateur$separateur", $separateur, $texte);
5535
+    }
5536 5536
 
5537
-	// pas de separateur au debut ni a la fin
5538
-	$texte = trim($texte, $separateur);
5537
+    // pas de separateur au debut ni a la fin
5538
+    $texte = trim($texte, $separateur);
5539 5539
 
5540
-	// en minuscules
5541
-	$texte = strtolower($texte);
5540
+    // en minuscules
5541
+    $texte = strtolower($texte);
5542 5542
 
5543
-	switch ($type) {
5544
-		case 'class':
5545
-		case 'id':
5546
-		case 'anchor':
5547
-			if (preg_match(',^\d,', $texte)) {
5548
-				$texte = substr($type, 0, 1) . $texte;
5549
-			}
5550
-	}
5543
+    switch ($type) {
5544
+        case 'class':
5545
+        case 'id':
5546
+        case 'anchor':
5547
+            if (preg_match(',^\d,', $texte)) {
5548
+                $texte = substr($type, 0, 1) . $texte;
5549
+            }
5550
+    }
5551 5551
 
5552
-	if (strlen($texte) > $longueur_maxi) {
5553
-		$texte = substr($texte, 0, $longueur_maxi);
5554
-	}
5552
+    if (strlen($texte) > $longueur_maxi) {
5553
+        $texte = substr($texte, 0, $longueur_maxi);
5554
+    }
5555 5555
 
5556
-	if (strlen($texte) < $longueur_mini and $longueur_mini < $longueur_maxi) {
5557
-		if (preg_match(',^\d,', $texte)) {
5558
-			$texte = ($type ? substr($type, 0, 1) : 's') . $texte;
5559
-		}
5560
-		$texte .= $separateur . md5($original);
5561
-		$texte = substr($texte, 0, $longueur_mini);
5562
-	}
5556
+    if (strlen($texte) < $longueur_mini and $longueur_mini < $longueur_maxi) {
5557
+        if (preg_match(',^\d,', $texte)) {
5558
+            $texte = ($type ? substr($type, 0, 1) : 's') . $texte;
5559
+        }
5560
+        $texte .= $separateur . md5($original);
5561
+        $texte = substr($texte, 0, $longueur_mini);
5562
+    }
5563 5563
 
5564
-	return $texte;
5564
+    return $texte;
5565 5565
 }
5566 5566
 
5567 5567
 
@@ -5582,11 +5582,11 @@  discard block
 block discarded – undo
5582 5582
  * @exemple `<:info_maximum|label_nettoyer:>`
5583 5583
  */
5584 5584
 function label_nettoyer(string $text, bool $ucfirst = true): string {
5585
-	$label = preg_replace('#([\s:]|\&nbsp;)+$#u', '', $text);
5586
-	if ($ucfirst) {
5587
-		$label = spip_ucfirst($label);
5588
-	}
5589
-	return $label;
5585
+    $label = preg_replace('#([\s:]|\&nbsp;)+$#u', '', $text);
5586
+    if ($ucfirst) {
5587
+        $label = spip_ucfirst($label);
5588
+    }
5589
+    return $label;
5590 5590
 }
5591 5591
 
5592 5592
 /**
@@ -5599,8 +5599,8 @@  discard block
 block discarded – undo
5599 5599
  * @exemple `<:info_maximum|label_ponctuer:>`
5600 5600
  */
5601 5601
 function label_ponctuer(string $text, bool $ucfirst = true): string {
5602
-	$label = label_nettoyer($text, $ucfirst);
5603
-	return _T('label_ponctuer', ['label' => $label]);
5602
+    $label = label_nettoyer($text, $ucfirst);
5603
+    return _T('label_ponctuer', ['label' => $label]);
5604 5604
 }
5605 5605
 
5606 5606
 
@@ -5613,19 +5613,19 @@  discard block
 block discarded – undo
5613 5613
  * @return array
5614 5614
  */
5615 5615
 function helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, $fonction) {
5616
-	if (!in_array($fonction, ['objet_lister_parents', 'objet_lister_enfants', 'objet_lister_parents_par_type', 'objet_lister_enfants_par_type'])) {
5617
-		return [];
5618
-	}
5616
+    if (!in_array($fonction, ['objet_lister_parents', 'objet_lister_enfants', 'objet_lister_parents_par_type', 'objet_lister_enfants_par_type'])) {
5617
+        return [];
5618
+    }
5619 5619
 
5620
-	// compatibilite signature inversee
5621
-	if (is_numeric($objet) and !is_numeric($id_objet)) {
5622
-		[$objet, $id_objet] = [$id_objet, $objet];
5623
-	}
5620
+    // compatibilite signature inversee
5621
+    if (is_numeric($objet) and !is_numeric($id_objet)) {
5622
+        [$objet, $id_objet] = [$id_objet, $objet];
5623
+    }
5624 5624
 
5625
-	if (!function_exists($fonction)) {
5626
-		include_spip('base/objets');
5627
-	}
5628
-	return $fonction($objet, $id_objet);
5625
+    if (!function_exists($fonction)) {
5626
+        include_spip('base/objets');
5627
+    }
5628
+    return $fonction($objet, $id_objet);
5629 5629
 }
5630 5630
 
5631 5631
 
@@ -5640,7 +5640,7 @@  discard block
 block discarded – undo
5640 5640
  * @return array
5641 5641
  */
5642 5642
 function filtre_objet_lister_parents_dist($objet, $id_objet) {
5643
-	return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents');
5643
+    return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents');
5644 5644
 }
5645 5645
 
5646 5646
 /**
@@ -5654,7 +5654,7 @@  discard block
 block discarded – undo
5654 5654
  * @return array
5655 5655
  */
5656 5656
 function filtre_objet_lister_parents_par_type_dist($objet, $id_objet) {
5657
-	return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents_par_type');
5657
+    return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents_par_type');
5658 5658
 }
5659 5659
 
5660 5660
 /**
@@ -5668,7 +5668,7 @@  discard block
 block discarded – undo
5668 5668
  * @return array
5669 5669
  */
5670 5670
 function filtre_objet_lister_enfants_dist($objet, $id_objet) {
5671
-	return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants');
5671
+    return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants');
5672 5672
 }
5673 5673
 
5674 5674
 /**
@@ -5682,5 +5682,5 @@  discard block
 block discarded – undo
5682 5682
  * @return array
5683 5683
  */
5684 5684
 function filtre_objet_lister_enfants_par_type_dist($objet, $id_objet) {
5685
-	return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants_par_type');
5685
+    return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants_par_type');
5686 5686
 }
Please login to merge, or discard this patch.
Spacing   +133 added lines, -134 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 	}
97 97
 
98 98
 	include_fichiers_fonctions();
99
-	foreach (['filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc] as $f) {
99
+	foreach (['filtre_'.$fonc, 'filtre_'.$fonc.'_dist', $fonc] as $f) {
100 100
 		trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels
101 101
 		// fonction ou name\space\fonction
102 102
 		if (is_callable($f)) {
@@ -223,7 +223,7 @@  discard block
 block discarded – undo
223 223
 	// affichage "GIT [master: abcdef]"
224 224
 	$commit = $desc['commit_short'] ?? $desc['commit'];
225 225
 	if ($desc['branch']) {
226
-		$commit = $desc['branch'] . ': ' . $commit;
226
+		$commit = $desc['branch'].': '.$commit;
227 227
 	}
228 228
 	return "{$desc['vcs']} [$commit]";
229 229
 }
@@ -242,9 +242,9 @@  discard block
 block discarded – undo
242 242
 	}
243 243
 
244 244
 	// version installee par GIT
245
-	if (lire_fichier($dir . '/.git/HEAD', $c)) {
245
+	if (lire_fichier($dir.'/.git/HEAD', $c)) {
246 246
 		$currentHead = trim(substr($c, 4));
247
-		if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
247
+		if (lire_fichier($dir.'/.git/'.$currentHead, $hash)) {
248 248
 			return [
249 249
 				'vcs' => 'GIT',
250 250
 				'branch' => basename($currentHead),
@@ -271,8 +271,8 @@  discard block
 block discarded – undo
271 271
 		$dir = '.';
272 272
 	}
273 273
 	// version installee par SVN
274
-	if (file_exists($dir . '/.svn/wc.db') && class_exists(\SQLite3::class)) {
275
-		$db = new SQLite3($dir . '/.svn/wc.db');
274
+	if (file_exists($dir.'/.svn/wc.db') && class_exists(\SQLite3::class)) {
275
+		$db = new SQLite3($dir.'/.svn/wc.db');
276 276
 		$result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1');
277 277
 		if ($result) {
278 278
 			$row = $result->fetchArray();
@@ -290,12 +290,12 @@  discard block
 block discarded – undo
290 290
 
291 291
 // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images
292 292
 // et laisser passer les fonctions personnelles baptisees image_...
293
-$GLOBALS['spip_matrice']['image_graver'] = true;//'inc/filtres_images_mini.php';
294
-$GLOBALS['spip_matrice']['image_select'] = true;//'inc/filtres_images_mini.php';
295
-$GLOBALS['spip_matrice']['image_reduire'] = true;//'inc/filtres_images_mini.php';
296
-$GLOBALS['spip_matrice']['image_reduire_par'] = true;//'inc/filtres_images_mini.php';
297
-$GLOBALS['spip_matrice']['image_passe_partout'] = true;//'inc/filtres_images_mini.php';
298
-$GLOBALS['spip_matrice']['image_recadre_avec_fallback'] = true;//'inc/filtres_images_mini.php';
293
+$GLOBALS['spip_matrice']['image_graver'] = true; //'inc/filtres_images_mini.php';
294
+$GLOBALS['spip_matrice']['image_select'] = true; //'inc/filtres_images_mini.php';
295
+$GLOBALS['spip_matrice']['image_reduire'] = true; //'inc/filtres_images_mini.php';
296
+$GLOBALS['spip_matrice']['image_reduire_par'] = true; //'inc/filtres_images_mini.php';
297
+$GLOBALS['spip_matrice']['image_passe_partout'] = true; //'inc/filtres_images_mini.php';
298
+$GLOBALS['spip_matrice']['image_recadre_avec_fallback'] = true; //'inc/filtres_images_mini.php';
299 299
 
300 300
 $GLOBALS['spip_matrice']['couleur_html_to_hex'] = 'inc/filtres_images_mini.php';
301 301
 $GLOBALS['spip_matrice']['couleur_hex_to_hsl'] = 'inc/filtres_images_mini.php';
@@ -454,8 +454,8 @@  discard block
 block discarded – undo
454 454
  */
455 455
 function filtre_debug($val, $key = null) {
456 456
 	$debug = (
457
-		is_null($key) ? '' : (var_export($key, true) . ' = ')
458
-		) . var_export($val, true);
457
+		is_null($key) ? '' : (var_export($key, true).' = ')
458
+		).var_export($val, true);
459 459
 
460 460
 	include_spip('inc/autoriser');
461 461
 	if (autoriser('webmestre')) {
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 		$is_file = false;
510 510
 	}
511 511
 	if ($is_file) {
512
-		$is_local_file = function ($path) {
512
+		$is_local_file = function($path) {
513 513
 			if (strpos($path, '?') !== false) {
514 514
 				$path = supprimer_timestamp($path);
515 515
 				// remove ?24px added by find_in_theme on .svg files
@@ -561,7 +561,7 @@  discard block
 block discarded – undo
561 561
 						if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) {
562 562
 							$srcover = $match[1];
563 563
 							array_shift($args);
564
-							array_unshift($args, "<img src='" . $match[1] . "' />");
564
+							array_unshift($args, "<img src='".$match[1]."' />");
565 565
 							$srcover_filter = call_user_func_array($filtre, $args);
566 566
 							$srcover_filter = extraire_attribut($srcover_filter, 'src');
567 567
 							$reduit = str_replace($srcover, $srcover_filter, $reduit);
@@ -637,7 +637,7 @@  discard block
 block discarded – undo
637 637
 			if (!$srcHeight) {
638 638
 				$hauteur_img[$src] = $srcHeight = $imagesize[1];
639 639
 			}
640
-			if (!$srcSize){
640
+			if (!$srcSize) {
641 641
 				$poids_img[$src] = filesize($src);
642 642
 			}
643 643
 		}
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
 				if (!$srcHeight) {
652 652
 					$hauteur_img[$src] = $srcHeight = $height;
653 653
 				}
654
-				if (!$srcSize){
654
+				if (!$srcSize) {
655 655
 					$poids_img[$src] = $srcSize = strlen($src);
656 656
 				}
657 657
 			}
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
 			if (!$srcHeight) {
670 670
 				$hauteur_img[$src] = $srcHeight = $valeurs['hauteur_dest'];
671 671
 			}
672
-			if (!$srcSize){
672
+			if (!$srcSize) {
673 673
 				$poids_img[$src] = $srcSize = 0;
674 674
 			}
675 675
 		}
@@ -695,7 +695,7 @@  discard block
 block discarded – undo
695 695
 	return $infos['poids'];
696 696
 }
697 697
 
698
-function taille_image($img, $force_refresh = false){
698
+function taille_image($img, $force_refresh = false) {
699 699
 	$infos = infos_image($img, $force_refresh);
700 700
 	return [$infos['hauteur'], $infos['largeur']];
701 701
 }
@@ -964,7 +964,7 @@  discard block
 block discarded – undo
964 964
 	// " -> &quot; et tout ce genre de choses
965 965
 	$u = $GLOBALS['meta']['pcre_u'];
966 966
 	$texte = str_replace('&nbsp;', ' ', $texte);
967
-	$texte = preg_replace('/\s{2,}/S' . $u, ' ', $texte);
967
+	$texte = preg_replace('/\s{2,}/S'.$u, ' ', $texte);
968 968
 	// ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
969 969
 	$texte = entites_html($texte, false, false);
970 970
 	// mais bien echapper les double quotes !
@@ -1024,7 +1024,7 @@  discard block
 block discarded – undo
1024 1024
  **/
1025 1025
 function supprimer_numero($texte) {
1026 1026
 	return preg_replace(
1027
-		',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1027
+		',^[[:space:]]*([0-9]+)([.)]|'.chr(194).'?'.chr(176).')[[:space:]]+,S',
1028 1028
 		'',
1029 1029
 		$texte
1030 1030
 	);
@@ -1052,7 +1052,7 @@  discard block
 block discarded – undo
1052 1052
 function recuperer_numero($texte) {
1053 1053
 	if (
1054 1054
 		preg_match(
1055
-			',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1055
+			',^[[:space:]]*([0-9]+)([.)]|'.chr(194).'?'.chr(176).')[[:space:]]+,S',
1056 1056
 			$texte,
1057 1057
 			$regs
1058 1058
 		)
@@ -1143,8 +1143,8 @@  discard block
 block discarded – undo
1143 1143
  **/
1144 1144
 function textebrut($texte) {
1145 1145
 	$u = $GLOBALS['meta']['pcre_u'];
1146
-	$texte = preg_replace('/\s+/S' . $u, ' ', $texte);
1147
-	$texte = preg_replace('/<(p|br)( [^>]*)?' . '>/iS', "\n\n", $texte);
1146
+	$texte = preg_replace('/\s+/S'.$u, ' ', $texte);
1147
+	$texte = preg_replace('/<(p|br)( [^>]*)?'.'>/iS', "\n\n", $texte);
1148 1148
 	$texte = preg_replace("/^\n+/", '', $texte);
1149 1149
 	$texte = preg_replace("/\n+$/", '', $texte);
1150 1150
 	$texte = preg_replace("/\n +/", "\n", $texte);
@@ -1178,7 +1178,7 @@  discard block
 block discarded – undo
1178 1178
 		)
1179 1179
 	) {
1180 1180
 		foreach ($liens[0] as $a) {
1181
-			$rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1181
+			$rel = 'noopener noreferrer '.extraire_attribut($a, 'rel');
1182 1182
 			$ablank = inserer_attribut($a, 'rel', $rel);
1183 1183
 			$ablank = inserer_attribut($ablank, 'target', '_blank');
1184 1184
 			$texte = str_replace($a, $ablank, $texte);
@@ -1203,7 +1203,7 @@  discard block
 block discarded – undo
1203 1203
 		foreach ($regs[0] as $a) {
1204 1204
 			$rel = extraire_attribut($a, 'rel');
1205 1205
 			if (strpos($rel, 'nofollow') === false) {
1206
-				$rel = 'nofollow' . ($rel ? " $rel" : '');
1206
+				$rel = 'nofollow'.($rel ? " $rel" : '');
1207 1207
 				$anofollow = inserer_attribut($a, 'rel', $rel);
1208 1208
 				$texte = str_replace($a, $anofollow, $texte);
1209 1209
 			}
@@ -1232,7 +1232,7 @@  discard block
 block discarded – undo
1232 1232
 	$u = $GLOBALS['meta']['pcre_u'];
1233 1233
 	$texte = preg_replace('@</p>@iS', "\n", $texte);
1234 1234
 	$texte = preg_replace("@<p\b.*>@UiS", '<br />', $texte);
1235
-	$texte = preg_replace('@^\s*<br />@S' . $u, '', $texte);
1235
+	$texte = preg_replace('@^\s*<br />@S'.$u, '', $texte);
1236 1236
 
1237 1237
 	return $texte;
1238 1238
 }
@@ -1263,7 +1263,7 @@  discard block
 block discarded – undo
1263 1263
 		return $texte;
1264 1264
 	}
1265 1265
 	include_spip('inc/texte');
1266
-	$tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1266
+	$tag = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $texte) ?
1267 1267
 		'div' : 'span';
1268 1268
 
1269 1269
 	return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
@@ -1375,7 +1375,7 @@  discard block
 block discarded – undo
1375 1375
 	}
1376 1376
 	$u = $GLOBALS['meta']['pcre_u'];
1377 1377
 	if ($textebrut) {
1378
-		$texte = preg_replace([",\n,", ',\s(?=\s),msS' . $u], [' ', ''], textebrut($texte));
1378
+		$texte = preg_replace([",\n,", ',\s(?=\s),msS'.$u], [' ', ''], textebrut($texte));
1379 1379
 	}
1380 1380
 	$texte = texte_backend($texte);
1381 1381
 	$texte = str_replace(["'", '"'], ['&#039;', '&#034;'], $texte);
@@ -1410,7 +1410,7 @@  discard block
 block discarded – undo
1410 1410
 	# un message pour abs_url
1411 1411
 	$GLOBALS['mode_abs_url'] = 'url';
1412 1412
 	$url = trim($url);
1413
-	$r = ',^(?:' . _PROTOCOLES_STD . '):?/?/?$,iS';
1413
+	$r = ',^(?:'._PROTOCOLES_STD.'):?/?/?$,iS';
1414 1414
 
1415 1415
 	return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1416 1416
 }
@@ -1614,14 +1614,14 @@  discard block
 block discarded – undo
1614 1614
 	if (strpos($texte, '<') !== false) {
1615 1615
 		include_spip('inc/lien');
1616 1616
 		if (defined('_PREG_MODELE')) {
1617
-			$preg_modeles = '@' . _PREG_MODELE . '@imsS';
1617
+			$preg_modeles = '@'._PREG_MODELE.'@imsS';
1618 1618
 			$texte = echappe_html($texte, '', true, $preg_modeles);
1619 1619
 		}
1620 1620
 	}
1621 1621
 
1622 1622
 	$debut = '';
1623 1623
 	$suite = $texte;
1624
-	while ($t = strpos('-' . $suite, "\n", 1)) {
1624
+	while ($t = strpos('-'.$suite, "\n", 1)) {
1625 1625
 		$debut .= substr($suite, 0, $t - 1);
1626 1626
 		$suite = substr($suite, $t);
1627 1627
 		$car = substr($suite, 0, 1);
@@ -1639,11 +1639,11 @@  discard block
 block discarded – undo
1639 1639
 			$suite = substr($suite, strlen($regs[0]));
1640 1640
 		}
1641 1641
 	}
1642
-	$texte = $debut . $suite;
1642
+	$texte = $debut.$suite;
1643 1643
 
1644 1644
 	$texte = echappe_retour($texte);
1645 1645
 
1646
-	return $texte . $fin;
1646
+	return $texte.$fin;
1647 1647
 }
1648 1648
 
1649 1649
 
@@ -1705,7 +1705,7 @@  discard block
 block discarded – undo
1705 1705
 		}
1706 1706
 
1707 1707
 		foreach ($regs as $reg) {
1708
-			$cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2];
1708
+			$cle = ($reg[1] ? $reg[1].':' : '').$reg[2];
1709 1709
 			$desc = $traduire($cle, $lang, true);
1710 1710
 			$l = $desc->langue;
1711 1711
 			// si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte.
@@ -1819,9 +1819,9 @@  discard block
 block discarded – undo
1819 1819
 					// il ne faut pas echapper en div si propre produit un seul paragraphe
1820 1820
 					include_spip('inc/texte');
1821 1821
 					$trad_propre = preg_replace(',(^<p[^>]*>|</p>$),Uims', '', propre($trad));
1822
-					$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1822
+					$mode = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1823 1823
 					if ($mode === 'div') {
1824
-						$trad = rtrim($trad) . "\n\n";
1824
+						$trad = rtrim($trad)."\n\n";
1825 1825
 					}
1826 1826
 					$trad = code_echappement($trad, 'multi', false, $mode);
1827 1827
 					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
@@ -2017,7 +2017,7 @@  discard block
 block discarded – undo
2017 2017
 	if (is_array($balise)) {
2018 2018
 		array_walk(
2019 2019
 			$balise,
2020
-			function (&$a, $key, $t) {
2020
+			function(&$a, $key, $t) {
2021 2021
 				$a = extraire_attribut($a, $t);
2022 2022
 			},
2023 2023
 			$attribut
@@ -2114,14 +2114,14 @@  discard block
 block discarded – undo
2114 2114
 
2115 2115
 	if ($old !== null) {
2116 2116
 		// Remplacer l'ancien attribut du meme nom
2117
-		$balise = $r[1] . $insert . $r[5];
2117
+		$balise = $r[1].$insert.$r[5];
2118 2118
 	} else {
2119 2119
 		// preferer une balise " />" (comme <img />)
2120 2120
 		if (preg_match(',/>,', $balise)) {
2121
-			$balise = preg_replace(',\s?/>,S', $insert . ' />', $balise, 1);
2121
+			$balise = preg_replace(',\s?/>,S', $insert.' />', $balise, 1);
2122 2122
 		} // sinon une balise <a ...> ... </a>
2123 2123
 		else {
2124
-			$balise = preg_replace(',\s?>,S', $insert . '>', $balise, 1);
2124
+			$balise = preg_replace(',\s?>,S', $insert.'>', $balise, 1);
2125 2125
 		}
2126 2126
 	}
2127 2127
 
@@ -2176,7 +2176,7 @@  discard block
 block discarded – undo
2176 2176
 		if (
2177 2177
 			$class_courante
2178 2178
 			and strpos($class_courante, (string) $c) !== false
2179
-			and preg_match('/(^|\s)' . preg_quote($c) . '($|\s)/', $class_courante)
2179
+			and preg_match('/(^|\s)'.preg_quote($c).'($|\s)/', $class_courante)
2180 2180
 		) {
2181 2181
 			$is_class_presente = true;
2182 2182
 		}
@@ -2184,12 +2184,12 @@  discard block
 block discarded – undo
2184 2184
 			in_array($operation, ['ajouter', 'commuter'])
2185 2185
 			and !$is_class_presente
2186 2186
 		) {
2187
-			$class_new = ltrim(rtrim($class_new ?? '') . ' ' . $c);
2187
+			$class_new = ltrim(rtrim($class_new ?? '').' '.$c);
2188 2188
 		} elseif (
2189 2189
 			in_array($operation, ['supprimer', 'commuter'])
2190 2190
 			and $is_class_presente
2191 2191
 		) {
2192
-			$class_new = trim(preg_replace('/(^|\s)' . preg_quote($c) . '($|\s)/', "\\1", $class_new));
2192
+			$class_new = trim(preg_replace('/(^|\s)'.preg_quote($c).'($|\s)/', "\\1", $class_new));
2193 2193
 		}
2194 2194
 	}
2195 2195
 
@@ -2252,7 +2252,7 @@  discard block
 block discarded – undo
2252 2252
 // Quelques fonctions de calcul arithmetique
2253 2253
 //
2254 2254
 function floatstr($a) {
2255
- return str_replace(',', '.', (string)floatval($a));
2255
+ return str_replace(',', '.', (string) floatval($a));
2256 2256
 }
2257 2257
 function strize($f, $a, $b) {
2258 2258
  return floatstr($f(floatstr($a), floatstr($b)));
@@ -2388,13 +2388,13 @@  discard block
 block discarded – undo
2388 2388
 	if (!defined('_TAGS_NOM_AUTEUR')) {
2389 2389
 		define('_TAGS_NOM_AUTEUR', '');
2390 2390
 	}
2391
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2391
+	$tags_acceptes = array_unique(explode(',', 'multi,'._TAGS_NOM_AUTEUR));
2392 2392
 	foreach ($tags_acceptes as $tag) {
2393 2393
 		if (strlen($tag)) {
2394
-			$remp1[] = '<' . trim($tag) . '>';
2395
-			$remp1[] = '</' . trim($tag) . '>';
2396
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2397
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2394
+			$remp1[] = '<'.trim($tag).'>';
2395
+			$remp1[] = '</'.trim($tag).'>';
2396
+			$remp2[] = '\x60'.trim($tag).'\x61';
2397
+			$remp2[] = '\x60/'.trim($tag).'\x61';
2398 2398
 		}
2399 2399
 	}
2400 2400
 	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
@@ -2448,7 +2448,7 @@  discard block
 block discarded – undo
2448 2448
 				. http_img_pack(
2449 2449
 					'attachment-16.png',
2450 2450
 					$t,
2451
-					'title="' . attribut_html($t) . '"'
2451
+					'title="'.attribut_html($t).'"'
2452 2452
 				)
2453 2453
 				. '</a>',
2454 2454
 				$tag
@@ -2512,10 +2512,10 @@  discard block
 block discarded – undo
2512 2512
 	$fichier = basename($url);
2513 2513
 
2514 2514
 	return '<a rel="enclosure"'
2515
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2516
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2517
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2518
-	. '>' . $fichier . '</a>';
2515
+	. ($url ? ' href="'.spip_htmlspecialchars($url).'"' : '')
2516
+	. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2517
+	. ($length ? ' title="'.spip_htmlspecialchars($length).'"' : '')
2518
+	. '>'.$fichier.'</a>';
2519 2519
 }
2520 2520
 
2521 2521
 /**
@@ -2543,9 +2543,9 @@  discard block
 block discarded – undo
2543 2543
 			} # vieux data
2544 2544
 			$fichier = basename($url);
2545 2545
 			$enclosures[] = '<enclosure'
2546
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2547
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2548
-				. ($length ? ' length="' . $length . '"' : '')
2546
+				. ($url ? ' url="'.spip_htmlspecialchars($url).'"' : '')
2547
+				. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2548
+				. ($length ? ' length="'.$length.'"' : '')
2549 2549
 				. ' />';
2550 2550
 		}
2551 2551
 	}
@@ -2571,7 +2571,7 @@  discard block
 block discarded – undo
2571 2571
 		if (extraire_attribut($e, 'rel') == 'tag') {
2572 2572
 			$subjects .= '<dc:subject>'
2573 2573
 				. texte_backend(textebrut($e))
2574
-				. '</dc:subject>' . "\n";
2574
+				. '</dc:subject>'."\n";
2575 2575
 		}
2576 2576
 	}
2577 2577
 
@@ -2607,7 +2607,7 @@  discard block
 block discarded – undo
2607 2607
 	if (is_array($texte)) {
2608 2608
 		array_walk(
2609 2609
 			$texte,
2610
-			function (&$a, $key, $t) {
2610
+			function(&$a, $key, $t) {
2611 2611
 				$a = extraire_balise($a, $t);
2612 2612
 			},
2613 2613
 			$tag
@@ -2655,7 +2655,7 @@  discard block
 block discarded – undo
2655 2655
 	if (is_array($texte)) {
2656 2656
 		array_walk(
2657 2657
 			$texte,
2658
-			function (&$a, $key, $t) {
2658
+			function(&$a, $key, $t) {
2659 2659
 				$a = extraire_balises($a, $t);
2660 2660
 			},
2661 2661
 			$tag
@@ -2788,7 +2788,7 @@  discard block
 block discarded – undo
2788 2788
 		if ($fond != '404') {
2789 2789
 			$contexte = array_shift($p);
2790 2790
 			$contexte['page'] = $fond;
2791
-			$action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2791
+			$action = preg_replace('/([?]'.preg_quote($fond).'[^&=]*[0-9]+)(&|$)/', '?&', $action);
2792 2792
 		}
2793 2793
 	}
2794 2794
 	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
@@ -2843,9 +2843,9 @@  discard block
 block discarded – undo
2843 2843
 			. '"'
2844 2844
 			. (is_null($val)
2845 2845
 				? ''
2846
-				: ' value="' . entites_html($val) . '"'
2846
+				: ' value="'.entites_html($val).'"'
2847 2847
 			)
2848
-			. ' type="hidden"' . "\n/>";
2848
+			. ' type="hidden"'."\n/>";
2849 2849
 	}
2850 2850
 
2851 2851
 	return join('', $hidden);
@@ -2955,7 +2955,7 @@  discard block
 block discarded – undo
2955 2955
 
2956 2956
 	return preg_replace_callback(
2957 2957
 		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2958
-		fn($x) => "url('" . suivre_lien($path, $x[1]) . "')",
2958
+		fn($x) => "url('".suivre_lien($path, $x[1])."')",
2959 2959
 		$contenu
2960 2960
 	);
2961 2961
 }
@@ -3016,14 +3016,14 @@  discard block
 block discarded – undo
3016 3016
 	) {
3017 3017
 		$distant = true;
3018 3018
 		$cssf = parse_url($css);
3019
-		$cssf = $cssf['path'] . ($cssf['query'] ? '?' . $cssf['query'] : '');
3019
+		$cssf = $cssf['path'].($cssf['query'] ? '?'.$cssf['query'] : '');
3020 3020
 		$cssf = preg_replace(',[?:&=],', '_', $cssf);
3021 3021
 	} else {
3022 3022
 		$distant = false;
3023 3023
 		$cssf = $css;
3024 3024
 		// 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
3025 3025
 		//propose (rien a faire dans ce cas)
3026
-		$f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
3026
+		$f = preg_replace(',(_rtl)?\.css$,i', '_'.$ndir.'.css', $css);
3027 3027
 		if (@file_exists($f)) {
3028 3028
 			return $f;
3029 3029
 		}
@@ -3033,7 +3033,7 @@  discard block
 block discarded – undo
3033 3033
 	$dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
3034 3034
 	$f = $dir_var
3035 3035
 		. preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
3036
-		. '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
3036
+		. '.'.substr(md5($cssf), 0, 4).'_'.$ndir.'.css';
3037 3037
 
3038 3038
 	// la css peut etre distante (url absolue !)
3039 3039
 	if ($distant) {
@@ -3079,8 +3079,8 @@  discard block
 block discarded – undo
3079 3079
 		} // si la css_direction commence par $dir_var on la fait passer pour une absolue
3080 3080
 		elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
3081 3081
 			$css_direction = substr($css_direction, strlen($dir_var));
3082
-			$src_faux_abs['/@@@@@@/' . $css_direction] = $css_direction;
3083
-			$css_direction = '/@@@@@@/' . $css_direction;
3082
+			$src_faux_abs['/@@@@@@/'.$css_direction] = $css_direction;
3083
+			$css_direction = '/@@@@@@/'.$css_direction;
3084 3084
 		}
3085 3085
 		$src[] = $regs[0][$k];
3086 3086
 		$src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
@@ -3129,7 +3129,7 @@  discard block
 block discarded – undo
3129 3129
 
3130 3130
 	$f = basename($css, '.css');
3131 3131
 	$f = sous_repertoire(_DIR_VAR, 'cache-css')
3132
-		. preg_replace(',(.*?)(_rtl|_ltr)?$,', "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
3132
+		. preg_replace(',(.*?)(_rtl|_ltr)?$,', "\\1-urlabs-".substr(md5("$css-urlabs"), 0, 4)."\\2", $f)
3133 3133
 		. '.css';
3134 3134
 
3135 3135
 	if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
@@ -3139,7 +3139,7 @@  discard block
 block discarded – undo
3139 3139
 	if ($url_absolue_css == $css) {
3140 3140
 		if (
3141 3141
 			strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
3142
-			or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
3142
+			or !lire_fichier(_DIR_RACINE.substr($css, $l), $contenu)
3143 3143
 		) {
3144 3144
 			include_spip('inc/distant');
3145 3145
 			$contenu = recuperer_url($css);
@@ -3251,7 +3251,7 @@  discard block
 block discarded – undo
3251 3251
 	$expression = str_replace('\/', '/', $expression);
3252 3252
 	$expression = str_replace('/', '\/', $expression);
3253 3253
 
3254
-	if (preg_match('/' . $expression . '/' . $modif, $texte ?? '', $r)) {
3254
+	if (preg_match('/'.$expression.'/'.$modif, $texte ?? '', $r)) {
3255 3255
 		if (isset($r[$capte])) {
3256 3256
 			return $r[$capte];
3257 3257
 		} else {
@@ -3289,7 +3289,7 @@  discard block
 block discarded – undo
3289 3289
 	$expression = str_replace('\/', '/', $expression);
3290 3290
 	$expression = str_replace('/', '\/', $expression);
3291 3291
 
3292
-	return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3292
+	return preg_replace('/'.$expression.'/'.$modif, $replace, $texte);
3293 3293
 }
3294 3294
 
3295 3295
 
@@ -3308,7 +3308,7 @@  discard block
 block discarded – undo
3308 3308
 function traiter_doublons_documents(&$doublons, $letexte) {
3309 3309
 
3310 3310
 	// Verifier dans le texte & les notes (pas beau, helas)
3311
-	$t = $letexte . $GLOBALS['les_notes'];
3311
+	$t = $letexte.$GLOBALS['les_notes'];
3312 3312
 
3313 3313
 	if (
3314 3314
 		strstr($t, 'spip_document_') // evite le preg_match_all si inutile
@@ -3322,7 +3322,7 @@  discard block
 block discarded – undo
3322 3322
 		if (!isset($doublons['documents'])) {
3323 3323
 			$doublons['documents'] = '';
3324 3324
 		}
3325
-		$doublons['documents'] .= ',' . join(',', $matches[1]);
3325
+		$doublons['documents'] .= ','.join(',', $matches[1]);
3326 3326
 	}
3327 3327
 
3328 3328
 	return $letexte;
@@ -3379,7 +3379,7 @@  discard block
 block discarded – undo
3379 3379
 	if ($env) {
3380 3380
 		foreach ($env as $i => $j) {
3381 3381
 			if (is_string($j) and !in_array($i, $ignore_params)) {
3382
-				$texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3382
+				$texte .= "<param name='".attribut_html($i)."'\n\tvalue='".attribut_html($j)."' />";
3383 3383
 			}
3384 3384
 		}
3385 3385
 	}
@@ -3418,7 +3418,7 @@  discard block
 block discarded – undo
3418 3418
 	if ($env) {
3419 3419
 		foreach ($env as $i => $j) {
3420 3420
 			if (is_string($j) and !in_array($i, $ignore_params)) {
3421
-				$texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3421
+				$texte .= attribut_html($i)."='".attribut_html($j)."' ";
3422 3422
 			}
3423 3423
 		}
3424 3424
 	}
@@ -3492,10 +3492,10 @@  discard block
 block discarded – undo
3492 3492
 	// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3493 3493
 	if (
3494 3494
 		preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3495
-		and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . '-xx.svg'
3495
+		and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])).'-xx.svg'
3496 3496
 		and file_exists($variante_svg_generique)
3497 3497
 	) {
3498
-		if ($variante_svg_size = substr($variante_svg_generique, 0, -6) . $m[1] . '.svg' and file_exists($variante_svg_size)) {
3498
+		if ($variante_svg_size = substr($variante_svg_generique, 0, -6).$m[1].'.svg' and file_exists($variante_svg_size)) {
3499 3499
 			$img_file = $variante_svg_size;
3500 3500
 		}
3501 3501
 		else {
@@ -3553,7 +3553,7 @@  discard block
 block discarded – undo
3553 3553
 				return '';
3554 3554
 			}
3555 3555
 		}
3556
-		$atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3556
+		$atts .= " width='".$largeur."' height='".$hauteur."'";
3557 3557
 	}
3558 3558
 
3559 3559
 	if (file_exists($img_file)) {
@@ -3563,14 +3563,14 @@  discard block
 block discarded – undo
3563 3563
 		$alt = '';
3564 3564
 	}
3565 3565
 	elseif ($alt or $alt === '') {
3566
-		$alt = " alt='" . attribut_html($alt) . "'";
3566
+		$alt = " alt='".attribut_html($alt)."'";
3567 3567
 	}
3568 3568
 	else {
3569
-		$alt = " alt='" . attribut_html($title) . "'";
3569
+		$alt = " alt='".attribut_html($title)."'";
3570 3570
 	}
3571 3571
 	return "<img src='$img_file'$alt"
3572
-	. ($title ? ' title="' . attribut_html($title) . '"' : '')
3573
-	. ' ' . ltrim($atts)
3572
+	. ($title ? ' title="'.attribut_html($title).'"' : '')
3573
+	. ' '.ltrim($atts)
3574 3574
 	. ' />';
3575 3575
 }
3576 3576
 
@@ -3584,10 +3584,10 @@  discard block
 block discarded – undo
3584 3584
  */
3585 3585
 function http_style_background($img, $att = '', $size = null) {
3586 3586
 	if ($size and is_numeric($size)) {
3587
-		$size = trim($size) . 'px';
3587
+		$size = trim($size).'px';
3588 3588
 	}
3589
-	return " style='background" .
3590
-		($att ? '' : '-image') . ': url("' . chemin_image($img) . '")' . ($att ? (' ' . $att) : '') . ';'
3589
+	return " style='background".
3590
+		($att ? '' : '-image').': url("'.chemin_image($img).'")'.($att ? (' '.$att) : '').';'
3591 3591
 		. ($size ? "background-size:{$size};" : '')
3592 3592
 		. "'";
3593 3593
 }
@@ -3702,7 +3702,7 @@  discard block
 block discarded – undo
3702 3702
 		$img = http_img_pack(
3703 3703
 			$img,
3704 3704
 			$alt,
3705
-			$class ? " class='" . attribut_html($class) . "'" : '',
3705
+			$class ? " class='".attribut_html($class)."'" : '',
3706 3706
 			'',
3707 3707
 			['chemin_image' => false, 'utiliser_suffixe_size' => false]
3708 3708
 		);
@@ -3787,7 +3787,7 @@  discard block
 block discarded – undo
3787 3787
 	$balise_svg_source = $balise_svg;
3788 3788
 
3789 3789
 	// entete XML à supprimer
3790
-	$svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3790
+	$svg = preg_replace(',^\s*<\?xml[^>]*\?'.'>,', '', $svg);
3791 3791
 
3792 3792
 	// IE est toujours mon ami
3793 3793
 	$balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
@@ -3805,9 +3805,9 @@  discard block
 block discarded – undo
3805 3805
 	// regler le alt
3806 3806
 	if ($alt) {
3807 3807
 		$balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3808
-		$id = 'img-svg-title-' . substr(md5("$img_file:$svg:$alt"), 0, 4);
3808
+		$id = 'img-svg-title-'.substr(md5("$img_file:$svg:$alt"), 0, 4);
3809 3809
 		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3810
-		$title = "<title id=\"$id\">" . entites_html($alt) . "</title>\n";
3810
+		$title = "<title id=\"$id\">".entites_html($alt)."</title>\n";
3811 3811
 		$balise_svg .= $title;
3812 3812
 	}
3813 3813
 	else {
@@ -3855,7 +3855,7 @@  discard block
 block discarded – undo
3855 3855
 	if (is_array($tableau)) {
3856 3856
 		foreach ($tableau as $k => $v) {
3857 3857
 			$res = recuperer_fond(
3858
-				'modeles/' . $modele,
3858
+				'modeles/'.$modele,
3859 3859
 				array_merge(['cle' => $k], (is_array($v) ? $v : ['valeur' => $v]))
3860 3860
 			);
3861 3861
 			$texte .= $res;
@@ -4040,7 +4040,7 @@  discard block
 block discarded – undo
4040 4040
 	}
4041 4041
 
4042 4042
 	$c = serialize($c);
4043
-	$cle = calculer_cle_action($form . $c);
4043
+	$cle = calculer_cle_action($form.$c);
4044 4044
 	$c = "$cle:$c";
4045 4045
 
4046 4046
 	// on ne stocke pas les contextes dans des fichiers en cache
@@ -4098,15 +4098,15 @@  discard block
 block discarded – undo
4098 4098
 	}
4099 4099
 	// toujours encoder l'url source dans le bloc ajax
4100 4100
 	$r = self();
4101
-	$r = ' data-origin="' . $r . '"';
4101
+	$r = ' data-origin="'.$r.'"';
4102 4102
 	$class = 'ajaxbloc';
4103 4103
 	if ($ajaxid and is_string($ajaxid)) {
4104 4104
 		// ajaxid est normalement conforme a un nom de classe css
4105 4105
 		// on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
4106
-		$class .= ' ajax-id-' . entites_html($ajaxid);
4106
+		$class .= ' ajax-id-'.entites_html($ajaxid);
4107 4107
 	}
4108 4108
 
4109
-	return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
4109
+	return "<div class='$class' "."data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
4110 4110
 }
4111 4111
 
4112 4112
 /**
@@ -4150,7 +4150,7 @@  discard block
 block discarded – undo
4150 4150
 		$cle = substr($c, 0, $p);
4151 4151
 		$c = substr($c, $p + 1);
4152 4152
 
4153
-		if ($cle == calculer_cle_action($form . $c)) {
4153
+		if ($cle == calculer_cle_action($form.$c)) {
4154 4154
 			$env = @unserialize($c);
4155 4155
 			return $env;
4156 4156
 		}
@@ -4271,13 +4271,13 @@  discard block
 block discarded – undo
4271 4271
 				}
4272 4272
 			}
4273 4273
 		}
4274
-		$att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"';
4274
+		$att .= 'class="'.($class ? attribut_html($class).' ' : '').(defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on').'"';
4275 4275
 	} else {
4276 4276
 		$bal = 'a';
4277 4277
 		$att = "href='$url'"
4278
-			. ($title ? " title='" . attribut_html($title) . "'" : '')
4279
-			. ($class ? " class='" . attribut_html($class) . "'" : '')
4280
-			. ($rel ? " rel='" . attribut_html($rel) . "'" : '')
4278
+			. ($title ? " title='".attribut_html($title)."'" : '')
4279
+			. ($class ? " class='".attribut_html($class)."'" : '')
4280
+			. ($rel ? " rel='".attribut_html($rel)."'" : '')
4281 4281
 			. $evt;
4282 4282
 	}
4283 4283
 	if ($libelle === null) {
@@ -4416,7 +4416,7 @@  discard block
 block discarded – undo
4416 4416
 
4417 4417
 	// Icône
4418 4418
 	$icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4419
-	$icone = '<span class="icone-image' . ($fonction ? " icone-fonction icone-fonction-$fonction" : '') . "\">$icone</span>";
4419
+	$icone = '<span class="icone-image'.($fonction ? " icone-fonction icone-fonction-$fonction" : '')."\">$icone</span>";
4420 4420
 
4421 4421
 	// Markup final
4422 4422
 	if ($type == 'lien') {
@@ -4693,20 +4693,20 @@  discard block
 block discarded – undo
4693 4693
 		$class_form = 'ajax';
4694 4694
 		$class = str_replace('ajax', '', $class);
4695 4695
 	}
4696
-	$class_btn = 'submit ' . trim($class);
4696
+	$class_btn = 'submit '.trim($class);
4697 4697
 
4698 4698
 	if ($confirm) {
4699
-		$confirm = 'confirm("' . attribut_html($confirm) . '")';
4699
+		$confirm = 'confirm("'.attribut_html($confirm).'")';
4700 4700
 		if ($callback) {
4701 4701
 			$callback = "$confirm?($callback):false";
4702 4702
 		} else {
4703 4703
 			$callback = $confirm;
4704 4704
 		}
4705 4705
 	}
4706
-	$onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : '';
4706
+	$onclick = $callback ? " onclick='return ".addcslashes($callback, "'")."'" : '';
4707 4707
 	$title = $title ? " title='$title'" : '';
4708 4708
 
4709
-	return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>" . form_hidden($url)
4709
+	return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>".form_hidden($url)
4710 4710
 	. "<button type='submit' class='$class_btn'$title$onclick>$libelle</button></div></form>";
4711 4711
 }
4712 4712
 
@@ -4771,14 +4771,14 @@  discard block
 block discarded – undo
4771 4771
 		$champ_titre = '';
4772 4772
 		if ($demande_titre) {
4773 4773
 			// si pas de titre declare mais champ titre, il sera peuple par le select *
4774
-			$champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4774
+			$champ_titre = (!empty($desc['titre'])) ? ', '.$desc['titre'] : '';
4775 4775
 		}
4776 4776
 		include_spip('base/abstract_sql');
4777 4777
 		include_spip('base/connect_sql');
4778 4778
 		$objets[$type_objet][$id_objet] = sql_fetsel(
4779
-			'*' . $champ_titre,
4779
+			'*'.$champ_titre,
4780 4780
 			$desc['table_sql'],
4781
-			id_table_objet($type_objet) . ' = ' . intval($id_objet)
4781
+			id_table_objet($type_objet).' = '.intval($id_objet)
4782 4782
 		);
4783 4783
 
4784 4784
 		// Toujours noter la longueur d'introduction, même si pas demandé cette fois-ci
@@ -4871,8 +4871,7 @@  discard block
 block discarded – undo
4871 4871
 	if (isset($ligne_sql['chapo'])) {
4872 4872
 		$chapo = $ligne_sql['chapo'];
4873 4873
 		$texte = strlen($descriptif) ?
4874
-			'' :
4875
-			"$chapo \n\n $texte";
4874
+			'' : "$chapo \n\n $texte";
4876 4875
 	}
4877 4876
 
4878 4877
 	// Longueur en paramètre, sinon celle renseignée dans la description de l'objet, sinon valeur en dur
@@ -4947,7 +4946,7 @@  discard block
 block discarded – undo
4947 4946
 		return $texte;
4948 4947
 	}
4949 4948
 
4950
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4949
+	$traitement = str_replace('%s', "'".texte_script($texte)."'", $traitement);
4951 4950
 
4952 4951
 	// Fournir $connect et $Pile[0] au traitement si besoin
4953 4952
 	$Pile = [0 => $env];
@@ -4981,7 +4980,7 @@  discard block
 block discarded – undo
4981 4980
 	}
4982 4981
 	$url = generer_objet_url($id_objet, $objet, '', '', null, '', $connect);
4983 4982
 
4984
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . '</a>';
4983
+	return "<a href='$url' class='$objet'>".couper($titre, $longueur).'</a>';
4985 4984
 }
4986 4985
 
4987 4986
 /**
@@ -5007,10 +5006,10 @@  discard block
 block discarded – undo
5007 5006
 function wrap($texte, $wrap) {
5008 5007
 	$balises = extraire_balises($wrap);
5009 5008
 	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
5010
-		$texte = $wrap . $texte;
5009
+		$texte = $wrap.$texte;
5011 5010
 		$regs = array_reverse($regs[1]);
5012
-		$wrap = '</' . implode('></', $regs) . '>';
5013
-		$texte = $texte . $wrap;
5011
+		$wrap = '</'.implode('></', $regs).'>';
5012
+		$texte = $texte.$wrap;
5014 5013
 	}
5015 5014
 
5016 5015
 	return $texte;
@@ -5041,7 +5040,7 @@  discard block
 block discarded – undo
5041 5040
 
5042 5041
 	// caster $u en array si besoin
5043 5042
 	if (is_object($u)) {
5044
-		$u = (array)$u;
5043
+		$u = (array) $u;
5045 5044
 	}
5046 5045
 
5047 5046
 	if (is_array($u)) {
@@ -5063,7 +5062,7 @@  discard block
 block discarded – undo
5063 5062
 		// sinon on passe a la ligne et on indente
5064 5063
 		$i_str = str_pad('', $indent, ' ');
5065 5064
 		foreach ($u as $k => $v) {
5066
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
5065
+			$out .= $join.$i_str."$k: ".filtre_print_dist($v, $join, $indent + 2);
5067 5066
 		}
5068 5067
 
5069 5068
 		return $out;
@@ -5117,7 +5116,7 @@  discard block
 block discarded – undo
5117 5116
  * @return string
5118 5117
  */
5119 5118
 function objet_icone($objet, $taille = 24, $class = '') {
5120
-	$icone = objet_info($objet, 'icone_objet') . '-' . $taille . '.png';
5119
+	$icone = objet_info($objet, 'icone_objet').'-'.$taille.'.png';
5121 5120
 	$icone = chemin_image($icone);
5122 5121
 	$balise_img = charger_filtre('balise_img');
5123 5122
 
@@ -5143,7 +5142,7 @@  discard block
 block discarded – undo
5143 5142
  */
5144 5143
 function objet_T($objet, $chaine, $args = [], $options = []) {
5145 5144
 	$chaine = explode(':', $chaine);
5146
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, ['force' => false]))) {
5145
+	if ($t = _T($objet.':'.end($chaine), $args, array_merge($options, ['force' => false]))) {
5147 5146
 		return $t;
5148 5147
 	}
5149 5148
 	$chaine = implode(':', $chaine);
@@ -5209,7 +5208,7 @@  discard block
 block discarded – undo
5209 5208
 	$cache = recuperer_fond($fond, $contexte, $options, $connect);
5210 5209
 
5211 5210
 	// calculer le nom de la css
5212
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
5211
+	$dir_var = sous_repertoire(_DIR_VAR, 'cache-'.$extension);
5213 5212
 	$nom_safe = preg_replace(',\W,', '_', str_replace('.', '_', $fond));
5214 5213
 	$contexte_implicite = calculer_contexte_implicite();
5215 5214
 
@@ -5217,14 +5216,14 @@  discard block
 block discarded – undo
5217 5216
 	// mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
5218 5217
 	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
5219 5218
 	if (isset($options['hash_on_content']) and $options['hash_on_content']) {
5220
-		$hash = md5($contexte_implicite['host'] . '::' . $cache);
5219
+		$hash = md5($contexte_implicite['host'].'::'.$cache);
5221 5220
 	}
5222 5221
 	else {
5223 5222
 		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
5224 5223
 		ksort($contexte);
5225
-		$hash = md5($fond . json_encode($contexte_implicite, JSON_THROW_ON_ERROR) . json_encode($contexte, JSON_THROW_ON_ERROR) . $connect);
5224
+		$hash = md5($fond.json_encode($contexte_implicite, JSON_THROW_ON_ERROR).json_encode($contexte, JSON_THROW_ON_ERROR).$connect);
5226 5225
 	}
5227
-	$filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
5226
+	$filename = $dir_var.$extension."dyn-$nom_safe-".substr($hash, 0, 8).".$extension";
5228 5227
 
5229 5228
 	// mettre a jour le fichier si il n'existe pas
5230 5229
 	// ou trop ancien
@@ -5232,8 +5231,8 @@  discard block
 block discarded – undo
5232 5231
 	// et recopie sur le fichier cible uniquement si il change
5233 5232
 	if (
5234 5233
 		!file_exists($filename)
5235
-		or !file_exists($filename . '.last')
5236
-		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . '.last') < $cache['lastmodified'])
5234
+		or !file_exists($filename.'.last')
5235
+		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename.'.last') < $cache['lastmodified'])
5237 5236
 		or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
5238 5237
 	) {
5239 5238
 		$contenu = $cache['texte'];
@@ -5254,10 +5253,10 @@  discard block
 block discarded – undo
5254 5253
 			}
5255 5254
 			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
5256 5255
 			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
5257
-			$comment .= "}\n   md5:" . md5($contenu) . " */\n";
5256
+			$comment .= "}\n   md5:".md5($contenu)." */\n";
5258 5257
 		}
5259 5258
 		// et ecrire le fichier si il change
5260
-		ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
5259
+		ecrire_fichier_calcule_si_modifie($filename, $comment.$contenu, false, true);
5261 5260
 	}
5262 5261
 
5263 5262
 	return timestamp($filename);
@@ -5483,7 +5482,7 @@  discard block
 block discarded – undo
5483 5482
 	if ($e > 0 and strlen($mid) > 8) {
5484 5483
 		$mid = '***...***';
5485 5484
 	}
5486
-	return substr($passe, 0, $e) . $mid . ($e > 0 ? substr($passe, -$e) : '');
5485
+	return substr($passe, 0, $e).$mid.($e > 0 ? substr($passe, -$e) : '');
5487 5486
 }
5488 5487
 
5489 5488
 
@@ -5545,7 +5544,7 @@  discard block
 block discarded – undo
5545 5544
 		case 'id':
5546 5545
 		case 'anchor':
5547 5546
 			if (preg_match(',^\d,', $texte)) {
5548
-				$texte = substr($type, 0, 1) . $texte;
5547
+				$texte = substr($type, 0, 1).$texte;
5549 5548
 			}
5550 5549
 	}
5551 5550
 
@@ -5555,9 +5554,9 @@  discard block
 block discarded – undo
5555 5554
 
5556 5555
 	if (strlen($texte) < $longueur_mini and $longueur_mini < $longueur_maxi) {
5557 5556
 		if (preg_match(',^\d,', $texte)) {
5558
-			$texte = ($type ? substr($type, 0, 1) : 's') . $texte;
5557
+			$texte = ($type ? substr($type, 0, 1) : 's').$texte;
5559 5558
 		}
5560
-		$texte .= $separateur . md5($original);
5559
+		$texte .= $separateur.md5($original);
5561 5560
 		$texte = substr($texte, 0, $longueur_mini);
5562 5561
 	}
5563 5562
 
Please login to merge, or discard this patch.
Braces   +10 added lines, -20 removed lines patch added patch discarded remove patch
@@ -640,8 +640,7 @@  discard block
 block discarded – undo
640 640
 			if (!$srcSize){
641 641
 				$poids_img[$src] = filesize($src);
642 642
 			}
643
-		}
644
-		elseif (strpos($src, '<svg') !== false) {
643
+		} elseif (strpos($src, '<svg') !== false) {
645 644
 			include_spip('inc/svg');
646 645
 			if ($attrs = svg_lire_attributs($src)) {
647 646
 				[$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs);
@@ -3497,8 +3496,7 @@  discard block
 block discarded – undo
3497 3496
 	) {
3498 3497
 		if ($variante_svg_size = substr($variante_svg_generique, 0, -6) . $m[1] . '.svg' and file_exists($variante_svg_size)) {
3499 3498
 			$img_file = $variante_svg_size;
3500
-		}
3501
-		else {
3499
+		} else {
3502 3500
 			$img_file = $variante_svg_generique;
3503 3501
 		}
3504 3502
 	}
@@ -3530,8 +3528,7 @@  discard block
 block discarded – undo
3530 3528
 	}
3531 3529
 	if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3532 3530
 		$img_file = chemin_image($img);
3533
-	}
3534
-	else {
3531
+	} else {
3535 3532
 		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true) {
3536 3533
 			$img_file = http_img_variante_svg_si_possible($img_file);
3537 3534
 		}
@@ -3561,11 +3558,9 @@  discard block
 block discarded – undo
3561 3558
 	}
3562 3559
 	if ($alt === false) {
3563 3560
 		$alt = '';
3564
-	}
3565
-	elseif ($alt or $alt === '') {
3561
+	} elseif ($alt or $alt === '') {
3566 3562
 		$alt = " alt='" . attribut_html($alt) . "'";
3567
-	}
3568
-	else {
3563
+	} else {
3569 3564
 		$alt = " alt='" . attribut_html($title) . "'";
3570 3565
 	}
3571 3566
 	return "<img src='$img_file'$alt"
@@ -3692,13 +3687,11 @@  discard block
 block discarded – undo
3692 3687
 		if (!is_null($class)) {
3693 3688
 			if (strlen($class)) {
3694 3689
 				$img = inserer_attribut($img, 'class', $class);
3695
-			}
3696
-			else {
3690
+			} else {
3697 3691
 				$img = vider_attribut($img, 'class');
3698 3692
 			}
3699 3693
 		}
3700
-	}
3701
-	else {
3694
+	} else {
3702 3695
 		$img = http_img_pack(
3703 3696
 			$img,
3704 3697
 			$alt,
@@ -3796,8 +3789,7 @@  discard block
 block discarded – undo
3796 3789
 	if (!is_null($class)) {
3797 3790
 		if (strlen($class)) {
3798 3791
 			$balise_svg = inserer_attribut($balise_svg, 'class', $class);
3799
-		}
3800
-		else {
3792
+		} else {
3801 3793
 			$balise_svg = vider_attribut($balise_svg, 'class');
3802 3794
 		}
3803 3795
 	}
@@ -3809,8 +3801,7 @@  discard block
 block discarded – undo
3809 3801
 		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3810 3802
 		$title = "<title id=\"$id\">" . entites_html($alt) . "</title>\n";
3811 3803
 		$balise_svg .= $title;
3812
-	}
3813
-	else {
3804
+	} else {
3814 3805
 		$balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3815 3806
 	}
3816 3807
 
@@ -5218,8 +5209,7 @@  discard block
 block discarded – undo
5218 5209
 	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
5219 5210
 	if (isset($options['hash_on_content']) and $options['hash_on_content']) {
5220 5211
 		$hash = md5($contexte_implicite['host'] . '::' . $cache);
5221
-	}
5222
-	else {
5212
+	} else {
5223 5213
 		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
5224 5214
 		ksort($contexte);
5225 5215
 		$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.