Completed
Push — master ( bcd628...6b340f )
by cam
08:24 queued 07:20
created
ecrire/inc/filtres.php 2 patches
Indentation   +2478 added lines, -2478 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
 
@@ -1032,11 +1032,11 @@  discard block
 block discarded – undo
1032 1032
  *     Numéro de titre, sinon chaîne vide
1033 1033
  **/
1034 1034
 function supprimer_numero($texte) {
1035
-	return preg_replace(
1036
-		',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1037
-		'',
1038
-		$texte
1039
-	);
1035
+    return preg_replace(
1036
+        ',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1037
+        '',
1038
+        $texte
1039
+    );
1040 1040
 }
1041 1041
 
1042 1042
 /**
@@ -1059,18 +1059,18 @@  discard block
 block discarded – undo
1059 1059
  *     Numéro de titre, sinon chaîne vide
1060 1060
  **/
1061 1061
 function recuperer_numero($texte) {
1062
-	if (
1063
-		$texte and
1064
-		preg_match(
1065
-			',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1066
-			$texte,
1067
-			$regs
1068
-		)
1069
-	) {
1070
-		return strval($regs[1]);
1071
-	} else {
1072
-		return '';
1073
-	}
1062
+    if (
1063
+        $texte and
1064
+        preg_match(
1065
+            ',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1066
+            $texte,
1067
+            $regs
1068
+        )
1069
+    ) {
1070
+        return strval($regs[1]);
1071
+    } else {
1072
+        return '';
1073
+    }
1074 1074
 }
1075 1075
 
1076 1076
 /**
@@ -1097,16 +1097,16 @@  discard block
 block discarded – undo
1097 1097
  *     Texte ou tableau de textes converti
1098 1098
  **/
1099 1099
 function supprimer_tags($texte, $rempl = '') {
1100
-	if ($texte === null) {
1101
-		return '';
1102
-	}
1103
-	$texte = preg_replace(',<(!--|\w|/|!\[endif|!\[if)[^>]*>,US', $rempl, $texte);
1104
-	// ne pas oublier un < final non ferme car coupe
1105
-	$texte = preg_replace(',<(!--|\w|/).*$,US', $rempl, $texte);
1106
-	// mais qui peut aussi etre un simple signe plus petit que
1107
-	$texte = str_replace('<', '&lt;', $texte);
1100
+    if ($texte === null) {
1101
+        return '';
1102
+    }
1103
+    $texte = preg_replace(',<(!--|\w|/|!\[endif|!\[if)[^>]*>,US', $rempl, $texte);
1104
+    // ne pas oublier un < final non ferme car coupe
1105
+    $texte = preg_replace(',<(!--|\w|/).*$,US', $rempl, $texte);
1106
+    // mais qui peut aussi etre un simple signe plus petit que
1107
+    $texte = str_replace('<', '&lt;', $texte);
1108 1108
 
1109
-	return $texte;
1109
+    return $texte;
1110 1110
 }
1111 1111
 
1112 1112
 /**
@@ -1129,9 +1129,9 @@  discard block
 block discarded – undo
1129 1129
  *     Texte converti
1130 1130
  **/
1131 1131
 function echapper_tags($texte, $rempl = '') {
1132
-	$texte = preg_replace('/<([^>]*)>/', "&lt;\\1&gt;", $texte);
1132
+    $texte = preg_replace('/<([^>]*)>/', "&lt;\\1&gt;", $texte);
1133 1133
 
1134
-	return $texte;
1134
+    return $texte;
1135 1135
 }
1136 1136
 
1137 1137
 /**
@@ -1152,18 +1152,18 @@  discard block
 block discarded – undo
1152 1152
  *     Texte converti
1153 1153
  **/
1154 1154
 function textebrut($texte) {
1155
-	$u = $GLOBALS['meta']['pcre_u'];
1156
-	$texte = preg_replace('/\s+/S' . $u, ' ', $texte);
1157
-	$texte = preg_replace('/<(p|br)( [^>]*)?' . '>/iS', "\n\n", $texte);
1158
-	$texte = preg_replace("/^\n+/", '', $texte);
1159
-	$texte = preg_replace("/\n+$/", '', $texte);
1160
-	$texte = preg_replace("/\n +/", "\n", $texte);
1161
-	$texte = supprimer_tags($texte);
1162
-	$texte = preg_replace('/(&nbsp;| )+/S', ' ', $texte);
1163
-	// nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail...
1164
-	$texte = str_replace('&#8217;', "'", $texte);
1155
+    $u = $GLOBALS['meta']['pcre_u'];
1156
+    $texte = preg_replace('/\s+/S' . $u, ' ', $texte);
1157
+    $texte = preg_replace('/<(p|br)( [^>]*)?' . '>/iS', "\n\n", $texte);
1158
+    $texte = preg_replace("/^\n+/", '', $texte);
1159
+    $texte = preg_replace("/\n+$/", '', $texte);
1160
+    $texte = preg_replace("/\n +/", "\n", $texte);
1161
+    $texte = supprimer_tags($texte);
1162
+    $texte = preg_replace('/(&nbsp;| )+/S', ' ', $texte);
1163
+    // nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail...
1164
+    $texte = str_replace('&#8217;', "'", $texte);
1165 1165
 
1166
-	return $texte;
1166
+    return $texte;
1167 1167
 }
1168 1168
 
1169 1169
 
@@ -1179,23 +1179,23 @@  discard block
 block discarded – undo
1179 1179
  *     Texte avec liens ouvrants
1180 1180
  **/
1181 1181
 function liens_ouvrants($texte) {
1182
-	if (
1183
-		preg_match_all(
1184
-			",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1185
-			$texte,
1186
-			$liens,
1187
-			PREG_PATTERN_ORDER
1188
-		)
1189
-	) {
1190
-		foreach ($liens[0] as $a) {
1191
-			$rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1192
-			$ablank = inserer_attribut($a, 'rel', $rel);
1193
-			$ablank = inserer_attribut($ablank, 'target', '_blank');
1194
-			$texte = str_replace($a, $ablank, $texte);
1195
-		}
1196
-	}
1197
-
1198
-	return $texte;
1182
+    if (
1183
+        preg_match_all(
1184
+            ",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1185
+            $texte,
1186
+            $liens,
1187
+            PREG_PATTERN_ORDER
1188
+        )
1189
+    ) {
1190
+        foreach ($liens[0] as $a) {
1191
+            $rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1192
+            $ablank = inserer_attribut($a, 'rel', $rel);
1193
+            $ablank = inserer_attribut($ablank, 'target', '_blank');
1194
+            $texte = str_replace($a, $ablank, $texte);
1195
+        }
1196
+    }
1197
+
1198
+    return $texte;
1199 1199
 }
1200 1200
 
1201 1201
 /**
@@ -1205,22 +1205,22 @@  discard block
 block discarded – undo
1205 1205
  * @return string
1206 1206
  */
1207 1207
 function liens_nofollow($texte) {
1208
-	if (stripos($texte, '<a') === false) {
1209
-		return $texte;
1210
-	}
1208
+    if (stripos($texte, '<a') === false) {
1209
+        return $texte;
1210
+    }
1211 1211
 
1212
-	if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) {
1213
-		foreach ($regs[0] as $a) {
1214
-			$rel = extraire_attribut($a, 'rel') ?? '';
1215
-			if (strpos($rel, 'nofollow') === false) {
1216
-				$rel = 'nofollow' . ($rel ? " $rel" : '');
1217
-				$anofollow = inserer_attribut($a, 'rel', $rel);
1218
-				$texte = str_replace($a, $anofollow, $texte);
1219
-			}
1220
-		}
1221
-	}
1212
+    if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) {
1213
+        foreach ($regs[0] as $a) {
1214
+            $rel = extraire_attribut($a, 'rel') ?? '';
1215
+            if (strpos($rel, 'nofollow') === false) {
1216
+                $rel = 'nofollow' . ($rel ? " $rel" : '');
1217
+                $anofollow = inserer_attribut($a, 'rel', $rel);
1218
+                $texte = str_replace($a, $anofollow, $texte);
1219
+            }
1220
+        }
1221
+    }
1222 1222
 
1223
-	return $texte;
1223
+    return $texte;
1224 1224
 }
1225 1225
 
1226 1226
 /**
@@ -1239,12 +1239,12 @@  discard block
 block discarded – undo
1239 1239
  *     Texte sans paraghaphes
1240 1240
  **/
1241 1241
 function PtoBR($texte) {
1242
-	$u = $GLOBALS['meta']['pcre_u'];
1243
-	$texte = preg_replace('@</p>@iS', "\n", $texte);
1244
-	$texte = preg_replace("@<p\b.*>@UiS", '<br />', $texte);
1245
-	$texte = preg_replace('@^\s*<br />@S' . $u, '', $texte);
1242
+    $u = $GLOBALS['meta']['pcre_u'];
1243
+    $texte = preg_replace('@</p>@iS', "\n", $texte);
1244
+    $texte = preg_replace("@<p\b.*>@UiS", '<br />', $texte);
1245
+    $texte = preg_replace('@^\s*<br />@S' . $u, '', $texte);
1246 1246
 
1247
-	return $texte;
1247
+    return $texte;
1248 1248
 }
1249 1249
 
1250 1250
 
@@ -1269,14 +1269,14 @@  discard block
 block discarded – undo
1269 1269
  * @return string Texte encadré du style CSS
1270 1270
  */
1271 1271
 function lignes_longues($texte) {
1272
-	if (!strlen(trim($texte))) {
1273
-		return $texte;
1274
-	}
1275
-	include_spip('inc/texte');
1276
-	$tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1277
-		'div' : 'span';
1272
+    if (!strlen(trim($texte))) {
1273
+        return $texte;
1274
+    }
1275
+    include_spip('inc/texte');
1276
+    $tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1277
+        'div' : 'span';
1278 1278
 
1279
-	return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
1279
+    return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
1280 1280
 }
1281 1281
 
1282 1282
 /**
@@ -1295,30 +1295,30 @@  discard block
 block discarded – undo
1295 1295
  * @return string Texte en majuscule
1296 1296
  */
1297 1297
 function majuscules($texte) {
1298
-	if (!strlen($texte)) {
1299
-		return '';
1300
-	}
1298
+    if (!strlen($texte)) {
1299
+        return '';
1300
+    }
1301 1301
 
1302
-	// Cas du turc
1303
-	if ($GLOBALS['spip_lang'] == 'tr') {
1304
-		# remplacer hors des tags et des entites
1305
-		if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) {
1306
-			foreach ($regs as $n => $match) {
1307
-				$texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte);
1308
-			}
1309
-		}
1302
+    // Cas du turc
1303
+    if ($GLOBALS['spip_lang'] == 'tr') {
1304
+        # remplacer hors des tags et des entites
1305
+        if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) {
1306
+            foreach ($regs as $n => $match) {
1307
+                $texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte);
1308
+            }
1309
+        }
1310 1310
 
1311
-		$texte = str_replace('i', '&#304;', $texte);
1311
+        $texte = str_replace('i', '&#304;', $texte);
1312 1312
 
1313
-		if ($regs) {
1314
-			foreach ($regs as $n => $match) {
1315
-				$texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte);
1316
-			}
1317
-		}
1318
-	}
1313
+        if ($regs) {
1314
+            foreach ($regs as $n => $match) {
1315
+                $texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte);
1316
+            }
1317
+        }
1318
+    }
1319 1319
 
1320
-	// Cas general
1321
-	return "<span style='text-transform: uppercase;'>$texte</span>";
1320
+    // Cas general
1321
+    return "<span style='text-transform: uppercase;'>$texte</span>";
1322 1322
 }
1323 1323
 
1324 1324
 /**
@@ -1336,29 +1336,29 @@  discard block
 block discarded – undo
1336 1336
  * @return string
1337 1337
  **/
1338 1338
 function taille_en_octets($taille) {
1339
-	if (!defined('_KILOBYTE')) {
1340
-		/**
1341
-		 * Définit le nombre d'octets dans un Kilobyte
1342
-		 *
1343
-		 * @var int
1344
-		 **/
1345
-		define('_KILOBYTE', 1024);
1346
-	}
1339
+    if (!defined('_KILOBYTE')) {
1340
+        /**
1341
+         * Définit le nombre d'octets dans un Kilobyte
1342
+         *
1343
+         * @var int
1344
+         **/
1345
+        define('_KILOBYTE', 1024);
1346
+    }
1347 1347
 
1348
-	if ($taille < 1) {
1349
-		return '';
1350
-	}
1351
-	if ($taille < _KILOBYTE) {
1352
-		$taille = _T('taille_octets', ['taille' => $taille]);
1353
-	} elseif ($taille < _KILOBYTE * _KILOBYTE) {
1354
-		$taille = _T('taille_ko', ['taille' => round($taille / _KILOBYTE, 1)]);
1355
-	} elseif ($taille < _KILOBYTE * _KILOBYTE * _KILOBYTE) {
1356
-		$taille = _T('taille_mo', ['taille' => round($taille / _KILOBYTE / _KILOBYTE, 1)]);
1357
-	} else {
1358
-		$taille = _T('taille_go', ['taille' => round($taille / _KILOBYTE / _KILOBYTE / _KILOBYTE, 2)]);
1359
-	}
1348
+    if ($taille < 1) {
1349
+        return '';
1350
+    }
1351
+    if ($taille < _KILOBYTE) {
1352
+        $taille = _T('taille_octets', ['taille' => $taille]);
1353
+    } elseif ($taille < _KILOBYTE * _KILOBYTE) {
1354
+        $taille = _T('taille_ko', ['taille' => round($taille / _KILOBYTE, 1)]);
1355
+    } elseif ($taille < _KILOBYTE * _KILOBYTE * _KILOBYTE) {
1356
+        $taille = _T('taille_mo', ['taille' => round($taille / _KILOBYTE / _KILOBYTE, 1)]);
1357
+    } else {
1358
+        $taille = _T('taille_go', ['taille' => round($taille / _KILOBYTE / _KILOBYTE / _KILOBYTE, 2)]);
1359
+    }
1360 1360
 
1361
-	return $taille;
1361
+    return $taille;
1362 1362
 }
1363 1363
 
1364 1364
 
@@ -1380,21 +1380,21 @@  discard block
 block discarded – undo
1380 1380
  *     Texte prêt pour être utilisé en attribut HTML
1381 1381
  **/
1382 1382
 function attribut_html(?string $texte, $textebrut = true): string {
1383
-	if ($texte === null) {
1384
-		return '';
1385
-	}
1386
-	$u = $GLOBALS['meta']['pcre_u'];
1387
-	if ($textebrut) {
1388
-		$texte = preg_replace([",\n,", ',\s(?=\s),msS' . $u], [' ', ''], textebrut($texte));
1389
-	}
1390
-	$texte = texte_backend($texte);
1391
-	$texte = str_replace(["'", '"'], ['&#039;', '&#034;'], $texte);
1383
+    if ($texte === null) {
1384
+        return '';
1385
+    }
1386
+    $u = $GLOBALS['meta']['pcre_u'];
1387
+    if ($textebrut) {
1388
+        $texte = preg_replace([",\n,", ',\s(?=\s),msS' . $u], [' ', ''], textebrut($texte));
1389
+    }
1390
+    $texte = texte_backend($texte);
1391
+    $texte = str_replace(["'", '"'], ['&#039;', '&#034;'], $texte);
1392 1392
 
1393
-	return preg_replace(
1394
-		['/&(amp;|#38;)/', '/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/'],
1395
-		['&', '&#38;'],
1396
-		$texte
1397
-	);
1393
+    return preg_replace(
1394
+        ['/&(amp;|#38;)/', '/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/'],
1395
+        ['&', '&#38;'],
1396
+        $texte
1397
+    );
1398 1398
 }
1399 1399
 
1400 1400
 
@@ -1414,15 +1414,15 @@  discard block
 block discarded – undo
1414 1414
  *     URL ou chaîne vide
1415 1415
  **/
1416 1416
 function vider_url(?string $url, $entites = true): string {
1417
-	if ($url === null) {
1418
-		return '';
1419
-	}
1420
-	# un message pour abs_url
1421
-	$GLOBALS['mode_abs_url'] = 'url';
1422
-	$url = trim($url);
1423
-	$r = ',^(?:' . _PROTOCOLES_STD . '):?/?/?$,iS';
1417
+    if ($url === null) {
1418
+        return '';
1419
+    }
1420
+    # un message pour abs_url
1421
+    $GLOBALS['mode_abs_url'] = 'url';
1422
+    $url = trim($url);
1423
+    $r = ',^(?:' . _PROTOCOLES_STD . '):?/?/?$,iS';
1424 1424
 
1425
-	return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1425
+    return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1426 1426
 }
1427 1427
 
1428 1428
 
@@ -1437,10 +1437,10 @@  discard block
 block discarded – undo
1437 1437
  * @return string Adresse email maquillée
1438 1438
  **/
1439 1439
 function antispam($texte) {
1440
-	include_spip('inc/acces');
1441
-	$masque = creer_pass_aleatoire(3);
1440
+    include_spip('inc/acces');
1441
+    $masque = creer_pass_aleatoire(3);
1442 1442
 
1443
-	return preg_replace('/@/', " $masque ", $texte);
1443
+    return preg_replace('/@/', " $masque ", $texte);
1444 1444
 }
1445 1445
 
1446 1446
 /**
@@ -1472,8 +1472,8 @@  discard block
 block discarded – undo
1472 1472
  *     True si on a le droit d'accès, false sinon.
1473 1473
  **/
1474 1474
 function filtre_securiser_acces_dist($id_auteur, $cle, $dir, $op = '', $args = '') {
1475
-	include_spip('inc/acces');
1476
-	return securiser_acces_low_sec($id_auteur, $cle, $op ? "$dir $op $args" : $dir);
1475
+    include_spip('inc/acces');
1476
+    return securiser_acces_low_sec($id_auteur, $cle, $op ? "$dir $op $args" : $dir);
1477 1477
 }
1478 1478
 
1479 1479
 /**
@@ -1498,13 +1498,13 @@  discard block
 block discarded – undo
1498 1498
  *     Retourne $texte, sinon $sinon.
1499 1499
  **/
1500 1500
 function sinon($texte, $sinon = '') {
1501
-	if ($texte) {
1502
-		return $texte;
1503
-	} elseif (is_scalar($texte) and strlen($texte)) {
1504
-		return $texte;
1505
-	} else {
1506
-		return $sinon;
1507
-	}
1501
+    if ($texte) {
1502
+        return $texte;
1503
+    } elseif (is_scalar($texte) and strlen($texte)) {
1504
+        return $texte;
1505
+    } else {
1506
+        return $sinon;
1507
+    }
1508 1508
 }
1509 1509
 
1510 1510
 /**
@@ -1528,7 +1528,7 @@  discard block
 block discarded – undo
1528 1528
  * @return mixed
1529 1529
  **/
1530 1530
 function choixsivide($a, $vide, $pasvide) {
1531
-	return $a ? $pasvide : $vide;
1531
+    return $a ? $pasvide : $vide;
1532 1532
 }
1533 1533
 
1534 1534
 /**
@@ -1552,7 +1552,7 @@  discard block
 block discarded – undo
1552 1552
  * @return mixed
1553 1553
  **/
1554 1554
 function choixsiegal($a1, $a2, $v, $f) {
1555
-	return ($a1 == $a2) ? $v : $f;
1555
+    return ($a1 == $a2) ? $v : $f;
1556 1556
 }
1557 1557
 
1558 1558
 //
@@ -1571,13 +1571,13 @@  discard block
 block discarded – undo
1571 1571
  * @return string
1572 1572
  **/
1573 1573
 function filtrer_ical($texte) {
1574
-	#include_spip('inc/charsets');
1575
-	$texte = html2unicode($texte);
1576
-	$texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset']), 'utf-8');
1577
-	$texte = preg_replace("/\n/", ' ', $texte);
1578
-	$texte = preg_replace('/,/', '\,', $texte);
1574
+    #include_spip('inc/charsets');
1575
+    $texte = html2unicode($texte);
1576
+    $texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset']), 'utf-8');
1577
+    $texte = preg_replace("/\n/", ' ', $texte);
1578
+    $texte = preg_replace('/,/', '\,', $texte);
1579 1579
 
1580
-	return $texte;
1580
+    return $texte;
1581 1581
 }
1582 1582
 
1583 1583
 
@@ -1602,54 +1602,54 @@  discard block
 block discarded – undo
1602 1602
  * @return string
1603 1603
  **/
1604 1604
 function post_autobr($texte, $delim = "\n_ ") {
1605
-	if (!function_exists('echappe_html')) {
1606
-		include_spip('inc/texte_mini');
1607
-	}
1608
-	$texte = str_replace("\r\n", "\r", $texte);
1609
-	$texte = str_replace("\r", "\n", $texte);
1610
-
1611
-	if (preg_match(",\n+$,", $texte, $fin)) {
1612
-		$texte = substr($texte, 0, -strlen($fin = $fin[0]));
1613
-	} else {
1614
-		$fin = '';
1615
-	}
1616
-
1617
-	$texte = echappe_html($texte, '', true);
1618
-
1619
-	// echapper les modeles
1620
-	if (strpos($texte, '<') !== false) {
1621
-		include_spip('inc/lien');
1622
-		if (defined('_PREG_MODELE')) {
1623
-			$preg_modeles = '@' . _PREG_MODELE . '@imsS';
1624
-			$texte = echappe_html($texte, '', true, $preg_modeles);
1625
-		}
1626
-	}
1627
-
1628
-	$debut = '';
1629
-	$suite = $texte;
1630
-	while ($t = strpos('-' . $suite, "\n", 1)) {
1631
-		$debut .= substr($suite, 0, $t - 1);
1632
-		$suite = substr($suite, $t);
1633
-		$car = substr($suite, 0, 1);
1634
-		if (
1635
-			($car <> '-') and ($car <> '_') and ($car <> "\n") and ($car <> '|') and ($car <> '}')
1636
-			and !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite))
1637
-			and !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut)
1638
-		) {
1639
-			$debut .= $delim;
1640
-		} else {
1641
-			$debut .= "\n";
1642
-		}
1643
-		if (preg_match(",^\n+,", $suite, $regs)) {
1644
-			$debut .= $regs[0];
1645
-			$suite = substr($suite, strlen($regs[0]));
1646
-		}
1647
-	}
1648
-	$texte = $debut . $suite;
1649
-
1650
-	$texte = echappe_retour($texte);
1651
-
1652
-	return $texte . $fin;
1605
+    if (!function_exists('echappe_html')) {
1606
+        include_spip('inc/texte_mini');
1607
+    }
1608
+    $texte = str_replace("\r\n", "\r", $texte);
1609
+    $texte = str_replace("\r", "\n", $texte);
1610
+
1611
+    if (preg_match(",\n+$,", $texte, $fin)) {
1612
+        $texte = substr($texte, 0, -strlen($fin = $fin[0]));
1613
+    } else {
1614
+        $fin = '';
1615
+    }
1616
+
1617
+    $texte = echappe_html($texte, '', true);
1618
+
1619
+    // echapper les modeles
1620
+    if (strpos($texte, '<') !== false) {
1621
+        include_spip('inc/lien');
1622
+        if (defined('_PREG_MODELE')) {
1623
+            $preg_modeles = '@' . _PREG_MODELE . '@imsS';
1624
+            $texte = echappe_html($texte, '', true, $preg_modeles);
1625
+        }
1626
+    }
1627
+
1628
+    $debut = '';
1629
+    $suite = $texte;
1630
+    while ($t = strpos('-' . $suite, "\n", 1)) {
1631
+        $debut .= substr($suite, 0, $t - 1);
1632
+        $suite = substr($suite, $t);
1633
+        $car = substr($suite, 0, 1);
1634
+        if (
1635
+            ($car <> '-') and ($car <> '_') and ($car <> "\n") and ($car <> '|') and ($car <> '}')
1636
+            and !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite))
1637
+            and !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut)
1638
+        ) {
1639
+            $debut .= $delim;
1640
+        } else {
1641
+            $debut .= "\n";
1642
+        }
1643
+        if (preg_match(",^\n+,", $suite, $regs)) {
1644
+            $debut .= $regs[0];
1645
+            $suite = substr($suite, strlen($regs[0]));
1646
+        }
1647
+    }
1648
+    $texte = $debut . $suite;
1649
+
1650
+    $texte = echappe_retour($texte);
1651
+
1652
+    return $texte . $fin;
1653 1653
 }
1654 1654
 
1655 1655
 
@@ -1690,47 +1690,47 @@  discard block
 block discarded – undo
1690 1690
  * @return string
1691 1691
  **/
1692 1692
 function extraire_idiome($letexte, $lang = null, $options = []) {
1693
-	static $traduire = false;
1694
-	if (
1695
-		$letexte
1696
-		and preg_match_all(_EXTRAIRE_IDIOME, $letexte, $regs, PREG_SET_ORDER)
1697
-	) {
1698
-		if (!$traduire) {
1699
-			$traduire = charger_fonction('traduire', 'inc');
1700
-			include_spip('inc/lang');
1701
-		}
1702
-		if (!$lang) {
1703
-			$lang = $GLOBALS['spip_lang'];
1704
-		}
1705
-		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1706
-		if (is_bool($options)) {
1707
-			$options = ['echappe_span' => $options];
1708
-		}
1709
-		if (!isset($options['echappe_span'])) {
1710
-			$options = array_merge($options, ['echappe_span' => false]);
1711
-		}
1712
-
1713
-		foreach ($regs as $reg) {
1714
-			$cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2];
1715
-			$desc = $traduire($cle, $lang, true);
1716
-			$l = $desc->langue;
1717
-			// si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte.
1718
-			if (strlen($desc->texte ?? '')) {
1719
-				$trad = code_echappement($desc->texte, 'idiome', false);
1720
-				if ($l !== $lang) {
1721
-					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1722
-				}
1723
-				if (lang_dir($l) !== lang_dir($lang)) {
1724
-					$trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1725
-				}
1726
-				if (!$options['echappe_span']) {
1727
-					$trad = echappe_retour($trad, 'idiome');
1728
-				}
1729
-				$letexte = str_replace($reg[0], $trad, $letexte);
1730
-			}
1731
-		}
1732
-	}
1733
-	return $letexte;
1693
+    static $traduire = false;
1694
+    if (
1695
+        $letexte
1696
+        and preg_match_all(_EXTRAIRE_IDIOME, $letexte, $regs, PREG_SET_ORDER)
1697
+    ) {
1698
+        if (!$traduire) {
1699
+            $traduire = charger_fonction('traduire', 'inc');
1700
+            include_spip('inc/lang');
1701
+        }
1702
+        if (!$lang) {
1703
+            $lang = $GLOBALS['spip_lang'];
1704
+        }
1705
+        // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1706
+        if (is_bool($options)) {
1707
+            $options = ['echappe_span' => $options];
1708
+        }
1709
+        if (!isset($options['echappe_span'])) {
1710
+            $options = array_merge($options, ['echappe_span' => false]);
1711
+        }
1712
+
1713
+        foreach ($regs as $reg) {
1714
+            $cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2];
1715
+            $desc = $traduire($cle, $lang, true);
1716
+            $l = $desc->langue;
1717
+            // si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte.
1718
+            if (strlen($desc->texte ?? '')) {
1719
+                $trad = code_echappement($desc->texte, 'idiome', false);
1720
+                if ($l !== $lang) {
1721
+                    $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1722
+                }
1723
+                if (lang_dir($l) !== lang_dir($lang)) {
1724
+                    $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1725
+                }
1726
+                if (!$options['echappe_span']) {
1727
+                    $trad = echappe_retour($trad, 'idiome');
1728
+                }
1729
+                $letexte = str_replace($reg[0], $trad, $letexte);
1730
+            }
1731
+        }
1732
+    }
1733
+    return $letexte;
1734 1734
 }
1735 1735
 
1736 1736
 /**
@@ -1782,68 +1782,68 @@  discard block
 block discarded – undo
1782 1782
  **/
