Completed
Push — master ( 978e74...7c6770 )
by cam
01:22
created
ecrire/inc/filtres.php 2 patches
Indentation   +2416 added lines, -2416 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,33 +77,33 @@  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
-		if (is_callable($f)) {
102
-			return $f;
103
-		}
104
-	}
105
-
106
-	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
+        if (is_callable($f)) {
102
+            return $f;
103
+        }
104
+    }
105
+
106
+    return $default;
107 107
 }
108 108
 
109 109
 /**
@@ -147,8 +147,8 @@  discard block
 block discarded – undo
147 147
  *     Chaîne vide sinon.
148 148
  **/
149 149
 function appliquer_filtre($arg, $filtre) {
150
-	$args = func_get_args();
151
-	return appliquer_filtre_sinon($arg, $filtre, $args, '');
150
+    $args = func_get_args();
151
+    return appliquer_filtre_sinon($arg, $filtre, $args, '');
152 152
 }
153 153
 
154 154
 /**
@@ -173,8 +173,8 @@  discard block
 block discarded – undo
173 173
  *     Texte d'origine sinon
174 174
  **/
175 175
 function appliquer_si_filtre($arg, $filtre) {
176
-	$args = func_get_args();
177
-	return appliquer_filtre_sinon($arg, $filtre, $args, $arg);
176
+    $args = func_get_args();
177
+    return appliquer_filtre_sinon($arg, $filtre, $args, $arg);
178 178
 }
179 179
 
180 180
 /**
@@ -190,12 +190,12 @@  discard block
 block discarded – undo
190 190
  *     Version de SPIP
191 191
  **/
192 192
 function spip_version() {
193
-	$version = $GLOBALS['spip_version_affichee'];
194
-	if ($vcs_version = version_vcs_courante(_DIR_RACINE)) {
195
-		$version .= " $vcs_version";
196
-	}
193
+    $version = $GLOBALS['spip_version_affichee'];
194
+    if ($vcs_version = version_vcs_courante(_DIR_RACINE)) {
195
+        $version .= " $vcs_version";
196
+    }
197 197
 
198
-	return $version;
198
+    return $version;
199 199
 }
200 200
 
201 201
 /**
@@ -207,11 +207,11 @@  discard block
 block discarded – undo
207 207
  * @return string
208 208
  */
209 209
 function header_silencieux($version): string {
210
-	if (isset($GLOBALS['spip_header_silencieux']) && (bool) $GLOBALS['spip_header_silencieux']) {
211
-		$version = '';
212
-	}
210
+    if (isset($GLOBALS['spip_header_silencieux']) && (bool) $GLOBALS['spip_header_silencieux']) {
211
+        $version = '';
212
+    }
213 213
 
214
-	return (string) $version;
214
+    return (string) $version;
215 215
 }
216 216
 
217 217
 /**
@@ -224,19 +224,19 @@  discard block
 block discarded – undo
224 224
  *    - string|null si $raw = false
225 225
  */
226 226
 function version_vcs_courante($dir, $raw = false) {
227
-	$desc = decrire_version_git($dir);
228
-	if ($desc === null) {
229
-		$desc = decrire_version_svn($dir);
230
-	}
231
-	if ($desc === null or $raw) {
232
-		return $desc;
233
-	}
234
-	// affichage "GIT [master: abcdef]"
235
-	$commit = $desc['commit_short'] ?? $desc['commit'];
236
-	if ($desc['branch']) {
237
-		$commit = $desc['branch'] . ': ' . $commit;
238
-	}
239
-	return "{$desc['vcs']} [$commit]";
227
+    $desc = decrire_version_git($dir);
228
+    if ($desc === null) {
229
+        $desc = decrire_version_svn($dir);
230
+    }
231
+    if ($desc === null or $raw) {
232
+        return $desc;
233
+    }
234
+    // affichage "GIT [master: abcdef]"
235
+    $commit = $desc['commit_short'] ?? $desc['commit'];
236
+    if ($desc['branch']) {
237
+        $commit = $desc['branch'] . ': ' . $commit;
238
+    }
239
+    return "{$desc['vcs']} [$commit]";
240 240
 }
241 241
 
242 242
 /**
@@ -248,24 +248,24 @@  discard block
 block discarded – undo
248 248
  *      array ['branch' => xx, 'commit' => yy] sinon.
249 249
  **/
250 250
 function decrire_version_git($dir) {
251
-	if (!$dir) {
252
-		$dir = '.';
253
-	}
251
+    if (!$dir) {
252
+        $dir = '.';
253
+    }
254 254
 
255
-	// version installee par GIT
256
-	if (lire_fichier($dir . '/.git/HEAD', $c)) {
257
-		$currentHead = trim(substr($c, 4));
258
-		if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
259
-			return [
260
-				'vcs' => 'GIT',
261
-				'branch' => basename($currentHead),
262
-				'commit' => trim($hash),
263
-				'commit_short' => substr(trim($hash), 0, 8),
264
-			];
265
-		}
266
-	}
255
+    // version installee par GIT
256
+    if (lire_fichier($dir . '/.git/HEAD', $c)) {
257
+        $currentHead = trim(substr($c, 4));
258
+        if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
259
+            return [
260
+                'vcs' => 'GIT',
261
+                'branch' => basename($currentHead),
262
+                'commit' => trim($hash),
263
+                'commit_short' => substr(trim($hash), 0, 8),
264
+            ];
265
+        }
266
+    }
267 267
 
268
-	return null;
268
+    return null;
269 269
 }
270 270
 
271 271
 
@@ -278,25 +278,25 @@  discard block
 block discarded – undo
278 278
  *      array ['commit' => yy, 'date' => xx, 'author' => xx] sinon.
279 279
  **/
280 280
 function decrire_version_svn($dir) {
281
-	if (!$dir) {
282
-		$dir = '.';
283
-	}
284
-	// version installee par SVN
285
-	if (file_exists($dir . '/.svn/wc.db') && class_exists(\SQLite3::class)) {
286
-		$db = new SQLite3($dir . '/.svn/wc.db');
287
-		$result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1');
288
-		if ($result) {
289
-			$row = $result->fetchArray();
290
-			if ($row['changed_revision'] != '') {
291
-				return [
292
-					'vcs' => 'SVN',
293
-					'branch' => '',
294
-					'commit' => $row['changed_revision'],
295
-				];
296
-			}
297
-		}
298
-	}
299
-	return null;
281
+    if (!$dir) {
282
+        $dir = '.';
283
+    }
284
+    // version installee par SVN
285
+    if (file_exists($dir . '/.svn/wc.db') && class_exists(\SQLite3::class)) {
286
+        $db = new SQLite3($dir . '/.svn/wc.db');
287
+        $result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1');
288
+        if ($result) {
289
+            $row = $result->fetchArray();
290
+            if ($row['changed_revision'] != '') {
291
+                return [
292
+                    'vcs' => 'SVN',
293
+                    'branch' => '',
294
+                    'commit' => $row['changed_revision'],
295
+                ];
296
+            }
297
+        }
298
+    }
299
+    return null;
300 300
 }
301 301
 
302 302
 // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images
@@ -343,18 +343,18 @@  discard block
 block discarded – undo
343 343
  *     Code HTML retourné par le filtre
344 344
  **/
345 345
 function filtrer($filtre) {
346
-	$tous = func_get_args();
347
-	if (trouver_filtre_matrice($filtre) and substr($filtre, 0, 6) == 'image_') {
348
-		return image_filtrer($tous);
349
-	} elseif ($f = chercher_filtre($filtre)) {
350
-		array_shift($tous);
351
-		return $f(...$tous);
352
-	} else {
353
-		// le filtre n'existe pas, on provoque une erreur
354
-		$msg = ['zbug_erreur_filtre', ['filtre' => texte_script($filtre)]];
355
-		erreur_squelette($msg);
356
-		return '';
357
-	}
346
+    $tous = func_get_args();
347
+    if (trouver_filtre_matrice($filtre) and substr($filtre, 0, 6) == 'image_') {
348
+        return image_filtrer($tous);
349
+    } elseif ($f = chercher_filtre($filtre)) {
350
+        array_shift($tous);
351
+        return $f(...$tous);
352
+    } else {
353
+        // le filtre n'existe pas, on provoque une erreur
354
+        $msg = ['zbug_erreur_filtre', ['filtre' => texte_script($filtre)]];
355
+        erreur_squelette($msg);
356
+        return '';
357
+    }
358 358
 }
359 359
 
360 360
 /**
@@ -371,11 +371,11 @@  discard block
 block discarded – undo
371 371
  * @return bool true si on trouve le filtre dans la matrice, false sinon.
372 372
  */
373 373
 function trouver_filtre_matrice($filtre) {
374
-	if (isset($GLOBALS['spip_matrice'][$filtre]) and is_string($f = $GLOBALS['spip_matrice'][$filtre])) {
375
-		find_in_path($f, '', true);
376
-		$GLOBALS['spip_matrice'][$filtre] = true;
377
-	}
378
-	return !empty($GLOBALS['spip_matrice'][$filtre]);
374
+    if (isset($GLOBALS['spip_matrice'][$filtre]) and is_string($f = $GLOBALS['spip_matrice'][$filtre])) {
375
+        find_in_path($f, '', true);
376
+        $GLOBALS['spip_matrice'][$filtre] = true;
377
+    }
378
+    return !empty($GLOBALS['spip_matrice'][$filtre]);
379 379
 }
380 380
 
381 381
 
@@ -403,8 +403,8 @@  discard block
 block discarded – undo
403 403
  * @return mixed
404 404
  */
405 405
 function filtre_set(&$Pile, $val, $key, $continue = null) {
406
-	$Pile['vars'][$key] = $val;
407
-	return $continue ? $val : '';
406
+    $Pile['vars'][$key] = $val;
407
+    return $continue ? $val : '';
408 408
 }
409 409
 
410 410
 /**
@@ -430,8 +430,8 @@  discard block
 block discarded – undo
430 430
  * @return string|mixed Retourne `$val` si `$continue` présent, sinon ''.
431 431
  */
432 432
 function filtre_setenv(&$Pile, $val, $key, $continue = null) {
433
-	$Pile[0][$key] = $val;
434
-	return $continue ? $val : '';
433
+    $Pile[0][$key] = $val;
434
+    return $continue ? $val : '';
435 435
 }
436 436
 
437 437
 /**
@@ -440,8 +440,8 @@  discard block
 block discarded – undo
440 440
  * @return string
441 441
  */
442 442
 function filtre_sanitize_env(&$Pile, $keys) {
443
-	$Pile[0] = spip_sanitize_from_request($Pile[0], $keys);
444
-	return '';
443
+    $Pile[0] = spip_sanitize_from_request($Pile[0], $keys);
444
+    return '';
445 445
 }
446 446
 
447 447
 
@@ -464,18 +464,18 @@  discard block
 block discarded – undo
464 464
  * @return mixed Retourne la valeur (sans la modifier).
465 465
  */
466 466
 function filtre_debug($val, $key = null) {
467
-	$debug = (
468
-		is_null($key) ? '' : (var_export($key, true) . ' = ')
469
-		) . var_export($val, true);
467
+    $debug = (
468
+        is_null($key) ? '' : (var_export($key, true) . ' = ')
469
+        ) . var_export($val, true);
470 470
 
471
-	include_spip('inc/autoriser');
472
-	if (autoriser('webmestre')) {
473
-		echo "<div class='spip_debug'>\n", $debug, "</div>\n";
474
-	}
471
+    include_spip('inc/autoriser');
472
+    if (autoriser('webmestre')) {
473
+        echo "<div class='spip_debug'>\n", $debug, "</div>\n";
474
+    }
475 475
 
476
-	spip_log($debug, 'debug');
476
+    spip_log($debug, 'debug');
477 477
 
478
-	return $val;
478
+    return $val;
479 479
 }
480 480
 
481 481
 
@@ -505,84 +505,84 @@  discard block
 block discarded – undo
505 505
  *     Texte qui a reçu les filtres
506 506
  **/
507 507
 function image_filtrer($args) {
508
-	$filtre = array_shift($args); # enlever $filtre
509
-	$texte = array_shift($args);
510
-	if ($texte === null || !strlen($texte)) {
511
-		return '';
512
-	}
513
-	find_in_path('filtres_images_mini.php', 'inc/', true);
514
-	statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver
515
-	// Cas du nom de fichier local
516
-	$is_file = trim($texte);
517
-	if (
518
-		strpos(substr($is_file, strlen(_DIR_RACINE)), '..') !== false
519
-		  or strpbrk($is_file, "<>\n\r\t") !== false
520
-		  or strpos($is_file, '/') === 0
521
-	) {
522
-		$is_file = false;
523
-	}
524
-	if ($is_file) {
525
-		$is_local_file = function ($path) {
526
-			if (strpos($path, '?') !== false) {
527
-				$path = supprimer_timestamp($path);
528
-				// remove ?24px added by find_in_theme on .svg files
529
-				$path = preg_replace(',\?[[:digit:]]+(px)$,', '', $path);
530
-			}
531
-			return file_exists($path);
532
-		};
533
-		if ($is_local_file($is_file) or tester_url_absolue($is_file)) {
534
-			$res = $filtre("<img src='$is_file' />", ...$args);
535
-			statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
536
-			return $res;
537
-		}
538
-	}
539
-
540
-	// Cas general : trier toutes les images, avec eventuellement leur <span>
541
-	if (
542
-		preg_match_all(
543
-			',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS',
544
-			$texte,
545
-			$tags,
546
-			PREG_SET_ORDER
547
-		)
548
-	) {
549
-		foreach ($tags as $tag) {
550
-			$class = extraire_attribut($tag[3], 'class');
551
-			if (
552
-				!$class or
553
-				(strpos($class, 'filtre_inactif') === false
554
-					// compat historique a virer en 3.2
555
-					and strpos($class, 'no_image_filtrer') === false)
556
-			) {
557
-				if ($reduit = $filtre($tag[3], ...$args)) {
558
-					// En cas de span spip_documents, modifier le style=...width:
559
-					if ($tag[1]) {
560
-						$w = extraire_attribut($reduit, 'width');
561
-						if (!$w and preg_match(',width:\s*(\d+)px,S', extraire_attribut($reduit, 'style'), $regs)) {
562
-							$w = $regs[1];
563
-						}
564
-						if ($w and ($style = extraire_attribut($tag[1], 'style'))) {
565
-							$style = preg_replace(',width:\s*\d+px,S', "width:{$w}px", $style);
566
-							$replace = inserer_attribut($tag[1], 'style', $style);
567
-							$texte = str_replace($tag[1], $replace, $texte);
568
-						}
569
-					}
570
-					// traiter aussi un eventuel mouseover
571
-					if ($mouseover = extraire_attribut($reduit, 'onmouseover')) {
572
-						if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) {
573
-							$srcover = $match[1];
574
-							$srcover_filter = $filtre("<img src='" . $match[1] . "' />", ...$args);
575
-							$srcover_filter = extraire_attribut($srcover_filter, 'src');
576
-							$reduit = str_replace($srcover, $srcover_filter, $reduit);
577
-						}
578
-					}
579
-					$texte = str_replace($tag[3], $reduit, $texte);
580
-				}
581
-			}
582
-		}
583
-	}
584
-	statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
585
-	return $texte;
508
+    $filtre = array_shift($args); # enlever $filtre
509
+    $texte = array_shift($args);
510
+    if ($texte === null || !strlen($texte)) {
511
+        return '';
512
+    }
513
+    find_in_path('filtres_images_mini.php', 'inc/', true);
514
+    statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver
515
+    // Cas du nom de fichier local
516
+    $is_file = trim($texte);
517
+    if (
518
+        strpos(substr($is_file, strlen(_DIR_RACINE)), '..') !== false
519
+          or strpbrk($is_file, "<>\n\r\t") !== false
520
+          or strpos($is_file, '/') === 0
521
+    ) {
522
+        $is_file = false;
523
+    }
524
+    if ($is_file) {
525
+        $is_local_file = function ($path) {
526
+            if (strpos($path, '?') !== false) {
527
+                $path = supprimer_timestamp($path);
528
+                // remove ?24px added by find_in_theme on .svg files
529
+                $path = preg_replace(',\?[[:digit:]]+(px)$,', '', $path);
530
+            }
531
+            return file_exists($path);
532
+        };
533
+        if ($is_local_file($is_file) or tester_url_absolue($is_file)) {
534
+            $res = $filtre("<img src='$is_file' />", ...$args);
535
+            statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
536
+            return $res;
537
+        }
538
+    }
539
+
540
+    // Cas general : trier toutes les images, avec eventuellement leur <span>
541
+    if (
542
+        preg_match_all(
543
+            ',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS',
544
+            $texte,
545
+            $tags,
546
+            PREG_SET_ORDER
547
+        )
548
+    ) {
549
+        foreach ($tags as $tag) {
550
+            $class = extraire_attribut($tag[3], 'class');
551
+            if (
552
+                !$class or
553
+                (strpos($class, 'filtre_inactif') === false
554
+                    // compat historique a virer en 3.2
555
+                    and strpos($class, 'no_image_filtrer') === false)
556
+            ) {
557
+                if ($reduit = $filtre($tag[3], ...$args)) {
558
+                    // En cas de span spip_documents, modifier le style=...width:
559
+                    if ($tag[1]) {
560
+                        $w = extraire_attribut($reduit, 'width');
561
+                        if (!$w and preg_match(',width:\s*(\d+)px,S', extraire_attribut($reduit, 'style'), $regs)) {
562
+                            $w = $regs[1];
563
+                        }
564
+                        if ($w and ($style = extraire_attribut($tag[1], 'style'))) {
565
+                            $style = preg_replace(',width:\s*\d+px,S', "width:{$w}px", $style);
566
+                            $replace = inserer_attribut($tag[1], 'style', $style);
567
+                            $texte = str_replace($tag[1], $replace, $texte);
568
+                        }
569
+                    }
570
+                    // traiter aussi un eventuel mouseover
571
+                    if ($mouseover = extraire_attribut($reduit, 'onmouseover')) {
572
+                        if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) {
573
+                            $srcover = $match[1];
574
+                            $srcover_filter = $filtre("<img src='" . $match[1] . "' />", ...$args);
575
+                            $srcover_filter = extraire_attribut($srcover_filter, 'src');
576
+                            $reduit = str_replace($srcover, $srcover_filter, $reduit);
577
+                        }
578
+                    }
579
+                    $texte = str_replace($tag[3], $reduit, $texte);
580
+                }
581
+            }
582
+        }
583
+    }
584
+    statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
585
+    return $texte;
586 586
 }
587 587
 
588 588
 /**
@@ -599,91 +599,91 @@  discard block
 block discarded – undo
599 599
  **/
600 600
 function infos_image($img, $force_refresh = false) {
601 601
 
602
-	static $largeur_img = [], $hauteur_img = [], $poids_img = [];
603
-	$srcWidth = 0;
604
-	$srcHeight = 0;
605
-	$srcSize = null;
606
-
607
-	$src = extraire_attribut($img, 'src');
608
-
609
-	if (!$src) {
610
-		$src = $img;
611
-	} else {
612
-		$srcWidth = extraire_attribut($img, 'width');
613
-		$srcHeight = extraire_attribut($img, 'height');
614
-	}
615
-
616
-	// ne jamais operer directement sur une image distante pour des raisons de perfo
617
-	// la copie locale a toutes les chances d'etre la ou de resservir
618
-	if (tester_url_absolue($src)) {
619
-		include_spip('inc/distant');
620
-		$fichier = copie_locale($src);
621
-		$src = $fichier ? _DIR_RACINE . $fichier : $src;
622
-	}
623
-	if (($p = strpos($src, '?')) !== false) {
624
-		$src = substr($src, 0, $p);
625
-	}
626
-
627
-	$imagesize = false;
628
-	if (isset($largeur_img[$src]) and !$force_refresh) {
629
-		$srcWidth = $largeur_img[$src];
630
-	}
631
-	if (isset($hauteur_img[$src]) and !$force_refresh) {
632
-		$srcHeight = $hauteur_img[$src];
633
-	}
634
-	if (isset($poids_img[$src]) and !$force_refresh) {
635
-		$srcSize = $poids_img[$src];
636
-	}
637
-	if (!$srcWidth or !$srcHeight or is_null($srcSize)) {
638
-		if (
639
-			file_exists($src)
640
-			and $imagesize = spip_getimagesize($src)
641
-		) {
642
-			if (!$srcWidth) {
643
-				$largeur_img[$src] = $srcWidth = $imagesize[0];
644
-			}
645
-			if (!$srcHeight) {
646
-				$hauteur_img[$src] = $srcHeight = $imagesize[1];
647
-			}
648
-			if (!$srcSize) {
649
-				$poids_img[$src] = filesize($src);
650
-			}
651
-		}
652
-		elseif (strpos($src, '<svg') !== false) {
653
-			include_spip('inc/svg');
654
-			if ($attrs = svg_lire_attributs($src)) {
655
-				[$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs);
656
-				if (!$srcWidth) {
657
-					$largeur_img[$src] = $srcWidth = $width;
658
-				}
659
-				if (!$srcHeight) {
660
-					$hauteur_img[$src] = $srcHeight = $height;
661
-				}
662
-				if (!$srcSize) {
663
-					$poids_img[$src] = $srcSize = strlen($src);
664
-				}
665
-			}
666
-		}
667
-		// $src peut etre une reference a une image temporaire dont a n'a que le log .src
668
-		// on s'y refere, l'image sera reconstruite en temps utile si necessaire
669
-		elseif (
670
-			@file_exists($f = "$src.src")
671
-			and lire_fichier($f, $valeurs)
672
-			and $valeurs = unserialize($valeurs)
673
-		) {
674
-			if (!$srcWidth) {
675
-				$largeur_img[$src] = $srcWidth = $valeurs['largeur_dest'];
676
-			}
677
-			if (!$srcHeight) {
678
-				$hauteur_img[$src] = $srcHeight = $valeurs['hauteur_dest'];
679
-			}
680
-			if (!$srcSize) {
681
-				$poids_img[$src] = $srcSize = 0;
682
-			}
683
-		}
684
-	}
685
-
686
-	return ['hauteur' => $srcHeight, 'largeur' => $srcWidth, 'poids' => $srcSize];
602
+    static $largeur_img = [], $hauteur_img = [], $poids_img = [];
603
+    $srcWidth = 0;
604
+    $srcHeight = 0;
605
+    $srcSize = null;
606
+
607
+    $src = extraire_attribut($img, 'src');
608
+
609
+    if (!$src) {
610
+        $src = $img;
611
+    } else {
612
+        $srcWidth = extraire_attribut($img, 'width');
613
+        $srcHeight = extraire_attribut($img, 'height');
614
+    }
615
+
616
+    // ne jamais operer directement sur une image distante pour des raisons de perfo
617
+    // la copie locale a toutes les chances d'etre la ou de resservir
618
+    if (tester_url_absolue($src)) {
619
+        include_spip('inc/distant');
620
+        $fichier = copie_locale($src);
621
+        $src = $fichier ? _DIR_RACINE . $fichier : $src;
622
+    }
623
+    if (($p = strpos($src, '?')) !== false) {
624
+        $src = substr($src, 0, $p);
625
+    }
626
+
627
+    $imagesize = false;
628
+    if (isset($largeur_img[$src]) and !$force_refresh) {
629
+        $srcWidth = $largeur_img[$src];
630
+    }
631
+    if (isset($hauteur_img[$src]) and !$force_refresh) {
632
+        $srcHeight = $hauteur_img[$src];
633
+    }
634
+    if (isset($poids_img[$src]) and !$force_refresh) {
635
+        $srcSize = $poids_img[$src];
636
+    }
637
+    if (!$srcWidth or !$srcHeight or is_null($srcSize)) {
638
+        if (
639
+            file_exists($src)
640
+            and $imagesize = spip_getimagesize($src)
641
+        ) {
642
+            if (!$srcWidth) {
643
+                $largeur_img[$src] = $srcWidth = $imagesize[0];
644
+            }
645
+            if (!$srcHeight) {
646
+                $hauteur_img[$src] = $srcHeight = $imagesize[1];
647
+            }
648
+            if (!$srcSize) {
649
+                $poids_img[$src] = filesize($src);
650
+            }
651
+        }
652
+        elseif (strpos($src, '<svg') !== false) {
653
+            include_spip('inc/svg');
654
+            if ($attrs = svg_lire_attributs($src)) {
655
+                [$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs);
656
+                if (!$srcWidth) {
657
+                    $largeur_img[$src] = $srcWidth = $width;
658
+                }
659
+                if (!$srcHeight) {
660
+                    $hauteur_img[$src] = $srcHeight = $height;
661
+                }
662
+                if (!$srcSize) {
663
+                    $poids_img[$src] = $srcSize = strlen($src);
664
+                }
665
+            }
666
+        }
667
+        // $src peut etre une reference a une image temporaire dont a n'a que le log .src
668
+        // on s'y refere, l'image sera reconstruite en temps utile si necessaire
669
+        elseif (
670
+            @file_exists($f = "$src.src")
671
+            and lire_fichier($f, $valeurs)
672
+            and $valeurs = unserialize($valeurs)
673
+        ) {
674
+            if (!$srcWidth) {
675
+                $largeur_img[$src] = $srcWidth = $valeurs['largeur_dest'];
676
+            }
677
+            if (!$srcHeight) {
678
+                $hauteur_img[$src] = $srcHeight = $valeurs['hauteur_dest'];
679
+            }
680
+            if (!$srcSize) {
681
+                $poids_img[$src] = $srcSize = 0;
682
+            }
683
+        }
684
+    }
685
+
686
+    return ['hauteur' => $srcHeight, 'largeur' => $srcWidth, 'poids' => $srcSize];
687 687
 }
688 688
 
689 689
 /**
@@ -699,13 +699,13 @@  discard block
 block discarded – undo
699 699
  *     poids
700 700
  **/
701 701
 function poids_image($img, $force_refresh = false) {
702
-	$infos = infos_image($img, $force_refresh);
703
-	return $infos['poids'];
702
+    $infos = infos_image($img, $force_refresh);
703
+    return $infos['poids'];
704 704
 }
705 705
 
706 706
 function taille_image($img, $force_refresh = false) {
707
-	$infos = infos_image($img, $force_refresh);
708
-	return [$infos['hauteur'], $infos['largeur']];
707
+    $infos = infos_image($img, $force_refresh);
708
+    return [$infos['hauteur'], $infos['largeur']];
709 709
 }
710 710
 
711 711
 /**
@@ -722,12 +722,12 @@  discard block
 block discarded – undo
722 722
  *     Largeur en pixels, NULL ou 0 si aucune image.
723 723
  **/
724 724
 function largeur($img) {
725
-	if (!$img) {
726
-		return;
727
-	}
728
-	[$h, $l] = taille_image($img);
725
+    if (!$img) {
726
+        return;
727
+    }
728
+    [$h, $l] = taille_image($img);
729 729
 
730
-	return $l;
730
+    return $l;
731 731
 }
732 732
 
733 733
 /**
@@ -744,12 +744,12 @@  discard block
 block discarded – undo
744 744
  *     Hauteur en pixels, NULL ou 0 si aucune image.
745 745
  **/
746 746
 function hauteur($img) {
747
-	if (!$img) {
748
-		return;
749
-	}
750
-	[$h, $l] = taille_image($img);
747
+    if (!$img) {
748
+        return;
749
+    }
750
+    [$h, $l] = taille_image($img);
751 751
 
752
-	return $h;
752
+    return $h;
753 753
 }
754 754
 
755 755
 
@@ -769,11 +769,11 @@  discard block
 block discarded – undo
769 769
  * @return string
770 770
  **/
771 771
 function corriger_entites_html($texte) {
772
-	if (strpos($texte, '&amp;') === false) {
773
-		return $texte;
774
-	}
772
+    if (strpos($texte, '&amp;') === false) {
773
+        return $texte;
774
+    }
775 775
 
776
-	return preg_replace(',&amp;(#[0-9][0-9][0-9]+;|amp;),iS', '&\1', $texte);
776
+    return preg_replace(',&amp;(#[0-9][0-9][0-9]+;|amp;),iS', '&\1', $texte);
777 777
 }
778 778
 
779 779
 /**
@@ -788,11 +788,11 @@  discard block
 block discarded – undo
788 788
  * @return string
789 789
  **/
790 790
 function corriger_toutes_entites_html($texte) {
791
-	if (strpos($texte, '&amp;') === false) {
792
-		return $texte;
793
-	}
791
+    if (strpos($texte, '&amp;') === false) {
792
+        return $texte;
793
+    }
794 794
 
795
-	return preg_replace(',&amp;(#?[a-z0-9]+;),iS', '&\1', $texte);
795
+    return preg_replace(',&amp;(#?[a-z0-9]+;),iS', '&\1', $texte);
796 796
 }
797 797
 
798 798
 /**
@@ -802,7 +802,7 @@  discard block
 block discarded – undo
802 802
  * @return string
803 803
  **/
804 804
 function proteger_amp($texte) {
805
-	return str_replace('&', '&amp;', $texte);
805
+    return str_replace('&', '&amp;', $texte);
806 806
 }
807 807
 
808 808
 
@@ -833,21 +833,21 @@  discard block
 block discarded – undo
833 833
  * @return mixed|string
834 834
  */
835 835
 function entites_html($texte, $tout = false, $quote = true) {
836
-	if (
837
-		!is_string($texte) or !$texte
838
-		or strpbrk($texte, "&\"'<>") == false
839
-	) {
840
-		return $texte;
841
-	}
842
-	include_spip('inc/texte');
843
-	$flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES);
844
-	$flags |= ENT_HTML401;
845
-	$texte = spip_htmlspecialchars(echappe_retour(echappe_html($texte, '', true), '', 'proteger_amp'), $flags);
846
-	if ($tout) {
847
-		return corriger_toutes_entites_html($texte);
848
-	} else {
849
-		return corriger_entites_html($texte);
850
-	}
836
+    if (
837
+        !is_string($texte) or !$texte
838
+        or strpbrk($texte, "&\"'<>") == false
839
+    ) {
840
+        return $texte;
841
+    }
842
+    include_spip('inc/texte');
843
+    $flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES);
844
+    $flags |= ENT_HTML401;
845
+    $texte = spip_htmlspecialchars(echappe_retour(echappe_html($texte, '', true), '', 'proteger_amp'), $flags);
846
+    if ($tout) {
847
+        return corriger_toutes_entites_html($texte);
848
+    } else {
849
+        return corriger_entites_html($texte);
850
+    }
851 851
 }
852 852
 
853 853
 /**
@@ -866,38 +866,38 @@  discard block
 block discarded – undo
866 866
  *     Texte converti
867 867
  **/
868 868
 function filtrer_entites(?string $texte): string {
869
-	$texte ??= '';
870
-	if (strpos($texte, '&') === false) {
871
-		return $texte;
872
-	}
873
-	// filtrer
874
-	$texte = html2unicode($texte);
875
-	// remettre le tout dans le charset cible
876
-	$texte = unicode2charset($texte);
877
-	// cas particulier des " et ' qu'il faut filtrer aussi
878
-	// (on le faisait deja avec un &quot;)
879
-	if (strpos($texte, '&#') !== false) {
880
-		$texte = str_replace(['&#039;', '&#39;', '&#034;', '&#34;'], ["'", "'", '"', '"'], $texte);
881
-	}
869
+    $texte ??= '';
870
+    if (strpos($texte, '&') === false) {
871
+        return $texte;
872
+    }
873
+    // filtrer
874
+    $texte = html2unicode($texte);
875
+    // remettre le tout dans le charset cible
876
+    $texte = unicode2charset($texte);
877
+    // cas particulier des " et ' qu'il faut filtrer aussi
878
+    // (on le faisait deja avec un &quot;)
879
+    if (strpos($texte, '&#') !== false) {
880
+        $texte = str_replace(['&#039;', '&#39;', '&#034;', '&#34;'], ["'", "'", '"', '"'], $texte);
881
+    }
882 882
 
883
-	return $texte;
883
+    return $texte;
884 884
 }
885 885
 
886 886
 
887 887
 if (!function_exists('filtre_filtrer_entites_dist')) {
888
-	/**
889
-	 * Version sécurisée de filtrer_entites
890
-	 *
891
-	 * @uses interdire_scripts()
892
-	 * @uses filtrer_entites()
893
-	 *
894
-	 * @param string $t
895
-	 * @return string
896
-	 */
897
-	function filtre_filtrer_entites_dist($t) {
898
-		include_spip('inc/texte');
899
-		return interdire_scripts(filtrer_entites($t));
900
-	}
888
+    /**
889
+     * Version sécurisée de filtrer_entites
890
+     *
891
+     * @uses interdire_scripts()
892
+     * @uses filtrer_entites()
893
+     *
894
+     * @param string $t
895
+     * @return string
896
+     */
897
+    function filtre_filtrer_entites_dist($t) {
898
+        include_spip('inc/texte');
899
+        return interdire_scripts(filtrer_entites($t));
900
+    }
901 901
 }
902 902
 
903 903
 
@@ -912,18 +912,18 @@  discard block
 block discarded – undo
912 912
  * @return string|array
913 913
  **/
914 914
 function supprimer_caracteres_illegaux($texte) {
915
-	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";
916
-	static $to = null;
915
+    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";
916
+    static $to = null;
917 917
 
918
-	if (is_array($texte)) {
919
-		return array_map('supprimer_caracteres_illegaux', $texte);
920
-	}
918
+    if (is_array($texte)) {
919
+        return array_map('supprimer_caracteres_illegaux', $texte);
920
+    }
921 921
 
922
-	if (!$to) {
923
-		$to = str_repeat('-', strlen($from));
924
-	}
922
+    if (!$to) {
923
+        $to = str_repeat('-', strlen($from));
924
+    }
925 925
 
926
-	return strtr($texte, $from, $to);
926
+    return strtr($texte, $from, $to);
927 927
 }
928 928
 
929 929
 /**
@@ -935,10 +935,10 @@  discard block
 block discarded – undo
935 935
  * @return string|array
936 936
  **/
937 937
 function corriger_caracteres($texte) {
938
-	$texte = corriger_caracteres_windows($texte);
939
-	$texte = supprimer_caracteres_illegaux($texte);
938
+    $texte = corriger_caracteres_windows($texte);
939
+    $texte = supprimer_caracteres_illegaux($texte);
940 940
 
941
-	return $texte;
941
+    return $texte;
942 942
 }
943 943
 
944 944
 /**
@@ -955,44 +955,44 @@  discard block
 block discarded – undo
955 955
  *     Texte encodé pour XML
956 956
  */