1783 1783
 function extraire_multi($letexte, $lang = null, $options = []) {
1784 1784
 
1785
-	if (
1786
-		$letexte
1787
-		and preg_match_all(_EXTRAIRE_MULTI, $letexte, $regs, PREG_SET_ORDER)
1788
-	) {
1789
-		if (!$lang) {
1790
-			$lang = $GLOBALS['spip_lang'];
1791
-		}
1792
-
1793
-		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1794
-		if (is_bool($options)) {
1795
-			$options = ['echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT];
1796
-		}
1797
-		if (!isset($options['echappe_span'])) {
1798
-			$options = array_merge($options, ['echappe_span' => false]);
1799
-		}
1800
-		if (!isset($options['lang_defaut'])) {
1801
-			$options = array_merge($options, ['lang_defaut' => _LANGUE_PAR_DEFAUT]);
1802
-		}
1803
-
1804
-		include_spip('inc/lang');
1805
-		foreach ($regs as $reg) {
1806
-			// chercher la version de la langue courante
1807
-			$trads = extraire_trads($reg[1]);
1808
-			if ($l = approcher_langue($trads, $lang)) {
1809
-				$trad = $trads[$l];
1810
-			} else {
1811
-				if ($options['lang_defaut'] == 'aucune') {
1812
-					$trad = '';
1813
-				} else {
1814
-					// langue absente, prendre le fr ou une langue précisée (meme comportement que inc/traduire.php)
1815
-					// ou la premiere dispo
1816
-					// mais typographier le texte selon les regles de celle-ci
1817
-					// Attention aux blocs multi sur plusieurs lignes
1818
-					if (!$l = approcher_langue($trads, $options['lang_defaut'])) {
1819
-						$l = key($trads);
1820
-					}
1821
-					$trad = $trads[$l];
1822
-					$typographie = charger_fonction(lang_typo($l), 'typographie');
1823
-					$trad = $typographie($trad);
1824
-					// Tester si on echappe en span ou en div
1825
-					// il ne faut pas echapper en div si propre produit un seul paragraphe
1826
-					include_spip('inc/texte');
1827
-					$trad_propre = preg_replace(',(^<p[^>]*>|</p>$),Uims', '', propre($trad));
1828
-					$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1829
-					if ($mode === 'div') {
1830
-						$trad = rtrim($trad) . "\n\n";
1831
-					}
1832
-					$trad = code_echappement($trad, 'multi', false, $mode);
1833
-					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1834
-					if (lang_dir($l) !== lang_dir($lang)) {
1835
-						$trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1836
-					}
1837
-					if (!$options['echappe_span']) {
1838
-						$trad = echappe_retour($trad, 'multi');
1839
-					}
1840
-				}
1841
-			}
1842
-			$letexte = str_replace($reg[0], $trad, $letexte);
1843
-		}
1844
-	}
1845
-
1846
-	return $letexte;
1785
+    if (
1786
+        $letexte
1787
+        and preg_match_all(_EXTRAIRE_MULTI, $letexte, $regs, PREG_SET_ORDER)
1788
+    ) {
1789
+        if (!$lang) {
1790
+            $lang = $GLOBALS['spip_lang'];
1791
+        }
1792
+
1793
+        // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1794
+        if (is_bool($options)) {
1795
+            $options = ['echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT];
1796
+        }
1797
+        if (!isset($options['echappe_span'])) {
1798
+            $options = array_merge($options, ['echappe_span' => false]);
1799
+        }
1800
+        if (!isset($options['lang_defaut'])) {
1801
+            $options = array_merge($options, ['lang_defaut' => _LANGUE_PAR_DEFAUT]);
1802
+        }
1803
+
1804
+        include_spip('inc/lang');
1805
+        foreach ($regs as $reg) {
1806
+            // chercher la version de la langue courante
1807
+            $trads = extraire_trads($reg[1]);
1808
+            if ($l = approcher_langue($trads, $lang)) {
1809
+                $trad = $trads[$l];
1810
+            } else {
1811
+                if ($options['lang_defaut'] == 'aucune') {
1812
+                    $trad = '';
1813
+                } else {
1814
+                    // langue absente, prendre le fr ou une langue précisée (meme comportement que inc/traduire.php)
1815
+                    // ou la premiere dispo
1816
+                    // mais typographier le texte selon les regles de celle-ci
1817
+                    // Attention aux blocs multi sur plusieurs lignes
1818
+                    if (!$l = approcher_langue($trads, $options['lang_defaut'])) {
1819
+                        $l = key($trads);
1820
+                    }
1821
+                    $trad = $trads[$l];
1822
+                    $typographie = charger_fonction(lang_typo($l), 'typographie');
1823
+                    $trad = $typographie($trad);
1824
+                    // Tester si on echappe en span ou en div
1825
+                    // il ne faut pas echapper en div si propre produit un seul paragraphe
1826
+                    include_spip('inc/texte');
1827
+                    $trad_propre = preg_replace(',(^<p[^>]*>|</p>$),Uims', '', propre($trad));
1828
+                    $mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1829
+                    if ($mode === 'div') {
1830
+                        $trad = rtrim($trad) . "\n\n";
1831
+                    }
1832
+                    $trad = code_echappement($trad, 'multi', false, $mode);
1833
+                    $trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
1834
+                    if (lang_dir($l) !== lang_dir($lang)) {
1835
+                        $trad = str_replace("'", '"', inserer_attribut($trad, 'dir', lang_dir($l)));
1836
+                    }
1837
+                    if (!$options['echappe_span']) {
1838
+                        $trad = echappe_retour($trad, 'multi');
1839
+                    }
1840
+                }
1841
+            }
1842
+            $letexte = str_replace($reg[0], $trad, $letexte);
1843
+        }
1844
+    }
1845
+
1846
+    return $letexte;
1847 1847
 }
1848 1848
 
1849 1849
 /**
@@ -1859,21 +1859,21 @@  discard block
 block discarded – undo
1859 1859
  *     Peut retourner un code de langue vide, lorsqu'un texte par défaut est indiqué.
1860 1860
  **/
1861 1861
 function extraire_trads($bloc) {
1862
-	$trads = [];
1863
-	$lang = '';
1862
+    $trads = [];
1863
+    $lang = '';
1864 1864
 // ce reg fait planter l'analyse multi s'il y a de l'{italique} dans le champ
1865 1865
 //	while (preg_match("/^(.*?)[{\[]([a-z_]+)[}\]]/siS", $bloc, $regs)) {
1866
-	while (preg_match('/^(.*?)[\[]([a-z_]+)[\]]/siS', $bloc, $regs)) {
1867
-		$texte = trim($regs[1]);
1868
-		if ($texte or $lang) {
1869
-			$trads[$lang] = $texte;
1870
-		}
1871
-		$bloc = substr($bloc, strlen($regs[0]));
1872
-		$lang = $regs[2];
1873
-	}
1874
-	$trads[$lang] = $bloc;
1866
+    while (preg_match('/^(.*?)[\[]([a-z_]+)[\]]/siS', $bloc, $regs)) {
1867
+        $texte = trim($regs[1]);
1868
+        if ($texte or $lang) {
1869
+            $trads[$lang] = $texte;
1870
+        }
1871
+        $bloc = substr($bloc, strlen($regs[0]));
1872
+        $lang = $regs[2];
1873
+    }
1874
+    $trads[$lang] = $bloc;
1875 1875
 
1876
-	return $trads;
1876
+    return $trads;
1877 1877
 }
1878 1878
 
1879 1879
 
@@ -1884,7 +1884,7 @@  discard block
 block discarded – undo
1884 1884
  * @return string L'initiale en majuscule
1885 1885
  */
1886 1886
 function filtre_initiale($nom) {
1887
-	return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1);
1887
+    return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1);
1888 1888
 }
1889 1889
 
1890 1890
 
@@ -1929,33 +1929,33 @@  discard block
 block discarded – undo
1929 1929
  *      - null (interne) : si on empile
1930 1930
  **/
1931 1931
 function unique($donnee, $famille = '', $cpt = false) {
1932
-	static $mem = [];
1933
-	// permettre de vider la pile et de la restaurer
1934
-	// pour le calcul de introduction...
1935
-	if ($famille == '_spip_raz_') {
1936
-		$tmp = $mem;
1937
-		$mem = [];
1938
-
1939
-		return $tmp;
1940
-	} elseif ($famille == '_spip_set_') {
1941
-		$mem = $donnee;
1942
-
1943
-		return;
1944
-	}
1945
-	// eviter une notice
1946
-	if (!isset($mem[$famille])) {
1947
-		$mem[$famille] = [];
1948
-	}
1949
-	if ($cpt) {
1950
-		return is_countable($mem[$famille]) ? count($mem[$famille]) : 0;
1951
-	}
1952
-	// eviter une notice
1953
-	if (!isset($mem[$famille][$donnee])) {
1954
-		$mem[$famille][$donnee] = 0;
1955
-	}
1956
-	if (!($mem[$famille][$donnee]++)) {
1957
-		return $donnee;
1958
-	}
1932
+    static $mem = [];
1933
+    // permettre de vider la pile et de la restaurer
1934
+    // pour le calcul de introduction...
1935
+    if ($famille == '_spip_raz_') {
1936
+        $tmp = $mem;
1937
+        $mem = [];
1938
+
1939
+        return $tmp;
1940
+    } elseif ($famille == '_spip_set_') {
1941
+        $mem = $donnee;
1942
+
1943
+        return;
1944
+    }
1945
+    // eviter une notice
1946
+    if (!isset($mem[$famille])) {
1947
+        $mem[$famille] = [];
1948
+    }
1949
+    if ($cpt) {
1950
+        return is_countable($mem[$famille]) ? count($mem[$famille]) : 0;
1951
+    }
1952
+    // eviter une notice
1953
+    if (!isset($mem[$famille][$donnee])) {
1954
+        $mem[$famille][$donnee] = 0;
1955
+    }
1956
+    if (!($mem[$famille][$donnee]++)) {
1957
+        return $donnee;
1958
+    }
1959 1959
 }
1960 1960
 
1961 1961
 
@@ -1985,20 +1985,20 @@  discard block
 block discarded – undo
1985 1985
  *     Une des valeurs en fonction du compteur.
1986 1986
  **/
1987 1987
 function alterner($i, ...$args) {
1988
-	// recuperer les arguments (attention fonctions un peu space)
1989
-	$num = count($args);
1988
+    // recuperer les arguments (attention fonctions un peu space)
1989
+    $num = count($args);
1990 1990
 
1991
-	if ($num === 1 && is_array($args[0])) {
1992
-		// un tableau de valeur dont les cles sont numerotees de 0 a num
1993
-		$args = array_values($args[0]);
1994
-		$num = count($args);
1995
-	}
1991
+    if ($num === 1 && is_array($args[0])) {
1992
+        // un tableau de valeur dont les cles sont numerotees de 0 a num
1993
+        $args = array_values($args[0]);
1994
+        $num = count($args);
1995
+    }
1996 1996
 
1997
-	// un index compris entre 0 et num exclus
1998
-	$i = ((intval($i) - 1) % $num); // dans ]-$num;$num[
1999
-	$i = ($i + $num) % $num; // dans [0;$num[
2000
-	// renvoyer le i-ieme argument, modulo le nombre d'arguments
2001
-	return $args[$i];
1997
+    // un index compris entre 0 et num exclus
1998
+    $i = ((intval($i) - 1) % $num); // dans ]-$num;$num[
1999
+    $i = ($i + $num) % $num; // dans [0;$num[
2000
+    // renvoyer le i-ieme argument, modulo le nombre d'arguments
2001
+    return $args[$i];
2002 2002
 }
2003 2003
 
2004 2004
 
@@ -2024,51 +2024,51 @@  discard block
 block discarded – undo
2024 2024
  *     - null lorsque l’attribut n’existe pas.
2025 2025
  **/
2026 2026
 function extraire_attribut($balise, $attribut, $complet = false) {
2027
-	if (is_array($balise)) {
2028
-		array_walk(
2029
-			$balise,
2030
-			function (&$a, $key, $t) {
2031
-				$a = extraire_attribut($a, $t);
2032
-			},
2033
-			$attribut
2034
-		);
2035
-
2036
-		return $balise;
2037
-	}
2038
-	if (
2039
-		$balise
2040
-		&& preg_match(
2041
-			',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
2042
-			. $attribut
2043
-			. '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
2044
-			$balise,
2045
-			$r
2046
-		)
2047
-	) {
2048
-		if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) {
2049
-			$r[4] = substr($r[3], 1, -1);
2050
-			$r[3] = $r[3][0];
2051
-		} elseif ($r[3] !== '') {
2052
-			$r[4] = $r[3];
2053
-			$r[3] = '';
2054
-		} else {
2055
-			$r[4] = trim($r[2]);
2056
-		}
2057
-		$att = $r[4];
2058
-		if (strpos($att, '&#') !== false) {
2059
-			$att = str_replace(['&#039;', '&#39;', '&#034;', '&#34;'], ["'", "'", '"', '"'], $att);
2060
-		}
2061
-		$att = filtrer_entites($att);
2062
-	} else {
2063
-		$att = null;
2064
-		$r = [];
2065
-	}
2066
-
2067
-	if ($complet) {
2068
-		return [$att, $r];
2069
-	} else {
2070
-		return $att;
2071
-	}
2027
+    if (is_array($balise)) {
2028
+        array_walk(
2029
+            $balise,
2030
+            function (&$a, $key, $t) {
2031
+                $a = extraire_attribut($a, $t);
2032
+            },
2033
+            $attribut
2034
+        );
2035
+
2036
+        return $balise;
2037
+    }
2038
+    if (
2039
+        $balise
2040
+        && preg_match(
2041
+            ',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
2042
+            . $attribut
2043
+            . '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
2044
+            $balise,
2045
+            $r
2046
+        )
2047
+    ) {
2048
+        if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) {
2049
+            $r[4] = substr($r[3], 1, -1);
2050
+            $r[3] = $r[3][0];
2051
+        } elseif ($r[3] !== '') {
2052
+            $r[4] = $r[3];
2053
+            $r[3] = '';
2054
+        } else {
2055
+            $r[4] = trim($r[2]);
2056
+        }
2057
+        $att = $r[4];
2058
+        if (strpos($att, '&#') !== false) {
2059
+            $att = str_replace(['&#039;', '&#39;', '&#034;', '&#34;'], ["'", "'", '"', '"'], $att);
2060
+        }
2061
+        $att = filtrer_entites($att);
2062
+    } else {
2063
+        $att = null;
2064
+        $r = [];
2065
+    }
2066
+
2067
+    if ($complet) {
2068
+        return [$att, $r];
2069
+    } else {
2070
+        return $att;
2071
+    }
2072 2072
 }
2073 2073
 
2074 2074
 /**
@@ -2101,41 +2101,41 @@  discard block
 block discarded – undo
2101 2101
  **/
2102 2102
 function inserer_attribut(?string $balise, string $attribut, string $val, bool $proteger = true, bool $vider = false): string {
2103 2103
 
2104
-	if ($balise === null or $balise === '') {
2105
-		return '';
2106
-	}
2104
+    if ($balise === null or $balise === '') {
2105
+        return '';
2106
+    }
2107 2107
 
2108
-	// preparer l'attribut
2109
-	// supprimer les &nbsp; etc mais pas les balises html
2110
-	// qui ont un sens dans un attribut value d'un input
2111
-	if ($proteger) {
2112
-		$val = attribut_html($val, false);
2113
-	}
2108
+    // preparer l'attribut
2109
+    // supprimer les &nbsp; etc mais pas les balises html
2110
+    // qui ont un sens dans un attribut value d'un input
2111
+    if ($proteger) {
2112
+        $val = attribut_html($val, false);
2113
+    }
2114 2114
 
2115
-	// echapper les ' pour eviter tout bug
2116
-	$val = str_replace("'", '&#039;', $val);
2117
-	if ($vider and strlen($val) === 0) {
2118
-		$insert = '';
2119
-	} else {
2120
-		$insert = " $attribut='$val'";
2121
-	}
2115
+    // echapper les ' pour eviter tout bug
2116
+    $val = str_replace("'", '&#039;', $val);
2117
+    if ($vider and strlen($val) === 0) {
2118
+        $insert = '';
2119
+    } else {
2120
+        $insert = " $attribut='$val'";
2121
+    }
2122 2122
 
2123
-	[$old, $r] = extraire_attribut($balise, $attribut, true);
2123
+    [$old, $r] = extraire_attribut($balise, $attribut, true);
2124 2124
 
2125
-	if ($old !== null) {
2126
-		// Remplacer l'ancien attribut du meme nom
2127
-		$balise = $r[1] . $insert . $r[5];
2128
-	} else {
2129
-		// preferer une balise " />" (comme <img />)
2130
-		if (preg_match(',/>,', $balise)) {
2131
-			$balise = preg_replace(',\s?/>,S', $insert . ' />', $balise, 1);
2132
-		} // sinon une balise <a ...> ... </a>
2133
-		else {
2134
-			$balise = preg_replace(',\s?>,S', $insert . '>', $balise, 1);
2135
-		}
2136
-	}
2125
+    if ($old !== null) {
2126
+        // Remplacer l'ancien attribut du meme nom
2127
+        $balise = $r[1] . $insert . $r[5];
2128
+    } else {
2129
+        // preferer une balise " />" (comme <img />)
2130
+        if (preg_match(',/>,', $balise)) {
2131
+            $balise = preg_replace(',\s?/>,S', $insert . ' />', $balise, 1);
2132
+        } // sinon une balise <a ...> ... </a>
2133
+        else {
2134
+            $balise = preg_replace(',\s?>,S', $insert . '>', $balise, 1);
2135
+        }
2136
+    }
2137 2137
 
2138
-	return $balise;
2138
+    return $balise;
2139 2139
 }
2140 2140
 
2141 2141
 /**
@@ -2153,7 +2153,7 @@  discard block
 block discarded – undo
2153 2153
  * @return string Code HTML sans l'attribut
2154 2154
  **/
2155 2155
 function vider_attribut(?string $balise, string $attribut): string {
2156
-	return inserer_attribut($balise, $attribut, '', false, true);
2156
+    return inserer_attribut($balise, $attribut, '', false, true);
2157 2157
 }
2158 2158
 
2159 2159
 /**
@@ -2165,53 +2165,53 @@  discard block
 block discarded – undo
2165 2165
  * @return string
2166 2166
  */
2167 2167
 function modifier_class($balise, $class, $operation = 'ajouter') {
2168
-	if (is_string($class)) {
2169
-		$class = explode(' ', trim($class));
2170
-	}
2171
-	$class = array_filter($class);
2172
-	$class = array_unique($class);
2173
-	if (!$class) {
2174
-		return $balise;
2175
-	}
2176
-
2177
-	// si la ou les classes ont des caracteres invalides on ne fait rien
2178
-	if (preg_match(',[^\w-],', implode('', $class))) {
2179
-		return $balise;
2180
-	}
2181
-
2182
-	$class_courante = extraire_attribut($balise, 'class');
2183
-	$class_new = $class_courante;
2184
-	foreach ($class as $c) {
2185
-		$is_class_presente = false;
2186
-		if (
2187
-			$class_courante
2188
-			and strpos($class_courante, (string) $c) !== false
2189
-			and preg_match('/(^|\s)' . preg_quote($c) . '($|\s)/', $class_courante)
2190
-		) {
2191
-			$is_class_presente = true;
2192
-		}
2193
-		if (
2194
-			in_array($operation, ['ajouter', 'commuter'])
2195
-			and !$is_class_presente
2196
-		) {
2197
-			$class_new = ltrim(rtrim($class_new ?? '') . ' ' . $c);
2198
-		} elseif (
2199
-			in_array($operation, ['supprimer', 'commuter'])
2200
-			and $is_class_presente
2201
-		) {
2202
-			$class_new = trim(preg_replace('/(^|\s)' . preg_quote($c) . '($|\s)/', "\\1", $class_new));
2203
-		}
2204
-	}
2205
-
2206
-	if ($class_new !== $class_courante) {
2207
-		if (strlen($class_new)) {
2208
-			$balise = inserer_attribut($balise, 'class', $class_new);
2209
-		} elseif ($class_courante) {
2210
-			$balise = vider_attribut($balise, 'class');
2211
-		}
2212
-	}
2213
-
2214
-	return $balise;
2168
+    if (is_string($class)) {
2169
+        $class = explode(' ', trim($class));
2170
+    }
2171
+    $class = array_filter($class);
2172
+    $class = array_unique($class);
2173
+    if (!$class) {
2174
+        return $balise;
2175
+    }
2176
+
2177
+    // si la ou les classes ont des caracteres invalides on ne fait rien
2178
+    if (preg_match(',[^\w-],', implode('', $class))) {
2179
+        return $balise;
2180
+    }
2181
+
2182
+    $class_courante = extraire_attribut($balise, 'class');
2183
+    $class_new = $class_courante;
2184
+    foreach ($class as $c) {
2185
+        $is_class_presente = false;
2186
+        if (
2187
+            $class_courante
2188
+            and strpos($class_courante, (string) $c) !== false
2189
+            and preg_match('/(^|\s)' . preg_quote($c) . '($|\s)/', $class_courante)
2190
+        ) {
2191
+            $is_class_presente = true;
2192
+        }
2193
+        if (
2194
+            in_array($operation, ['ajouter', 'commuter'])
2195
+            and !$is_class_presente
2196
+        ) {
2197
+            $class_new = ltrim(rtrim($class_new ?? '') . ' ' . $c);
2198
+        } elseif (
2199
+            in_array($operation, ['supprimer', 'commuter'])
2200
+            and $is_class_presente
2201
+        ) {
2202
+            $class_new = trim(preg_replace('/(^|\s)' . preg_quote($c) . '($|\s)/', "\\1", $class_new));
2203
+        }
2204
+    }
2205
+
2206
+    if ($class_new !== $class_courante) {
2207
+        if (strlen($class_new)) {
2208
+            $balise = inserer_attribut($balise, 'class', $class_new);
2209
+        } elseif ($class_courante) {
2210
+            $balise = vider_attribut($balise, 'class');
2211
+        }
2212
+    }
2213
+
2214
+    return $balise;
2215 2215
 }
2216 2216
 
2217 2217
 /**
@@ -2221,7 +2221,7 @@  discard block
 block discarded – undo
2221 2221
  * @return string
2222 2222
  */
2223 2223
 function ajouter_class($balise, $class) {
2224
-	return modifier_class($balise, $class, 'ajouter');
2224
+    return modifier_class($balise, $class, 'ajouter');
2225 2225
 }
2226 2226
 
2227 2227
 /**
@@ -2231,7 +2231,7 @@  discard block
 block discarded – undo
2231 2231
  * @return string
2232 2232
  */
2233 2233
 function supprimer_class($balise, $class) {
2234
-	return modifier_class($balise, $class, 'supprimer');
2234
+    return modifier_class($balise, $class, 'supprimer');
2235 2235
 }
2236 2236
 
2237 2237
 /**
@@ -2242,7 +2242,7 @@  discard block
 block discarded – undo
2242 2242
  * @return string
2243 2243
  */
2244 2244
 function commuter_class($balise, $class) {
2245
-	return modifier_class($balise, $class, 'commuter');
2245
+    return modifier_class($balise, $class, 'commuter');
2246 2246
 }
2247 2247
 
2248 2248
 /**
@@ -2253,19 +2253,19 @@  discard block
 block discarded – undo
2253 2253
  * @return string
2254 2254
  */
2255 2255
 function tester_config($id, $mode = '') {
2256
-	include_spip('action/inscrire_auteur');
2256
+    include_spip('action/inscrire_auteur');
2257 2257
 
2258
-	return tester_statut_inscription($mode, $id);
2258
+    return tester_statut_inscription($mode, $id);
2259 2259
 }
2260 2260
 
2261 2261
 //
2262 2262
 // Quelques fonctions de calcul arithmetique
2263 2263
 //
2264 2264
 function floatstr($a) {
2265
- return str_replace(',', '.', (string)floatval($a));
2265
+    return str_replace(',', '.', (string)floatval($a));
2266 2266
 }
2267 2267
 function strize($f, $a, $b) {
2268
- return floatstr($f(floatstr($a), floatstr($b)));
2268
+    return floatstr($f(floatstr($a), floatstr($b)));
2269 2269
 }
2270 2270
 
2271 2271
 /**
@@ -2284,7 +2284,7 @@  discard block
 block discarded – undo
2284 2284
  * @return int $a+$b
2285 2285
  **/
2286 2286
 function plus($a, $b) {
2287
-	return $a + $b;
2287
+    return $a + $b;
2288 2288
 }
2289 2289
 function strplus($a, $b) {
2290 2290
 return strize('plus', $a, $b);
@@ -2305,7 +2305,7 @@  discard block
 block discarded – undo
2305 2305
  * @return int $a-$b
2306 2306
  **/
2307 2307
 function moins($a, $b) {
2308
-	return $a - $b;
2308
+    return $a - $b;
2309 2309
 }
2310 2310
 function strmoins($a, $b) {
2311 2311
 return strize('moins', $a, $b);
@@ -2328,7 +2328,7 @@  discard block
 block discarded – undo
2328 2328
  * @return int $a*$b
2329 2329
  **/
2330 2330
 function mult($a, $b) {
2331
-	return $a * $b;
2331
+    return $a * $b;
2332 2332
 }
2333 2333
 function strmult($a, $b) {
2334 2334
 return strize('mult', $a, $b);
@@ -2351,7 +2351,7 @@  discard block
 block discarded – undo
2351 2351
  * @return int $a/$b (ou 0 si $b est nul)
2352 2352
  **/
2353 2353
 function div($a, $b) {
2354
-	return $b ? $a / $b : 0;
2354
+    return $b ? $a / $b : 0;
2355 2355
 }
2356 2356
 function strdiv($a, $b) {
2357 2357
 return strize('div', $a, $b);
@@ -2375,7 +2375,7 @@  discard block
 block discarded – undo
2375 2375
  * @return int ($nb % $mod) + $add
2376 2376
  **/
2377 2377
 function modulo($nb, $mod, $add = 0) {
2378
-	return ($mod ? $nb % $mod : 0) + $add;
2378
+    return ($mod ? $nb % $mod : 0) + $add;
2379 2379
 }
2380 2380
 
2381 2381
 
@@ -2390,26 +2390,26 @@  discard block
 block discarded – undo
2390 2390
  *      - true sinon
2391 2391
  **/
2392 2392
 function nom_acceptable($nom) {
2393
-	$remp2 = [];
2394
-	$remp1 = [];
2395
-	if (!is_string($nom)) {
2396
-		return false;
2397
-	}
2398
-	if (!defined('_TAGS_NOM_AUTEUR')) {
2399
-		define('_TAGS_NOM_AUTEUR', '');
2400
-	}
2401
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2402
-	foreach ($tags_acceptes as $tag) {
2403
-		if (strlen($tag)) {
2404
-			$remp1[] = '<' . trim($tag) . '>';
2405
-			$remp1[] = '</' . trim($tag) . '>';
2406
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2407
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2408
-		}
2409
-	}
2410
-	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2411
-
2412
-	return str_replace('&lt;', '<', $v_nom) == $nom;
2393
+    $remp2 = [];
2394
+    $remp1 = [];
2395
+    if (!is_string($nom)) {
2396
+        return false;
2397
+    }
2398
+    if (!defined('_TAGS_NOM_AUTEUR')) {
2399
+        define('_TAGS_NOM_AUTEUR', '');
2400
+    }
2401
+    $tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2402
+    foreach ($tags_acceptes as $tag) {
2403
+        if (strlen($tag)) {
2404
+            $remp1[] = '<' . trim($tag) . '>';
2405
+            $remp1[] = '</' . trim($tag) . '>';
2406
+            $remp2[] = '\x60' . trim($tag) . '\x61';
2407
+            $remp2[] = '\x60/' . trim($tag) . '\x61';
2408
+        }
2409
+    }
2410
+    $v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2411
+
2412
+    return str_replace('&lt;', '<', $v_nom) == $nom;
2413 2413
 }
2414 2414
 
2415 2415
 
@@ -2425,14 +2425,14 @@  discard block
 block discarded – undo
2425 2425
  *      - renvoie un tableau si l'entree est un tableau
2426 2426
  **/
2427 2427
 function email_valide($adresses) {
2428
-	if (is_array($adresses)) {
2429
-		$adresses = array_map('email_valide', $adresses);
2430
-		$adresses = array_filter($adresses);
2431
-		return $adresses;
2432
-	}
2428
+    if (is_array($adresses)) {
2429
+        $adresses = array_map('email_valide', $adresses);
2430
+        $adresses = array_filter($adresses);
2431
+        return $adresses;
2432
+    }
2433 2433
 
2434
-	$email_valide = charger_fonction('email_valide', 'inc');
2435
-	return $email_valide($adresses);
2434
+    $email_valide = charger_fonction('email_valide', 'inc');
2435
+    return $email_valide($adresses);
2436 2436
 }
2437 2437
 
2438 2438
 /**
@@ -2446,29 +2446,29 @@  discard block
 block discarded – undo
2446 2446
  * @return string Texte
2447 2447
  **/
2448 2448
 function afficher_enclosures($tags) {
2449
-	$s = [];
2450
-	foreach (extraire_balises($tags, 'a') as $tag) {
2451
-		if (
2452
-			extraire_attribut($tag, 'rel') == 'enclosure'
2453
-			and $t = extraire_attribut($tag, 'href')
2454
-		) {
2455
-			$s[] = preg_replace(
2456
-				',>[^<]+</a>,S',
2457
-				'>'
2458
-				. http_img_pack(
2459
-					'attachment-16.png',
2460
-					$t,
2461
-					'',
2462
-					$t,
2463
-					['utiliser_suffixe_size' => true]
2464
-				)
2465
-				. '</a>',
2466
-				$tag
2467
-			);
2468
-		}
2469
-	}
2470
-
2471
-	return join('&nbsp;', $s);
2449
+    $s = [];
2450
+    foreach (extraire_balises($tags, 'a') as $tag) {
2451
+        if (
2452
+            extraire_attribut($tag, 'rel') == 'enclosure'
2453
+            and $t = extraire_attribut($tag, 'href')
2454
+        ) {
2455
+            $s[] = preg_replace(
2456
+                ',>[^<]+</a>,S',
2457
+                '>'
2458
+                . http_img_pack(
2459
+                    'attachment-16.png',
2460
+                    $t,
2461
+                    '',
2462
+                    $t,
2463
+                    ['utiliser_suffixe_size' => true]
2464
+                )
2465
+                . '</a>',
2466
+                $tag
2467
+            );
2468
+        }
2469
+    }
2470
+
2471
+    return join('&nbsp;', $s);
2472 2472
 }
2473 2473
 
2474 2474
 /**
@@ -2483,15 +2483,15 @@  discard block
 block discarded – undo
2483 2483
  * @return string Liens trouvés
2484 2484
  **/
2485 2485
 function afficher_tags($tags, $rels = 'tag,directory') {
2486
-	$s = [];
2487
-	foreach (extraire_balises($tags, 'a') as $tag) {
2488
-		$rel = extraire_attribut($tag, 'rel');
2489
-		if (strstr(",$rels,", (string) ",$rel,")) {
2490
-			$s[] = $tag;
2491
-		}
2492
-	}
2486
+    $s = [];
2487
+    foreach (extraire_balises($tags, 'a') as $tag) {
2488
+        $rel = extraire_attribut($tag, 'rel');
2489
+        if (strstr(",$rels,", (string) ",$rel,")) {
2490
+            $s[] = $tag;
2491
+        }
2492
+    }
2493 2493
 
2494
-	return join(', ', $s);
2494
+    return join(', ', $s);
2495 2495
 }
2496 2496
 
2497 2497
 
@@ -2513,21 +2513,21 @@  discard block
 block discarded – undo
2513 2513
  * @return string Tag HTML `<a>` avec microformat.
2514 2514
  **/
2515 2515
 function enclosure2microformat($e) {
2516
-	if (!$url = filtrer_entites(extraire_attribut($e, 'url') ?? '')) {
2517
-		$url = filtrer_entites(extraire_attribut($e, 'href') ?? '');
2518
-	}
2519
-	$type = extraire_attribut($e, 'type');
2520
-	if (!$length = extraire_attribut($e, 'length')) {
2521
-		# <media:content : longeur dans fileSize. On tente.
2522
-		$length = extraire_attribut($e, 'fileSize');
2523
-	}
2524
-	$fichier = basename($url);
2516
+    if (!$url = filtrer_entites(extraire_attribut($e, 'url') ?? '')) {
2517
+        $url = filtrer_entites(extraire_attribut($e, 'href') ?? '');
2518
+    }
2519
+    $type = extraire_attribut($e, 'type');
2520
+    if (!$length = extraire_attribut($e, 'length')) {
2521
+        # <media:content : longeur dans fileSize. On tente.
2522
+        $length = extraire_attribut($e, 'fileSize');
2523
+    }
2524
+    $fichier = basename($url);
2525 2525
 
2526
-	return '<a rel="enclosure"'
2527
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2528
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2529
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2530
-	. '>' . $fichier . '</a>';
2526
+    return '<a rel="enclosure"'
2527
+    . ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2528
+    . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2529
+    . ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2530
+    . '>' . $fichier . '</a>';
2531 2531
 }
2532 2532
 
2533 2533
 /**
@@ -2545,24 +2545,24 @@  discard block
 block discarded – undo
2545 2545
  * @return string Tags RSS `<enclosure>`.
2546 2546
  **/
2547 2547
 function microformat2enclosure($tags) {
2548
-	$enclosures = [];
2549
-	foreach (extraire_balises($tags, 'a') as $e) {
2550
-		if (extraire_attribut($e, 'rel') == 'enclosure') {
2551
-			$url = filtrer_entites(extraire_attribut($e, 'href'));
2552
-			$type = extraire_attribut($e, 'type');
2553
-			if (!$length = intval(extraire_attribut($e, 'title'))) {
2554
-				$length = intval(extraire_attribut($e, 'length'));
2555
-			} # vieux data
2556
-			$fichier = basename($url);
2557
-			$enclosures[] = '<enclosure'
2558
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2559
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2560
-				. ($length ? ' length="' . $length . '"' : '')
2561
-				. ' />';
2562
-		}
2563
-	}
2548
+    $enclosures = [];
2549
+    foreach (extraire_balises($tags, 'a') as $e) {
2550
+        if (extraire_attribut($e, 'rel') == 'enclosure') {
2551
+            $url = filtrer_entites(extraire_attribut($e, 'href'));
2552
+            $type = extraire_attribut($e, 'type');
2553
+            if (!$length = intval(extraire_attribut($e, 'title'))) {
2554
+                $length = intval(extraire_attribut($e, 'length'));
2555
+            } # vieux data
2556
+            $fichier = basename($url);
2557
+            $enclosures[] = '<enclosure'
2558
+                . ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2559
+                . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2560
+                . ($length ? ' length="' . $length . '"' : '')
2561
+                . ' />';
2562
+        }
2563
+    }
2564 2564
 
2565
-	return join("\n", $enclosures);
2565
+    return join("\n", $enclosures);
2566 2566
 }
2567 2567
 
2568 2568
 
@@ -2578,16 +2578,16 @@  discard block
 block discarded – undo
2578 2578
  * @return string Tags RSS Atom `<dc:subject>`.
2579 2579
  **/
2580 2580
 function tags2dcsubject($tags) {
2581
-	$subjects = '';
2582
-	foreach (extraire_balises($tags, 'a') as $e) {
2583
-		if (extraire_attribut($e, 'rel') == 'tag') {
2584
-			$subjects .= '<dc:subject>'
2585
-				. texte_backend(textebrut($e))
2586
-				. '</dc:subject>' . "\n";
2587
-		}
2588
-	}
2581
+    $subjects = '';
2582
+    foreach (extraire_balises($tags, 'a') as $e) {
2583
+        if (extraire_attribut($e, 'rel') == 'tag') {
2584
+            $subjects .= '<dc:subject>'
2585
+                . texte_backend(textebrut($e))
2586
+                . '</dc:subject>' . "\n";
2587
+        }
2588
+    }
2589 2589
 
2590
-	return $subjects;
2590
+    return $subjects;
2591 2591
 }
2592 2592
 
2593 2593
 /**
@@ -2616,27 +2616,27 @@  discard block
 block discarded – undo
2616 2616
  *     - Tableau de résultats, si tableau en entrée.
2617 2617
  **/
2618 2618
 function extraire_balise($texte, $tag = 'a') {
2619
-	if (is_array($texte)) {
2620
-		array_walk(
2621
-			$texte,
2622
-			function (&$a, $key, $t) {
2623
-				$a = extraire_balise($a, $t);
2624
-			},
2625
-			$tag
2626
-		);
2627
-
2628
-		return $texte;
2629
-	}
2630
-
2631
-	if (
2632
-		preg_match(
2633
-			",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS",
2634
-			$texte,
2635
-			$regs
2636
-		)
2637
-	) {
2638
-		return $regs[0];
2639
-	}
2619
+    if (is_array($texte)) {
2620
+        array_walk(
2621
+            $texte,
2622
+            function (&$a, $key, $t) {
2623
+                $a = extraire_balise($a, $t);
2624
+            },
2625
+            $tag
2626
+        );
2627
+
2628
+        return $texte;
2629
+    }
2630
+
2631
+    if (
2632
+        preg_match(
2633
+            ",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS",
2634
+            $texte,
2635
+            $regs
2636
+        )
2637
+    ) {
2638
+        return $regs[0];
2639
+    }
2640 2640
 }
2641 2641
 
2642 2642
 /**
@@ -2664,30 +2664,30 @@  discard block
 block discarded – undo
2664 2664
  *     - Tableau de résultats, si tableau en entrée.
2665 2665
  **/
2666 2666
 function extraire_balises($texte, $tag = 'a') {
2667
-	if (is_array($texte)) {
2668
-		array_walk(
2669
-			$texte,
2670
-			function (&$a, $key, $t) {
2671
-				$a = extraire_balises($a, $t);
2672
-			},
2673
-			$tag
2674
-		);
2675
-
2676
-		return $texte;
2677
-	}
2678
-
2679
-	if (
2680
-		preg_match_all(
2681
-			",<{$tag}\b[^>]*(/>|>.*</{$tag}\b[^>]*>|>),UimsS",
2682
-			$texte,
2683
-			$regs,
2684
-			PREG_PATTERN_ORDER
2685
-		)
2686
-	) {
2687
-		return $regs[0];
2688
-	} else {
2689
-		return [];
2690
-	}
2667
+    if (is_array($texte)) {
2668
+        array_walk(
2669
+            $texte,
2670
+            function (&$a, $key, $t) {
2671
+                $a = extraire_balises($a, $t);
2672
+            },
2673
+            $tag
2674
+        );
2675
+
2676
+        return $texte;
2677
+    }
2678
+
2679
+    if (
2680
+        preg_match_all(
2681
+            ",<{$tag}\b[^>]*(/>|>.*</{$tag}\b[^>]*>|>),UimsS",
2682
+            $texte,
2683
+            $regs,
2684
+            PREG_PATTERN_ORDER
2685
+        )
2686
+    ) {
2687
+        return $regs[0];
2688
+    } else {
2689
+        return [];
2690
+    }
2691 2691
 }
2692 2692
 
2693 2693
 /**
@@ -2716,11 +2716,11 @@  discard block
 block discarded – undo
2716 2716
  *     - `$def` si on n'a pas transmis de tableau
2717 2717
  **/
2718 2718
 function in_any($val, $vals, $def = '') {
2719
-	if (!is_array($vals) and $vals and $v = unserialize($vals)) {
2720
-		$vals = $v;
2721
-	}
2719
+    if (!is_array($vals) and $vals and $v = unserialize($vals)) {
2720
+        $vals = $v;
2721
+    }
2722 2722
 
2723
-	return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : ''));
2723
+    return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : ''));
2724 2724
 }