957 957
 function texte_backend(string $texte): string {
958
-	if ($texte === '') {
959
-		return '';
960
-	}
958
+    if ($texte === '') {
959
+        return '';
960
+    }
961 961
 
962
-	static $apostrophe = ['&#8217;', "'"]; # n'allouer qu'une fois
962
+    static $apostrophe = ['&#8217;', "'"]; # n'allouer qu'une fois
963 963
 
964
-	// si on a des liens ou des images, les passer en absolu
965
-	$texte = liens_absolus($texte);
964
+    // si on a des liens ou des images, les passer en absolu
965
+    $texte = liens_absolus($texte);
966 966
 
967
-	// echapper les tags &gt; &lt;
968
-	$texte = preg_replace(',&(gt|lt);,S', '&amp;\1;', $texte);
967
+    // echapper les tags &gt; &lt;
968
+    $texte = preg_replace(',&(gt|lt);,S', '&amp;\1;', $texte);
969 969
 
970
-	// importer les &eacute;
971
-	$texte = filtrer_entites($texte);
970
+    // importer les &eacute;
971
+    $texte = filtrer_entites($texte);
972 972
 
973
-	// " -> &quot; et tout ce genre de choses
974
-	$u = $GLOBALS['meta']['pcre_u'];
975
-	$texte = str_replace('&nbsp;', ' ', $texte);
976
-	$texte = preg_replace('/\s{2,}/S' . $u, ' ', $texte);
977
-	// ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
978
-	$texte = entites_html($texte, false, false);
979
-	// mais bien echapper les double quotes !
980
-	$texte = str_replace('"', '&#034;', $texte);
973
+    // " -> &quot; et tout ce genre de choses
974
+    $u = $GLOBALS['meta']['pcre_u'];
975
+    $texte = str_replace('&nbsp;', ' ', $texte);
976
+    $texte = preg_replace('/\s{2,}/S' . $u, ' ', $texte);
977
+    // ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
978
+    $texte = entites_html($texte, false, false);
979
+    // mais bien echapper les double quotes !
980
+    $texte = str_replace('"', '&#034;', $texte);
981 981
 
982
-	// verifier le charset
983
-	$texte = charset2unicode($texte);
982
+    // verifier le charset
983
+    $texte = charset2unicode($texte);
984 984
 
985
-	// Caracteres problematiques en iso-latin 1
986
-	if (isset($GLOBALS['meta']['charset']) and $GLOBALS['meta']['charset'] == 'iso-8859-1') {
987
-		$texte = str_replace(chr(156), '&#156;', $texte);
988
-		$texte = str_replace(chr(140), '&#140;', $texte);
989
-		$texte = str_replace(chr(159), '&#159;', $texte);
990
-	}
985
+    // Caracteres problematiques en iso-latin 1
986
+    if (isset($GLOBALS['meta']['charset']) and $GLOBALS['meta']['charset'] == 'iso-8859-1') {
987
+        $texte = str_replace(chr(156), '&#156;', $texte);
988
+        $texte = str_replace(chr(140), '&#140;', $texte);
989
+        $texte = str_replace(chr(159), '&#159;', $texte);
990
+    }
991 991
 
992
-	// l'apostrophe curly pose probleme a certains lecteure de RSS
993
-	// et le caractere apostrophe alourdit les squelettes avec PHP
994
-	// ==> on les remplace par l'entite HTML
995
-	return str_replace($apostrophe, "'", $texte);
992
+    // l'apostrophe curly pose probleme a certains lecteure de RSS
993
+    // et le caractere apostrophe alourdit les squelettes avec PHP
994
+    // ==> on les remplace par l'entite HTML
995
+    return str_replace($apostrophe, "'", $texte);
996 996
 }
997 997
 
998 998
 /**
@@ -1009,7 +1009,7 @@  discard block
 block discarded – undo
1009 1009
  *     Texte encodé et quote pour XML
1010 1010
  */
1011 1011
 function texte_backendq(string $texte): string {
1012
-	return addslashes(texte_backend($texte));
1012
+    return addslashes(texte_backend($texte));
1013 1013
 }
1014 1014
 
1015 1015
 
@@ -1031,14 +1031,14 @@  discard block
 block discarded – undo
1031 1031
  *     Texte sans son numéro éventuel
1032 1032
  **/
1033 1033
 function supprimer_numero(?string $texte): string {
1034
-	if ($texte === null) {
1035
-		return '';
1036
-	}
1037
-	return preg_replace(
1038
-		',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1039
-		'',
1040
-		$texte
1041
-	);
1034
+    if ($texte === null) {
1035
+        return '';
1036
+    }
1037
+    return preg_replace(
1038
+        ',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1039
+        '',
1040
+        $texte
1041
+    );
1042 1042
 }
1043 1043
 
1044 1044
 /**
@@ -1061,18 +1061,18 @@  discard block
 block discarded – undo
1061 1061
  *     Numéro de titre, sinon chaîne vide
1062 1062
  **/
1063 1063
 function recuperer_numero(?string $texte): string {
1064
-	if (
1065
-		$texte and
1066
-		preg_match(
1067
-			',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1068
-			$texte,
1069
-			$regs
1070
-		)
1071
-	) {
1072
-		return strval($regs[1]);
1073
-	} else {
1074
-		return '';
1075
-	}
1064
+    if (
1065
+        $texte and
1066
+        preg_match(
1067
+            ',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1068
+            $texte,
1069
+            $regs
1070
+        )
1071
+    ) {
1072
+        return strval($regs[1]);
1073
+    } else {
1074
+        return '';
1075
+    }
1076 1076
 }
1077 1077
 
1078 1078
 /**
@@ -1099,16 +1099,16 @@  discard block
 block discarded – undo
1099 1099
  *     Texte ou tableau de textes converti
1100 1100
  **/
1101 1101
 function supprimer_tags($texte, $rempl = '') {
1102
-	if ($texte === null) {
1103
-		return '';
1104
-	}
1105
-	$texte = preg_replace(',<(!--|\w|/|!\[endif|!\[if)[^>]*>,US', $rempl, $texte);
1106
-	// ne pas oublier un < final non ferme car coupe
1107
-	$texte = preg_replace(',<(!--|\w|/).*$,US', $rempl, $texte);
1108
-	// mais qui peut aussi etre un simple signe plus petit que
1109
-	$texte = str_replace('<', '&lt;', $texte);
1102
+    if ($texte === null) {
1103
+        return '';
1104
+    }
1105
+    $texte = preg_replace(',<(!--|\w|/|!\[endif|!\[if)[^>]*>,US', $rempl, $texte);
1106
+    // ne pas oublier un < final non ferme car coupe
1107
+    $texte = preg_replace(',<(!--|\w|/).*$,US', $rempl, $texte);
1108
+    // mais qui peut aussi etre un simple signe plus petit que
1109
+    $texte = str_replace('<', '&lt;', $texte);
1110 1110
 
1111
-	return $texte;
1111
+    return $texte;
1112 1112
 }
1113 1113
 
1114 1114
 /**
@@ -1131,9 +1131,9 @@  discard block
 block discarded – undo
1131 1131
  *     Texte converti
1132 1132
  **/
1133 1133
 function echapper_tags($texte, $rempl = '') {
1134
-	$texte = preg_replace('/<([^>]*)>/', "&lt;\\1&gt;", $texte);
1134
+    $texte = preg_replace('/<([^>]*)>/', "&lt;\\1&gt;", $texte);
1135 1135
 
1136
-	return $texte;
1136
+    return $texte;
1137 1137
 }
1138 1138
 
1139 1139
 /**
@@ -1154,18 +1154,18 @@  discard block
 block discarded – undo
1154 1154
  *     Texte converti
1155 1155
  **/
1156 1156
 function textebrut($texte) {
1157
-	$u = $GLOBALS['meta']['pcre_u'];
1158
-	$texte = preg_replace('/\s+/S' . $u, ' ', $texte);
1159
-	$texte = preg_replace('/<(p|br)( [^>]*)?' . '>/iS', "\n\n", $texte);
1160
-	$texte = preg_replace("/^\n+/", '', $texte);
1161
-	$texte = preg_replace("/\n+$/", '', $texte);
1162
-	$texte = preg_replace("/\n +/", "\n", $texte);
1163
-	$texte = supprimer_tags($texte);
1164
-	$texte = preg_replace('/(&nbsp;| )+/S', ' ', $texte);
1165
-	// nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail...
1166
-	$texte = str_replace('&#8217;', "'", $texte);
1157
+    $u = $GLOBALS['meta']['pcre_u'];
1158
+    $texte = preg_replace('/\s+/S' . $u, ' ', $texte);
1159
+    $texte = preg_replace('/<(p|br)( [^>]*)?' . '>/iS', "\n\n", $texte);
1160
+    $texte = preg_replace("/^\n+/", '', $texte);
1161
+    $texte = preg_replace("/\n+$/", '', $texte);
1162
+    $texte = preg_replace("/\n +/", "\n", $texte);
1163
+    $texte = supprimer_tags($texte);
1164
+    $texte = preg_replace('/(&nbsp;| )+/S', ' ', $texte);
1165
+    // nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail...
1166
+    $texte = str_replace('&#8217;', "'", $texte);
1167 1167
 
1168
-	return $texte;
1168
+    return $texte;
1169 1169
 }
1170 1170
 
1171 1171
 
@@ -1181,23 +1181,23 @@  discard block
 block discarded – undo
1181 1181
  *     Texte avec liens ouvrants
1182 1182
  **/
1183 1183
 function liens_ouvrants($texte) {
1184
-	if (
1185
-		preg_match_all(
1186
-			",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1187
-			$texte,
1188
-			$liens,
1189
-			PREG_PATTERN_ORDER
1190
-		)
1191
-	) {
1192
-		foreach ($liens[0] as $a) {
1193
-			$rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1194
-			$ablank = inserer_attribut($a, 'rel', $rel);
1195
-			$ablank = inserer_attribut($ablank, 'target', '_blank');
1196
-			$texte = str_replace($a, $ablank, $texte);
1197
-		}
1198
-	}
1199
-
1200
-	return $texte;
1184
+    if (
1185
+        preg_match_all(
1186
+            ",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1187
+            $texte,
1188
+            $liens,
1189
+            PREG_PATTERN_ORDER
1190
+        )
1191
+    ) {
1192
+        foreach ($liens[0] as $a) {
1193
+            $rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1194
+            $ablank = inserer_attribut($a, 'rel', $rel);
1195
+            $ablank = inserer_attribut($ablank, 'target', '_blank');
1196
+            $texte = str_replace($a, $ablank, $texte);
1197
+        }
1198
+    }
1199
+
1200
+    return $texte;
1201 1201
 }
1202 1202
 
1203 1203
 /**
@@ -1207,22 +1207,22 @@  discard block
 block discarded – undo
1207 1207
  * @return string
1208 1208
  */
1209 1209
 function liens_nofollow($texte) {
1210
-	if (stripos($texte, '<a') === false) {
1211
-		return $texte;
1212
-	}
1210
+    if (stripos($texte, '<a') === false) {
1211
+        return $texte;
1212
+    }
1213 1213
 
1214
-	if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) {
1215
-		foreach ($regs[0] as $a) {
1216
-			$rel = extraire_attribut($a, 'rel') ?? '';
1217
-			if (strpos($rel, 'nofollow') === false) {
1218
-				$rel = 'nofollow' . ($rel ? " $rel" : '');
1219
-				$anofollow = inserer_attribut($a, 'rel', $rel);
1220
-				$texte = str_replace($a, $anofollow, $texte);
1221
-			}
1222
-		}
1223
-	}
1214
+    if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) {
1215
+        foreach ($regs[0] as $a) {
1216
+            $rel = extraire_attribut($a, 'rel') ?? '';
1217
+            if (strpos($rel, 'nofollow') === false) {
1218
+                $rel = 'nofollow' . ($rel ? " $rel" : '');
1219
+                $anofollow = inserer_attribut($a, 'rel', $rel);
1220
+                $texte = str_replace($a, $anofollow, $texte);
1221
+            }
1222
+        }
1223
+    }
1224 1224
 
1225
-	return $texte;
1225
+    return $texte;
1226 1226
 }
1227 1227
 
1228 1228
 /**
@@ -1241,12 +1241,12 @@  discard block
 block discarded – undo
1241 1241
  *     Texte sans paraghaphes
1242 1242
  **/
1243 1243
 function PtoBR($texte) {
1244
-	$u = $GLOBALS['meta']['pcre_u'];
1245
-	$texte = preg_replace('@</p>@iS', "\n", $texte);
1246
-	$texte = preg_replace("@<p\b.*>@UiS", '<br />', $texte);
1247
-	$texte = preg_replace('@^\s*<br />@S' . $u, '', $texte);
1244
+    $u = $GLOBALS['meta']['pcre_u'];
1245
+    $texte = preg_replace('@</p>@iS', "\n", $texte);
1246
+    $texte = preg_replace("@<p\b.*>@UiS", '<br />', $texte);
1247
+    $texte = preg_replace('@^\s*<br />@S' . $u, '', $texte);
1248 1248
 
1249
-	return $texte;
1249
+    return $texte;
1250 1250
 }
1251 1251
 
1252 1252
 
@@ -1271,14 +1271,14 @@  discard block
 block discarded – undo
1271 1271
  * @return string Texte encadré du style CSS
1272 1272
  */
1273 1273
 function lignes_longues($texte) {
1274
-	if (!strlen(trim($texte))) {
1275
-		return $texte;
1276
-	}
1277
-	include_spip('inc/texte');
1278
-	$tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1279
-		'div' : 'span';
1274
+    if (!strlen(trim($texte))) {
1275
+        return $texte;
1276
+    }
1277
+    include_spip('inc/texte');
1278
+    $tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1279
+        'div' : 'span';
1280 1280
 
1281
-	return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
1281
+    return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
1282 1282
 }
1283 1283
 
1284 1284
 /**
@@ -1297,30 +1297,30 @@  discard block
 block discarded – undo
1297 1297
  * @return string Texte en majuscule
1298 1298
  */
1299 1299
 function majuscules($texte) {
1300
-	if (!strlen($texte)) {
1301
-		return '';
1302
-	}
1300
+    if (!strlen($texte)) {
1301
+        return '';
1302
+    }
1303 1303
 
1304
-	// Cas du turc
1305
-	if ($GLOBALS['spip_lang'] == 'tr') {
1306
-		# remplacer hors des tags et des entites
1307
-		if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) {
1308
-			foreach ($regs as $n => $match) {
1309
-				$texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte);
1310
-			}
1311
-		}
1304
+    // Cas du turc
1305
+    if ($GLOBALS['spip_lang'] == 'tr') {
1306
+        # remplacer hors des tags et des entites
1307
+        if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) {
1308
+            foreach ($regs as $n => $match) {
1309
+                $texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte);
1310
+            }
1311
+        }
1312 1312
 
1313
-		$texte = str_replace('i', '&#304;', $texte);
1313
+        $texte = str_replace('i', '&#304;', $texte);
1314 1314
 
1315
-		if ($regs) {
1316
-			foreach ($regs as $n => $match) {
1317
-				$texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte);
1318
-			}
1319
-		}
1320
-	}
1315
+        if ($regs) {
1316
+            foreach ($regs as $n => $match) {
1317
+                $texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte);
1318
+            }
1319
+        }
1320
+    }
1321 1321
 
1322
-	// Cas general
1323
-	return "<span style='text-transform: uppercase;'>$texte</span>";
1322
+    // Cas general
1323
+    return "<span style='text-transform: uppercase;'>$texte</span>";
1324 1324
 }
1325 1325
 
1326 1326
 /**
@@ -1338,29 +1338,29 @@  discard block
 block discarded – undo
1338 1338
  * @return string
1339 1339
  **/
1340 1340
 function taille_en_octets($taille) {
1341
-	if (!defined('_KILOBYTE')) {
1342
-		/**
1343
-		 * Définit le nombre d'octets dans un Kilobyte
1344
-		 *
1345
-		 * @var int
1346
-		 **/
1347
-		define('_KILOBYTE', 1024);
1348
-	}
1341
+    if (!defined('_KILOBYTE')) {
1342
+        /**
1343
+         * Définit le nombre d'octets dans un Kilobyte
1344
+         *
1345
+         * @var int
1346
+         **/
1347
+        define('_KILOBYTE', 1024);
1348
+    }
1349 1349
 
1350
-	if ($taille < 1) {
1351
-		return '';
1352
-	}
1353
-	if ($taille < _KILOBYTE) {
1354
-		$taille = _T('taille_octets', ['taille' => $taille]);
1355
-	} elseif ($taille < _KILOBYTE * _KILOBYTE) {
1356
-		$taille = _T('taille_ko', ['taille' => round($taille / _KILOBYTE, 1)]);
1357
-	} elseif ($taille < _KILOBYTE * _KILOBYTE * _KILOBYTE) {
1358
-		$taille = _T('taille_mo', ['taille' => round($taille / _KILOBYTE / _KILOBYTE, 1)]);
1359
-	} else {
1360
-		$taille = _T('taille_go', ['taille' => round($taille / _KILOBYTE / _KILOBYTE / _KILOBYTE, 2)]);
1361
-	}
1350
+    if ($taille < 1) {
1351
+        return '';
1352
+    }
1353
+    if ($taille < _KILOBYTE) {
1354
+        $taille = _T('taille_octets', ['taille' => $taille]);
1355
+    } elseif ($taille < _KILOBYTE * _KILOBYTE) {
1356
+        $taille = _T('taille_ko', ['taille' => round($taille / _KILOBYTE, 1)]);
1357
+    } elseif ($taille < _KILOBYTE * _KILOBYTE * _KILOBYTE) {
1358
+        $taille = _T('taille_mo', ['taille' => round($taille / _KILOBYTE / _KILOBYTE, 1)]);
1359
+    } else {
1360
+        $taille = _T('taille_go', ['taille' => round($taille / _KILOBYTE / _KILOBYTE / _KILOBYTE, 2)]);
1361
+    }
1362 1362
 
1363
-	return $taille;
1363
+    return $taille;
1364 1364
 }
1365 1365
 
1366 1366
 
@@ -1382,21 +1382,21 @@  discard block
 block discarded – undo
1382 1382
  *     Texte prêt pour être utilisé en attribut HTML
1383 1383
  **/
1384 1384
 function attribut_html(?string $texte, $textebrut = true): string {
1385
-	if ($texte === null) {
1386
-		return '';
1387
-	}
1388
-	$u = $GLOBALS['meta']['pcre_u'];
1389
-	if ($textebrut) {
1390
-		$texte = preg_replace([",\n,", ',\s(?=\s),msS' . $u], [' ', ''], textebrut($texte));
1391
-	}
1392
-	$texte = texte_backend($texte);
1393
-	$texte = str_replace(["'", '"'], ['&#039;', '&#034;'], $texte);
1385
+    if ($texte === null) {
1386
+        return '';
1387
+    }
1388
+    $u = $GLOBALS['meta']['pcre_u'];
1389
+    if ($textebrut) {
1390
+        $texte = preg_replace([",\n,", ',\s(?=\s),msS' . $u], [' ', ''], textebrut($texte));
1391
+    }
1392
+    $texte = texte_backend($texte);
1393
+    $texte = str_replace(["'", '"'], ['&#039;', '&#034;'], $texte);
1394 1394
 
1395
-	return preg_replace(
1396
-		['/&(amp;|#38;)/', '/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/'],
1397
-		['&', '&#38;'],
1398
-		$texte
1399
-	);
1395
+    return preg_replace(
1396
+        ['/&(amp;|#38;)/', '/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/'],
1397
+        ['&', '&#38;'],
1398
+        $texte
1399
+    );
1400 1400
 }
1401 1401
 
1402 1402
 
@@ -1416,15 +1416,15 @@  discard block
 block discarded – undo
1416 1416
  *     URL ou chaîne vide
1417 1417
  **/
1418 1418
 function vider_url(?string $url, $entites = true): string {
1419
-	if ($url === null) {
1420
-		return '';
1421
-	}
1422
-	# un message pour abs_url
1423
-	$GLOBALS['mode_abs_url'] = 'url';
1424
-	$url = trim($url);
1425
-	$r = ',^(?:' . _PROTOCOLES_STD . '):?/?/?$,iS';
1419
+    if ($url === null) {
1420
+        return '';
1421
+    }
1422
+    # un message pour abs_url
1423
+    $GLOBALS['mode_abs_url'] = 'url';
1424
+    $url = trim($url);
1425
+    $r = ',^(?:' . _PROTOCOLES_STD . '):?/?/?$,iS';
1426 1426
 
1427
-	return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1427
+    return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1428 1428
 }
1429 1429
 
1430 1430
 
@@ -1439,10 +1439,10 @@  discard block
 block discarded – undo
1439 1439
  * @return string Adresse email maquillée
1440 1440
  **/
1441 1441
 function antispam($texte) {
1442
-	include_spip('inc/acces');
1443
-	$masque = creer_pass_aleatoire(3);
1442
+    include_spip('inc/acces');
1443
+    $masque = creer_pass_aleatoire(3);
1444 1444
 
1445
-	return preg_replace('/@/', " $masque ", $texte);
1445
+    return preg_replace('/@/', " $masque ", $texte);
1446 1446
 }
1447 1447
 
1448 1448
 /**
@@ -1474,8 +1474,8 @@  discard block
 block discarded – undo
1474 1474
  *     True si on a le droit d'accès, false sinon.
1475 1475
  **/
1476 1476
 function filtre_securiser_acces_dist($id_auteur, $cle, $dir, $op = '', $args = '') {
1477
-	include_spip('inc/acces');
1478
-	return securiser_acces_low_sec($id_auteur, $cle, $op ? "$dir $op $args" : $dir);
1477
+    include_spip('inc/acces');
1478
+    return securiser_acces_low_sec($id_auteur, $cle, $op ? "$dir $op $args" : $dir);
1479 1479
 }
1480 1480
 
1481 1481
 /**
@@ -1500,13 +1500,13 @@  discard block
 block discarded – undo
1500 1500
  *     Retourne $texte, sinon $sinon.
1501 1501
  **/
1502 1502
 function sinon($texte, $sinon = '') {
1503
-	if ($texte) {
1504
-		return $texte;
1505
-	} elseif (is_scalar($texte) and strlen($texte)) {
1506
-		return $texte;
1507
-	} else {
1508
-		return $sinon;
1509
-	}
1503
+    if ($texte) {
1504
+        return $texte;
1505
+    } elseif (is_scalar($texte) and strlen($texte)) {
1506
+        return $texte;
1507
+    } else {
1508
+        return $sinon;
1509
+    }
1510 1510
 }
1511 1511
 
1512 1512
 /**
@@ -1530,7 +1530,7 @@  discard block
 block discarded – undo
1530 1530
  * @return mixed
1531 1531
  **/
1532 1532
 function choixsivide($a, $vide, $pasvide) {
1533
-	return $a ? $pasvide : $vide;
1533
+    return $a ? $pasvide : $vide;
1534 1534
 }
1535 1535
 
1536 1536
 /**
@@ -1554,7 +1554,7 @@  discard block
 block discarded – undo
1554 1554
  * @return mixed
1555 1555
  **/
1556 1556
 function choixsiegal($a1, $a2, $v, $f) {
1557
-	return ($a1 == $a2) ? $v : $f;
1557
+    return ($a1 == $a2) ? $v : $f;
1558 1558
 }
1559 1559
 
1560 1560
 //
@@ -1573,13 +1573,13 @@  discard block
 block discarded – undo
1573 1573
  * @return string
1574 1574
  **/
1575 1575
 function filtrer_ical($texte) {
1576
-	#include_spip('inc/charsets');
1577
-	$texte = html2unicode($texte);
1578
-	$texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset']), 'utf-8');
1579
-	$texte = preg_replace("/\n/", ' ', $texte);
1580
-	$texte = preg_replace('/,/', '\,', $texte);
1576
+    #include_spip('inc/charsets');
1577
+    $texte = html2unicode($texte);
1578
+    $texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset']), 'utf-8');
1579
+    $texte = preg_replace("/\n/", ' ', $texte);
1580
+    $texte = preg_replace('/,/', '\,', $texte);
1581 1581
 
1582
-	return $texte;
1582
+    return $texte;
1583 1583
 }
1584 1584
 
1585 1585
 
@@ -1604,58 +1604,58 @@  discard block
 block discarded – undo
1604 1604
  * @return string
1605 1605
  **/
1606 1606
 function post_autobr($texte, $delim = "\n_ ") {
1607
-	if (!function_exists('echappe_html')) {
1608
-		include_spip('inc/texte_mini');
1609
-	}
1610
-	$texte = str_replace("\r\n", "\r", $texte);
1611
-	$texte = str_replace("\r", "\n", $texte);
1612
-
1613
-	if (preg_match(",\n+$,", $texte, $fin)) {
1614
-		$texte = substr($texte, 0, -strlen($fin = $fin[0]));
1615
-	} else {
1616
-		$fin = '';
1617
-	}
1618
-
1619
-	$texte = echappe_html($texte, '', true);
1620
-
1621
-	// echapper les modeles
1622
-	$collecteurModeles = null;
1623
-	if (strpos($texte, '<') !== false) {
1624
-		include_spip("src/Texte/Collecteur/AbstractCollecteur");
1625
-		include_spip("src/Texte/Collecteur/Modeles");
1626
-		$collecteurModeles = new Spip\Texte\Collecteur\Modeles();
1627
-		$texte = $collecteurModeles->echapper($texte);
1628
-	}
1629
-
1630
-	$debut = '';
1631
-	$suite = $texte;
1632
-	while ($t = strpos('-' . $suite, "\n", 1)) {
1633
-		$debut .= substr($suite, 0, $t - 1);
1634
-		$suite = substr($suite, $t);
1635
-		$car = substr($suite, 0, 1);
1636
-		if (
1637
-			($car <> '-') and ($car <> '_') and ($car <> "\n") and ($car <> '|') and ($car <> '}')
1638
-			and !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite))
1639
-			and !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut)
1640
-		) {
1641
-			$debut .= $delim;
1642
-		} else {
1643
-			$debut .= "\n";
1644
-		}
1645
-		if (preg_match(",^\n+,", $suite, $regs)) {
1646
-			$debut .= $regs[0];
1647
-			$suite = substr($suite, strlen($regs[0]));
1648
-		}
1649
-	}
1650
-	$texte = $debut . $suite;
1651
-
1652
-	if ($collecteurModeles) {
1653
-		$texte = $collecteurModeles->retablir($texte);
1654
-	}
1655
-
1656
-	$texte = echappe_retour($texte);
1657
-
1658
-	return $texte . $fin;
1607
+    if (!function_exists('echappe_html')) {
1608
+        include_spip('inc/texte_mini');
1609
+    }
1610
+    $texte = str_replace("\r\n", "\r", $texte);
1611
+    $texte = str_replace("\r", "\n", $texte);
1612
+
1613
+    if (preg_match(",\n+$,", $texte, $fin)) {
1614
+        $texte = substr($texte, 0, -strlen($fin = $fin[0]));
1615
+    } else {
1616
+        $fin = '';
1617
+    }
1618
+
1619
+    $texte = echappe_html($texte, '', true);
1620
+
1621
+    // echapper les modeles
1622
+    $collecteurModeles = null;
1623
+    if (strpos($texte, '<') !== false) {
1624
+        include_spip("src/Texte/Collecteur/AbstractCollecteur");
1625
+        include_spip("src/Texte/Collecteur/Modeles");
1626
+        $collecteurModeles = new Spip\Texte\Collecteur\Modeles();
1627
+        $texte = $collecteurModeles->echapper($texte);
1628
+    }
1629
+
1630
+    $debut = '';
1631
+    $suite = $texte;
1632
+    while ($t = strpos('-' . $suite, "\n", 1)) {
1633
+        $debut .= substr($suite, 0, $t - 1);
1634
+        $suite = substr($suite, $t);
1635
+        $car = substr($suite, 0, 1);
1636
+        if (
1637
+            ($car <> '-') and ($car <> '_') and ($car <> "\n") and ($car <> '|') and ($car <> '}')
1638
+            and !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite))
1639
+            and !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut)
1640
+        ) {
1641
+            $debut .= $delim;
1642
+        } else {
1643
+            $debut .= "\n";
1644
+        }
1645
+        if (preg_match(",^\n+,", $suite, $regs)) {
1646
+            $debut .= $regs[0];
1647
+            $suite = substr($suite, strlen($regs[0]));
1648
+        }
1649
+    }
1650
+    $texte = $debut . $suite;
1651
+
1652
+    if ($collecteurModeles) {
1653
+        $texte = $collecteurModeles->retablir($texte);
1654
+    }
1655
+
1656
+    $texte = echappe_retour($texte);
1657
+
1658
+    return $texte . $fin;
1659 1659
 }
1660 1660
 
1661 1661
 
@@ -1690,30 +1690,30 @@  discard block
 block discarded – undo
1690 1690
  **/
1691 1691
 function extraire_idiome($letexte, $lang = null, $options = []) {
1692 1692
 
1693
-	if (
1694
-		$letexte
1695
-		and strpos($letexte, '<:') !== false
1696
-	) {
1697
-		if (!$lang) {
1698
-			$lang = $GLOBALS['spip_lang'];
1699
-		}
1700
-		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1701
-		if (is_bool($options)) {
1702
-			$options = ['echappe_span' => $options];
1703
-		}
1704
-		if (!isset($options['echappe_span'])) {
1705
-			$options = array_merge($options, ['echappe_span' => false]);
1706
-		}
1707
-		$options['lang'] = $lang;
1693
+    if (
1694
+        $letexte
1695
+        and strpos($letexte, '<:') !== false
1696
+    ) {
1697
+        if (!$lang) {
1698
+            $lang = $GLOBALS['spip_lang'];
1699
+        }
1700
+        // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1701
+        if (is_bool($options)) {
1702
+            $options = ['echappe_span' => $options];
1703
+        }
1704
+        if (!isset($options['echappe_span'])) {
1705
+            $options = array_merge($options, ['echappe_span' => false]);
1706
+        }
1707
+        $options['lang'] = $lang;
1708 1708
 
1709
-		include_spip("src/Texte/Collecteur/AbstractCollecteur");
1710
-		include_spip("src/Texte/Collecteur/Idiomes");
1711
-		$collecteurIdiomes = new Spip\Texte\Collecteur\Idiomes();
1709
+        include_spip("src/Texte/Collecteur/AbstractCollecteur");
1710
+        include_spip("src/Texte/Collecteur/Idiomes");
1711
+        $collecteurIdiomes = new Spip\Texte\Collecteur\Idiomes();
1712 1712
 
1713
-		$letexte = $collecteurIdiomes->traiter($letexte, $options);
1713
+        $letexte = $collecteurIdiomes->traiter($letexte, $options);
1714 1714
 
1715
-	}
1716
-	return $letexte;
1715
+    }
1716
+    return $letexte;
1717 1717
 }
1718 1718
 
1719 1719
 /**
@@ -1751,34 +1751,34 @@  discard block
 block discarded – undo
1751 1751
  **/
1752 1752
 function extraire_multi($letexte, $lang = null, $options = []) {
1753 1753
 
1754
-	if (
1755
-		$letexte
1756
-		and stripos($letexte, '<multi') !== false
1757
-	) {
1758
-		if (!$lang) {
1759
-			$lang = $GLOBALS['spip_lang'];
1760
-		}
1754
+    if (
1755
+        $letexte
1756
+        and stripos($letexte, '<multi') !== false
1757
+    ) {
1758
+        if (!$lang) {
1759
+            $lang = $GLOBALS['spip_lang'];
1760
+        }
1761 1761
 
1762
-		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1763
-		if (is_bool($options)) {
1764
-			$options = ['echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT];
1765
-		}
1766
-		if (!isset($options['echappe_span'])) {
1767
-			$options = array_merge($options, ['echappe_span' => false]);
1768
-		}
1769
-		if (!isset($options['lang_defaut'])) {
1770
-			$options = array_merge($options, ['lang_defaut' => _LANGUE_PAR_DEFAUT]);
1771
-		}
1772
-		$options['lang'] = $lang;
1762
+        // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1763
+        if (is_bool($options)) {
1764
+            $options = ['echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT];
1765
+        }
1766
+        if (!isset($options['echappe_span'])) {
1767
+            $options = array_merge($options, ['echappe_span' => false]);
1768
+        }
1769
+        if (!isset($options['lang_defaut'])) {
1770
+            $options = array_merge($options, ['lang_defaut' => _LANGUE_PAR_DEFAUT]);
1771
+        }
1772
+        $options['lang'] = $lang;
1773 1773
 
1774
-		include_spip("src/Texte/Collecteur/AbstractCollecteur");
1775
-		include_spip("src/Texte/Collecteur/Multis");
1776
-		$collecteurMultis = new Spip\Texte\Collecteur\Multis();
1774
+        include_spip("src/Texte/Collecteur/AbstractCollecteur");
1775
+        include_spip("src/Texte/Collecteur/Multis");
1776
+        $collecteurMultis = new Spip\Texte\Collecteur\Multis();
1777 1777
 
1778
-		$letexte = $collecteurMultis->traiter($letexte, $options);
1779
-	}
1778
+        $letexte = $collecteurMultis->traiter($letexte, $options);
1779
+    }
1780 1780
 
1781
-	return $letexte;
1781
+    return $letexte;
1782 1782
 }
1783 1783
 
1784 1784
 /**
@@ -1788,7 +1788,7 @@  discard block
 block discarded – undo
1788 1788
  * @return string L'initiale en majuscule
1789 1789
  */
1790 1790
 function filtre_initiale($nom) {
1791
-	return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1);
1791
+    return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1);
1792 1792
 }
1793 1793
 
1794 1794
 
@@ -1833,33 +1833,33 @@  discard block
 block discarded – undo
1833 1833
  *      - null (interne) : si on empile
1834 1834
  **/
1835 1835
 function unique($donnee, $famille = '', $cpt = false) {
1836
-	static $mem = [];
1837
-	// permettre de vider la pile et de la restaurer
1838
-	// pour le calcul de introduction...
1839
-	if ($famille == '_spip_raz_') {
1840
-		$tmp = $mem;
1841
-		$mem = [];
1842
-
1843
-		return $tmp;
1844
-	} elseif ($famille == '_spip_set_') {
1845
-		$mem = $donnee;
1846
-
1847
-		return;
1848
-	}
1849
-	// eviter une notice
1850
-	if (!isset($mem[$famille])) {
1851
-		$mem[$famille] = [];
1852
-	}
1853
-	if ($cpt) {
1854
-		return is_countable($mem[$famille]) ? count($mem[$famille]) : 0;
1855
-	}
1856
-	// eviter une notice
1857
-	if (!isset($mem[$famille][$donnee])) {
1858
-		$mem[$famille][$donnee] = 0;
1859
-	}
1860
-	if (!($mem[$famille][$donnee]++)) {
1861
-		return $donnee;
1862
-	}
1836
+    static $mem = [];
1837
+    // permettre de vider la pile et de la restaurer
1838
+    // pour le calcul de introduction...
1839
+    if ($famille == '_spip_raz_') {
1840
+        $tmp = $mem;
1841
+        $mem = [];
1842
+
1843
+        return $tmp;
1844
+    } elseif ($famille == '_spip_set_') {
1845
+        $mem = $donnee;
1846
+
1847
+        return;
1848
+    }
1849
+    // eviter une notice
1850
+    if (!isset($mem[$famille])) {
1851
+        $mem[$famille] = [];
1852
+    }
1853
+    if ($cpt) {
1854
+        return is_countable($mem[$famille]) ? count($mem[$famille]) : 0;
1855
+    }
1856
+    // eviter une notice
1857
+    if (!isset($mem[$famille][$donnee])) {
1858
+        $mem[$famille][$donnee] = 0;
1859
+    }
1860
+    if (!($mem[$famille][$donnee]++)) {
1861
+        return $donnee;
1862
+    }
1863 1863
 }
1864 1864
 
1865 1865
 
@@ -1889,20 +1889,20 @@  discard block
 block discarded – undo
1889 1889
  *     Une des valeurs en fonction du compteur.
1890 1890
  **/
1891 1891
 function alterner($i, ...$args) {
1892
-	// recuperer les arguments (attention fonctions un peu space)
1893
-	$num = count($args);
1892
+    // recuperer les arguments (attention fonctions un peu space)
1893
+    $num = count($args);
1894 1894
 
1895
-	if ($num === 1 && is_array($args[0])) {
1896
-		// un tableau de valeur dont les cles sont numerotees de 0 a num
1897
-		$args = array_values($args[0]);
1898
-		$num = count($args);
1899
-	}
1895
+    if ($num === 1 && is_array($args[0])) {
1896
+        // un tableau de valeur dont les cles sont numerotees de 0 a num
1897
+        $args = array_values($args[0]);
1898
+        $num = count($args);
1899
+    }
1900 1900
 
1901
-	// un index compris entre 0 et num exclus
1902
-	$i = ((intval($i) - 1) % $num); // dans ]-$num;$num[
1903
-	$i = ($i + $num) % $num; // dans [0;$num[
1904
-	// renvoyer le i-ieme argument, modulo le nombre d'arguments
1905
-	return $args[$i];
1901
+    // un index compris entre 0 et num exclus
1902
+    $i = ((intval($i) - 1) % $num); // dans ]-$num;$num[
1903
+    $i = ($i + $num) % $num; // dans [0;$num[
1904
+    // renvoyer le i-ieme argument, modulo le nombre d'arguments
1905
+    return $args[$i];
1906 1906
 }
1907 1907
 
1908 1908
 
@@ -1928,52 +1928,52 @@  discard block
 block discarded – undo
1928 1928
  *     - null lorsque l’attribut n’existe pas.
1929 1929
  **/
1930 1930
 function extraire_attribut($balise, $attribut, $complet = false) {
1931
-	if (is_array($balise)) {
1932
-		array_walk(
1933
-			$balise,
1934
-			function (&$a, $key, $t) {
1935
-				$a = extraire_attribut($a, $t);
1936
-			},
1937
-			$attribut
1938
-		);
1939
-
1940
-		return $balise;
1941
-	}
1942
-	if (
1943
-		$balise
1944
-		&& stripos($balise, $attribut) !== false
1945
-		&& preg_match(
1946
-			',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
1947
-			. $attribut
1948
-			. '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
1949
-			$balise,
1950
-			$r
1951
-		)
1952
-	) {
1953
-		if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) {
1954
-			$r[4] = substr($r[3], 1, -1);
1955
-			$r[3] = $r[3][0];
1956
-		} elseif ($r[3] !== '') {
1957
-			$r[4] = $r[3];
1958
-			$r[3] = '';
1959
-		} else {
1960
-			$r[4] = trim($r[2]);
1961
-		}
1962
-		$att = $r[4];
1963
-		if (strpos($att, '&#') !== false) {
1964
-			$att = str_replace(['&#039;', '&#39;', '&#034;', '&#34;'], ["'", "'", '"', '"'], $att);
1965
-		}
1966
-		$att = filtrer_entites($att);
1967
-	} else {
1968
-		$att = null;
1969
-		$r = [];
1970
-	}
1971
-
1972
-	if ($complet) {
1973
-		return [$att, $r];
1974
-	} else {
1975
-		return $att;
1976
-	}
1931
+    if (is_array($balise)) {
1932
+        array_walk(
1933
+            $balise,
1934
+            function (&$a, $key, $t) {
1935
+                $a = extraire_attribut($a, $t);
1936
+            },
1937
+            $attribut
1938
+        );
1939
+
1940
+        return $balise;
1941
+    }
1942
+    if (
1943
+        $balise
1944
+        && stripos($balise, $attribut) !== false
1945
+        && preg_match(
1946
+            ',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
1947
+            . $attribut
1948
+            . '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
1949
+            $balise,
1950
+            $r
1951
+        )
1952
+    ) {
1953
+        if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) {
1954
+            $r[4] = substr($r[3], 1, -1);
1955
+            $r[3] = $r[3][0];
1956
+        } elseif ($r[3] !== '') {
1957
+            $r[4] = $r[3];
1958
+            $r[3] = '';
1959
+        } else {
1960
+            $r[4] = trim($r[2]);
1961
+        }
1962
+        $att = $r[4];
1963
+        if (strpos($att, '&#') !== false) {
1964
+            $att = str_replace(['&#039;', '&#39;', '&#034;', '&#34;'], ["'", "'", '"', '"'], $att);
1965
+        }
1966
+        $att = filtrer_entites($att);
1967
+    } else {
1968
+        $att = null;
1969
+        $r = [];
1970
+    }
1971
+
1972
+    if ($complet) {
1973
+        return [$att, $r];
1974
+    } else {
1975
+        return $att;
1976
+    }
1977 1977
 }
1978 1978
 
1979 1979
 /**
@@ -2006,41 +2006,41 @@  discard block
 block discarded – undo
2006 2006
  **/
2007 2007
 function inserer_attribut(?string $balise, string $attribut, string $val, bool $proteger = true, bool $vider = false): string {
2008 2008
 
2009
-	if ($balise === null or $balise === '') {
2010
-		return '';
2011
-	}
2009
+    if ($balise === null or $balise === '') {
2010
+        return '';
2011
+    }
2012 2012
 
2013
-	// preparer l'attribut
2014
-	// supprimer les &nbsp; etc mais pas les balises html
2015
-	// qui ont un sens dans un attribut value d'un input
2016
-	if ($proteger) {
2017
-		$val = attribut_html($val, false);
2018
-	}
2013
+    // preparer l'attribut
2014
+    // supprimer les &nbsp; etc mais pas les balises html
2015
+    // qui ont un sens dans un attribut value d'un input
2016
+    if ($proteger) {
2017
+        $val = attribut_html($val, false);
2018
+    }
2019 2019
 
2020
-	// echapper les ' pour eviter tout bug
2021
-	$val = str_replace("'", '&#039;', $val);
2022
-	if ($vider and strlen($val) === 0) {
2023
-		$insert = '';
2024
-	} else {
2025
-		$insert = " $attribut='$val'";
2026
-	}
2020
+    // echapper les ' pour eviter tout bug
2021
+    $val = str_replace("'", '&#039;', $val);
2022
+    if ($vider and strlen($val) === 0) {
2023
+        $insert = '';
2024
+    } else {
2025
+        $insert = " $attribut='$val'";
2026
+    }
2027 2027
 
2028
-	[$old, $r] = extraire_attribut($balise, $attribut, true);
2028
+    [$old, $r] = extraire_attribut($balise, $attribut, true);
2029 2029
 
2030
-	if ($old !== null) {
2031
-		// Remplacer l'ancien attribut du meme nom
2032
-		$balise = $r[1] . $insert . $r[5];
2033
-	} else {
2034
-		// preferer une balise " />" (comme <img />)
2035
-		if (preg_match(',/>,', $balise)) {
2036
-			$balise = preg_replace(',\s?/>,S', $insert . ' />', $balise, 1);
2037
-		} // sinon une balise <a ...> ... </a>
2038
-		else {
2039
-			$balise = preg_replace(',\s?>,S', $insert . '>', $balise, 1);
2040
-		}
2041
-	}
2030
+    if ($old !== null) {
2031
+        // Remplacer l'ancien attribut du meme nom
2032
+        $balise = $r[1] . $insert . $r[5];
2033
+    } else {
2034
+        // preferer une balise " />" (comme <img />)
2035
+        if (preg_match(',/>,', $balise)) {
2036
+            $balise = preg_replace(',\s?/>,S', $insert . ' />', $balise, 1);
2037
+        } // sinon une balise <a ...> ... </a>
2038
+        else {
2039
+            $balise = preg_replace(',\s?>,S', $insert . '>', $balise, 1);
2040
+        }
2041
+    }
2042 2042
 
2043
-	return $balise;
2043
+    return $balise;
2044 2044
 }
2045 2045
 
2046 2046
 /**
@@ -2058,7 +2058,7 @@  discard block
 block discarded – undo
2058 2058
  * @return string Code HTML sans l'attribut
2059 2059
  **/
2060 2060
 function vider_attribut(?string $balise, string $attribut): string {
2061
-	return inserer_attribut($balise, $attribut, '', false, true);
2061
+    return inserer_attribut($balise, $attribut, '', false, true);
2062 2062
 }
2063 2063
 
2064 2064
 /**
@@ -2070,53 +2070,53 @@  discard block
 block discarded – undo
2070 2070
  * @return string
2071 2071
  */
2072 2072
 function modifier_class($balise, $class, $operation = 'ajouter') {
2073
-	if (is_string($class)) {
2074
-		$class = explode(' ', trim($class));
2075
-	}
2076
-	$class = array_filter($class);
2077
-	$class = array_unique($class);
2078
-	if (!$class) {
2079
-		return $balise;
2080
-	}
2081
-
2082
-	// si la ou les classes ont des caracteres invalides on ne fait rien
2083
-	if (preg_match(',[^\w-],', implode('', $class))) {
2084
-		return $balise;
2085
-	}
2086
-
2087
-	$class_courante = extraire_attribut($balise, 'class');
2088
-	$class_new = $class_courante;
2089
-	foreach ($class as $c) {
2090
-		$is_class_presente = false;
2091
-		if (
2092
-			$class_courante
2093
-			and strpos($class_courante, (string) $c) !== false
2094
-			and preg_match('/(^|\s)' . preg_quote($c) . '($|\s)/', $class_courante)
2095
-		) {
2096
-			$is_class_presente = true;
2097
-		}
2098
-		if (
2099
-			in_array($operation, ['ajouter', 'commuter'])
2100
-			and !$is_class_presente
2101
-		) {
2102
-			$class_new = ltrim(rtrim($class_new ?? '') . ' ' . $c);
2103
-		} elseif (
2104
-			in_array($operation, ['supprimer', 'commuter'])
2105
-			and $is_class_presente
2106
-		) {
2107
-			$class_new = trim(preg_replace('/(^|\s)' . preg_quote($c) . '($|\s)/', "\\1", $class_new));
2108
-		}
2109
-	}
2110
-
2111
-	if ($class_new !== $class_courante) {
2112
-		if (strlen($class_new)) {
2113
-			$balise = inserer_attribut($balise, 'class', $class_new);
2114
-		} elseif ($class_courante) {
2115
-			$balise = vider_attribut($balise, 'class');
2116
-		}
2117
-	}
2118
-
2119
-	return $balise;
2073
+    if (is_string($class)) {
2074
+        $class = explode(' ', trim($class));
2075
+    }
2076
+    $class = array_filter($class);
2077
+    $class = array_unique($class);
2078
+    if (!$class) {
2079
+        return $balise;
2080
+    }
2081
+
2082
+    // si la ou les classes ont des caracteres invalides on ne fait rien
2083
+    if (preg_match(',[^\w-],', implode('', $class))) {
2084
+        return $balise;
2085
+    }
2086
+
2087
+    $class_courante = extraire_attribut($balise, 'class');
2088
+    $class_new = $class_courante;
2089
+    foreach ($class as $c) {
2090
+        $is_class_presente = false;
2091
+        if (
2092
+            $class_courante
2093
+            and strpos($class_courante, (string) $c) !== false
2094
+            and preg_match('/(^|\s)' . preg_quote($c) . '($|\s)/', $class_courante)
2095
+        ) {
2096
+            $is_class_presente = true;
2097
+        }
2098
+        if (
2099
+            in_array($operation, ['ajouter', 'commuter'])
2100
+            and !$is_class_presente
2101
+        ) {
2102
+            $class_new = ltrim(rtrim($class_new ?? '') . ' ' . $c);
2103
+        } elseif (
2104
+            in_array($operation, ['supprimer', 'commuter'])
2105
+            and $is_class_presente
2106
+        ) {
2107
+            $class_new = trim(preg_replace('/(^|\s)' . preg_quote($c) . '($|\s)/', "\\1", $class_new));
2108
+        }
2109
+    }
2110
+
2111
+    if ($class_new !== $class_courante) {
2112
+        if (strlen($class_new)) {
2113
+            $balise = inserer_attribut($balise, 'class', $class_new);
2114
+        } elseif ($class_courante) {
2115
+            $balise = vider_attribut($balise, 'class');
2116
+        }
2117
+    }
2118
+
2119
+    return $balise;
2120 2120
 }
2121 2121
 
2122 2122
 /**
@@ -2126,7 +2126,7 @@  discard block
 block discarded – undo
2126 2126
  * @return string
2127 2127
  */
2128 2128
 function ajouter_class($balise, $class) {
2129
-	return modifier_class($balise, $class, 'ajouter');
2129
+    return modifier_class($balise, $class, 'ajouter');
2130 2130
 }
2131 2131
 
2132 2132
 /**
@@ -2136,7 +2136,7 @@  discard block
 block discarded – undo
2136 2136
  * @return string
2137 2137
  */
2138 2138
 function supprimer_class($balise, $class) {
2139
-	return modifier_class($balise, $class, 'supprimer');
2139
+    return modifier_class($balise, $class, 'supprimer');
2140 2140
 }
2141 2141
 
2142 2142
 /**
@@ -2147,7 +2147,7 @@  discard block
 block discarded – undo
2147 2147
  * @return string
2148 2148
  */
2149 2149
 function commuter_class($balise, $class) {
2150
-	return modifier_class($balise, $class, 'commuter');
2150
+    return modifier_class($balise, $class, 'commuter');
2151 2151
 }
2152 2152
 
2153 2153
 /**
@@ -2158,19 +2158,19 @@  discard block
 block discarded – undo
2158 2158
  * @return string
2159 2159
  */
2160 2160
 function tester_config($id, $mode = '') {
2161
-	include_spip('action/inscrire_auteur');
2161
+    include_spip('action/inscrire_auteur');
2162 2162
 
2163
-	return tester_statut_inscription($mode, $id);
2163
+    return tester_statut_inscription($mode, $id);
2164 2164
 }
2165 2165
 
2166 2166
 //
2167 2167
 // Quelques fonctions de calcul arithmetique
2168 2168
 //
2169 2169
 function floatstr($a) {
2170
- return str_replace(',', '.', (string)floatval($a));
2170
+    return str_replace(',', '.', (string)floatval($a));
2171 2171
 }
2172 2172
 function strize($f, $a, $b) {
2173
- return floatstr($f(floatstr($a), floatstr($b)));
2173
+    return floatstr($f(floatstr($a), floatstr($b)));
2174 2174
 }
2175 2175
 
2176 2176
 /**
@@ -2189,7 +2189,7 @@  discard block
 block discarded – undo
2189 2189
  * @return int $a+$b
2190 2190
  **/
2191 2191
 function plus($a, $b) {
2192
-	return $a + $b;
2192
+    return $a + $b;
2193 2193
 }
2194 2194
 function strplus($a, $b) {
2195 2195
 return strize('plus', $a, $b);
@@ -2210,7 +2210,7 @@  discard block
 block discarded – undo
2210 2210
  * @return int $a-$b
2211 2211
  **/
2212 2212
 function moins($a, $b) {
2213
-	return $a - $b;
2213
+    return $a - $b;
2214 2214
 }
2215 2215
 function strmoins($a, $b) {
2216 2216
 return strize('moins', $a, $b);
@@ -2233,7 +2233,7 @@  discard block
 block discarded – undo
2233 2233
  * @return int $a*$b
2234 2234
  **/
2235 2235
 function mult($a, $b) {
2236
-	return $a * $b;
2236
+    return $a * $b;
2237 2237
 }
2238 2238
 function strmult($a, $b) {
2239 2239
 return strize('mult', $a, $b);
@@ -2256,7 +2256,7 @@  discard block
 block discarded – undo
2256 2256
  * @return int $a/$b (ou 0 si $b est nul)
2257 2257
  **/
2258 2258
 function div($a, $b) {
2259
-	return $b ? $a / $b : 0;
2259
+    return $b ? $a / $b : 0;
2260 2260
 }
2261 2261
 function strdiv($a, $b) {
2262 2262
 return strize('div', $a, $b);
@@ -2280,7 +2280,7 @@  discard block
 block discarded – undo
2280 2280
  * @return int ($nb % $mod) + $add
2281 2281
  **/
2282 2282
 function modulo($nb, $mod, $add = 0) {
2283
-	return ($mod ? $nb % $mod : 0) + $add;
2283
+    return ($mod ? $nb % $mod : 0) + $add;
2284 2284
 }
2285 2285
 
2286 2286
 
@@ -2295,26 +2295,26 @@  discard block
 block discarded – undo
2295 2295
  *      - true sinon
2296 2296
  **/
2297 2297
 function nom_acceptable($nom) {
2298
-	$remp2 = [];
2299
-	$remp1 = [];
2300
-	if (!is_string($nom)) {
2301
-		return false;
2302
-	}
2303
-	if (!defined('_TAGS_NOM_AUTEUR')) {
2304
-		define('_TAGS_NOM_AUTEUR', '');
2305
-	}
2306
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2307
-	foreach ($tags_acceptes as $tag) {
2308
-		if (strlen($tag)) {
2309
-			$remp1[] = '<' . trim($tag) . '>';
2310
-			$remp1[] = '</' . trim($tag) . '>';
2311
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2312
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2313
-		}
2314
-	}
2315
-	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2316
-
2317
-	return str_replace('&lt;', '<', $v_nom) == $nom;
2298
+    $remp2 = [];
2299
+    $remp1 = [];
2300
+    if (!is_string($nom)) {
2301
+        return false;
2302
+    }
2303
+    if (!defined('_TAGS_NOM_AUTEUR')) {
2304
+        define('_TAGS_NOM_AUTEUR', '');
2305
+    }
2306
+    $tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2307
+    foreach ($tags_acceptes as $tag) {
2308
+        if (strlen($tag)) {
2309
+            $remp1[] = '<' . trim($tag) . '>';
2310
+            $remp1[] = '</' . trim($tag) . '>';
2311
+            $remp2[] = '\x60' . trim($tag) . '\x61';
2312
+            $remp2[] = '\x60/' . trim($tag) . '\x61';
2313
+        }
2314
+    }
2315
+    $v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2316
+
2317
+    return str_replace('&lt;', '<', $v_nom) == $nom;
2318 2318
 }
2319 2319
 
2320 2320
 
@@ -2330,14 +2330,14 @@  discard block
 block discarded – undo
2330 2330
  *      - renvoie un tableau si l'entree est un tableau
2331 2331
  **/
2332 2332
 function email_valide($adresses) {
2333
-	if (is_array($adresses)) {
2334
-		$adresses = array_map('email_valide', $adresses);
2335
-		$adresses = array_filter($adresses);
2336
-		return $adresses;
2337
-	}
2333
+    if (is_array($adresses)) {
2334
+        $adresses = array_map('email_valide', $adresses);
2335
+        $adresses = array_filter($adresses);
2336
+        return $adresses;
2337
+    }
2338 2338
 
2339
-	$email_valide = charger_fonction('email_valide', 'inc');
2340
-	return $email_valide($adresses);
2339
+    $email_valide = charger_fonction('email_valide', 'inc');
2340
+    return $email_valide($adresses);
2341 2341
 }
2342 2342
 
2343 2343
 /**
@@ -2351,29 +2351,29 @@  discard block
 block discarded – undo
2351 2351
  * @return string Texte
2352 2352
  **/
2353 2353
 function afficher_enclosures($tags) {
2354
-	$s = [];
2355
-	foreach (extraire_balises($tags, 'a') as $tag) {
2356
-		if (
2357
-			extraire_attribut($tag, 'rel') == 'enclosure'
2358
-			and $t = extraire_attribut($tag, 'href')
2359
-		) {
2360
-			$s[] = preg_replace(
2361
-				',>[^<]+</a>,S',
2362
-				'>'
2363
-				. http_img_pack(
2364
-					'attachment-16.png',
2365
-					$t,
2366
-					'',
2367
-					$t,
2368
-					['utiliser_suffixe_size' => true]
2369
-				)
2370
-				. '</a>',
2371
-				$tag
2372
-			);
2373
-		}
2374
-	}
2375
-
2376
-	return join('&nbsp;', $s);
2354
+    $s = [];
2355
+    foreach (extraire_balises($tags, 'a') as $tag) {
2356
+        if (
2357
+            extraire_attribut($tag, 'rel') == 'enclosure'
2358
+            and $t = extraire_attribut($tag, 'href')
2359
+        ) {
2360
+            $s[] = preg_replace(
2361
+                ',>[^<]+</a>,S',
2362
+                '>'
2363
+                . http_img_pack(
2364
+                    'attachment-16.png',
2365
+                    $t,
2366
+                    '',
2367
+                    $t,
2368
+                    ['utiliser_suffixe_size' => true]
2369
+                )
2370
+                . '</a>',
2371
+                $tag
2372
+            );
2373
+        }
2374
+    }
2375
+
2376
+    return join('&nbsp;', $s);
2377 2377
 }
2378 2378
 
2379 2379
 /**
@@ -2388,15 +2388,15 @@  discard block
 block discarded – undo
2388 2388
  * @return string Liens trouvés
2389 2389
  **/
2390 2390
 function afficher_tags($tags, $rels = 'tag,directory') {
2391
-	$s = [];
2392
-	foreach (extraire_balises($tags, 'a') as $tag) {
2393
-		$rel = extraire_attribut($tag, 'rel');
2394
-		if (strstr(",$rels,", (string) ",$rel,")) {
2395
-			$s[] = $tag;
2396
-		}
2397
-	}
2391
+    $s = [];
2392
+    foreach (extraire_balises($tags, 'a') as $tag) {
2393
+        $rel = extraire_attribut($tag, 'rel');
2394
+        if (strstr(",$rels,", (string) ",$rel,")) {
2395
+            $s[] = $tag;
2396
+        }
2397
+    }
2398 2398
 
2399
-	return join(', ', $s);
2399
+    return join(', ', $s);
2400 2400
 }
2401 2401
 
2402 2402
 
@@ -2418,21 +2418,21 @@  discard block
 block discarded – undo
2418 2418
  * @return string Tag HTML `<a>` avec microformat.
2419 2419
  **/
2420 2420
 function enclosure2microformat($e) {
2421
-	if (!$url = filtrer_entites(extraire_attribut($e, 'url') ?? '')) {
2422
-		$url = filtrer_entites(extraire_attribut($e, 'href') ?? '');
2423
-	}
2424
-	$type = extraire_attribut($e, 'type');
2425
-	if (!$length = extraire_attribut($e, 'length')) {
2426
-		# <media:content : longeur dans fileSize. On tente.
2427
-		$length = extraire_attribut($e, 'fileSize');
2428
-	}
2429
-	$fichier = basename($url);
2421
+    if (!$url = filtrer_entites(extraire_attribut($e, 'url') ?? '')) {
2422
+        $url = filtrer_entites(extraire_attribut($e, 'href') ?? '');
2423
+    }
2424
+    $type = extraire_attribut($e, 'type');
2425
+    if (!$length = extraire_attribut($e, 'length')) {
2426
+        # <media:content : longeur dans fileSize. On tente.
2427
+        $length = extraire_attribut($e, 'fileSize');
2428
+    }
2429
+    $fichier = basename($url);
2430 2430
 
2431
-	return '<a rel="enclosure"'
2432
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2433
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2434
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2435
-	. '>' . $fichier . '</a>';
2431
+    return '<a rel="enclosure"'
2432
+    . ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2433
+    . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2434
+    . ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2435
+    . '>' . $fichier . '</a>';
2436 2436
 }
2437 2437
 
2438 2438
 /**
@@ -2450,24 +2450,24 @@  discard block
 block discarded – undo
2450 2450
  * @return string Tags RSS `<enclosure>`.
2451 2451
  **/
2452 2452
 function microformat2enclosure($tags) {
2453
-	$enclosures = [];
2454
-	foreach (extraire_balises($tags, 'a') as $e) {
2455
-		if (extraire_attribut($e, 'rel') == 'enclosure') {
2456
-			$url = filtrer_entites(extraire_attribut($e, 'href'));
2457
-			$type = extraire_attribut($e, 'type');
2458
-			if (!$length = intval(extraire_attribut($e, 'title'))) {
2459
-				$length = intval(extraire_attribut($e, 'length'));
2460
-			} # vieux data
2461
-			$fichier = basename($url);
2462
-			$enclosures[] = '<enclosure'
2463
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2464
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2465
-				. ($length ? ' length="' . $length . '"' : '')
2466
-				. ' />';
2467
-		}
2468
-	}
2453
+    $enclosures = [];
2454
+    foreach (extraire_balises($tags, 'a') as $e) {
2455
+        if (extraire_attribut($e, 'rel') == 'enclosure') {
2456
+            $url = filtrer_entites(extraire_attribut($e, 'href'));
2457
+            $type = extraire_attribut($e, 'type');
2458
+            if (!$length = intval(extraire_attribut($e, 'title'))) {
2459
+                $length = intval(extraire_attribut($e, 'length'));
2460
+            } # vieux data
2461
+            $fichier = basename($url);
2462
+            $enclosures[] = '<enclosure'
2463
+                . ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2464
+                . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2465
+                . ($length ? ' length="' . $length . '"' : '')
2466
+                . ' />';
2467
+        }
2468
+    }
2469 2469
 
2470
-	return join("\n", $enclosures);
2470
+    return join("\n", $enclosures);
2471 2471
 }
2472 2472
 
2473 2473
 
@@ -2483,16 +2483,16 @@  discard block
 block discarded – undo
2483 2483
  * @return string Tags RSS Atom `<dc:subject>`.
2484 2484
  **/
2485 2485
 function tags2dcsubject($tags) {
2486
-	$subjects = '';
2487
-	foreach (extraire_balises($tags, 'a') as $e) {
2488
-		if (extraire_attribut($e, 'rel') == 'tag') {
2489
-			$subjects .= '<dc:subject>'
2490
-				. texte_backend(textebrut($e))
2491
-				. '</dc:subject>' . "\n";
2492
-		}
2493
-	}
2486
+    $subjects = '';
2487
+    foreach (extraire_balises($tags, 'a') as $e) {
2488
+        if (extraire_attribut($e, 'rel') == 'tag') {
2489
+            $subjects .= '<dc:subject>'
2490
+                . texte_backend(textebrut($e))
2491
+                . '</dc:subject>' . "\n";
2492
+        }
2493
+    }
2494 2494
 
2495
-	return $subjects;
2495
+    return $subjects;
2496 2496
 }
2497 2497
 
2498 2498
 /**
@@ -2521,27 +2521,27 @@  discard block
 block discarded – undo
2521 2521
  *     - Tableau de résultats, si tableau en entrée.
2522 2522
  **/
2523 2523
 function extraire_balise($texte, $tag = 'a') {
2524
-	if (is_array($texte)) {
2525
-		array_walk(
2526
-			$texte,
2527
-			function (&$a, $key, $t) {
2528
-				$a = extraire_balise($a, $t);
2529
-			},
2530
-			$tag
2531
-		);
2532
-
2533
-		return $texte;
2534
-	}
2535
-
2536
-	if (
2537
-		preg_match(
2538
-			",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS",
2539
-			$texte,
2540
-			$regs
2541
-		)
2542
-	) {
2543
-		return $regs[0];
2544
-	}
2524
+    if (is_array($texte)) {
2525
+        array_walk(
2526
+            $texte,
2527
+            function (&$a, $key, $t) {
2528
+                $a = extraire_balise($a, $t);
2529
+            },
2530
+            $tag
2531
+        );
2532
+
2533
+        return $texte;
2534
+    }
2535
+
2536
+    if (
2537
+        preg_match(
2538
+            ",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS",
2539
+            $texte,
2540
+            $regs
2541
+        )
2542
+    ) {
2543
+        return $regs[0];
2544
+    }
2545 2545
 }
2546 2546
 
2547 2547
 /**
@@ -2569,30 +2569,30 @@  discard block
 block discarded – undo
2569 2569
  *     - Tableau de résultats, si tableau en entrée.
2570 2570
  **/
2571 2571
 function extraire_balises($texte, $tag = 'a') {
2572
-	if (is_array($texte)) {
2573
-		array_walk(
2574
-			$texte,
2575
-			function (&$a, $key, $t) {
2576
-				$a = extraire_balises($a, $t);
2577
-			},
2578
-			$tag
2579
-		);
2580
-
2581
-		return $texte;
2582
-	}
2583
-
2584
-	if (
2585
-		preg_match_all(
2586
-			",<{$tag}\b[^>]*(/>|>.*</{$tag}\b[^>]*>|>),UimsS",
2587
-			$texte,
2588
-			$regs,
2589
-			PREG_PATTERN_ORDER
2590
-		)
2591
-	) {
2592
-		return $regs[0];
2593
-	} else {
2594
-		return [];
2595
-	}
2572
+    if (is_array($texte)) {
2573
+        array_walk(
2574
+            $texte,
2575
+            function (&$a, $key, $t) {
2576
+                $a = extraire_balises($a, $t);
2577
+            },
2578
+            $tag
2579
+        );
2580
+
2581
+        return $texte;
2582
+    }
2583
+
2584
+    if (
2585
+        preg_match_all(
2586
+            ",<{$tag}\b[^>]*(/>|>.*</{$tag}\b[^>]*>|>),UimsS",
2587
+            $texte,
2588
+            $regs,
2589
+            PREG_PATTERN_ORDER
2590
+        )
2591
+    ) {
2592
+        return $regs[0];
2593
+    } else {
2594
+        return [];
2595
+    }
2596 2596
 }
2597 2597
 
2598 2598
 /**
@@ -2621,11 +2621,11 @@  discard block
 block discarded – undo
2621 2621
  *     - `$def` si on n'a pas transmis de tableau
2622 2622
  **/
2623 2623
 function in_any($val, $vals, $def = '') {
2624
-	if (!is_array($vals) and $vals and $v = unserialize($vals)) {
2625
-		$vals = $v;
2626
-	}
2624
+    if (!is_array($vals) and $vals and $v = unserialize($vals)) {
2625
+        $vals = $v;
2626
+    }
2627 2627
 
2628
-	return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : ''));
2628
+    return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : ''));
2629 2629
 }
2630 2630
 
2631 2631
 
@@ -2646,12 +2646,12 @@  discard block
 block discarded – undo
2646 2646
  *     Résultat du calcul
2647 2647
  **/
2648 2648
 function valeur_numerique($expr) {
2649
-	$a = 0;
2650
-	if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) {
2651
-		eval("\$a = $expr;");
2652
-	}
2649
+    $a = 0;
2650
+    if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) {
2651
+        eval("\$a = $expr;");
2652
+    }
2653 2653
 
2654
-	return intval($a);
2654
+    return intval($a);
2655 2655
 }
2656 2656
 
2657 2657
 /**
@@ -2670,7 +2670,7 @@  discard block
 block discarded – undo
2670 2670
  *      Retourne `$a*$b/$c`
2671 2671
  **/
2672 2672
 function regledetrois($a, $b, $c) {
2673
-	return round($a * $b / $c);
2673
+    return round($a * $b / $c);
2674 2674
 }
2675 2675
 
2676 2676
 
@@ -2693,79 +2693,79 @@  discard block
 block discarded – undo
2693 2693
  * @return string Suite de champs input hidden
2694 2694
  **/
2695 2695
 function form_hidden(?string $action = ''): string {
2696
-	$action ??= '';
2697
-
2698
-	$contexte = [];
2699
-	include_spip('inc/urls');
2700
-	if (
2701
-		$p = urls_decoder_url($action, '')
2702
-		and reset($p)
2703
-	) {
2704
-		$fond = array_shift($p);
2705
-		if ($fond != '404') {
2706
-			$contexte = array_shift($p);
2707
-			$contexte['page'] = $fond;
2708
-			$action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2709
-		}
2710
-	}
2711
-	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2712
-	if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
2713
-		unset($contexte['type']);
2714
-	}
2715
-	if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') or _DEFINIR_CONTEXTE_TYPE_PAGE) {
2716
-		unset($contexte['type-page']);
2717
-	}
2718
-
2719
-	// on va remplir un tableau de valeurs en prenant bien soin de ne pas
2720
-	// ecraser les elements de la forme mots[]=1&mots[]=2
2721
-	$values = [];
2722
-
2723
-	// d'abord avec celles de l'url
2724
-	if (false !== ($p = strpos($action, '?'))) {
2725
-		foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2726
-			$c = explode('=', $c, 2);
2727
-			$var = array_shift($c);
2728
-			$val = array_shift($c) ?? '';
2729
-			if ($var) {
2730
-				$val = rawurldecode($val);
2731
-				$var = rawurldecode($var); // decoder les [] eventuels
2732
-				if (preg_match(',\[\]$,S', $var)) {
2733
-					$values[] = [$var, $val];
2734
-				} else {
2735
-					if (!isset($values[$var])) {
2736
-						$values[$var] = [$var, $val];
2737
-					}
2738
-				}
2739
-			}
2740
-		}
2741
-	}
2742
-
2743
-	// ensuite avec celles du contexte, sans doublonner !
2744
-	foreach ($contexte as $var => $val) {
2745
-		if (preg_match(',\[\]$,S', $var)) {
2746
-			$values[] = [$var, $val];
2747
-		} else {
2748
-			if (!isset($values[$var])) {
2749
-				$values[$var] = [$var, $val];
2750
-			}
2751
-		}
2752
-	}
2753
-
2754
-	// puis on rassemble le tout
2755
-	$hidden = [];
2756
-	foreach ($values as $value) {
2757
-		[$var, $val] = $value;
2758
-		$hidden[] = '<input name="'
2759
-			. entites_html($var)
2760
-			. '"'
2761
-			. (is_null($val)
2762
-				? ''
2763
-				: ' value="' . entites_html($val) . '"'
2764
-			)
2765
-			. ' type="hidden"' . "\n/>";
2766
-	}
2767
-
2768
-	return join('', $hidden);
2696
+    $action ??= '';
2697
+
2698
+    $contexte = [];
2699
+    include_spip('inc/urls');
2700
+    if (
2701
+        $p = urls_decoder_url($action, '')
2702
+        and reset($p)
2703
+    ) {
2704
+        $fond = array_shift($p);
2705
+        if ($fond != '404') {
2706
+            $contexte = array_shift($p);
2707
+            $contexte['page'] = $fond;
2708
+            $action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2709
+        }
2710
+    }
2711
+    // defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2712
+    if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
2713
+        unset($contexte['type']);
2714
+    }
2715
+    if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') or _DEFINIR_CONTEXTE_TYPE_PAGE) {
2716
+        unset($contexte['type-page']);
2717
+    }
2718
+
2719
+    // on va remplir un tableau de valeurs en prenant bien soin de ne pas
2720
+    // ecraser les elements de la forme mots[]=1&mots[]=2
2721
+    $values = [];
2722
+
2723
+    // d'abord avec celles de l'url
2724
+    if (false !== ($p = strpos($action, '?'))) {
2725
+        foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2726
+            $c = explode('=', $c, 2);
2727
+            $var = array_shift($c);
2728
+            $val = array_shift($c) ?? '';
2729
+            if ($var) {
2730
+                $val = rawurldecode($val);
2731
+                $var = rawurldecode($var); // decoder les [] eventuels
2732
+                if (preg_match(',\[\]$,S', $var)) {
2733
+                    $values[] = [$var, $val];
2734
+                } else {
2735
+                    if (!isset($values[$var])) {
2736
+                        $values[$var] = [$var, $val];
2737
+                    }
2738
+                }
2739
+            }
2740
+        }
2741
+    }
2742
+
2743
+    // ensuite avec celles du contexte, sans doublonner !
2744
+    foreach ($contexte as $var => $val) {
2745
+        if (preg_match(',\[\]$,S', $var)) {
2746
+            $values[] = [$var, $val];
2747
+        } else {
2748
+            if (!isset($values[$var])) {
2749
+                $values[$var] = [$var, $val];
2750
+            }
2751
+        }
2752
+    }
2753
+
2754
+    // puis on rassemble le tout
2755
+    $hidden = [];
2756
+    foreach ($values as $value) {
2757
+        [$var, $val] = $value;
2758
+        $hidden[] = '<input name="'
2759
+            . entites_html($var)
2760
+            . '"'
2761
+            . (is_null($val)
2762
+                ? ''
2763
+                : ' value="' . entites_html($val) . '"'
2764
+            )
2765
+            . ' type="hidden"' . "\n/>";
2766
+    }
2767
+
2768
+    return join('', $hidden);
2769 2769
 }