2725 2725
 
2726 2726
 
@@ -2741,12 +2741,12 @@  discard block
 block discarded – undo
2741 2741
  *     Résultat du calcul
2742 2742
  **/
2743 2743
 function valeur_numerique($expr) {
2744
-	$a = 0;
2745
-	if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) {
2746
-		eval("\$a = $expr;");
2747
-	}
2744
+    $a = 0;
2745
+    if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) {
2746
+        eval("\$a = $expr;");
2747
+    }
2748 2748
 
2749
-	return intval($a);
2749
+    return intval($a);
2750 2750
 }
2751 2751
 
2752 2752
 /**
@@ -2765,7 +2765,7 @@  discard block
 block discarded – undo
2765 2765
  *      Retourne `$a*$b/$c`
2766 2766
  **/
2767 2767
 function regledetrois($a, $b, $c) {
2768
-	return round($a * $b / $c);
2768
+    return round($a * $b / $c);
2769 2769
 }
2770 2770
 
2771 2771
 
@@ -2788,79 +2788,79 @@  discard block
 block discarded – undo
2788 2788
  * @return string Suite de champs input hidden
2789 2789
  **/
2790 2790
 function form_hidden(?string $action = ''): string {
2791
-	$action ??= '';
2792
-
2793
-	$contexte = [];
2794
-	include_spip('inc/urls');
2795
-	if (
2796
-		$p = urls_decoder_url($action, '')
2797
-		and reset($p)
2798
-	) {
2799
-		$fond = array_shift($p);
2800
-		if ($fond != '404') {
2801
-			$contexte = array_shift($p);
2802
-			$contexte['page'] = $fond;
2803
-			$action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2804
-		}
2805
-	}
2806
-	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2807
-	if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
2808
-		unset($contexte['type']);
2809
-	}
2810
-	if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') or _DEFINIR_CONTEXTE_TYPE_PAGE) {
2811
-		unset($contexte['type-page']);
2812
-	}
2813
-
2814
-	// on va remplir un tableau de valeurs en prenant bien soin de ne pas
2815
-	// ecraser les elements de la forme mots[]=1&mots[]=2
2816
-	$values = [];
2817
-
2818
-	// d'abord avec celles de l'url
2819
-	if (false !== ($p = strpos($action, '?'))) {
2820
-		foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2821
-			$c = explode('=', $c, 2);
2822
-			$var = array_shift($c);
2823
-			$val = array_shift($c) ?? '';
2824
-			if ($var) {
2825
-				$val = rawurldecode($val);
2826
-				$var = rawurldecode($var); // decoder les [] eventuels
2827
-				if (preg_match(',\[\]$,S', $var)) {
2828
-					$values[] = [$var, $val];
2829
-				} else {
2830
-					if (!isset($values[$var])) {
2831
-						$values[$var] = [$var, $val];
2832
-					}
2833
-				}
2834
-			}
2835
-		}
2836
-	}
2837
-
2838
-	// ensuite avec celles du contexte, sans doublonner !
2839
-	foreach ($contexte as $var => $val) {
2840
-		if (preg_match(',\[\]$,S', $var)) {
2841
-			$values[] = [$var, $val];
2842
-		} else {
2843
-			if (!isset($values[$var])) {
2844
-				$values[$var] = [$var, $val];
2845
-			}
2846
-		}
2847
-	}
2848
-
2849
-	// puis on rassemble le tout
2850
-	$hidden = [];
2851
-	foreach ($values as $value) {
2852
-		[$var, $val] = $value;
2853
-		$hidden[] = '<input name="'
2854
-			. entites_html($var)
2855
-			. '"'
2856
-			. (is_null($val)
2857
-				? ''
2858
-				: ' value="' . entites_html($val) . '"'
2859
-			)
2860
-			. ' type="hidden"' . "\n/>";
2861
-	}
2862
-
2863
-	return join('', $hidden);
2791
+    $action ??= '';
2792
+
2793
+    $contexte = [];
2794
+    include_spip('inc/urls');
2795
+    if (
2796
+        $p = urls_decoder_url($action, '')
2797
+        and reset($p)
2798
+    ) {
2799
+        $fond = array_shift($p);
2800
+        if ($fond != '404') {
2801
+            $contexte = array_shift($p);
2802
+            $contexte['page'] = $fond;
2803
+            $action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2804
+        }
2805
+    }
2806
+    // defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2807
+    if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
2808
+        unset($contexte['type']);
2809
+    }
2810
+    if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') or _DEFINIR_CONTEXTE_TYPE_PAGE) {
2811
+        unset($contexte['type-page']);
2812
+    }
2813
+
2814
+    // on va remplir un tableau de valeurs en prenant bien soin de ne pas
2815
+    // ecraser les elements de la forme mots[]=1&mots[]=2
2816
+    $values = [];
2817
+
2818
+    // d'abord avec celles de l'url
2819
+    if (false !== ($p = strpos($action, '?'))) {
2820
+        foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2821
+            $c = explode('=', $c, 2);
2822
+            $var = array_shift($c);
2823
+            $val = array_shift($c) ?? '';
2824
+            if ($var) {
2825
+                $val = rawurldecode($val);
2826
+                $var = rawurldecode($var); // decoder les [] eventuels
2827
+                if (preg_match(',\[\]$,S', $var)) {
2828
+                    $values[] = [$var, $val];
2829
+                } else {
2830
+                    if (!isset($values[$var])) {
2831
+                        $values[$var] = [$var, $val];
2832
+                    }
2833
+                }
2834
+            }
2835
+        }
2836
+    }
2837
+
2838
+    // ensuite avec celles du contexte, sans doublonner !
2839
+    foreach ($contexte as $var => $val) {
2840
+        if (preg_match(',\[\]$,S', $var)) {
2841
+            $values[] = [$var, $val];
2842
+        } else {
2843
+            if (!isset($values[$var])) {
2844
+                $values[$var] = [$var, $val];
2845
+            }
2846
+        }
2847
+    }
2848
+
2849
+    // puis on rassemble le tout
2850
+    $hidden = [];
2851
+    foreach ($values as $value) {
2852
+        [$var, $val] = $value;
2853
+        $hidden[] = '<input name="'
2854
+            . entites_html($var)
2855
+            . '"'
2856
+            . (is_null($val)
2857
+                ? ''
2858
+                : ' value="' . entites_html($val) . '"'
2859
+            )
2860
+            . ' type="hidden"' . "\n/>";
2861
+    }
2862
+
2863
+    return join('', $hidden);
2864 2864
 }
2865 2865
 
2866 2866
 
@@ -2882,7 +2882,7 @@  discard block
 block discarded – undo
2882 2882
  *    - la première valeur du tableau sinon.
2883 2883
  **/
2884 2884
 function filtre_reset($array) {
2885
-	return !is_array($array) ? null : reset($array);
2885
+    return !is_array($array) ? null : reset($array);
2886 2886
 }
2887 2887
 
2888 2888
 /**
@@ -2903,7 +2903,7 @@  discard block
 block discarded – undo
2903 2903
  *    - la dernière valeur du tableau sinon.
2904 2904
  **/
2905 2905
 function filtre_end($array) {
2906
-	return !is_array($array) ? null : end($array);
2906
+    return !is_array($array) ? null : end($array);
2907 2907
 }
2908 2908
 
2909 2909
 /**
@@ -2923,11 +2923,11 @@  discard block
 block discarded – undo
2923 2923
  *
2924 2924
  **/
2925 2925
 function filtre_push($array, $val) {
2926
-	if (!is_array($array) or !array_push($array, $val)) {
2927
-		return '';
2928
-	}
2926
+    if (!is_array($array) or !array_push($array, $val)) {
2927
+        return '';
2928
+    }
2929 2929
 
2930
-	return $array;
2930
+    return $array;
2931 2931
 }
2932 2932
 
2933 2933
 /**
@@ -2946,7 +2946,7 @@  discard block
 block discarded – undo
2946 2946
  *     - `true` si la valeur existe dans le tableau, `false` sinon.
2947 2947
  **/
2948 2948
 function filtre_find($array, $val) {
2949
-	return (is_array($array) and in_array($val, $array));
2949
+    return (is_array($array) and in_array($val, $array));
2950 2950
 }
2951 2951
 
2952 2952
 
@@ -2963,13 +2963,13 @@  discard block
 block discarded – undo
2963 2963
  *     Contenu avec urls en absolus
2964 2964
  **/
2965 2965
 function urls_absolues_css($contenu, $source) {
2966
-	$path = suivre_lien(url_absolue($source), './');
2966
+    $path = suivre_lien(url_absolue($source), './');
2967 2967
 
2968
-	return preg_replace_callback(
2969
-		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2970
-		fn($x) => "url('" . suivre_lien($path, $x[1]) . "')",
2971
-		$contenu
2972
-	);
2968
+    return preg_replace_callback(
2969
+        ",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2970
+        fn($x) => "url('" . suivre_lien($path, $x[1]) . "')",
2971
+        $contenu
2972
+    );
2973 2973
 }
2974 2974
 
2975 2975
 
@@ -2998,119 +2998,119 @@  discard block
 block discarded – undo
2998 2998
  *     Chemin du fichier CSS inversé
2999 2999
  **/
3000 3000
 function direction_css($css, $voulue = '') {
3001
-	if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) {
3002
-		return $css;
3003
-	}
3004
-	include_spip('inc/lang');
3005
-	// si on a precise le sens voulu en argument, le prendre en compte
3006
-	if ($voulue = strtolower($voulue)) {
3007
-		if ($voulue != 'rtl' and $voulue != 'ltr') {
3008
-			$voulue = lang_dir($voulue);
3009
-		}
3010
-	} else {
3011
-		$voulue = lang_dir();
3012
-	}
3013
-
3014
-	$r = count($r) > 1;
3015
-	$right = $r ? 'left' : 'right'; // 'right' de la css lue en entree
3016
-	$dir = $r ? 'rtl' : 'ltr';
3017
-	$ndir = $r ? 'ltr' : 'rtl';
3018
-
3019
-	if ($voulue == $dir) {
3020
-		return $css;
3021
-	}
3022
-
3023
-	if (
3024
-		// url absolue
3025
-		preg_match(',^https?:,i', $css)
3026
-		// ou qui contient un ?
3027
-		or (($p = strpos($css, '?')) !== false)
3028
-	) {
3029
-		$distant = true;
3030
-		$cssf = parse_url($css);
3031
-		$cssf = $cssf['path'] . ($cssf['query'] ? '?' . $cssf['query'] : '');
3032
-		$cssf = preg_replace(',[?:&=],', '_', $cssf);
3033
-	} else {
3034
-		$distant = false;
3035
-		$cssf = $css;
3036
-		// 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
3037
-		//propose (rien a faire dans ce cas)
3038
-		$f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
3039
-		if (@file_exists($f)) {
3040
-			return $f;
3041
-		}
3042
-	}
3043
-
3044
-	// 2.
3045
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
3046
-	$f = $dir_var
3047
-		. preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
3048
-		. '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
3049
-
3050
-	// la css peut etre distante (url absolue !)
3051
-	if ($distant) {
3052
-		include_spip('inc/distant');
3053
-		$res = recuperer_url($css);
3054
-		if (!$res or !$contenu = $res['page']) {
3055
-			return $css;
3056
-		}
3057
-	} else {
3058
-		if (
3059
-			(@filemtime($f) > @filemtime($css))
3060
-			and (_VAR_MODE != 'recalcul')
3061
-		) {
3062
-			return $f;
3063
-		}
3064
-		if (!lire_fichier($css, $contenu)) {
3065
-			return $css;
3066
-		}
3067
-	}
3068
-
3069
-
3070
-	// Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands
3071
-	include_spip('lib/csstidy/class.csstidy');
3072
-	$parser = new csstidy();
3073
-	$parser->set_cfg('optimise_shorthands', 0);
3074
-	$parser->set_cfg('reverse_left_and_right', true);
3075
-	$parser->parse($contenu);
3076
-
3077
-	$contenu = $parser->print->plain();
3078
-
3079
-
3080
-	// reperer les @import auxquels il faut propager le direction_css
3081
-	preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs);
3082
-	$src = [];
3083
-	$src_direction_css = [];
3084
-	$src_faux_abs = [];
3085
-	$d = dirname($css);
3086
-	foreach ($regs[1] as $k => $import_css) {
3087
-		$css_direction = direction_css("$d/$import_css", $voulue);
3088
-		// si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue
3089
-		if (substr($css_direction, 0, strlen($d) + 1) == "$d/") {
3090
-			$css_direction = substr($css_direction, strlen($d) + 1);
3091
-		} // si la css_direction commence par $dir_var on la fait passer pour une absolue
3092
-		elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
3093
-			$css_direction = substr($css_direction, strlen($dir_var));
3094
-			$src_faux_abs['/@@@@@@/' . $css_direction] = $css_direction;
3095
-			$css_direction = '/@@@@@@/' . $css_direction;
3096
-		}
3097
-		$src[] = $regs[0][$k];
3098
-		$src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
3099
-	}
3100
-	$contenu = str_replace($src, $src_direction_css, $contenu);
3101
-
3102
-	$contenu = urls_absolues_css($contenu, $css);
3103
-
3104
-	// virer les fausses url absolues que l'on a mis dans les import
3105
-	if (count($src_faux_abs)) {
3106
-		$contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu);
3107
-	}
3108
-
3109
-	if (!ecrire_fichier($f, $contenu)) {
3110
-		return $css;
3111
-	}
3112
-
3113
-	return $f;
3001
+    if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) {
3002
+        return $css;
3003
+    }
3004
+    include_spip('inc/lang');
3005
+    // si on a precise le sens voulu en argument, le prendre en compte
3006
+    if ($voulue = strtolower($voulue)) {
3007
+        if ($voulue != 'rtl' and $voulue != 'ltr') {
3008
+            $voulue = lang_dir($voulue);
3009
+        }
3010
+    } else {
3011
+        $voulue = lang_dir();
3012
+    }
3013
+
3014
+    $r = count($r) > 1;
3015
+    $right = $r ? 'left' : 'right'; // 'right' de la css lue en entree
3016
+    $dir = $r ? 'rtl' : 'ltr';
3017
+    $ndir = $r ? 'ltr' : 'rtl';
3018
+
3019
+    if ($voulue == $dir) {
3020
+        return $css;
3021
+    }
3022
+
3023
+    if (
3024
+        // url absolue
3025
+        preg_match(',^https?:,i', $css)
3026
+        // ou qui contient un ?
3027
+        or (($p = strpos($css, '?')) !== false)
3028
+    ) {
3029
+        $distant = true;
3030
+        $cssf = parse_url($css);
3031
+        $cssf = $cssf['path'] . ($cssf['query'] ? '?' . $cssf['query'] : '');
3032
+        $cssf = preg_replace(',[?:&=],', '_', $cssf);
3033
+    } else {
3034
+        $distant = false;
3035
+        $cssf = $css;
3036
+        // 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
3037
+        //propose (rien a faire dans ce cas)
3038
+        $f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
3039
+        if (@file_exists($f)) {
3040
+            return $f;
3041
+        }
3042
+    }
3043
+
3044
+    // 2.
3045
+    $dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
3046
+    $f = $dir_var
3047
+        . preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
3048
+        . '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
3049
+
3050
+    // la css peut etre distante (url absolue !)
3051
+    if ($distant) {
3052
+        include_spip('inc/distant');
3053
+        $res = recuperer_url($css);
3054
+        if (!$res or !$contenu = $res['page']) {
3055
+            return $css;
3056
+        }
3057
+    } else {
3058
+        if (
3059
+            (@filemtime($f) > @filemtime($css))
3060
+            and (_VAR_MODE != 'recalcul')
3061
+        ) {
3062
+            return $f;
3063
+        }
3064
+        if (!lire_fichier($css, $contenu)) {
3065
+            return $css;
3066
+        }
3067
+    }
3068
+
3069
+
3070
+    // Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands
3071
+    include_spip('lib/csstidy/class.csstidy');
3072
+    $parser = new csstidy();
3073
+    $parser->set_cfg('optimise_shorthands', 0);
3074
+    $parser->set_cfg('reverse_left_and_right', true);
3075
+    $parser->parse($contenu);
3076
+
3077
+    $contenu = $parser->print->plain();
3078
+
3079
+
3080
+    // reperer les @import auxquels il faut propager le direction_css
3081
+    preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs);
3082
+    $src = [];
3083
+    $src_direction_css = [];
3084
+    $src_faux_abs = [];
3085
+    $d = dirname($css);
3086
+    foreach ($regs[1] as $k => $import_css) {
3087
+        $css_direction = direction_css("$d/$import_css", $voulue);
3088
+        // si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue
3089
+        if (substr($css_direction, 0, strlen($d) + 1) == "$d/") {
3090
+            $css_direction = substr($css_direction, strlen($d) + 1);
3091
+        } // si la css_direction commence par $dir_var on la fait passer pour une absolue
3092
+        elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
3093
+            $css_direction = substr($css_direction, strlen($dir_var));
3094
+            $src_faux_abs['/@@@@@@/' . $css_direction] = $css_direction;
3095
+            $css_direction = '/@@@@@@/' . $css_direction;
3096
+        }
3097
+        $src[] = $regs[0][$k];
3098
+        $src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
3099
+    }
3100
+    $contenu = str_replace($src, $src_direction_css, $contenu);
3101
+
3102
+    $contenu = urls_absolues_css($contenu, $css);
3103
+
3104
+    // virer les fausses url absolues que l'on a mis dans les import
3105
+    if (count($src_faux_abs)) {
3106
+        $contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu);
3107
+    }
3108
+
3109
+    if (!ecrire_fichier($f, $contenu)) {
3110
+        return $css;
3111
+    }
3112
+
3113
+    return $f;
3114 3114
 }
3115 3115
 
3116 3116
 
@@ -3133,46 +3133,46 @@  discard block
 block discarded – undo
3133 3133
  *     - Chemin ou URL du fichier CSS source sinon.
3134 3134
  **/
3135 3135
 function url_absolue_css($css) {
3136
-	if (!preg_match(',\.css$,i', $css, $r)) {
3137
-		return $css;
3138
-	}
3136
+    if (!preg_match(',\.css$,i', $css, $r)) {
3137
+        return $css;
3138
+    }
3139 3139
 
3140
-	$url_absolue_css = url_absolue($css);
3140
+    $url_absolue_css = url_absolue($css);
3141 3141
 
3142
-	$f = basename($css, '.css');
3143
-	$f = sous_repertoire(_DIR_VAR, 'cache-css')
3144
-		. preg_replace(',(.*?)(_rtl|_ltr)?$,', "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
3145
-		. '.css';
3142
+    $f = basename($css, '.css');
3143
+    $f = sous_repertoire(_DIR_VAR, 'cache-css')
3144
+        . preg_replace(',(.*?)(_rtl|_ltr)?$,', "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
3145
+        . '.css';
3146 3146
 
3147
-	if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
3148
-		return $f;
3149
-	}
3147
+    if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
3148
+        return $f;
3149
+    }
3150 3150
 
3151
-	if ($url_absolue_css == $css) {
3152
-		if (
3153
-			strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
3154
-			or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
3155
-		) {
3156
-			include_spip('inc/distant');
3157
-			$contenu = recuperer_url($css);
3158
-			$contenu = $contenu['page'] ?? '';
3159
-			if (!$contenu) {
3160
-				return $css;
3161
-			}
3162
-		}
3163
-	} elseif (!lire_fichier($css, $contenu)) {
3164
-		return $css;
3165
-	}
3151
+    if ($url_absolue_css == $css) {
3152
+        if (
3153
+            strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
3154
+            or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
3155
+        ) {
3156
+            include_spip('inc/distant');
3157
+            $contenu = recuperer_url($css);
3158
+            $contenu = $contenu['page'] ?? '';
3159
+            if (!$contenu) {
3160
+                return $css;
3161
+            }
3162
+        }
3163
+    } elseif (!lire_fichier($css, $contenu)) {
3164
+        return $css;
3165
+    }
3166 3166
 
3167
-	// passer les url relatives a la css d'origine en url absolues
3168
-	$contenu = urls_absolues_css($contenu, $css);
3167
+    // passer les url relatives a la css d'origine en url absolues
3168
+    $contenu = urls_absolues_css($contenu, $css);
3169 3169
 
3170
-	// ecrire la css
3171
-	if (!ecrire_fichier($f, $contenu)) {
3172
-		return $css;
3173
-	}
3170
+    // ecrire la css
3171
+    if (!ecrire_fichier($f, $contenu)) {
3172
+        return $css;
3173
+    }
3174 3174
 
3175
-	return $f;
3175
+    return $f;
3176 3176
 }
3177 3177
 
3178 3178
 
@@ -3206,24 +3206,24 @@  discard block
 block discarded – undo
3206 3206
  *     Valeur trouvée ou valeur par défaut.
3207 3207
  **/
3208 3208
 function table_valeur($table, $cle, $defaut = '', $conserver_null = false) {
3209
-	foreach (explode('/', $cle) as $k) {
3210
-		$table = (is_string($table) ? @unserialize($table) : $table);
3209
+    foreach (explode('/', $cle) as $k) {
3210
+        $table = (is_string($table) ? @unserialize($table) : $table);
3211 3211
 
3212
-		if (is_object($table)) {
3213
-			$table = (($k !== '') and isset($table->$k)) ? $table->$k : $defaut;
3214
-		} elseif (is_array($table)) {
3215
-			if ($conserver_null) {
3216
-				$table = array_key_exists($k, $table) ? $table[$k] : $defaut;
3217
-			} else {
3218
-				$table = ($table[$k] ?? $defaut);
3219
-			}
3220
-		} else {
3221
-			$table = $defaut;
3222
-			break;
3223
-		}
3224
-	}
3212
+        if (is_object($table)) {
3213
+            $table = (($k !== '') and isset($table->$k)) ? $table->$k : $defaut;
3214
+        } elseif (is_array($table)) {
3215
+            if ($conserver_null) {
3216
+                $table = array_key_exists($k, $table) ? $table[$k] : $defaut;
3217
+            } else {
3218
+                $table = ($table[$k] ?? $defaut);
3219
+            }
3220
+        } else {
3221
+            $table = $defaut;
3222
+            break;
3223
+        }
3224
+    }
3225 3225
 
3226
-	return $table;
3226
+    return $table;
3227 3227
 }
3228 3228
 
3229 3229
 /**
@@ -3256,22 +3256,22 @@  discard block
 block discarded – undo
3256 3256
  *     - string : expression trouvée.
3257 3257
  **/
3258 3258
 function filtre_match_dist(?string $texte, $expression, $modif = 'UuimsS', $capte = 0) {
3259
-	if (intval($modif) and $capte == 0) {
3260
-		$capte = $modif;
3261
-		$modif = 'UuimsS';
3262
-	}
3263
-	$expression = str_replace('\/', '/', $expression);
3264
-	$expression = str_replace('/', '\/', $expression);
3259
+    if (intval($modif) and $capte == 0) {
3260
+        $capte = $modif;
3261
+        $modif = 'UuimsS';
3262
+    }
3263
+    $expression = str_replace('\/', '/', $expression);
3264
+    $expression = str_replace('/', '\/', $expression);
3265 3265
 
3266
-	if (preg_match('/' . $expression . '/' . $modif, $texte ?? '', $r)) {
3267
-		if (isset($r[$capte])) {
3268
-			return $r[$capte];
3269
-		} else {
3270
-			return true;
3271
-		}
3272
-	}
3266
+    if (preg_match('/' . $expression . '/' . $modif, $texte ?? '', $r)) {
3267
+        if (isset($r[$capte])) {
3268
+            return $r[$capte];
3269
+        } else {
3270
+            return true;
3271
+        }
3272
+    }
3273 3273
 
3274
-	return false;
3274
+    return false;
3275 3275
 }
3276 3276
 
3277 3277
 
@@ -3298,10 +3298,10 @@  discard block
 block discarded – undo
3298 3298
  *     Texte
3299 3299
  **/
3300 3300
 function replace($texte, $expression, $replace = '', $modif = 'UimsS') {
3301
-	$expression = str_replace('\/', '/', $expression);
3302
-	$expression = str_replace('/', '\/', $expression);
3301
+    $expression = str_replace('\/', '/', $expression);
3302
+    $expression = str_replace('/', '\/', $expression);
3303 3303
 
3304
-	return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3304
+    return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3305 3305
 }
3306 3306
 
3307 3307
 
@@ -3319,25 +3319,25 @@  discard block
 block discarded – undo
3319 3319
  **/