2770 2770
 
2771 2771
 
@@ -2787,7 +2787,7 @@  discard block
 block discarded – undo
2787 2787
  *    - la première valeur du tableau sinon.
2788 2788
  **/
2789 2789
 function filtre_reset($array) {
2790
-	return !is_array($array) ? null : reset($array);
2790
+    return !is_array($array) ? null : reset($array);
2791 2791
 }
2792 2792
 
2793 2793
 /**
@@ -2808,7 +2808,7 @@  discard block
 block discarded – undo
2808 2808
  *    - la dernière valeur du tableau sinon.
2809 2809
  **/
2810 2810
 function filtre_end($array) {
2811
-	return !is_array($array) ? null : end($array);
2811
+    return !is_array($array) ? null : end($array);
2812 2812
 }
2813 2813
 
2814 2814
 /**
@@ -2828,11 +2828,11 @@  discard block
 block discarded – undo
2828 2828
  *
2829 2829
  **/
2830 2830
 function filtre_push($array, $val) {
2831
-	if (!is_array($array) or !array_push($array, $val)) {
2832
-		return '';
2833
-	}
2831
+    if (!is_array($array) or !array_push($array, $val)) {
2832
+        return '';
2833
+    }
2834 2834
 
2835
-	return $array;
2835
+    return $array;
2836 2836
 }
2837 2837
 
2838 2838
 /**
@@ -2851,7 +2851,7 @@  discard block
 block discarded – undo
2851 2851
  *     - `true` si la valeur existe dans le tableau, `false` sinon.
2852 2852
  **/
2853 2853
 function filtre_find($array, $val) {
2854
-	return (is_array($array) and in_array($val, $array));
2854
+    return (is_array($array) and in_array($val, $array));
2855 2855
 }
2856 2856
 
2857 2857
 
@@ -2868,13 +2868,13 @@  discard block
 block discarded – undo
2868 2868
  *     Contenu avec urls en absolus
2869 2869
  **/
2870 2870
 function urls_absolues_css($contenu, $source) {
2871
-	$path = suivre_lien(url_absolue($source), './');
2871
+    $path = suivre_lien(url_absolue($source), './');
2872 2872
 
2873
-	return preg_replace_callback(
2874
-		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2875
-		fn($x) => "url('" . suivre_lien($path, $x[1]) . "')",
2876
-		$contenu
2877
-	);
2873
+    return preg_replace_callback(
2874
+        ",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2875
+        fn($x) => "url('" . suivre_lien($path, $x[1]) . "')",
2876
+        $contenu
2877
+    );
2878 2878
 }
2879 2879
 
2880 2880
 
@@ -2903,119 +2903,119 @@  discard block
 block discarded – undo
2903 2903
  *     Chemin du fichier CSS inversé
2904 2904
  **/
2905 2905
 function direction_css($css, $voulue = '') {
2906
-	if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) {
2907
-		return $css;
2908
-	}
2909
-	include_spip('inc/lang');
2910
-	// si on a precise le sens voulu en argument, le prendre en compte
2911
-	if ($voulue = strtolower($voulue)) {
2912
-		if ($voulue != 'rtl' and $voulue != 'ltr') {
2913
-			$voulue = lang_dir($voulue);
2914
-		}
2915
-	} else {
2916
-		$voulue = lang_dir();
2917
-	}
2918
-
2919
-	$r = count($r) > 1;
2920
-	$right = $r ? 'left' : 'right'; // 'right' de la css lue en entree
2921
-	$dir = $r ? 'rtl' : 'ltr';
2922
-	$ndir = $r ? 'ltr' : 'rtl';
2923
-
2924
-	if ($voulue == $dir) {
2925
-		return $css;
2926
-	}
2927
-
2928
-	if (
2929
-		// url absolue
2930
-		preg_match(',^https?:,i', $css)
2931
-		// ou qui contient un ?
2932
-		or (($p = strpos($css, '?')) !== false)
2933
-	) {
2934
-		$distant = true;
2935
-		$cssf = parse_url($css);
2936
-		$cssf = $cssf['path'] . ($cssf['query'] ? '?' . $cssf['query'] : '');
2937
-		$cssf = preg_replace(',[?:&=],', '_', $cssf);
2938
-	} else {
2939
-		$distant = false;
2940
-		$cssf = $css;
2941
-		// 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2942
-		//propose (rien a faire dans ce cas)
2943
-		$f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2944
-		if (@file_exists($f)) {
2945
-			return $f;
2946
-		}
2947
-	}
2948
-
2949
-	// 2.
2950
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2951
-	$f = $dir_var
2952
-		. preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2953
-		. '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2954
-
2955
-	// la css peut etre distante (url absolue !)
2956
-	if ($distant) {
2957
-		include_spip('inc/distant');
2958
-		$res = recuperer_url($css);
2959
-		if (!$res or !$contenu = $res['page']) {
2960
-			return $css;
2961
-		}
2962
-	} else {
2963
-		if (
2964
-			(@filemtime($f) > @filemtime($css))
2965
-			and (_VAR_MODE != 'recalcul')
2966
-		) {
2967
-			return $f;
2968
-		}
2969
-		if (!lire_fichier($css, $contenu)) {
2970
-			return $css;
2971
-		}
2972
-	}
2973
-
2974
-
2975
-	// Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands
2976
-	include_spip('lib/csstidy/class.csstidy');
2977
-	$parser = new csstidy();
2978
-	$parser->set_cfg('optimise_shorthands', 0);
2979
-	$parser->set_cfg('reverse_left_and_right', true);
2980
-	$parser->parse($contenu);
2981
-
2982
-	$contenu = $parser->print->plain();
2983
-
2984
-
2985
-	// reperer les @import auxquels il faut propager le direction_css
2986
-	preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs);
2987
-	$src = [];
2988
-	$src_direction_css = [];
2989
-	$src_faux_abs = [];
2990
-	$d = dirname($css);
2991
-	foreach ($regs[1] as $k => $import_css) {
2992
-		$css_direction = direction_css("$d/$import_css", $voulue);
2993
-		// si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue
2994
-		if (substr($css_direction, 0, strlen($d) + 1) == "$d/") {
2995
-			$css_direction = substr($css_direction, strlen($d) + 1);
2996
-		} // si la css_direction commence par $dir_var on la fait passer pour une absolue
2997
-		elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
2998
-			$css_direction = substr($css_direction, strlen($dir_var));
2999
-			$src_faux_abs['/@@@@@@/' . $css_direction] = $css_direction;
3000
-			$css_direction = '/@@@@@@/' . $css_direction;
3001
-		}
3002
-		$src[] = $regs[0][$k];
3003
-		$src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
3004
-	}
3005
-	$contenu = str_replace($src, $src_direction_css, $contenu);
3006
-
3007
-	$contenu = urls_absolues_css($contenu, $css);
3008
-
3009
-	// virer les fausses url absolues que l'on a mis dans les import
3010
-	if (count($src_faux_abs)) {
3011
-		$contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu);
3012
-	}
3013
-
3014
-	if (!ecrire_fichier($f, $contenu)) {
3015
-		return $css;
3016
-	}
3017
-
3018
-	return $f;
2906
+    if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) {
2907
+        return $css;
2908
+    }
2909
+    include_spip('inc/lang');
2910
+    // si on a precise le sens voulu en argument, le prendre en compte
2911
+    if ($voulue = strtolower($voulue)) {
2912
+        if ($voulue != 'rtl' and $voulue != 'ltr') {
2913
+            $voulue = lang_dir($voulue);
2914
+        }
2915
+    } else {
2916
+        $voulue = lang_dir();
2917
+    }
2918
+
2919
+    $r = count($r) > 1;
2920
+    $right = $r ? 'left' : 'right'; // 'right' de la css lue en entree
2921
+    $dir = $r ? 'rtl' : 'ltr';
2922
+    $ndir = $r ? 'ltr' : 'rtl';
2923
+
2924
+    if ($voulue == $dir) {
2925
+        return $css;
2926
+    }
2927
+
2928
+    if (
2929
+        // url absolue
2930
+        preg_match(',^https?:,i', $css)
2931
+        // ou qui contient un ?
2932
+        or (($p = strpos($css, '?')) !== false)
2933
+    ) {
2934
+        $distant = true;
2935
+        $cssf = parse_url($css);
2936
+        $cssf = $cssf['path'] . ($cssf['query'] ? '?' . $cssf['query'] : '');
2937
+        $cssf = preg_replace(',[?:&=],', '_', $cssf);
2938
+    } else {
2939
+        $distant = false;
2940
+        $cssf = $css;
2941
+        // 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2942
+        //propose (rien a faire dans ce cas)
2943
+        $f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2944
+        if (@file_exists($f)) {
2945
+            return $f;
2946
+        }
2947
+    }
2948
+
2949
+    // 2.
2950
+    $dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2951
+    $f = $dir_var
2952
+        . preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2953
+        . '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2954
+
2955
+    // la css peut etre distante (url absolue !)
2956
+    if ($distant) {
2957
+        include_spip('inc/distant');
2958
+        $res = recuperer_url($css);
2959
+        if (!$res or !$contenu = $res['page']) {
2960
+            return $css;
2961
+        }
2962
+    } else {
2963
+        if (
2964
+            (@filemtime($f) > @filemtime($css))
2965
+            and (_VAR_MODE != 'recalcul')
2966
+        ) {
2967
+            return $f;
2968
+        }
2969
+        if (!lire_fichier($css, $contenu)) {
2970
+            return $css;
2971
+        }
2972
+    }
2973
+
2974
+
2975
+    // Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands
2976
+    include_spip('lib/csstidy/class.csstidy');
2977
+    $parser = new csstidy();
2978
+    $parser->set_cfg('optimise_shorthands', 0);
2979
+    $parser->set_cfg('reverse_left_and_right', true);
2980
+    $parser->parse($contenu);
2981
+
2982
+    $contenu = $parser->print->plain();
2983
+
2984
+
2985
+    // reperer les @import auxquels il faut propager le direction_css
2986
+    preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs);
2987
+    $src = [];
2988
+    $src_direction_css = [];
2989
+    $src_faux_abs = [];
2990
+    $d = dirname($css);
2991
+    foreach ($regs[1] as $k => $import_css) {
2992
+        $css_direction = direction_css("$d/$import_css", $voulue);
2993
+        // si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue
2994
+        if (substr($css_direction, 0, strlen($d) + 1) == "$d/") {
2995
+            $css_direction = substr($css_direction, strlen($d) + 1);
2996
+        } // si la css_direction commence par $dir_var on la fait passer pour une absolue
2997
+        elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
2998
+            $css_direction = substr($css_direction, strlen($dir_var));
2999
+            $src_faux_abs['/@@@@@@/' . $css_direction] = $css_direction;
3000
+            $css_direction = '/@@@@@@/' . $css_direction;
3001
+        }
3002
+        $src[] = $regs[0][$k];
3003
+        $src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
3004
+    }
3005
+    $contenu = str_replace($src, $src_direction_css, $contenu);
3006
+
3007
+    $contenu = urls_absolues_css($contenu, $css);
3008
+
3009
+    // virer les fausses url absolues que l'on a mis dans les import
3010
+    if (count($src_faux_abs)) {
3011
+        $contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu);
3012
+    }
3013
+
3014
+    if (!ecrire_fichier($f, $contenu)) {
3015
+        return $css;
3016
+    }
3017
+
3018
+    return $f;
3019 3019
 }
3020 3020
 
3021 3021
 
@@ -3038,46 +3038,46 @@  discard block
 block discarded – undo
3038 3038
  *     - Chemin ou URL du fichier CSS source sinon.
3039 3039
  **/
3040 3040
 function url_absolue_css($css) {
3041
-	if (!preg_match(',\.css$,i', $css, $r)) {
3042
-		return $css;
3043
-	}
3041
+    if (!preg_match(',\.css$,i', $css, $r)) {
3042
+        return $css;
3043
+    }
3044 3044
 
3045
-	$url_absolue_css = url_absolue($css);
3045
+    $url_absolue_css = url_absolue($css);
3046 3046
 
3047
-	$f = basename($css, '.css');
3048
-	$f = sous_repertoire(_DIR_VAR, 'cache-css')
3049
-		. preg_replace(',(.*?)(_rtl|_ltr)?$,', "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
3050
-		. '.css';
3047
+    $f = basename($css, '.css');
3048
+    $f = sous_repertoire(_DIR_VAR, 'cache-css')
3049
+        . preg_replace(',(.*?)(_rtl|_ltr)?$,', "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
3050
+        . '.css';
3051 3051
 
3052
-	if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
3053
-		return $f;
3054
-	}
3052
+    if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
3053
+        return $f;
3054
+    }
3055 3055
 
3056
-	if ($url_absolue_css == $css) {
3057
-		if (
3058
-			strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
3059
-			or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
3060
-		) {
3061
-			include_spip('inc/distant');
3062
-			$contenu = recuperer_url($css);
3063
-			$contenu = $contenu['page'] ?? '';
3064
-			if (!$contenu) {
3065
-				return $css;
3066
-			}
3067
-		}
3068
-	} elseif (!lire_fichier($css, $contenu)) {
3069
-		return $css;
3070
-	}
3056
+    if ($url_absolue_css == $css) {
3057
+        if (
3058
+            strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
3059
+            or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
3060
+        ) {
3061
+            include_spip('inc/distant');
3062
+            $contenu = recuperer_url($css);
3063
+            $contenu = $contenu['page'] ?? '';
3064
+            if (!$contenu) {
3065
+                return $css;
3066
+            }
3067
+        }
3068
+    } elseif (!lire_fichier($css, $contenu)) {
3069
+        return $css;
3070
+    }
3071 3071
 
3072
-	// passer les url relatives a la css d'origine en url absolues
3073
-	$contenu = urls_absolues_css($contenu, $css);
3072
+    // passer les url relatives a la css d'origine en url absolues
3073
+    $contenu = urls_absolues_css($contenu, $css);
3074 3074
 
3075
-	// ecrire la css
3076
-	if (!ecrire_fichier($f, $contenu)) {
3077
-		return $css;
3078
-	}
3075
+    // ecrire la css
3076
+    if (!ecrire_fichier($f, $contenu)) {
3077
+        return $css;
3078
+    }
3079 3079
 
3080
-	return $f;
3080
+    return $f;
3081 3081
 }
3082 3082
 
3083 3083
 
@@ -3111,24 +3111,24 @@  discard block
 block discarded – undo
3111 3111
  *     Valeur trouvée ou valeur par défaut.
3112 3112
  **/
3113 3113
 function table_valeur($table, $cle, $defaut = '', $conserver_null = false) {
3114
-	foreach (explode('/', $cle) as $k) {
3115
-		$table = (is_string($table) ? @unserialize($table) : $table);
3114
+    foreach (explode('/', $cle) as $k) {
3115
+        $table = (is_string($table) ? @unserialize($table) : $table);
3116 3116
 
3117
-		if (is_object($table)) {
3118
-			$table = (($k !== '') and isset($table->$k)) ? $table->$k : $defaut;
3119
-		} elseif (is_array($table)) {
3120
-			if ($conserver_null) {
3121
-				$table = array_key_exists($k, $table) ? $table[$k] : $defaut;
3122
-			} else {
3123
-				$table = ($table[$k] ?? $defaut);
3124
-			}
3125
-		} else {
3126
-			$table = $defaut;
3127
-			break;
3128
-		}
3129
-	}
3117
+        if (is_object($table)) {
3118
+            $table = (($k !== '') and isset($table->$k)) ? $table->$k : $defaut;
3119
+        } elseif (is_array($table)) {
3120
+            if ($conserver_null) {
3121
+                $table = array_key_exists($k, $table) ? $table[$k] : $defaut;
3122
+            } else {
3123
+                $table = ($table[$k] ?? $defaut);
3124
+            }
3125
+        } else {
3126
+            $table = $defaut;
3127
+            break;
3128
+        }
3129
+    }
3130 3130
 
3131
-	return $table;
3131
+    return $table;
3132 3132
 }
3133 3133
 
3134 3134
 /**
@@ -3161,22 +3161,22 @@  discard block
 block discarded – undo
3161 3161
  *     - string : expression trouvée.
3162 3162
  **/
3163 3163
 function filtre_match_dist(?string $texte, $expression, $modif = 'UuimsS', $capte = 0) {
3164
-	if (intval($modif) and $capte == 0) {
3165
-		$capte = $modif;
3166
-		$modif = 'UuimsS';
3167
-	}
3168
-	$expression = str_replace('\/', '/', $expression);
3169
-	$expression = str_replace('/', '\/', $expression);
3164
+    if (intval($modif) and $capte == 0) {
3165
+        $capte = $modif;
3166
+        $modif = 'UuimsS';
3167
+    }
3168
+    $expression = str_replace('\/', '/', $expression);
3169
+    $expression = str_replace('/', '\/', $expression);
3170 3170
 
3171
-	if (preg_match('/' . $expression . '/' . $modif, $texte ?? '', $r)) {
3172
-		if (isset($r[$capte])) {
3173
-			return $r[$capte];
3174
-		} else {
3175
-			return true;
3176
-		}
3177
-	}
3171
+    if (preg_match('/' . $expression . '/' . $modif, $texte ?? '', $r)) {
3172
+        if (isset($r[$capte])) {
3173
+            return $r[$capte];
3174
+        } else {
3175
+            return true;
3176
+        }
3177
+    }
3178 3178
 
3179
-	return false;
3179
+    return false;
3180 3180
 }
3181 3181
 
3182 3182
 
@@ -3203,10 +3203,10 @@  discard block
 block discarded – undo
3203 3203
  *     Texte
3204 3204
  **/
3205 3205
 function replace($texte, $expression, $replace = '', $modif = 'UimsS') {
3206
-	$expression = str_replace('\/', '/', $expression);
3207
-	$expression = str_replace('/', '\/', $expression);
3206
+    $expression = str_replace('\/', '/', $expression);
3207
+    $expression = str_replace('/', '\/', $expression);
3208 3208
 
3209
-	return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3209
+    return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3210 3210
 }
3211 3211
 
3212 3212
 
@@ -3224,25 +3224,25 @@  discard block
 block discarded – undo
3224 3224
  **/
3225 3225
 function traiter_doublons_documents(&$doublons, $letexte) {
3226 3226
 
3227
-	// Verifier dans le texte & les notes (pas beau, helas)
3228
-	$t = $letexte . $GLOBALS['les_notes'];
3227
+    // Verifier dans le texte & les notes (pas beau, helas)
3228
+    $t = $letexte . $GLOBALS['les_notes'];
3229 3229
 
3230
-	if (
3231
-		strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3232
-		and preg_match_all(
3233
-			',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS',
3234
-			$t,
3235
-			$matches,
3236
-			PREG_PATTERN_ORDER
3237
-		)
3238
-	) {
3239
-		if (!isset($doublons['documents'])) {
3240
-			$doublons['documents'] = '';
3241
-		}
3242
-		$doublons['documents'] .= ',' . join(',', $matches[1]);
3243
-	}
3230
+    if (
3231
+        strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3232
+        and preg_match_all(
3233
+            ',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS',
3234
+            $t,
3235
+            $matches,
3236
+            PREG_PATTERN_ORDER
3237
+        )
3238
+    ) {
3239
+        if (!isset($doublons['documents'])) {
3240
+            $doublons['documents'] = '';
3241
+        }
3242
+        $doublons['documents'] .= ',' . join(',', $matches[1]);
3243
+    }
3244 3244
 
3245
-	return $letexte;
3245
+    return $letexte;
3246 3246
 }
3247 3247
 
3248 3248
 /**
@@ -3256,7 +3256,7 @@  discard block
 block discarded – undo
3256 3256
  * @return string Chaîne vide
3257 3257
  **/
3258 3258
 function vide($texte) {
3259
-	return '';
3259
+    return '';
3260 3260
 }
3261 3261
 
3262 3262
 //
@@ -3285,23 +3285,23 @@  discard block
 block discarded – undo
3285 3285
  *      Code HTML résultant
3286 3286
  **/
3287 3287
 function env_to_params($env, $ignore_params = []) {
3288
-	$ignore_params = array_merge(
3289
-		['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'],
3290
-		$ignore_params
3291
-	);
3292
-	if (!is_array($env)) {
3293
-		$env = unserialize($env);
3294
-	}
3295
-	$texte = '';
3296
-	if ($env) {
3297
-		foreach ($env as $i => $j) {
3298
-			if (is_string($j) and !in_array($i, $ignore_params)) {
3299
-				$texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3300
-			}
3301
-		}
3302
-	}
3303
-
3304
-	return $texte;
3288
+    $ignore_params = array_merge(
3289
+        ['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'],
3290
+        $ignore_params
3291
+    );
3292
+    if (!is_array($env)) {
3293
+        $env = unserialize($env);
3294
+    }
3295
+    $texte = '';
3296
+    if ($env) {
3297
+        foreach ($env as $i => $j) {
3298
+            if (is_string($j) and !in_array($i, $ignore_params)) {
3299
+                $texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3300
+            }
3301
+        }
3302
+    }
3303
+
3304
+    return $texte;
3305 3305
 }
3306 3306
 
3307 3307
 /**
@@ -3324,23 +3324,23 @@  discard block
 block discarded – undo
3324 3324
  *      Code HTML résultant
3325 3325
  **/
3326 3326
 function env_to_attributs($env, $ignore_params = []) {
3327
-	$ignore_params = array_merge(
3328
-		['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'],
3329
-		$ignore_params
3330
-	);
3331
-	if (!is_array($env)) {
3332
-		$env = unserialize($env);
3333
-	}
3334
-	$texte = '';
3335
-	if ($env) {
3336
-		foreach ($env as $i => $j) {
3337
-			if (is_string($j) and !in_array($i, $ignore_params)) {
3338
-				$texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3339
-			}
3340
-		}
3341
-	}
3327
+    $ignore_params = array_merge(
3328
+        ['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'],
3329
+        $ignore_params
3330
+    );
3331
+    if (!is_array($env)) {
3332
+        $env = unserialize($env);
3333
+    }
3334
+    $texte = '';
3335
+    if ($env) {
3336
+        foreach ($env as $i => $j) {
3337
+            if (is_string($j) and !in_array($i, $ignore_params)) {
3338
+                $texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3339
+            }
3340
+        }
3341
+    }
3342 3342
 
3343
-	return $texte;
3343
+    return $texte;
3344 3344
 }
3345 3345
 
3346 3346
 
@@ -3358,7 +3358,7 @@  discard block
 block discarded – undo
3358 3358
  * @return string Chaînes concaténés
3359 3359
  **/
3360 3360
 function concat(...$args): string {
3361
-	return join('', $args);
3361
+    return join('', $args);
3362 3362
 }
3363 3363
 
3364 3364
 
@@ -3378,23 +3378,23 @@  discard block
 block discarded – undo
3378 3378
  *     Contenu du ou des fichiers, concaténé
3379 3379
  **/
3380 3380
 function charge_scripts($files, $script = true) {
3381
-	$flux = '';
3382
-	foreach (is_array($files) ? $files : explode('|', $files) as $file) {
3383
-		if (!is_string($file)) {
3384
-			continue;
3385
-		}
3386
-		if ($script) {
3387
-			$file = preg_match(',^\w+$,', $file) ? "javascript/$file.js" : '';
3388
-		}
3389
-		if ($file) {
3390
-			$path = find_in_path($file);
3391
-			if ($path) {
3392
-				$flux .= spip_file_get_contents($path);
3393
-			}
3394
-		}
3395
-	}
3396
-
3397
-	return $flux;
3381
+    $flux = '';
3382
+    foreach (is_array($files) ? $files : explode('|', $files) as $file) {
3383
+        if (!is_string($file)) {
3384
+            continue;
3385
+        }
3386
+        if ($script) {
3387
+            $file = preg_match(',^\w+$,', $file) ? "javascript/$file.js" : '';
3388
+        }
3389
+        if ($file) {
3390
+            $path = find_in_path($file);
3391
+            if ($path) {
3392
+                $flux .= spip_file_get_contents($path);
3393
+            }
3394
+        }
3395
+    }
3396
+
3397
+    return $flux;
3398 3398
 }
3399 3399
 
3400 3400
 /**
@@ -3405,22 +3405,22 @@  discard block
 block discarded – undo
3405 3405
  * @return string
3406 3406
  */
3407 3407
 function http_img_variante_svg_si_possible($img_file) {
3408
-	// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3409
-	// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3410
-	if (
3411
-		preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3412
-		and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . '-xx.svg'
3413
-		and file_exists($variante_svg_generique)
3414
-	) {
3415
-		if ($variante_svg_size = substr($variante_svg_generique, 0, -6) . $m[1] . '.svg' and file_exists($variante_svg_size)) {
3416
-			$img_file = $variante_svg_size;
3417
-		}
3418
-		else {
3419
-			$img_file = $variante_svg_generique;
3420
-		}
3421
-	}
3408
+    // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3409
+    // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3410
+    if (
3411
+        preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3412
+        and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . '-xx.svg'
3413
+        and file_exists($variante_svg_generique)
3414
+    ) {
3415
+        if ($variante_svg_size = substr($variante_svg_generique, 0, -6) . $m[1] . '.svg' and file_exists($variante_svg_size)) {
3416
+            $img_file = $variante_svg_size;
3417
+        }
3418
+        else {
3419
+            $img_file = $variante_svg_generique;
3420
+        }
3421
+    }
3422 3422
 
3423
-	return $img_file;
3423
+    return $img_file;
3424 3424
 }
3425 3425
 
3426 3426
 /**
@@ -3441,54 +3441,54 @@  discard block
 block discarded – undo
3441 3441
  */
3442 3442
 function http_img_pack($img, $alt, $atts = '', $title = '', $options = []) {
3443 3443
 
3444
-	$img_file = $img;
3445
-	if ($p = strpos($img_file, '?')) {
3446
-		$img_file = substr($img_file, 0, $p);
3447
-	}
3448
-	if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3449
-		$img_file = chemin_image($img);
3450
-	}
3451
-	else {
3452
-		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true) {
3453
-			$img_file = http_img_variante_svg_si_possible($img_file);
3454
-		}
3455
-	}
3456
-	if (stripos($atts, 'width') === false) {
3457
-		// utiliser directement l'info de taille presente dans le nom
3458
-		if (
3459
-			(!isset($options['utiliser_suffixe_size'])
3460
-				or $options['utiliser_suffixe_size'] == true
3461
-			  or strpos($img_file, '-xx.svg') !== false)
3462
-			and (preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs)
3463
-					 or preg_match(',\?([0-9]+)px$,', $img, $regs))
3464
-		) {
3465
-			$largeur = $hauteur = intval($regs[1]);
3466
-		} else {
3467
-			$taille = taille_image($img_file);
3468
-			[$hauteur, $largeur] = $taille;
3469
-			if (!$hauteur or !$largeur) {
3470
-				return '';
3471
-			}
3472
-		}
3473
-		$atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3474
-	}
3475
-
3476
-	if (file_exists($img_file)) {
3477
-		$img_file = timestamp($img_file);
3478
-	}
3479
-	if ($alt === false) {
3480
-		$alt = '';
3481
-	}
3482
-	elseif ($alt or $alt === '') {
3483
-		$alt = " alt='" . attribut_html($alt) . "'";
3484
-	}
3485
-	else {
3486
-		$alt = " alt='" . attribut_html($title) . "'";
3487
-	}
3488
-	return "<img src='" . attribut_html($img_file) . "'$alt"
3489
-	. ($title ? ' title="' . attribut_html($title) . '"' : '')
3490
-	. ' ' . ltrim($atts)
3491
-	. ' />';
3444
+    $img_file = $img;
3445
+    if ($p = strpos($img_file, '?')) {
3446
+        $img_file = substr($img_file, 0, $p);
3447
+    }
3448
+    if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3449
+        $img_file = chemin_image($img);
3450
+    }
3451
+    else {
3452
+        if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true) {
3453
+            $img_file = http_img_variante_svg_si_possible($img_file);
3454
+        }
3455
+    }
3456
+    if (stripos($atts, 'width') === false) {
3457
+        // utiliser directement l'info de taille presente dans le nom
3458
+        if (
3459
+            (!isset($options['utiliser_suffixe_size'])
3460
+                or $options['utiliser_suffixe_size'] == true
3461
+              or strpos($img_file, '-xx.svg') !== false)
3462
+            and (preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs)
3463
+                     or preg_match(',\?([0-9]+)px$,', $img, $regs))
3464
+        ) {
3465
+            $largeur = $hauteur = intval($regs[1]);
3466
+        } else {
3467
+            $taille = taille_image($img_file);
3468
+            [$hauteur, $largeur] = $taille;
3469
+            if (!$hauteur or !$largeur) {
3470
+                return '';
3471
+            }
3472
+        }
3473
+        $atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3474
+    }
3475
+
3476
+    if (file_exists($img_file)) {
3477
+        $img_file = timestamp($img_file);
3478
+    }
3479
+    if ($alt === false) {
3480
+        $alt = '';
3481
+    }
3482
+    elseif ($alt or $alt === '') {
3483
+        $alt = " alt='" . attribut_html($alt) . "'";
3484
+    }
3485
+    else {
3486
+        $alt = " alt='" . attribut_html($title) . "'";
3487
+    }
3488
+    return "<img src='" . attribut_html($img_file) . "'$alt"
3489
+    . ($title ? ' title="' . attribut_html($title) . '"' : '')
3490
+    . ' ' . ltrim($atts)
3491
+    . ' />';
3492 3492
 }
3493 3493
 
3494 3494
 /**
@@ -3500,70 +3500,70 @@  discard block
 block discarded – undo
3500 3500
  * @return string
3501 3501
  */
3502 3502
 function http_style_background($img, $att = '', $size = null) {
3503
-	if ($size and is_numeric($size)) {
3504
-		$size = trim($size) . 'px';
3505
-	}
3506
-	return " style='background" .
3507
-		($att ? '' : '-image') . ': url("' . chemin_image($img) . '")' . ($att ? (' ' . $att) : '') . ';'
3508
-		. ($size ? "background-size:{$size};" : '')
3509
-		. "'";
3503
+    if ($size and is_numeric($size)) {
3504
+        $size = trim($size) . 'px';
3505
+    }
3506
+    return " style='background" .
3507
+        ($att ? '' : '-image') . ': url("' . chemin_image($img) . '")' . ($att ? (' ' . $att) : '') . ';'
3508
+        . ($size ? "background-size:{$size};" : '')
3509
+        . "'";
3510 3510
 }
3511 3511
 
3512 3512
 
3513 3513
 function helper_filtre_balise_img_svg_arguments($alt_or_size, $class_or_size, $size) {
3514
-	$args = [$alt_or_size, $class_or_size, $size];
3515
-	while (is_null(end($args)) and count($args)) {
3516
-		array_pop($args);
3517
-	}
3518
-	if (!count($args)) {
3519
-		return [null, null, null];
3520
-	}
3521
-	if (count($args) < 3) {
3522
-		$maybe_size = array_pop($args);
3523
-		// @2x
3524
-		// @1.5x
3525
-		// 512
3526
-		// 512x*
3527
-		// 512x300
3528
-		if (
3529
-			!strlen($maybe_size)
3530
-			or !preg_match(',^(@\d+(\.\d+)?x|\d+(x\*)?|\d+x\d+)$,', trim($maybe_size))
3531
-		) {
3532
-			$args[] = $maybe_size;
3533
-			$maybe_size = null;
3534
-		}
3535
-		while (count($args) < 2) {
3536
-			$args[] = null; // default alt or class
3537
-		}
3538
-		$args[] = $maybe_size;
3539
-	}
3540
-	return $args;
3514
+    $args = [$alt_or_size, $class_or_size, $size];
3515
+    while (is_null(end($args)) and count($args)) {
3516
+        array_pop($args);
3517
+    }
3518
+    if (!count($args)) {
3519
+        return [null, null, null];
3520
+    }
3521
+    if (count($args) < 3) {
3522
+        $maybe_size = array_pop($args);
3523
+        // @2x
3524
+        // @1.5x
3525
+        // 512
3526
+        // 512x*
3527
+        // 512x300
3528
+        if (
3529
+            !strlen($maybe_size)
3530
+            or !preg_match(',^(@\d+(\.\d+)?x|\d+(x\*)?|\d+x\d+)$,', trim($maybe_size))
3531
+        ) {
3532
+            $args[] = $maybe_size;
3533
+            $maybe_size = null;
3534
+        }
3535
+        while (count($args) < 2) {
3536
+            $args[] = null; // default alt or class
3537
+        }
3538
+        $args[] = $maybe_size;
3539
+    }
3540
+    return $args;
3541 3541
 }
3542 3542
 
3543 3543
 function helper_filtre_balise_img_svg_size($img, $size) {
3544
-	// si size est de la forme '@2x' c'est un coeff multiplicateur sur la densite
3545
-	if (strpos($size, '@') === 0 and substr($size, -1) === 'x') {
3546
-		$coef = floatval(substr($size, 1, -1));
3547
-		[$h, $w] = taille_image($img);
3548
-		$height = intval(round($h / $coef));
3549
-		$width = intval(round($w / $coef));
3550
-	}
3551
-	// sinon c'est une valeur seule si image caree ou largeurxhauteur
3552
-	else {
3553
-		$size = explode('x', $size, 2);
3554
-		$size = array_map('trim', $size);
3555
-		$height = $width = intval(array_shift($size));
3556
-
3557
-		if (count($size) and reset($size)) {
3558
-			$height = array_shift($size);
3559
-			if ($height === '*') {
3560
-				[$h, $w] = taille_image($img);
3561
-				$height = intval(round($h * $width / $w));
3562
-			}
3563
-		}
3564
-	}
3565
-
3566
-	return [$width, $height];
3544
+    // si size est de la forme '@2x' c'est un coeff multiplicateur sur la densite
3545
+    if (strpos($size, '@') === 0 and substr($size, -1) === 'x') {
3546
+        $coef = floatval(substr($size, 1, -1));
3547
+        [$h, $w] = taille_image($img);
3548
+        $height = intval(round($h / $coef));
3549
+        $width = intval(round($w / $coef));
3550
+    }
3551
+    // sinon c'est une valeur seule si image caree ou largeurxhauteur
3552
+    else {
3553
+        $size = explode('x', $size, 2);
3554
+        $size = array_map('trim', $size);
3555
+        $height = $width = intval(array_shift($size));
3556
+
3557
+        if (count($size) and reset($size)) {
3558
+            $height = array_shift($size);
3559
+            if ($height === '*') {
3560
+                [$h, $w] = taille_image($img);
3561
+                $height = intval(round($h * $width / $w));
3562
+            }
3563
+        }
3564
+    }
3565
+
3566
+    return [$width, $height];
3567 3567
 }
3568 3568
 
3569 3569
 /**
@@ -3599,43 +3599,43 @@  discard block
 block discarded – undo
3599 3599
  */
3600 3600
 function filtre_balise_img_dist($img, $alt = '', $class = null, $size = null) {
3601 3601
 
3602
-	[$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3603
-
3604
-	$img = trim((string) $img);
3605
-	if (strpos($img, '<img') === 0) {
3606
-		if (!is_null($alt)) {
3607
-			$img = inserer_attribut($img, 'alt', $alt);
3608
-		}
3609
-		if (!is_null($class)) {
3610
-			if (strlen($class)) {
3611
-				$img = inserer_attribut($img, 'class', $class);
3612
-			}
3613
-			else {
3614
-				$img = vider_attribut($img, 'class');
3615
-			}
3616
-		}
3617
-	}
3618
-	else {
3619
-		$img = http_img_pack(
3620
-			$img,
3621
-			$alt,
3622
-			$class ? " class='" . attribut_html($class) . "'" : '',
3623
-			'',
3624
-			['chemin_image' => false, 'utiliser_suffixe_size' => false]
3625
-		);
3626
-		if (is_null($alt)) {
3627
-			$img = vider_attribut($img, 'alt');
3628
-		}
3629
-	}
3630
-
3631
-	if ($img and !is_null($size) and strlen($size = trim($size))) {
3632
-		[$width, $height] = helper_filtre_balise_img_svg_size($img, $size);
3633
-
3634
-		$img = inserer_attribut($img, 'width', $width);
3635
-		$img = inserer_attribut($img, 'height', $height);
3636
-	}
3637
-
3638
-	return $img;
3602
+    [$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3603
+
3604
+    $img = trim((string) $img);
3605
+    if (strpos($img, '<img') === 0) {
3606
+        if (!is_null($alt)) {
3607
+            $img = inserer_attribut($img, 'alt', $alt);
3608
+        }
3609
+        if (!is_null($class)) {
3610
+            if (strlen($class)) {
3611
+                $img = inserer_attribut($img, 'class', $class);
3612
+            }
3613
+            else {
3614
+                $img = vider_attribut($img, 'class');
3615
+            }
3616
+        }
3617
+    }
3618
+    else {
3619
+        $img = http_img_pack(
3620
+            $img,
3621
+            $alt,
3622
+            $class ? " class='" . attribut_html($class) . "'" : '',
3623
+            '',
3624
+            ['chemin_image' => false, 'utiliser_suffixe_size' => false]
3625
+        );
3626
+        if (is_null($alt)) {
3627
+            $img = vider_attribut($img, 'alt');
3628
+        }
3629
+    }
3630
+
3631
+    if ($img and !is_null($size) and strlen($size = trim($size))) {
3632
+        [$width, $height] = helper_filtre_balise_img_svg_size($img, $size);
3633
+
3634
+        $img = inserer_attribut($img, 'width', $width);
3635
+        $img = inserer_attribut($img, 'height', $height);
3636
+    }
3637
+
3638
+    return $img;
3639 3639
 }
3640 3640
 
3641 3641
 
@@ -3669,80 +3669,80 @@  discard block
 block discarded – undo
3669 3669
  */
3670 3670
 function filtre_balise_svg_dist($img, $alt = '', $class = null, $size = null) {
3671 3671
 
3672
-	$svg = null;
3673
-	$img = trim($img);
3674
-	$img_file = $img;
3675
-	if (strpos($img, '<svg') === false) {
3676
-		if ($p = strpos($img_file, '?')) {
3677
-			$img_file = substr($img_file, 0, $p);
3678
-		}
3679
-
3680
-		// ne jamais operer directement sur une image distante pour des raisons de perfo
3681
-		// la copie locale a toutes les chances d'etre la ou de resservir
3682
-		if (tester_url_absolue($img_file)) {
3683
-			include_spip('inc/distant');
3684
-			$fichier = copie_locale($img_file);
3685
-			$img_file = ($fichier ? _DIR_RACINE . $fichier : $img_file);
3686
-		}
3687
-
3688
-		if (
3689
-			!$img_file
3690
-			or !file_exists($img_file)
3691
-			or !$svg = file_get_contents($img_file)
3692
-		) {
3693
-			return '';
3694
-		}
3695
-	}
3696
-
3697
-	if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) {
3698
-		return '';
3699
-	}
3700
-
3701
-	[$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3702
-
3703
-	$balise_svg = $match[0];
3704
-	$balise_svg_source = $balise_svg;
3705
-
3706
-	// entete XML à supprimer
3707
-	$svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3708
-
3709
-	// IE est toujours mon ami
3710
-	$balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3711
-
3712
-	// regler la classe
3713
-	if (!is_null($class)) {
3714
-		if (strlen($class)) {
3715
-			$balise_svg = inserer_attribut($balise_svg, 'class', $class);
3716
-		}
3717
-		else {
3718
-			$balise_svg = vider_attribut($balise_svg, 'class');
3719
-		}
3720
-	}
3721
-
3722
-	// regler le alt
3723
-	if ($alt) {
3724
-		$balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3725
-		$id = 'img-svg-title-' . substr(md5("$img_file:$svg:$alt"), 0, 4);
3726
-		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3727
-		$title = "<title id=\"$id\">" . entites_html($alt) . "</title>\n";
3728
-		$balise_svg .= $title;
3729
-	}
3730
-	else {
3731
-		$balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3732
-	}
3733
-
3734
-	$svg = str_replace($balise_svg_source, $balise_svg, $svg);
3735
-
3736
-	if (!is_null($size) and strlen($size = trim($size))) {
3737
-		[$width, $height] = helper_filtre_balise_img_svg_size($svg, $size);
3738
-
3739
-		if (!function_exists('svg_redimensionner')) {
3740
-			include_spip('inc/svg');
3741
-		}
3742
-		$svg = svg_redimensionner($svg, $width, $height);
3743
-	}
3744
-
3745
-	return $svg;
3672
+    $svg = null;
3673
+    $img = trim($img);
3674
+    $img_file = $img;
3675
+    if (strpos($img, '<svg') === false) {
3676
+        if ($p = strpos($img_file, '?')) {
3677
+            $img_file = substr($img_file, 0, $p);
3678
+        }
3679
+
3680
+        // ne jamais operer directement sur une image distante pour des raisons de perfo
3681
+        // la copie locale a toutes les chances d'etre la ou de resservir
3682
+        if (tester_url_absolue($img_file)) {
3683
+            include_spip('inc/distant');
3684
+            $fichier = copie_locale($img_file);
3685
+            $img_file = ($fichier ? _DIR_RACINE . $fichier : $img_file);
3686
+        }
3687
+
3688
+        if (
3689
+            !$img_file
3690
+            or !file_exists($img_file)
3691
+            or !$svg = file_get_contents($img_file)
3692
+        ) {
3693
+            return '';
3694
+        }
3695
+    }
3696
+
3697
+    if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) {
3698
+        return '';
3699
+    }
3700
+
3701
+    [$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3702
+
3703
+    $balise_svg = $match[0];
3704
+    $balise_svg_source = $balise_svg;
3705
+
3706
+    // entete XML à supprimer
3707
+    $svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3708
+
3709
+    // IE est toujours mon ami
3710
+    $balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3711
+
3712
+    // regler la classe
3713
+    if (!is_null($class)) {
3714
+        if (strlen($class)) {
3715
+            $balise_svg = inserer_attribut($balise_svg, 'class', $class);
3716
+        }
3717
+        else {
3718
+            $balise_svg = vider_attribut($balise_svg, 'class');
3719
+        }
3720
+    }
3721
+
3722
+    // regler le alt
3723
+    if ($alt) {
3724
+        $balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3725
+        $id = 'img-svg-title-' . substr(md5("$img_file:$svg:$alt"), 0, 4);
3726
+        $balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3727
+        $title = "<title id=\"$id\">" . entites_html($alt) . "</title>\n";
3728
+        $balise_svg .= $title;
3729
+    }
3730
+    else {
3731
+        $balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3732
+    }
3733
+
3734
+    $svg = str_replace($balise_svg_source, $balise_svg, $svg);
3735
+
3736
+    if (!is_null($size) and strlen($size = trim($size))) {
3737
+        [$width, $height] = helper_filtre_balise_img_svg_size($svg, $size);
3738
+
3739
+        if (!function_exists('svg_redimensionner')) {
3740
+            include_spip('inc/svg');
3741
+        }
3742
+        $svg = svg_redimensionner($svg, $width, $height);
3743
+    }
3744
+
3745
+    return $svg;
3746 3746
 }
3747 3747
 
3748 3748
 
@@ -3768,18 +3768,18 @@  discard block
 block discarded – undo
3768 3768
  *     Code HTML résultant
3769 3769
  **/
3770 3770
 function filtre_foreach_dist($tableau, $modele = 'foreach') {
3771
-	$texte = '';
3772
-	if (is_array($tableau)) {
3773
-		foreach ($tableau as $k => $v) {
3774
-			$res = recuperer_fond(
3775
-				'modeles/' . $modele,
3776
-				array_merge(['cle' => $k], (is_array($v) ? $v : ['valeur' => $v]))
3777
-			);
3778
-			$texte .= $res;
3779
-		}
3780
-	}
3771
+    $texte = '';
3772
+    if (is_array($tableau)) {
3773
+        foreach ($tableau as $k => $v) {
3774
+            $res = recuperer_fond(
3775
+                'modeles/' . $modele,
3776
+                array_merge(['cle' => $k], (is_array($v) ? $v : ['valeur' => $v]))
3777
+            );
3778
+            $texte .= $res;
3779
+        }
3780
+    }
3781 3781
 
3782
-	return $texte;
3782
+    return $texte;
3783 3783
 }
3784 3784
 
3785 3785
 
@@ -3804,37 +3804,37 @@  discard block
 block discarded – undo
3804 3804
  *         - tout : retourne toutes les informations du plugin actif
3805 3805
  **/
3806 3806
 function filtre_info_plugin_dist($plugin, $type_info, $reload = false) {
3807
-	include_spip('inc/plugin');
3808
-	$plugin = strtoupper($plugin);
3809
-	$plugins_actifs = liste_plugin_actifs();
3810
-
3811
-	if (!$plugin) {
3812
-		return serialize(array_keys($plugins_actifs));
3813
-	} elseif (empty($plugins_actifs[$plugin]) and !$reload) {
3814
-		return '';
3815
-	} elseif (($type_info == 'est_actif') and !$reload) {
3816
-		return $plugins_actifs[$plugin] ? 1 : 0;
3817
-	} elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) {
3818
-		return $plugins_actifs[$plugin][$type_info];
3819
-	} else {
3820
-		$get_infos = charger_fonction('get_infos', 'plugins');
3821
-		// On prend en compte les extensions
3822
-		if (!is_dir($plugins_actifs[$plugin]['dir_type'])) {
3823
-			$dir_plugins = constant($plugins_actifs[$plugin]['dir_type']);
3824
-		} else {
3825
-			$dir_plugins = $plugins_actifs[$plugin]['dir_type'];
3826
-		}
3827
-		if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) {
3828
-			return '';
3829
-		}
3830
-		if ($type_info == 'tout') {
3831
-			return $infos;
3832
-		} elseif ($type_info == 'est_actif') {
3833
-			return $infos ? 1 : 0;
3834
-		} else {
3835
-			return strval($infos[$type_info]);
3836
-		}
3837
-	}
3807
+    include_spip('inc/plugin');
3808
+    $plugin = strtoupper($plugin);
3809
+    $plugins_actifs = liste_plugin_actifs();
3810
+
3811
+    if (!$plugin) {
3812
+        return serialize(array_keys($plugins_actifs));
3813
+    } elseif (empty($plugins_actifs[$plugin]) and !$reload) {
3814
+        return '';
3815
+    } elseif (($type_info == 'est_actif') and !$reload) {
3816
+        return $plugins_actifs[$plugin] ? 1 : 0;
3817
+    } elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) {
3818
+        return $plugins_actifs[$plugin][$type_info];
3819
+    } else {
3820
+        $get_infos = charger_fonction('get_infos', 'plugins');
3821
+        // On prend en compte les extensions
3822
+        if (!is_dir($plugins_actifs[$plugin]['dir_type'])) {
3823
+            $dir_plugins = constant($plugins_actifs[$plugin]['dir_type']);
3824
+        } else {
3825
+            $dir_plugins = $plugins_actifs[$plugin]['dir_type'];
3826
+        }
3827
+        if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) {
3828
+            return '';
3829
+        }
3830
+        if ($type_info == 'tout') {
3831
+            return $infos;
3832
+        } elseif ($type_info == 'est_actif') {
3833
+            return $infos ? 1 : 0;
3834
+        } else {
3835
+            return strval($infos[$type_info]);
3836
+        }
3837
+    }
3838 3838
 }
3839 3839
 
3840 3840
 
@@ -3861,9 +3861,9 @@  discard block
 block discarded – undo
3861 3861
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
3862 3862
  */
3863 3863
 function puce_changement_statut($id_objet, $statut, $id_rubrique, $type, $ajax = false) {
3864
-	$puce_statut = charger_fonction('puce_statut', 'inc');
3864
+    $puce_statut = charger_fonction('puce_statut', 'inc');
3865 3865
 
3866
-	return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax);
3866
+    return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax);
3867 3867
 }
3868 3868
 
3869 3869
 
@@ -3893,19 +3893,19 @@  discard block
 block discarded – undo
3893 3893
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
3894 3894
  */
3895 3895
 function filtre_puce_statut_dist($statut, $objet, $id_objet = 0, $id_parent = 0) {
3896
-	static $puce_statut = null;
3897
-	if (!$puce_statut) {
3898
-		$puce_statut = charger_fonction('puce_statut', 'inc');
3899
-	}
3896
+    static $puce_statut = null;
3897
+    if (!$puce_statut) {
3898
+        $puce_statut = charger_fonction('puce_statut', 'inc');
3899
+    }
3900 3900
 
3901
-	return $puce_statut(
3902
-		$id_objet,
3903
-		$statut,
3904
-		$id_parent,
3905
-		$objet,
3906
-		false,
3907
-		objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false
3908
-	);
3901
+    return $puce_statut(
3902
+        $id_objet,
3903
+        $statut,
3904
+        $id_parent,
3905
+        $objet,
3906
+        false,
3907
+        objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false
3908
+    );
3909 3909
 }
3910 3910
 
3911 3911
 
@@ -3932,98 +3932,98 @@  discard block
 block discarded – undo
3932 3932
  *   hash du contexte
3933 3933
  */
3934 3934
 function encoder_contexte_ajax($c, $form = '', $emboite = null, $ajaxid = '') {
3935
-	$env = null;
3936
-	if (
3937
-		is_string($c)
3938
-		and @unserialize($c) !== false
3939
-	) {
3940
-		$c = unserialize($c);
3941
-	}
3942
-
3943
-	// supprimer les parametres debut_x
3944
-	// pour que la pagination ajax ne soit pas plantee
3945
-	// si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0,
3946
-	// le debut_x=0 n'existe pas, et on resterait sur 1
3947
-	if (is_array($c)) {
3948
-		foreach ($c as $k => $v) {
3949
-			if (strpos($k, 'debut_') === 0) {
3950
-				unset($c[$k]);
3951
-			}
3952
-		}
3953
-	}
3954
-
3955
-	if (!function_exists('calculer_cle_action')) {
3956
-		include_spip('inc/securiser_action');
3957
-	}
3958
-
3959
-	$c = serialize($c);
3960
-	$cle = calculer_cle_action($form . $c);
3961
-	$c = "$cle:$c";
3962
-
3963
-	// on ne stocke pas les contextes dans des fichiers en cache
3964
-	// par defaut, sauf si cette configuration a été forcée
3965
-	// OU que la longueur de l’argument géneré est plus long
3966
-	// que ce qui est toléré.
3967
-	$cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX);
3968
-	if (!$cache_contextes_ajax) {
3969
-		$env = $c;
3970
-		if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3971
-			$env = gzdeflate($env);
3972
-		}
3973
-		$env = _xor($env);
3974
-		$env = base64_encode($env);
3975
-		$len = strlen($env);
3976
-		// Si l’url est trop longue pour le navigateur
3977
-		$max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR;
3978
-		if ($len > $max_len) {
3979
-			$cache_contextes_ajax = true;
3980
-			spip_log(
3981
-				'Contextes AJAX forces en fichiers !'
3982
-				. ' Cela arrive lorsque la valeur du contexte'
3983
-				. " depasse la longueur maximale autorisee ($max_len). Ici : $len.",
3984
-				_LOG_AVERTISSEMENT
3985
-			);
3986
-		}
3987
-		// Sinon si Suhosin est actif et a une la valeur maximale des variables en GET...
3988
-		elseif (
3989
-			$max_len = @ini_get('suhosin.get.max_value_length')
3990
-			and $max_len < $len
3991
-		) {
3992
-			$cache_contextes_ajax = true;
3993
-			spip_log('Contextes AJAX forces en fichiers !'
3994
-				. ' Cela arrive lorsque la valeur du contexte'
3995
-				. ' depasse la longueur maximale autorisee par Suhosin'
3996
-				. " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len."
3997
-				. ' Vous devriez modifier les parametres de Suhosin'
3998
-				. ' pour accepter au moins 1024 caracteres.', _LOG_AVERTISSEMENT);
3999
-		}
4000
-	}
4001
-
4002
-	if ($cache_contextes_ajax) {
4003
-		$dir = sous_repertoire(_DIR_CACHE, 'contextes');
4004
-		// stocker les contextes sur disque et ne passer qu'un hash dans l'url
4005
-		$md5 = md5($c);
4006
-		ecrire_fichier("$dir/c$md5", $c);
4007
-		$env = $md5;
4008
-	}
4009
-
4010
-	if ($emboite === null) {
4011
-		return $env;
4012
-	}
4013
-	if (!trim($emboite)) {
4014
-		return '';
4015
-	}
4016
-	// toujours encoder l'url source dans le bloc ajax
4017
-	$r = self();
4018
-	$r = ' data-origin="' . $r . '"';
4019
-	$class = 'ajaxbloc';
4020
-	if ($ajaxid and is_string($ajaxid)) {
4021
-		// ajaxid est normalement conforme a un nom de classe css
4022
-		// on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
4023
-		$class .= ' ajax-id-' . entites_html($ajaxid);
4024
-	}
4025
-
4026
-	return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3935
+    $env = null;
3936
+    if (
3937
+        is_string($c)
3938
+        and @unserialize($c) !== false
3939
+    ) {
3940
+        $c = unserialize($c);
3941
+    }
3942
+
3943
+    // supprimer les parametres debut_x
3944
+    // pour que la pagination ajax ne soit pas plantee
3945
+    // si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0,
3946
+    // le debut_x=0 n'existe pas, et on resterait sur 1
3947
+    if (is_array($c)) {
3948
+        foreach ($c as $k => $v) {
3949
+            if (strpos($k, 'debut_') === 0) {
3950
+                unset($c[$k]);
3951
+            }
3952
+        }
3953
+    }
3954
+
3955
+    if (!function_exists('calculer_cle_action')) {
3956
+        include_spip('inc/securiser_action');
3957
+    }
3958
+
3959
+    $c = serialize($c);
3960
+    $cle = calculer_cle_action($form . $c);
3961
+    $c = "$cle:$c";
3962
+
3963
+    // on ne stocke pas les contextes dans des fichiers en cache
3964
+    // par defaut, sauf si cette configuration a été forcée
3965
+    // OU que la longueur de l’argument géneré est plus long
3966
+    // que ce qui est toléré.
3967
+    $cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX);
3968
+    if (!$cache_contextes_ajax) {
3969
+        $env = $c;
3970
+        if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3971
+            $env = gzdeflate($env);
3972
+        }
3973
+        $env = _xor($env);
3974
+        $env = base64_encode($env);
3975
+        $len = strlen($env);
3976
+        // Si l’url est trop longue pour le navigateur
3977
+        $max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR;
3978
+        if ($len > $max_len) {
3979
+            $cache_contextes_ajax = true;
3980
+            spip_log(
3981
+                'Contextes AJAX forces en fichiers !'
3982
+                . ' Cela arrive lorsque la valeur du contexte'
3983
+                . " depasse la longueur maximale autorisee ($max_len). Ici : $len.",
3984
+                _LOG_AVERTISSEMENT
3985
+            );
3986
+        }
3987
+        // Sinon si Suhosin est actif et a une la valeur maximale des variables en GET...
3988
+        elseif (
3989
+            $max_len = @ini_get('suhosin.get.max_value_length')
3990
+            and $max_len < $len
3991
+        ) {
3992
+            $cache_contextes_ajax = true;
3993
+            spip_log('Contextes AJAX forces en fichiers !'
3994
+                . ' Cela arrive lorsque la valeur du contexte'
3995
+                . ' depasse la longueur maximale autorisee par Suhosin'
3996
+                . " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len."
3997
+                . ' Vous devriez modifier les parametres de Suhosin'
3998
+                . ' pour accepter au moins 1024 caracteres.', _LOG_AVERTISSEMENT);
3999
+        }
4000
+    }
4001
+
4002
+    if ($cache_contextes_ajax) {
4003
+        $dir = sous_repertoire(_DIR_CACHE, 'contextes');
4004
+        // stocker les contextes sur disque et ne passer qu'un hash dans l'url
4005
+        $md5 = md5($c);
4006
+        ecrire_fichier("$dir/c$md5", $c);
4007
+        $env = $md5;
4008
+    }
4009
+
4010
+    if ($emboite === null) {
4011
+        return $env;
4012
+    }
4013
+    if (!trim($emboite)) {
4014
+        return '';
4015
+    }
4016
+    // toujours encoder l'url source dans le bloc ajax
4017
+    $r = self();
4018
+    $r = ' data-origin="' . $r . '"';
4019
+    $class = 'ajaxbloc';
4020
+    if ($ajaxid and is_string($ajaxid)) {
4021
+        // ajaxid est normalement conforme a un nom de classe css
4022
+        // on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
4023
+        $class .= ' ajax-id-' . entites_html($ajaxid);
4024
+    }
4025
+
4026
+    return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
4027 4027
 }
4028 4028
 
4029 4029
 /**
@@ -4043,37 +4043,37 @@  discard block
 block discarded – undo
4043 4043
  *   - false : erreur de décodage
4044 4044
  */
4045 4045
 function decoder_contexte_ajax($c, $form = '') {
4046
-	if (!function_exists('calculer_cle_action')) {
4047
-		include_spip('inc/securiser_action');
4048
-	}
4049
-	if (
4050
-		((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32)
4051
-		and $dir = sous_repertoire(_DIR_CACHE, 'contextes')
4052
-		and lire_fichier("$dir/c$c", $contexte)
4053
-	) {
4054
-		$c = $contexte;
4055
-	} else {
4056
-		$c = @base64_decode($c);
4057
-		$c = _xor($c);
4058
-		if (function_exists('gzdeflate') && function_exists('gzinflate')) {
4059
-			$c = @gzinflate($c);
4060
-		}
4061
-	}
4062
-
4063
-	// extraire la signature en debut de contexte
4064
-	// et la verifier avant de deserializer
4065
-	// format : signature:donneesserializees
4066
-	if ($p = strpos($c, ':')) {
4067
-		$cle = substr($c, 0, $p);
4068
-		$c = substr($c, $p + 1);
4069
-
4070
-		if ($cle == calculer_cle_action($form . $c)) {
4071
-			$env = @unserialize($c);
4072
-			return $env;
4073
-		}
4074
-	}
4075
-
4076
-	return false;
4046
+    if (!function_exists('calculer_cle_action')) {
4047
+        include_spip('inc/securiser_action');
4048
+    }
4049
+    if (
4050
+        ((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32)
4051
+        and $dir = sous_repertoire(_DIR_CACHE, 'contextes')
4052
+        and lire_fichier("$dir/c$c", $contexte)
4053
+    ) {
4054
+        $c = $contexte;
4055
+    } else {
4056
+        $c = @base64_decode($c);
4057
+        $c = _xor($c);
4058
+        if (function_exists('gzdeflate') && function_exists('gzinflate')) {
4059
+            $c = @gzinflate($c);
4060
+        }
4061
+    }
4062
+
4063
+    // extraire la signature en debut de contexte
4064
+    // et la verifier avant de deserializer
4065
+    // format : signature:donneesserializees
4066
+    if ($p = strpos($c, ':')) {
4067
+        $cle = substr($c, 0, $p);
4068
+        $c = substr($c, $p + 1);
4069
+
4070
+        if ($cle == calculer_cle_action($form . $c)) {
4071
+            $env = @unserialize($c);
4072
+            return $env;
4073
+        }
4074
+    }
4075
+
4076
+    return false;
4077 4077
 }
4078 4078
 
4079 4079
 
@@ -4091,20 +4091,20 @@  discard block
 block discarded – undo
4091 4091
  *    Message décrypté ou encrypté
4092 4092
  **/
4093 4093
 function _xor($message, $key = null) {
4094
-	if (is_null($key)) {
4095
-		if (!function_exists('calculer_cle_action')) {
4096
-			include_spip('inc/securiser_action');
4097
-		}
4098
-		$key = pack('H*', calculer_cle_action('_xor'));
4099
-	}
4094
+    if (is_null($key)) {
4095
+        if (!function_exists('calculer_cle_action')) {
4096
+            include_spip('inc/securiser_action');
4097
+        }
4098
+        $key = pack('H*', calculer_cle_action('_xor'));
4099
+    }
4100 4100
 
4101
-	$keylen = strlen($key);
4102
-	$messagelen = strlen($message);
4103
-	for ($i = 0; $i < $messagelen; $i++) {
4104
-		$message[$i] = ~($message[$i] ^ $key[$i % $keylen]);
4105
-	}
4101
+    $keylen = strlen($key);
4102
+    $messagelen = strlen($message);
4103
+    for ($i = 0; $i < $messagelen; $i++) {
4104
+        $message[$i] = ~($message[$i] ^ $key[$i % $keylen]);
4105
+    }
4106 4106
 
4107
-	return $message;
4107
+    return $message;
4108 4108
 }
4109 4109
 
4110 4110
 /**
@@ -4118,7 +4118,7 @@  discard block
 block discarded – undo
4118 4118
  * @return string
4119 4119
  */
4120 4120
 function url_reponse_forum($texte) {
4121
- return $texte;
4121
+    return $texte;
4122 4122
 }
4123 4123
 
4124 4124
 /**
@@ -4132,7 +4132,7 @@  discard block
 block discarded – undo
4132 4132
  * @return string
4133 4133
  */
4134 4134
 function url_rss_forum($texte) {
4135
- return $texte;
4135
+    return $texte;
4136 4136
 }
4137 4137
 
4138 4138
 
@@ -4171,37 +4171,37 @@  discard block
 block discarded – undo
4171 4171
  *   Code HTML
4172 4172
  */
4173 4173
 function lien_ou_expose($url, $libelle = null, $on = false, $class = '', $title = '', $rel = '', $evt = '') {
4174
-	if ($on) {
4175
-		$bal = 'strong';
4176
-		$class = '';
4177
-		$att = '';
4178
-		// si $on passe la balise et optionnelement une ou ++classe
4179
-		// a.active span.selected.active etc....
4180
-		if (is_string($on) and (strncmp($on, 'a', 1) == 0 or strncmp($on, 'span', 4) == 0 or strncmp($on, 'strong', 6) == 0)) {
4181
-			$on = explode('.', $on);
4182
-			// on verifie que c'est exactement une des 3 balises a, span ou strong
4183
-			if (in_array(reset($on), ['a', 'span', 'strong'])) {
4184
-				$bal = array_shift($on);
4185
-				$class = implode(' ', $on);
4186
-				if ($bal == 'a') {
4187
-					$att = 'href="#" ';
4188
-				}
4189
-			}
4190
-		}
4191
-		$att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"';
4192
-	} else {
4193
-		$bal = 'a';
4194
-		$att = "href='$url'"
4195
-			. ($title ? " title='" . attribut_html($title) . "'" : '')
4196
-			. ($class ? " class='" . attribut_html($class) . "'" : '')
4197
-			. ($rel ? " rel='" . attribut_html($rel) . "'" : '')
4198
-			. $evt;
4199
-	}
4200
-	if ($libelle === null) {
4201
-		$libelle = $url;
4202
-	}
4203
-
4204
-	return "<$bal $att>$libelle</$bal>";
4174
+    if ($on) {
4175
+        $bal = 'strong';
4176
+        $class = '';
4177
+        $att = '';
4178
+        // si $on passe la balise et optionnelement une ou ++classe
4179
+        // a.active span.selected.active etc....
4180
+        if (is_string($on) and (strncmp($on, 'a', 1) == 0 or strncmp($on, 'span', 4) == 0 or strncmp($on, 'strong', 6) == 0)) {
4181
+            $on = explode('.', $on);
4182
+            // on verifie que c'est exactement une des 3 balises a, span ou strong
4183
+            if (in_array(reset($on), ['a', 'span', 'strong'])) {
4184
+                $bal = array_shift($on);
4185
+                $class = implode(' ', $on);
4186
+                if ($bal == 'a') {
4187
+                    $att = 'href="#" ';
4188
+                }
4189
+            }
4190
+        }
4191
+        $att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"';
4192
+    } else {
4193
+        $bal = 'a';
4194
+        $att = "href='$url'"
4195
+            . ($title ? " title='" . attribut_html($title) . "'" : '')
4196
+            . ($class ? " class='" . attribut_html($class) . "'" : '')
4197
+            . ($rel ? " rel='" . attribut_html($rel) . "'" : '')
4198
+            . $evt;
4199
+    }
4200
+    if ($libelle === null) {
4201
+        $libelle = $url;
4202
+    }
4203
+
4204
+    return "<$bal $att>$libelle</$bal>";
4205 4205
 }
4206 4206
 
4207 4207
 
@@ -4218,39 +4218,39 @@  discard block
 block discarded – undo
4218 4218
  * @return string : la chaine de langue finale en utilisant la fonction _T()
4219 4219
  */
4220 4220
 function singulier_ou_pluriel($nb, $chaine_un, $chaine_plusieurs, $var = 'nb', $vars = []) {
4221
-	static $local_singulier_ou_pluriel = [];
4222
-
4223
-	// si nb=0 ou pas de $vars valide on retourne une chaine vide, a traiter par un |sinon
4224
-	if (!is_numeric($nb) or $nb == 0) {
4225
-		return '';
4226
-	}
4227
-	if (!is_array($vars)) {
4228
-		return '';
4229
-	}
4230
-
4231
-	$langue = $GLOBALS['spip_lang'];
4232
-	if (!isset($local_singulier_ou_pluriel[$langue])) {
4233
-		$local_singulier_ou_pluriel[$langue] = false;
4234
-		if (
4235
-			$f = charger_fonction("singulier_ou_pluriel_{$langue}", 'inc', true)
4236
-			or $f = charger_fonction('singulier_ou_pluriel', 'inc', true)
4237
-		) {
4238
-			$local_singulier_ou_pluriel[$langue] = $f;
4239
-		}
4240
-	}
4241
-
4242
-	// si on a une surcharge on l'utilise
4243
-	if ($local_singulier_ou_pluriel[$langue]) {
4244
-		return ($local_singulier_ou_pluriel[$langue])($nb, $chaine_un, $chaine_plusieurs, $var, $vars);
4245
-	}
4246
-
4247
-	// sinon traitement par defaut
4248
-	$vars[$var] = $nb;
4249
-	if ($nb >= 2) {
4250
-		return _T($chaine_plusieurs, $vars);
4251
-	} else {
4252
-		return _T($chaine_un, $vars);
4253
-	}
4221
+    static $local_singulier_ou_pluriel = [];
4222
+
4223
+    // si nb=0 ou pas de $vars valide on retourne une chaine vide, a traiter par un |sinon
4224
+    if (!is_numeric($nb) or $nb == 0) {
4225
+        return '';
4226
+    }
4227
+    if (!is_array($vars)) {
4228
+        return '';
4229
+    }
4230
+
4231
+    $langue = $GLOBALS['spip_lang'];
4232
+    if (!isset($local_singulier_ou_pluriel[$langue])) {
4233
+        $local_singulier_ou_pluriel[$langue] = false;
4234
+        if (
4235
+            $f = charger_fonction("singulier_ou_pluriel_{$langue}", 'inc', true)
4236
+            or $f = charger_fonction('singulier_ou_pluriel', 'inc', true)
4237
+        ) {
4238
+            $local_singulier_ou_pluriel[$langue] = $f;
4239
+        }
4240
+    }
4241
+
4242
+    // si on a une surcharge on l'utilise
4243
+    if ($local_singulier_ou_pluriel[$langue]) {
4244
+        return ($local_singulier_ou_pluriel[$langue])($nb, $chaine_un, $chaine_plusieurs, $var, $vars);
4245
+    }
4246
+
4247
+    // sinon traitement par defaut
4248
+    $vars[$var] = $nb;
4249
+    if ($nb >= 2) {
4250
+        return _T($chaine_plusieurs, $vars);
4251
+    } else {
4252
+        return _T($chaine_un, $vars);
4253
+    }
4254 4254
 }
4255 4255
 
4256 4256
 
@@ -4278,73 +4278,73 @@  discard block
 block discarded – undo
4278 4278
  */
4279 4279
 function prepare_icone_base($type, $lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') {
4280 4280
 
4281
-	$class_lien = $class_bouton = $class;
4282
-
4283
-	// Normaliser la fonction et compléter la classe en fonction
4284
-	if (in_array($fonction, ['del', 'supprimer.gif'])) {
4285
-		$class_lien .= ' danger';
4286
-		$class_bouton .= ' btn_danger';
4287
-	} elseif ($fonction == 'rien.gif') {
4288
-		$fonction = '';
4289
-	} elseif ($fonction == 'delsafe') {
4290
-		$fonction = 'del';
4291
-	}
4292
-
4293
-	$fond_origine = $fond;
4294
-	// Remappage des icone : article-24.png+new => article-new-24.png
4295
-	if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
4296
-		[$fond, $fonction] = $icone_renommer($fond, $fonction);
4297
-	}
4298
-
4299
-	// Ajouter le type d'objet dans la classe
4300
-	$objet_type = substr(basename($fond), 0, -4);
4301
-	$class_lien .= " $objet_type";
4302
-	$class_bouton .= " $objet_type";
4303
-
4304
-	// Texte
4305
-	$alt = attribut_html($texte);
4306
-	$title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
4307
-
4308
-	// Liens : préparer les classes ajax
4309
-	$ajax = '';
4310
-	if ($type === 'lien') {
4311
-		if (strpos($class_lien, 'ajax') !== false) {
4312
-			$ajax = 'ajax';
4313
-			if (strpos($class_lien, 'preload') !== false) {
4314
-				$ajax .= ' preload';
4315
-			}
4316
-			if (strpos($class_lien, 'nocache') !== false) {
4317
-				$ajax .= ' nocache';
4318
-			}
4319
-			$ajax = " class='$ajax'";
4320
-		}
4321
-	}
4322
-
4323
-	// Repérer la taille et l'ajouter dans la classe
4324
-	$size = 24;
4325
-	if (
4326
-		preg_match('/-([0-9]{1,3})[.](gif|png|svg)$/i', $fond, $match)
4327
-		or preg_match('/-([0-9]{1,3})([.](gif|png|svg))?$/i', $fond_origine, $match)
4328
-	) {
4329
-		$size = $match[1];
4330
-	}
4331
-	$class_lien .= " s$size";
4332
-	$class_bouton .= " s$size";
4333
-
4334
-	// Icône
4335
-	$icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4336
-	$icone = '<span class="icone-image' . ($fonction ? " icone-fonction icone-fonction-$fonction" : '') . "\">$icone</span>";
4337
-
4338
-	// Markup final
4339
-	if ($type == 'lien') {
4340
-		return "<span class='icone $class_lien'>"
4341
-		. "<a href='$lien'$title$ajax$javascript>"
4342
-		. $icone
4343
-		. "<b>$texte</b>"
4344
-		. "</a></span>\n";
4345
-	} else {
4346
-		return bouton_action("$icone $texte", $lien, $class_bouton, $javascript, $alt);
4347
-	}
4281
+    $class_lien = $class_bouton = $class;
4282
+
4283
+    // Normaliser la fonction et compléter la classe en fonction
4284
+    if (in_array($fonction, ['del', 'supprimer.gif'])) {
4285
+        $class_lien .= ' danger';
4286
+        $class_bouton .= ' btn_danger';
4287
+    } elseif ($fonction == 'rien.gif') {
4288
+        $fonction = '';
4289
+    } elseif ($fonction == 'delsafe') {
4290
+        $fonction = 'del';
4291
+    }
4292
+
4293
+    $fond_origine = $fond;
4294
+    // Remappage des icone : article-24.png+new => article-new-24.png
4295
+    if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
4296
+        [$fond, $fonction] = $icone_renommer($fond, $fonction);
4297
+    }
4298
+
4299
+    // Ajouter le type d'objet dans la classe
4300
+    $objet_type = substr(basename($fond), 0, -4);
4301
+    $class_lien .= " $objet_type";
4302
+    $class_bouton .= " $objet_type";
4303
+
4304
+    // Texte
4305
+    $alt = attribut_html($texte);
4306
+    $title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
4307
+
4308
+    // Liens : préparer les classes ajax
4309
+    $ajax = '';
4310
+    if ($type === 'lien') {
4311
+        if (strpos($class_lien, 'ajax') !== false) {
4312
+            $ajax = 'ajax';
4313
+            if (strpos($class_lien, 'preload') !== false) {
4314
+                $ajax .= ' preload';
4315
+            }
4316
+            if (strpos($class_lien, 'nocache') !== false) {
4317
+                $ajax .= ' nocache';
4318
+            }
4319
+            $ajax = " class='$ajax'";
4320
+        }
4321
+    }
4322
+
4323
+    // Repérer la taille et l'ajouter dans la classe
4324
+    $size = 24;
4325
+    if (
4326
+        preg_match('/-([0-9]{1,3})[.](gif|png|svg)$/i', $fond, $match)
4327
+        or preg_match('/-([0-9]{1,3})([.](gif|png|svg))?$/i', $fond_origine, $match)
4328
+    ) {
4329
+        $size = $match[1];
4330
+    }
4331
+    $class_lien .= " s$size";
4332
+    $class_bouton .= " s$size";
4333
+
4334
+    // Icône
4335
+    $icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4336
+    $icone = '<span class="icone-image' . ($fonction ? " icone-fonction icone-fonction-$fonction" : '') . "\">$icone</span>";
4337
+
4338
+    // Markup final
4339
+    if ($type == 'lien') {
4340
+        return "<span class='icone $class_lien'>"
4341
+        . "<a href='$lien'$title$ajax$javascript>"
4342
+        . $icone
4343
+        . "<b>$texte</b>"
4344
+        . "</a></span>\n";
4345
+    } else {
4346
+        return bouton_action("$icone $texte", $lien, $class_bouton, $javascript, $alt);
4347
+    }
4348 4348
 }