3320 3320
 function traiter_doublons_documents(&$doublons, $letexte) {
3321 3321
 
3322
-	// Verifier dans le texte & les notes (pas beau, helas)
3323
-	$t = $letexte . $GLOBALS['les_notes'];
3322
+    // Verifier dans le texte & les notes (pas beau, helas)
3323
+    $t = $letexte . $GLOBALS['les_notes'];
3324 3324
 
3325
-	if (
3326
-		strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3327
-		and preg_match_all(
3328
-			',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS',
3329
-			$t,
3330
-			$matches,
3331
-			PREG_PATTERN_ORDER
3332
-		)
3333
-	) {
3334
-		if (!isset($doublons['documents'])) {
3335
-			$doublons['documents'] = '';
3336
-		}
3337
-		$doublons['documents'] .= ',' . join(',', $matches[1]);
3338
-	}
3325
+    if (
3326
+        strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3327
+        and preg_match_all(
3328
+            ',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS',
3329
+            $t,
3330
+            $matches,
3331
+            PREG_PATTERN_ORDER
3332
+        )
3333
+    ) {
3334
+        if (!isset($doublons['documents'])) {
3335
+            $doublons['documents'] = '';
3336
+        }
3337
+        $doublons['documents'] .= ',' . join(',', $matches[1]);
3338
+    }
3339 3339
 
3340
-	return $letexte;
3340
+    return $letexte;
3341 3341
 }
3342 3342
 
3343 3343
 /**
@@ -3351,7 +3351,7 @@  discard block
 block discarded – undo
3351 3351
  * @return string Chaîne vide
3352 3352
  **/
3353 3353
 function vide($texte) {
3354
-	return '';
3354
+    return '';
3355 3355
 }
3356 3356
 
3357 3357
 //
@@ -3380,23 +3380,23 @@  discard block
 block discarded – undo
3380 3380
  *      Code HTML résultant
3381 3381
  **/
3382 3382
 function env_to_params($env, $ignore_params = []) {
3383
-	$ignore_params = array_merge(
3384
-		['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'],
3385
-		$ignore_params
3386
-	);
3387
-	if (!is_array($env)) {
3388
-		$env = unserialize($env);
3389
-	}
3390
-	$texte = '';
3391
-	if ($env) {
3392
-		foreach ($env as $i => $j) {
3393
-			if (is_string($j) and !in_array($i, $ignore_params)) {
3394
-				$texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3395
-			}
3396
-		}
3397
-	}
3398
-
3399
-	return $texte;
3383
+    $ignore_params = array_merge(
3384
+        ['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'],
3385
+        $ignore_params
3386
+    );
3387
+    if (!is_array($env)) {
3388
+        $env = unserialize($env);
3389
+    }
3390
+    $texte = '';
3391
+    if ($env) {
3392
+        foreach ($env as $i => $j) {
3393
+            if (is_string($j) and !in_array($i, $ignore_params)) {
3394
+                $texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3395
+            }
3396
+        }
3397
+    }
3398
+
3399
+    return $texte;
3400 3400
 }
3401 3401
 
3402 3402
 /**
@@ -3419,23 +3419,23 @@  discard block
 block discarded – undo
3419 3419
  *      Code HTML résultant
3420 3420
  **/
3421 3421
 function env_to_attributs($env, $ignore_params = []) {
3422
-	$ignore_params = array_merge(
3423
-		['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'],
3424
-		$ignore_params
3425
-	);
3426
-	if (!is_array($env)) {
3427
-		$env = unserialize($env);
3428
-	}
3429
-	$texte = '';
3430
-	if ($env) {
3431
-		foreach ($env as $i => $j) {
3432
-			if (is_string($j) and !in_array($i, $ignore_params)) {
3433
-				$texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3434
-			}
3435
-		}
3436
-	}
3422
+    $ignore_params = array_merge(
3423
+        ['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'],
3424
+        $ignore_params
3425
+    );
3426
+    if (!is_array($env)) {
3427
+        $env = unserialize($env);
3428
+    }
3429
+    $texte = '';
3430
+    if ($env) {
3431
+        foreach ($env as $i => $j) {
3432
+            if (is_string($j) and !in_array($i, $ignore_params)) {
3433
+                $texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3434
+            }
3435
+        }
3436
+    }
3437 3437
 
3438
-	return $texte;
3438
+    return $texte;
3439 3439
 }
3440 3440
 
3441 3441
 
@@ -3453,7 +3453,7 @@  discard block
 block discarded – undo
3453 3453
  * @return string Chaînes concaténés
3454 3454
  **/
3455 3455
 function concat(...$args): string {
3456
-	return join('', $args);
3456
+    return join('', $args);
3457 3457
 }
3458 3458
 
3459 3459
 
@@ -3473,23 +3473,23 @@  discard block
 block discarded – undo
3473 3473
  *     Contenu du ou des fichiers, concaténé
3474 3474
  **/
3475 3475
 function charge_scripts($files, $script = true) {
3476
-	$flux = '';
3477
-	foreach (is_array($files) ? $files : explode('|', $files) as $file) {
3478
-		if (!is_string($file)) {
3479
-			continue;
3480
-		}
3481
-		if ($script) {
3482
-			$file = preg_match(',^\w+$,', $file) ? "javascript/$file.js" : '';
3483
-		}
3484
-		if ($file) {
3485
-			$path = find_in_path($file);
3486
-			if ($path) {
3487
-				$flux .= spip_file_get_contents($path);
3488
-			}
3489
-		}
3490
-	}
3491
-
3492
-	return $flux;
3476
+    $flux = '';
3477
+    foreach (is_array($files) ? $files : explode('|', $files) as $file) {
3478
+        if (!is_string($file)) {
3479
+            continue;
3480
+        }
3481
+        if ($script) {
3482
+            $file = preg_match(',^\w+$,', $file) ? "javascript/$file.js" : '';
3483
+        }
3484
+        if ($file) {
3485
+            $path = find_in_path($file);
3486
+            if ($path) {
3487
+                $flux .= spip_file_get_contents($path);
3488
+            }
3489
+        }
3490
+    }
3491
+
3492
+    return $flux;
3493 3493
 }
3494 3494
 
3495 3495
 /**
@@ -3500,22 +3500,22 @@  discard block
 block discarded – undo
3500 3500
  * @return string
3501 3501
  */
3502 3502
 function http_img_variante_svg_si_possible($img_file) {
3503
-	// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3504
-	// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3505
-	if (
3506
-		preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3507
-		and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . '-xx.svg'
3508
-		and file_exists($variante_svg_generique)
3509
-	) {
3510
-		if ($variante_svg_size = substr($variante_svg_generique, 0, -6) . $m[1] . '.svg' and file_exists($variante_svg_size)) {
3511
-			$img_file = $variante_svg_size;
3512
-		}
3513
-		else {
3514
-			$img_file = $variante_svg_generique;
3515
-		}
3516
-	}
3503
+    // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3504
+    // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3505
+    if (
3506
+        preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3507
+        and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . '-xx.svg'
3508
+        and file_exists($variante_svg_generique)
3509
+    ) {
3510
+        if ($variante_svg_size = substr($variante_svg_generique, 0, -6) . $m[1] . '.svg' and file_exists($variante_svg_size)) {
3511
+            $img_file = $variante_svg_size;
3512
+        }
3513
+        else {
3514
+            $img_file = $variante_svg_generique;
3515
+        }
3516
+    }
3517 3517
 
3518
-	return $img_file;
3518
+    return $img_file;
3519 3519
 }
3520 3520
 
3521 3521
 /**
@@ -3536,54 +3536,54 @@  discard block
 block discarded – undo
3536 3536
  */
3537 3537
 function http_img_pack($img, $alt, $atts = '', $title = '', $options = []) {
3538 3538
 
3539
-	$img_file = $img;
3540
-	if ($p = strpos($img_file, '?')) {
3541
-		$img_file = substr($img_file, 0, $p);
3542
-	}
3543
-	if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3544
-		$img_file = chemin_image($img);
3545
-	}
3546
-	else {
3547
-		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true) {
3548
-			$img_file = http_img_variante_svg_si_possible($img_file);
3549
-		}
3550
-	}
3551
-	if (stripos($atts, 'width') === false) {
3552
-		// utiliser directement l'info de taille presente dans le nom
3553
-		if (
3554
-			(!isset($options['utiliser_suffixe_size'])
3555
-				or $options['utiliser_suffixe_size'] == true
3556
-			  or strpos($img_file, '-xx.svg') !== false)
3557
-			and (preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs)
3558
-					 or preg_match(',\?([0-9]+)px$,', $img, $regs))
3559
-		) {
3560
-			$largeur = $hauteur = intval($regs[1]);
3561
-		} else {
3562
-			$taille = taille_image($img_file);
3563
-			[$hauteur, $largeur] = $taille;
3564
-			if (!$hauteur or !$largeur) {
3565
-				return '';
3566
-			}
3567
-		}
3568
-		$atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3569
-	}
3570
-
3571
-	if (file_exists($img_file)) {
3572
-		$img_file = timestamp($img_file);
3573
-	}
3574
-	if ($alt === false) {
3575
-		$alt = '';
3576
-	}
3577
-	elseif ($alt or $alt === '') {
3578
-		$alt = " alt='" . attribut_html($alt) . "'";
3579
-	}
3580
-	else {
3581
-		$alt = " alt='" . attribut_html($title) . "'";
3582
-	}
3583
-	return "<img src='" . attribut_html($img_file) . "'$alt"
3584
-	. ($title ? ' title="' . attribut_html($title) . '"' : '')
3585
-	. ' ' . ltrim($atts)
3586
-	. ' />';
3539
+    $img_file = $img;
3540
+    if ($p = strpos($img_file, '?')) {
3541
+        $img_file = substr($img_file, 0, $p);
3542
+    }
3543
+    if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3544
+        $img_file = chemin_image($img);
3545
+    }
3546
+    else {
3547
+        if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true) {
3548
+            $img_file = http_img_variante_svg_si_possible($img_file);
3549
+        }
3550
+    }
3551
+    if (stripos($atts, 'width') === false) {
3552
+        // utiliser directement l'info de taille presente dans le nom
3553
+        if (
3554
+            (!isset($options['utiliser_suffixe_size'])
3555
+                or $options['utiliser_suffixe_size'] == true
3556
+              or strpos($img_file, '-xx.svg') !== false)
3557
+            and (preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs)
3558
+                     or preg_match(',\?([0-9]+)px$,', $img, $regs))
3559
+        ) {
3560
+            $largeur = $hauteur = intval($regs[1]);
3561
+        } else {
3562
+            $taille = taille_image($img_file);
3563
+            [$hauteur, $largeur] = $taille;
3564
+            if (!$hauteur or !$largeur) {
3565
+                return '';
3566
+            }
3567
+        }
3568
+        $atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3569
+    }
3570
+
3571
+    if (file_exists($img_file)) {
3572
+        $img_file = timestamp($img_file);
3573
+    }
3574
+    if ($alt === false) {
3575
+        $alt = '';
3576
+    }
3577
+    elseif ($alt or $alt === '') {
3578
+        $alt = " alt='" . attribut_html($alt) . "'";
3579
+    }
3580
+    else {
3581
+        $alt = " alt='" . attribut_html($title) . "'";
3582
+    }
3583
+    return "<img src='" . attribut_html($img_file) . "'$alt"
3584
+    . ($title ? ' title="' . attribut_html($title) . '"' : '')
3585
+    . ' ' . ltrim($atts)
3586
+    . ' />';
3587 3587
 }
3588 3588
 
3589 3589
 /**
@@ -3595,70 +3595,70 @@  discard block
 block discarded – undo
3595 3595
  * @return string
3596 3596
  */
3597 3597
 function http_style_background($img, $att = '', $size = null) {
3598
-	if ($size and is_numeric($size)) {
3599
-		$size = trim($size) . 'px';
3600
-	}
3601
-	return " style='background" .
3602
-		($att ? '' : '-image') . ': url("' . chemin_image($img) . '")' . ($att ? (' ' . $att) : '') . ';'
3603
-		. ($size ? "background-size:{$size};" : '')
3604
-		. "'";
3598
+    if ($size and is_numeric($size)) {
3599
+        $size = trim($size) . 'px';
3600
+    }
3601
+    return " style='background" .
3602
+        ($att ? '' : '-image') . ': url("' . chemin_image($img) . '")' . ($att ? (' ' . $att) : '') . ';'
3603
+        . ($size ? "background-size:{$size};" : '')
3604
+        . "'";
3605 3605
 }
3606 3606
 
3607 3607
 
3608 3608
 function helper_filtre_balise_img_svg_arguments($alt_or_size, $class_or_size, $size) {
3609
-	$args = [$alt_or_size, $class_or_size, $size];
3610
-	while (is_null(end($args)) and count($args)) {
3611
-		array_pop($args);
3612
-	}
3613
-	if (!count($args)) {
3614
-		return [null, null, null];
3615
-	}
3616
-	if (count($args) < 3) {
3617
-		$maybe_size = array_pop($args);
3618
-		// @2x
3619
-		// @1.5x
3620
-		// 512
3621
-		// 512x*
3622
-		// 512x300
3623
-		if (
3624
-			!strlen($maybe_size)
3625
-			or !preg_match(',^(@\d+(\.\d+)?x|\d+(x\*)?|\d+x\d+)$,', trim($maybe_size))
3626
-		) {
3627
-			$args[] = $maybe_size;
3628
-			$maybe_size = null;
3629
-		}
3630
-		while (count($args) < 2) {
3631
-			$args[] = null; // default alt or class
3632
-		}
3633
-		$args[] = $maybe_size;
3634
-	}
3635
-	return $args;
3609
+    $args = [$alt_or_size, $class_or_size, $size];
3610
+    while (is_null(end($args)) and count($args)) {
3611
+        array_pop($args);
3612
+    }
3613
+    if (!count($args)) {
3614
+        return [null, null, null];
3615
+    }
3616
+    if (count($args) < 3) {
3617
+        $maybe_size = array_pop($args);
3618
+        // @2x
3619
+        // @1.5x
3620
+        // 512
3621
+        // 512x*
3622
+        // 512x300
3623
+        if (
3624
+            !strlen($maybe_size)
3625
+            or !preg_match(',^(@\d+(\.\d+)?x|\d+(x\*)?|\d+x\d+)$,', trim($maybe_size))
3626
+        ) {
3627
+            $args[] = $maybe_size;
3628
+            $maybe_size = null;
3629
+        }
3630
+        while (count($args) < 2) {
3631
+            $args[] = null; // default alt or class
3632
+        }
3633
+        $args[] = $maybe_size;
3634
+    }
3635
+    return $args;
3636 3636
 }
3637 3637
 
3638 3638
 function helper_filtre_balise_img_svg_size($img, $size) {
3639
-	// si size est de la forme '@2x' c'est un coeff multiplicateur sur la densite
3640
-	if (strpos($size, '@') === 0 and substr($size, -1) === 'x') {
3641
-		$coef = floatval(substr($size, 1, -1));
3642
-		[$h, $w] = taille_image($img);
3643
-		$height = intval(round($h / $coef));
3644
-		$width = intval(round($w / $coef));
3645
-	}
3646
-	// sinon c'est une valeur seule si image caree ou largeurxhauteur
3647
-	else {
3648
-		$size = explode('x', $size, 2);
3649
-		$size = array_map('trim', $size);
3650
-		$height = $width = intval(array_shift($size));
3651
-
3652
-		if (count($size) and reset($size)) {
3653
-			$height = array_shift($size);
3654
-			if ($height === '*') {
3655
-				[$h, $w] = taille_image($img);
3656
-				$height = intval(round($h * $width / $w));
3657
-			}
3658
-		}
3659
-	}
3660
-
3661
-	return [$width, $height];
3639
+    // si size est de la forme '@2x' c'est un coeff multiplicateur sur la densite
3640
+    if (strpos($size, '@') === 0 and substr($size, -1) === 'x') {
3641
+        $coef = floatval(substr($size, 1, -1));
3642
+        [$h, $w] = taille_image($img);
3643
+        $height = intval(round($h / $coef));
3644
+        $width = intval(round($w / $coef));
3645
+    }
3646
+    // sinon c'est une valeur seule si image caree ou largeurxhauteur
3647
+    else {
3648
+        $size = explode('x', $size, 2);
3649
+        $size = array_map('trim', $size);
3650
+        $height = $width = intval(array_shift($size));
3651
+
3652
+        if (count($size) and reset($size)) {
3653
+            $height = array_shift($size);
3654
+            if ($height === '*') {
3655
+                [$h, $w] = taille_image($img);
3656
+                $height = intval(round($h * $width / $w));
3657
+            }
3658
+        }
3659
+    }
3660
+
3661
+    return [$width, $height];
3662 3662
 }
3663 3663
 
3664 3664
 /**
@@ -3694,43 +3694,43 @@  discard block
 block discarded – undo
3694 3694
  */
3695 3695
 function filtre_balise_img_dist($img, $alt = '', $class = null, $size = null) {
3696 3696
 
3697
-	[$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3698
-
3699
-	$img = trim((string) $img);
3700
-	if (strpos($img, '<img') === 0) {
3701
-		if (!is_null($alt)) {
3702
-			$img = inserer_attribut($img, 'alt', $alt);
3703
-		}
3704
-		if (!is_null($class)) {
3705
-			if (strlen($class)) {
3706
-				$img = inserer_attribut($img, 'class', $class);
3707
-			}
3708
-			else {
3709
-				$img = vider_attribut($img, 'class');
3710
-			}
3711
-		}
3712
-	}
3713
-	else {
3714
-		$img = http_img_pack(
3715
-			$img,
3716
-			$alt,
3717
-			$class ? " class='" . attribut_html($class) . "'" : '',
3718
-			'',
3719
-			['chemin_image' => false, 'utiliser_suffixe_size' => false]
3720
-		);
3721
-		if (is_null($alt)) {
3722
-			$img = vider_attribut($img, 'alt');
3723
-		}
3724
-	}
3725
-
3726
-	if ($img and !is_null($size) and strlen($size = trim($size))) {
3727
-		[$width, $height] = helper_filtre_balise_img_svg_size($img, $size);
3728
-
3729
-		$img = inserer_attribut($img, 'width', $width);
3730
-		$img = inserer_attribut($img, 'height', $height);
3731
-	}
3732
-
3733
-	return $img;
3697
+    [$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3698
+
3699
+    $img = trim((string) $img);
3700
+    if (strpos($img, '<img') === 0) {
3701
+        if (!is_null($alt)) {
3702
+            $img = inserer_attribut($img, 'alt', $alt);
3703
+        }
3704
+        if (!is_null($class)) {
3705
+            if (strlen($class)) {
3706
+                $img = inserer_attribut($img, 'class', $class);
3707
+            }
3708
+            else {
3709
+                $img = vider_attribut($img, 'class');
3710
+            }
3711
+        }
3712
+    }
3713
+    else {
3714
+        $img = http_img_pack(
3715
+            $img,
3716
+            $alt,
3717
+            $class ? " class='" . attribut_html($class) . "'" : '',
3718
+            '',
3719
+            ['chemin_image' => false, 'utiliser_suffixe_size' => false]
3720
+        );
3721
+        if (is_null($alt)) {
3722
+            $img = vider_attribut($img, 'alt');
3723
+        }
3724
+    }
3725
+
3726
+    if ($img and !is_null($size) and strlen($size = trim($size))) {
3727
+        [$width, $height] = helper_filtre_balise_img_svg_size($img, $size);
3728
+
3729
+        $img = inserer_attribut($img, 'width', $width);
3730
+        $img = inserer_attribut($img, 'height', $height);
3731
+    }
3732
+
3733
+    return $img;
3734 3734
 }
3735 3735
 
3736 3736
 
@@ -3764,80 +3764,80 @@  discard block
 block discarded – undo
3764 3764
  */
3765 3765
 function filtre_balise_svg_dist($img, $alt = '', $class = null, $size = null) {
3766 3766
 
3767
-	$svg = null;
3768
-	$img = trim($img);
3769
-	$img_file = $img;
3770
-	if (strpos($img, '<svg') === false) {
3771
-		if ($p = strpos($img_file, '?')) {
3772
-			$img_file = substr($img_file, 0, $p);
3773
-		}
3774
-
3775
-		// ne jamais operer directement sur une image distante pour des raisons de perfo
3776
-		// la copie locale a toutes les chances d'etre la ou de resservir
3777
-		if (tester_url_absolue($img_file)) {
3778
-			include_spip('inc/distant');
3779
-			$fichier = copie_locale($img_file);
3780
-			$img_file = ($fichier ? _DIR_RACINE . $fichier : $img_file);
3781
-		}
3782
-
3783
-		if (
3784
-			!$img_file
3785
-			or !file_exists($img_file)
3786
-			or !$svg = file_get_contents($img_file)
3787
-		) {
3788
-			return '';
3789
-		}
3790
-	}
3791
-
3792
-	if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) {
3793
-		return '';
3794
-	}
3795
-
3796
-	[$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3797
-
3798
-	$balise_svg = $match[0];
3799
-	$balise_svg_source = $balise_svg;
3800
-
3801
-	// entete XML à supprimer
3802
-	$svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3803
-
3804
-	// IE est toujours mon ami
3805
-	$balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3806
-
3807
-	// regler la classe
3808
-	if (!is_null($class)) {
3809
-		if (strlen($class)) {
3810
-			$balise_svg = inserer_attribut($balise_svg, 'class', $class);
3811
-		}
3812
-		else {
3813
-			$balise_svg = vider_attribut($balise_svg, 'class');
3814
-		}
3815
-	}
3816
-
3817
-	// regler le alt
3818
-	if ($alt) {
3819
-		$balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3820
-		$id = 'img-svg-title-' . substr(md5("$img_file:$svg:$alt"), 0, 4);
3821
-		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3822
-		$title = "<title id=\"$id\">" . entites_html($alt) . "</title>\n";
3823
-		$balise_svg .= $title;
3824
-	}
3825
-	else {
3826
-		$balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3827
-	}
3828
-
3829
-	$svg = str_replace($balise_svg_source, $balise_svg, $svg);
3830
-
3831
-	if (!is_null($size) and strlen($size = trim($size))) {
3832
-		[$width, $height] = helper_filtre_balise_img_svg_size($svg, $size);
3833
-
3834
-		if (!function_exists('svg_redimensionner')) {
3835
-			include_spip('inc/svg');
3836
-		}
3837
-		$svg = svg_redimensionner($svg, $width, $height);
3838
-	}
3839
-
3840
-	return $svg;
3767
+    $svg = null;
3768
+    $img = trim($img);
3769
+    $img_file = $img;
3770
+    if (strpos($img, '<svg') === false) {
3771
+        if ($p = strpos($img_file, '?')) {
3772
+            $img_file = substr($img_file, 0, $p);
3773
+        }
3774
+
3775
+        // ne jamais operer directement sur une image distante pour des raisons de perfo
3776
+        // la copie locale a toutes les chances d'etre la ou de resservir
3777
+        if (tester_url_absolue($img_file)) {
3778
+            include_spip('inc/distant');
3779
+            $fichier = copie_locale($img_file);
3780
+            $img_file = ($fichier ? _DIR_RACINE . $fichier : $img_file);
3781
+        }
3782
+
3783
+        if (
3784
+            !$img_file
3785
+            or !file_exists($img_file)
3786
+            or !$svg = file_get_contents($img_file)
3787
+        ) {
3788
+            return '';
3789
+        }
3790
+    }
3791
+
3792
+    if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) {
3793
+        return '';
3794
+    }
3795
+
3796
+    [$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3797
+
3798
+    $balise_svg = $match[0];
3799
+    $balise_svg_source = $balise_svg;
3800
+
3801
+    // entete XML à supprimer
3802
+    $svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3803
+
3804
+    // IE est toujours mon ami
3805
+    $balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3806
+
3807
+    // regler la classe
3808
+    if (!is_null($class)) {
3809
+        if (strlen($class)) {
3810
+            $balise_svg = inserer_attribut($balise_svg, 'class', $class);
3811
+        }
3812
+        else {
3813
+            $balise_svg = vider_attribut($balise_svg, 'class');
3814
+        }
3815
+    }
3816
+
3817
+    // regler le alt
3818
+    if ($alt) {
3819
+        $balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3820
+        $id = 'img-svg-title-' . substr(md5("$img_file:$svg:$alt"), 0, 4);
3821
+        $balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3822
+        $title = "<title id=\"$id\">" . entites_html($alt) . "</title>\n";
3823
+        $balise_svg .= $title;
3824
+    }
3825
+    else {
3826
+        $balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3827
+    }
3828
+
3829
+    $svg = str_replace($balise_svg_source, $balise_svg, $svg);
3830
+
3831
+    if (!is_null($size) and strlen($size = trim($size))) {
3832
+        [$width, $height] = helper_filtre_balise_img_svg_size($svg, $size);
3833
+
3834
+        if (!function_exists('svg_redimensionner')) {
3835
+            include_spip('inc/svg');
3836
+        }
3837
+        $svg = svg_redimensionner($svg, $width, $height);
3838
+    }
3839
+
3840
+    return $svg;
3841 3841
 }
3842 3842
 
3843 3843
 
@@ -3863,18 +3863,18 @@  discard block
 block discarded – undo
3863 3863
  *     Code HTML résultant
3864 3864
  **/
3865 3865
 function filtre_foreach_dist($tableau, $modele = 'foreach') {
3866
-	$texte = '';
3867
-	if (is_array($tableau)) {
3868
-		foreach ($tableau as $k => $v) {
3869
-			$res = recuperer_fond(
3870
-				'modeles/' . $modele,
3871
-				array_merge(['cle' => $k], (is_array($v) ? $v : ['valeur' => $v]))
3872
-			);
3873
-			$texte .= $res;
3874
-		}
3875
-	}
3866
+    $texte = '';
3867
+    if (is_array($tableau)) {
3868
+        foreach ($tableau as $k => $v) {
3869
+            $res = recuperer_fond(
3870
+                'modeles/' . $modele,
3871
+                array_merge(['cle' => $k], (is_array($v) ? $v : ['valeur' => $v]))
3872
+            );
3873
+            $texte .= $res;
3874
+        }
3875
+    }
3876 3876
 
3877
-	return $texte;
3877
+    return $texte;
3878 3878
 }
3879 3879
 
3880 3880
 
@@ -3899,37 +3899,37 @@  discard block
 block discarded – undo
3899 3899
  *         - tout : retourne toutes les informations du plugin actif
3900 3900
  **/
3901 3901
 function filtre_info_plugin_dist($plugin, $type_info, $reload = false) {
3902
-	include_spip('inc/plugin');
3903
-	$plugin = strtoupper($plugin);
3904
-	$plugins_actifs = liste_plugin_actifs();
3905
-
3906
-	if (!$plugin) {
3907
-		return serialize(array_keys($plugins_actifs));
3908
-	} elseif (empty($plugins_actifs[$plugin]) and !$reload) {
3909
-		return '';
3910
-	} elseif (($type_info == 'est_actif') and !$reload) {
3911
-		return $plugins_actifs[$plugin] ? 1 : 0;
3912
-	} elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) {
3913
-		return $plugins_actifs[$plugin][$type_info];
3914
-	} else {
3915
-		$get_infos = charger_fonction('get_infos', 'plugins');
3916
-		// On prend en compte les extensions
3917
-		if (!is_dir($plugins_actifs[$plugin]['dir_type'])) {
3918
-			$dir_plugins = constant($plugins_actifs[$plugin]['dir_type']);
3919
-		} else {
3920
-			$dir_plugins = $plugins_actifs[$plugin]['dir_type'];
3921
-		}
3922
-		if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) {
3923
-			return '';
3924
-		}
3925
-		if ($type_info == 'tout') {
3926
-			return $infos;
3927
-		} elseif ($type_info == 'est_actif') {
3928
-			return $infos ? 1 : 0;
3929
-		} else {
3930
-			return strval($infos[$type_info]);
3931
-		}
3932
-	}
3902
+    include_spip('inc/plugin');
3903
+    $plugin = strtoupper($plugin);
3904
+    $plugins_actifs = liste_plugin_actifs();
3905
+
3906
+    if (!$plugin) {
3907
+        return serialize(array_keys($plugins_actifs));
3908
+    } elseif (empty($plugins_actifs[$plugin]) and !$reload) {
3909
+        return '';
3910
+    } elseif (($type_info == 'est_actif') and !$reload) {
3911
+        return $plugins_actifs[$plugin] ? 1 : 0;
3912
+    } elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) {
3913
+        return $plugins_actifs[$plugin][$type_info];
3914
+    } else {
3915
+        $get_infos = charger_fonction('get_infos', 'plugins');
3916
+        // On prend en compte les extensions
3917
+        if (!is_dir($plugins_actifs[$plugin]['dir_type'])) {
3918
+            $dir_plugins = constant($plugins_actifs[$plugin]['dir_type']);
3919
+        } else {
3920
+            $dir_plugins = $plugins_actifs[$plugin]['dir_type'];
3921
+        }
3922
+        if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) {
3923
+            return '';
3924
+        }
3925
+        if ($type_info == 'tout') {
3926
+            return $infos;
3927
+        } elseif ($type_info == 'est_actif') {
3928
+            return $infos ? 1 : 0;
3929
+        } else {
3930
+            return strval($infos[$type_info]);
3931
+        }
3932
+    }
3933 3933
 }
3934 3934
 
3935 3935
 
@@ -3956,9 +3956,9 @@  discard block
 block discarded – undo
3956 3956
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
3957 3957
  */
3958 3958
 function puce_changement_statut($id_objet, $statut, $id_rubrique, $type, $ajax = false) {
3959
-	$puce_statut = charger_fonction('puce_statut', 'inc');
3959
+    $puce_statut = charger_fonction('puce_statut', 'inc');
3960 3960
 
3961
-	return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax);
3961
+    return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax);
3962 3962
 }
3963 3963
 
3964 3964
 
@@ -3988,19 +3988,19 @@  discard block
 block discarded – undo
3988 3988
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
3989 3989
  */
3990 3990
 function filtre_puce_statut_dist($statut, $objet, $id_objet = 0, $id_parent = 0) {
3991
-	static $puce_statut = null;
3992
-	if (!$puce_statut) {
3993
-		$puce_statut = charger_fonction('puce_statut', 'inc');
3994
-	}
3991
+    static $puce_statut = null;
3992
+    if (!$puce_statut) {
3993
+        $puce_statut = charger_fonction('puce_statut', 'inc');
3994
+    }
3995 3995
 
3996
-	return $puce_statut(
3997
-		$id_objet,
3998
-		$statut,
3999
-		$id_parent,
4000
-		$objet,
4001
-		false,
4002
-		objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false
4003
-	);
3996
+    return $puce_statut(
3997
+        $id_objet,
3998
+        $statut,
3999
+        $id_parent,
4000
+        $objet,
4001
+        false,
4002
+        objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false
4003
+    );
4004 4004
 }
4005 4005
 
4006 4006
 
@@ -4027,98 +4027,98 @@  discard block
 block discarded – undo
4027 4027
  *   hash du contexte
4028 4028
  */