4349 4349
 
4350 4350
 /**
@@ -4368,7 +4368,7 @@  discard block
 block discarded – undo
4368 4368
  *     Code HTML du lien
4369 4369
  **/
4370 4370
 function icone_base($lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') {
4371
-	return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript);
4371
+    return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript);
4372 4372
 }
4373 4373
 
4374 4374
 /**
@@ -4403,7 +4403,7 @@  discard block
 block discarded – undo
4403 4403
  *     Code HTML du lien
4404 4404
  **/
4405 4405
 function filtre_icone_verticale_dist($lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') {
4406
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript);
4406
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript);
4407 4407
 }
4408 4408
 
4409 4409
 /**
@@ -4448,7 +4448,7 @@  discard block
 block discarded – undo
4448 4448
  *     Code HTML du lien
4449 4449
  **/
4450 4450
 function filtre_icone_horizontale_dist($lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') {
4451
-	return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript);
4451
+    return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript);
4452 4452
 }
4453 4453
 
4454 4454
 /**
@@ -4479,7 +4479,7 @@  discard block
 block discarded – undo
4479 4479
  *     Code HTML du lien
4480 4480
  **/
4481 4481
 function filtre_bouton_action_horizontal_dist($lien, $texte, $fond, $fonction = '', $class = '', $confirm = '') {
4482
-	return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, $class, $confirm);
4482
+    return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, $class, $confirm);
4483 4483
 }
4484 4484
 
4485 4485
 /**
@@ -4510,7 +4510,7 @@  discard block
 block discarded – undo
4510 4510
  *     Code HTML du lien
4511 4511
  */
4512 4512
 function filtre_icone_dist($lien, $texte, $fond, $align = '', $fonction = '', $class = '', $javascript = '') {
4513
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript);
4513
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript);
4514 4514
 }
4515 4515
 
4516 4516
 
@@ -4532,7 +4532,7 @@  discard block
 block discarded – undo
4532 4532
  * @return array Liste des éléments
4533 4533
  */
4534 4534
 function filtre_explode_dist($a, $b) {
4535
-	return explode($b, (string) $a);
4535
+    return explode($b, (string) $a);
4536 4536
 }
4537 4537
 
4538 4538
 /**
@@ -4553,7 +4553,7 @@  discard block
 block discarded – undo
4553 4553
  * @return string Texte
4554 4554
  */
4555 4555
 function filtre_implode_dist($a, $b) {
4556
-	return is_array($a) ? implode($b, $a) : $a;
4556
+    return is_array($a) ? implode($b, $a) : $a;
4557 4557
 }
4558 4558
 
4559 4559
 /**
@@ -4562,22 +4562,22 @@  discard block
 block discarded – undo
4562 4562
  * @return string Code CSS
4563 4563
  */
4564 4564
 function bando_images_background() {
4565
-	include_spip('inc/bandeau');
4566
-	// recuperer tous les boutons et leurs images
4567
-	$boutons = definir_barre_boutons(definir_barre_contexte(), true, false);
4565
+    include_spip('inc/bandeau');
4566
+    // recuperer tous les boutons et leurs images
4567
+    $boutons = definir_barre_boutons(definir_barre_contexte(), true, false);
4568 4568
 
4569
-	$res = '';
4570
-	foreach ($boutons as $page => $detail) {
4571
-		$selecteur = (in_array($page, ['outils_rapides', 'outils_collaboratifs']) ? '' : '.navigation_avec_icones ');
4572
-		foreach ($detail->sousmenu as $souspage => $sousdetail) {
4573
-			if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4574
-				$img = http_img_variante_svg_si_possible($sousdetail->icone);
4575
-				$res .= "\n$selecteur.bando2_$souspage {background-image:url($img);}";
4576
-			}
4577
-		}
4578
-	}
4569
+    $res = '';
4570
+    foreach ($boutons as $page => $detail) {
4571
+        $selecteur = (in_array($page, ['outils_rapides', 'outils_collaboratifs']) ? '' : '.navigation_avec_icones ');
4572
+        foreach ($detail->sousmenu as $souspage => $sousdetail) {
4573
+            if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4574
+                $img = http_img_variante_svg_si_possible($sousdetail->icone);
4575
+                $res .= "\n$selecteur.bando2_$souspage {background-image:url($img);}";
4576
+            }
4577
+        }
4578
+    }
4579 4579
 
4580
-	return $res;
4580
+    return $res;
4581 4581
 }
4582 4582
 
4583 4583
 /**
@@ -4602,27 +4602,27 @@  discard block
 block discarded – undo
4602 4602
  */
4603 4603
 function bouton_action($libelle, $url, $class = '', $confirm = '', $title = '', $callback = '') {
4604 4604
 
4605
-	// Classes : dispatcher `ajax` sur le formulaire
4606
-	$class_form = '';
4607
-	if (strpos($class, 'ajax') !== false) {
4608
-		$class_form = 'ajax';
4609
-		$class = str_replace('ajax', '', $class);
4610
-	}
4611
-	$class_btn = 'submit ' . trim($class);
4605
+    // Classes : dispatcher `ajax` sur le formulaire
4606
+    $class_form = '';
4607
+    if (strpos($class, 'ajax') !== false) {
4608
+        $class_form = 'ajax';
4609
+        $class = str_replace('ajax', '', $class);
4610
+    }
4611
+    $class_btn = 'submit ' . trim($class);
4612 4612
 
4613
-	if ($confirm) {
4614
-		$confirm = 'confirm("' . attribut_html($confirm) . '")';
4615
-		if ($callback) {
4616
-			$callback = "$confirm?($callback):false";
4617
-		} else {
4618
-			$callback = $confirm;
4619
-		}
4620
-	}
4621
-	$onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : '';
4622
-	$title = $title ? " title='$title'" : '';
4613
+    if ($confirm) {
4614
+        $confirm = 'confirm("' . attribut_html($confirm) . '")';
4615
+        if ($callback) {
4616
+            $callback = "$confirm?($callback):false";
4617
+        } else {
4618
+            $callback = $confirm;
4619
+        }
4620
+    }
4621
+    $onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : '';
4622
+    $title = $title ? " title='$title'" : '';
4623 4623
 
4624
-	return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>" . form_hidden($url)
4625
-	. "<button type='submit' class='$class_btn'$title$onclick>$libelle</button></div></form>";
4624
+    return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>" . form_hidden($url)
4625
+    . "<button type='submit' class='$class_btn'$title$onclick>$libelle</button></div></form>";
4626 4626
 }
4627 4627
 
4628 4628
 /**
@@ -4645,101 +4645,101 @@  discard block
 block discarded – undo
4645 4645
  * @return string
4646 4646
  */
4647 4647
 function generer_objet_info($id_objet, string $type_objet, string $info, string $etoile = '', array $params = []): string {
4648
-	static $trouver_table = null;
4649
-	static $objets;
4650
-
4651
-	// On verifie qu'on a tout ce qu'il faut
4652
-	$id_objet = intval($id_objet);
4653
-	if (!($id_objet and $type_objet and $info)) {
4654
-		return '';
4655
-	}
4656
-
4657
-	// si on a deja note que l'objet n'existe pas, ne pas aller plus loin
4658
-	if (isset($objets[$type_objet]) and $objets[$type_objet] === false) {
4659
-		return '';
4660
-	}
4661
-
4662
-	// Si on demande l'url, on retourne direct la fonction
4663
-	if ($info == 'url') {
4664
-		return generer_objet_url($id_objet, $type_objet, ...$params);
4665
-	}
4666
-
4667
-	// Sinon on va tout chercher dans la table et on garde en memoire
4668
-	$demande_titre = ($info === 'titre');
4669
-	$demande_introduction = ($info === 'introduction');
4670
-
4671
-	// 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
4672
-	if (
4673
-		!isset($objets[$type_objet][$id_objet])
4674
-		or
4675
-		($demande_titre and !isset($objets[$type_objet][$id_objet]['titre']))
4676
-	) {
4677
-		if (!$trouver_table) {
4678
-			$trouver_table = charger_fonction('trouver_table', 'base');
4679
-		}
4680
-		$desc = $trouver_table(table_objet_sql($type_objet));
4681
-		if (!$desc) {
4682
-			return $objets[$type_objet] = false;
4683
-		}
4684
-
4685
-		// Si on demande le titre, on le gere en interne
4686
-		$champ_titre = '';
4687
-		if ($demande_titre) {
4688
-			// si pas de titre declare mais champ titre, il sera peuple par le select *
4689
-			$champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4690
-		}
4691
-		include_spip('base/abstract_sql');
4692
-		include_spip('base/connect_sql');
4693
-		$objets[$type_objet][$id_objet] = sql_fetsel(
4694
-			'*' . $champ_titre,
4695
-			$desc['table_sql'],
4696
-			id_table_objet($type_objet) . ' = ' . intval($id_objet)
4697
-		);
4698
-
4699
-		// Toujours noter la longueur d'introduction, même si pas demandé cette fois-ci
4700
-		$objets[$type_objet]['introduction_longueur'] = $desc['introduction_longueur'] ?? null;
4701
-	}
4702
-
4703
-	// Pour les fonction generer_xxx, si on demande l'introduction,
4704
-	// ajouter la longueur au début des params supplémentaires
4705
-	if ($demande_introduction) {
4706
-		$introduction_longueur = $objets[$type_objet]['introduction_longueur'];
4707
-		array_unshift($params, $introduction_longueur);
4708
-	}
4709
-
4710
-	// Si la fonction generer_TYPE_TRUC existe, on l'utilise pour formater $info_generee
4711
-	if (
4712
-		$generer = charger_fonction("generer_{$type_objet}_{$info}", '', true)
4713
-		// @deprecated 4.1 generer_TRUC_TYPE
4714
-		or $generer = charger_fonction("generer_{$info}_{$type_objet}", '', true)
4715
-	) {
4716
-		$info_generee = $generer($id_objet, $objets[$type_objet][$id_objet], ...$params);
4717
-	}
4718
-	// Si la fonction generer_objet_TRUC existe, on l'utilise pour formater $info_generee
4719
-	elseif (
4720
-		$generer = charger_fonction("generer_objet_{$info}", '', true)
4721
-		// @deprecated 4.1 generer_TRUC_entite
4722
-		or $generer = charger_fonction("generer_{$info}_entite", '', true)
4723
-	) {
4724
-		$info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet], ...$params);
4725
-	} // Sinon on prend directement le champ SQL tel quel
4726
-	else {
4727
-		$info_generee = ($objets[$type_objet][$id_objet][$info] ?? '');
4728
-	}
4729
-
4730
-	// On va ensuite appliquer les traitements automatiques si besoin
4731
-	if (!$etoile) {
4732
-		// FIXME: on fournit un ENV minimum avec id et type et connect=''
4733
-		// mais ce fonctionnement est a ameliorer !
4734
-		$info_generee = appliquer_traitement_champ(
4735
-			$info_generee,
4736
-			$info,
4737
-			table_objet($type_objet),
4738
-			['id_objet' => $id_objet, 'objet' => $type_objet, '']
4739
-		);
4740
-	}
4741
-
4742
-	return $info_generee;
4648
+    static $trouver_table = null;
4649
+    static $objets;
4650
+
4651
+    // On verifie qu'on a tout ce qu'il faut
4652
+    $id_objet = intval($id_objet);
4653
+    if (!($id_objet and $type_objet and $info)) {
4654
+        return '';
4655
+    }
4656
+
4657
+    // si on a deja note que l'objet n'existe pas, ne pas aller plus loin
4658
+    if (isset($objets[$type_objet]) and $objets[$type_objet] === false) {
4659
+        return '';
4660
+    }
4661
+
4662
+    // Si on demande l'url, on retourne direct la fonction
4663
+    if ($info == 'url') {
4664
+        return generer_objet_url($id_objet, $type_objet, ...$params);
4665
+    }
4666
+
4667
+    // Sinon on va tout chercher dans la table et on garde en memoire
4668
+    $demande_titre = ($info === 'titre');
4669
+    $demande_introduction = ($info === 'introduction');
4670
+
4671
+    // 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
4672
+    if (
4673
+        !isset($objets[$type_objet][$id_objet])
4674
+        or
4675
+        ($demande_titre and !isset($objets[$type_objet][$id_objet]['titre']))
4676
+    ) {
4677
+        if (!$trouver_table) {
4678
+            $trouver_table = charger_fonction('trouver_table', 'base');
4679
+        }
4680
+        $desc = $trouver_table(table_objet_sql($type_objet));
4681
+        if (!$desc) {
4682
+            return $objets[$type_objet] = false;
4683
+        }
4684
+
4685
+        // Si on demande le titre, on le gere en interne
4686
+        $champ_titre = '';
4687
+        if ($demande_titre) {
4688
+            // si pas de titre declare mais champ titre, il sera peuple par le select *
4689
+            $champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4690
+        }
4691
+        include_spip('base/abstract_sql');
4692
+        include_spip('base/connect_sql');
4693
+        $objets[$type_objet][$id_objet] = sql_fetsel(
4694
+            '*' . $champ_titre,
4695
+            $desc['table_sql'],
4696
+            id_table_objet($type_objet) . ' = ' . intval($id_objet)
4697
+        );
4698
+
4699
+        // Toujours noter la longueur d'introduction, même si pas demandé cette fois-ci
4700
+        $objets[$type_objet]['introduction_longueur'] = $desc['introduction_longueur'] ?? null;
4701
+    }
4702
+
4703
+    // Pour les fonction generer_xxx, si on demande l'introduction,
4704
+    // ajouter la longueur au début des params supplémentaires
4705
+    if ($demande_introduction) {
4706
+        $introduction_longueur = $objets[$type_objet]['introduction_longueur'];
4707
+        array_unshift($params, $introduction_longueur);
4708
+    }
4709
+
4710
+    // Si la fonction generer_TYPE_TRUC existe, on l'utilise pour formater $info_generee
4711
+    if (
4712
+        $generer = charger_fonction("generer_{$type_objet}_{$info}", '', true)
4713
+        // @deprecated 4.1 generer_TRUC_TYPE
4714
+        or $generer = charger_fonction("generer_{$info}_{$type_objet}", '', true)
4715
+    ) {
4716
+        $info_generee = $generer($id_objet, $objets[$type_objet][$id_objet], ...$params);
4717
+    }
4718
+    // Si la fonction generer_objet_TRUC existe, on l'utilise pour formater $info_generee
4719
+    elseif (
4720
+        $generer = charger_fonction("generer_objet_{$info}", '', true)
4721
+        // @deprecated 4.1 generer_TRUC_entite
4722
+        or $generer = charger_fonction("generer_{$info}_entite", '', true)
4723
+    ) {
4724
+        $info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet], ...$params);
4725
+    } // Sinon on prend directement le champ SQL tel quel
4726
+    else {
4727
+        $info_generee = ($objets[$type_objet][$id_objet][$info] ?? '');
4728
+    }
4729
+
4730
+    // On va ensuite appliquer les traitements automatiques si besoin
4731
+    if (!$etoile) {
4732
+        // FIXME: on fournit un ENV minimum avec id et type et connect=''
4733
+        // mais ce fonctionnement est a ameliorer !
4734
+        $info_generee = appliquer_traitement_champ(
4735
+            $info_generee,
4736
+            $info,
4737
+            table_objet($type_objet),
4738
+            ['id_objet' => $id_objet, 'objet' => $type_objet, '']
4739
+        );
4740
+    }
4741
+
4742
+    return $info_generee;
4743 4743
 }
4744 4744
 
4745 4745
 /**
@@ -4747,7 +4747,7 @@  discard block
 block discarded – undo
4747 4747
  * @see generer_objet_info
4748 4748
  */
4749 4749
 function generer_info_entite($id_objet, $type_objet, $info, $etoile = '', $params = []) {
4750
-	return generer_objet_info(intval($id_objet), $type_objet, $info, $etoile, $params);
4750
+    return generer_objet_info(intval($id_objet), $type_objet, $info, $etoile, $params);
4751 4751
 }
4752 4752
 
4753 4753
 /**
@@ -4780,36 +4780,36 @@  discard block
 block discarded – undo
4780 4780
  */
4781 4781
 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 {
4782 4782
 
4783
-	$descriptif = $ligne_sql['descriptif'] ?? '';
4784
-	$texte = $ligne_sql['texte'] ?? '';
4785
-	// En absence de descriptif, on se rabat sur chapo + texte
4786
-	if (isset($ligne_sql['chapo'])) {
4787
-		$chapo = $ligne_sql['chapo'];
4788
-		$texte = strlen($descriptif) ?
4789
-			'' :
4790
-			"$chapo \n\n $texte";
4791
-	}
4783
+    $descriptif = $ligne_sql['descriptif'] ?? '';
4784
+    $texte = $ligne_sql['texte'] ?? '';
4785
+    // En absence de descriptif, on se rabat sur chapo + texte
4786
+    if (isset($ligne_sql['chapo'])) {
4787
+        $chapo = $ligne_sql['chapo'];
4788
+        $texte = strlen($descriptif) ?
4789
+            '' :
4790
+            "$chapo \n\n $texte";
4791
+    }
4792 4792
 
4793
-	// Longueur en paramètre, sinon celle renseignée dans la description de l'objet, sinon valeur en dur
4794
-	if (!intval($longueur_ou_suite)) {
4795
-		$longueur = intval($introduction_longueur ?: 600);
4796
-	} else {
4797
-		$longueur = intval($longueur_ou_suite);
4798
-	}
4793
+    // Longueur en paramètre, sinon celle renseignée dans la description de l'objet, sinon valeur en dur
4794
+    if (!intval($longueur_ou_suite)) {
4795
+        $longueur = intval($introduction_longueur ?: 600);
4796
+    } else {
4797
+        $longueur = intval($longueur_ou_suite);
4798
+    }
4799 4799
 
4800
-	// On peut optionnellement passer la suite en 1er paramètre de la balise
4801
-	// Ex : #INTRODUCTION{...}
4802
-	if (
4803
-		is_null($suite)
4804
-		and !intval($longueur_ou_suite)
4805
-	) {
4806
-		$suite = $longueur_ou_suite;
4807
-	}
4800
+    // On peut optionnellement passer la suite en 1er paramètre de la balise
4801
+    // Ex : #INTRODUCTION{...}
4802
+    if (
4803
+        is_null($suite)
4804
+        and !intval($longueur_ou_suite)
4805
+    ) {
4806
+        $suite = $longueur_ou_suite;
4807
+    }
4808 4808
 
4809
-	$f = chercher_filtre('introduction');
4810
-	$introduction = $f($descriptif, $texte, $longueur, $connect, $suite);
4809
+    $f = chercher_filtre('introduction');
4810
+    $introduction = $f($descriptif, $texte, $longueur, $connect, $suite);
4811 4811
 
4812
-	return $introduction;
4812
+    return $introduction;
4813 4813
 }
4814 4814
 
4815 4815
 /**
@@ -4817,7 +4817,7 @@  discard block
 block discarded – undo
4817 4817
  * @see generer_objet_introduction
4818 4818
  */
4819 4819
 function generer_introduction_entite($id_objet, $type_objet, $ligne_sql, $introduction_longueur = null, $longueur_ou_suite = null, $suite = null, string $connect = '') {
4820
-	return generer_objet_introduction(intval($id_objet), $type_objet, $ligne_sql, $introduction_longueur, $longueur_ou_suite, $suite, $connect);
4820
+    return generer_objet_introduction(intval($id_objet), $type_objet, $ligne_sql, $introduction_longueur, $longueur_ou_suite, $suite, $connect);
4821 4821
 }
4822 4822
 
4823 4823
 /**
@@ -4831,49 +4831,49 @@  discard block
 block discarded – undo
4831 4831
  * @return string
4832 4832
  */
4833 4833
 function appliquer_traitement_champ($texte, $champ, $table_objet = '', $env = [], string $connect = '') {
4834
-	if (!$champ) {
4835
-		return $texte;
4836
-	}
4834
+    if (!$champ) {
4835
+        return $texte;
4836
+    }
4837 4837
 
4838
-	// On charge les définitions des traitements (inc/texte et fichiers de fonctions)
4839
-	// car il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4840
-	include_fichiers_fonctions();
4838
+    // On charge les définitions des traitements (inc/texte et fichiers de fonctions)
4839
+    // car il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4840
+    include_fichiers_fonctions();
4841 4841
 
4842
-	$champ = strtoupper($champ);
4843
-	$traitements = $GLOBALS['table_des_traitements'][$champ] ?? false;
4844
-	if (!$traitements or !is_array($traitements)) {
4845
-		return $texte;
4846
-	}
4842
+    $champ = strtoupper($champ);
4843
+    $traitements = $GLOBALS['table_des_traitements'][$champ] ?? false;
4844
+    if (!$traitements or !is_array($traitements)) {
4845
+        return $texte;
4846
+    }
4847 4847
 
4848
-	$traitement = '';
4849
-	if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) {
4850
-		// necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4851
-		$table_objet = table_objet($table_objet);
4852
-		if (isset($traitements[$table_objet])) {
4853
-			$traitement = $traitements[$table_objet];
4854
-		}
4855
-	}
4856
-	if (!$traitement and isset($traitements[0])) {
4857
-		$traitement = $traitements[0];
4858
-	}
4859
-	// (sinon prendre le premier de la liste par defaut ?)
4848
+    $traitement = '';
4849
+    if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) {
4850
+        // necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4851
+        $table_objet = table_objet($table_objet);
4852
+        if (isset($traitements[$table_objet])) {
4853
+            $traitement = $traitements[$table_objet];
4854
+        }
4855
+    }
4856
+    if (!$traitement and isset($traitements[0])) {
4857
+        $traitement = $traitements[0];
4858
+    }
4859
+    // (sinon prendre le premier de la liste par defaut ?)
4860 4860
 
4861
-	if (!$traitement) {
4862
-		return $texte;
4863
-	}
4861
+    if (!$traitement) {
4862
+        return $texte;
4863
+    }
4864 4864
 
4865
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4865
+    $traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4866 4866
 
4867
-	// signaler qu'on est dans l'espace prive pour les filtres qui se servent de ce flag
4868
-	if (test_espace_prive()) {
4869
-		$env['espace_prive'] = 1;
4870
-	}
4867
+    // signaler qu'on est dans l'espace prive pour les filtres qui se servent de ce flag
4868
+    if (test_espace_prive()) {
4869
+        $env['espace_prive'] = 1;
4870
+    }
4871 4871
 
4872
-	// Fournir $connect et $Pile[0] au traitement si besoin
4873
-	$Pile = [0 => $env];
4874
-	eval("\$texte = $traitement;");
4872
+    // Fournir $connect et $Pile[0] au traitement si besoin
4873
+    $Pile = [0 => $env];
4874
+    eval("\$texte = $traitement;");
4875 4875
 
4876
-	return $texte;
4876
+    return $texte;
4877 4877
 }
4878 4878
 
4879 4879
 
@@ -4887,21 +4887,21 @@  discard block
 block discarded – undo
4887 4887
  * @return string
4888 4888
  */
4889 4889
 function generer_objet_lien(int $id_objet, string $objet, int $longueur = 80, string $connect = ''): string {
4890
-	include_spip('inc/liens');
4891
-	$titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4892
-	// lorsque l'objet n'est plus declare (plugin desactive par exemple)
4893
-	// le raccourcis n'est plus valide
4894
-	$titre = typo($titre['titre'] ?? '');
4895
-	// on essaye avec generer_info_entite ?
4896
-	if (!strlen($titre) and !$connect) {
4897
-		$titre = generer_objet_info($id_objet, $objet, 'titre');
4898
-	}
4899
-	if (!strlen($titre)) {
4900
-		$titre = _T('info_sans_titre');
4901
-	}
4902
-	$url = generer_objet_url($id_objet, $objet, '', '', null, '', $connect);
4890
+    include_spip('inc/liens');
4891
+    $titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4892
+    // lorsque l'objet n'est plus declare (plugin desactive par exemple)
4893
+    // le raccourcis n'est plus valide
4894
+    $titre = typo($titre['titre'] ?? '');
4895
+    // on essaye avec generer_info_entite ?
4896
+    if (!strlen($titre) and !$connect) {
4897
+        $titre = generer_objet_info($id_objet, $objet, 'titre');
4898
+    }
4899
+    if (!strlen($titre)) {
4900
+        $titre = _T('info_sans_titre');
4901
+    }
4902
+    $url = generer_objet_url($id_objet, $objet, '', '', null, '', $connect);
4903 4903
 
4904
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . '</a>';
4904
+    return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . '</a>';
4905 4905
 }
4906 4906
 
4907 4907
 /**
@@ -4909,7 +4909,7 @@  discard block
 block discarded – undo
4909 4909
  * @see generer_objet_lien
4910 4910
  */
4911 4911
 function generer_lien_entite($id_objet, $objet, $longueur = 80, $connect = null) {
4912
-	return generer_objet_lien(intval($id_objet), $objet, $longueur, $connect ?? '');
4912
+    return generer_objet_lien(intval($id_objet), $objet, $longueur, $connect ?? '');
4913 4913
 }
4914 4914
 
4915 4915
 /**
@@ -4925,15 +4925,15 @@  discard block
 block discarded – undo
4925 4925
  * @return string
4926 4926
  */
4927 4927
 function wrap($texte, $wrap) {
4928
-	$balises = extraire_balises($wrap);
4929
-	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4930
-		$texte = $wrap . $texte;
4931
-		$regs = array_reverse($regs[1]);
4932
-		$wrap = '</' . implode('></', $regs) . '>';
4933
-		$texte = $texte . $wrap;
4934
-	}
4928
+    $balises = extraire_balises($wrap);
4929
+    if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4930
+        $texte = $wrap . $texte;
4931
+        $regs = array_reverse($regs[1]);
4932
+        $wrap = '</' . implode('></', $regs) . '>';
4933
+        $texte = $texte . $wrap;
4934
+    }
4935 4935
 
4936
-	return $texte;
4936
+    return $texte;
4937 4937
 }
4938 4938
 
4939 4939
 
@@ -4953,44 +4953,44 @@  discard block
 block discarded – undo
4953 4953
  * @return array|mixed|string
4954 4954
  */
4955 4955
 function filtre_print_dist($u, $join = '<br />', $indent = 0) {
4956
-	if (is_string($u)) {
4957
-		$u = typo($u);
4956
+    if (is_string($u)) {
4957
+        $u = typo($u);
4958 4958
 
4959
-		return $u;
4960
-	}
4959
+        return $u;
4960
+    }
4961 4961
 
4962
-	// caster $u en array si besoin
4963
-	if (is_object($u)) {
4964
-		$u = (array)$u;
4965
-	}
4962
+    // caster $u en array si besoin
4963
+    if (is_object($u)) {
4964
+        $u = (array)$u;
4965
+    }
4966 4966
 
4967
-	if (is_array($u)) {
4968
-		$out = '';
4969
-		// toutes les cles sont numeriques ?
4970
-		// et aucun enfant n'est un tableau
4971
-		// liste simple separee par des virgules
4972
-		$numeric_keys = array_map('is_numeric', array_keys($u));
4973
-		$array_values = array_map('is_array', $u);
4974
-		$object_values = array_map('is_object', $u);
4975
-		if (
4976
-			array_sum($numeric_keys) == count($numeric_keys)
4977
-			and !array_sum($array_values)
4978
-			and !array_sum($object_values)
4979
-		) {
4980
-			return join(', ', array_map('filtre_print_dist', $u));
4981
-		}
4967
+    if (is_array($u)) {
4968
+        $out = '';
4969
+        // toutes les cles sont numeriques ?
4970
+        // et aucun enfant n'est un tableau
4971
+        // liste simple separee par des virgules
4972
+        $numeric_keys = array_map('is_numeric', array_keys($u));
4973
+        $array_values = array_map('is_array', $u);
4974
+        $object_values = array_map('is_object', $u);
4975
+        if (
4976
+            array_sum($numeric_keys) == count($numeric_keys)
4977
+            and !array_sum($array_values)
4978
+            and !array_sum($object_values)
4979
+        ) {
4980
+            return join(', ', array_map('filtre_print_dist', $u));
4981
+        }
4982 4982
 
4983
-		// sinon on passe a la ligne et on indente
4984
-		$i_str = str_pad('', $indent, ' ');
4985
-		foreach ($u as $k => $v) {
4986
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4987
-		}
4983
+        // sinon on passe a la ligne et on indente
4984
+        $i_str = str_pad('', $indent, ' ');
4985
+        foreach ($u as $k => $v) {
4986
+            $out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4987
+        }
4988 4988
 
4989
-		return $out;
4990
-	}
4989
+        return $out;
4990
+    }
4991 4991
 
4992
-	// on sait pas quoi faire...
4993
-	return $u;
4992
+    // on sait pas quoi faire...
4993
+    return $u;
4994 4994
 }
4995 4995
 
4996 4996
 
@@ -5003,10 +5003,10 @@  discard block
 block discarded – undo
5003 5003
  * @return string|array
5004 5004
  */
5005 5005
 function objet_info($objet, $info) {
5006
-	$table = table_objet_sql($objet);
5007
-	$infos = lister_tables_objets_sql($table);
5006
+    $table = table_objet_sql($objet);
5007
+    $infos = lister_tables_objets_sql($table);
5008 5008
 
5009
-	return ($infos[$info] ?? '');
5009
+    return ($infos[$info] ?? '');
5010 5010
 }
5011 5011
 
5012 5012
 /**
@@ -5021,11 +5021,11 @@  discard block
 block discarded – undo
5021 5021
  *     Texte traduit du comptage, tel que '3 articles'
5022 5022
  */
5023 5023
 function objet_afficher_nb($nb, $objet) {
5024
-	if (!$nb) {
5025
-		return _T(objet_info($objet, 'info_aucun_objet'));
5026
-	} else {
5027
-		return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), ['nb' => $nb]);
5028
-	}
5024
+    if (!$nb) {
5025
+        return _T(objet_info($objet, 'info_aucun_objet'));
5026
+    } else {
5027
+        return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), ['nb' => $nb]);
5028
+    }
5029 5029
 }
5030 5030
 
5031 5031
 /**
@@ -5037,11 +5037,11 @@  discard block
 block discarded – undo
5037 5037
  * @return string
5038 5038
  */
5039 5039
 function objet_icone($objet, $taille = 24, $class = '') {
5040
-	$icone = objet_info($objet, 'icone_objet') . '-' . $taille . '.png';
5041
-	$icone = chemin_image($icone);
5042
-	$balise_img = charger_filtre('balise_img');
5040
+    $icone = objet_info($objet, 'icone_objet') . '-' . $taille . '.png';
5041
+    $icone = chemin_image($icone);
5042
+    $balise_img = charger_filtre('balise_img');
5043 5043
 
5044
-	return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : '';
5044
+    return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : '';
5045 5045
 }
5046 5046
 
5047 5047
 /**
@@ -5062,12 +5062,12 @@  discard block
 block discarded – undo
5062 5062
  * @return string
5063 5063
  */
5064 5064
 function objet_T($objet, $chaine, $args = [], $options = []) {
5065
-	$chaine = explode(':', $chaine);
5066
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, ['force' => false]))) {
5067
-		return $t;
5068
-	}
5069
-	$chaine = implode(':', $chaine);
5070
-	return _T($chaine, $args, $options);
5065
+    $chaine = explode(':', $chaine);
5066
+    if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, ['force' => false]))) {
5067
+        return $t;
5068
+    }
5069
+    $chaine = implode(':', $chaine);
5070
+    return _T($chaine, $args, $options);
5071 5071
 }