4029 4029
 function encoder_contexte_ajax($c, $form = '', $emboite = null, $ajaxid = '') {
4030
-	$env = null;
4031
-	if (
4032
-		is_string($c)
4033
-		and @unserialize($c) !== false
4034
-	) {
4035
-		$c = unserialize($c);
4036
-	}
4037
-
4038
-	// supprimer les parametres debut_x
4039
-	// pour que la pagination ajax ne soit pas plantee
4040
-	// si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0,
4041
-	// le debut_x=0 n'existe pas, et on resterait sur 1
4042
-	if (is_array($c)) {
4043
-		foreach ($c as $k => $v) {
4044
-			if (strpos($k, 'debut_') === 0) {
4045
-				unset($c[$k]);
4046
-			}
4047
-		}
4048
-	}
4049
-
4050
-	if (!function_exists('calculer_cle_action')) {
4051
-		include_spip('inc/securiser_action');
4052
-	}
4053
-
4054
-	$c = serialize($c);
4055
-	$cle = calculer_cle_action($form . $c);
4056
-	$c = "$cle:$c";
4057
-
4058
-	// on ne stocke pas les contextes dans des fichiers en cache
4059
-	// par defaut, sauf si cette configuration a été forcée
4060
-	// OU que la longueur de l’argument géneré est plus long
4061
-	// que ce qui est toléré.
4062
-	$cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX);
4063
-	if (!$cache_contextes_ajax) {
4064
-		$env = $c;
4065
-		if (function_exists('gzdeflate') && function_exists('gzinflate')) {
4066
-			$env = gzdeflate($env);
4067
-		}
4068
-		$env = _xor($env);
4069
-		$env = base64_encode($env);
4070
-		$len = strlen($env);
4071
-		// Si l’url est trop longue pour le navigateur
4072
-		$max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR;
4073
-		if ($len > $max_len) {
4074
-			$cache_contextes_ajax = true;
4075
-			spip_log(
4076
-				'Contextes AJAX forces en fichiers !'
4077
-				. ' Cela arrive lorsque la valeur du contexte'
4078
-				. " depasse la longueur maximale autorisee ($max_len). Ici : $len.",
4079
-				_LOG_AVERTISSEMENT
4080
-			);
4081
-		}
4082
-		// Sinon si Suhosin est actif et a une la valeur maximale des variables en GET...
4083
-		elseif (
4084
-			$max_len = @ini_get('suhosin.get.max_value_length')
4085
-			and $max_len < $len
4086
-		) {
4087
-			$cache_contextes_ajax = true;
4088
-			spip_log('Contextes AJAX forces en fichiers !'
4089
-				. ' Cela arrive lorsque la valeur du contexte'
4090
-				. ' depasse la longueur maximale autorisee par Suhosin'
4091
-				. " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len."
4092
-				. ' Vous devriez modifier les parametres de Suhosin'
4093
-				. ' pour accepter au moins 1024 caracteres.', _LOG_AVERTISSEMENT);
4094
-		}
4095
-	}
4096
-
4097
-	if ($cache_contextes_ajax) {
4098
-		$dir = sous_repertoire(_DIR_CACHE, 'contextes');
4099
-		// stocker les contextes sur disque et ne passer qu'un hash dans l'url
4100
-		$md5 = md5($c);
4101
-		ecrire_fichier("$dir/c$md5", $c);
4102
-		$env = $md5;
4103
-	}
4104
-
4105
-	if ($emboite === null) {
4106
-		return $env;
4107
-	}
4108
-	if (!trim($emboite)) {
4109
-		return '';
4110
-	}
4111
-	// toujours encoder l'url source dans le bloc ajax
4112
-	$r = self();
4113
-	$r = ' data-origin="' . $r . '"';
4114
-	$class = 'ajaxbloc';
4115
-	if ($ajaxid and is_string($ajaxid)) {
4116
-		// ajaxid est normalement conforme a un nom de classe css
4117
-		// on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
4118
-		$class .= ' ajax-id-' . entites_html($ajaxid);
4119
-	}
4120
-
4121
-	return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
4030
+    $env = null;
4031
+    if (
4032
+        is_string($c)
4033
+        and @unserialize($c) !== false
4034
+    ) {
4035
+        $c = unserialize($c);
4036
+    }
4037
+
4038
+    // supprimer les parametres debut_x
4039
+    // pour que la pagination ajax ne soit pas plantee
4040
+    // si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0,
4041
+    // le debut_x=0 n'existe pas, et on resterait sur 1
4042
+    if (is_array($c)) {
4043
+        foreach ($c as $k => $v) {
4044
+            if (strpos($k, 'debut_') === 0) {
4045
+                unset($c[$k]);
4046
+            }
4047
+        }
4048
+    }
4049
+
4050
+    if (!function_exists('calculer_cle_action')) {
4051
+        include_spip('inc/securiser_action');
4052
+    }
4053
+
4054
+    $c = serialize($c);
4055
+    $cle = calculer_cle_action($form . $c);
4056
+    $c = "$cle:$c";
4057
+
4058
+    // on ne stocke pas les contextes dans des fichiers en cache
4059
+    // par defaut, sauf si cette configuration a été forcée
4060
+    // OU que la longueur de l’argument géneré est plus long
4061
+    // que ce qui est toléré.
4062
+    $cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX);
4063
+    if (!$cache_contextes_ajax) {
4064
+        $env = $c;
4065
+        if (function_exists('gzdeflate') && function_exists('gzinflate')) {
4066
+            $env = gzdeflate($env);
4067
+        }
4068
+        $env = _xor($env);
4069
+        $env = base64_encode($env);
4070
+        $len = strlen($env);
4071
+        // Si l’url est trop longue pour le navigateur
4072
+        $max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR;
4073
+        if ($len > $max_len) {
4074
+            $cache_contextes_ajax = true;
4075
+            spip_log(
4076
+                'Contextes AJAX forces en fichiers !'
4077
+                . ' Cela arrive lorsque la valeur du contexte'
4078
+                . " depasse la longueur maximale autorisee ($max_len). Ici : $len.",
4079
+                _LOG_AVERTISSEMENT
4080
+            );
4081
+        }
4082
+        // Sinon si Suhosin est actif et a une la valeur maximale des variables en GET...
4083
+        elseif (
4084
+            $max_len = @ini_get('suhosin.get.max_value_length')
4085
+            and $max_len < $len
4086
+        ) {
4087
+            $cache_contextes_ajax = true;
4088
+            spip_log('Contextes AJAX forces en fichiers !'
4089
+                . ' Cela arrive lorsque la valeur du contexte'
4090
+                . ' depasse la longueur maximale autorisee par Suhosin'
4091
+                . " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len."
4092
+                . ' Vous devriez modifier les parametres de Suhosin'
4093
+                . ' pour accepter au moins 1024 caracteres.', _LOG_AVERTISSEMENT);
4094
+        }
4095
+    }
4096
+
4097
+    if ($cache_contextes_ajax) {
4098
+        $dir = sous_repertoire(_DIR_CACHE, 'contextes');
4099
+        // stocker les contextes sur disque et ne passer qu'un hash dans l'url
4100
+        $md5 = md5($c);
4101
+        ecrire_fichier("$dir/c$md5", $c);
4102
+        $env = $md5;
4103
+    }
4104
+
4105
+    if ($emboite === null) {
4106
+        return $env;
4107
+    }
4108
+    if (!trim($emboite)) {
4109
+        return '';
4110
+    }
4111
+    // toujours encoder l'url source dans le bloc ajax
4112
+    $r = self();
4113
+    $r = ' data-origin="' . $r . '"';
4114
+    $class = 'ajaxbloc';
4115
+    if ($ajaxid and is_string($ajaxid)) {
4116
+        // ajaxid est normalement conforme a un nom de classe css
4117
+        // on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
4118
+        $class .= ' ajax-id-' . entites_html($ajaxid);
4119
+    }
4120
+
4121
+    return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
4122 4122
 }
4123 4123
 
4124 4124
 /**
@@ -4138,37 +4138,37 @@  discard block
 block discarded – undo
4138 4138
  *   - false : erreur de décodage
4139 4139
  */
4140 4140
 function decoder_contexte_ajax($c, $form = '') {
4141
-	if (!function_exists('calculer_cle_action')) {
4142
-		include_spip('inc/securiser_action');
4143
-	}
4144
-	if (
4145
-		((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32)
4146
-		and $dir = sous_repertoire(_DIR_CACHE, 'contextes')
4147
-		and lire_fichier("$dir/c$c", $contexte)
4148
-	) {
4149
-		$c = $contexte;
4150
-	} else {
4151
-		$c = @base64_decode($c);
4152
-		$c = _xor($c);
4153
-		if (function_exists('gzdeflate') && function_exists('gzinflate')) {
4154
-			$c = @gzinflate($c);
4155
-		}
4156
-	}
4157
-
4158
-	// extraire la signature en debut de contexte
4159
-	// et la verifier avant de deserializer
4160
-	// format : signature:donneesserializees
4161
-	if ($p = strpos($c, ':')) {
4162
-		$cle = substr($c, 0, $p);
4163
-		$c = substr($c, $p + 1);
4164
-
4165
-		if ($cle == calculer_cle_action($form . $c)) {
4166
-			$env = @unserialize($c);
4167
-			return $env;
4168
-		}
4169
-	}
4170
-
4171
-	return false;
4141
+    if (!function_exists('calculer_cle_action')) {
4142
+        include_spip('inc/securiser_action');
4143
+    }
4144
+    if (
4145
+        ((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32)
4146
+        and $dir = sous_repertoire(_DIR_CACHE, 'contextes')
4147
+        and lire_fichier("$dir/c$c", $contexte)
4148
+    ) {
4149
+        $c = $contexte;
4150
+    } else {
4151
+        $c = @base64_decode($c);
4152
+        $c = _xor($c);
4153
+        if (function_exists('gzdeflate') && function_exists('gzinflate')) {
4154
+            $c = @gzinflate($c);
4155
+        }
4156
+    }
4157
+
4158
+    // extraire la signature en debut de contexte
4159
+    // et la verifier avant de deserializer
4160
+    // format : signature:donneesserializees
4161
+    if ($p = strpos($c, ':')) {
4162
+        $cle = substr($c, 0, $p);
4163
+        $c = substr($c, $p + 1);
4164
+
4165
+        if ($cle == calculer_cle_action($form . $c)) {
4166
+            $env = @unserialize($c);
4167
+            return $env;
4168
+        }
4169
+    }
4170
+
4171
+    return false;
4172 4172
 }
4173 4173
 
4174 4174
 
@@ -4186,20 +4186,20 @@  discard block
 block discarded – undo
4186 4186
  *    Message décrypté ou encrypté
4187 4187
  **/
4188 4188
 function _xor($message, $key = null) {
4189
-	if (is_null($key)) {
4190
-		if (!function_exists('calculer_cle_action')) {
4191
-			include_spip('inc/securiser_action');
4192
-		}
4193
-		$key = pack('H*', calculer_cle_action('_xor'));
4194
-	}
4189
+    if (is_null($key)) {
4190
+        if (!function_exists('calculer_cle_action')) {
4191
+            include_spip('inc/securiser_action');
4192
+        }
4193
+        $key = pack('H*', calculer_cle_action('_xor'));
4194
+    }
4195 4195
 
4196
-	$keylen = strlen($key);
4197
-	$messagelen = strlen($message);
4198
-	for ($i = 0; $i < $messagelen; $i++) {
4199
-		$message[$i] = ~($message[$i] ^ $key[$i % $keylen]);
4200
-	}
4196
+    $keylen = strlen($key);
4197
+    $messagelen = strlen($message);
4198
+    for ($i = 0; $i < $messagelen; $i++) {
4199
+        $message[$i] = ~($message[$i] ^ $key[$i % $keylen]);
4200
+    }
4201 4201
 
4202
-	return $message;
4202
+    return $message;
4203 4203
 }
4204 4204
 
4205 4205
 /**
@@ -4213,7 +4213,7 @@  discard block
 block discarded – undo
4213 4213
  * @return string
4214 4214
  */
4215 4215
 function url_reponse_forum($texte) {
4216
- return $texte;
4216
+    return $texte;
4217 4217
 }
4218 4218
 
4219 4219
 /**
@@ -4227,7 +4227,7 @@  discard block
 block discarded – undo
4227 4227
  * @return string
4228 4228
  */
4229 4229
 function url_rss_forum($texte) {
4230
- return $texte;
4230
+    return $texte;
4231 4231
 }
4232 4232
 
4233 4233
 
@@ -4266,37 +4266,37 @@  discard block
 block discarded – undo
4266 4266
  *   Code HTML
4267 4267
  */
4268 4268
 function lien_ou_expose($url, $libelle = null, $on = false, $class = '', $title = '', $rel = '', $evt = '') {
4269
-	if ($on) {
4270
-		$bal = 'strong';
4271
-		$class = '';
4272
-		$att = '';
4273
-		// si $on passe la balise et optionnelement une ou ++classe
4274
-		// a.active span.selected.active etc....
4275
-		if (is_string($on) and (strncmp($on, 'a', 1) == 0 or strncmp($on, 'span', 4) == 0 or strncmp($on, 'strong', 6) == 0)) {
4276
-			$on = explode('.', $on);
4277
-			// on verifie que c'est exactement une des 3 balises a, span ou strong
4278
-			if (in_array(reset($on), ['a', 'span', 'strong'])) {
4279
-				$bal = array_shift($on);
4280
-				$class = implode(' ', $on);
4281
-				if ($bal == 'a') {
4282
-					$att = 'href="#" ';
4283
-				}
4284
-			}
4285
-		}
4286
-		$att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"';
4287
-	} else {
4288
-		$bal = 'a';
4289
-		$att = "href='$url'"
4290
-			. ($title ? " title='" . attribut_html($title) . "'" : '')
4291
-			. ($class ? " class='" . attribut_html($class) . "'" : '')
4292
-			. ($rel ? " rel='" . attribut_html($rel) . "'" : '')
4293
-			. $evt;
4294
-	}
4295
-	if ($libelle === null) {
4296
-		$libelle = $url;
4297
-	}
4298
-
4299
-	return "<$bal $att>$libelle</$bal>";
4269
+    if ($on) {
4270
+        $bal = 'strong';
4271
+        $class = '';
4272
+        $att = '';
4273
+        // si $on passe la balise et optionnelement une ou ++classe
4274
+        // a.active span.selected.active etc....
4275
+        if (is_string($on) and (strncmp($on, 'a', 1) == 0 or strncmp($on, 'span', 4) == 0 or strncmp($on, 'strong', 6) == 0)) {
4276
+            $on = explode('.', $on);
4277
+            // on verifie que c'est exactement une des 3 balises a, span ou strong
4278
+            if (in_array(reset($on), ['a', 'span', 'strong'])) {
4279
+                $bal = array_shift($on);
4280
+                $class = implode(' ', $on);
4281
+                if ($bal == 'a') {
4282
+                    $att = 'href="#" ';
4283
+                }
4284
+            }
4285
+        }
4286
+        $att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"';
4287
+    } else {
4288
+        $bal = 'a';
4289
+        $att = "href='$url'"
4290
+            . ($title ? " title='" . attribut_html($title) . "'" : '')
4291
+            . ($class ? " class='" . attribut_html($class) . "'" : '')
4292
+            . ($rel ? " rel='" . attribut_html($rel) . "'" : '')
4293
+            . $evt;
4294
+    }
4295
+    if ($libelle === null) {
4296
+        $libelle = $url;
4297
+    }
4298
+
4299
+    return "<$bal $att>$libelle</$bal>";
4300 4300
 }
4301 4301
 
4302 4302
 
@@ -4313,39 +4313,39 @@  discard block
 block discarded – undo
4313 4313
  * @return string : la chaine de langue finale en utilisant la fonction _T()
4314 4314
  */
4315 4315
 function singulier_ou_pluriel($nb, $chaine_un, $chaine_plusieurs, $var = 'nb', $vars = []) {
4316
-	static $local_singulier_ou_pluriel = [];
4317
-
4318
-	// si nb=0 ou pas de $vars valide on retourne une chaine vide, a traiter par un |sinon
4319
-	if (!is_numeric($nb) or $nb == 0) {
4320
-		return '';
4321
-	}
4322
-	if (!is_array($vars)) {
4323
-		return '';
4324
-	}
4325
-
4326
-	$langue = $GLOBALS['spip_lang'];
4327
-	if (!isset($local_singulier_ou_pluriel[$langue])) {
4328
-		$local_singulier_ou_pluriel[$langue] = false;
4329
-		if (
4330
-			$f = charger_fonction("singulier_ou_pluriel_{$langue}", 'inc', true)
4331
-			or $f = charger_fonction('singulier_ou_pluriel', 'inc', true)
4332
-		) {
4333
-			$local_singulier_ou_pluriel[$langue] = $f;
4334
-		}
4335
-	}
4336
-
4337
-	// si on a une surcharge on l'utilise
4338
-	if ($local_singulier_ou_pluriel[$langue]) {
4339
-		return ($local_singulier_ou_pluriel[$langue])($nb, $chaine_un, $chaine_plusieurs, $var, $vars);
4340
-	}
4341
-
4342
-	// sinon traitement par defaut
4343
-	$vars[$var] = $nb;
4344
-	if ($nb >= 2) {
4345
-		return _T($chaine_plusieurs, $vars);
4346
-	} else {
4347
-		return _T($chaine_un, $vars);
4348
-	}
4316
+    static $local_singulier_ou_pluriel = [];
4317
+
4318
+    // si nb=0 ou pas de $vars valide on retourne une chaine vide, a traiter par un |sinon
4319
+    if (!is_numeric($nb) or $nb == 0) {
4320
+        return '';
4321
+    }
4322
+    if (!is_array($vars)) {
4323
+        return '';
4324
+    }
4325
+
4326
+    $langue = $GLOBALS['spip_lang'];
4327
+    if (!isset($local_singulier_ou_pluriel[$langue])) {
4328
+        $local_singulier_ou_pluriel[$langue] = false;
4329
+        if (
4330
+            $f = charger_fonction("singulier_ou_pluriel_{$langue}", 'inc', true)
4331
+            or $f = charger_fonction('singulier_ou_pluriel', 'inc', true)
4332
+        ) {
4333
+            $local_singulier_ou_pluriel[$langue] = $f;
4334
+        }
4335
+    }
4336
+
4337
+    // si on a une surcharge on l'utilise
4338
+    if ($local_singulier_ou_pluriel[$langue]) {
4339
+        return ($local_singulier_ou_pluriel[$langue])($nb, $chaine_un, $chaine_plusieurs, $var, $vars);
4340
+    }
4341
+
4342
+    // sinon traitement par defaut
4343
+    $vars[$var] = $nb;
4344
+    if ($nb >= 2) {
4345
+        return _T($chaine_plusieurs, $vars);
4346
+    } else {
4347
+        return _T($chaine_un, $vars);
4348
+    }
4349 4349
 }
4350 4350
 
4351 4351
 
@@ -4373,73 +4373,73 @@  discard block
 block discarded – undo
4373 4373
  */
4374 4374
 function prepare_icone_base($type, $lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') {
4375 4375
 
4376
-	$class_lien = $class_bouton = $class;
4377
-
4378
-	// Normaliser la fonction et compléter la classe en fonction
4379
-	if (in_array($fonction, ['del', 'supprimer.gif'])) {
4380
-		$class_lien .= ' danger';
4381
-		$class_bouton .= ' btn_danger';
4382
-	} elseif ($fonction == 'rien.gif') {
4383
-		$fonction = '';
4384
-	} elseif ($fonction == 'delsafe') {
4385
-		$fonction = 'del';
4386
-	}
4387
-
4388
-	$fond_origine = $fond;
4389
-	// Remappage des icone : article-24.png+new => article-new-24.png
4390
-	if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
4391
-		[$fond, $fonction] = $icone_renommer($fond, $fonction);
4392
-	}
4393
-
4394
-	// Ajouter le type d'objet dans la classe
4395
-	$objet_type = substr(basename($fond), 0, -4);
4396
-	$class_lien .= " $objet_type";
4397
-	$class_bouton .= " $objet_type";
4398
-
4399
-	// Texte
4400
-	$alt = attribut_html($texte);
4401
-	$title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
4402
-
4403
-	// Liens : préparer les classes ajax
4404
-	$ajax = '';
4405
-	if ($type === 'lien') {
4406
-		if (strpos($class_lien, 'ajax') !== false) {
4407
-			$ajax = 'ajax';
4408
-			if (strpos($class_lien, 'preload') !== false) {
4409
-				$ajax .= ' preload';
4410
-			}
4411
-			if (strpos($class_lien, 'nocache') !== false) {
4412
-				$ajax .= ' nocache';
4413
-			}
4414
-			$ajax = " class='$ajax'";
4415
-		}
4416
-	}
4417
-
4418
-	// Repérer la taille et l'ajouter dans la classe
4419
-	$size = 24;
4420
-	if (
4421
-		preg_match('/-([0-9]{1,3})[.](gif|png|svg)$/i', $fond, $match)
4422
-		or preg_match('/-([0-9]{1,3})([.](gif|png|svg))?$/i', $fond_origine, $match)
4423
-	) {
4424
-		$size = $match[1];
4425
-	}
4426
-	$class_lien .= " s$size";
4427
-	$class_bouton .= " s$size";
4428
-
4429
-	// Icône
4430
-	$icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4431
-	$icone = '<span class="icone-image' . ($fonction ? " icone-fonction icone-fonction-$fonction" : '') . "\">$icone</span>";
4432
-
4433
-	// Markup final
4434
-	if ($type == 'lien') {
4435
-		return "<span class='icone $class_lien'>"
4436
-		. "<a href='$lien'$title$ajax$javascript>"
4437
-		. $icone
4438
-		. "<b>$texte</b>"
4439
-		. "</a></span>\n";
4440
-	} else {
4441
-		return bouton_action("$icone $texte", $lien, $class_bouton, $javascript, $alt);
4442
-	}
4376
+    $class_lien = $class_bouton = $class;
4377
+
4378
+    // Normaliser la fonction et compléter la classe en fonction
4379
+    if (in_array($fonction, ['del', 'supprimer.gif'])) {
4380
+        $class_lien .= ' danger';
4381
+        $class_bouton .= ' btn_danger';
4382
+    } elseif ($fonction == 'rien.gif') {
4383
+        $fonction = '';
4384
+    } elseif ($fonction == 'delsafe') {
4385
+        $fonction = 'del';
4386
+    }
4387
+
4388
+    $fond_origine = $fond;
4389
+    // Remappage des icone : article-24.png+new => article-new-24.png
4390
+    if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
4391
+        [$fond, $fonction] = $icone_renommer($fond, $fonction);
4392
+    }
4393
+
4394
+    // Ajouter le type d'objet dans la classe
4395
+    $objet_type = substr(basename($fond), 0, -4);
4396
+    $class_lien .= " $objet_type";
4397
+    $class_bouton .= " $objet_type";
4398
+
4399
+    // Texte
4400
+    $alt = attribut_html($texte);
4401
+    $title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
4402
+
4403
+    // Liens : préparer les classes ajax
4404
+    $ajax = '';
4405
+    if ($type === 'lien') {
4406
+        if (strpos($class_lien, 'ajax') !== false) {
4407
+            $ajax = 'ajax';
4408
+            if (strpos($class_lien, 'preload') !== false) {
4409
+                $ajax .= ' preload';
4410
+            }
4411
+            if (strpos($class_lien, 'nocache') !== false) {
4412
+                $ajax .= ' nocache';
4413
+            }
4414
+            $ajax = " class='$ajax'";
4415
+        }
4416
+    }
4417
+
4418
+    // Repérer la taille et l'ajouter dans la classe
4419
+    $size = 24;
4420
+    if (
4421
+        preg_match('/-([0-9]{1,3})[.](gif|png|svg)$/i', $fond, $match)
4422
+        or preg_match('/-([0-9]{1,3})([.](gif|png|svg))?$/i', $fond_origine, $match)
4423
+    ) {
4424
+        $size = $match[1];
4425
+    }
4426
+    $class_lien .= " s$size";
4427
+    $class_bouton .= " s$size";
4428
+
4429
+    // Icône
4430
+    $icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4431
+    $icone = '<span class="icone-image' . ($fonction ? " icone-fonction icone-fonction-$fonction" : '') . "\">$icone</span>";
4432
+
4433
+    // Markup final
4434
+    if ($type == 'lien') {
4435
+        return "<span class='icone $class_lien'>"
4436
+        . "<a href='$lien'$title$ajax$javascript>"
4437
+        . $icone
4438
+        . "<b>$texte</b>"
4439
+        . "</a></span>\n";
4440
+    } else {
4441
+        return bouton_action("$icone $texte", $lien, $class_bouton, $javascript, $alt);
4442
+    }
4443 4443
 }
4444 4444
 
4445 4445
 /**
@@ -4463,7 +4463,7 @@  discard block
 block discarded – undo
4463 4463
  *     Code HTML du lien
4464 4464
  **/
4465 4465
 function icone_base($lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') {
4466
-	return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript);
4466
+    return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript);
4467 4467
 }
4468 4468
 
4469 4469
 /**
@@ -4498,7 +4498,7 @@  discard block
 block discarded – undo
4498 4498
  *     Code HTML du lien
4499 4499
  **/
4500 4500
 function filtre_icone_verticale_dist($lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') {
4501
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript);
4501
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript);
4502 4502
 }
4503 4503
 
4504 4504
 /**
@@ -4543,7 +4543,7 @@  discard block
 block discarded – undo
4543 4543
  *     Code HTML du lien
4544 4544
  **/
4545 4545
 function filtre_icone_horizontale_dist($lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') {
4546
-	return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript);
4546
+    return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript);
4547 4547
 }
4548 4548
 
4549 4549
 /**
@@ -4574,7 +4574,7 @@  discard block
 block discarded – undo
4574 4574
  *     Code HTML du lien
4575 4575
  **/
4576 4576
 function filtre_bouton_action_horizontal_dist($lien, $texte, $fond, $fonction = '', $class = '', $confirm = '') {
4577
-	return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, $class, $confirm);
4577
+    return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, $class, $confirm);
4578 4578
 }
4579 4579
 
4580 4580
 /**
@@ -4605,7 +4605,7 @@  discard block
 block discarded – undo
4605 4605
  *     Code HTML du lien
4606 4606
  */
4607 4607
 function filtre_icone_dist($lien, $texte, $fond, $align = '', $fonction = '', $class = '', $javascript = '') {
4608
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript);
4608
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript);
4609 4609
 }
4610 4610
 
4611 4611
 
@@ -4627,7 +4627,7 @@  discard block
 block discarded – undo
4627 4627
  * @return array Liste des éléments
4628 4628
  */
4629 4629
 function filtre_explode_dist($a, $b) {
4630
-	return explode($b, (string) $a);
4630
+    return explode($b, (string) $a);
4631 4631
 }
4632 4632
 
4633 4633
 /**
@@ -4648,7 +4648,7 @@  discard block
 block discarded – undo
4648 4648
  * @return string Texte
4649 4649
  */
4650 4650
 function filtre_implode_dist($a, $b) {
4651
-	return is_array($a) ? implode($b, $a) : $a;
4651
+    return is_array($a) ? implode($b, $a) : $a;
4652 4652
 }
4653 4653
 
4654 4654
 /**
@@ -4657,22 +4657,22 @@  discard block
 block discarded – undo
4657 4657
  * @return string Code CSS
4658 4658
  */
4659 4659
 function bando_images_background() {
4660
-	include_spip('inc/bandeau');
4661
-	// recuperer tous les boutons et leurs images
4662
-	$boutons = definir_barre_boutons(definir_barre_contexte(), true, false);
4660
+    include_spip('inc/bandeau');
4661
+    // recuperer tous les boutons et leurs images
4662
+    $boutons = definir_barre_boutons(definir_barre_contexte(), true, false);
4663 4663
 
4664
-	$res = '';
4665
-	foreach ($boutons as $page => $detail) {
4666
-		$selecteur = (in_array($page, ['outils_rapides', 'outils_collaboratifs']) ? '' : '.navigation_avec_icones ');
4667
-		foreach ($detail->sousmenu as $souspage => $sousdetail) {
4668
-			if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4669
-				$img = http_img_variante_svg_si_possible($sousdetail->icone);
4670
-				$res .= "\n$selecteur.bando2_$souspage {background-image:url($img);}";
4671
-			}
4672
-		}
4673
-	}
4664
+    $res = '';
4665
+    foreach ($boutons as $page => $detail) {
4666
+        $selecteur = (in_array($page, ['outils_rapides', 'outils_collaboratifs']) ? '' : '.navigation_avec_icones ');
4667
+        foreach ($detail->sousmenu as $souspage => $sousdetail) {
4668
+            if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4669
+                $img = http_img_variante_svg_si_possible($sousdetail->icone);
4670
+                $res .= "\n$selecteur.bando2_$souspage {background-image:url($img);}";
4671
+            }
4672
+        }
4673
+    }
4674 4674
 
4675
-	return $res;
4675
+    return $res;
4676 4676
 }
4677 4677
 
4678 4678
 /**
@@ -4697,27 +4697,27 @@  discard block
 block discarded – undo
4697 4697
  */
4698 4698
 function bouton_action($libelle, $url, $class = '', $confirm = '', $title = '', $callback = '') {
4699 4699
 
4700
-	// Classes : dispatcher `ajax` sur le formulaire
4701
-	$class_form = '';
4702
-	if (strpos($class, 'ajax') !== false) {
4703
-		$class_form = 'ajax';
4704
-		$class = str_replace('ajax', '', $class);
4705
-	}
4706
-	$class_btn = 'submit ' . trim($class);
4700
+    // Classes : dispatcher `ajax` sur le formulaire
4701
+    $class_form = '';
4702
+    if (strpos($class, 'ajax') !== false) {
4703
+        $class_form = 'ajax';
4704
+        $class = str_replace('ajax', '', $class);
4705
+    }
4706
+    $class_btn = 'submit ' . trim($class);
4707 4707
 
4708
-	if ($confirm) {
4709
-		$confirm = 'confirm("' . attribut_html($confirm) . '")';
4710
-		if ($callback) {
4711
-			$callback = "$confirm?($callback):false";
4712
-		} else {
4713
-			$callback = $confirm;
4714
-		}
4715
-	}
4716
-	$onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : '';
4717
-	$title = $title ? " title='$title'" : '';
4708
+    if ($confirm) {
4709
+        $confirm = 'confirm("' . attribut_html($confirm) . '")';
4710
+        if ($callback) {
4711
+            $callback = "$confirm?($callback):false";
4712
+        } else {
4713
+            $callback = $confirm;
4714
+        }
4715
+    }
4716
+    $onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : '';
4717
+    $title = $title ? " title='$title'" : '';
4718 4718
 
4719
-	return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>" . form_hidden($url)
4720
-	. "<button type='submit' class='$class_btn'$title$onclick>$libelle</button></div></form>";
4719
+    return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>" . form_hidden($url)
4720
+    . "<button type='submit' class='$class_btn'$title$onclick>$libelle</button></div></form>";
4721 4721
 }