5072 5072
 
5073 5073
 /**
@@ -5081,18 +5081,18 @@  discard block
 block discarded – undo
5081 5081
  * @return string      Code HTML
5082 5082
  */
5083 5083
 function insert_head_css_conditionnel($flux) {
5084
-	if (
5085
-		strpos($flux, '<!-- insert_head_css -->') === false
5086
-		and $p = strpos($flux, '<!-- insert_head -->')
5087
-	) {
5088
-		// plutot avant le premier js externe (jquery) pour etre non bloquant
5089
-		if ($p1 = stripos($flux, '<script src=') and $p1 < $p) {
5090
-			$p = $p1;
5091
-		}
5092
-		$flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
5093
-	}
5084
+    if (
5085
+        strpos($flux, '<!-- insert_head_css -->') === false
5086
+        and $p = strpos($flux, '<!-- insert_head -->')
5087
+    ) {
5088
+        // plutot avant le premier js externe (jquery) pour etre non bloquant
5089
+        if ($p1 = stripos($flux, '<script src=') and $p1 < $p) {
5090
+            $p = $p1;
5091
+        }
5092
+        $flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
5093
+    }
5094 5094
 
5095
-	return $flux;
5095
+    return $flux;
5096 5096
 }
5097 5097
 
5098 5098
 /**
@@ -5115,75 +5115,75 @@  discard block
 block discarded – undo
5115 5115
  * @return string
5116 5116
  */
5117 5117
 function produire_fond_statique($fond, $contexte = [], $options = [], string $connect = '') {
5118
-	if (isset($contexte['format'])) {
5119
-		$extension = $contexte['format'];
5120
-		unset($contexte['format']);
5121
-	} else {
5122
-		$extension = 'html';
5123
-		if (preg_match(',[.](css|js|json|xml|svg)$,', $fond, $m)) {
5124
-			$extension = $m[1];
5125
-		}
5126
-	}
5127
-	// recuperer le contenu produit par le squelette
5128
-	$options['raw'] = true;
5129
-	$cache = recuperer_fond($fond, $contexte, $options, $connect);
5130
-
5131
-	// calculer le nom de la css
5132
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
5133
-	$nom_safe = preg_replace(',\W,', '_', str_replace('.', '_', $fond));
5134
-	$contexte_implicite = calculer_contexte_implicite();
5135
-
5136
-	// par defaut on hash selon les contextes qui sont a priori moins variables
5137
-	// mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
5138
-	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
5139
-	if (isset($options['hash_on_content']) and $options['hash_on_content']) {
5140
-		$hash = md5($contexte_implicite['host'] . '::' . $cache);
5141
-	}
5142
-	else {
5143
-		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
5144
-		ksort($contexte);
5145
-		$hash = md5($fond . json_encode($contexte_implicite, JSON_THROW_ON_ERROR) . json_encode($contexte, JSON_THROW_ON_ERROR) . $connect);
5146
-	}
5147
-	$filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
5148
-
5149
-	// mettre a jour le fichier si il n'existe pas
5150
-	// ou trop ancien
5151
-	// le dernier fichier produit est toujours suffixe par .last
5152
-	// et recopie sur le fichier cible uniquement si il change
5153
-	if (
5154
-		!file_exists($filename)
5155
-		or !file_exists($filename . '.last')
5156
-		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . '.last') < $cache['lastmodified'])
5157
-		or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
5158
-	) {
5159
-		$contenu = $cache['texte'];
5160
-		// passer les urls en absolu si c'est une css
5161
-		if ($extension == 'css') {
5162
-			$contenu = urls_absolues_css(
5163
-				$contenu,
5164
-				test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond)
5165
-			);
5166
-		}
5167
-
5168
-		$comment = '';
5169
-		// ne pas insérer de commentaire sur certains formats
5170
-		if (!in_array($extension, ['json', 'xml', 'svg'])) {
5171
-			$comment = "/* #PRODUIRE{fond=$fond";
5172
-			foreach ($contexte as $k => $v) {
5173
-				if (is_array($v)) {
5174
-					$v = var_export($v, true);
5175
-				}
5176
-				$comment .= ",$k=$v";
5177
-			}
5178
-			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
5179
-			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
5180
-			$comment .= "}\n   md5:" . md5($contenu) . " */\n";
5181
-		}
5182
-		// et ecrire le fichier si il change
5183
-		ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
5184
-	}
5185
-
5186
-	return timestamp($filename);
5118
+    if (isset($contexte['format'])) {
5119
+        $extension = $contexte['format'];
5120
+        unset($contexte['format']);
5121
+    } else {
5122
+        $extension = 'html';
5123
+        if (preg_match(',[.](css|js|json|xml|svg)$,', $fond, $m)) {
5124
+            $extension = $m[1];
5125
+        }
5126
+    }
5127
+    // recuperer le contenu produit par le squelette
5128
+    $options['raw'] = true;
5129
+    $cache = recuperer_fond($fond, $contexte, $options, $connect);
5130
+
5131
+    // calculer le nom de la css
5132
+    $dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
5133
+    $nom_safe = preg_replace(',\W,', '_', str_replace('.', '_', $fond));
5134
+    $contexte_implicite = calculer_contexte_implicite();
5135
+
5136
+    // par defaut on hash selon les contextes qui sont a priori moins variables
5137
+    // mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
5138
+    // reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
5139
+    if (isset($options['hash_on_content']) and $options['hash_on_content']) {
5140
+        $hash = md5($contexte_implicite['host'] . '::' . $cache);
5141
+    }
5142
+    else {
5143
+        unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
5144
+        ksort($contexte);
5145
+        $hash = md5($fond . json_encode($contexte_implicite, JSON_THROW_ON_ERROR) . json_encode($contexte, JSON_THROW_ON_ERROR) . $connect);
5146
+    }
5147
+    $filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
5148
+
5149
+    // mettre a jour le fichier si il n'existe pas
5150
+    // ou trop ancien
5151
+    // le dernier fichier produit est toujours suffixe par .last
5152
+    // et recopie sur le fichier cible uniquement si il change
5153
+    if (
5154
+        !file_exists($filename)
5155
+        or !file_exists($filename . '.last')
5156
+        or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . '.last') < $cache['lastmodified'])
5157
+        or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
5158
+    ) {
5159
+        $contenu = $cache['texte'];
5160
+        // passer les urls en absolu si c'est une css
5161
+        if ($extension == 'css') {
5162
+            $contenu = urls_absolues_css(
5163
+                $contenu,
5164
+                test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond)
5165
+            );
5166
+        }
5167
+
5168
+        $comment = '';
5169
+        // ne pas insérer de commentaire sur certains formats
5170
+        if (!in_array($extension, ['json', 'xml', 'svg'])) {
5171
+            $comment = "/* #PRODUIRE{fond=$fond";
5172
+            foreach ($contexte as $k => $v) {
5173
+                if (is_array($v)) {
5174
+                    $v = var_export($v, true);
5175
+                }
5176
+                $comment .= ",$k=$v";
5177
+            }
5178
+            // pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
5179
+            // mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
5180
+            $comment .= "}\n   md5:" . md5($contenu) . " */\n";
5181
+        }
5182
+        // et ecrire le fichier si il change
5183
+        ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
5184
+    }
5185
+
5186
+    return timestamp($filename);
5187 5187
 }
5188 5188
 
5189 5189
 /**
@@ -5196,15 +5196,15 @@  discard block
 block discarded – undo
5196 5196
  *    $fichier auquel on a ajouté le timestamp
5197 5197
  */
5198 5198
 function timestamp($fichier) {
5199
-	if (
5200
-		!$fichier
5201
-		or !file_exists($fichier)
5202
-		or !$m = filemtime($fichier)
5203
-	) {
5204
-		return $fichier;
5205
-	}
5199
+    if (
5200
+        !$fichier
5201
+        or !file_exists($fichier)
5202
+        or !$m = filemtime($fichier)
5203
+    ) {
5204
+        return $fichier;
5205
+    }
5206 5206
 
5207
-	return "$fichier?$m";
5207
+    return "$fichier?$m";
5208 5208
 }
5209 5209
 
5210 5210
 /**
@@ -5214,11 +5214,11 @@  discard block
 block discarded – undo
5214 5214
  * @return string
5215 5215
  */
5216 5216
 function supprimer_timestamp($url) {
5217
-	if (strpos($url, '?') === false) {
5218
-		return $url;
5219
-	}
5217
+    if (strpos($url, '?') === false) {
5218
+        return $url;
5219
+    }
5220 5220
 
5221
-	return preg_replace(',\?[[:digit:]]+$,', '', $url);
5221
+    return preg_replace(',\?[[:digit:]]+$,', '', $url);
5222 5222
 }
5223 5223
 
5224 5224
 /**
@@ -5233,15 +5233,15 @@  discard block
 block discarded – undo
5233 5233
  * @return string
5234 5234
  */
5235 5235
 function filtre_nettoyer_titre_email_dist($titre) {
5236
-	include_spip('inc/envoyer_mail');
5236
+    include_spip('inc/envoyer_mail');
5237 5237
 
5238
-	$titre = nettoyer_titre_email($titre);
5239
-	// on est dans un squelette : securiser le retour
5240
-	if (strpos($titre, '<') !== false) {
5241
-		$titre = interdire_scripts($titre);
5242
-	}
5238
+    $titre = nettoyer_titre_email($titre);
5239
+    // on est dans un squelette : securiser le retour
5240
+    if (strpos($titre, '<') !== false) {
5241
+        $titre = interdire_scripts($titre);
5242
+    }
5243 5243
 
5244
-	return $titre;
5244
+    return $titre;
5245 5245
 }
5246 5246
 
5247 5247
 /**
@@ -5263,27 +5263,27 @@  discard block
 block discarded – undo
5263 5263
  * @return string
5264 5264
  */
5265 5265
 function filtre_chercher_rubrique_dist(
5266
-	$titre,
5267
-	$id_objet,
5268
-	$id_parent,
5269
-	$objet,
5270
-	$id_secteur,
5271
-	$restreint,
5272
-	$actionable = false,
5273
-	$retour_sans_cadre = false
5266
+    $titre,
5267
+    $id_objet,
5268
+    $id_parent,
5269
+    $objet,
5270
+    $id_secteur,
5271
+    $restreint,
5272
+    $actionable = false,
5273
+    $retour_sans_cadre = false
5274 5274
 ) {
5275
-	include_spip('inc/filtres_ecrire');
5275
+    include_spip('inc/filtres_ecrire');
5276 5276
 
5277
-	return chercher_rubrique(
5278
-		$titre,
5279
-		$id_objet,
5280
-		$id_parent,
5281
-		$objet,
5282
-		$id_secteur,
5283
-		$restreint,
5284
-		$actionable,
5285
-		$retour_sans_cadre
5286
-	);
5277
+    return chercher_rubrique(
5278
+        $titre,
5279
+        $id_objet,
5280
+        $id_parent,
5281
+        $objet,
5282
+        $id_secteur,
5283
+        $restreint,
5284
+        $actionable,
5285
+        $retour_sans_cadre
5286
+    );
5287 5287
 }
5288 5288
 
5289 5289
 /**
@@ -5312,56 +5312,56 @@  discard block
 block discarded – undo
5312 5312
  *     Chaîne vide si l'accès est autorisé
5313 5313
  */
5314 5314
 function sinon_interdire_acces($ok = false, $url = '', $statut = 0, $message = null) {
5315
-	if ($ok) {
5316
-		return '';
5317
-	}
5318
-
5319
-	// Vider tous les tampons
5320
-	$level = @ob_get_level();
5321
-	while ($level--) {
5322
-		@ob_end_clean();
5323
-	}
5324
-
5325
-	include_spip('inc/headers');
5326
-
5327
-	// S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
5328
-	if ($url) {
5329
-		redirige_par_entete($url, '', $statut);
5330
-	}
5331
-
5332
-	// ecriture simplifiee avec message en 3eme argument (= statut 403)
5333
-	if (!is_numeric($statut) and is_null($message)) {
5334
-		$message = $statut;
5335
-		$statut = 0;
5336
-	}
5337
-	if (!$message) {
5338
-		$message = '';
5339
-	}
5340
-	$statut = intval($statut);
5341
-
5342
-	// Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
5343
-	if (test_espace_prive()) {
5344
-		if (!$statut or !in_array($statut, [404, 403])) {
5345
-			$statut = 403;
5346
-		}
5347
-		http_response_code(403);
5348
-		$echec = charger_fonction('403', 'exec');
5349
-		$echec($message);
5350
-	} else {
5351
-		// Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
5352
-		if (!$statut) {
5353
-			$statut = 404;
5354
-		}
5355
-		// Dans tous les cas on modifie l'entité avec ce qui est demandé
5356
-		http_response_code($statut);
5357
-		// Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
5358
-		if ($statut >= 400) {
5359
-			echo recuperer_fond("$statut", ['erreur' => $message]);
5360
-		}
5361
-	}
5362
-
5363
-
5364
-	exit;
5315
+    if ($ok) {
5316
+        return '';
5317
+    }
5318
+
5319
+    // Vider tous les tampons
5320
+    $level = @ob_get_level();
5321
+    while ($level--) {
5322
+        @ob_end_clean();
5323
+    }
5324
+
5325
+    include_spip('inc/headers');
5326
+
5327
+    // S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
5328
+    if ($url) {
5329
+        redirige_par_entete($url, '', $statut);
5330
+    }
5331
+
5332
+    // ecriture simplifiee avec message en 3eme argument (= statut 403)
5333
+    if (!is_numeric($statut) and is_null($message)) {
5334
+        $message = $statut;
5335
+        $statut = 0;
5336
+    }
5337
+    if (!$message) {
5338
+        $message = '';
5339
+    }
5340
+    $statut = intval($statut);
5341
+
5342
+    // Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
5343
+    if (test_espace_prive()) {
5344
+        if (!$statut or !in_array($statut, [404, 403])) {
5345
+            $statut = 403;
5346
+        }
5347
+        http_response_code(403);
5348
+        $echec = charger_fonction('403', 'exec');
5349
+        $echec($message);
5350
+    } else {
5351
+        // Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
5352
+        if (!$statut) {
5353
+            $statut = 404;
5354
+        }
5355
+        // Dans tous les cas on modifie l'entité avec ce qui est demandé
5356
+        http_response_code($statut);
5357
+        // Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
5358
+        if ($statut >= 400) {
5359
+            echo recuperer_fond("$statut", ['erreur' => $message]);
5360
+        }
5361
+    }
5362
+
5363
+
5364
+    exit;
5365 5365
 }
5366 5366
 
5367 5367
 /**
@@ -5372,11 +5372,11 @@  discard block
 block discarded – undo
5372 5372
  * @return string
5373 5373
  */
5374 5374
 function filtre_compacte_dist($source, $format = null) {
5375
-	if (function_exists('minifier')) {
5376
-		return minifier($source, $format);
5377
-	}
5375
+    if (function_exists('minifier')) {
5376
+        return minifier($source, $format);
5377
+    }
5378 5378
 
5379
-	return $source;
5379
+    return $source;
5380 5380
 }
5381 5381
 
5382 5382
 
@@ -5388,32 +5388,32 @@  discard block
 block discarded – undo
5388 5388
  * @return string
5389 5389
  */
5390 5390
 function spip_affiche_mot_de_passe_masque(?string $passe, bool $afficher_partiellement = false, ?int $portion_pourcent = null): string {
5391
-	$passe ??= '';
5392
-	$l = strlen($passe);
5393
-
5394
-	if ($l <= 8 or !$afficher_partiellement) {
5395
-		if (!$l) {
5396
-			return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
5397
-		}
5398
-		return str_pad('', $afficher_partiellement ? $l : 16, '*');
5399
-	}
5400
-
5401
-	if (is_null($portion_pourcent)) {
5402
-		if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) {
5403
-			define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20%
5404
-		}
5405
-		$portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT;
5406
-	}
5407
-	if ($portion_pourcent >= 100) {
5408
-		return $passe;
5409
-	}
5410
-	$e = intval(ceil($l * $portion_pourcent / 100 / 2));
5411
-	$e = max($e, 0);
5412
-	$mid = str_pad('', $l - 2 * $e, '*');
5413
-	if ($e > 0 and strlen($mid) > 8) {
5414
-		$mid = '***...***';
5415
-	}
5416
-	return substr($passe, 0, $e) . $mid . ($e > 0 ? substr($passe, -$e) : '');
5391
+    $passe ??= '';
5392
+    $l = strlen($passe);
5393
+
5394
+    if ($l <= 8 or !$afficher_partiellement) {
5395
+        if (!$l) {
5396
+            return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
5397
+        }
5398
+        return str_pad('', $afficher_partiellement ? $l : 16, '*');
5399
+    }
5400
+
5401
+    if (is_null($portion_pourcent)) {
5402
+        if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) {
5403
+            define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20%
5404
+        }
5405
+        $portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT;
5406
+    }
5407
+    if ($portion_pourcent >= 100) {
5408
+        return $passe;
5409
+    }
5410
+    $e = intval(ceil($l * $portion_pourcent / 100 / 2));
5411
+    $e = max($e, 0);
5412
+    $mid = str_pad('', $l - 2 * $e, '*');
5413
+    if ($e > 0 and strlen($mid) > 8) {
5414
+        $mid = '***...***';
5415
+    }
5416
+    return substr($passe, 0, $e) . $mid . ($e > 0 ? substr($passe, -$e) : '');
5417 5417
 }
5418 5418
 
5419 5419
 
@@ -5434,64 +5434,64 @@  discard block
 block discarded – undo
5434 5434
  */
5435 5435
 function identifiant_slug($texte, $type = '', $options = []) {
5436 5436
 
5437
-	$original = $texte;
5438
-	$separateur = ($options['separateur'] ?? '_');
5439
-	$longueur_maxi = ($options['longueur_maxi'] ?? 60);
5440
-	$longueur_mini = ($options['longueur_mini'] ?? 0);
5437
+    $original = $texte;
5438
+    $separateur = ($options['separateur'] ?? '_');
5439
+    $longueur_maxi = ($options['longueur_maxi'] ?? 60);
5440
+    $longueur_mini = ($options['longueur_mini'] ?? 0);
5441 5441
 
5442
-	if (!function_exists('translitteration')) {
5443
-		include_spip('inc/charsets');
5444
-	}
5442
+    if (!function_exists('translitteration')) {
5443
+        include_spip('inc/charsets');
5444
+    }
5445 5445
 
5446
-	// pas de balise html
5447
-	if (strpos($texte, '<') !== false) {
5448
-		$texte = strip_tags($texte);
5449
-	}
5450
-	if (strpos($texte, '&') !== false) {
5451
-		$texte = unicode2charset($texte);
5452
-	}
5453
-	// On enlève les espaces indésirables
5454
-	$texte = trim($texte);
5446
+    // pas de balise html
5447
+    if (strpos($texte, '<') !== false) {
5448
+        $texte = strip_tags($texte);
5449
+    }
5450
+    if (strpos($texte, '&') !== false) {
5451
+        $texte = unicode2charset($texte);
5452
+    }
5453
+    // On enlève les espaces indésirables
5454
+    $texte = trim($texte);
5455 5455
 
5456
-	// On enlève les accents et cie
5457
-	$texte = translitteration($texte);
5456
+    // On enlève les accents et cie
5457
+    $texte = translitteration($texte);
5458 5458
 
5459
-	// On remplace tout ce qui n'est pas un mot par un séparateur
5460
-	$texte = preg_replace(',[\W_]+,ms', $separateur, $texte);
5459
+    // On remplace tout ce qui n'est pas un mot par un séparateur
5460
+    $texte = preg_replace(',[\W_]+,ms', $separateur, $texte);
5461 5461
 
5462
-	// nettoyer les doubles occurences du separateur si besoin
5463
-	while (strpos($texte, (string) "$separateur$separateur") !== false) {
5464
-		$texte = str_replace("$separateur$separateur", $separateur, $texte);
5465
-	}
5462
+    // nettoyer les doubles occurences du separateur si besoin
5463
+    while (strpos($texte, (string) "$separateur$separateur") !== false) {
5464
+        $texte = str_replace("$separateur$separateur", $separateur, $texte);
5465
+    }
5466 5466
 
5467
-	// pas de separateur au debut ni a la fin
5468
-	$texte = trim($texte, $separateur);
5467
+    // pas de separateur au debut ni a la fin
5468
+    $texte = trim($texte, $separateur);
5469 5469
 
5470
-	// en minuscules
5471
-	$texte = strtolower($texte);
5470
+    // en minuscules
5471
+    $texte = strtolower($texte);
5472 5472
 
5473
-	switch ($type) {
5474
-		case 'class':
5475
-		case 'id':
5476
-		case 'anchor':
5477
-			if (preg_match(',^\d,', $texte)) {
5478
-				$texte = substr($type, 0, 1) . $texte;
5479
-			}
5480
-	}
5473
+    switch ($type) {
5474
+        case 'class':
5475
+        case 'id':
5476
+        case 'anchor':
5477
+            if (preg_match(',^\d,', $texte)) {
5478
+                $texte = substr($type, 0, 1) . $texte;
5479
+            }
5480
+    }
5481 5481
 
5482
-	if (strlen($texte) > $longueur_maxi) {
5483
-		$texte = substr($texte, 0, $longueur_maxi);
5484
-	}
5482
+    if (strlen($texte) > $longueur_maxi) {
5483
+        $texte = substr($texte, 0, $longueur_maxi);
5484
+    }
5485 5485
 
5486
-	if (strlen($texte) < $longueur_mini and $longueur_mini < $longueur_maxi) {
5487
-		if (preg_match(',^\d,', $texte)) {
5488
-			$texte = ($type ? substr($type, 0, 1) : 's') . $texte;
5489
-		}
5490
-		$texte .= $separateur . md5($original);
5491
-		$texte = substr($texte, 0, $longueur_mini);
5492
-	}
5486
+    if (strlen($texte) < $longueur_mini and $longueur_mini < $longueur_maxi) {
5487
+        if (preg_match(',^\d,', $texte)) {
5488
+            $texte = ($type ? substr($type, 0, 1) : 's') . $texte;
5489
+        }
5490
+        $texte .= $separateur . md5($original);
5491
+        $texte = substr($texte, 0, $longueur_mini);
5492
+    }
5493 5493
 
5494
-	return $texte;
5494
+    return $texte;
5495 5495
 }
5496 5496
 
5497 5497
 
@@ -5512,11 +5512,11 @@  discard block
 block discarded – undo
5512 5512
  * @exemple `<:info_maximum|label_nettoyer:>`
5513 5513
  */
5514 5514
 function label_nettoyer(string $text, bool $ucfirst = true): string {
5515
-	$label = preg_replace('#([\s:]|\&nbsp;)+$#u', '', $text);
5516
-	if ($ucfirst) {
5517
-		$label = spip_ucfirst($label);
5518
-	}
5519
-	return $label;
5515
+    $label = preg_replace('#([\s:]|\&nbsp;)+$#u', '', $text);
5516
+    if ($ucfirst) {
5517
+        $label = spip_ucfirst($label);
5518
+    }
5519
+    return $label;
5520 5520
 }
5521 5521
 
5522 5522
 /**
@@ -5529,8 +5529,8 @@  discard block
 block discarded – undo
5529 5529
  * @exemple `<:info_maximum|label_ponctuer:>`
5530 5530
  */
5531 5531
 function label_ponctuer(string $text, bool $ucfirst = true): string {
5532
-	$label = label_nettoyer($text, $ucfirst);
5533
-	return _T('label_ponctuer', ['label' => $label]);
5532
+    $label = label_nettoyer($text, $ucfirst);
5533
+    return _T('label_ponctuer', ['label' => $label]);
5534 5534
 }
5535 5535
 
5536 5536
 
@@ -5543,19 +5543,19 @@  discard block
 block discarded – undo
5543 5543
  * @return array
5544 5544
  */
5545 5545
 function helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, $fonction) {
5546
-	if (!in_array($fonction, ['objet_lister_parents', 'objet_lister_enfants', 'objet_lister_parents_par_type', 'objet_lister_enfants_par_type'])) {
5547
-		return [];
5548
-	}
5546
+    if (!in_array($fonction, ['objet_lister_parents', 'objet_lister_enfants', 'objet_lister_parents_par_type', 'objet_lister_enfants_par_type'])) {
5547
+        return [];
5548
+    }
5549 5549
 
5550
-	// compatibilite signature inversee
5551
-	if (is_numeric($objet) and !is_numeric($id_objet)) {
5552
-		[$objet, $id_objet] = [$id_objet, $objet];
5553
-	}
5550
+    // compatibilite signature inversee
5551
+    if (is_numeric($objet) and !is_numeric($id_objet)) {
5552
+        [$objet, $id_objet] = [$id_objet, $objet];
5553
+    }
5554 5554
 
5555
-	if (!function_exists($fonction)) {
5556
-		include_spip('base/objets');
5557
-	}
5558
-	return $fonction($objet, $id_objet);
5555
+    if (!function_exists($fonction)) {
5556
+        include_spip('base/objets');
5557
+    }
5558
+    return $fonction($objet, $id_objet);
5559 5559
 }
5560 5560
 
5561 5561
 
@@ -5570,7 +5570,7 @@  discard block
 block discarded – undo
5570 5570
  * @return array
5571 5571
  */
5572 5572
 function filtre_objet_lister_parents_dist($objet, $id_objet) {
5573
-	return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents');
5573
+    return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents');
5574 5574
 }
5575 5575
 
5576 5576
 /**
@@ -5584,7 +5584,7 @@  discard block
 block discarded – undo
5584 5584
  * @return array
5585 5585
  */
5586 5586
 function filtre_objet_lister_parents_par_type_dist($objet, $id_objet) {
5587
-	return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents_par_type');
5587
+    return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents_par_type');
5588 5588
 }
5589 5589
 
5590 5590
 /**
@@ -5598,7 +5598,7 @@  discard block
 block discarded – undo
5598 5598
  * @return array
5599 5599
  */
5600 5600
 function filtre_objet_lister_enfants_dist($objet, $id_objet) {
5601
-	return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants');
5601
+    return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants');
5602 5602
 }
5603 5603
 
5604 5604
 /**
@@ -5612,5 +5612,5 @@  discard block
 block discarded – undo
5612 5612
  * @return array
5613 5613
  */
5614 5614
 function filtre_objet_lister_enfants_par_type_dist($objet, $id_objet) {
5615
-	return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants_par_type');
5615
+    return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants_par_type');
5616 5616
 }
Please login to merge, or discard this patch.
Spacing   +125 added lines, -126 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
 		if (is_callable($f)) {
102 102
 			return $f;
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 	// affichage "GIT [master: abcdef]"
235 235
 	$commit = $desc['commit_short'] ?? $desc['commit'];
236 236
 	if ($desc['branch']) {
237
-		$commit = $desc['branch'] . ': ' . $commit;
237
+		$commit = $desc['branch'].': '.$commit;
238 238
 	}
239 239
 	return "{$desc['vcs']} [$commit]";
240 240
 }
@@ -253,9 +253,9 @@  discard block
 block discarded – undo
253 253
 	}
254 254
 
255 255
 	// version installee par GIT