4722 4722
 
4723 4723
 /**
@@ -4740,101 +4740,101 @@  discard block
 block discarded – undo
4740 4740
  * @return string
4741 4741
  */
4742 4742
 function generer_objet_info($id_objet, string $type_objet, string $info, string $etoile = '', array $params = []): string {
4743
-	static $trouver_table = null;
4744
-	static $objets;
4745
-
4746
-	// On verifie qu'on a tout ce qu'il faut
4747
-	$id_objet = intval($id_objet);
4748
-	if (!($id_objet and $type_objet and $info)) {
4749
-		return '';
4750
-	}
4751
-
4752
-	// si on a deja note que l'objet n'existe pas, ne pas aller plus loin
4753
-	if (isset($objets[$type_objet]) and $objets[$type_objet] === false) {
4754
-		return '';
4755
-	}
4756
-
4757
-	// Si on demande l'url, on retourne direct la fonction
4758
-	if ($info == 'url') {
4759
-		return generer_objet_url($id_objet, $type_objet, ...$params);
4760
-	}
4761
-
4762
-	// Sinon on va tout chercher dans la table et on garde en memoire
4763
-	$demande_titre = ($info === 'titre');
4764
-	$demande_introduction = ($info === 'introduction');
4765
-
4766
-	// 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
4767
-	if (
4768
-		!isset($objets[$type_objet][$id_objet])
4769
-		or
4770
-		($demande_titre and !isset($objets[$type_objet][$id_objet]['titre']))
4771
-	) {
4772
-		if (!$trouver_table) {
4773
-			$trouver_table = charger_fonction('trouver_table', 'base');
4774
-		}
4775
-		$desc = $trouver_table(table_objet_sql($type_objet));
4776
-		if (!$desc) {
4777
-			return $objets[$type_objet] = false;
4778
-		}
4779
-
4780
-		// Si on demande le titre, on le gere en interne
4781
-		$champ_titre = '';
4782
-		if ($demande_titre) {
4783
-			// si pas de titre declare mais champ titre, il sera peuple par le select *
4784
-			$champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4785
-		}
4786
-		include_spip('base/abstract_sql');
4787
-		include_spip('base/connect_sql');
4788
-		$objets[$type_objet][$id_objet] = sql_fetsel(
4789
-			'*' . $champ_titre,
4790
-			$desc['table_sql'],
4791
-			id_table_objet($type_objet) . ' = ' . intval($id_objet)
4792
-		);
4793
-
4794
-		// Toujours noter la longueur d'introduction, même si pas demandé cette fois-ci
4795
-		$objets[$type_objet]['introduction_longueur'] = $desc['introduction_longueur'] ?? null;
4796
-	}
4797
-
4798
-	// Pour les fonction generer_xxx, si on demande l'introduction,
4799
-	// ajouter la longueur au début des params supplémentaires
4800
-	if ($demande_introduction) {
4801
-		$introduction_longueur = $objets[$type_objet]['introduction_longueur'];
4802
-		array_unshift($params, $introduction_longueur);
4803
-	}
4804
-
4805
-	// Si la fonction generer_TYPE_TRUC existe, on l'utilise pour formater $info_generee
4806
-	if (
4807
-		$generer = charger_fonction("generer_{$type_objet}_{$info}", '', true)
4808
-		// @deprecated 4.1 generer_TRUC_TYPE
4809
-		or $generer = charger_fonction("generer_{$info}_{$type_objet}", '', true)
4810
-	) {
4811
-		$info_generee = $generer($id_objet, $objets[$type_objet][$id_objet], ...$params);
4812
-	}
4813
-	// Si la fonction generer_objet_TRUC existe, on l'utilise pour formater $info_generee
4814
-	elseif (
4815
-		$generer = charger_fonction("generer_objet_{$info}", '', true)
4816
-		// @deprecated 4.1 generer_TRUC_entite
4817
-		or $generer = charger_fonction("generer_{$info}_entite", '', true)
4818
-	) {
4819
-		$info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet], ...$params);
4820
-	} // Sinon on prend directement le champ SQL tel quel
4821
-	else {
4822
-		$info_generee = ($objets[$type_objet][$id_objet][$info] ?? '');
4823
-	}
4824
-
4825
-	// On va ensuite appliquer les traitements automatiques si besoin
4826
-	if (!$etoile) {
4827
-		// FIXME: on fournit un ENV minimum avec id et type et connect=''
4828
-		// mais ce fonctionnement est a ameliorer !
4829
-		$info_generee = appliquer_traitement_champ(
4830
-			$info_generee,
4831
-			$info,
4832
-			table_objet($type_objet),
4833
-			['id_objet' => $id_objet, 'objet' => $type_objet, '']
4834
-		);
4835
-	}
4836
-
4837
-	return $info_generee;
4743
+    static $trouver_table = null;
4744
+    static $objets;
4745
+
4746
+    // On verifie qu'on a tout ce qu'il faut
4747
+    $id_objet = intval($id_objet);
4748
+    if (!($id_objet and $type_objet and $info)) {
4749
+        return '';
4750
+    }
4751
+
4752
+    // si on a deja note que l'objet n'existe pas, ne pas aller plus loin
4753
+    if (isset($objets[$type_objet]) and $objets[$type_objet] === false) {
4754
+        return '';
4755
+    }
4756
+
4757
+    // Si on demande l'url, on retourne direct la fonction
4758
+    if ($info == 'url') {
4759
+        return generer_objet_url($id_objet, $type_objet, ...$params);
4760
+    }
4761
+
4762
+    // Sinon on va tout chercher dans la table et on garde en memoire
4763
+    $demande_titre = ($info === 'titre');
4764
+    $demande_introduction = ($info === 'introduction');
4765
+
4766
+    // 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
4767
+    if (
4768
+        !isset($objets[$type_objet][$id_objet])
4769
+        or
4770
+        ($demande_titre and !isset($objets[$type_objet][$id_objet]['titre']))
4771
+    ) {
4772
+        if (!$trouver_table) {
4773
+            $trouver_table = charger_fonction('trouver_table', 'base');
4774
+        }
4775
+        $desc = $trouver_table(table_objet_sql($type_objet));
4776
+        if (!$desc) {
4777
+            return $objets[$type_objet] = false;
4778
+        }
4779
+
4780
+        // Si on demande le titre, on le gere en interne
4781
+        $champ_titre = '';
4782
+        if ($demande_titre) {
4783
+            // si pas de titre declare mais champ titre, il sera peuple par le select *
4784
+            $champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4785
+        }
4786
+        include_spip('base/abstract_sql');
4787
+        include_spip('base/connect_sql');
4788
+        $objets[$type_objet][$id_objet] = sql_fetsel(
4789
+            '*' . $champ_titre,
4790
+            $desc['table_sql'],
4791
+            id_table_objet($type_objet) . ' = ' . intval($id_objet)
4792
+        );
4793
+
4794
+        // Toujours noter la longueur d'introduction, même si pas demandé cette fois-ci
4795
+        $objets[$type_objet]['introduction_longueur'] = $desc['introduction_longueur'] ?? null;
4796
+    }
4797
+
4798
+    // Pour les fonction generer_xxx, si on demande l'introduction,
4799
+    // ajouter la longueur au début des params supplémentaires
4800
+    if ($demande_introduction) {
4801
+        $introduction_longueur = $objets[$type_objet]['introduction_longueur'];
4802
+        array_unshift($params, $introduction_longueur);
4803
+    }
4804
+
4805
+    // Si la fonction generer_TYPE_TRUC existe, on l'utilise pour formater $info_generee
4806
+    if (
4807
+        $generer = charger_fonction("generer_{$type_objet}_{$info}", '', true)
4808
+        // @deprecated 4.1 generer_TRUC_TYPE
4809
+        or $generer = charger_fonction("generer_{$info}_{$type_objet}", '', true)
4810
+    ) {
4811
+        $info_generee = $generer($id_objet, $objets[$type_objet][$id_objet], ...$params);
4812
+    }
4813
+    // Si la fonction generer_objet_TRUC existe, on l'utilise pour formater $info_generee
4814
+    elseif (
4815
+        $generer = charger_fonction("generer_objet_{$info}", '', true)
4816
+        // @deprecated 4.1 generer_TRUC_entite
4817
+        or $generer = charger_fonction("generer_{$info}_entite", '', true)
4818
+    ) {
4819
+        $info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet], ...$params);
4820
+    } // Sinon on prend directement le champ SQL tel quel
4821
+    else {
4822
+        $info_generee = ($objets[$type_objet][$id_objet][$info] ?? '');
4823
+    }
4824
+
4825
+    // On va ensuite appliquer les traitements automatiques si besoin
4826
+    if (!$etoile) {
4827
+        // FIXME: on fournit un ENV minimum avec id et type et connect=''
4828
+        // mais ce fonctionnement est a ameliorer !
4829
+        $info_generee = appliquer_traitement_champ(
4830
+            $info_generee,
4831
+            $info,
4832
+            table_objet($type_objet),
4833
+            ['id_objet' => $id_objet, 'objet' => $type_objet, '']
4834
+        );
4835
+    }
4836
+
4837
+    return $info_generee;
4838 4838
 }
4839 4839
 
4840 4840
 /**
@@ -4842,7 +4842,7 @@  discard block
 block discarded – undo
4842 4842
  * @see generer_objet_info
4843 4843
  */
4844 4844
 function generer_info_entite($id_objet, $type_objet, $info, $etoile = '', $params = []) {
4845
-	return generer_objet_info(intval($id_objet), $type_objet, $info, $etoile, $params);
4845
+    return generer_objet_info(intval($id_objet), $type_objet, $info, $etoile, $params);
4846 4846
 }
4847 4847
 
4848 4848
 /**
@@ -4875,36 +4875,36 @@  discard block
 block discarded – undo
4875 4875
  */
4876 4876
 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 {
4877 4877
 
4878
-	$descriptif = $ligne_sql['descriptif'] ?? '';
4879
-	$texte = $ligne_sql['texte'] ?? '';
4880
-	// En absence de descriptif, on se rabat sur chapo + texte
4881
-	if (isset($ligne_sql['chapo'])) {
4882
-		$chapo = $ligne_sql['chapo'];
4883
-		$texte = strlen($descriptif) ?
4884
-			'' :
4885
-			"$chapo \n\n $texte";
4886
-	}
4878
+    $descriptif = $ligne_sql['descriptif'] ?? '';
4879
+    $texte = $ligne_sql['texte'] ?? '';
4880
+    // En absence de descriptif, on se rabat sur chapo + texte
4881
+    if (isset($ligne_sql['chapo'])) {
4882
+        $chapo = $ligne_sql['chapo'];
4883
+        $texte = strlen($descriptif) ?
4884
+            '' :
4885
+            "$chapo \n\n $texte";
4886
+    }
4887 4887
 
4888
-	// Longueur en paramètre, sinon celle renseignée dans la description de l'objet, sinon valeur en dur
4889
-	if (!intval($longueur_ou_suite)) {
4890
-		$longueur = intval($introduction_longueur ?: 600);
4891
-	} else {
4892
-		$longueur = intval($longueur_ou_suite);
4893
-	}
4888
+    // Longueur en paramètre, sinon celle renseignée dans la description de l'objet, sinon valeur en dur
4889
+    if (!intval($longueur_ou_suite)) {
4890
+        $longueur = intval($introduction_longueur ?: 600);
4891
+    } else {
4892
+        $longueur = intval($longueur_ou_suite);
4893
+    }
4894 4894
 
4895
-	// On peut optionnellement passer la suite en 1er paramètre de la balise
4896
-	// Ex : #INTRODUCTION{...}
4897
-	if (
4898
-		is_null($suite)
4899
-		and !intval($longueur_ou_suite)
4900
-	) {
4901
-		$suite = $longueur_ou_suite;
4902
-	}
4895
+    // On peut optionnellement passer la suite en 1er paramètre de la balise
4896
+    // Ex : #INTRODUCTION{...}
4897
+    if (
4898
+        is_null($suite)
4899
+        and !intval($longueur_ou_suite)
4900
+    ) {
4901
+        $suite = $longueur_ou_suite;
4902
+    }
4903 4903
 
4904
-	$f = chercher_filtre('introduction');
4905
-	$introduction = $f($descriptif, $texte, $longueur, $connect, $suite);
4904
+    $f = chercher_filtre('introduction');
4905
+    $introduction = $f($descriptif, $texte, $longueur, $connect, $suite);
4906 4906
 
4907
-	return $introduction;
4907
+    return $introduction;
4908 4908
 }
4909 4909
 
4910 4910
 /**
@@ -4912,7 +4912,7 @@  discard block
 block discarded – undo
4912 4912
  * @see generer_objet_introduction
4913 4913
  */
4914 4914
 function generer_introduction_entite($id_objet, $type_objet, $ligne_sql, $introduction_longueur = null, $longueur_ou_suite = null, $suite = null, string $connect = '') {
4915
-	return generer_objet_introduction(intval($id_objet), $type_objet, $ligne_sql, $introduction_longueur, $longueur_ou_suite, $suite, $connect);
4915
+    return generer_objet_introduction(intval($id_objet), $type_objet, $ligne_sql, $introduction_longueur, $longueur_ou_suite, $suite, $connect);
4916 4916
 }
4917 4917
 
4918 4918
 /**
@@ -4926,49 +4926,49 @@  discard block
 block discarded – undo
4926 4926
  * @return string
4927 4927
  */
4928 4928
 function appliquer_traitement_champ($texte, $champ, $table_objet = '', $env = [], string $connect = '') {
4929
-	if (!$champ) {
4930
-		return $texte;
4931
-	}
4929
+    if (!$champ) {
4930
+        return $texte;
4931
+    }
4932 4932
 
4933
-	// On charge les définitions des traitements (inc/texte et fichiers de fonctions)
4934
-	// car il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4935
-	include_fichiers_fonctions();
4933
+    // On charge les définitions des traitements (inc/texte et fichiers de fonctions)
4934
+    // car il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4935
+    include_fichiers_fonctions();
4936 4936
 
4937
-	$champ = strtoupper($champ);
4938
-	$traitements = $GLOBALS['table_des_traitements'][$champ] ?? false;
4939
-	if (!$traitements or !is_array($traitements)) {
4940
-		return $texte;
4941
-	}
4937
+    $champ = strtoupper($champ);
4938
+    $traitements = $GLOBALS['table_des_traitements'][$champ] ?? false;
4939
+    if (!$traitements or !is_array($traitements)) {
4940
+        return $texte;
4941
+    }
4942 4942
 
4943
-	$traitement = '';
4944
-	if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) {
4945
-		// necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4946
-		$table_objet = table_objet($table_objet);
4947
-		if (isset($traitements[$table_objet])) {
4948
-			$traitement = $traitements[$table_objet];
4949
-		}
4950
-	}
4951
-	if (!$traitement and isset($traitements[0])) {
4952
-		$traitement = $traitements[0];
4953
-	}
4954
-	// (sinon prendre le premier de la liste par defaut ?)
4943
+    $traitement = '';
4944
+    if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) {
4945
+        // necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4946
+        $table_objet = table_objet($table_objet);
4947
+        if (isset($traitements[$table_objet])) {
4948
+            $traitement = $traitements[$table_objet];
4949
+        }
4950
+    }
4951
+    if (!$traitement and isset($traitements[0])) {
4952
+        $traitement = $traitements[0];
4953
+    }
4954
+    // (sinon prendre le premier de la liste par defaut ?)
4955 4955
 
4956
-	if (!$traitement) {
4957
-		return $texte;
4958
-	}
4956
+    if (!$traitement) {
4957
+        return $texte;
4958
+    }
4959 4959
 
4960
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4960
+    $traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4961 4961
 
4962
-	// signaler qu'on est dans l'espace prive pour les filtres qui se servent de ce flag
4963
-	if (test_espace_prive()) {
4964
-		$env['espace_prive'] = 1;
4965
-	}
4962
+    // signaler qu'on est dans l'espace prive pour les filtres qui se servent de ce flag
4963
+    if (test_espace_prive()) {
4964
+        $env['espace_prive'] = 1;
4965
+    }
4966 4966
 
4967
-	// Fournir $connect et $Pile[0] au traitement si besoin
4968
-	$Pile = [0 => $env];
4969
-	eval("\$texte = $traitement;");
4967
+    // Fournir $connect et $Pile[0] au traitement si besoin
4968
+    $Pile = [0 => $env];
4969
+    eval("\$texte = $traitement;");
4970 4970
 
4971
-	return $texte;
4971
+    return $texte;
4972 4972
 }
4973 4973
 
4974 4974
 
@@ -4982,21 +4982,21 @@  discard block
 block discarded – undo
4982 4982
  * @return string
4983 4983
  */
4984 4984
 function generer_objet_lien(int $id_objet, string $objet, int $longueur = 80, string $connect = ''): string {
4985
-	include_spip('inc/liens');
4986
-	$titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4987
-	// lorsque l'objet n'est plus declare (plugin desactive par exemple)
4988
-	// le raccourcis n'est plus valide
4989
-	$titre = typo($titre['titre'] ?? '');
4990
-	// on essaye avec generer_info_entite ?
4991
-	if (!strlen($titre) and !$connect) {
4992
-		$titre = generer_objet_info($id_objet, $objet, 'titre');
4993
-	}
4994
-	if (!strlen($titre)) {
4995
-		$titre = _T('info_sans_titre');
4996
-	}
4997
-	$url = generer_objet_url($id_objet, $objet, '', '', null, '', $connect);
4985
+    include_spip('inc/liens');
4986
+    $titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4987
+    // lorsque l'objet n'est plus declare (plugin desactive par exemple)
4988
+    // le raccourcis n'est plus valide
4989
+    $titre = typo($titre['titre'] ?? '');
4990
+    // on essaye avec generer_info_entite ?
4991
+    if (!strlen($titre) and !$connect) {
4992
+        $titre = generer_objet_info($id_objet, $objet, 'titre');
4993
+    }
4994
+    if (!strlen($titre)) {
4995
+        $titre = _T('info_sans_titre');
4996
+    }
4997
+    $url = generer_objet_url($id_objet, $objet, '', '', null, '', $connect);
4998 4998
 
4999
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . '</a>';
4999
+    return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . '</a>';
5000 5000
 }
5001 5001
 
5002 5002
 /**
@@ -5004,7 +5004,7 @@  discard block
 block discarded – undo
5004 5004
  * @see generer_objet_lien
5005 5005
  */
5006 5006
 function generer_lien_entite($id_objet, $objet, $longueur = 80, $connect = null) {
5007
-	return generer_objet_lien(intval($id_objet), $objet, $longueur, $connect ?? '');
5007
+    return generer_objet_lien(intval($id_objet), $objet, $longueur, $connect ?? '');
5008 5008
 }
5009 5009
 
5010 5010
 /**
@@ -5020,15 +5020,15 @@  discard block
 block discarded – undo
5020 5020
  * @return string
5021 5021
  */
5022 5022
 function wrap($texte, $wrap) {
5023
-	$balises = extraire_balises($wrap);
5024
-	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
5025
-		$texte = $wrap . $texte;
5026
-		$regs = array_reverse($regs[1]);
5027
-		$wrap = '</' . implode('></', $regs) . '>';
5028
-		$texte = $texte . $wrap;
5029
-	}
5023
+    $balises = extraire_balises($wrap);
5024
+    if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
5025
+        $texte = $wrap . $texte;
5026
+        $regs = array_reverse($regs[1]);
5027
+        $wrap = '</' . implode('></', $regs) . '>';
5028
+        $texte = $texte . $wrap;
5029
+    }
5030 5030
 
5031
-	return $texte;
5031
+    return $texte;
5032 5032
 }
5033 5033
 
5034 5034
 
@@ -5048,44 +5048,44 @@  discard block
 block discarded – undo
5048 5048
  * @return array|mixed|string
5049 5049
  */
5050 5050
 function filtre_print_dist($u, $join = '<br />', $indent = 0) {
5051
-	if (is_string($u)) {
5052
-		$u = typo($u);
5051
+    if (is_string($u)) {
5052
+        $u = typo($u);
5053 5053
 
5054
-		return $u;
5055
-	}
5054
+        return $u;
5055
+    }
5056 5056
 
5057
-	// caster $u en array si besoin
5058
-	if (is_object($u)) {
5059
-		$u = (array)$u;
5060
-	}
5057
+    // caster $u en array si besoin
5058
+    if (is_object($u)) {
5059
+        $u = (array)$u;
5060
+    }
5061 5061
 
5062
-	if (is_array($u)) {
5063
-		$out = '';
5064
-		// toutes les cles sont numeriques ?
5065
-		// et aucun enfant n'est un tableau
5066
-		// liste simple separee par des virgules
5067
-		$numeric_keys = array_map('is_numeric', array_keys($u));
5068
-		$array_values = array_map('is_array', $u);
5069
-		$object_values = array_map('is_object', $u);
5070
-		if (
5071
-			array_sum($numeric_keys) == count($numeric_keys)
5072
-			and !array_sum($array_values)
5073
-			and !array_sum($object_values)
5074
-		) {
5075
-			return join(', ', array_map('filtre_print_dist', $u));
5076
-		}
5062
+    if (is_array($u)) {
5063
+        $out = '';
5064
+        // toutes les cles sont numeriques ?
5065
+        // et aucun enfant n'est un tableau
5066
+        // liste simple separee par des virgules
5067
+        $numeric_keys = array_map('is_numeric', array_keys($u));
5068
+        $array_values = array_map('is_array', $u);
5069
+        $object_values = array_map('is_object', $u);
5070
+        if (
5071
+            array_sum($numeric_keys) == count($numeric_keys)
5072
+            and !array_sum($array_values)
5073
+            and !array_sum($object_values)
5074
+        ) {
5075
+            return join(', ', array_map('filtre_print_dist', $u));
5076
+        }
5077 5077
 
5078
-		// sinon on passe a la ligne et on indente
5079
-		$i_str = str_pad('', $indent, ' ');
5080
-		foreach ($u as $k => $v) {
5081
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
5082
-		}
5078
+        // sinon on passe a la ligne et on indente
5079
+        $i_str = str_pad('', $indent, ' ');
5080
+        foreach ($u as $k => $v) {
5081
+            $out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
5082
+        }
5083 5083
 
5084
-		return $out;
5085
-	}
5084
+        return $out;
5085
+    }
5086 5086
 
5087
-	// on sait pas quoi faire...
5088
-	return $u;
5087
+    // on sait pas quoi faire...
5088
+    return $u;
5089 5089
 }
5090 5090
 
5091 5091
 
@@ -5098,10 +5098,10 @@  discard block
 block discarded – undo
5098 5098
  * @return string|array
5099 5099
  */
5100 5100
 function objet_info($objet, $info) {
5101
-	$table = table_objet_sql($objet);
5102
-	$infos = lister_tables_objets_sql($table);
5101
+    $table = table_objet_sql($objet);
5102
+    $infos = lister_tables_objets_sql($table);
5103 5103
 
5104
-	return ($infos[$info] ?? '');
5104
+    return ($infos[$info] ?? '');
5105 5105
 }
5106 5106
 
5107 5107
 /**
@@ -5116,11 +5116,11 @@  discard block
 block discarded – undo
5116 5116
  *     Texte traduit du comptage, tel que '3 articles'
5117 5117
  */
5118 5118
 function objet_afficher_nb($nb, $objet) {
5119
-	if (!$nb) {
5120
-		return _T(objet_info($objet, 'info_aucun_objet'));
5121
-	} else {
5122
-		return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), ['nb' => $nb]);
5123
-	}
5119
+    if (!$nb) {
5120
+        return _T(objet_info($objet, 'info_aucun_objet'));
5121
+    } else {
5122
+        return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), ['nb' => $nb]);
5123
+    }
5124 5124
 }
5125 5125
 
5126 5126
 /**
@@ -5132,11 +5132,11 @@  discard block
 block discarded – undo
5132 5132
  * @return string
5133 5133
  */
5134 5134
 function objet_icone($objet, $taille = 24, $class = '') {
5135
-	$icone = objet_info($objet, 'icone_objet') . '-' . $taille . '.png';
5136
-	$icone = chemin_image($icone);
5137
-	$balise_img = charger_filtre('balise_img');
5135
+    $icone = objet_info($objet, 'icone_objet') . '-' . $taille . '.png';
5136
+    $icone = chemin_image($icone);
5137
+    $balise_img = charger_filtre('balise_img');
5138 5138
 
5139
-	return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : '';
5139
+    return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : '';
5140 5140
 }
5141 5141
 
5142 5142
 /**
@@ -5157,12 +5157,12 @@  discard block
 block discarded – undo
5157 5157
  * @return string
5158 5158
  */
5159 5159
 function objet_T($objet, $chaine, $args = [], $options = []) {
5160
-	$chaine = explode(':', $chaine);
5161
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, ['force' => false]))) {
5162
-		return $t;
5163
-	}
5164
-	$chaine = implode(':', $chaine);
5165
-	return _T($chaine, $args, $options);
5160
+    $chaine = explode(':', $chaine);
5161
+    if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, ['force' => false]))) {
5162
+        return $t;
5163
+    }
5164
+    $chaine = implode(':', $chaine);
5165
+    return _T($chaine, $args, $options);
5166 5166
 }
5167 5167
 
5168 5168
 /**
@@ -5176,18 +5176,18 @@  discard block
 block discarded – undo
5176 5176
  * @return string      Code HTML
5177 5177
  */
5178 5178
 function insert_head_css_conditionnel($flux) {
5179
-	if (
5180
-		strpos($flux, '<!-- insert_head_css -->') === false
5181
-		and $p = strpos($flux, '<!-- insert_head -->')
5182
-	) {
5183
-		// plutot avant le premier js externe (jquery) pour etre non bloquant
5184
-		if ($p1 = stripos($flux, '<script src=') and $p1 < $p) {
5185
-			$p = $p1;
5186
-		}
5187
-		$flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
5188
-	}
5179
+    if (
5180
+        strpos($flux, '<!-- insert_head_css -->') === false
5181
+        and $p = strpos($flux, '<!-- insert_head -->')
5182
+    ) {
5183
+        // plutot avant le premier js externe (jquery) pour etre non bloquant
5184
+        if ($p1 = stripos($flux, '<script src=') and $p1 < $p) {
5185
+            $p = $p1;
5186
+        }
5187
+        $flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
5188
+    }
5189 5189
 
5190
-	return $flux;
5190
+    return $flux;
5191 5191
 }
5192 5192
 
5193 5193
 /**
@@ -5210,75 +5210,75 @@  discard block
 block discarded – undo
5210 5210
  * @return string
5211 5211
  */
5212 5212
 function produire_fond_statique($fond, $contexte = [], $options = [], string $connect = '') {
5213
-	if (isset($contexte['format'])) {
5214
-		$extension = $contexte['format'];
5215
-		unset($contexte['format']);
5216
-	} else {
5217
-		$extension = 'html';
5218
-		if (preg_match(',[.](css|js|json|xml|svg)$,', $fond, $m)) {
5219
-			$extension = $m[1];
5220
-		}
5221
-	}
5222
-	// recuperer le contenu produit par le squelette
5223
-	$options['raw'] = true;
5224
-	$cache = recuperer_fond($fond, $contexte, $options, $connect);
5225
-
5226
-	// calculer le nom de la css
5227
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
5228
-	$nom_safe = preg_replace(',\W,', '_', str_replace('.', '_', $fond));
5229
-	$contexte_implicite = calculer_contexte_implicite();
5230
-
5231
-	// par defaut on hash selon les contextes qui sont a priori moins variables
5232
-	// mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
5233
-	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
5234
-	if (isset($options['hash_on_content']) and $options['hash_on_content']) {
5235
-		$hash = md5($contexte_implicite['host'] . '::' . $cache);
5236
-	}
5237
-	else {
5238
-		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
5239
-		ksort($contexte);
5240
-		$hash = md5($fond . json_encode($contexte_implicite, JSON_THROW_ON_ERROR) . json_encode($contexte, JSON_THROW_ON_ERROR) . $connect);
5241
-	}
5242
-	$filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
5243
-
5244
-	// mettre a jour le fichier si il n'existe pas
5245
-	// ou trop ancien
5246
-	// le dernier fichier produit est toujours suffixe par .last
5247
-	// et recopie sur le fichier cible uniquement si il change
5248
-	if (
5249
-		!file_exists($filename)
5250
-		or !file_exists($filename . '.last')
5251
-		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . '.last') < $cache['lastmodified'])
5252
-		or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
5253
-	) {
5254
-		$contenu = $cache['texte'];
5255
-		// passer les urls en absolu si c'est une css
5256
-		if ($extension == 'css') {
5257
-			$contenu = urls_absolues_css(
5258
-				$contenu,
5259
-				test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond)
5260
-			);
5261
-		}
5262
-
5263
-		$comment = '';
5264
-		// ne pas insérer de commentaire sur certains formats
5265
-		if (!in_array($extension, ['json', 'xml', 'svg'])) {
5266
-			$comment = "/* #PRODUIRE{fond=$fond";
5267
-			foreach ($contexte as $k => $v) {
5268
-				if (is_array($v)) {
5269
-					$v = var_export($v, true);
5270
-				}
5271
-				$comment .= ",$k=$v";
5272
-			}
5273
-			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
5274
-			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
5275
-			$comment .= "}\n   md5:" . md5($contenu) . " */\n";
5276
-		}
5277
-		// et ecrire le fichier si il change
5278
-		ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
5279
-	}
5280
-
5281
-	return timestamp($filename);
5213
+    if (isset($contexte['format'])) {
5214
+        $extension = $contexte['format'];
5215
+        unset($contexte['format']);
5216
+    } else {
5217
+        $extension = 'html';
5218
+        if (preg_match(',[.](css|js|json|xml|svg)$,', $fond, $m)) {
5219
+            $extension = $m[1];
5220
+        }
5221
+    }
5222
+    // recuperer le contenu produit par le squelette
5223
+    $options['raw'] = true;
5224
+    $cache = recuperer_fond($fond, $contexte, $options, $connect);
5225
+
5226
+    // calculer le nom de la css
5227
+    $dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
5228
+    $nom_safe = preg_replace(',\W,', '_', str_replace('.', '_', $fond));
5229
+    $contexte_implicite = calculer_contexte_implicite();
5230
+
5231
+    // par defaut on hash selon les contextes qui sont a priori moins variables
5232
+    // mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
5233
+    // reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
5234
+    if (isset($options['hash_on_content']) and $options['hash_on_content']) {
5235
+        $hash = md5($contexte_implicite['host'] . '::' . $cache);
5236
+    }
5237
+    else {
5238
+        unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
5239
+        ksort($contexte);
5240
+        $hash = md5($fond . json_encode($contexte_implicite, JSON_THROW_ON_ERROR) . json_encode($contexte, JSON_THROW_ON_ERROR) . $connect);
5241
+    }
5242
+    $filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
5243
+
5244
+    // mettre a jour le fichier si il n'existe pas
5245
+    // ou trop ancien
5246
+    // le dernier fichier produit est toujours suffixe par .last
5247
+    // et recopie sur le fichier cible uniquement si il change
5248
+    if (
5249
+        !file_exists($filename)
5250
+        or !file_exists($filename . '.last')
5251
+        or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . '.last') < $cache['lastmodified'])
5252
+        or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
5253
+    ) {
5254
+        $contenu = $cache['texte'];
5255
+        // passer les urls en absolu si c'est une css
5256
+        if ($extension == 'css') {
5257
+            $contenu = urls_absolues_css(
5258
+                $contenu,
5259
+                test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond)
5260
+            );
5261
+        }
5262
+
5263
+        $comment = '';
5264
+        // ne pas insérer de commentaire sur certains formats
5265
+        if (!in_array($extension, ['json', 'xml', 'svg'])) {
5266
+            $comment = "/* #PRODUIRE{fond=$fond";
5267
+            foreach ($contexte as $k => $v) {
5268
+                if (is_array($v)) {
5269
+                    $v = var_export($v, true);
5270
+                }
5271
+                $comment .= ",$k=$v";
5272
+            }
5273
+            // pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
5274
+            // mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
5275
+            $comment .= "}\n   md5:" . md5($contenu) . " */\n";
5276
+        }
5277
+        // et ecrire le fichier si il change
5278
+        ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
5279
+    }
5280
+
5281
+    return timestamp($filename);
5282 5282
 }
5283 5283
 
5284 5284
 /**
@@ -5291,15 +5291,15 @@  discard block
 block discarded – undo
5291 5291
  *    $fichier auquel on a ajouté le timestamp
5292 5292
  */
5293 5293
 function timestamp($fichier) {
5294
-	if (
5295
-		!$fichier
5296
-		or !file_exists($fichier)
5297
-		or !$m = filemtime($fichier)
5298
-	) {
5299
-		return $fichier;
5300
-	}
5294
+    if (
5295
+        !$fichier
5296
+        or !file_exists($fichier)
5297
+        or !$m = filemtime($fichier)
5298
+    ) {
5299
+        return $fichier;
5300
+    }
5301 5301
 
5302
-	return "$fichier?$m";
5302
+    return "$fichier?$m";
5303 5303
 }
5304 5304
 
5305 5305
 /**
@@ -5309,11 +5309,11 @@  discard block
 block discarded – undo
5309 5309
  * @return string
5310 5310
  */
5311 5311
 function supprimer_timestamp($url) {
5312
-	if (strpos($url, '?') === false) {
5313
-		return $url;
5314
-	}
5312
+    if (strpos($url, '?') === false) {
5313
+        return $url;
5314
+    }
5315 5315
 
5316
-	return preg_replace(',\?[[:digit:]]+$,', '', $url);
5316
+    return preg_replace(',\?[[:digit:]]+$,', '', $url);
5317 5317
 }
5318 5318
 
5319 5319
 /**
@@ -5328,15 +5328,15 @@  discard block
 block discarded – undo
5328 5328
  * @return string
5329 5329
  */
5330 5330
 function filtre_nettoyer_titre_email_dist($titre) {
5331
-	include_spip('inc/envoyer_mail');
5331
+    include_spip('inc/envoyer_mail');
5332 5332
 
5333
-	$titre = nettoyer_titre_email($titre);
5334
-	// on est dans un squelette : securiser le retour
5335
-	if (strpos($titre, '<') !== false) {
5336
-		$titre = interdire_scripts($titre);
5337
-	}
5333
+    $titre = nettoyer_titre_email($titre);
5334
+    // on est dans un squelette : securiser le retour
5335
+    if (strpos($titre, '<') !== false) {
5336
+        $titre = interdire_scripts($titre);
5337
+    }
5338 5338
 
5339
-	return $titre;
5339
+    return $titre;
5340 5340
 }
5341 5341
 
5342 5342
 /**
@@ -5358,27 +5358,27 @@  discard block
 block discarded – undo
5358 5358
  * @return string
5359 5359
  */
5360 5360
 function filtre_chercher_rubrique_dist(
5361
-	$titre,
5362
-	$id_objet,
5363
-	$id_parent,
5364
-	$objet,
5365
-	$id_secteur,
5366
-	$restreint,
5367
-	$actionable = false,
5368
-	$retour_sans_cadre = false
5361
+    $titre,
5362
+    $id_objet,
5363
+    $id_parent,
5364
+    $objet,
5365
+    $id_secteur,
5366
+    $restreint,
5367
+    $actionable = false,
5368
+    $retour_sans_cadre = false
5369 5369
 ) {
5370
-	include_spip('inc/filtres_ecrire');
5370
+    include_spip('inc/filtres_ecrire');
5371 5371
 
5372
-	return chercher_rubrique(
5373
-		$titre,
5374
-		$id_objet,
5375
-		$id_parent,
5376
-		$objet,
5377
-		$id_secteur,
5378
-		$restreint,
5379
-		$actionable,
5380
-		$retour_sans_cadre
5381
-	);
5372
+    return chercher_rubrique(
5373
+        $titre,
5374
+        $id_objet,
5375
+        $id_parent,
5376
+        $objet,
5377
+        $id_secteur,
5378
+        $restreint,
5379
+        $actionable,
5380
+        $retour_sans_cadre
5381
+    );
5382 5382
 }
5383 5383
 
5384 5384
 /**
@@ -5407,56 +5407,56 @@  discard block
 block discarded – undo
5407 5407
  *     Chaîne vide si l'accès est autorisé
5408 5408
  */
5409 5409
 function sinon_interdire_acces($ok = false, $url = '', $statut = 0, $message = null) {
5410
-	if ($ok) {
5411
-		return '';
5412
-	}
5413
-
5414
-	// Vider tous les tampons
5415
-	$level = @ob_get_level();
5416
-	while ($level--) {
5417
-		@ob_end_clean();
5418
-	}
5419
-
5420
-	include_spip('inc/headers');
5421
-
5422
-	// S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
5423
-	if ($url) {
5424
-		redirige_par_entete($url, '', $statut);
5425
-	}
5426
-
5427
-	// ecriture simplifiee avec message en 3eme argument (= statut 403)
5428
-	if (!is_numeric($statut) and is_null($message)) {
5429
-		$message = $statut;
5430
-		$statut = 0;
5431
-	}
5432
-	if (!$message) {
5433
-		$message = '';
5434
-	}
5435
-	$statut = intval($statut);
5436
-
5437
-	// Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
5438
-	if (test_espace_prive()) {
5439
-		if (!$statut or !in_array($statut, [404, 403])) {
5440
-			$statut = 403;
5441
-		}
5442
-		http_response_code(403);
5443
-		$echec = charger_fonction('403', 'exec');
5444
-		$echec($message);
5445
-	} else {
5446
-		// Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
5447
-		if (!$statut) {
5448
-			$statut = 404;
5449
-		}
5450
-		// Dans tous les cas on modifie l'entité avec ce qui est demandé
5451
-		http_response_code($statut);
5452
-		// Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
5453
-		if ($statut >= 400) {
5454
-			echo recuperer_fond("$statut", ['erreur' => $message]);
5455
-		}
5456
-	}
5457
-
5458
-
5459
-	exit;
5410
+    if ($ok) {
5411
+        return '';
5412
+    }
5413
+
5414
+    // Vider tous les tampons
5415
+    $level = @ob_get_level();
5416
+    while ($level--) {
5417
+        @ob_end_clean();
5418
+    }
5419
+
5420
+    include_spip('inc/headers');
5421
+
5422
+    // S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
5423
+    if ($url) {
5424
+        redirige_par_entete($url, '', $statut);
5425
+    }
5426
+
5427
+    // ecriture simplifiee avec message en 3eme argument (= statut 403)
5428
+    if (!is_numeric($statut) and is_null($message)) {
5429
+        $message = $statut;
5430
+        $statut = 0;
5431
+    }
5432
+    if (!$message) {
5433
+        $message = '';
5434
+    }
5435
+    $statut = intval($statut);
5436
+
5437
+    // Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
5438
+    if (test_espace_prive()) {
5439
+        if (!$statut or !in_array($statut, [404, 403])) {
5440
+            $statut = 403;
5441
+        }
5442
+        http_response_code(403);
5443
+        $echec = charger_fonction('403', 'exec');
5444
+        $echec($message);
5445
+    } else {
5446
+        // Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
5447
+        if (!$statut) {
5448
+            $statut = 404;
5449
+        }
5450
+        // Dans tous les cas on modifie l'entité avec ce qui est demandé
5451
+        http_response_code($statut);
5452
+        // Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
5453
+        if ($statut >= 400) {
5454
+            echo recuperer_fond("$statut", ['erreur' => $message]);
5455
+        }
5456
+    }
5457
+
5458
+
5459
+    exit;
5460 5460
 }
5461 5461
 
5462 5462
 /**
@@ -5467,11 +5467,11 @@  discard block
 block discarded – undo
5467 5467
  * @return string
5468 5468
  */
5469 5469
 function filtre_compacte_dist($source, $format = null) {
5470
-	if (function_exists('minifier')) {
5471
-		return minifier($source, $format);
5472
-	}
5470
+    if (function_exists('minifier')) {
5471
+        return minifier($source, $format);
5472
+    }
5473 5473
 
5474
-	return $source;
5474
+    return $source;
5475 5475
 }
5476 5476
 
5477 5477
 
@@ -5483,32 +5483,32 @@  discard block
 block discarded – undo
5483 5483
  * @return string
5484 5484
  */
5485 5485
 function spip_affiche_mot_de_passe_masque(?string $passe, bool $afficher_partiellement = false, ?int $portion_pourcent = null): string {
5486
-	$passe ??= '';
5487
-	$l = strlen($passe);
5488
-
5489
-	if ($l <= 8 or !$afficher_partiellement) {
5490
-		if (!$l) {
5491
-			return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
5492
-		}
5493
-		return str_pad('', $afficher_partiellement ? $l : 16, '*');
5494
-	}
5495
-
5496
-	if (is_null($portion_pourcent)) {
5497
-		if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) {
5498
-			define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20%
5499
-		}
5500
-		$portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT;
5501
-	}
5502
-	if ($portion_pourcent >= 100) {
5503
-		return $passe;
5504
-	}
5505
-	$e = intval(ceil($l * $portion_pourcent / 100 / 2));
5506
-	$e = max($e, 0);
5507
-	$mid = str_pad('', $l - 2 * $e, '*');
5508
-	if ($e > 0 and strlen($mid) > 8) {
5509
-		$mid = '***...***';
5510
-	}
5511
-	return substr($passe, 0, $e) . $mid . ($e > 0 ? substr($passe, -$e) : '');
5486
+    $passe ??= '';
5487
+    $l = strlen($passe);
5488
+
5489
+    if ($l <= 8 or !$afficher_partiellement) {
5490
+        if (!$l) {
5491
+            return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
5492
+        }
5493
+        return str_pad('', $afficher_partiellement ? $l : 16, '*');
5494
+    }
5495
+
5496
+    if (is_null($portion_pourcent)) {
5497
+        if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) {
5498
+            define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20%
5499
+        }
5500
+        $portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT;
5501
+    }
5502
+    if ($portion_pourcent >= 100) {
5503
+        return $passe;
5504
+    }
5505
+    $e = intval(ceil($l * $portion_pourcent / 100 / 2));
5506
+    $e = max($e, 0);
5507
+    $mid = str_pad('', $l - 2 * $e, '*');
5508
+    if ($e > 0 and strlen($mid) > 8) {
5509
+        $mid = '***...***';
5510
+    }
5511
+    return substr($passe, 0, $e) . $mid . ($e > 0 ? substr($passe, -$e) : '');
5512 5512
 }
5513 5513
 
5514 5514
 
@@ -5529,64 +5529,64 @@  discard block
 block discarded – undo
5529 5529
  */
5530 5530
 function identifiant_slug($texte, $type = '', $options = []) {
5531 5531
 
5532
-	$original = $texte;
5533
-	$separateur = ($options['separateur'] ?? '_');
5534
-	$longueur_maxi = ($options['longueur_maxi'] ?? 60);
5535
-	$longueur_mini = ($options['longueur_mini'] ?? 0);
5532
+    $original = $texte;
5533
+    $separateur = ($options['separateur'] ?? '_');
5534
+    $longueur_maxi = ($options['longueur_maxi'] ?? 60);
5535
+    $longueur_mini = ($options['longueur_mini'] ?? 0);
5536 5536
 
5537
-	if (!function_exists('translitteration')) {
5538
-		include_spip('inc/charsets');
5539
-	}
5537
+    if (!function_exists('translitteration')) {
5538
+        include_spip('inc/charsets');
5539
+    }
5540 5540
 
5541
-	// pas de balise html
5542
-	if (strpos($texte, '<') !== false) {
5543
-		$texte = strip_tags($texte);
5544
-	}
5545
-	if (strpos($texte, '&') !== false) {
5546
-		$texte = unicode2charset($texte);
5547
-	}
5548
-	// On enlève les espaces indésirables
5549
-	$texte = trim($texte);
5541
+    // pas de balise html
5542
+    if (strpos($texte, '<') !== false) {
5543
+        $texte = strip_tags($texte);
5544
+    }
5545
+    if (strpos($texte, '&') !== false) {
5546
+        $texte = unicode2charset($texte);
5547
+    }
5548
+    // On enlève les espaces indésirables
5549
+    $texte = trim($texte);
5550 5550
 
5551
-	// On enlève les accents et cie
5552
-	$texte = translitteration($texte);
5551
+    // On enlève les accents et cie
5552
+    $texte = translitteration($texte);
5553 5553
 
5554
-	// On remplace tout ce qui n'est pas un mot par un séparateur
5555
-	$texte = preg_replace(',[\W_]+,ms', $separateur, $texte);
5554
+    // On remplace tout ce qui n'est pas un mot par un séparateur
5555
+    $texte = preg_replace(',[\W_]+,ms', $separateur, $texte);
5556 5556
 
5557
-	// nettoyer les doubles occurences du separateur si besoin
5558
-	while (strpos($texte, (string) "$separateur$separateur") !== false) {
5559
-		$texte = str_replace("$separateur$separateur", $separateur, $texte);
5560
-	}
5557
+    // nettoyer les doubles occurences du separateur si besoin
5558
+    while (strpos($texte, (string) "$separateur$separateur") !== false) {
5559
+        $texte = str_replace("$separateur$separateur", $separateur, $texte);
5560
+    }
5561 5561
 
5562
-	// pas de separateur au debut ni a la fin
5563
-	$texte = trim($texte, $separateur);
5562
+    // pas de separateur au debut ni a la fin
5563
+    $texte = trim($texte, $separateur);
5564 5564
 
5565
-	// en minuscules
5566
-	$texte = strtolower($texte);
5565
+    // en minuscules
5566
+    $texte = strtolower($texte);
5567 5567
 
5568
-	switch ($type) {
5569
-		case 'class':
5570
-		case 'id':
5571
-		case 'anchor':
5572
-			if (preg_match(',^\d,', $texte)) {
5573
-				$texte = substr($type, 0, 1) . $texte;
5574
-			}
5575
-	}
5568
+    switch ($type) {
5569
+        case 'class':
5570
+        case 'id':
5571
+        case 'anchor':
5572
+            if (preg_match(',^\d,', $texte)) {
5573
+                $texte = substr($type, 0, 1) . $texte;
5574
+            }
5575
+    }
5576 5576
 
5577
-	if (strlen($texte) > $longueur_maxi) {
5578
-		$texte = substr($texte, 0, $longueur_maxi);
5579
-	}
5577
+    if (strlen($texte) > $longueur_maxi) {
5578
+        $texte = substr($texte, 0, $longueur_maxi);
5579
+    }
5580 5580
 
5581
-	if (strlen($texte) < $longueur_mini and $longueur_mini < $longueur_maxi) {
5582
-		if (preg_match(',^\d,', $texte)) {
5583
-			$texte = ($type ? substr($type, 0, 1) : 's') . $texte;
5584
-		}
5585
-		$texte .= $separateur . md5($original);
5586
-		$texte = substr($texte, 0, $longueur_mini);
5587
-	}
5581
+    if (strlen($texte) < $longueur_mini and $longueur_mini < $longueur_maxi) {
5582
+        if (preg_match(',^\d,', $texte)) {
5583
+            $texte = ($type ? substr($type, 0, 1) : 's') . $texte;
5584
+        }
5585
+        $texte .= $separateur . md5($original);
5586
+        $texte = substr($texte, 0, $longueur_mini);
5587
+    }
5588 5588
 
5589
-	return $texte;
5589
+    return $texte;
5590 5590
 }
5591 5591
 
5592 5592
 
@@ -5607,11 +5607,11 @@  discard block
 block discarded – undo
5607 5607
  * @exemple `<:info_maximum|label_nettoyer:>`
5608 5608
  */
5609 5609
 function label_nettoyer(string $text, bool $ucfirst = true): string {
5610
-	$label = preg_replace('#([\s:]|\&nbsp;)+$#u', '', $text);
5611
-	if ($ucfirst) {
5612
-		$label = spip_ucfirst($label);
5613
-	}
5614
-	return $label;
5610
+    $label = preg_replace('#([\s:]|\&nbsp;)+$#u', '', $text);
5611
+    if ($ucfirst) {
5612
+        $label = spip_ucfirst($label);
5613
+    }
5614
+    return $label;
5615 5615
 }
5616 5616
 
5617 5617
 /**
@@ -5624,8 +5624,8 @@  discard block
 block discarded – undo
5624 5624
  * @exemple `<:info_maximum|label_ponctuer:>`
5625 5625
  */
5626 5626
 function label_ponctuer(string $text, bool $ucfirst = true): string {
5627
-	$label = label_nettoyer($text, $ucfirst);
5628
-	return _T('label_ponctuer', ['label' => $label]);
5627
+    $label = label_nettoyer($text, $ucfirst);
5628
+    return _T('label_ponctuer', ['label' => $label]);
5629 5629
 }
5630 5630
 
5631 5631
 
@@ -5638,19 +5638,19 @@  discard block
 block discarded – undo
5638 5638
  * @return array
5639 5639
  */
5640 5640
 function helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, $fonction) {
5641
-	if (!in_array($fonction, ['objet_lister_parents', 'objet_lister_enfants', 'objet_lister_parents_par_type', 'objet_lister_enfants_par_type'])) {
5642
-		return [];
5643
-	}
5641
+    if (!in_array($fonction, ['objet_lister_parents', 'objet_lister_enfants', 'objet_lister_parents_par_type', 'objet_lister_enfants_par_type'])) {
5642
+        return [];
5643
+    }
5644 5644
 
5645
-	// compatibilite signature inversee
5646
-	if (is_numeric($objet) and !is_numeric($id_objet)) {
5647
-		[$objet, $id_objet] = [$id_objet, $objet];
5648
-	}
5645
+    // compatibilite signature inversee
5646
+    if (is_numeric($objet) and !is_numeric($id_objet)) {
5647
+        [$objet, $id_objet] = [$id_objet, $objet];
5648
+    }
5649 5649
 
5650
-	if (!function_exists($fonction)) {
5651
-		include_spip('base/objets');
5652
-	}
5653
-	return $fonction($objet, $id_objet);
5650
+    if (!function_exists($fonction)) {
5651
+        include_spip('base/objets');
5652
+    }
5653
+    return $fonction($objet, $id_objet);
5654 5654
 }
5655 5655
 
5656 5656
 
@@ -5665,7 +5665,7 @@  discard block
 block discarded – undo
5665 5665
  * @return array
5666 5666
  */
5667 5667
 function filtre_objet_lister_parents_dist($objet, $id_objet) {
5668
-	return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents');
5668
+    return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents');
5669 5669
 }
5670 5670
 
5671 5671
 /**
@@ -5679,7 +5679,7 @@  discard block
 block discarded – undo
5679 5679
  * @return array
5680 5680
  */
5681 5681
 function filtre_objet_lister_parents_par_type_dist($objet, $id_objet) {
5682
-	return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents_par_type');
5682
+    return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents_par_type');
5683 5683
 }
5684 5684
 
5685 5685
 /**
@@ -5693,7 +5693,7 @@  discard block
 block discarded – undo
5693 5693
  * @return array
5694 5694
  */
5695 5695
 function filtre_objet_lister_enfants_dist($objet, $id_objet) {
5696
-	return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants');
5696
+    return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants');
5697 5697
 }
5698 5698
 
5699 5699
 /**
@@ -5707,5 +5707,5 @@  discard block
 block discarded – undo
5707 5707
  * @return array
5708 5708
  */
5709 5709
 function filtre_objet_lister_enfants_par_type_dist($objet, $id_objet) {
5710
-	return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants_par_type');
5710
+    return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants_par_type');
5711 5711
 }
Please login to merge, or discard this patch.
Spacing   +129 added lines, -130 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 !
@@ -1033,7 +1033,7 @@  discard block
 block discarded – undo
1033 1033
  **/
1034 1034
 function supprimer_numero($texte) {
1035 1035
 	return preg_replace(
1036
-		',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1036
+		',^[[:space:]]*([0-9]+)([.)]|'.chr(194).'?'.chr(176).')[[:space:]]+,S',
1037 1037
 		'',
1038 1038
 		$texte
1039 1039
 	);
@@ -1062,7 +1062,7 @@  discard block
 block discarded – undo
1062 1062
 	if (
1063 1063
 		$texte and
1064 1064
 		preg_match(
1065
-			',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1065
+			',^[[:space:]]*([0-9]+)([.)]|'.chr(194).'?'.chr(176).')[[:space:]]+,S',
1066 1066
 			$texte,
1067 1067
 			$regs
1068 1068
 		)
@@ -1153,8 +1153,8 @@  discard block
 block discarded – undo
1153 1153
  **/
1154 1154
 function textebrut($texte) {
1155 1155
 	$u = $GLOBALS['meta']['pcre_u'];
1156
-	$texte = preg_replace('/\s+/S' . $u, ' ', $texte);
1157
-	$texte = preg_replace('/<(p|br)( [^>]*)?' . '>/iS', "\n\n", $texte);
1156
+	$texte = preg_replace('/\s+/S'.$u, ' ', $texte);
1157
+	$texte = preg_replace('/<(p|br)( [^>]*)?'.'>/iS', "\n\n", $texte);
1158 1158
 	$texte = preg_replace("/^\n+/", '', $texte);
1159 1159
 	$texte = preg_replace("/\n+$/", '', $texte);
1160 1160
 	$texte = preg_replace("/\n +/", "\n", $texte);
@@ -1188,7 +1188,7 @@  discard block
 block discarded – undo
1188 1188
 		)
1189 1189
 	) {
1190 1190
 		foreach ($liens[0] as $a) {
1191
-			$rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1191
+			$rel = 'noopener noreferrer '.extraire_attribut($a, 'rel');
1192 1192
 			$ablank = inserer_attribut($a, 'rel', $rel);
1193 1193
 			$ablank = inserer_attribut($ablank, 'target', '_blank');
1194 1194
 			$texte = str_replace($a, $ablank, $texte);
@@ -1213,7 +1213,7 @@  discard block
 block discarded – undo
1213 1213
 		foreach ($regs[0] as $a) {
1214 1214
 			$rel = extraire_attribut($a, 'rel') ?? '';
1215 1215
 			if (strpos($rel, 'nofollow') === false) {
1216
-				$rel = 'nofollow' . ($rel ? " $rel" : '');
1216
+				$rel = 'nofollow'.($rel ? " $rel" : '');
1217 1217
 				$anofollow = inserer_attribut($a, 'rel', $rel);
1218 1218
 				$texte = str_replace($a, $anofollow, $texte);
1219 1219
 			}
@@ -1242,7 +1242,7 @@  discard block
 block discarded – undo
1242 1242
 	$u = $GLOBALS['meta']['pcre_u'];
1243 1243
 	$texte = preg_replace('@</p>@iS', "\n", $texte);
1244 1244
 	$texte = preg_replace("@<p\b.*>@UiS", '<br />', $texte);
1245
-	$texte = preg_replace('@^\s*<br />@S' . $u, '', $texte);
1245
+	$texte = preg_replace('@^\s*<br />@S'.$u, '', $texte);
1246 1246
 
1247 1247
 	return $texte;
1248 1248
 }
@@ -1273,7 +1273,7 @@  discard block
 block discarded – undo
1273 1273
 		return $texte;
1274 1274
 	}
1275 1275
 	include_spip('inc/texte');
1276
-	$tag = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $texte) ?
1276
+	$tag = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $texte) ?
1277 1277
 		'div' : 'span';
1278 1278
 
1279 1279
 	return "<$tag style='word-wrap:break-word;'>$texte</$tag>";
@@ -1385,7 +1385,7 @@  discard block
 block discarded – undo
1385 1385
 	}
1386 1386
 	$u = $GLOBALS['meta']['pcre_u'];
1387 1387
 	if ($textebrut) {
1388
-		$texte = preg_replace([",\n,", ',\s(?=\s),msS' . $u], [' ', ''], textebrut($texte));
1388
+		$texte = preg_replace([",\n,", ',\s(?=\s),msS'.$u], [' ', ''], textebrut($texte));
1389 1389
 	}
1390 1390
 	$texte = texte_backend($texte);
1391 1391
 	$texte = str_replace(["'", '"'], ['&#039;', '&#034;'], $texte);
@@ -1420,7 +1420,7 @@  discard block
 block discarded – undo
1420 1420
 	# un message pour abs_url
1421 1421
 	$GLOBALS['mode_abs_url'] = 'url';
1422 1422
 	$url = trim($url);
1423
-	$r = ',^(?:' . _PROTOCOLES_STD . '):?/?/?$,iS';
1423
+	$r = ',^(?:'._PROTOCOLES_STD.'):?/?/?$,iS';
1424 1424
 
1425 1425
 	return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1426 1426
 }
@@ -1620,14 +1620,14 @@  discard block
 block discarded – undo
1620 1620
 	if (strpos($texte, '<') !== false) {
1621 1621
 		include_spip('inc/lien');
1622 1622
 		if (defined('_PREG_MODELE')) {
1623
-			$preg_modeles = '@' . _PREG_MODELE . '@imsS';
1623
+			$preg_modeles = '@'._PREG_MODELE.'@imsS';
1624 1624
 			$texte = echappe_html($texte, '', true, $preg_modeles);
1625 1625
 		}
1626 1626
 	}
1627 1627
 
1628 1628
 	$debut = '';
1629 1629
 	$suite = $texte;
1630
-	while ($t = strpos('-' . $suite, "\n", 1)) {
1630
+	while ($t = strpos('-'.$suite, "\n", 1)) {
1631 1631
 		$debut .= substr($suite, 0, $t - 1);
1632 1632
 		$suite = substr($suite, $t);
1633 1633
 		$car = substr($suite, 0, 1);
@@ -1645,11 +1645,11 @@  discard block
 block discarded – undo
1645 1645
 			$suite = substr($suite, strlen($regs[0]));
1646 1646
 		}
1647 1647
 	}
1648
-	$texte = $debut . $suite;
1648
+	$texte = $debut.$suite;
1649 1649
 
1650 1650
 	$texte = echappe_retour($texte);
1651 1651
 
1652
-	return $texte . $fin;
1652
+	return $texte.$fin;
1653 1653
 }
1654 1654
 
1655 1655
 
@@ -1711,7 +1711,7 @@  discard block
 block discarded – undo
1711 1711
 		}
1712 1712
 