256
-	if (lire_fichier($dir . '/.git/HEAD', $c)) {
256
+	if (lire_fichier($dir.'/.git/HEAD', $c)) {
257 257
 		$currentHead = trim(substr($c, 4));
258
-		if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
258
+		if (lire_fichier($dir.'/.git/'.$currentHead, $hash)) {
259 259
 			return [
260 260
 				'vcs' => 'GIT',
261 261
 				'branch' => basename($currentHead),
@@ -282,8 +282,8 @@  discard block
 block discarded – undo
282 282
 		$dir = '.';
283 283
 	}
284 284
 	// version installee par SVN
285
-	if (file_exists($dir . '/.svn/wc.db') && class_exists(\SQLite3::class)) {
286
-		$db = new SQLite3($dir . '/.svn/wc.db');
285
+	if (file_exists($dir.'/.svn/wc.db') && class_exists(\SQLite3::class)) {
286
+		$db = new SQLite3($dir.'/.svn/wc.db');
287 287
 		$result = $db->query('SELECT changed_revision FROM nodes WHERE local_relpath = "" LIMIT 1');
288 288
 		if ($result) {
289 289
 			$row = $result->fetchArray();
@@ -301,12 +301,12 @@  discard block
 block discarded – undo
301 301
 
302 302
 // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images
303 303
 // et laisser passer les fonctions personnelles baptisees image_...
304
-$GLOBALS['spip_matrice']['image_graver'] = true;//'inc/filtres_images_mini.php';
305
-$GLOBALS['spip_matrice']['image_select'] = true;//'inc/filtres_images_mini.php';
306
-$GLOBALS['spip_matrice']['image_reduire'] = true;//'inc/filtres_images_mini.php';
307
-$GLOBALS['spip_matrice']['image_reduire_par'] = true;//'inc/filtres_images_mini.php';
308
-$GLOBALS['spip_matrice']['image_passe_partout'] = true;//'inc/filtres_images_mini.php';
309
-$GLOBALS['spip_matrice']['image_recadre_avec_fallback'] = true;//'inc/filtres_images_mini.php';
304
+$GLOBALS['spip_matrice']['image_graver'] = true; //'inc/filtres_images_mini.php';
305
+$GLOBALS['spip_matrice']['image_select'] = true; //'inc/filtres_images_mini.php';
306
+$GLOBALS['spip_matrice']['image_reduire'] = true; //'inc/filtres_images_mini.php';
307
+$GLOBALS['spip_matrice']['image_reduire_par'] = true; //'inc/filtres_images_mini.php';
308
+$GLOBALS['spip_matrice']['image_passe_partout'] = true; //'inc/filtres_images_mini.php';
309
+$GLOBALS['spip_matrice']['image_recadre_avec_fallback'] = true; //'inc/filtres_images_mini.php';
310 310
 
311 311
 $GLOBALS['spip_matrice']['couleur_html_to_hex'] = 'inc/filtres_images_mini.php';
312 312
 $GLOBALS['spip_matrice']['couleur_hex_to_hsl'] = 'inc/filtres_images_mini.php';
@@ -465,8 +465,8 @@  discard block
 block discarded – undo
465 465
  */
466 466
 function filtre_debug($val, $key = null) {
467 467
 	$debug = (
468
-		is_null($key) ? '' : (var_export($key, true) . ' = ')
469
-		) . var_export($val, true);
468
+		is_null($key) ? '' : (var_export($key, true).' = ')
469
+		).var_export($val, true);
470 470
 
471 471
 	include_spip('inc/autoriser');
472 472
 	if (autoriser('webmestre')) {
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 		$is_file = false;
523 523
 	}
524 524
 	if ($is_file) {
525
-		$is_local_file = function ($path) {
525
+		$is_local_file = function($path) {
526 526
 			if (strpos($path, '?') !== false) {
527 527
 				$path = supprimer_timestamp($path);
528 528
 				// remove ?24px added by find_in_theme on .svg files
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
 					if ($mouseover = extraire_attribut($reduit, 'onmouseover')) {
572 572
 						if (preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)) {
573 573
 							$srcover = $match[1];
574
-							$srcover_filter = $filtre("<img src='" . $match[1] . "' />", ...$args);
574
+							$srcover_filter = $filtre("<img src='".$match[1]."' />", ...$args);
575 575
 							$srcover_filter = extraire_attribut($srcover_filter, 'src');
576 576
 							$reduit = str_replace($srcover, $srcover_filter, $reduit);
577 577
 						}
@@ -973,7 +973,7 @@  discard block
 block discarded – undo
973 973
 	// " -> &quot; et tout ce genre de choses
974 974
 	$u = $GLOBALS['meta']['pcre_u'];
975 975
 	$texte = str_replace('&nbsp;', ' ', $texte);
976
-	$texte = preg_replace('/\s{2,}/S' . $u, ' ', $texte);
976
+	$texte = preg_replace('/\s{2,}/S'.$u, ' ', $texte);
977 977
 	// ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
978 978
 	$texte = entites_html($texte, false, false);
979 979
 	// mais bien echapper les double quotes !
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
 		return '';
1036 1036
 	}
1037 1037
 	return preg_replace(
1038
-		',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1038
+		',^[[:space:]]*([0-9]+)([.)]|'.chr(194).'?'.chr(176).')[[:space:]]+,S',
1039 1039
 		'',
1040 1040
 		$texte
1041 1041
 	);
@@ -1064,7 +1064,7 @@  discard block
 block discarded – undo
1064 1064
 	if (
1065 1065
 		$texte and
1066 1066
 		preg_match(
1067
-			',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1067
+			',^[[:space:]]*([0-9]+)([.)]|'.chr(194).'?'.chr(176).')[[:space:]]+,S',
1068 1068
 			$texte,
1069 1069
 			$regs
1070 1070
 		)
@@ -1155,8 +1155,8 @@  discard block
 block discarded – undo
1155 1155
  **/
1156 1156
 function textebrut($texte) {
1157 1157
 	$u = $GLOBALS['meta']['pcre_u'];
1158
-	$texte = preg_replace('/\s+/S' . $u, ' ', $texte);
1159
-	$texte = preg_replace('/<(p|br)( [^>]*)?' . '>/iS', "\n\n", $texte);
1158
+	$texte = preg_replace('/\s+/S'.$u, ' ', $texte);
1159
+	$texte = preg_replace('/<(p|br)( [^>]*)?'.'>/iS', "\n\n", $texte);
1160 1160
 	$texte = preg_replace("/^\n+/", '', $texte);
1161 1161
 	$texte = preg_replace("/\n+$/", '', $texte);
1162 1162
 	$texte = preg_replace("/\n +/", "\n", $texte);
@@ -1190,7 +1190,7 @@  discard block
 block discarded – undo
1190 1190
 		)
1191 1191
 	) {
1192 1192
 		foreach ($liens[0] as $a) {
1193
-			$rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1193
+			$rel = 'noopener noreferrer '.extraire_attribut($a, 'rel');
1194 1194
 			$ablank = inserer_attribut($a, 'rel', $rel);
1195 1195
 			$ablank = inserer_attribut($ablank, 'target', '_blank');
1196 1196
 			$texte = str_replace($a, $ablank, $texte);
@@ -1215,7 +1215,7 @@  discard block
 block discarded – undo
1215 1215
 		foreach ($regs[0] as $a) {
1216 1216
 			$rel = extraire_attribut($a, 'rel') ?? '';
1217 1217
 			if (strpos($rel, 'nofollow') === false) {
1218
-				$rel = 'nofollow' . ($rel ? " $rel" : '');
1218
+				$rel = 'nofollow'.($rel ? " $rel" : '');
1219 1219
 				$anofollow = inserer_attribut($a, 'rel', $rel);
1220 1220
 				$texte = str_replace($a, $anofollow, $texte);
1221 1221
 			}
@@ -1244,7 +1244,7 @@  discard block
 block discarded – undo
1244 1244
 	$u = $GLOBALS['meta']['pcre_u'];
1245 1245
 	$texte = preg_replace('@</p>@iS', "\n", $texte);
1246 1246
 	$texte = preg_replace("@<p\b.*>@UiS", '<br />', $texte);
1247
-	$texte = preg_replace('@^\s*<br />@S' . $u, '', $texte);
1247
+	$texte = preg_replace('@^\s*<br />@S'.$u, '', $texte);
1248 1248
 
1249 1249
 	return $texte;
1250 1250
 }
@@ -1275,7 +1275,7 @@  discard block
 block discarded – undo
1275 1275
 		return $texte;
1276 1276
 	}
1277 1277
 	include_spip('inc/texte');
1278
-	$tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1278
+	$tag = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $texte) ?
1279 1279
 		'div' : 'span';
1280 1280
 
1281 1281
 	return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
@@ -1387,7 +1387,7 @@  discard block
 block discarded – undo
1387 1387
 	}
1388 1388
 	$u = $GLOBALS['meta']['pcre_u'];
1389 1389
 	if ($textebrut) {
1390
-		$texte = preg_replace([",\n,", ',\s(?=\s),msS' . $u], [' ', ''], textebrut($texte));
1390
+		$texte = preg_replace([",\n,", ',\s(?=\s),msS'.$u], [' ', ''], textebrut($texte));
1391 1391
 	}
1392 1392
 	$texte = texte_backend($texte);
1393 1393
 	$texte = str_replace(["'", '"'], ['&#039;', '&#034;'], $texte);
@@ -1422,7 +1422,7 @@  discard block
 block discarded – undo
1422 1422
 	# un message pour abs_url
1423 1423
 	$GLOBALS['mode_abs_url'] = 'url';
1424 1424
 	$url = trim($url);
1425
-	$r = ',^(?:' . _PROTOCOLES_STD . '):?/?/?$,iS';
1425
+	$r = ',^(?:'._PROTOCOLES_STD.'):?/?/?$,iS';
1426 1426
 
1427 1427
 	return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1428 1428
 }
@@ -1629,7 +1629,7 @@  discard block
 block discarded – undo
1629 1629
 
1630 1630
 	$debut = '';
1631 1631
 	$suite = $texte;
1632
-	while ($t = strpos('-' . $suite, "\n", 1)) {
1632
+	while ($t = strpos('-'.$suite, "\n", 1)) {
1633 1633
 		$debut .= substr($suite, 0, $t - 1);
1634 1634
 		$suite = substr($suite, $t);
1635 1635
 		$car = substr($suite, 0, 1);
@@ -1647,7 +1647,7 @@  discard block
 block discarded – undo
1647 1647
 			$suite = substr($suite, strlen($regs[0]));
1648 1648
 		}
1649 1649
 	}
1650
-	$texte = $debut . $suite;
1650
+	$texte = $debut.$suite;
1651 1651
 
1652 1652
 	if ($collecteurModeles) {
1653 1653
 		$texte = $collecteurModeles->retablir($texte);
@@ -1655,7 +1655,7 @@  discard block
 block discarded – undo
1655 1655
 
1656 1656
 	$texte = echappe_retour($texte);
1657 1657
 
1658
-	return $texte . $fin;
1658
+	return $texte.$fin;
1659 1659
 }
1660 1660
 
1661 1661
 
@@ -1931,7 +1931,7 @@  discard block
 block discarded – undo
1931 1931
 	if (is_array($balise)) {
1932 1932
 		array_walk(
1933 1933
 			$balise,
1934
-			function (&$a, $key, $t) {
1934
+			function(&$a, $key, $t) {
1935 1935
 				$a = extraire_attribut($a, $t);
1936 1936
 			},
1937 1937
 			$attribut
@@ -2029,14 +2029,14 @@  discard block
 block discarded – undo
2029 2029
 
2030 2030
 	if ($old !== null) {
2031 2031
 		// Remplacer l'ancien attribut du meme nom
2032
-		$balise = $r[1] . $insert . $r[5];
2032
+		$balise = $r[1].$insert.$r[5];
2033 2033
 	} else {
2034 2034
 		// preferer une balise " />" (comme <img />)
2035 2035
 		if (preg_match(',/>,', $balise)) {
2036
-			$balise = preg_replace(',\s?/>,S', $insert . ' />', $balise, 1);
2036
+			$balise = preg_replace(',\s?/>,S', $insert.' />', $balise, 1);
2037 2037
 		} // sinon une balise <a ...> ... </a>
2038 2038
 		else {
2039
-			$balise = preg_replace(',\s?>,S', $insert . '>', $balise, 1);
2039
+			$balise = preg_replace(',\s?>,S', $insert.'>', $balise, 1);
2040 2040
 		}
2041 2041
 	}
2042 2042
 
@@ -2091,7 +2091,7 @@  discard block
 block discarded – undo
2091 2091
 		if (
2092 2092
 			$class_courante
2093 2093
 			and strpos($class_courante, (string) $c) !== false
2094
-			and preg_match('/(^|\s)' . preg_quote($c) . '($|\s)/', $class_courante)
2094
+			and preg_match('/(^|\s)'.preg_quote($c).'($|\s)/', $class_courante)
2095 2095
 		) {
2096 2096
 			$is_class_presente = true;
2097 2097
 		}
@@ -2099,12 +2099,12 @@  discard block
 block discarded – undo
2099 2099
 			in_array($operation, ['ajouter', 'commuter'])
2100 2100
 			and !$is_class_presente
2101 2101
 		) {
2102
-			$class_new = ltrim(rtrim($class_new ?? '') . ' ' . $c);
2102
+			$class_new = ltrim(rtrim($class_new ?? '').' '.$c);
2103 2103
 		} elseif (
2104 2104
 			in_array($operation, ['supprimer', 'commuter'])
2105 2105
 			and $is_class_presente
2106 2106
 		) {
2107
-			$class_new = trim(preg_replace('/(^|\s)' . preg_quote($c) . '($|\s)/', "\\1", $class_new));
2107
+			$class_new = trim(preg_replace('/(^|\s)'.preg_quote($c).'($|\s)/', "\\1", $class_new));
2108 2108
 		}
2109 2109
 	}
2110 2110
 
@@ -2167,7 +2167,7 @@  discard block
 block discarded – undo
2167 2167
 // Quelques fonctions de calcul arithmetique
2168 2168
 //
2169 2169
 function floatstr($a) {
2170
- return str_replace(',', '.', (string)floatval($a));
2170
+ return str_replace(',', '.', (string) floatval($a));
2171 2171
 }
2172 2172
 function strize($f, $a, $b) {
2173 2173
  return floatstr($f(floatstr($a), floatstr($b)));
@@ -2303,13 +2303,13 @@  discard block
 block discarded – undo
2303 2303
 	if (!defined('_TAGS_NOM_AUTEUR')) {
2304 2304
 		define('_TAGS_NOM_AUTEUR', '');
2305 2305
 	}
2306
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2306
+	$tags_acceptes = array_unique(explode(',', 'multi,'._TAGS_NOM_AUTEUR));
2307 2307
 	foreach ($tags_acceptes as $tag) {
2308 2308
 		if (strlen($tag)) {
2309
-			$remp1[] = '<' . trim($tag) . '>';
2310
-			$remp1[] = '</' . trim($tag) . '>';
2311
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2312
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2309
+			$remp1[] = '<'.trim($tag).'>';
2310
+			$remp1[] = '</'.trim($tag).'>';
2311
+			$remp2[] = '\x60'.trim($tag).'\x61';
2312
+			$remp2[] = '\x60/'.trim($tag).'\x61';
2313 2313
 		}
2314 2314
 	}
2315 2315
 	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
@@ -2429,10 +2429,10 @@  discard block
 block discarded – undo
2429 2429
 	$fichier = basename($url);
2430 2430
 
2431 2431
 	return '<a rel="enclosure"'
2432
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2433
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2434
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2435
-	. '>' . $fichier . '</a>';
2432
+	. ($url ? ' href="'.spip_htmlspecialchars($url).'"' : '')
2433
+	. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2434
+	. ($length ? ' title="'.spip_htmlspecialchars($length).'"' : '')
2435
+	. '>'.$fichier.'</a>';
2436 2436
 }
2437 2437
 
2438 2438
 /**
@@ -2460,9 +2460,9 @@  discard block
 block discarded – undo
2460 2460
 			} # vieux data
2461 2461
 			$fichier = basename($url);
2462 2462
 			$enclosures[] = '<enclosure'
2463
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2464
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2465
-				. ($length ? ' length="' . $length . '"' : '')
2463
+				. ($url ? ' url="'.spip_htmlspecialchars($url).'"' : '')
2464
+				. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2465
+				. ($length ? ' length="'.$length.'"' : '')
2466 2466
 				. ' />';
2467 2467
 		}
2468 2468
 	}
@@ -2488,7 +2488,7 @@  discard block
 block discarded – undo
2488 2488
 		if (extraire_attribut($e, 'rel') == 'tag') {
2489 2489
 			$subjects .= '<dc:subject>'
2490 2490
 				. texte_backend(textebrut($e))
2491
-				. '</dc:subject>' . "\n";
2491
+				. '</dc:subject>'."\n";
2492 2492
 		}
2493 2493
 	}
2494 2494
 
@@ -2524,7 +2524,7 @@  discard block
 block discarded – undo
2524 2524
 	if (is_array($texte)) {
2525 2525
 		array_walk(
2526 2526
 			$texte,
2527
-			function (&$a, $key, $t) {
2527
+			function(&$a, $key, $t) {
2528 2528
 				$a = extraire_balise($a, $t);
2529 2529
 			},
2530 2530
 			$tag
@@ -2572,7 +2572,7 @@  discard block
 block discarded – undo
2572 2572
 	if (is_array($texte)) {
2573 2573
 		array_walk(
2574 2574
 			$texte,
2575
-			function (&$a, $key, $t) {
2575
+			function(&$a, $key, $t) {
2576 2576
 				$a = extraire_balises($a, $t);
2577 2577
 			},
2578 2578
 			$tag
@@ -2705,7 +2705,7 @@  discard block
 block discarded – undo
2705 2705
 		if ($fond != '404') {
2706 2706
 			$contexte = array_shift($p);
2707 2707
 			$contexte['page'] = $fond;
2708
-			$action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2708
+			$action = preg_replace('/([?]'.preg_quote($fond).'[^&=]*[0-9]+)(&|$)/', '?&', $action);
2709 2709
 		}
2710 2710
 	}
2711 2711
 	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
@@ -2760,9 +2760,9 @@  discard block
 block discarded – undo
2760 2760
 			. '"'
2761 2761
 			. (is_null($val)
2762 2762
 				? ''
2763
-				: ' value="' . entites_html($val) . '"'
2763
+				: ' value="'.entites_html($val).'"'
2764 2764
 			)
2765
-			. ' type="hidden"' . "\n/>";
2765
+			. ' type="hidden"'."\n/>";
2766 2766
 	}
2767 2767
 
2768 2768
 	return join('', $hidden);
@@ -2872,7 +2872,7 @@  discard block
 block discarded – undo
2872 2872
 
2873 2873
 	return preg_replace_callback(
2874 2874
 		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2875
-		fn($x) => "url('" . suivre_lien($path, $x[1]) . "')",
2875
+		fn($x) => "url('".suivre_lien($path, $x[1])."')",
2876 2876
 		$contenu
2877 2877
 	);
2878 2878
 }
@@ -2933,14 +2933,14 @@  discard block
 block discarded – undo
2933 2933
 	) {
2934 2934
 		$distant = true;
2935 2935
 		$cssf = parse_url($css);
2936
-		$cssf = $cssf['path'] . ($cssf['query'] ? '?' . $cssf['query'] : '');
2936
+		$cssf = $cssf['path'].($cssf['query'] ? '?'.$cssf['query'] : '');
2937 2937
 		$cssf = preg_replace(',[?:&=],', '_', $cssf);
2938 2938
 	} else {
2939 2939
 		$distant = false;
2940 2940
 		$cssf = $css;
2941 2941
 		// 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2942 2942
 		//propose (rien a faire dans ce cas)
2943
-		$f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2943
+		$f = preg_replace(',(_rtl)?\.css$,i', '_'.$ndir.'.css', $css);
2944 2944
 		if (@file_exists($f)) {
2945 2945
 			return $f;
2946 2946
 		}
@@ -2950,7 +2950,7 @@  discard block
 block discarded – undo
2950 2950
 	$dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2951 2951
 	$f = $dir_var
2952 2952
 		. preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2953
-		. '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2953
+		. '.'.substr(md5($cssf), 0, 4).'_'.$ndir.'.css';
2954 2954
 
2955 2955
 	// la css peut etre distante (url absolue !)
2956 2956
 	if ($distant) {
@@ -2996,8 +2996,8 @@  discard block
 block discarded – undo
2996 2996
 		} // si la css_direction commence par $dir_var on la fait passer pour une absolue
2997 2997
 		elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
2998 2998
 			$css_direction = substr($css_direction, strlen($dir_var));
2999
-			$src_faux_abs['/@@@@@@/' . $css_direction] = $css_direction;
3000
-			$css_direction = '/@@@@@@/' . $css_direction;
2999
+			$src_faux_abs['/@@@@@@/'.$css_direction] = $css_direction;
3000
+			$css_direction = '/@@@@@@/'.$css_direction;
3001 3001
 		}
3002 3002
 		$src[] = $regs[0][$k];
3003 3003
 		$src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
@@ -3046,7 +3046,7 @@  discard block
 block discarded – undo
3046 3046
 
3047 3047
 	$f = basename($css, '.css');
3048 3048
 	$f = sous_repertoire(_DIR_VAR, 'cache-css')
3049
-		. preg_replace(',(.*?)(_rtl|_ltr)?$,', "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
3049
+		. preg_replace(',(.*?)(_rtl|_ltr)?$,', "\\1-urlabs-".substr(md5("$css-urlabs"), 0, 4)."\\2", $f)
3050 3050
 		. '.css';
3051 3051
 
3052 3052
 	if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
@@ -3056,7 +3056,7 @@  discard block
 block discarded – undo
3056 3056
 	if ($url_absolue_css == $css) {
3057 3057
 		if (
3058 3058
 			strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
3059
-			or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
3059
+			or !lire_fichier(_DIR_RACINE.substr($css, $l), $contenu)
3060 3060
 		) {
3061 3061
 			include_spip('inc/distant');
3062 3062
 			$contenu = recuperer_url($css);
@@ -3168,7 +3168,7 @@  discard block
 block discarded – undo
3168 3168
 	$expression = str_replace('\/', '/', $expression);
3169 3169
 	$expression = str_replace('/', '\/', $expression);
3170 3170
 
3171
-	if (preg_match('/' . $expression . '/' . $modif, $texte ?? '', $r)) {
3171
+	if (preg_match('/'.$expression.'/'.$modif, $texte ?? '', $r)) {
3172 3172
 		if (isset($r[$capte])) {
3173 3173
 			return $r[$capte];
3174 3174
 		} else {
@@ -3206,7 +3206,7 @@  discard block
 block discarded – undo
3206 3206
 	$expression = str_replace('\/', '/', $expression);
3207 3207
 	$expression = str_replace('/', '\/', $expression);
3208 3208
 
3209
-	return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3209
+	return preg_replace('/'.$expression.'/'.$modif, $replace, $texte);
3210 3210
 }
3211 3211
 
3212 3212
 
@@ -3225,7 +3225,7 @@  discard block
 block discarded – undo
3225 3225
 function traiter_doublons_documents(&$doublons, $letexte) {
3226 3226
 
3227 3227
 	// Verifier dans le texte & les notes (pas beau, helas)
3228
-	$t = $letexte . $GLOBALS['les_notes'];
3228
+	$t = $letexte.$GLOBALS['les_notes'];
3229 3229
 
3230 3230
 	if (
3231 3231
 		strstr($t, 'spip_document_') // evite le preg_match_all si inutile
@@ -3239,7 +3239,7 @@  discard block
 block discarded – undo
3239 3239
 		if (!isset($doublons['documents'])) {
3240 3240
 			$doublons['documents'] = '';
3241 3241
 		}
3242
-		$doublons['documents'] .= ',' . join(',', $matches[1]);
3242
+		$doublons['documents'] .= ','.join(',', $matches[1]);
3243 3243
 	}
3244 3244
 
3245 3245
 	return $letexte;
@@ -3296,7 +3296,7 @@  discard block
 block discarded – undo
3296 3296
 	if ($env) {
3297 3297
 		foreach ($env as $i => $j) {
3298 3298
 			if (is_string($j) and !in_array($i, $ignore_params)) {
3299
-				$texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3299
+				$texte .= "<param name='".attribut_html($i)."'\n\tvalue='".attribut_html($j)."' />";
3300 3300
 			}
3301 3301
 		}
3302 3302
 	}
@@ -3335,7 +3335,7 @@  discard block
 block discarded – undo
3335 3335
 	if ($env) {
3336 3336
 		foreach ($env as $i => $j) {
3337 3337
 			if (is_string($j) and !in_array($i, $ignore_params)) {
3338
-				$texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3338
+				$texte .= attribut_html($i)."='".attribut_html($j)."' ";
3339 3339
 			}
3340 3340
 		}
3341 3341
 	}
@@ -3409,10 +3409,10 @@  discard block
 block discarded – undo
3409 3409
 	// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3410 3410
 	if (
3411 3411
 		preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3412
-		and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . '-xx.svg'
3412
+		and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])).'-xx.svg'
3413 3413
 		and file_exists($variante_svg_generique)
3414 3414
 	) {
3415
-		if ($variante_svg_size = substr($variante_svg_generique, 0, -6) . $m[1] . '.svg' and file_exists($variante_svg_size)) {
3415
+		if ($variante_svg_size = substr($variante_svg_generique, 0, -6).$m[1].'.svg' and file_exists($variante_svg_size)) {
3416 3416
 			$img_file = $variante_svg_size;
3417 3417
 		}
3418 3418
 		else {
@@ -3470,7 +3470,7 @@  discard block
 block discarded – undo
3470 3470
 				return '';
3471 3471
 			}
3472 3472
 		}
3473
-		$atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3473
+		$atts .= " width='".$largeur."' height='".$hauteur."'";
3474 3474
 	}
3475 3475
 
3476 3476
 	if (file_exists($img_file)) {
@@ -3480,14 +3480,14 @@  discard block
 block discarded – undo
3480 3480
 		$alt = '';
3481 3481
 	}
3482 3482
 	elseif ($alt or $alt === '') {
3483
-		$alt = " alt='" . attribut_html($alt) . "'";
3483
+		$alt = " alt='".attribut_html($alt)."'";
3484 3484
 	}
3485 3485
 	else {
3486
-		$alt = " alt='" . attribut_html($title) . "'";
3486
+		$alt = " alt='".attribut_html($title)."'";
3487 3487
 	}
3488
-	return "<img src='" . attribut_html($img_file) . "'$alt"
3489
-	. ($title ? ' title="' . attribut_html($title) . '"' : '')
3490
-	. ' ' . ltrim($atts)
3488
+	return "<img src='".attribut_html($img_file)."'$alt"
3489
+	. ($title ? ' title="'.attribut_html($title).'"' : '')
3490
+	. ' '.ltrim($atts)
3491 3491
 	. ' />';
3492 3492
 }
3493 3493
 
@@ -3501,10 +3501,10 @@  discard block
 block discarded – undo
3501 3501
  */
3502 3502
 function http_style_background($img, $att = '', $size = null) {
3503 3503
 	if ($size and is_numeric($size)) {
3504
-		$size = trim($size) . 'px';
3504
+		$size = trim($size).'px';
3505 3505
 	}
3506
-	return " style='background" .
3507
-		($att ? '' : '-image') . ': url("' . chemin_image($img) . '")' . ($att ? (' ' . $att) : '') . ';'
3506
+	return " style='background".
3507
+		($att ? '' : '-image').': url("'.chemin_image($img).'")'.($att ? (' '.$att) : '').';'
3508 3508
 		. ($size ? "background-size:{$size};" : '')
3509 3509
 		. "'";
3510 3510
 }
@@ -3619,7 +3619,7 @@  discard block
 block discarded – undo
3619 3619
 		$img = http_img_pack(
3620 3620
 			$img,
3621 3621
 			$alt,
3622
-			$class ? " class='" . attribut_html($class) . "'" : '',
3622
+			$class ? " class='".attribut_html($class)."'" : '',
3623 3623
 			'',
3624 3624
 			['chemin_image' => false, 'utiliser_suffixe_size' => false]
3625 3625
 		);
@@ -3704,7 +3704,7 @@  discard block
 block discarded – undo
3704 3704
 	$balise_svg_source = $balise_svg;
3705 3705
 
3706 3706
 	// entete XML à supprimer
3707
-	$svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3707
+	$svg = preg_replace(',^\s*<\?xml[^>]*\?'.'>,', '', $svg);
3708 3708
 
3709 3709
 	// IE est toujours mon ami
3710 3710
 	$balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
@@ -3722,9 +3722,9 @@  discard block
 block discarded – undo
3722 3722
 	// regler le alt
3723 3723
 	if ($alt) {
3724 3724
 		$balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3725
-		$id = 'img-svg-title-' . substr(md5("$img_file:$svg:$alt"), 0, 4);
3725
+		$id = 'img-svg-title-'.substr(md5("$img_file:$svg:$alt"), 0, 4);
3726 3726
 		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3727
-		$title = "<title id=\"$id\">" . entites_html($alt) . "</title>\n";
3727
+		$title = "<title id=\"$id\">".entites_html($alt)."</title>\n";
3728 3728
 		$balise_svg .= $title;
3729 3729
 	}
3730 3730
 	else {
@@ -3772,7 +3772,7 @@  discard block
 block discarded – undo
3772 3772
 	if (is_array($tableau)) {
3773 3773
 		foreach ($tableau as $k => $v) {
3774 3774
 			$res = recuperer_fond(
3775
-				'modeles/' . $modele,
3775
+				'modeles/'.$modele,
3776 3776
 				array_merge(['cle' => $k], (is_array($v) ? $v : ['valeur' => $v]))
3777 3777
 			);
3778 3778
 			$texte .= $res;
@@ -3957,7 +3957,7 @@  discard block
 block discarded – undo
3957 3957
 	}
3958 3958
 
3959 3959
 	$c = serialize($c);
3960
-	$cle = calculer_cle_action($form . $c);
3960
+	$cle = calculer_cle_action($form.$c);
3961 3961
 	$c = "$cle:$c";
3962 3962
 
3963 3963
 	// on ne stocke pas les contextes dans des fichiers en cache
@@ -4015,15 +4015,15 @@  discard block
 block discarded – undo
4015 4015
 	}
4016 4016
 	// toujours encoder l'url source dans le bloc ajax
4017 4017
 	$r = self();
4018
-	$r = ' data-origin="' . $r . '"';
4018
+	$r = ' data-origin="'.$r.'"';
4019 4019
 	$class = 'ajaxbloc';
4020 4020
 	if ($ajaxid and is_string($ajaxid)) {
4021 4021
 		// ajaxid est normalement conforme a un nom de classe css
4022 4022
 		// on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
4023
-		$class .= ' ajax-id-' . entites_html($ajaxid);
4023
+		$class .= ' ajax-id-'.entites_html($ajaxid);
4024 4024
 	}
4025 4025
 
4026
-	return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
4026
+	return "<div class='$class' "."data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
4027 4027
 }
4028 4028
 
4029 4029
 /**
@@ -4067,7 +4067,7 @@  discard block
 block discarded – undo
4067 4067
 		$cle = substr($c, 0, $p);
4068 4068
 		$c = substr($c, $p + 1);
4069 4069
 
4070
-		if ($cle == calculer_cle_action($form . $c)) {
4070
+		if ($cle == calculer_cle_action($form.$c)) {
4071 4071
 			$env = @unserialize($c);
4072 4072
 			return $env;
4073 4073
 		}
@@ -4188,13 +4188,13 @@  discard block
 block discarded – undo
4188 4188
 				}
4189 4189
 			}
4190 4190
 		}
4191
-		$att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"';
4191
+		$att .= 'class="'.($class ? attribut_html($class).' ' : '').(defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on').'"';
4192 4192
 	} else {
4193 4193
 		$bal = 'a';
4194 4194
 		$att = "href='$url'"
4195
-			. ($title ? " title='" . attribut_html($title) . "'" : '')
4196
-			. ($class ? " class='" . attribut_html($class) . "'" : '')
4197
-			. ($rel ? " rel='" . attribut_html($rel) . "'" : '')
4195
+			. ($title ? " title='".attribut_html($title)."'" : '')
4196
+			. ($class ? " class='".attribut_html($class)."'" : '')
4197
+			. ($rel ? " rel='".attribut_html($rel)."'" : '')
4198 4198
 			. $evt;
4199 4199
 	}
4200 4200
 	if ($libelle === null) {
@@ -4333,7 +4333,7 @@  discard block
 block discarded – undo
4333 4333
 
4334 4334
 	// Icône
4335 4335
 	$icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4336
-	$icone = '<span class="icone-image' . ($fonction ? " icone-fonction icone-fonction-$fonction" : '') . "\">$icone</span>";
4336
+	$icone = '<span class="icone-image'.($fonction ? " icone-fonction icone-fonction-$fonction" : '')."\">$icone</span>";
4337 4337
 
4338 4338
 	// Markup final
4339 4339
 	if ($type == 'lien') {
@@ -4608,20 +4608,20 @@  discard block
 block discarded – undo
4608 4608
 		$class_form = 'ajax';
4609 4609
 		$class = str_replace('ajax', '', $class);
4610 4610
 	}
4611
-	$class_btn = 'submit ' . trim($class);
4611
+	$class_btn = 'submit '.trim($class);
4612 4612
 
4613 4613
 	if ($confirm) {
4614
-		$confirm = 'confirm("' . attribut_html($confirm) . '")';
4614
+		$confirm = 'confirm("'.attribut_html($confirm).'")';
4615 4615
 		if ($callback) {
4616 4616
 			$callback = "$confirm?($callback):false";
4617 4617
 		} else {
4618 4618
 			$callback = $confirm;
4619 4619
 		}
4620 4620
 	}
4621
-	$onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : '';
4621
+	$onclick = $callback ? " onclick='return ".addcslashes($callback, "'")."'" : '';
4622 4622
 	$title = $title ? " title='$title'" : '';
4623 4623
 
4624
-	return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>" . form_hidden($url)
4624
+	return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>".form_hidden($url)
4625 4625
 	. "<button type='submit' class='$class_btn'$title$onclick>$libelle</button></div></form>";
4626 4626
 }
4627 4627
 
@@ -4686,14 +4686,14 @@  discard block
 block discarded – undo
4686 4686
 		$champ_titre = '';
4687 4687
 		if ($demande_titre) {
4688 4688
 			// si pas de titre declare mais champ titre, il sera peuple par le select *
4689
-			$champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4689
+			$champ_titre = (!empty($desc['titre'])) ? ', '.$desc['titre'] : '';
4690 4690
 		}
4691 4691
 		include_spip('base/abstract_sql');
4692 4692
 		include_spip('base/connect_sql');
4693 4693
 		$objets[$type_objet][$id_objet] = sql_fetsel(
4694
-			'*' . $champ_titre,
4694
+			'*'.$champ_titre,
4695 4695
 			$desc['table_sql'],
4696
-			id_table_objet($type_objet) . ' = ' . intval($id_objet)
4696
+			id_table_objet($type_objet).' = '.intval($id_objet)
4697 4697
 		);
4698 4698
 
4699 4699
 		// Toujours noter la longueur d'introduction, même si pas demandé cette fois-ci
@@ -4786,8 +4786,7 @@  discard block
 block discarded – undo
4786 4786
 	if (isset($ligne_sql['chapo'])) {
4787 4787
 		$chapo = $ligne_sql['chapo'];
4788 4788
 		$texte = strlen($descriptif) ?
4789
-			'' :
4790
-			"$chapo \n\n $texte";
4789
+			'' : "$chapo \n\n $texte";
4791 4790
 	}
4792 4791
 
4793 4792
 	// Longueur en paramètre, sinon celle renseignée dans la description de l'objet, sinon valeur en dur
@@ -4862,7 +4861,7 @@  discard block
 block discarded – undo
4862 4861
 		return $texte;
4863 4862
 	}
4864 4863
 
4865
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4864
+	$traitement = str_replace('%s', "'".texte_script($texte)."'", $traitement);
4866 4865
 
4867 4866
 	// signaler qu'on est dans l'espace prive pour les filtres qui se servent de ce flag
4868 4867
 	if (test_espace_prive()) {
@@ -4901,7 +4900,7 @@  discard block
 block discarded – undo
4901 4900
 	}
4902 4901
 	$url = generer_objet_url($id_objet, $objet, '', '', null, '', $connect);
4903 4902
 
4904
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . '</a>';
4903
+	return "<a href='$url' class='$objet'>".couper($titre, $longueur).'</a>';
4905 4904
 }
4906 4905
 
4907 4906
 /**
@@ -4927,10 +4926,10 @@  discard block
 block discarded – undo
4927 4926
 function wrap($texte, $wrap) {
4928 4927
 	$balises = extraire_balises($wrap);
4929 4928
 	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4930
-		$texte = $wrap . $texte;
4929
+		$texte = $wrap.$texte;
4931 4930
 		$regs = array_reverse($regs[1]);
4932
-		$wrap = '</' . implode('></', $regs) . '>';
4933
-		$texte = $texte . $wrap;
4931
+		$wrap = '</'.implode('></', $regs).'>';
4932
+		$texte = $texte.$wrap;
4934 4933
 	}
4935 4934
 
4936 4935
 	return $texte;
@@ -4961,7 +4960,7 @@  discard block
 block discarded – undo
4961 4960
 
4962 4961
 	// caster $u en array si besoin
4963 4962
 	if (is_object($u)) {
4964
-		$u = (array)$u;
4963
+		$u = (array) $u;
4965 4964
 	}
4966 4965
 
4967 4966
 	if (is_array($u)) {
@@ -4983,7 +4982,7 @@  discard block
 block discarded – undo
4983 4982
 		// sinon on passe a la ligne et on indente
4984 4983
 		$i_str = str_pad('', $indent, ' ');
4985 4984
 		foreach ($u as $k => $v) {
4986
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4985
+			$out .= $join.$i_str."$k: ".filtre_print_dist($v, $join, $indent + 2);
4987 4986
 		}
4988 4987
 
4989 4988
 		return $out;
@@ -5037,7 +5036,7 @@  discard block
 block discarded – undo
5037 5036
  * @return string
5038 5037
  */
5039 5038
 function objet_icone($objet, $taille = 24, $class = '') {
5040
-	$icone = objet_info($objet, 'icone_objet') . '-' . $taille . '.png';
5039
+	$icone = objet_info($objet, 'icone_objet').'-'.$taille.'.png';
5041 5040
 	$icone = chemin_image($icone);
5042 5041
 	$balise_img = charger_filtre('balise_img');
5043 5042
 
@@ -5063,7 +5062,7 @@  discard block
 block discarded – undo
5063 5062
  */
5064 5063
 function objet_T($objet, $chaine, $args = [], $options = []) {
5065 5064
 	$chaine = explode(':', $chaine);
5066
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, ['force' => false]))) {
5065
+	if ($t = _T($objet.':'.end($chaine), $args, array_merge($options, ['force' => false]))) {
5067 5066
 		return $t;
5068 5067
 	}
5069 5068
 	$chaine = implode(':', $chaine);
@@ -5129,7 +5128,7 @@  discard block
 block discarded – undo
5129 5128
 	$cache = recuperer_fond($fond, $contexte, $options, $connect);
5130 5129
 
5131 5130
 	// calculer le nom de la css
5132
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
5131
+	$dir_var = sous_repertoire(_DIR_VAR, 'cache-'.$extension);
5133 5132
 	$nom_safe = preg_replace(',\W,', '_', str_replace('.', '_', $fond));
5134 5133
 	$contexte_implicite = calculer_contexte_implicite();
5135 5134
 
@@ -5137,14 +5136,14 @@  discard block
 block discarded – undo
5137 5136
 	// mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
5138 5137
 	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
5139 5138
 	if (isset($options['hash_on_content']) and $options['hash_on_content']) {
5140
-		$hash = md5($contexte_implicite['host'] . '::' . $cache);
5139
+		$hash = md5($contexte_implicite['host'].'::'.$cache);
5141 5140
 	}
5142 5141
 	else {
5143 5142
 		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
5144 5143
 		ksort($contexte);
5145
-		$hash = md5($fond . json_encode($contexte_implicite, JSON_THROW_ON_ERROR) . json_encode($contexte, JSON_THROW_ON_ERROR) . $connect);
5144
+		$hash = md5($fond.json_encode($contexte_implicite, JSON_THROW_ON_ERROR).json_encode($contexte, JSON_THROW_ON_ERROR).$connect);
5146 5145
 	}
5147
-	$filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
5146
+	$filename = $dir_var.$extension."dyn-$nom_safe-".substr($hash, 0, 8).".$extension";
5148 5147
 
5149 5148
 	// mettre a jour le fichier si il n'existe pas
5150 5149
 	// ou trop ancien
@@ -5152,8 +5151,8 @@  discard block
 block discarded – undo
5152 5151
 	// et recopie sur le fichier cible uniquement si il change
5153 5152
 	if (
5154 5153
 		!file_exists($filename)
5155
-		or !file_exists($filename . '.last')
5156
-		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . '.last') < $cache['lastmodified'])
5154
+		or !file_exists($filename.'.last')
5155
+		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename.'.last') < $cache['lastmodified'])
5157 5156
 		or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
5158 5157
 	) {
5159 5158
 		$contenu = $cache['texte'];
@@ -5177,10 +5176,10 @@  discard block
 block discarded – undo
5177 5176
 			}
5178 5177
 			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
5179 5178
 			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
5180
-			$comment .= "}\n   md5:" . md5($contenu) . " */\n";
5179
+			$comment .= "}\n   md5:".md5($contenu)." */\n";
5181 5180
 		}
5182 5181
 		// et ecrire le fichier si il change
5183
-		ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
5182
+		ecrire_fichier_calcule_si_modifie($filename, $comment.$contenu, false, true);
5184 5183
 	}
5185 5184
 
5186 5185
 	return timestamp($filename);
@@ -5413,7 +5412,7 @@  discard block
 block discarded – undo
5413 5412
 	if ($e > 0 and strlen($mid) > 8) {
5414 5413
 		$mid = '***...***';
5415 5414
 	}
5416
-	return substr($passe, 0, $e) . $mid . ($e > 0 ? substr($passe, -$e) : '');
5415
+	return substr($passe, 0, $e).$mid.($e > 0 ? substr($passe, -$e) : '');
5417 5416
 }
5418 5417
 
5419 5418
 
@@ -5475,7 +5474,7 @@  discard block
 block discarded – undo
5475 5474
 		case 'id':
5476 5475
 		case 'anchor':
5477 5476
 			if (preg_match(',^\d,', $texte)) {
5478
-				$texte = substr($type, 0, 1) . $texte;
5477
+				$texte = substr($type, 0, 1).$texte;
5479 5478
 			}
5480 5479
 	}
5481 5480
 
@@ -5485,9 +5484,9 @@  discard block
 block discarded – undo
5485 5484
 
5486 5485
 	if (strlen($texte) < $longueur_mini and $longueur_mini < $longueur_maxi) {
5487 5486
 		if (preg_match(',^\d,', $texte)) {
5488
-			$texte = ($type ? substr($type, 0, 1) : 's') . $texte;
5487
+			$texte = ($type ? substr($type, 0, 1) : 's').$texte;
5489 5488
 		}
5490
-		$texte .= $separateur . md5($original);
5489
+		$texte .= $separateur.md5($original);
5491 5490
 		$texte = substr($texte, 0, $longueur_mini);
5492 5491
 	}
5493 5492
 
Please login to merge, or discard this patch.