1713 1713
 		foreach ($regs as $reg) {
1714
-			$cle = ($reg[1] ? $reg[1] . ':' : '') . $reg[2];
1714
+			$cle = ($reg[1] ? $reg[1].':' : '').$reg[2];
1715 1715
 			$desc = $traduire($cle, $lang, true);
1716 1716
 			$l = $desc->langue;
1717 1717
 			// si pas de traduction, on laissera l'écriture de l'idiome entier dans le texte.
@@ -1825,9 +1825,9 @@  discard block
 block discarded – undo
1825 1825
 					// il ne faut pas echapper en div si propre produit un seul paragraphe
1826 1826
 					include_spip('inc/texte');
1827 1827
 					$trad_propre = preg_replace(',(^<p[^>]*>|</p>$),Uims', '', propre($trad));
1828
-					$mode = preg_match(',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1828
+					$mode = preg_match(',</?('._BALISES_BLOCS.')[>[:space:]],iS', $trad_propre) ? 'div' : 'span';
1829 1829
 					if ($mode === 'div') {
1830
-						$trad = rtrim($trad) . "\n\n";
1830
+						$trad = rtrim($trad)."\n\n";
1831 1831
 					}
1832 1832
 					$trad = code_echappement($trad, 'multi', false, $mode);
1833 1833
 					$trad = str_replace("'", '"', inserer_attribut($trad, 'lang', $l));
@@ -2027,7 +2027,7 @@  discard block
 block discarded – undo
2027 2027
 	if (is_array($balise)) {
2028 2028
 		array_walk(
2029 2029
 			$balise,
2030
-			function (&$a, $key, $t) {
2030
+			function(&$a, $key, $t) {
2031 2031
 				$a = extraire_attribut($a, $t);
2032 2032
 			},
2033 2033
 			$attribut
@@ -2124,14 +2124,14 @@  discard block
 block discarded – undo
2124 2124
 
2125 2125
 	if ($old !== null) {
2126 2126
 		// Remplacer l'ancien attribut du meme nom
2127
-		$balise = $r[1] . $insert . $r[5];
2127
+		$balise = $r[1].$insert.$r[5];
2128 2128
 	} else {
2129 2129
 		// preferer une balise " />" (comme <img />)
2130 2130
 		if (preg_match(',/>,', $balise)) {
2131
-			$balise = preg_replace(',\s?/>,S', $insert . ' />', $balise, 1);
2131
+			$balise = preg_replace(',\s?/>,S', $insert.' />', $balise, 1);
2132 2132
 		} // sinon une balise <a ...> ... </a>
2133 2133
 		else {
2134
-			$balise = preg_replace(',\s?>,S', $insert . '>', $balise, 1);
2134
+			$balise = preg_replace(',\s?>,S', $insert.'>', $balise, 1);
2135 2135
 		}
2136 2136
 	}
2137 2137
 
@@ -2186,7 +2186,7 @@  discard block
 block discarded – undo
2186 2186
 		if (
2187 2187
 			$class_courante
2188 2188
 			and strpos($class_courante, (string) $c) !== false
2189
-			and preg_match('/(^|\s)' . preg_quote($c) . '($|\s)/', $class_courante)
2189
+			and preg_match('/(^|\s)'.preg_quote($c).'($|\s)/', $class_courante)
2190 2190
 		) {
2191 2191
 			$is_class_presente = true;
2192 2192
 		}
@@ -2194,12 +2194,12 @@  discard block
 block discarded – undo
2194 2194
 			in_array($operation, ['ajouter', 'commuter'])
2195 2195
 			and !$is_class_presente
2196 2196
 		) {
2197
-			$class_new = ltrim(rtrim($class_new ?? '') . ' ' . $c);
2197
+			$class_new = ltrim(rtrim($class_new ?? '').' '.$c);
2198 2198
 		} elseif (
2199 2199
 			in_array($operation, ['supprimer', 'commuter'])
2200 2200
 			and $is_class_presente
2201 2201
 		) {
2202
-			$class_new = trim(preg_replace('/(^|\s)' . preg_quote($c) . '($|\s)/', "\\1", $class_new));
2202
+			$class_new = trim(preg_replace('/(^|\s)'.preg_quote($c).'($|\s)/', "\\1", $class_new));
2203 2203
 		}
2204 2204
 	}
2205 2205
 
@@ -2262,7 +2262,7 @@  discard block
 block discarded – undo
2262 2262
 // Quelques fonctions de calcul arithmetique
2263 2263
 //
2264 2264
 function floatstr($a) {
2265
- return str_replace(',', '.', (string)floatval($a));
2265
+ return str_replace(',', '.', (string) floatval($a));
2266 2266
 }
2267 2267
 function strize($f, $a, $b) {
2268 2268
  return floatstr($f(floatstr($a), floatstr($b)));
@@ -2398,13 +2398,13 @@  discard block
 block discarded – undo
2398 2398
 	if (!defined('_TAGS_NOM_AUTEUR')) {
2399 2399
 		define('_TAGS_NOM_AUTEUR', '');
2400 2400
 	}
2401
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2401
+	$tags_acceptes = array_unique(explode(',', 'multi,'._TAGS_NOM_AUTEUR));
2402 2402
 	foreach ($tags_acceptes as $tag) {
2403 2403
 		if (strlen($tag)) {
2404
-			$remp1[] = '<' . trim($tag) . '>';
2405
-			$remp1[] = '</' . trim($tag) . '>';
2406
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2407
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2404
+			$remp1[] = '<'.trim($tag).'>';
2405
+			$remp1[] = '</'.trim($tag).'>';
2406
+			$remp2[] = '\x60'.trim($tag).'\x61';
2407
+			$remp2[] = '\x60/'.trim($tag).'\x61';
2408 2408
 		}
2409 2409
 	}
2410 2410
 	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
@@ -2524,10 +2524,10 @@  discard block
 block discarded – undo
2524 2524
 	$fichier = basename($url);
2525 2525
 
2526 2526
 	return '<a rel="enclosure"'
2527
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2528
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2529
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2530
-	. '>' . $fichier . '</a>';
2527
+	. ($url ? ' href="'.spip_htmlspecialchars($url).'"' : '')
2528
+	. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2529
+	. ($length ? ' title="'.spip_htmlspecialchars($length).'"' : '')
2530
+	. '>'.$fichier.'</a>';
2531 2531
 }
2532 2532
 
2533 2533
 /**
@@ -2555,9 +2555,9 @@  discard block
 block discarded – undo
2555 2555
 			} # vieux data
2556 2556
 			$fichier = basename($url);
2557 2557
 			$enclosures[] = '<enclosure'
2558
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2559
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2560
-				. ($length ? ' length="' . $length . '"' : '')
2558
+				. ($url ? ' url="'.spip_htmlspecialchars($url).'"' : '')
2559
+				. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2560
+				. ($length ? ' length="'.$length.'"' : '')
2561 2561
 				. ' />';
2562 2562
 		}
2563 2563
 	}
@@ -2583,7 +2583,7 @@  discard block
 block discarded – undo
2583 2583
 		if (extraire_attribut($e, 'rel') == 'tag') {
2584 2584
 			$subjects .= '<dc:subject>'
2585 2585
 				. texte_backend(textebrut($e))
2586
-				. '</dc:subject>' . "\n";
2586
+				. '</dc:subject>'."\n";
2587 2587
 		}
2588 2588
 	}
2589 2589
 
@@ -2619,7 +2619,7 @@  discard block
 block discarded – undo
2619 2619
 	if (is_array($texte)) {
2620 2620
 		array_walk(
2621 2621
 			$texte,
2622
-			function (&$a, $key, $t) {
2622
+			function(&$a, $key, $t) {
2623 2623
 				$a = extraire_balise($a, $t);
2624 2624
 			},
2625 2625
 			$tag
@@ -2667,7 +2667,7 @@  discard block
 block discarded – undo
2667 2667
 	if (is_array($texte)) {
2668 2668
 		array_walk(
2669 2669
 			$texte,
2670
-			function (&$a, $key, $t) {
2670
+			function(&$a, $key, $t) {
2671 2671
 				$a = extraire_balises($a, $t);
2672 2672
 			},
2673 2673
 			$tag
@@ -2800,7 +2800,7 @@  discard block
 block discarded – undo
2800 2800
 		if ($fond != '404') {
2801 2801
 			$contexte = array_shift($p);
2802 2802
 			$contexte['page'] = $fond;
2803
-			$action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2803
+			$action = preg_replace('/([?]'.preg_quote($fond).'[^&=]*[0-9]+)(&|$)/', '?&', $action);
2804 2804
 		}
2805 2805
 	}
2806 2806
 	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
@@ -2855,9 +2855,9 @@  discard block
 block discarded – undo
2855 2855
 			. '"'
2856 2856
 			. (is_null($val)
2857 2857
 				? ''
2858
-				: ' value="' . entites_html($val) . '"'
2858
+				: ' value="'.entites_html($val).'"'
2859 2859
 			)
2860
-			. ' type="hidden"' . "\n/>";
2860
+			. ' type="hidden"'."\n/>";
2861 2861
 	}
2862 2862
 
2863 2863
 	return join('', $hidden);
@@ -2967,7 +2967,7 @@  discard block
 block discarded – undo
2967 2967
 
2968 2968
 	return preg_replace_callback(
2969 2969
 		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2970
-		fn($x) => "url('" . suivre_lien($path, $x[1]) . "')",
2970
+		fn($x) => "url('".suivre_lien($path, $x[1])."')",
2971 2971
 		$contenu
2972 2972
 	);
2973 2973
 }
@@ -3028,14 +3028,14 @@  discard block
 block discarded – undo
3028 3028
 	) {
3029 3029
 		$distant = true;
3030 3030
 		$cssf = parse_url($css);
3031
-		$cssf = $cssf['path'] . ($cssf['query'] ? '?' . $cssf['query'] : '');
3031
+		$cssf = $cssf['path'].($cssf['query'] ? '?'.$cssf['query'] : '');
3032 3032
 		$cssf = preg_replace(',[?:&=],', '_', $cssf);
3033 3033
 	} else {
3034 3034
 		$distant = false;
3035 3035
 		$cssf = $css;
3036 3036
 		// 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
3037 3037
 		//propose (rien a faire dans ce cas)
3038
-		$f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
3038
+		$f = preg_replace(',(_rtl)?\.css$,i', '_'.$ndir.'.css', $css);
3039 3039
 		if (@file_exists($f)) {
3040 3040
 			return $f;
3041 3041
 		}
@@ -3045,7 +3045,7 @@  discard block
 block discarded – undo
3045 3045
 	$dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
3046 3046
 	$f = $dir_var
3047 3047
 		. preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
3048
-		. '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
3048
+		. '.'.substr(md5($cssf), 0, 4).'_'.$ndir.'.css';
3049 3049
 
3050 3050
 	// la css peut etre distante (url absolue !)
3051 3051
 	if ($distant) {
@@ -3091,8 +3091,8 @@  discard block
 block discarded – undo
3091 3091
 		} // si la css_direction commence par $dir_var on la fait passer pour une absolue
3092 3092
 		elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
3093 3093
 			$css_direction = substr($css_direction, strlen($dir_var));
3094
-			$src_faux_abs['/@@@@@@/' . $css_direction] = $css_direction;
3095
-			$css_direction = '/@@@@@@/' . $css_direction;
3094
+			$src_faux_abs['/@@@@@@/'.$css_direction] = $css_direction;
3095
+			$css_direction = '/@@@@@@/'.$css_direction;
3096 3096
 		}
3097 3097
 		$src[] = $regs[0][$k];
3098 3098
 		$src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
@@ -3141,7 +3141,7 @@  discard block
 block discarded – undo
3141 3141
 
3142 3142
 	$f = basename($css, '.css');
3143 3143
 	$f = sous_repertoire(_DIR_VAR, 'cache-css')
3144
-		. preg_replace(',(.*?)(_rtl|_ltr)?$,', "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
3144
+		. preg_replace(',(.*?)(_rtl|_ltr)?$,', "\\1-urlabs-".substr(md5("$css-urlabs"), 0, 4)."\\2", $f)
3145 3145
 		. '.css';
3146 3146
 
3147 3147
 	if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
@@ -3151,7 +3151,7 @@  discard block
 block discarded – undo
3151 3151
 	if ($url_absolue_css == $css) {
3152 3152
 		if (
3153 3153
 			strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
3154
-			or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
3154
+			or !lire_fichier(_DIR_RACINE.substr($css, $l), $contenu)
3155 3155
 		) {
3156 3156
 			include_spip('inc/distant');
3157 3157
 			$contenu = recuperer_url($css);
@@ -3263,7 +3263,7 @@  discard block
 block discarded – undo
3263 3263
 	$expression = str_replace('\/', '/', $expression);
3264 3264
 	$expression = str_replace('/', '\/', $expression);
3265 3265
 
3266
-	if (preg_match('/' . $expression . '/' . $modif, $texte ?? '', $r)) {
3266
+	if (preg_match('/'.$expression.'/'.$modif, $texte ?? '', $r)) {
3267 3267
 		if (isset($r[$capte])) {
3268 3268
 			return $r[$capte];
3269 3269
 		} else {
@@ -3301,7 +3301,7 @@  discard block
 block discarded – undo
3301 3301
 	$expression = str_replace('\/', '/', $expression);
3302 3302
 	$expression = str_replace('/', '\/', $expression);
3303 3303
 
3304
-	return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3304
+	return preg_replace('/'.$expression.'/'.$modif, $replace, $texte);
3305 3305
 }
3306 3306
 
3307 3307
 
@@ -3320,7 +3320,7 @@  discard block
 block discarded – undo
3320 3320
 function traiter_doublons_documents(&$doublons, $letexte) {
3321 3321
 
3322 3322
 	// Verifier dans le texte & les notes (pas beau, helas)
3323
-	$t = $letexte . $GLOBALS['les_notes'];
3323
+	$t = $letexte.$GLOBALS['les_notes'];
3324 3324
 
3325 3325
 	if (
3326 3326
 		strstr($t, 'spip_document_') // evite le preg_match_all si inutile
@@ -3334,7 +3334,7 @@  discard block
 block discarded – undo
3334 3334
 		if (!isset($doublons['documents'])) {
3335 3335
 			$doublons['documents'] = '';
3336 3336
 		}
3337
-		$doublons['documents'] .= ',' . join(',', $matches[1]);
3337
+		$doublons['documents'] .= ','.join(',', $matches[1]);
3338 3338
 	}
3339 3339
 
3340 3340
 	return $letexte;
@@ -3391,7 +3391,7 @@  discard block
 block discarded – undo
3391 3391
 	if ($env) {
3392 3392
 		foreach ($env as $i => $j) {
3393 3393
 			if (is_string($j) and !in_array($i, $ignore_params)) {
3394
-				$texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3394
+				$texte .= "<param name='".attribut_html($i)."'\n\tvalue='".attribut_html($j)."' />";
3395 3395
 			}
3396 3396
 		}
3397 3397
 	}
@@ -3430,7 +3430,7 @@  discard block
 block discarded – undo
3430 3430
 	if ($env) {
3431 3431
 		foreach ($env as $i => $j) {
3432 3432
 			if (is_string($j) and !in_array($i, $ignore_params)) {
3433
-				$texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3433
+				$texte .= attribut_html($i)."='".attribut_html($j)."' ";
3434 3434
 			}
3435 3435
 		}
3436 3436
 	}
@@ -3504,10 +3504,10 @@  discard block
 block discarded – undo
3504 3504
 	// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3505 3505
 	if (
3506 3506
 		preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3507
-		and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . '-xx.svg'
3507
+		and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])).'-xx.svg'
3508 3508
 		and file_exists($variante_svg_generique)
3509 3509
 	) {
3510
-		if ($variante_svg_size = substr($variante_svg_generique, 0, -6) . $m[1] . '.svg' and file_exists($variante_svg_size)) {
3510
+		if ($variante_svg_size = substr($variante_svg_generique, 0, -6).$m[1].'.svg' and file_exists($variante_svg_size)) {
3511 3511
 			$img_file = $variante_svg_size;
3512 3512
 		}
3513 3513
 		else {
@@ -3565,7 +3565,7 @@  discard block
 block discarded – undo
3565 3565
 				return '';
3566 3566
 			}
3567 3567
 		}
3568
-		$atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3568
+		$atts .= " width='".$largeur."' height='".$hauteur."'";
3569 3569
 	}
3570 3570
 
3571 3571
 	if (file_exists($img_file)) {
@@ -3575,14 +3575,14 @@  discard block
 block discarded – undo
3575 3575
 		$alt = '';
3576 3576
 	}
3577 3577
 	elseif ($alt or $alt === '') {
3578
-		$alt = " alt='" . attribut_html($alt) . "'";
3578
+		$alt = " alt='".attribut_html($alt)."'";
3579 3579
 	}
3580 3580
 	else {
3581
-		$alt = " alt='" . attribut_html($title) . "'";
3581
+		$alt = " alt='".attribut_html($title)."'";
3582 3582
 	}
3583
-	return "<img src='" . attribut_html($img_file) . "'$alt"
3584
-	. ($title ? ' title="' . attribut_html($title) . '"' : '')
3585
-	. ' ' . ltrim($atts)
3583
+	return "<img src='".attribut_html($img_file)."'$alt"
3584
+	. ($title ? ' title="'.attribut_html($title).'"' : '')
3585
+	. ' '.ltrim($atts)
3586 3586
 	. ' />';
3587 3587
 }
3588 3588
 
@@ -3596,10 +3596,10 @@  discard block
 block discarded – undo
3596 3596
  */
3597 3597
 function http_style_background($img, $att = '', $size = null) {
3598 3598
 	if ($size and is_numeric($size)) {
3599
-		$size = trim($size) . 'px';
3599
+		$size = trim($size).'px';
3600 3600
 	}
3601
-	return " style='background" .
3602
-		($att ? '' : '-image') . ': url("' . chemin_image($img) . '")' . ($att ? (' ' . $att) : '') . ';'
3601
+	return " style='background".
3602
+		($att ? '' : '-image').': url("'.chemin_image($img).'")'.($att ? (' '.$att) : '').';'
3603 3603
 		. ($size ? "background-size:{$size};" : '')
3604 3604
 		. "'";
3605 3605
 }
@@ -3714,7 +3714,7 @@  discard block
 block discarded – undo
3714 3714
 		$img = http_img_pack(
3715 3715
 			$img,
3716 3716
 			$alt,
3717
-			$class ? " class='" . attribut_html($class) . "'" : '',
3717
+			$class ? " class='".attribut_html($class)."'" : '',
3718 3718
 			'',
3719 3719
 			['chemin_image' => false, 'utiliser_suffixe_size' => false]
3720 3720
 		);
@@ -3799,7 +3799,7 @@  discard block
 block discarded – undo
3799 3799
 	$balise_svg_source = $balise_svg;
3800 3800
 
3801 3801
 	// entete XML à supprimer
3802
-	$svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3802
+	$svg = preg_replace(',^\s*<\?xml[^>]*\?'.'>,', '', $svg);
3803 3803
 
3804 3804
 	// IE est toujours mon ami
3805 3805
 	$balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
@@ -3817,9 +3817,9 @@  discard block
 block discarded – undo
3817 3817
 	// regler le alt
3818 3818
 	if ($alt) {
3819 3819
 		$balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3820
-		$id = 'img-svg-title-' . substr(md5("$img_file:$svg:$alt"), 0, 4);
3820
+		$id = 'img-svg-title-'.substr(md5("$img_file:$svg:$alt"), 0, 4);
3821 3821
 		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3822
-		$title = "<title id=\"$id\">" . entites_html($alt) . "</title>\n";
3822
+		$title = "<title id=\"$id\">".entites_html($alt)."</title>\n";
3823 3823
 		$balise_svg .= $title;
3824 3824
 	}
3825 3825
 	else {
@@ -3867,7 +3867,7 @@  discard block
 block discarded – undo
3867 3867
 	if (is_array($tableau)) {
3868 3868
 		foreach ($tableau as $k => $v) {
3869 3869
 			$res = recuperer_fond(
3870
-				'modeles/' . $modele,
3870
+				'modeles/'.$modele,
3871 3871
 				array_merge(['cle' => $k], (is_array($v) ? $v : ['valeur' => $v]))
3872 3872
 			);
3873 3873
 			$texte .= $res;
@@ -4052,7 +4052,7 @@  discard block
 block discarded – undo
4052 4052
 	}
4053 4053
 
4054 4054
 	$c = serialize($c);
4055
-	$cle = calculer_cle_action($form . $c);
4055
+	$cle = calculer_cle_action($form.$c);
4056 4056
 	$c = "$cle:$c";
4057 4057
 
4058 4058
 	// on ne stocke pas les contextes dans des fichiers en cache
@@ -4110,15 +4110,15 @@  discard block
 block discarded – undo
4110 4110
 	}
4111 4111
 	// toujours encoder l'url source dans le bloc ajax
4112 4112
 	$r = self();
4113
-	$r = ' data-origin="' . $r . '"';
4113
+	$r = ' data-origin="'.$r.'"';
4114 4114
 	$class = 'ajaxbloc';
4115 4115
 	if ($ajaxid and is_string($ajaxid)) {
4116 4116
 		// ajaxid est normalement conforme a un nom de classe css
4117 4117
 		// on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
4118
-		$class .= ' ajax-id-' . entites_html($ajaxid);
4118
+		$class .= ' ajax-id-'.entites_html($ajaxid);
4119 4119
 	}
4120 4120
 
4121
-	return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
4121
+	return "<div class='$class' "."data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
4122 4122
 }
4123 4123
 
4124 4124
 /**
@@ -4162,7 +4162,7 @@  discard block
 block discarded – undo
4162 4162
 		$cle = substr($c, 0, $p);
4163 4163
 		$c = substr($c, $p + 1);
4164 4164
 
4165
-		if ($cle == calculer_cle_action($form . $c)) {
4165
+		if ($cle == calculer_cle_action($form.$c)) {
4166 4166
 			$env = @unserialize($c);
4167 4167
 			return $env;
4168 4168
 		}
@@ -4283,13 +4283,13 @@  discard block
 block discarded – undo
4283 4283
 				}
4284 4284
 			}
4285 4285
 		}
4286
-		$att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"';
4286
+		$att .= 'class="'.($class ? attribut_html($class).' ' : '').(defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on').'"';
4287 4287
 	} else {
4288 4288
 		$bal = 'a';
4289 4289
 		$att = "href='$url'"
4290
-			. ($title ? " title='" . attribut_html($title) . "'" : '')
4291
-			. ($class ? " class='" . attribut_html($class) . "'" : '')
4292
-			. ($rel ? " rel='" . attribut_html($rel) . "'" : '')
4290
+			. ($title ? " title='".attribut_html($title)."'" : '')
4291
+			. ($class ? " class='".attribut_html($class)."'" : '')
4292
+			. ($rel ? " rel='".attribut_html($rel)."'" : '')
4293 4293
 			. $evt;
4294 4294
 	}
4295 4295
 	if ($libelle === null) {
@@ -4428,7 +4428,7 @@  discard block
 block discarded – undo
4428 4428
 
4429 4429
 	// Icône
4430 4430
 	$icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4431
-	$icone = '<span class="icone-image' . ($fonction ? " icone-fonction icone-fonction-$fonction" : '') . "\">$icone</span>";
4431
+	$icone = '<span class="icone-image'.($fonction ? " icone-fonction icone-fonction-$fonction" : '')."\">$icone</span>";
4432 4432
 
4433 4433
 	// Markup final
4434 4434
 	if ($type == 'lien') {
@@ -4703,20 +4703,20 @@  discard block
 block discarded – undo
4703 4703
 		$class_form = 'ajax';
4704 4704
 		$class = str_replace('ajax', '', $class);
4705 4705
 	}
4706
-	$class_btn = 'submit ' . trim($class);
4706
+	$class_btn = 'submit '.trim($class);
4707 4707
 
4708 4708
 	if ($confirm) {
4709
-		$confirm = 'confirm("' . attribut_html($confirm) . '")';
4709
+		$confirm = 'confirm("'.attribut_html($confirm).'")';
4710 4710
 		if ($callback) {
4711 4711
 			$callback = "$confirm?($callback):false";
4712 4712
 		} else {
4713 4713
 			$callback = $confirm;
4714 4714
 		}
4715 4715
 	}
4716
-	$onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : '';
4716
+	$onclick = $callback ? " onclick='return ".addcslashes($callback, "'")."'" : '';
4717 4717
 	$title = $title ? " title='$title'" : '';
4718 4718
 
4719
-	return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>" . form_hidden($url)
4719
+	return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>".form_hidden($url)
4720 4720
 	. "<button type='submit' class='$class_btn'$title$onclick>$libelle</button></div></form>";
4721 4721
 }
4722 4722
 
@@ -4781,14 +4781,14 @@  discard block
 block discarded – undo
4781 4781
 		$champ_titre = '';
4782 4782
 		if ($demande_titre) {
4783 4783
 			// si pas de titre declare mais champ titre, il sera peuple par le select *
4784
-			$champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4784
+			$champ_titre = (!empty($desc['titre'])) ? ', '.$desc['titre'] : '';
4785 4785
 		}
4786 4786
 		include_spip('base/abstract_sql');
4787 4787
 		include_spip('base/connect_sql');
4788 4788
 		$objets[$type_objet][$id_objet] = sql_fetsel(
4789
-			'*' . $champ_titre,
4789
+			'*'.$champ_titre,
4790 4790
 			$desc['table_sql'],
4791
-			id_table_objet($type_objet) . ' = ' . intval($id_objet)
4791
+			id_table_objet($type_objet).' = '.intval($id_objet)
4792 4792
 		);
4793 4793
 
4794 4794
 		// Toujours noter la longueur d'introduction, même si pas demandé cette fois-ci
@@ -4881,8 +4881,7 @@  discard block
 block discarded – undo
4881 4881
 	if (isset($ligne_sql['chapo'])) {
4882 4882
 		$chapo = $ligne_sql['chapo'];
4883 4883
 		$texte = strlen($descriptif) ?
4884
-			'' :
4885
-			"$chapo \n\n $texte";
4884
+			'' : "$chapo \n\n $texte";
4886 4885
 	}
4887 4886
 
4888 4887
 	// Longueur en paramètre, sinon celle renseignée dans la description de l'objet, sinon valeur en dur
@@ -4957,7 +4956,7 @@  discard block
 block discarded – undo
4957 4956
 		return $texte;
4958 4957
 	}
4959 4958
 
4960
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4959
+	$traitement = str_replace('%s', "'".texte_script($texte)."'", $traitement);
4961 4960
 
4962 4961
 	// signaler qu'on est dans l'espace prive pour les filtres qui se servent de ce flag
4963 4962
 	if (test_espace_prive()) {
@@ -4996,7 +4995,7 @@  discard block
 block discarded – undo
4996 4995
 	}
4997 4996
 	$url = generer_objet_url($id_objet, $objet, '', '', null, '', $connect);
4998 4997
 
4999
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . '</a>';
4998
+	return "<a href='$url' class='$objet'>".couper($titre, $longueur).'</a>';
5000 4999
 }
5001 5000
 
5002 5001
 /**
@@ -5022,10 +5021,10 @@  discard block
 block discarded – undo
5022 5021
 function wrap($texte, $wrap) {
5023 5022
 	$balises = extraire_balises($wrap);
5024 5023
 	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
5025
-		$texte = $wrap . $texte;
5024
+		$texte = $wrap.$texte;
5026 5025
 		$regs = array_reverse($regs[1]);
5027
-		$wrap = '</' . implode('></', $regs) . '>';
5028
-		$texte = $texte . $wrap;
5026
+		$wrap = '</'.implode('></', $regs).'>';
5027
+		$texte = $texte.$wrap;
5029 5028
 	}
5030 5029
 
5031 5030
 	return $texte;
@@ -5056,7 +5055,7 @@  discard block
 block discarded – undo
5056 5055
 
5057 5056
 	// caster $u en array si besoin
5058 5057
 	if (is_object($u)) {
5059
-		$u = (array)$u;
5058
+		$u = (array) $u;
5060 5059
 	}
5061 5060
 
5062 5061
 	if (is_array($u)) {
@@ -5078,7 +5077,7 @@  discard block
 block discarded – undo
5078 5077
 		// sinon on passe a la ligne et on indente
5079 5078
 		$i_str = str_pad('', $indent, ' ');
5080 5079
 		foreach ($u as $k => $v) {
5081
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
5080
+			$out .= $join.$i_str."$k: ".filtre_print_dist($v, $join, $indent + 2);
5082 5081
 		}
5083 5082
 
5084 5083
 		return $out;
@@ -5132,7 +5131,7 @@  discard block
 block discarded – undo
5132 5131
  * @return string
5133 5132
  */
5134 5133
 function objet_icone($objet, $taille = 24, $class = '') {
5135
-	$icone = objet_info($objet, 'icone_objet') . '-' . $taille . '.png';
5134
+	$icone = objet_info($objet, 'icone_objet').'-'.$taille.'.png';
5136 5135
 	$icone = chemin_image($icone);
5137 5136
 	$balise_img = charger_filtre('balise_img');
5138 5137
 
@@ -5158,7 +5157,7 @@  discard block
 block discarded – undo
5158 5157
  */
5159 5158
 function objet_T($objet, $chaine, $args = [], $options = []) {
5160 5159
 	$chaine = explode(':', $chaine);
5161
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, ['force' => false]))) {
5160
+	if ($t = _T($objet.':'.end($chaine), $args, array_merge($options, ['force' => false]))) {
5162 5161
 		return $t;
5163 5162
 	}
5164 5163
 	$chaine = implode(':', $chaine);
@@ -5224,7 +5223,7 @@  discard block
 block discarded – undo
5224 5223
 	$cache = recuperer_fond($fond, $contexte, $options, $connect);
5225 5224
 
5226 5225
 	// calculer le nom de la css
5227
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
5226
+	$dir_var = sous_repertoire(_DIR_VAR, 'cache-'.$extension);
5228 5227
 	$nom_safe = preg_replace(',\W,', '_', str_replace('.', '_', $fond));
5229 5228
 	$contexte_implicite = calculer_contexte_implicite();
5230 5229
 
@@ -5232,14 +5231,14 @@  discard block
 block discarded – undo
5232 5231
 	// mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
5233 5232
 	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
5234 5233
 	if (isset($options['hash_on_content']) and $options['hash_on_content']) {
5235
-		$hash = md5($contexte_implicite['host'] . '::' . $cache);
5234
+		$hash = md5($contexte_implicite['host'].'::'.$cache);
5236 5235
 	}
5237 5236
 	else {
5238 5237
 		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
5239 5238
 		ksort($contexte);
5240
-		$hash = md5($fond . json_encode($contexte_implicite, JSON_THROW_ON_ERROR) . json_encode($contexte, JSON_THROW_ON_ERROR) . $connect);
5239
+		$hash = md5($fond.json_encode($contexte_implicite, JSON_THROW_ON_ERROR).json_encode($contexte, JSON_THROW_ON_ERROR).$connect);
5241 5240
 	}
5242
-	$filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
5241
+	$filename = $dir_var.$extension."dyn-$nom_safe-".substr($hash, 0, 8).".$extension";
5243 5242
 
5244 5243
 	// mettre a jour le fichier si il n'existe pas
5245 5244
 	// ou trop ancien
@@ -5247,8 +5246,8 @@  discard block
 block discarded – undo
5247 5246
 	// et recopie sur le fichier cible uniquement si il change
5248 5247
 	if (
5249 5248
 		!file_exists($filename)
5250
-		or !file_exists($filename . '.last')
5251
-		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . '.last') < $cache['lastmodified'])
5249
+		or !file_exists($filename.'.last')
5250
+		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename.'.last') < $cache['lastmodified'])
5252 5251
 		or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
5253 5252
 	) {
5254 5253
 		$contenu = $cache['texte'];
@@ -5272,10 +5271,10 @@  discard block
 block discarded – undo
5272 5271
 			}
5273 5272
 			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
5274 5273
 			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
5275
-			$comment .= "}\n   md5:" . md5($contenu) . " */\n";
5274
+			$comment .= "}\n   md5:".md5($contenu)." */\n";
5276 5275
 		}
5277 5276
 		// et ecrire le fichier si il change
5278
-		ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
5277
+		ecrire_fichier_calcule_si_modifie($filename, $comment.$contenu, false, true);
5279 5278
 	}
5280 5279
 
5281 5280
 	return timestamp($filename);
@@ -5508,7 +5507,7 @@  discard block
 block discarded – undo
5508 5507
 	if ($e > 0 and strlen($mid) > 8) {
5509 5508
 		$mid = '***...***';
5510 5509
 	}
5511
-	return substr($passe, 0, $e) . $mid . ($e > 0 ? substr($passe, -$e) : '');
5510
+	return substr($passe, 0, $e).$mid.($e > 0 ? substr($passe, -$e) : '');
5512 5511
 }
5513 5512
 
5514 5513
 
@@ -5570,7 +5569,7 @@  discard block
 block discarded – undo
5570 5569
 		case 'id':
5571 5570
 		case 'anchor':
5572 5571
 			if (preg_match(',^\d,', $texte)) {
5573
-				$texte = substr($type, 0, 1) . $texte;
5572
+				$texte = substr($type, 0, 1).$texte;
5574 5573
 			}
5575 5574
 	}
5576 5575
 
@@ -5580,9 +5579,9 @@  discard block
 block discarded – undo
5580 5579
 
5581 5580
 	if (strlen($texte) < $longueur_mini and $longueur_mini < $longueur_maxi) {
5582 5581
 		if (preg_match(',^\d,', $texte)) {
5583
-			$texte = ($type ? substr($type, 0, 1) : 's') . $texte;
5582
+			$texte = ($type ? substr($type, 0, 1) : 's').$texte;
5584 5583
 		}
5585
-		$texte .= $separateur . md5($original);
5584
+		$texte .= $separateur.md5($original);
5586 5585
 		$texte = substr($texte, 0, $longueur_mini);
5587 5586
 	}
5588 5587
 
Please login to merge, or discard this patch.