Completed
Push — master ( a9c0b3...0bc4f4 )
by cam
01:02
created
ecrire/inc/modeles.php 2 patches
Indentation   +179 added lines, -179 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 // traite les modeles (dans la fonction typo), en remplacant
@@ -22,11 +22,11 @@  discard block
 block discarded – undo
22 22
 // mais on renvoie les params (pour l'indexation par le moteur de recherche)
23 23
 
24 24
 define(
25
-	'_PREG_MODELE',
26
-	'(<([a-z_-]{3,})' # <modele
27
-	. '\s*([0-9]*)\s*' # id
28
-	. '([|](?:<[^<>]*>|[^>])*?)?' # |arguments (y compris des tags <...>)
29
-	. '\s*/?' . '>)' # fin du modele >
25
+    '_PREG_MODELE',
26
+    '(<([a-z_-]{3,})' # <modele
27
+    . '\s*([0-9]*)\s*' # id
28
+    . '([|](?:<[^<>]*>|[^>])*?)?' # |arguments (y compris des tags <...>)
29
+    . '\s*/?' . '>)' # fin du modele >
30 30
 );
31 31
 
32 32
 /**
@@ -38,65 +38,65 @@  discard block
 block discarded – undo
38 38
  */
39 39
 function modeles_collecter($texte, bool $collecter_liens = true) {
40 40
 
41
-	$modeles = [];
42
-	// detecter les modeles (rapide)
43
-	$pos = 0;
44
-	while (
45
-		($next = strpos($texte, '<', $pos)) !== false
46
-		and preg_match('@' . _PREG_MODELE . '@isS', $texte, $regs, PREG_OFFSET_CAPTURE, $next)
47
-	) {
48
-
49
-		$a = $regs[0][1];
50
-		$mod = $regs[1][0];
51
-		$type = $regs[2][0];
52
-		$id = $regs[3][0] ?? '';
53
-		$params = $regs[4][0] ?? '';
54
-		$longueur = strlen($mod);
55
-		$end = $a + $longueur;
56
-
57
-		// il faut avoir un id ou des params commençant par un | sinon c'est une simple balise html
58
-		if (!empty($id) or !empty($params)) {
59
-
60
-			$lien = false;
61
-			if ($collecter_liens
62
-				and $fermeture_lien = stripos($texte, '</a>', $end)
63
-				and !strlen(trim(substr($texte, $end, $fermeture_lien - $end)))) {
64
-
65
-				$pos_lien_ouvrant = stripos($texte, '<a', $pos);
66
-				if ($pos_lien_ouvrant !== false
67
-					and $pos_lien_ouvrant < $a
68
-					and preg_match('/<a\s[^<>]*>\s*$/i', substr($texte, $pos, $a - $pos), $r)
69
-				) {
70
-					$lien = [
71
-						'href' => extraire_attribut($r[0], 'href'),
72
-						'class' => extraire_attribut($r[0], 'class'),
73
-						'mime' => extraire_attribut($r[0], 'type'),
74
-						'title' => extraire_attribut($r[0], 'title'),
75
-						'hreflang' => extraire_attribut($r[0], 'hreflang')
76
-					];
77
-					$n = strlen($r[0]);
78
-					$a -= $n;
79
-					$longueur = $fermeture_lien - $a + 4;
80
-					$end = $a + $longueur;
81
-				}
82
-			}
83
-
84
-			$modele = [
85
-				'modele' => $mod,
86
-				'pos' => $a,
87
-				'length' => $longueur,
88
-				'type' => $type,
89
-				'id' => $id,
90
-				'params' => $params,
91
-				'lien' => $lien,
92
-			];
93
-
94
-			$modeles[] = $modele;
95
-		}
96
-		$pos = $end;
97
-	}
98
-
99
-	return $modeles;
41
+    $modeles = [];
42
+    // detecter les modeles (rapide)
43
+    $pos = 0;
44
+    while (
45
+        ($next = strpos($texte, '<', $pos)) !== false
46
+        and preg_match('@' . _PREG_MODELE . '@isS', $texte, $regs, PREG_OFFSET_CAPTURE, $next)
47
+    ) {
48
+
49
+        $a = $regs[0][1];
50
+        $mod = $regs[1][0];
51
+        $type = $regs[2][0];
52
+        $id = $regs[3][0] ?? '';
53
+        $params = $regs[4][0] ?? '';
54
+        $longueur = strlen($mod);
55
+        $end = $a + $longueur;
56
+
57
+        // il faut avoir un id ou des params commençant par un | sinon c'est une simple balise html
58
+        if (!empty($id) or !empty($params)) {
59
+
60
+            $lien = false;
61
+            if ($collecter_liens
62
+                and $fermeture_lien = stripos($texte, '</a>', $end)
63
+                and !strlen(trim(substr($texte, $end, $fermeture_lien - $end)))) {
64
+
65
+                $pos_lien_ouvrant = stripos($texte, '<a', $pos);
66
+                if ($pos_lien_ouvrant !== false
67
+                    and $pos_lien_ouvrant < $a
68
+                    and preg_match('/<a\s[^<>]*>\s*$/i', substr($texte, $pos, $a - $pos), $r)
69
+                ) {
70
+                    $lien = [
71
+                        'href' => extraire_attribut($r[0], 'href'),
72
+                        'class' => extraire_attribut($r[0], 'class'),
73
+                        'mime' => extraire_attribut($r[0], 'type'),
74
+                        'title' => extraire_attribut($r[0], 'title'),
75
+                        'hreflang' => extraire_attribut($r[0], 'hreflang')
76
+                    ];
77
+                    $n = strlen($r[0]);
78
+                    $a -= $n;
79
+                    $longueur = $fermeture_lien - $a + 4;
80
+                    $end = $a + $longueur;
81
+                }
82
+            }
83
+
84
+            $modele = [
85
+                'modele' => $mod,
86
+                'pos' => $a,
87
+                'length' => $longueur,
88
+                'type' => $type,
89
+                'id' => $id,
90
+                'params' => $params,
91
+                'lien' => $lien,
92
+            ];
93
+
94
+            $modeles[] = $modele;
95
+        }
96
+        $pos = $end;
97
+    }
98
+
99
+    return $modeles;
100 100
 }
101 101
 
102 102
 /**
@@ -110,24 +110,24 @@  discard block
 block discarded – undo
110 110
  */
111 111
 function modeles_echapper_raccourcis($texte, bool $collecter_liens = false) {
112 112
 
113
-	$modeles = modeles_collecter($texte, $collecter_liens);
114
-	$markid = '';
115
-	if (!empty($modeles)) {
116
-		// generer un marqueur qui n'est pas dans le texte
117
-		do {
118
-			$markid = substr(md5(creer_uniqid()), 0, 7);
119
-			$markid = "@|MODELE$markid|";
120
-		} while (strpos($texte, $markid) !== false);
121
-
122
-		$offset_pos = 0;
123
-		foreach ($modeles as $m) {
124
-			$rempl = $markid . base64_encode($m['modele']) . '|@';
125
-			$texte = substr_replace($texte, $rempl, $m['pos'] + $offset_pos, $m['length']);
126
-			$offset_pos += strlen($rempl) - $m['length'];
127
-		}
128
-	}
129
-
130
-	return [$texte, $markid];
113
+    $modeles = modeles_collecter($texte, $collecter_liens);
114
+    $markid = '';
115
+    if (!empty($modeles)) {
116
+        // generer un marqueur qui n'est pas dans le texte
117
+        do {
118
+            $markid = substr(md5(creer_uniqid()), 0, 7);
119
+            $markid = "@|MODELE$markid|";
120
+        } while (strpos($texte, $markid) !== false);
121
+
122
+        $offset_pos = 0;
123
+        foreach ($modeles as $m) {
124
+            $rempl = $markid . base64_encode($m['modele']) . '|@';
125
+            $texte = substr_replace($texte, $rempl, $m['pos'] + $offset_pos, $m['length']);
126
+            $offset_pos += strlen($rempl) - $m['length'];
127
+        }
128
+    }
129
+
130
+    return [$texte, $markid];
131 131
 }
132 132
 
133 133
 /**
@@ -140,24 +140,24 @@  discard block
 block discarded – undo
140 140
  */
141 141
 function modele_retablir_raccourcis_echappes(string $texte, string $markid) {
142 142
 
143
-	if ($markid) {
144
-		$pos = 0;
145
-		while (
146
-			($p = strpos($texte, $markid, $pos)) !== false
147
-			and $end = strpos($texte, '|@', $p + 16)
148
-		) {
149
-			$base64 = substr($texte, $p + 16, $end - ($p + 16));
150
-			if ($modele = base64_decode($base64, true)) {
151
-				$texte = substr_replace($texte, $modele, $p, $end + 2 - $p);
152
-				$pos = $p + strlen($modele);
153
-			}
154
-			else {
155
-				$pos = $end;
156
-			}
157
-		}
158
-	}
159
-
160
-	return $texte;
143
+    if ($markid) {
144
+        $pos = 0;
145
+        while (
146
+            ($p = strpos($texte, $markid, $pos)) !== false
147
+            and $end = strpos($texte, '|@', $p + 16)
148
+        ) {
149
+            $base64 = substr($texte, $p + 16, $end - ($p + 16));
150
+            if ($modele = base64_decode($base64, true)) {
151
+                $texte = substr_replace($texte, $modele, $p, $end + 2 - $p);
152
+                $pos = $p + strlen($modele);
153
+            }
154
+            else {
155
+                $pos = $end;
156
+            }
157
+        }
158
+    }
159
+
160
+    return $texte;
161 161
 }
162 162
 
163 163
 
@@ -172,82 +172,82 @@  discard block
 block discarded – undo
172 172
  * @return string
173 173
  */
174 174
 function traiter_modeles($texte, $doublons = false, $echap = '', string $connect = '', ?string $markidliens = null, $env = []) {
175
-	// preserver la compatibilite : true = recherche des documents
176
-	if ($doublons === true) {
177
-		$doublons = ['documents' => ['doc', 'emb', 'img']];
178
-	}
179
-
180
-	$modeles = modeles_collecter($texte, true);
181
-	if (!empty($modeles)) {
182
-		include_spip('public/assembler');
183
-		$wrap_embed_html = charger_fonction('wrap_embed_html', 'inc', true);
184
-
185
-		$offset_pos = 0;
186
-		foreach ($modeles as $m) {
187
-			// calculer le modele
188
-			# hack indexation
189
-			if ($doublons) {
190
-				$texte .= preg_replace(',[|][^|=]*,s', ' ', $m['params']);
191
-			} # version normale
192
-			else {
193
-				// si un tableau de liens a ete passe, reinjecter le contenu d'origine
194
-				// dans les parametres, plutot que les liens echappes
195
-				$params = $m['params'];
196
-				if (!is_null($markidliens)) {
197
-					$params = liens_retablir_raccourcis_echappes($params, $markidliens);
198
-				}
199
-
200
-				$modele = inclure_modele($m['type'], $m['id'], $params, $m['lien'], $connect ?? '', $env);
201
-
202
-				// en cas d'echec,
203
-				// si l'objet demande a une url,
204
-				// creer un petit encadre vers elle
205
-				if ($modele === false) {
206
-					$modele = $m['modele'];
207
-
208
-					if (!is_null($markidliens)) {
209
-						$modele = liens_retablir_raccourcis_echappes($modele, $markidliens);
210
-					}
211
-
212
-					$contexte = array_merge($env, ['id' => $m['id'], 'type' => $m['type'], 'modele' => $modele]);
213
-
214
-					if (!empty($m['lien'])) {
215
-						# un eventuel guillemet (") sera reechappe par #ENV
216
-						$contexte['lien'] = str_replace('&quot;', '"', $m['lien']['href']);
217
-						$contexte['lien_class'] = $m['lien']['class'];
218
-						$contexte['lien_mime'] = $m['lien']['mime'];
219
-						$contexte['lien_title'] = $m['lien']['title'];
220
-						$contexte['lien_hreflang'] = $m['lien']['hreflang'];
221
-					}
222
-
223
-					$modele = recuperer_fond('modeles/dist', $contexte, [], $connect ?? '');
224
-				}
225
-
226
-				// le remplacer dans le texte
227
-				if ($modele !== false) {
228
-					$modele = protege_js_modeles($modele);
229
-
230
-					if ($wrap_embed_html) {
231
-						$modele = $wrap_embed_html($m['modele'], $modele);
232
-					}
233
-
234
-					$rempl = code_echappement($modele, $echap);
235
-					$texte = substr_replace($texte, $rempl, $m['pos'] + $offset_pos, $m['length']);
236
-					$offset_pos += strlen($rempl) - $m['length'];
237
-				}
238
-			}
239
-
240
-			// hack pour tout l'espace prive
241
-			if ((test_espace_prive() or ($doublons)) and !empty($m['id'])) {
242
-				$type = strtolower($m['type']);
243
-				foreach ($doublons ?: ['documents' => ['doc', 'emb', 'img']] as $quoi => $type_modeles) {
244
-					if (in_array($type, $type_modeles)) {
245
-						$GLOBALS["doublons_{$quoi}_inclus"][] = $m['id'];
246
-					}
247
-				}
248
-			}
249
-		}
250
-	}
251
-
252
-	return $texte;
175
+    // preserver la compatibilite : true = recherche des documents
176
+    if ($doublons === true) {
177
+        $doublons = ['documents' => ['doc', 'emb', 'img']];
178
+    }
179
+
180
+    $modeles = modeles_collecter($texte, true);
181
+    if (!empty($modeles)) {
182
+        include_spip('public/assembler');
183
+        $wrap_embed_html = charger_fonction('wrap_embed_html', 'inc', true);
184
+
185
+        $offset_pos = 0;
186
+        foreach ($modeles as $m) {
187
+            // calculer le modele
188
+            # hack indexation
189
+            if ($doublons) {
190
+                $texte .= preg_replace(',[|][^|=]*,s', ' ', $m['params']);
191
+            } # version normale
192
+            else {
193
+                // si un tableau de liens a ete passe, reinjecter le contenu d'origine
194
+                // dans les parametres, plutot que les liens echappes
195
+                $params = $m['params'];
196
+                if (!is_null($markidliens)) {
197
+                    $params = liens_retablir_raccourcis_echappes($params, $markidliens);
198
+                }
199
+
200
+                $modele = inclure_modele($m['type'], $m['id'], $params, $m['lien'], $connect ?? '', $env);
201
+
202
+                // en cas d'echec,
203
+                // si l'objet demande a une url,
204
+                // creer un petit encadre vers elle
205
+                if ($modele === false) {
206
+                    $modele = $m['modele'];
207
+
208
+                    if (!is_null($markidliens)) {
209
+                        $modele = liens_retablir_raccourcis_echappes($modele, $markidliens);
210
+                    }
211
+
212
+                    $contexte = array_merge($env, ['id' => $m['id'], 'type' => $m['type'], 'modele' => $modele]);
213
+
214
+                    if (!empty($m['lien'])) {
215
+                        # un eventuel guillemet (") sera reechappe par #ENV
216
+                        $contexte['lien'] = str_replace('&quot;', '"', $m['lien']['href']);
217
+                        $contexte['lien_class'] = $m['lien']['class'];
218
+                        $contexte['lien_mime'] = $m['lien']['mime'];
219
+                        $contexte['lien_title'] = $m['lien']['title'];
220
+                        $contexte['lien_hreflang'] = $m['lien']['hreflang'];
221
+                    }
222
+
223
+                    $modele = recuperer_fond('modeles/dist', $contexte, [], $connect ?? '');
224
+                }
225
+
226
+                // le remplacer dans le texte
227
+                if ($modele !== false) {
228
+                    $modele = protege_js_modeles($modele);
229
+
230
+                    if ($wrap_embed_html) {
231
+                        $modele = $wrap_embed_html($m['modele'], $modele);
232
+                    }
233
+
234
+                    $rempl = code_echappement($modele, $echap);
235
+                    $texte = substr_replace($texte, $rempl, $m['pos'] + $offset_pos, $m['length']);
236
+                    $offset_pos += strlen($rempl) - $m['length'];
237
+                }
238
+            }
239
+
240
+            // hack pour tout l'espace prive
241
+            if ((test_espace_prive() or ($doublons)) and !empty($m['id'])) {
242
+                $type = strtolower($m['type']);
243
+                foreach ($doublons ?: ['documents' => ['doc', 'emb', 'img']] as $quoi => $type_modeles) {
244
+                    if (in_array($type, $type_modeles)) {
245
+                        $GLOBALS["doublons_{$quoi}_inclus"][] = $m['id'];
246
+                    }
247
+                }
248
+            }
249
+        }
250
+    }
251
+
252
+    return $texte;
253 253
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	'(<([a-z_-]{3,})' # <modele
27 27
 	. '\s*([0-9]*)\s*' # id
28 28
 	. '([|](?:<[^<>]*>|[^>])*?)?' # |arguments (y compris des tags <...>)
29
-	. '\s*/?' . '>)' # fin du modele >
29
+	. '\s*/?'.'>)' # fin du modele >
30 30
 );
31 31
 
32 32
 /**
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	$pos = 0;
44 44
 	while (
45 45
 		($next = strpos($texte, '<', $pos)) !== false
46
-		and preg_match('@' . _PREG_MODELE . '@isS', $texte, $regs, PREG_OFFSET_CAPTURE, $next)
46
+		and preg_match('@'._PREG_MODELE.'@isS', $texte, $regs, PREG_OFFSET_CAPTURE, $next)
47 47
 	) {
48 48
 
49 49
 		$a = $regs[0][1];
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 
122 122
 		$offset_pos = 0;
123 123
 		foreach ($modeles as $m) {
124
-			$rempl = $markid . base64_encode($m['modele']) . '|@';
124
+			$rempl = $markid.base64_encode($m['modele']).'|@';
125 125
 			$texte = substr_replace($texte, $rempl, $m['pos'] + $offset_pos, $m['length']);
126 126
 			$offset_pos += strlen($rempl) - $m['length'];
127 127
 		}
Please login to merge, or discard this patch.
ecrire/inc/filtres.php 1 patch
Indentation   +2479 added lines, -2479 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,52 +2024,52 @@  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
-		&& stripos($balise, $attribut) !== false
2041
-		&& preg_match(
2042
-			',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
2043
-			. $attribut
2044
-			. '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
2045
-			$balise,
2046
-			$r
2047
-		)
2048
-	) {
2049
-		if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) {
2050
-			$r[4] = substr($r[3], 1, -1);
2051
-			$r[3] = $r[3][0];
2052
-		} elseif ($r[3] !== '') {
2053
-			$r[4] = $r[3];
2054
-			$r[3] = '';
2055
-		} else {
2056
-			$r[4] = trim($r[2]);
2057
-		}
2058
-		$att = $r[4];
2059
-		if (strpos($att, '&#') !== false) {
2060
-			$att = str_replace(['&#039;', '&#39;', '&#034;', '&#34;'], ["'", "'", '"', '"'], $att);
2061
-		}
2062
-		$att = filtrer_entites($att);
2063
-	} else {
2064
-		$att = null;
2065
-		$r = [];
2066
-	}
2067
-
2068
-	if ($complet) {
2069
-		return [$att, $r];
2070
-	} else {
2071
-		return $att;
2072
-	}
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
+        && stripos($balise, $attribut) !== false
2041
+        && preg_match(
2042
+            ',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
2043
+            . $attribut
2044
+            . '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
2045
+            $balise,
2046
+            $r
2047
+        )
2048
+    ) {
2049
+        if (isset($r[3][0]) and ($r[3][0] == '"' || $r[3][0] == "'")) {
2050
+            $r[4] = substr($r[3], 1, -1);
2051
+            $r[3] = $r[3][0];
2052
+        } elseif ($r[3] !== '') {
2053
+            $r[4] = $r[3];
2054
+            $r[3] = '';
2055
+        } else {
2056
+            $r[4] = trim($r[2]);
2057
+        }
2058
+        $att = $r[4];
2059
+        if (strpos($att, '&#') !== false) {
2060
+            $att = str_replace(['&#039;', '&#39;', '&#034;', '&#34;'], ["'", "'", '"', '"'], $att);
2061
+        }
2062
+        $att = filtrer_entites($att);
2063
+    } else {
2064
+        $att = null;
2065
+        $r = [];
2066
+    }
2067
+
2068
+    if ($complet) {
2069
+        return [$att, $r];
2070
+    } else {
2071
+        return $att;
2072
+    }
2073 2073
 }
2074 2074
 
2075 2075
 /**
@@ -2102,41 +2102,41 @@  discard block
 block discarded – undo
2102 2102
  **/
2103 2103
 function inserer_attribut(?string $balise, string $attribut, string $val, bool $proteger = true, bool $vider = false): string {
2104 2104
 
2105
-	if ($balise === null or $balise === '') {
2106
-		return '';
2107
-	}
2105
+    if ($balise === null or $balise === '') {
2106
+        return '';
2107
+    }
2108 2108
 
2109
-	// preparer l'attribut
2110
-	// supprimer les &nbsp; etc mais pas les balises html
2111
-	// qui ont un sens dans un attribut value d'un input
2112
-	if ($proteger) {
2113
-		$val = attribut_html($val, false);
2114
-	}
2109
+    // preparer l'attribut
2110
+    // supprimer les &nbsp; etc mais pas les balises html
2111
+    // qui ont un sens dans un attribut value d'un input
2112
+    if ($proteger) {
2113
+        $val = attribut_html($val, false);
2114
+    }
2115 2115
 
2116
-	// echapper les ' pour eviter tout bug
2117
-	$val = str_replace("'", '&#039;', $val);
2118
-	if ($vider and strlen($val) === 0) {
2119
-		$insert = '';
2120
-	} else {
2121
-		$insert = " $attribut='$val'";
2122
-	}
2116
+    // echapper les ' pour eviter tout bug
2117
+    $val = str_replace("'", '&#039;', $val);
2118
+    if ($vider and strlen($val) === 0) {
2119
+        $insert = '';
2120
+    } else {
2121
+        $insert = " $attribut='$val'";
2122
+    }
2123 2123
 
2124
-	[$old, $r] = extraire_attribut($balise, $attribut, true);
2124
+    [$old, $r] = extraire_attribut($balise, $attribut, true);
2125 2125
 
2126
-	if ($old !== null) {
2127
-		// Remplacer l'ancien attribut du meme nom
2128
-		$balise = $r[1] . $insert . $r[5];
2129
-	} else {
2130
-		// preferer une balise " />" (comme <img />)
2131
-		if (preg_match(',/>,', $balise)) {
2132
-			$balise = preg_replace(',\s?/>,S', $insert . ' />', $balise, 1);
2133
-		} // sinon une balise <a ...> ... </a>
2134
-		else {
2135
-			$balise = preg_replace(',\s?>,S', $insert . '>', $balise, 1);
2136
-		}
2137
-	}
2126
+    if ($old !== null) {
2127
+        // Remplacer l'ancien attribut du meme nom
2128
+        $balise = $r[1] . $insert . $r[5];
2129
+    } else {
2130
+        // preferer une balise " />" (comme <img />)
2131
+        if (preg_match(',/>,', $balise)) {
2132
+            $balise = preg_replace(',\s?/>,S', $insert . ' />', $balise, 1);
2133
+        } // sinon une balise <a ...> ... </a>
2134
+        else {
2135
+            $balise = preg_replace(',\s?>,S', $insert . '>', $balise, 1);
2136
+        }
2137
+    }
2138 2138
 
2139
-	return $balise;
2139
+    return $balise;
2140 2140
 }
2141 2141
 
2142 2142
 /**
@@ -2154,7 +2154,7 @@  discard block
 block discarded – undo
2154 2154
  * @return string Code HTML sans l'attribut
2155 2155
  **/
2156 2156
 function vider_attribut(?string $balise, string $attribut): string {
2157
-	return inserer_attribut($balise, $attribut, '', false, true);
2157
+    return inserer_attribut($balise, $attribut, '', false, true);
2158 2158
 }
2159 2159
 
2160 2160
 /**
@@ -2166,53 +2166,53 @@  discard block
 block discarded – undo
2166 2166
  * @return string
2167 2167
  */
2168 2168
 function modifier_class($balise, $class, $operation = 'ajouter') {
2169
-	if (is_string($class)) {
2170
-		$class = explode(' ', trim($class));
2171
-	}
2172
-	$class = array_filter($class);
2173
-	$class = array_unique($class);
2174
-	if (!$class) {
2175
-		return $balise;
2176
-	}
2177
-
2178
-	// si la ou les classes ont des caracteres invalides on ne fait rien
2179
-	if (preg_match(',[^\w-],', implode('', $class))) {
2180
-		return $balise;
2181
-	}
2182
-
2183
-	$class_courante = extraire_attribut($balise, 'class');
2184
-	$class_new = $class_courante;
2185
-	foreach ($class as $c) {
2186
-		$is_class_presente = false;
2187
-		if (
2188
-			$class_courante
2189
-			and strpos($class_courante, (string) $c) !== false
2190
-			and preg_match('/(^|\s)' . preg_quote($c) . '($|\s)/', $class_courante)
2191
-		) {
2192
-			$is_class_presente = true;
2193
-		}
2194
-		if (
2195
-			in_array($operation, ['ajouter', 'commuter'])
2196
-			and !$is_class_presente
2197
-		) {
2198
-			$class_new = ltrim(rtrim($class_new ?? '') . ' ' . $c);
2199
-		} elseif (
2200
-			in_array($operation, ['supprimer', 'commuter'])
2201
-			and $is_class_presente
2202
-		) {
2203
-			$class_new = trim(preg_replace('/(^|\s)' . preg_quote($c) . '($|\s)/', "\\1", $class_new));
2204
-		}
2205
-	}
2206
-
2207
-	if ($class_new !== $class_courante) {
2208
-		if (strlen($class_new)) {
2209
-			$balise = inserer_attribut($balise, 'class', $class_new);
2210
-		} elseif ($class_courante) {
2211
-			$balise = vider_attribut($balise, 'class');
2212
-		}
2213
-	}
2214
-
2215
-	return $balise;
2169
+    if (is_string($class)) {
2170
+        $class = explode(' ', trim($class));
2171
+    }
2172
+    $class = array_filter($class);
2173
+    $class = array_unique($class);
2174
+    if (!$class) {
2175
+        return $balise;
2176
+    }
2177
+
2178
+    // si la ou les classes ont des caracteres invalides on ne fait rien
2179
+    if (preg_match(',[^\w-],', implode('', $class))) {
2180
+        return $balise;
2181
+    }
2182
+
2183
+    $class_courante = extraire_attribut($balise, 'class');
2184
+    $class_new = $class_courante;
2185
+    foreach ($class as $c) {
2186
+        $is_class_presente = false;
2187
+        if (
2188
+            $class_courante
2189
+            and strpos($class_courante, (string) $c) !== false
2190
+            and preg_match('/(^|\s)' . preg_quote($c) . '($|\s)/', $class_courante)
2191
+        ) {
2192
+            $is_class_presente = true;
2193
+        }
2194
+        if (
2195
+            in_array($operation, ['ajouter', 'commuter'])
2196
+            and !$is_class_presente
2197
+        ) {
2198
+            $class_new = ltrim(rtrim($class_new ?? '') . ' ' . $c);
2199
+        } elseif (
2200
+            in_array($operation, ['supprimer', 'commuter'])
2201
+            and $is_class_presente
2202
+        ) {
2203
+            $class_new = trim(preg_replace('/(^|\s)' . preg_quote($c) . '($|\s)/', "\\1", $class_new));
2204
+        }
2205
+    }
2206
+
2207
+    if ($class_new !== $class_courante) {
2208
+        if (strlen($class_new)) {
2209
+            $balise = inserer_attribut($balise, 'class', $class_new);
2210
+        } elseif ($class_courante) {
2211
+            $balise = vider_attribut($balise, 'class');
2212
+        }
2213
+    }
2214
+
2215
+    return $balise;
2216 2216
 }
2217 2217
 
2218 2218
 /**
@@ -2222,7 +2222,7 @@  discard block
 block discarded – undo
2222 2222
  * @return string
2223 2223
  */
2224 2224
 function ajouter_class($balise, $class) {
2225
-	return modifier_class($balise, $class, 'ajouter');
2225
+    return modifier_class($balise, $class, 'ajouter');
2226 2226
 }
2227 2227
 
2228 2228
 /**
@@ -2232,7 +2232,7 @@  discard block
 block discarded – undo
2232 2232
  * @return string
2233 2233
  */
2234 2234
 function supprimer_class($balise, $class) {
2235
-	return modifier_class($balise, $class, 'supprimer');
2235
+    return modifier_class($balise, $class, 'supprimer');
2236 2236
 }
2237 2237
 
2238 2238
 /**
@@ -2243,7 +2243,7 @@  discard block
 block discarded – undo
2243 2243
  * @return string
2244 2244
  */
2245 2245
 function commuter_class($balise, $class) {
2246
-	return modifier_class($balise, $class, 'commuter');
2246
+    return modifier_class($balise, $class, 'commuter');
2247 2247
 }
2248 2248
 
2249 2249
 /**
@@ -2254,19 +2254,19 @@  discard block
 block discarded – undo
2254 2254
  * @return string
2255 2255
  */
2256 2256
 function tester_config($id, $mode = '') {
2257
-	include_spip('action/inscrire_auteur');
2257
+    include_spip('action/inscrire_auteur');
2258 2258
 
2259
-	return tester_statut_inscription($mode, $id);
2259
+    return tester_statut_inscription($mode, $id);
2260 2260
 }
2261 2261
 
2262 2262
 //
2263 2263
 // Quelques fonctions de calcul arithmetique
2264 2264
 //
2265 2265
 function floatstr($a) {
2266
- return str_replace(',', '.', (string)floatval($a));
2266
+    return str_replace(',', '.', (string)floatval($a));
2267 2267
 }
2268 2268
 function strize($f, $a, $b) {
2269
- return floatstr($f(floatstr($a), floatstr($b)));
2269
+    return floatstr($f(floatstr($a), floatstr($b)));
2270 2270
 }
2271 2271
 
2272 2272
 /**
@@ -2285,7 +2285,7 @@  discard block
 block discarded – undo
2285 2285
  * @return int $a+$b
2286 2286
  **/
2287 2287
 function plus($a, $b) {
2288
-	return $a + $b;
2288
+    return $a + $b;
2289 2289
 }
2290 2290
 function strplus($a, $b) {
2291 2291
 return strize('plus', $a, $b);
@@ -2306,7 +2306,7 @@  discard block
 block discarded – undo
2306 2306
  * @return int $a-$b
2307 2307
  **/
2308 2308
 function moins($a, $b) {
2309
-	return $a - $b;
2309
+    return $a - $b;
2310 2310
 }
2311 2311
 function strmoins($a, $b) {
2312 2312
 return strize('moins', $a, $b);
@@ -2329,7 +2329,7 @@  discard block
 block discarded – undo
2329 2329
  * @return int $a*$b
2330 2330
  **/
2331 2331
 function mult($a, $b) {
2332
-	return $a * $b;
2332
+    return $a * $b;
2333 2333
 }
2334 2334
 function strmult($a, $b) {
2335 2335
 return strize('mult', $a, $b);
@@ -2352,7 +2352,7 @@  discard block
 block discarded – undo
2352 2352
  * @return int $a/$b (ou 0 si $b est nul)
2353 2353
  **/
2354 2354
 function div($a, $b) {
2355
-	return $b ? $a / $b : 0;
2355
+    return $b ? $a / $b : 0;
2356 2356
 }
2357 2357
 function strdiv($a, $b) {
2358 2358
 return strize('div', $a, $b);
@@ -2376,7 +2376,7 @@  discard block
 block discarded – undo
2376 2376
  * @return int ($nb % $mod) + $add
2377 2377
  **/
2378 2378
 function modulo($nb, $mod, $add = 0) {
2379
-	return ($mod ? $nb % $mod : 0) + $add;
2379
+    return ($mod ? $nb % $mod : 0) + $add;
2380 2380
 }
2381 2381
 
2382 2382
 
@@ -2391,26 +2391,26 @@  discard block
 block discarded – undo
2391 2391
  *      - true sinon
2392 2392
  **/
2393 2393
 function nom_acceptable($nom) {
2394
-	$remp2 = [];
2395
-	$remp1 = [];
2396
-	if (!is_string($nom)) {
2397
-		return false;
2398
-	}
2399
-	if (!defined('_TAGS_NOM_AUTEUR')) {
2400
-		define('_TAGS_NOM_AUTEUR', '');
2401
-	}
2402
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2403
-	foreach ($tags_acceptes as $tag) {
2404
-		if (strlen($tag)) {
2405
-			$remp1[] = '<' . trim($tag) . '>';
2406
-			$remp1[] = '</' . trim($tag) . '>';
2407
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2408
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2409
-		}
2410
-	}
2411
-	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2412
-
2413
-	return str_replace('&lt;', '<', $v_nom) == $nom;
2394
+    $remp2 = [];
2395
+    $remp1 = [];
2396
+    if (!is_string($nom)) {
2397
+        return false;
2398
+    }
2399
+    if (!defined('_TAGS_NOM_AUTEUR')) {
2400
+        define('_TAGS_NOM_AUTEUR', '');
2401
+    }
2402
+    $tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2403
+    foreach ($tags_acceptes as $tag) {
2404
+        if (strlen($tag)) {
2405
+            $remp1[] = '<' . trim($tag) . '>';
2406
+            $remp1[] = '</' . trim($tag) . '>';
2407
+            $remp2[] = '\x60' . trim($tag) . '\x61';
2408
+            $remp2[] = '\x60/' . trim($tag) . '\x61';
2409
+        }
2410
+    }
2411
+    $v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2412
+
2413
+    return str_replace('&lt;', '<', $v_nom) == $nom;
2414 2414
 }
2415 2415
 
2416 2416
 
@@ -2426,14 +2426,14 @@  discard block
 block discarded – undo
2426 2426
  *      - renvoie un tableau si l'entree est un tableau
2427 2427
  **/
2428 2428
 function email_valide($adresses) {
2429
-	if (is_array($adresses)) {
2430
-		$adresses = array_map('email_valide', $adresses);
2431
-		$adresses = array_filter($adresses);
2432
-		return $adresses;
2433
-	}
2429
+    if (is_array($adresses)) {
2430
+        $adresses = array_map('email_valide', $adresses);
2431
+        $adresses = array_filter($adresses);
2432
+        return $adresses;
2433
+    }
2434 2434
 
2435
-	$email_valide = charger_fonction('email_valide', 'inc');
2436
-	return $email_valide($adresses);
2435
+    $email_valide = charger_fonction('email_valide', 'inc');
2436
+    return $email_valide($adresses);
2437 2437
 }
2438 2438
 
2439 2439
 /**
@@ -2447,29 +2447,29 @@  discard block
 block discarded – undo
2447 2447
  * @return string Texte
2448 2448
  **/
2449 2449
 function afficher_enclosures($tags) {
2450
-	$s = [];
2451
-	foreach (extraire_balises($tags, 'a') as $tag) {
2452
-		if (
2453
-			extraire_attribut($tag, 'rel') == 'enclosure'
2454
-			and $t = extraire_attribut($tag, 'href')
2455
-		) {
2456
-			$s[] = preg_replace(
2457
-				',>[^<]+</a>,S',
2458
-				'>'
2459
-				. http_img_pack(
2460
-					'attachment-16.png',
2461
-					$t,
2462
-					'',
2463
-					$t,
2464
-					['utiliser_suffixe_size' => true]
2465
-				)
2466
-				. '</a>',
2467
-				$tag
2468
-			);
2469
-		}
2470
-	}
2471
-
2472
-	return join('&nbsp;', $s);
2450
+    $s = [];
2451
+    foreach (extraire_balises($tags, 'a') as $tag) {
2452
+        if (
2453
+            extraire_attribut($tag, 'rel') == 'enclosure'
2454
+            and $t = extraire_attribut($tag, 'href')
2455
+        ) {
2456
+            $s[] = preg_replace(
2457
+                ',>[^<]+</a>,S',
2458
+                '>'
2459
+                . http_img_pack(
2460
+                    'attachment-16.png',
2461
+                    $t,
2462
+                    '',
2463
+                    $t,
2464
+                    ['utiliser_suffixe_size' => true]
2465
+                )
2466
+                . '</a>',
2467
+                $tag
2468
+            );
2469
+        }
2470
+    }
2471
+
2472
+    return join('&nbsp;', $s);
2473 2473
 }
2474 2474
 
2475 2475
 /**
@@ -2484,15 +2484,15 @@  discard block
 block discarded – undo
2484 2484
  * @return string Liens trouvés
2485 2485
  **/
2486 2486
 function afficher_tags($tags, $rels = 'tag,directory') {
2487
-	$s = [];
2488
-	foreach (extraire_balises($tags, 'a') as $tag) {
2489
-		$rel = extraire_attribut($tag, 'rel');
2490
-		if (strstr(",$rels,", (string) ",$rel,")) {
2491
-			$s[] = $tag;
2492
-		}
2493
-	}
2487
+    $s = [];
2488
+    foreach (extraire_balises($tags, 'a') as $tag) {
2489
+        $rel = extraire_attribut($tag, 'rel');
2490
+        if (strstr(",$rels,", (string) ",$rel,")) {
2491
+            $s[] = $tag;
2492
+        }
2493
+    }
2494 2494
 
2495
-	return join(', ', $s);
2495
+    return join(', ', $s);
2496 2496
 }
2497 2497
 
2498 2498
 
@@ -2514,21 +2514,21 @@  discard block
 block discarded – undo
2514 2514
  * @return string Tag HTML `<a>` avec microformat.
2515 2515
  **/
2516 2516
 function enclosure2microformat($e) {
2517
-	if (!$url = filtrer_entites(extraire_attribut($e, 'url') ?? '')) {
2518
-		$url = filtrer_entites(extraire_attribut($e, 'href') ?? '');
2519
-	}
2520
-	$type = extraire_attribut($e, 'type');
2521
-	if (!$length = extraire_attribut($e, 'length')) {
2522
-		# <media:content : longeur dans fileSize. On tente.
2523
-		$length = extraire_attribut($e, 'fileSize');
2524
-	}
2525
-	$fichier = basename($url);
2517
+    if (!$url = filtrer_entites(extraire_attribut($e, 'url') ?? '')) {
2518
+        $url = filtrer_entites(extraire_attribut($e, 'href') ?? '');
2519
+    }
2520
+    $type = extraire_attribut($e, 'type');
2521
+    if (!$length = extraire_attribut($e, 'length')) {
2522
+        # <media:content : longeur dans fileSize. On tente.
2523
+        $length = extraire_attribut($e, 'fileSize');
2524
+    }
2525
+    $fichier = basename($url);
2526 2526
 
2527
-	return '<a rel="enclosure"'
2528
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2529
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2530
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2531
-	. '>' . $fichier . '</a>';
2527
+    return '<a rel="enclosure"'
2528
+    . ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2529
+    . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2530
+    . ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2531
+    . '>' . $fichier . '</a>';
2532 2532
 }
2533 2533
 
2534 2534
 /**
@@ -2546,24 +2546,24 @@  discard block
 block discarded – undo
2546 2546
  * @return string Tags RSS `<enclosure>`.
2547 2547
  **/
2548 2548
 function microformat2enclosure($tags) {
2549
-	$enclosures = [];
2550
-	foreach (extraire_balises($tags, 'a') as $e) {
2551
-		if (extraire_attribut($e, 'rel') == 'enclosure') {
2552
-			$url = filtrer_entites(extraire_attribut($e, 'href'));
2553
-			$type = extraire_attribut($e, 'type');
2554
-			if (!$length = intval(extraire_attribut($e, 'title'))) {
2555
-				$length = intval(extraire_attribut($e, 'length'));
2556
-			} # vieux data
2557
-			$fichier = basename($url);
2558
-			$enclosures[] = '<enclosure'
2559
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2560
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2561
-				. ($length ? ' length="' . $length . '"' : '')
2562
-				. ' />';
2563
-		}
2564
-	}
2549
+    $enclosures = [];
2550
+    foreach (extraire_balises($tags, 'a') as $e) {
2551
+        if (extraire_attribut($e, 'rel') == 'enclosure') {
2552
+            $url = filtrer_entites(extraire_attribut($e, 'href'));
2553
+            $type = extraire_attribut($e, 'type');
2554
+            if (!$length = intval(extraire_attribut($e, 'title'))) {
2555
+                $length = intval(extraire_attribut($e, 'length'));
2556
+            } # vieux data
2557
+            $fichier = basename($url);
2558
+            $enclosures[] = '<enclosure'
2559
+                . ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2560
+                . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2561
+                . ($length ? ' length="' . $length . '"' : '')
2562
+                . ' />';
2563
+        }
2564
+    }
2565 2565
 
2566
-	return join("\n", $enclosures);
2566
+    return join("\n", $enclosures);
2567 2567
 }
2568 2568
 
2569 2569
 
@@ -2579,16 +2579,16 @@  discard block
 block discarded – undo
2579 2579
  * @return string Tags RSS Atom `<dc:subject>`.
2580 2580
  **/
2581 2581
 function tags2dcsubject($tags) {
2582
-	$subjects = '';
2583
-	foreach (extraire_balises($tags, 'a') as $e) {
2584
-		if (extraire_attribut($e, 'rel') == 'tag') {
2585
-			$subjects .= '<dc:subject>'
2586
-				. texte_backend(textebrut($e))
2587
-				. '</dc:subject>' . "\n";
2588
-		}
2589
-	}
2582
+    $subjects = '';
2583
+    foreach (extraire_balises($tags, 'a') as $e) {
2584
+        if (extraire_attribut($e, 'rel') == 'tag') {
2585
+            $subjects .= '<dc:subject>'
2586
+                . texte_backend(textebrut($e))
2587
+                . '</dc:subject>' . "\n";
2588
+        }
2589
+    }
2590 2590
 
2591
-	return $subjects;
2591
+    return $subjects;
2592 2592
 }
2593 2593
 
2594 2594
 /**
@@ -2617,27 +2617,27 @@  discard block
 block discarded – undo
2617 2617
  *     - Tableau de résultats, si tableau en entrée.
2618 2618
  **/
2619 2619
 function extraire_balise($texte, $tag = 'a') {
2620
-	if (is_array($texte)) {
2621
-		array_walk(
2622
-			$texte,
2623
-			function (&$a, $key, $t) {
2624
-				$a = extraire_balise($a, $t);
2625
-			},
2626
-			$tag
2627
-		);
2628
-
2629
-		return $texte;
2630
-	}
2631
-
2632
-	if (
2633
-		preg_match(
2634
-			",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS",
2635
-			$texte,
2636
-			$regs
2637
-		)
2638
-	) {
2639
-		return $regs[0];
2640
-	}
2620
+    if (is_array($texte)) {
2621
+        array_walk(
2622
+            $texte,
2623
+            function (&$a, $key, $t) {
2624
+                $a = extraire_balise($a, $t);
2625
+            },
2626
+            $tag
2627
+        );
2628
+
2629
+        return $texte;
2630
+    }
2631
+
2632
+    if (
2633
+        preg_match(
2634
+            ",<$tag\b[^>]*(/>|>.*</$tag\b[^>]*>|>),UimsS",
2635
+            $texte,
2636
+            $regs
2637
+        )
2638
+    ) {
2639
+        return $regs[0];
2640
+    }
2641 2641
 }
2642 2642
 
2643 2643
 /**
@@ -2665,30 +2665,30 @@  discard block
 block discarded – undo
2665 2665
  *     - Tableau de résultats, si tableau en entrée.
2666 2666
  **/
2667 2667
 function extraire_balises($texte, $tag = 'a') {
2668
-	if (is_array($texte)) {
2669
-		array_walk(
2670
-			$texte,
2671
-			function (&$a, $key, $t) {
2672
-				$a = extraire_balises($a, $t);
2673
-			},
2674
-			$tag
2675
-		);
2676
-
2677
-		return $texte;
2678
-	}
2679
-
2680
-	if (
2681
-		preg_match_all(
2682
-			",<{$tag}\b[^>]*(/>|>.*</{$tag}\b[^>]*>|>),UimsS",
2683
-			$texte,
2684
-			$regs,
2685
-			PREG_PATTERN_ORDER
2686
-		)
2687
-	) {
2688
-		return $regs[0];
2689
-	} else {
2690
-		return [];
2691
-	}
2668
+    if (is_array($texte)) {
2669
+        array_walk(
2670
+            $texte,
2671
+            function (&$a, $key, $t) {
2672
+                $a = extraire_balises($a, $t);
2673
+            },
2674
+            $tag
2675
+        );
2676
+
2677
+        return $texte;
2678
+    }
2679
+
2680
+    if (
2681
+        preg_match_all(
2682
+            ",<{$tag}\b[^>]*(/>|>.*</{$tag}\b[^>]*>|>),UimsS",
2683
+            $texte,
2684
+            $regs,
2685
+            PREG_PATTERN_ORDER
2686
+        )
2687
+    ) {
2688
+        return $regs[0];
2689
+    } else {
2690
+        return [];
2691
+    }
2692 2692
 }
2693 2693
 
2694 2694
 /**
@@ -2717,11 +2717,11 @@  discard block
 block discarded – undo
2717 2717
  *     - `$def` si on n'a pas transmis de tableau
2718 2718
  **/
2719 2719
 function in_any($val, $vals, $def = '') {
2720
-	if (!is_array($vals) and $vals and $v = unserialize($vals)) {
2721
-		$vals = $v;
2722
-	}
2720
+    if (!is_array($vals) and $vals and $v = unserialize($vals)) {
2721
+        $vals = $v;
2722
+    }
2723 2723
 
2724
-	return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : ''));
2724
+    return (!is_array($vals) ? $def : (in_array($val, $vals) ? ' ' : ''));
2725 2725
 }
2726 2726
 
2727 2727
 
@@ -2742,12 +2742,12 @@  discard block
 block discarded – undo
2742 2742
  *     Résultat du calcul
2743 2743
  **/
2744 2744
 function valeur_numerique($expr) {
2745
-	$a = 0;
2746
-	if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) {
2747
-		eval("\$a = $expr;");
2748
-	}
2745
+    $a = 0;
2746
+    if (preg_match(',^[0-9]+(\s*[+*-]\s*[0-9]+)*$,S', trim($expr))) {
2747
+        eval("\$a = $expr;");
2748
+    }
2749 2749
 
2750
-	return intval($a);
2750
+    return intval($a);
2751 2751
 }
2752 2752
 
2753 2753
 /**
@@ -2766,7 +2766,7 @@  discard block
 block discarded – undo
2766 2766
  *      Retourne `$a*$b/$c`
2767 2767
  **/
2768 2768
 function regledetrois($a, $b, $c) {
2769
-	return round($a * $b / $c);
2769
+    return round($a * $b / $c);
2770 2770
 }
2771 2771
 
2772 2772
 
@@ -2789,79 +2789,79 @@  discard block
 block discarded – undo
2789 2789
  * @return string Suite de champs input hidden
2790 2790
  **/
2791 2791
 function form_hidden(?string $action = ''): string {
2792
-	$action ??= '';
2793
-
2794
-	$contexte = [];
2795
-	include_spip('inc/urls');
2796
-	if (
2797
-		$p = urls_decoder_url($action, '')
2798
-		and reset($p)
2799
-	) {
2800
-		$fond = array_shift($p);
2801
-		if ($fond != '404') {
2802
-			$contexte = array_shift($p);
2803
-			$contexte['page'] = $fond;
2804
-			$action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2805
-		}
2806
-	}
2807
-	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2808
-	if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
2809
-		unset($contexte['type']);
2810
-	}
2811
-	if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') or _DEFINIR_CONTEXTE_TYPE_PAGE) {
2812
-		unset($contexte['type-page']);
2813
-	}
2814
-
2815
-	// on va remplir un tableau de valeurs en prenant bien soin de ne pas
2816
-	// ecraser les elements de la forme mots[]=1&mots[]=2
2817
-	$values = [];
2818
-
2819
-	// d'abord avec celles de l'url
2820
-	if (false !== ($p = strpos($action, '?'))) {
2821
-		foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2822
-			$c = explode('=', $c, 2);
2823
-			$var = array_shift($c);
2824
-			$val = array_shift($c) ?? '';
2825
-			if ($var) {
2826
-				$val = rawurldecode($val);
2827
-				$var = rawurldecode($var); // decoder les [] eventuels
2828
-				if (preg_match(',\[\]$,S', $var)) {
2829
-					$values[] = [$var, $val];
2830
-				} else {
2831
-					if (!isset($values[$var])) {
2832
-						$values[$var] = [$var, $val];
2833
-					}
2834
-				}
2835
-			}
2836
-		}
2837
-	}
2838
-
2839
-	// ensuite avec celles du contexte, sans doublonner !
2840
-	foreach ($contexte as $var => $val) {
2841
-		if (preg_match(',\[\]$,S', $var)) {
2842
-			$values[] = [$var, $val];
2843
-		} else {
2844
-			if (!isset($values[$var])) {
2845
-				$values[$var] = [$var, $val];
2846
-			}
2847
-		}
2848
-	}
2849
-
2850
-	// puis on rassemble le tout
2851
-	$hidden = [];
2852
-	foreach ($values as $value) {
2853
-		[$var, $val] = $value;
2854
-		$hidden[] = '<input name="'
2855
-			. entites_html($var)
2856
-			. '"'
2857
-			. (is_null($val)
2858
-				? ''
2859
-				: ' value="' . entites_html($val) . '"'
2860
-			)
2861
-			. ' type="hidden"' . "\n/>";
2862
-	}
2863
-
2864
-	return join('', $hidden);
2792
+    $action ??= '';
2793
+
2794
+    $contexte = [];
2795
+    include_spip('inc/urls');
2796
+    if (
2797
+        $p = urls_decoder_url($action, '')
2798
+        and reset($p)
2799
+    ) {
2800
+        $fond = array_shift($p);
2801
+        if ($fond != '404') {
2802
+            $contexte = array_shift($p);
2803
+            $contexte['page'] = $fond;
2804
+            $action = preg_replace('/([?]' . preg_quote($fond) . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2805
+        }
2806
+    }
2807
+    // defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2808
+    if (defined('_DEFINIR_CONTEXTE_TYPE') and _DEFINIR_CONTEXTE_TYPE) {
2809
+        unset($contexte['type']);
2810
+    }
2811
+    if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') or _DEFINIR_CONTEXTE_TYPE_PAGE) {
2812
+        unset($contexte['type-page']);
2813
+    }
2814
+
2815
+    // on va remplir un tableau de valeurs en prenant bien soin de ne pas
2816
+    // ecraser les elements de la forme mots[]=1&mots[]=2
2817
+    $values = [];
2818
+
2819
+    // d'abord avec celles de l'url
2820
+    if (false !== ($p = strpos($action, '?'))) {
2821
+        foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2822
+            $c = explode('=', $c, 2);
2823
+            $var = array_shift($c);
2824
+            $val = array_shift($c) ?? '';
2825
+            if ($var) {
2826
+                $val = rawurldecode($val);
2827
+                $var = rawurldecode($var); // decoder les [] eventuels
2828
+                if (preg_match(',\[\]$,S', $var)) {
2829
+                    $values[] = [$var, $val];
2830
+                } else {
2831
+                    if (!isset($values[$var])) {
2832
+                        $values[$var] = [$var, $val];
2833
+                    }
2834
+                }
2835
+            }
2836
+        }
2837
+    }
2838
+
2839
+    // ensuite avec celles du contexte, sans doublonner !
2840
+    foreach ($contexte as $var => $val) {
2841
+        if (preg_match(',\[\]$,S', $var)) {
2842
+            $values[] = [$var, $val];
2843
+        } else {
2844
+            if (!isset($values[$var])) {
2845
+                $values[$var] = [$var, $val];
2846
+            }
2847
+        }
2848
+    }
2849
+
2850
+    // puis on rassemble le tout
2851
+    $hidden = [];
2852
+    foreach ($values as $value) {
2853
+        [$var, $val] = $value;
2854
+        $hidden[] = '<input name="'
2855
+            . entites_html($var)
2856
+            . '"'
2857
+            . (is_null($val)
2858
+                ? ''
2859
+                : ' value="' . entites_html($val) . '"'
2860
+            )
2861
+            . ' type="hidden"' . "\n/>";
2862
+    }
2863
+
2864
+    return join('', $hidden);
2865 2865
 }
2866 2866
 
2867 2867
 
@@ -2883,7 +2883,7 @@  discard block
 block discarded – undo
2883 2883
  *    - la première valeur du tableau sinon.
2884 2884
  **/
2885 2885
 function filtre_reset($array) {
2886
-	return !is_array($array) ? null : reset($array);
2886
+    return !is_array($array) ? null : reset($array);
2887 2887
 }
2888 2888
 
2889 2889
 /**
@@ -2904,7 +2904,7 @@  discard block
 block discarded – undo
2904 2904
  *    - la dernière valeur du tableau sinon.
2905 2905
  **/
2906 2906
 function filtre_end($array) {
2907
-	return !is_array($array) ? null : end($array);
2907
+    return !is_array($array) ? null : end($array);
2908 2908
 }
2909 2909
 
2910 2910
 /**
@@ -2924,11 +2924,11 @@  discard block
 block discarded – undo
2924 2924
  *
2925 2925
  **/
2926 2926
 function filtre_push($array, $val) {
2927
-	if (!is_array($array) or !array_push($array, $val)) {
2928
-		return '';
2929
-	}
2927
+    if (!is_array($array) or !array_push($array, $val)) {
2928
+        return '';
2929
+    }
2930 2930
 
2931
-	return $array;
2931
+    return $array;
2932 2932
 }
2933 2933
 
2934 2934
 /**
@@ -2947,7 +2947,7 @@  discard block
 block discarded – undo
2947 2947
  *     - `true` si la valeur existe dans le tableau, `false` sinon.
2948 2948
  **/
2949 2949
 function filtre_find($array, $val) {
2950
-	return (is_array($array) and in_array($val, $array));
2950
+    return (is_array($array) and in_array($val, $array));
2951 2951
 }
2952 2952
 
2953 2953
 
@@ -2964,13 +2964,13 @@  discard block
 block discarded – undo
2964 2964
  *     Contenu avec urls en absolus
2965 2965
  **/
2966 2966
 function urls_absolues_css($contenu, $source) {
2967
-	$path = suivre_lien(url_absolue($source), './');
2967
+    $path = suivre_lien(url_absolue($source), './');
2968 2968
 
2969
-	return preg_replace_callback(
2970
-		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2971
-		fn($x) => "url('" . suivre_lien($path, $x[1]) . "')",
2972
-		$contenu
2973
-	);
2969
+    return preg_replace_callback(
2970
+        ",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2971
+        fn($x) => "url('" . suivre_lien($path, $x[1]) . "')",
2972
+        $contenu
2973
+    );
2974 2974
 }
2975 2975
 
2976 2976
 
@@ -2999,119 +2999,119 @@  discard block
 block discarded – undo
2999 2999
  *     Chemin du fichier CSS inversé
3000 3000
  **/
3001 3001
 function direction_css($css, $voulue = '') {
3002
-	if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) {
3003
-		return $css;
3004
-	}
3005
-	include_spip('inc/lang');
3006
-	// si on a precise le sens voulu en argument, le prendre en compte
3007
-	if ($voulue = strtolower($voulue)) {
3008
-		if ($voulue != 'rtl' and $voulue != 'ltr') {
3009
-			$voulue = lang_dir($voulue);
3010
-		}
3011
-	} else {
3012
-		$voulue = lang_dir();
3013
-	}
3014
-
3015
-	$r = count($r) > 1;
3016
-	$right = $r ? 'left' : 'right'; // 'right' de la css lue en entree
3017
-	$dir = $r ? 'rtl' : 'ltr';
3018
-	$ndir = $r ? 'ltr' : 'rtl';
3019
-
3020
-	if ($voulue == $dir) {
3021
-		return $css;
3022
-	}
3023
-
3024
-	if (
3025
-		// url absolue
3026
-		preg_match(',^https?:,i', $css)
3027
-		// ou qui contient un ?
3028
-		or (($p = strpos($css, '?')) !== false)
3029
-	) {
3030
-		$distant = true;
3031
-		$cssf = parse_url($css);
3032
-		$cssf = $cssf['path'] . ($cssf['query'] ? '?' . $cssf['query'] : '');
3033
-		$cssf = preg_replace(',[?:&=],', '_', $cssf);
3034
-	} else {
3035
-		$distant = false;
3036
-		$cssf = $css;
3037
-		// 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
3038
-		//propose (rien a faire dans ce cas)
3039
-		$f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
3040
-		if (@file_exists($f)) {
3041
-			return $f;
3042
-		}
3043
-	}
3044
-
3045
-	// 2.
3046
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
3047
-	$f = $dir_var
3048
-		. preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
3049
-		. '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
3050
-
3051
-	// la css peut etre distante (url absolue !)
3052
-	if ($distant) {
3053
-		include_spip('inc/distant');
3054
-		$res = recuperer_url($css);
3055
-		if (!$res or !$contenu = $res['page']) {
3056
-			return $css;
3057
-		}
3058
-	} else {
3059
-		if (
3060
-			(@filemtime($f) > @filemtime($css))
3061
-			and (_VAR_MODE != 'recalcul')
3062
-		) {
3063
-			return $f;
3064
-		}
3065
-		if (!lire_fichier($css, $contenu)) {
3066
-			return $css;
3067
-		}
3068
-	}
3069
-
3070
-
3071
-	// Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands
3072
-	include_spip('lib/csstidy/class.csstidy');
3073
-	$parser = new csstidy();
3074
-	$parser->set_cfg('optimise_shorthands', 0);
3075
-	$parser->set_cfg('reverse_left_and_right', true);
3076
-	$parser->parse($contenu);
3077
-
3078
-	$contenu = $parser->print->plain();
3079
-
3080
-
3081
-	// reperer les @import auxquels il faut propager le direction_css
3082
-	preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs);
3083
-	$src = [];
3084
-	$src_direction_css = [];
3085
-	$src_faux_abs = [];
3086
-	$d = dirname($css);
3087
-	foreach ($regs[1] as $k => $import_css) {
3088
-		$css_direction = direction_css("$d/$import_css", $voulue);
3089
-		// si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue
3090
-		if (substr($css_direction, 0, strlen($d) + 1) == "$d/") {
3091
-			$css_direction = substr($css_direction, strlen($d) + 1);
3092
-		} // si la css_direction commence par $dir_var on la fait passer pour une absolue
3093
-		elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
3094
-			$css_direction = substr($css_direction, strlen($dir_var));
3095
-			$src_faux_abs['/@@@@@@/' . $css_direction] = $css_direction;
3096
-			$css_direction = '/@@@@@@/' . $css_direction;
3097
-		}
3098
-		$src[] = $regs[0][$k];
3099
-		$src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
3100
-	}
3101
-	$contenu = str_replace($src, $src_direction_css, $contenu);
3102
-
3103
-	$contenu = urls_absolues_css($contenu, $css);
3104
-
3105
-	// virer les fausses url absolues que l'on a mis dans les import
3106
-	if (count($src_faux_abs)) {
3107
-		$contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu);
3108
-	}
3109
-
3110
-	if (!ecrire_fichier($f, $contenu)) {
3111
-		return $css;
3112
-	}
3113
-
3114
-	return $f;
3002
+    if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) {
3003
+        return $css;
3004
+    }
3005
+    include_spip('inc/lang');
3006
+    // si on a precise le sens voulu en argument, le prendre en compte
3007
+    if ($voulue = strtolower($voulue)) {
3008
+        if ($voulue != 'rtl' and $voulue != 'ltr') {
3009
+            $voulue = lang_dir($voulue);
3010
+        }
3011
+    } else {
3012
+        $voulue = lang_dir();
3013
+    }
3014
+
3015
+    $r = count($r) > 1;
3016
+    $right = $r ? 'left' : 'right'; // 'right' de la css lue en entree
3017
+    $dir = $r ? 'rtl' : 'ltr';
3018
+    $ndir = $r ? 'ltr' : 'rtl';
3019
+
3020
+    if ($voulue == $dir) {
3021
+        return $css;
3022
+    }
3023
+
3024
+    if (
3025
+        // url absolue
3026
+        preg_match(',^https?:,i', $css)
3027
+        // ou qui contient un ?
3028
+        or (($p = strpos($css, '?')) !== false)
3029
+    ) {
3030
+        $distant = true;
3031
+        $cssf = parse_url($css);
3032
+        $cssf = $cssf['path'] . ($cssf['query'] ? '?' . $cssf['query'] : '');
3033
+        $cssf = preg_replace(',[?:&=],', '_', $cssf);
3034
+    } else {
3035
+        $distant = false;
3036
+        $cssf = $css;
3037
+        // 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
3038
+        //propose (rien a faire dans ce cas)
3039
+        $f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
3040
+        if (@file_exists($f)) {
3041
+            return $f;
3042
+        }
3043
+    }
3044
+
3045
+    // 2.
3046
+    $dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
3047
+    $f = $dir_var
3048
+        . preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
3049
+        . '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
3050
+
3051
+    // la css peut etre distante (url absolue !)
3052
+    if ($distant) {
3053
+        include_spip('inc/distant');
3054
+        $res = recuperer_url($css);
3055
+        if (!$res or !$contenu = $res['page']) {
3056
+            return $css;
3057
+        }
3058
+    } else {
3059
+        if (
3060
+            (@filemtime($f) > @filemtime($css))
3061
+            and (_VAR_MODE != 'recalcul')
3062
+        ) {
3063
+            return $f;
3064
+        }
3065
+        if (!lire_fichier($css, $contenu)) {
3066
+            return $css;
3067
+        }
3068
+    }
3069
+
3070
+
3071
+    // Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands
3072
+    include_spip('lib/csstidy/class.csstidy');
3073
+    $parser = new csstidy();
3074
+    $parser->set_cfg('optimise_shorthands', 0);
3075
+    $parser->set_cfg('reverse_left_and_right', true);
3076
+    $parser->parse($contenu);
3077
+
3078
+    $contenu = $parser->print->plain();
3079
+
3080
+
3081
+    // reperer les @import auxquels il faut propager le direction_css
3082
+    preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", $contenu, $regs);
3083
+    $src = [];
3084
+    $src_direction_css = [];
3085
+    $src_faux_abs = [];
3086
+    $d = dirname($css);
3087
+    foreach ($regs[1] as $k => $import_css) {
3088
+        $css_direction = direction_css("$d/$import_css", $voulue);
3089
+        // si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue
3090
+        if (substr($css_direction, 0, strlen($d) + 1) == "$d/") {
3091
+            $css_direction = substr($css_direction, strlen($d) + 1);
3092
+        } // si la css_direction commence par $dir_var on la fait passer pour une absolue
3093
+        elseif (substr($css_direction, 0, strlen($dir_var)) == $dir_var) {
3094
+            $css_direction = substr($css_direction, strlen($dir_var));
3095
+            $src_faux_abs['/@@@@@@/' . $css_direction] = $css_direction;
3096
+            $css_direction = '/@@@@@@/' . $css_direction;
3097
+        }
3098
+        $src[] = $regs[0][$k];
3099
+        $src_direction_css[] = str_replace($import_css, $css_direction, $regs[0][$k]);
3100
+    }
3101
+    $contenu = str_replace($src, $src_direction_css, $contenu);
3102
+
3103
+    $contenu = urls_absolues_css($contenu, $css);
3104
+
3105
+    // virer les fausses url absolues que l'on a mis dans les import
3106
+    if (count($src_faux_abs)) {
3107
+        $contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu);
3108
+    }
3109
+
3110
+    if (!ecrire_fichier($f, $contenu)) {
3111
+        return $css;
3112
+    }
3113
+
3114
+    return $f;
3115 3115
 }
3116 3116
 
3117 3117
 
@@ -3134,46 +3134,46 @@  discard block
 block discarded – undo
3134 3134
  *     - Chemin ou URL du fichier CSS source sinon.
3135 3135
  **/
3136 3136
 function url_absolue_css($css) {
3137
-	if (!preg_match(',\.css$,i', $css, $r)) {
3138
-		return $css;
3139
-	}
3137
+    if (!preg_match(',\.css$,i', $css, $r)) {
3138
+        return $css;
3139
+    }
3140 3140
 
3141
-	$url_absolue_css = url_absolue($css);
3141
+    $url_absolue_css = url_absolue($css);
3142 3142
 
3143
-	$f = basename($css, '.css');
3144
-	$f = sous_repertoire(_DIR_VAR, 'cache-css')
3145
-		. preg_replace(',(.*?)(_rtl|_ltr)?$,', "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
3146
-		. '.css';
3143
+    $f = basename($css, '.css');
3144
+    $f = sous_repertoire(_DIR_VAR, 'cache-css')
3145
+        . preg_replace(',(.*?)(_rtl|_ltr)?$,', "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
3146
+        . '.css';
3147 3147
 
3148
-	if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
3149
-		return $f;
3150
-	}
3148
+    if ((@filemtime($f) > @filemtime($css)) and (_VAR_MODE != 'recalcul')) {
3149
+        return $f;
3150
+    }
3151 3151
 
3152
-	if ($url_absolue_css == $css) {
3153
-		if (
3154
-			strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
3155
-			or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
3156
-		) {
3157
-			include_spip('inc/distant');
3158
-			$contenu = recuperer_url($css);
3159
-			$contenu = $contenu['page'] ?? '';
3160
-			if (!$contenu) {
3161
-				return $css;
3162
-			}
3163
-		}
3164
-	} elseif (!lire_fichier($css, $contenu)) {
3165
-		return $css;
3166
-	}
3152
+    if ($url_absolue_css == $css) {
3153
+        if (
3154
+            strncmp($GLOBALS['meta']['adresse_site'], $css, $l = strlen($GLOBALS['meta']['adresse_site'])) != 0
3155
+            or !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
3156
+        ) {
3157
+            include_spip('inc/distant');
3158
+            $contenu = recuperer_url($css);
3159
+            $contenu = $contenu['page'] ?? '';
3160
+            if (!$contenu) {
3161
+                return $css;
3162
+            }
3163
+        }
3164
+    } elseif (!lire_fichier($css, $contenu)) {
3165
+        return $css;
3166
+    }
3167 3167
 
3168
-	// passer les url relatives a la css d'origine en url absolues
3169
-	$contenu = urls_absolues_css($contenu, $css);
3168
+    // passer les url relatives a la css d'origine en url absolues
3169
+    $contenu = urls_absolues_css($contenu, $css);
3170 3170
 
3171
-	// ecrire la css
3172
-	if (!ecrire_fichier($f, $contenu)) {
3173
-		return $css;
3174
-	}
3171
+    // ecrire la css
3172
+    if (!ecrire_fichier($f, $contenu)) {
3173
+        return $css;
3174
+    }
3175 3175
 
3176
-	return $f;
3176
+    return $f;
3177 3177
 }
3178 3178
 
3179 3179
 
@@ -3207,24 +3207,24 @@  discard block
 block discarded – undo
3207 3207
  *     Valeur trouvée ou valeur par défaut.
3208 3208
  **/
3209 3209
 function table_valeur($table, $cle, $defaut = '', $conserver_null = false) {
3210
-	foreach (explode('/', $cle) as $k) {
3211
-		$table = (is_string($table) ? @unserialize($table) : $table);
3210
+    foreach (explode('/', $cle) as $k) {
3211
+        $table = (is_string($table) ? @unserialize($table) : $table);
3212 3212
 
3213
-		if (is_object($table)) {
3214
-			$table = (($k !== '') and isset($table->$k)) ? $table->$k : $defaut;
3215
-		} elseif (is_array($table)) {
3216
-			if ($conserver_null) {
3217
-				$table = array_key_exists($k, $table) ? $table[$k] : $defaut;
3218
-			} else {
3219
-				$table = ($table[$k] ?? $defaut);
3220
-			}
3221
-		} else {
3222
-			$table = $defaut;
3223
-			break;
3224
-		}
3225
-	}
3213
+        if (is_object($table)) {
3214
+            $table = (($k !== '') and isset($table->$k)) ? $table->$k : $defaut;
3215
+        } elseif (is_array($table)) {
3216
+            if ($conserver_null) {
3217
+                $table = array_key_exists($k, $table) ? $table[$k] : $defaut;
3218
+            } else {
3219
+                $table = ($table[$k] ?? $defaut);
3220
+            }
3221
+        } else {
3222
+            $table = $defaut;
3223
+            break;
3224
+        }
3225
+    }
3226 3226
 
3227
-	return $table;
3227
+    return $table;
3228 3228
 }
3229 3229
 
3230 3230
 /**
@@ -3257,22 +3257,22 @@  discard block
 block discarded – undo
3257 3257
  *     - string : expression trouvée.
3258 3258
  **/
3259 3259
 function filtre_match_dist(?string $texte, $expression, $modif = 'UuimsS', $capte = 0) {
3260
-	if (intval($modif) and $capte == 0) {
3261
-		$capte = $modif;
3262
-		$modif = 'UuimsS';
3263
-	}
3264
-	$expression = str_replace('\/', '/', $expression);
3265
-	$expression = str_replace('/', '\/', $expression);
3260
+    if (intval($modif) and $capte == 0) {
3261
+        $capte = $modif;
3262
+        $modif = 'UuimsS';
3263
+    }
3264
+    $expression = str_replace('\/', '/', $expression);
3265
+    $expression = str_replace('/', '\/', $expression);
3266 3266
 
3267
-	if (preg_match('/' . $expression . '/' . $modif, $texte ?? '', $r)) {
3268
-		if (isset($r[$capte])) {
3269
-			return $r[$capte];
3270
-		} else {
3271
-			return true;
3272
-		}
3273
-	}
3267
+    if (preg_match('/' . $expression . '/' . $modif, $texte ?? '', $r)) {
3268
+        if (isset($r[$capte])) {
3269
+            return $r[$capte];
3270
+        } else {
3271
+            return true;
3272
+        }
3273
+    }
3274 3274
 
3275
-	return false;
3275
+    return false;
3276 3276
 }
3277 3277
 
3278 3278
 
@@ -3299,10 +3299,10 @@  discard block
 block discarded – undo
3299 3299
  *     Texte
3300 3300
  **/
3301 3301
 function replace($texte, $expression, $replace = '', $modif = 'UimsS') {
3302
-	$expression = str_replace('\/', '/', $expression);
3303
-	$expression = str_replace('/', '\/', $expression);
3302
+    $expression = str_replace('\/', '/', $expression);
3303
+    $expression = str_replace('/', '\/', $expression);
3304 3304
 
3305
-	return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3305
+    return preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3306 3306
 }
3307 3307
 
3308 3308
 
@@ -3320,25 +3320,25 @@  discard block
 block discarded – undo
3320 3320
  **/
3321 3321
 function traiter_doublons_documents(&$doublons, $letexte) {
3322 3322
 
3323
-	// Verifier dans le texte & les notes (pas beau, helas)
3324
-	$t = $letexte . $GLOBALS['les_notes'];
3323
+    // Verifier dans le texte & les notes (pas beau, helas)
3324
+    $t = $letexte . $GLOBALS['les_notes'];
3325 3325
 
3326
-	if (
3327
-		strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3328
-		and preg_match_all(
3329
-			',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS',
3330
-			$t,
3331
-			$matches,
3332
-			PREG_PATTERN_ORDER
3333
-		)
3334
-	) {
3335
-		if (!isset($doublons['documents'])) {
3336
-			$doublons['documents'] = '';
3337
-		}
3338
-		$doublons['documents'] .= ',' . join(',', $matches[1]);
3339
-	}
3326
+    if (
3327
+        strstr($t, 'spip_document_') // evite le preg_match_all si inutile
3328
+        and preg_match_all(
3329
+            ',<[^>]+\sclass=["\']spip_document_([0-9]+)[\s"\'],imsS',
3330
+            $t,
3331
+            $matches,
3332
+            PREG_PATTERN_ORDER
3333
+        )
3334
+    ) {
3335
+        if (!isset($doublons['documents'])) {
3336
+            $doublons['documents'] = '';
3337
+        }
3338
+        $doublons['documents'] .= ',' . join(',', $matches[1]);
3339
+    }
3340 3340
 
3341
-	return $letexte;
3341
+    return $letexte;
3342 3342
 }
3343 3343
 
3344 3344
 /**
@@ -3352,7 +3352,7 @@  discard block
 block discarded – undo
3352 3352
  * @return string Chaîne vide
3353 3353
  **/
3354 3354
 function vide($texte) {
3355
-	return '';
3355
+    return '';
3356 3356
 }
3357 3357
 
3358 3358
 //
@@ -3381,23 +3381,23 @@  discard block
 block discarded – undo
3381 3381
  *      Code HTML résultant
3382 3382
  **/
3383 3383
 function env_to_params($env, $ignore_params = []) {
3384
-	$ignore_params = array_merge(
3385
-		['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'],
3386
-		$ignore_params
3387
-	);
3388
-	if (!is_array($env)) {
3389
-		$env = unserialize($env);
3390
-	}
3391
-	$texte = '';
3392
-	if ($env) {
3393
-		foreach ($env as $i => $j) {
3394
-			if (is_string($j) and !in_array($i, $ignore_params)) {
3395
-				$texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3396
-			}
3397
-		}
3398
-	}
3399
-
3400
-	return $texte;
3384
+    $ignore_params = array_merge(
3385
+        ['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'],
3386
+        $ignore_params
3387
+    );
3388
+    if (!is_array($env)) {
3389
+        $env = unserialize($env);
3390
+    }
3391
+    $texte = '';
3392
+    if ($env) {
3393
+        foreach ($env as $i => $j) {
3394
+            if (is_string($j) and !in_array($i, $ignore_params)) {
3395
+                $texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3396
+            }
3397
+        }
3398
+    }
3399
+
3400
+    return $texte;
3401 3401
 }
3402 3402
 
3403 3403
 /**
@@ -3420,23 +3420,23 @@  discard block
 block discarded – undo
3420 3420
  *      Code HTML résultant
3421 3421
  **/
3422 3422
 function env_to_attributs($env, $ignore_params = []) {
3423
-	$ignore_params = array_merge(
3424
-		['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'],
3425
-		$ignore_params
3426
-	);
3427
-	if (!is_array($env)) {
3428
-		$env = unserialize($env);
3429
-	}
3430
-	$texte = '';
3431
-	if ($env) {
3432
-		foreach ($env as $i => $j) {
3433
-			if (is_string($j) and !in_array($i, $ignore_params)) {
3434
-				$texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3435
-			}
3436
-		}
3437
-	}
3423
+    $ignore_params = array_merge(
3424
+        ['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'],
3425
+        $ignore_params
3426
+    );
3427
+    if (!is_array($env)) {
3428
+        $env = unserialize($env);
3429
+    }
3430
+    $texte = '';
3431
+    if ($env) {
3432
+        foreach ($env as $i => $j) {
3433
+            if (is_string($j) and !in_array($i, $ignore_params)) {
3434
+                $texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3435
+            }
3436
+        }
3437
+    }
3438 3438
 
3439
-	return $texte;
3439
+    return $texte;
3440 3440
 }
3441 3441
 
3442 3442
 
@@ -3454,7 +3454,7 @@  discard block
 block discarded – undo
3454 3454
  * @return string Chaînes concaténés
3455 3455
  **/
3456 3456
 function concat(...$args): string {
3457
-	return join('', $args);
3457
+    return join('', $args);
3458 3458
 }
3459 3459
 
3460 3460
 
@@ -3474,23 +3474,23 @@  discard block
 block discarded – undo
3474 3474
  *     Contenu du ou des fichiers, concaténé
3475 3475
  **/
3476 3476
 function charge_scripts($files, $script = true) {
3477
-	$flux = '';
3478
-	foreach (is_array($files) ? $files : explode('|', $files) as $file) {
3479
-		if (!is_string($file)) {
3480
-			continue;
3481
-		}
3482
-		if ($script) {
3483
-			$file = preg_match(',^\w+$,', $file) ? "javascript/$file.js" : '';
3484
-		}
3485
-		if ($file) {
3486
-			$path = find_in_path($file);
3487
-			if ($path) {
3488
-				$flux .= spip_file_get_contents($path);
3489
-			}
3490
-		}
3491
-	}
3492
-
3493
-	return $flux;
3477
+    $flux = '';
3478
+    foreach (is_array($files) ? $files : explode('|', $files) as $file) {
3479
+        if (!is_string($file)) {
3480
+            continue;
3481
+        }
3482
+        if ($script) {
3483
+            $file = preg_match(',^\w+$,', $file) ? "javascript/$file.js" : '';
3484
+        }
3485
+        if ($file) {
3486
+            $path = find_in_path($file);
3487
+            if ($path) {
3488
+                $flux .= spip_file_get_contents($path);
3489
+            }
3490
+        }
3491
+    }
3492
+
3493
+    return $flux;
3494 3494
 }
3495 3495
 
3496 3496
 /**
@@ -3501,22 +3501,22 @@  discard block
 block discarded – undo
3501 3501
  * @return string
3502 3502
  */
3503 3503
 function http_img_variante_svg_si_possible($img_file) {
3504
-	// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3505
-	// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3506
-	if (
3507
-		preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3508
-		and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . '-xx.svg'
3509
-		and file_exists($variante_svg_generique)
3510
-	) {
3511
-		if ($variante_svg_size = substr($variante_svg_generique, 0, -6) . $m[1] . '.svg' and file_exists($variante_svg_size)) {
3512
-			$img_file = $variante_svg_size;
3513
-		}
3514
-		else {
3515
-			$img_file = $variante_svg_generique;
3516
-		}
3517
-	}
3504
+    // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3505
+    // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3506
+    if (
3507
+        preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3508
+        and $variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . '-xx.svg'
3509
+        and file_exists($variante_svg_generique)
3510
+    ) {
3511
+        if ($variante_svg_size = substr($variante_svg_generique, 0, -6) . $m[1] . '.svg' and file_exists($variante_svg_size)) {
3512
+            $img_file = $variante_svg_size;
3513
+        }
3514
+        else {
3515
+            $img_file = $variante_svg_generique;
3516
+        }
3517
+    }
3518 3518
 
3519
-	return $img_file;
3519
+    return $img_file;
3520 3520
 }
3521 3521
 
3522 3522
 /**
@@ -3537,54 +3537,54 @@  discard block
 block discarded – undo
3537 3537
  */
3538 3538
 function http_img_pack($img, $alt, $atts = '', $title = '', $options = []) {
3539 3539
 
3540
-	$img_file = $img;
3541
-	if ($p = strpos($img_file, '?')) {
3542
-		$img_file = substr($img_file, 0, $p);
3543
-	}
3544
-	if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3545
-		$img_file = chemin_image($img);
3546
-	}
3547
-	else {
3548
-		if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true) {
3549
-			$img_file = http_img_variante_svg_si_possible($img_file);
3550
-		}
3551
-	}
3552
-	if (stripos($atts, 'width') === false) {
3553
-		// utiliser directement l'info de taille presente dans le nom
3554
-		if (
3555
-			(!isset($options['utiliser_suffixe_size'])
3556
-				or $options['utiliser_suffixe_size'] == true
3557
-			  or strpos($img_file, '-xx.svg') !== false)
3558
-			and (preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs)
3559
-					 or preg_match(',\?([0-9]+)px$,', $img, $regs))
3560
-		) {
3561
-			$largeur = $hauteur = intval($regs[1]);
3562
-		} else {
3563
-			$taille = taille_image($img_file);
3564
-			[$hauteur, $largeur] = $taille;
3565
-			if (!$hauteur or !$largeur) {
3566
-				return '';
3567
-			}
3568
-		}
3569
-		$atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3570
-	}
3571
-
3572
-	if (file_exists($img_file)) {
3573
-		$img_file = timestamp($img_file);
3574
-	}
3575
-	if ($alt === false) {
3576
-		$alt = '';
3577
-	}
3578
-	elseif ($alt or $alt === '') {
3579
-		$alt = " alt='" . attribut_html($alt) . "'";
3580
-	}
3581
-	else {
3582
-		$alt = " alt='" . attribut_html($title) . "'";
3583
-	}
3584
-	return "<img src='" . attribut_html($img_file) . "'$alt"
3585
-	. ($title ? ' title="' . attribut_html($title) . '"' : '')
3586
-	. ' ' . ltrim($atts)
3587
-	. ' />';
3540
+    $img_file = $img;
3541
+    if ($p = strpos($img_file, '?')) {
3542
+        $img_file = substr($img_file, 0, $p);
3543
+    }
3544
+    if (!isset($options['chemin_image']) or $options['chemin_image'] == true) {
3545
+        $img_file = chemin_image($img);
3546
+    }
3547
+    else {
3548
+        if (!isset($options['variante_svg_si_possible']) or $options['variante_svg_si_possible'] == true) {
3549
+            $img_file = http_img_variante_svg_si_possible($img_file);
3550
+        }
3551
+    }
3552
+    if (stripos($atts, 'width') === false) {
3553
+        // utiliser directement l'info de taille presente dans le nom
3554
+        if (
3555
+            (!isset($options['utiliser_suffixe_size'])
3556
+                or $options['utiliser_suffixe_size'] == true
3557
+              or strpos($img_file, '-xx.svg') !== false)
3558
+            and (preg_match(',-([0-9]+)[.](png|gif|svg)$,', $img, $regs)
3559
+                     or preg_match(',\?([0-9]+)px$,', $img, $regs))
3560
+        ) {
3561
+            $largeur = $hauteur = intval($regs[1]);
3562
+        } else {
3563
+            $taille = taille_image($img_file);
3564
+            [$hauteur, $largeur] = $taille;
3565
+            if (!$hauteur or !$largeur) {
3566
+                return '';
3567
+            }
3568
+        }
3569
+        $atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3570
+    }
3571
+
3572
+    if (file_exists($img_file)) {
3573
+        $img_file = timestamp($img_file);
3574
+    }
3575
+    if ($alt === false) {
3576
+        $alt = '';
3577
+    }
3578
+    elseif ($alt or $alt === '') {
3579
+        $alt = " alt='" . attribut_html($alt) . "'";
3580
+    }
3581
+    else {
3582
+        $alt = " alt='" . attribut_html($title) . "'";
3583
+    }
3584
+    return "<img src='" . attribut_html($img_file) . "'$alt"
3585
+    . ($title ? ' title="' . attribut_html($title) . '"' : '')
3586
+    . ' ' . ltrim($atts)
3587
+    . ' />';
3588 3588
 }
3589 3589
 
3590 3590
 /**
@@ -3596,70 +3596,70 @@  discard block
 block discarded – undo
3596 3596
  * @return string
3597 3597
  */
3598 3598
 function http_style_background($img, $att = '', $size = null) {
3599
-	if ($size and is_numeric($size)) {
3600
-		$size = trim($size) . 'px';
3601
-	}
3602
-	return " style='background" .
3603
-		($att ? '' : '-image') . ': url("' . chemin_image($img) . '")' . ($att ? (' ' . $att) : '') . ';'
3604
-		. ($size ? "background-size:{$size};" : '')
3605
-		. "'";
3599
+    if ($size and is_numeric($size)) {
3600
+        $size = trim($size) . 'px';
3601
+    }
3602
+    return " style='background" .
3603
+        ($att ? '' : '-image') . ': url("' . chemin_image($img) . '")' . ($att ? (' ' . $att) : '') . ';'
3604
+        . ($size ? "background-size:{$size};" : '')
3605
+        . "'";
3606 3606
 }
3607 3607
 
3608 3608
 
3609 3609
 function helper_filtre_balise_img_svg_arguments($alt_or_size, $class_or_size, $size) {
3610
-	$args = [$alt_or_size, $class_or_size, $size];
3611
-	while (is_null(end($args)) and count($args)) {
3612
-		array_pop($args);
3613
-	}
3614
-	if (!count($args)) {
3615
-		return [null, null, null];
3616
-	}
3617
-	if (count($args) < 3) {
3618
-		$maybe_size = array_pop($args);
3619
-		// @2x
3620
-		// @1.5x
3621
-		// 512
3622
-		// 512x*
3623
-		// 512x300
3624
-		if (
3625
-			!strlen($maybe_size)
3626
-			or !preg_match(',^(@\d+(\.\d+)?x|\d+(x\*)?|\d+x\d+)$,', trim($maybe_size))
3627
-		) {
3628
-			$args[] = $maybe_size;
3629
-			$maybe_size = null;
3630
-		}
3631
-		while (count($args) < 2) {
3632
-			$args[] = null; // default alt or class
3633
-		}
3634
-		$args[] = $maybe_size;
3635
-	}
3636
-	return $args;
3610
+    $args = [$alt_or_size, $class_or_size, $size];
3611
+    while (is_null(end($args)) and count($args)) {
3612
+        array_pop($args);
3613
+    }
3614
+    if (!count($args)) {
3615
+        return [null, null, null];
3616
+    }
3617
+    if (count($args) < 3) {
3618
+        $maybe_size = array_pop($args);
3619
+        // @2x
3620
+        // @1.5x
3621
+        // 512
3622
+        // 512x*
3623
+        // 512x300
3624
+        if (
3625
+            !strlen($maybe_size)
3626
+            or !preg_match(',^(@\d+(\.\d+)?x|\d+(x\*)?|\d+x\d+)$,', trim($maybe_size))
3627
+        ) {
3628
+            $args[] = $maybe_size;
3629
+            $maybe_size = null;
3630
+        }
3631
+        while (count($args) < 2) {
3632
+            $args[] = null; // default alt or class
3633
+        }
3634
+        $args[] = $maybe_size;
3635
+    }
3636
+    return $args;
3637 3637
 }
3638 3638
 
3639 3639
 function helper_filtre_balise_img_svg_size($img, $size) {
3640
-	// si size est de la forme '@2x' c'est un coeff multiplicateur sur la densite
3641
-	if (strpos($size, '@') === 0 and substr($size, -1) === 'x') {
3642
-		$coef = floatval(substr($size, 1, -1));
3643
-		[$h, $w] = taille_image($img);
3644
-		$height = intval(round($h / $coef));
3645
-		$width = intval(round($w / $coef));
3646
-	}
3647
-	// sinon c'est une valeur seule si image caree ou largeurxhauteur
3648
-	else {
3649
-		$size = explode('x', $size, 2);
3650
-		$size = array_map('trim', $size);
3651
-		$height = $width = intval(array_shift($size));
3652
-
3653
-		if (count($size) and reset($size)) {
3654
-			$height = array_shift($size);
3655
-			if ($height === '*') {
3656
-				[$h, $w] = taille_image($img);
3657
-				$height = intval(round($h * $width / $w));
3658
-			}
3659
-		}
3660
-	}
3661
-
3662
-	return [$width, $height];
3640
+    // si size est de la forme '@2x' c'est un coeff multiplicateur sur la densite
3641
+    if (strpos($size, '@') === 0 and substr($size, -1) === 'x') {
3642
+        $coef = floatval(substr($size, 1, -1));
3643
+        [$h, $w] = taille_image($img);
3644
+        $height = intval(round($h / $coef));
3645
+        $width = intval(round($w / $coef));
3646
+    }
3647
+    // sinon c'est une valeur seule si image caree ou largeurxhauteur
3648
+    else {
3649
+        $size = explode('x', $size, 2);
3650
+        $size = array_map('trim', $size);
3651
+        $height = $width = intval(array_shift($size));
3652
+
3653
+        if (count($size) and reset($size)) {
3654
+            $height = array_shift($size);
3655
+            if ($height === '*') {
3656
+                [$h, $w] = taille_image($img);
3657
+                $height = intval(round($h * $width / $w));
3658
+            }
3659
+        }
3660
+    }
3661
+
3662
+    return [$width, $height];
3663 3663
 }
3664 3664
 
3665 3665
 /**
@@ -3695,43 +3695,43 @@  discard block
 block discarded – undo
3695 3695
  */
3696 3696
 function filtre_balise_img_dist($img, $alt = '', $class = null, $size = null) {
3697 3697
 
3698
-	[$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3699
-
3700
-	$img = trim((string) $img);
3701
-	if (strpos($img, '<img') === 0) {
3702
-		if (!is_null($alt)) {
3703
-			$img = inserer_attribut($img, 'alt', $alt);
3704
-		}
3705
-		if (!is_null($class)) {
3706
-			if (strlen($class)) {
3707
-				$img = inserer_attribut($img, 'class', $class);
3708
-			}
3709
-			else {
3710
-				$img = vider_attribut($img, 'class');
3711
-			}
3712
-		}
3713
-	}
3714
-	else {
3715
-		$img = http_img_pack(
3716
-			$img,
3717
-			$alt,
3718
-			$class ? " class='" . attribut_html($class) . "'" : '',
3719
-			'',
3720
-			['chemin_image' => false, 'utiliser_suffixe_size' => false]
3721
-		);
3722
-		if (is_null($alt)) {
3723
-			$img = vider_attribut($img, 'alt');
3724
-		}
3725
-	}
3726
-
3727
-	if ($img and !is_null($size) and strlen($size = trim($size))) {
3728
-		[$width, $height] = helper_filtre_balise_img_svg_size($img, $size);
3729
-
3730
-		$img = inserer_attribut($img, 'width', $width);
3731
-		$img = inserer_attribut($img, 'height', $height);
3732
-	}
3733
-
3734
-	return $img;
3698
+    [$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3699
+
3700
+    $img = trim((string) $img);
3701
+    if (strpos($img, '<img') === 0) {
3702
+        if (!is_null($alt)) {
3703
+            $img = inserer_attribut($img, 'alt', $alt);
3704
+        }
3705
+        if (!is_null($class)) {
3706
+            if (strlen($class)) {
3707
+                $img = inserer_attribut($img, 'class', $class);
3708
+            }
3709
+            else {
3710
+                $img = vider_attribut($img, 'class');
3711
+            }
3712
+        }
3713
+    }
3714
+    else {
3715
+        $img = http_img_pack(
3716
+            $img,
3717
+            $alt,
3718
+            $class ? " class='" . attribut_html($class) . "'" : '',
3719
+            '',
3720
+            ['chemin_image' => false, 'utiliser_suffixe_size' => false]
3721
+        );
3722
+        if (is_null($alt)) {
3723
+            $img = vider_attribut($img, 'alt');
3724
+        }
3725
+    }
3726
+
3727
+    if ($img and !is_null($size) and strlen($size = trim($size))) {
3728
+        [$width, $height] = helper_filtre_balise_img_svg_size($img, $size);
3729
+
3730
+        $img = inserer_attribut($img, 'width', $width);
3731
+        $img = inserer_attribut($img, 'height', $height);
3732
+    }
3733
+
3734
+    return $img;
3735 3735
 }
3736 3736
 
3737 3737
 
@@ -3765,80 +3765,80 @@  discard block
 block discarded – undo
3765 3765
  */
3766 3766
 function filtre_balise_svg_dist($img, $alt = '', $class = null, $size = null) {
3767 3767
 
3768
-	$svg = null;
3769
-	$img = trim($img);
3770
-	$img_file = $img;
3771
-	if (strpos($img, '<svg') === false) {
3772
-		if ($p = strpos($img_file, '?')) {
3773
-			$img_file = substr($img_file, 0, $p);
3774
-		}
3775
-
3776
-		// ne jamais operer directement sur une image distante pour des raisons de perfo
3777
-		// la copie locale a toutes les chances d'etre la ou de resservir
3778
-		if (tester_url_absolue($img_file)) {
3779
-			include_spip('inc/distant');
3780
-			$fichier = copie_locale($img_file);
3781
-			$img_file = ($fichier ? _DIR_RACINE . $fichier : $img_file);
3782
-		}
3783
-
3784
-		if (
3785
-			!$img_file
3786
-			or !file_exists($img_file)
3787
-			or !$svg = file_get_contents($img_file)
3788
-		) {
3789
-			return '';
3790
-		}
3791
-	}
3792
-
3793
-	if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) {
3794
-		return '';
3795
-	}
3796
-
3797
-	[$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3798
-
3799
-	$balise_svg = $match[0];
3800
-	$balise_svg_source = $balise_svg;
3801
-
3802
-	// entete XML à supprimer
3803
-	$svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3804
-
3805
-	// IE est toujours mon ami
3806
-	$balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3807
-
3808
-	// regler la classe
3809
-	if (!is_null($class)) {
3810
-		if (strlen($class)) {
3811
-			$balise_svg = inserer_attribut($balise_svg, 'class', $class);
3812
-		}
3813
-		else {
3814
-			$balise_svg = vider_attribut($balise_svg, 'class');
3815
-		}
3816
-	}
3817
-
3818
-	// regler le alt
3819
-	if ($alt) {
3820
-		$balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3821
-		$id = 'img-svg-title-' . substr(md5("$img_file:$svg:$alt"), 0, 4);
3822
-		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3823
-		$title = "<title id=\"$id\">" . entites_html($alt) . "</title>\n";
3824
-		$balise_svg .= $title;
3825
-	}
3826
-	else {
3827
-		$balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3828
-	}
3829
-
3830
-	$svg = str_replace($balise_svg_source, $balise_svg, $svg);
3831
-
3832
-	if (!is_null($size) and strlen($size = trim($size))) {
3833
-		[$width, $height] = helper_filtre_balise_img_svg_size($svg, $size);
3834
-
3835
-		if (!function_exists('svg_redimensionner')) {
3836
-			include_spip('inc/svg');
3837
-		}
3838
-		$svg = svg_redimensionner($svg, $width, $height);
3839
-	}
3840
-
3841
-	return $svg;
3768
+    $svg = null;
3769
+    $img = trim($img);
3770
+    $img_file = $img;
3771
+    if (strpos($img, '<svg') === false) {
3772
+        if ($p = strpos($img_file, '?')) {
3773
+            $img_file = substr($img_file, 0, $p);
3774
+        }
3775
+
3776
+        // ne jamais operer directement sur une image distante pour des raisons de perfo
3777
+        // la copie locale a toutes les chances d'etre la ou de resservir
3778
+        if (tester_url_absolue($img_file)) {
3779
+            include_spip('inc/distant');
3780
+            $fichier = copie_locale($img_file);
3781
+            $img_file = ($fichier ? _DIR_RACINE . $fichier : $img_file);
3782
+        }
3783
+
3784
+        if (
3785
+            !$img_file
3786
+            or !file_exists($img_file)
3787
+            or !$svg = file_get_contents($img_file)
3788
+        ) {
3789
+            return '';
3790
+        }
3791
+    }
3792
+
3793
+    if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) {
3794
+        return '';
3795
+    }
3796
+
3797
+    [$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3798
+
3799
+    $balise_svg = $match[0];
3800
+    $balise_svg_source = $balise_svg;
3801
+
3802
+    // entete XML à supprimer
3803
+    $svg = preg_replace(',^\s*<\?xml[^>]*\?' . '>,', '', $svg);
3804
+
3805
+    // IE est toujours mon ami
3806
+    $balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3807
+
3808
+    // regler la classe
3809
+    if (!is_null($class)) {
3810
+        if (strlen($class)) {
3811
+            $balise_svg = inserer_attribut($balise_svg, 'class', $class);
3812
+        }
3813
+        else {
3814
+            $balise_svg = vider_attribut($balise_svg, 'class');
3815
+        }
3816
+    }
3817
+
3818
+    // regler le alt
3819
+    if ($alt) {
3820
+        $balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3821
+        $id = 'img-svg-title-' . substr(md5("$img_file:$svg:$alt"), 0, 4);
3822
+        $balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3823
+        $title = "<title id=\"$id\">" . entites_html($alt) . "</title>\n";
3824
+        $balise_svg .= $title;
3825
+    }
3826
+    else {
3827
+        $balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3828
+    }
3829
+
3830
+    $svg = str_replace($balise_svg_source, $balise_svg, $svg);
3831
+
3832
+    if (!is_null($size) and strlen($size = trim($size))) {
3833
+        [$width, $height] = helper_filtre_balise_img_svg_size($svg, $size);
3834
+
3835
+        if (!function_exists('svg_redimensionner')) {
3836
+            include_spip('inc/svg');
3837
+        }
3838
+        $svg = svg_redimensionner($svg, $width, $height);
3839
+    }
3840
+
3841
+    return $svg;
3842 3842
 }
3843 3843
 
3844 3844
 
@@ -3864,18 +3864,18 @@  discard block
 block discarded – undo
3864 3864
  *     Code HTML résultant
3865 3865
  **/
3866 3866
 function filtre_foreach_dist($tableau, $modele = 'foreach') {
3867
-	$texte = '';
3868
-	if (is_array($tableau)) {
3869
-		foreach ($tableau as $k => $v) {
3870
-			$res = recuperer_fond(
3871
-				'modeles/' . $modele,
3872
-				array_merge(['cle' => $k], (is_array($v) ? $v : ['valeur' => $v]))
3873
-			);
3874
-			$texte .= $res;
3875
-		}
3876
-	}
3867
+    $texte = '';
3868
+    if (is_array($tableau)) {
3869
+        foreach ($tableau as $k => $v) {
3870
+            $res = recuperer_fond(
3871
+                'modeles/' . $modele,
3872
+                array_merge(['cle' => $k], (is_array($v) ? $v : ['valeur' => $v]))
3873
+            );
3874
+            $texte .= $res;
3875
+        }
3876
+    }
3877 3877
 
3878
-	return $texte;
3878
+    return $texte;
3879 3879
 }
3880 3880
 
3881 3881
 
@@ -3900,37 +3900,37 @@  discard block
 block discarded – undo
3900 3900
  *         - tout : retourne toutes les informations du plugin actif
3901 3901
  **/
3902 3902
 function filtre_info_plugin_dist($plugin, $type_info, $reload = false) {
3903
-	include_spip('inc/plugin');
3904
-	$plugin = strtoupper($plugin);
3905
-	$plugins_actifs = liste_plugin_actifs();
3906
-
3907
-	if (!$plugin) {
3908
-		return serialize(array_keys($plugins_actifs));
3909
-	} elseif (empty($plugins_actifs[$plugin]) and !$reload) {
3910
-		return '';
3911
-	} elseif (($type_info == 'est_actif') and !$reload) {
3912
-		return $plugins_actifs[$plugin] ? 1 : 0;
3913
-	} elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) {
3914
-		return $plugins_actifs[$plugin][$type_info];
3915
-	} else {
3916
-		$get_infos = charger_fonction('get_infos', 'plugins');
3917
-		// On prend en compte les extensions
3918
-		if (!is_dir($plugins_actifs[$plugin]['dir_type'])) {
3919
-			$dir_plugins = constant($plugins_actifs[$plugin]['dir_type']);
3920
-		} else {
3921
-			$dir_plugins = $plugins_actifs[$plugin]['dir_type'];
3922
-		}
3923
-		if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) {
3924
-			return '';
3925
-		}
3926
-		if ($type_info == 'tout') {
3927
-			return $infos;
3928
-		} elseif ($type_info == 'est_actif') {
3929
-			return $infos ? 1 : 0;
3930
-		} else {
3931
-			return strval($infos[$type_info]);
3932
-		}
3933
-	}
3903
+    include_spip('inc/plugin');
3904
+    $plugin = strtoupper($plugin);
3905
+    $plugins_actifs = liste_plugin_actifs();
3906
+
3907
+    if (!$plugin) {
3908
+        return serialize(array_keys($plugins_actifs));
3909
+    } elseif (empty($plugins_actifs[$plugin]) and !$reload) {
3910
+        return '';
3911
+    } elseif (($type_info == 'est_actif') and !$reload) {
3912
+        return $plugins_actifs[$plugin] ? 1 : 0;
3913
+    } elseif (isset($plugins_actifs[$plugin][$type_info]) and !$reload) {
3914
+        return $plugins_actifs[$plugin][$type_info];
3915
+    } else {
3916
+        $get_infos = charger_fonction('get_infos', 'plugins');
3917
+        // On prend en compte les extensions
3918
+        if (!is_dir($plugins_actifs[$plugin]['dir_type'])) {
3919
+            $dir_plugins = constant($plugins_actifs[$plugin]['dir_type']);
3920
+        } else {
3921
+            $dir_plugins = $plugins_actifs[$plugin]['dir_type'];
3922
+        }
3923
+        if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) {
3924
+            return '';
3925
+        }
3926
+        if ($type_info == 'tout') {
3927
+            return $infos;
3928
+        } elseif ($type_info == 'est_actif') {
3929
+            return $infos ? 1 : 0;
3930
+        } else {
3931
+            return strval($infos[$type_info]);
3932
+        }
3933
+    }
3934 3934
 }
3935 3935
 
3936 3936
 
@@ -3957,9 +3957,9 @@  discard block
 block discarded – undo
3957 3957
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
3958 3958
  */
3959 3959
 function puce_changement_statut($id_objet, $statut, $id_rubrique, $type, $ajax = false) {
3960
-	$puce_statut = charger_fonction('puce_statut', 'inc');
3960
+    $puce_statut = charger_fonction('puce_statut', 'inc');
3961 3961
 
3962
-	return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax);
3962
+    return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax);
3963 3963
 }
3964 3964
 
3965 3965
 
@@ -3989,19 +3989,19 @@  discard block
 block discarded – undo
3989 3989
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
3990 3990
  */
3991 3991
 function filtre_puce_statut_dist($statut, $objet, $id_objet = 0, $id_parent = 0) {
3992
-	static $puce_statut = null;
3993
-	if (!$puce_statut) {
3994
-		$puce_statut = charger_fonction('puce_statut', 'inc');
3995
-	}
3992
+    static $puce_statut = null;
3993
+    if (!$puce_statut) {
3994
+        $puce_statut = charger_fonction('puce_statut', 'inc');
3995
+    }
3996 3996
 
3997
-	return $puce_statut(
3998
-		$id_objet,
3999
-		$statut,
4000
-		$id_parent,
4001
-		$objet,
4002
-		false,
4003
-		objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false
4004
-	);
3997
+    return $puce_statut(
3998
+        $id_objet,
3999
+        $statut,
4000
+        $id_parent,
4001
+        $objet,
4002
+        false,
4003
+        objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false
4004
+    );
4005 4005
 }
4006 4006
 
4007 4007
 
@@ -4028,98 +4028,98 @@  discard block
 block discarded – undo
4028 4028
  *   hash du contexte
4029 4029
  */
4030 4030
 function encoder_contexte_ajax($c, $form = '', $emboite = null, $ajaxid = '') {
4031
-	$env = null;
4032
-	if (
4033
-		is_string($c)
4034
-		and @unserialize($c) !== false
4035
-	) {
4036
-		$c = unserialize($c);
4037
-	}
4038
-
4039
-	// supprimer les parametres debut_x
4040
-	// pour que la pagination ajax ne soit pas plantee
4041
-	// si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0,
4042
-	// le debut_x=0 n'existe pas, et on resterait sur 1
4043
-	if (is_array($c)) {
4044
-		foreach ($c as $k => $v) {
4045
-			if (strpos($k, 'debut_') === 0) {
4046
-				unset($c[$k]);
4047
-			}
4048
-		}
4049
-	}
4050
-
4051
-	if (!function_exists('calculer_cle_action')) {
4052
-		include_spip('inc/securiser_action');
4053
-	}
4054
-
4055
-	$c = serialize($c);
4056
-	$cle = calculer_cle_action($form . $c);
4057
-	$c = "$cle:$c";
4058
-
4059
-	// on ne stocke pas les contextes dans des fichiers en cache
4060
-	// par defaut, sauf si cette configuration a été forcée
4061
-	// OU que la longueur de l’argument géneré est plus long
4062
-	// que ce qui est toléré.
4063
-	$cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX);
4064
-	if (!$cache_contextes_ajax) {
4065
-		$env = $c;
4066
-		if (function_exists('gzdeflate') && function_exists('gzinflate')) {
4067
-			$env = gzdeflate($env);
4068
-		}
4069
-		$env = _xor($env);
4070
-		$env = base64_encode($env);
4071
-		$len = strlen($env);
4072
-		// Si l’url est trop longue pour le navigateur
4073
-		$max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR;
4074
-		if ($len > $max_len) {
4075
-			$cache_contextes_ajax = true;
4076
-			spip_log(
4077
-				'Contextes AJAX forces en fichiers !'
4078
-				. ' Cela arrive lorsque la valeur du contexte'
4079
-				. " depasse la longueur maximale autorisee ($max_len). Ici : $len.",
4080
-				_LOG_AVERTISSEMENT
4081
-			);
4082
-		}
4083
-		// Sinon si Suhosin est actif et a une la valeur maximale des variables en GET...
4084
-		elseif (
4085
-			$max_len = @ini_get('suhosin.get.max_value_length')
4086
-			and $max_len < $len
4087
-		) {
4088
-			$cache_contextes_ajax = true;
4089
-			spip_log('Contextes AJAX forces en fichiers !'
4090
-				. ' Cela arrive lorsque la valeur du contexte'
4091
-				. ' depasse la longueur maximale autorisee par Suhosin'
4092
-				. " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len."
4093
-				. ' Vous devriez modifier les parametres de Suhosin'
4094
-				. ' pour accepter au moins 1024 caracteres.', _LOG_AVERTISSEMENT);
4095
-		}
4096
-	}
4097
-
4098
-	if ($cache_contextes_ajax) {
4099
-		$dir = sous_repertoire(_DIR_CACHE, 'contextes');
4100
-		// stocker les contextes sur disque et ne passer qu'un hash dans l'url
4101
-		$md5 = md5($c);
4102
-		ecrire_fichier("$dir/c$md5", $c);
4103
-		$env = $md5;
4104
-	}
4105
-
4106
-	if ($emboite === null) {
4107
-		return $env;
4108
-	}
4109
-	if (!trim($emboite)) {
4110
-		return '';
4111
-	}
4112
-	// toujours encoder l'url source dans le bloc ajax
4113
-	$r = self();
4114
-	$r = ' data-origin="' . $r . '"';
4115
-	$class = 'ajaxbloc';
4116
-	if ($ajaxid and is_string($ajaxid)) {
4117
-		// ajaxid est normalement conforme a un nom de classe css
4118
-		// on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
4119
-		$class .= ' ajax-id-' . entites_html($ajaxid);
4120
-	}
4121
-
4122
-	return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
4031
+    $env = null;
4032
+    if (
4033
+        is_string($c)
4034
+        and @unserialize($c) !== false
4035
+    ) {
4036
+        $c = unserialize($c);
4037
+    }
4038
+
4039
+    // supprimer les parametres debut_x
4040
+    // pour que la pagination ajax ne soit pas plantee
4041
+    // si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0,
4042
+    // le debut_x=0 n'existe pas, et on resterait sur 1
4043
+    if (is_array($c)) {
4044
+        foreach ($c as $k => $v) {
4045
+            if (strpos($k, 'debut_') === 0) {
4046
+                unset($c[$k]);
4047
+            }
4048
+        }
4049
+    }
4050
+
4051
+    if (!function_exists('calculer_cle_action')) {
4052
+        include_spip('inc/securiser_action');
4053
+    }
4054
+
4055
+    $c = serialize($c);
4056
+    $cle = calculer_cle_action($form . $c);
4057
+    $c = "$cle:$c";
4058
+
4059
+    // on ne stocke pas les contextes dans des fichiers en cache
4060
+    // par defaut, sauf si cette configuration a été forcée
4061
+    // OU que la longueur de l’argument géneré est plus long
4062
+    // que ce qui est toléré.
4063
+    $cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX);
4064
+    if (!$cache_contextes_ajax) {
4065
+        $env = $c;
4066
+        if (function_exists('gzdeflate') && function_exists('gzinflate')) {
4067
+            $env = gzdeflate($env);
4068
+        }
4069
+        $env = _xor($env);
4070
+        $env = base64_encode($env);
4071
+        $len = strlen($env);
4072
+        // Si l’url est trop longue pour le navigateur
4073
+        $max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR;
4074
+        if ($len > $max_len) {
4075
+            $cache_contextes_ajax = true;
4076
+            spip_log(
4077
+                'Contextes AJAX forces en fichiers !'
4078
+                . ' Cela arrive lorsque la valeur du contexte'
4079
+                . " depasse la longueur maximale autorisee ($max_len). Ici : $len.",
4080
+                _LOG_AVERTISSEMENT
4081
+            );
4082
+        }
4083
+        // Sinon si Suhosin est actif et a une la valeur maximale des variables en GET...
4084
+        elseif (
4085
+            $max_len = @ini_get('suhosin.get.max_value_length')
4086
+            and $max_len < $len
4087
+        ) {
4088
+            $cache_contextes_ajax = true;
4089
+            spip_log('Contextes AJAX forces en fichiers !'
4090
+                . ' Cela arrive lorsque la valeur du contexte'
4091
+                . ' depasse la longueur maximale autorisee par Suhosin'
4092
+                . " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len."
4093
+                . ' Vous devriez modifier les parametres de Suhosin'
4094
+                . ' pour accepter au moins 1024 caracteres.', _LOG_AVERTISSEMENT);
4095
+        }
4096
+    }
4097
+
4098
+    if ($cache_contextes_ajax) {
4099
+        $dir = sous_repertoire(_DIR_CACHE, 'contextes');
4100
+        // stocker les contextes sur disque et ne passer qu'un hash dans l'url
4101
+        $md5 = md5($c);
4102
+        ecrire_fichier("$dir/c$md5", $c);
4103
+        $env = $md5;
4104
+    }
4105
+
4106
+    if ($emboite === null) {
4107
+        return $env;
4108
+    }
4109
+    if (!trim($emboite)) {
4110
+        return '';
4111
+    }
4112
+    // toujours encoder l'url source dans le bloc ajax
4113
+    $r = self();
4114
+    $r = ' data-origin="' . $r . '"';
4115
+    $class = 'ajaxbloc';
4116
+    if ($ajaxid and is_string($ajaxid)) {
4117
+        // ajaxid est normalement conforme a un nom de classe css
4118
+        // on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
4119
+        $class .= ' ajax-id-' . entites_html($ajaxid);
4120
+    }
4121
+
4122
+    return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
4123 4123
 }
4124 4124
 
4125 4125
 /**
@@ -4139,37 +4139,37 @@  discard block
 block discarded – undo
4139 4139
  *   - false : erreur de décodage
4140 4140
  */
4141 4141
 function decoder_contexte_ajax($c, $form = '') {
4142
-	if (!function_exists('calculer_cle_action')) {
4143
-		include_spip('inc/securiser_action');
4144
-	}
4145
-	if (
4146
-		((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32)
4147
-		and $dir = sous_repertoire(_DIR_CACHE, 'contextes')
4148
-		and lire_fichier("$dir/c$c", $contexte)
4149
-	) {
4150
-		$c = $contexte;
4151
-	} else {
4152
-		$c = @base64_decode($c);
4153
-		$c = _xor($c);
4154
-		if (function_exists('gzdeflate') && function_exists('gzinflate')) {
4155
-			$c = @gzinflate($c);
4156
-		}
4157
-	}
4158
-
4159
-	// extraire la signature en debut de contexte
4160
-	// et la verifier avant de deserializer
4161
-	// format : signature:donneesserializees
4162
-	if ($p = strpos($c, ':')) {
4163
-		$cle = substr($c, 0, $p);
4164
-		$c = substr($c, $p + 1);
4165
-
4166
-		if ($cle == calculer_cle_action($form . $c)) {
4167
-			$env = @unserialize($c);
4168
-			return $env;
4169
-		}
4170
-	}
4171
-
4172
-	return false;
4142
+    if (!function_exists('calculer_cle_action')) {
4143
+        include_spip('inc/securiser_action');
4144
+    }
4145
+    if (
4146
+        ((defined('_CACHE_CONTEXTES_AJAX') and _CACHE_CONTEXTES_AJAX) or strlen($c) == 32)
4147
+        and $dir = sous_repertoire(_DIR_CACHE, 'contextes')
4148
+        and lire_fichier("$dir/c$c", $contexte)
4149
+    ) {
4150
+        $c = $contexte;
4151
+    } else {
4152
+        $c = @base64_decode($c);
4153
+        $c = _xor($c);
4154
+        if (function_exists('gzdeflate') && function_exists('gzinflate')) {
4155
+            $c = @gzinflate($c);
4156
+        }
4157
+    }
4158
+
4159
+    // extraire la signature en debut de contexte
4160
+    // et la verifier avant de deserializer
4161
+    // format : signature:donneesserializees
4162
+    if ($p = strpos($c, ':')) {
4163
+        $cle = substr($c, 0, $p);
4164
+        $c = substr($c, $p + 1);
4165
+
4166
+        if ($cle == calculer_cle_action($form . $c)) {
4167
+            $env = @unserialize($c);
4168
+            return $env;
4169
+        }
4170
+    }
4171
+
4172
+    return false;
4173 4173
 }
4174 4174
 
4175 4175
 
@@ -4187,20 +4187,20 @@  discard block
 block discarded – undo
4187 4187
  *    Message décrypté ou encrypté
4188 4188
  **/
4189 4189
 function _xor($message, $key = null) {
4190
-	if (is_null($key)) {
4191
-		if (!function_exists('calculer_cle_action')) {
4192
-			include_spip('inc/securiser_action');
4193
-		}
4194
-		$key = pack('H*', calculer_cle_action('_xor'));
4195
-	}
4190
+    if (is_null($key)) {
4191
+        if (!function_exists('calculer_cle_action')) {
4192
+            include_spip('inc/securiser_action');
4193
+        }
4194
+        $key = pack('H*', calculer_cle_action('_xor'));
4195
+    }
4196 4196
 
4197
-	$keylen = strlen($key);
4198
-	$messagelen = strlen($message);
4199
-	for ($i = 0; $i < $messagelen; $i++) {
4200
-		$message[$i] = ~($message[$i] ^ $key[$i % $keylen]);
4201
-	}
4197
+    $keylen = strlen($key);
4198
+    $messagelen = strlen($message);
4199
+    for ($i = 0; $i < $messagelen; $i++) {
4200
+        $message[$i] = ~($message[$i] ^ $key[$i % $keylen]);
4201
+    }
4202 4202
 
4203
-	return $message;
4203
+    return $message;
4204 4204
 }
4205 4205
 
4206 4206
 /**
@@ -4214,7 +4214,7 @@  discard block
 block discarded – undo
4214 4214
  * @return string
4215 4215
  */
4216 4216
 function url_reponse_forum($texte) {
4217
- return $texte;
4217
+    return $texte;
4218 4218
 }
4219 4219
 
4220 4220
 /**
@@ -4228,7 +4228,7 @@  discard block
 block discarded – undo
4228 4228
  * @return string
4229 4229
  */
4230 4230
 function url_rss_forum($texte) {
4231
- return $texte;
4231
+    return $texte;
4232 4232
 }
4233 4233
 
4234 4234
 
@@ -4267,37 +4267,37 @@  discard block
 block discarded – undo
4267 4267
  *   Code HTML
4268 4268
  */
4269 4269
 function lien_ou_expose($url, $libelle = null, $on = false, $class = '', $title = '', $rel = '', $evt = '') {
4270
-	if ($on) {
4271
-		$bal = 'strong';
4272
-		$class = '';
4273
-		$att = '';
4274
-		// si $on passe la balise et optionnelement une ou ++classe
4275
-		// a.active span.selected.active etc....
4276
-		if (is_string($on) and (strncmp($on, 'a', 1) == 0 or strncmp($on, 'span', 4) == 0 or strncmp($on, 'strong', 6) == 0)) {
4277
-			$on = explode('.', $on);
4278
-			// on verifie que c'est exactement une des 3 balises a, span ou strong
4279
-			if (in_array(reset($on), ['a', 'span', 'strong'])) {
4280
-				$bal = array_shift($on);
4281
-				$class = implode(' ', $on);
4282
-				if ($bal == 'a') {
4283
-					$att = 'href="#" ';
4284
-				}
4285
-			}
4286
-		}
4287
-		$att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"';
4288
-	} else {
4289
-		$bal = 'a';
4290
-		$att = "href='$url'"
4291
-			. ($title ? " title='" . attribut_html($title) . "'" : '')
4292
-			. ($class ? " class='" . attribut_html($class) . "'" : '')
4293
-			. ($rel ? " rel='" . attribut_html($rel) . "'" : '')
4294
-			. $evt;
4295
-	}
4296
-	if ($libelle === null) {
4297
-		$libelle = $url;
4298
-	}
4299
-
4300
-	return "<$bal $att>$libelle</$bal>";
4270
+    if ($on) {
4271
+        $bal = 'strong';
4272
+        $class = '';
4273
+        $att = '';
4274
+        // si $on passe la balise et optionnelement une ou ++classe
4275
+        // a.active span.selected.active etc....
4276
+        if (is_string($on) and (strncmp($on, 'a', 1) == 0 or strncmp($on, 'span', 4) == 0 or strncmp($on, 'strong', 6) == 0)) {
4277
+            $on = explode('.', $on);
4278
+            // on verifie que c'est exactement une des 3 balises a, span ou strong
4279
+            if (in_array(reset($on), ['a', 'span', 'strong'])) {
4280
+                $bal = array_shift($on);
4281
+                $class = implode(' ', $on);
4282
+                if ($bal == 'a') {
4283
+                    $att = 'href="#" ';
4284
+                }
4285
+            }
4286
+        }
4287
+        $att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"';
4288
+    } else {
4289
+        $bal = 'a';
4290
+        $att = "href='$url'"
4291
+            . ($title ? " title='" . attribut_html($title) . "'" : '')
4292
+            . ($class ? " class='" . attribut_html($class) . "'" : '')
4293
+            . ($rel ? " rel='" . attribut_html($rel) . "'" : '')
4294
+            . $evt;
4295
+    }
4296
+    if ($libelle === null) {
4297
+        $libelle = $url;
4298
+    }
4299
+
4300
+    return "<$bal $att>$libelle</$bal>";
4301 4301
 }
4302 4302
 
4303 4303
 
@@ -4314,39 +4314,39 @@  discard block
 block discarded – undo
4314 4314
  * @return string : la chaine de langue finale en utilisant la fonction _T()
4315 4315
  */
4316 4316
 function singulier_ou_pluriel($nb, $chaine_un, $chaine_plusieurs, $var = 'nb', $vars = []) {
4317
-	static $local_singulier_ou_pluriel = [];
4318
-
4319
-	// si nb=0 ou pas de $vars valide on retourne une chaine vide, a traiter par un |sinon
4320
-	if (!is_numeric($nb) or $nb == 0) {
4321
-		return '';
4322
-	}
4323
-	if (!is_array($vars)) {
4324
-		return '';
4325
-	}
4326
-
4327
-	$langue = $GLOBALS['spip_lang'];
4328
-	if (!isset($local_singulier_ou_pluriel[$langue])) {
4329
-		$local_singulier_ou_pluriel[$langue] = false;
4330
-		if (
4331
-			$f = charger_fonction("singulier_ou_pluriel_{$langue}", 'inc', true)
4332
-			or $f = charger_fonction('singulier_ou_pluriel', 'inc', true)
4333
-		) {
4334
-			$local_singulier_ou_pluriel[$langue] = $f;
4335
-		}
4336
-	}
4337
-
4338
-	// si on a une surcharge on l'utilise
4339
-	if ($local_singulier_ou_pluriel[$langue]) {
4340
-		return ($local_singulier_ou_pluriel[$langue])($nb, $chaine_un, $chaine_plusieurs, $var, $vars);
4341
-	}
4342
-
4343
-	// sinon traitement par defaut
4344
-	$vars[$var] = $nb;
4345
-	if ($nb >= 2) {
4346
-		return _T($chaine_plusieurs, $vars);
4347
-	} else {
4348
-		return _T($chaine_un, $vars);
4349
-	}
4317
+    static $local_singulier_ou_pluriel = [];
4318
+
4319
+    // si nb=0 ou pas de $vars valide on retourne une chaine vide, a traiter par un |sinon
4320
+    if (!is_numeric($nb) or $nb == 0) {
4321
+        return '';
4322
+    }
4323
+    if (!is_array($vars)) {
4324
+        return '';
4325
+    }
4326
+
4327
+    $langue = $GLOBALS['spip_lang'];
4328
+    if (!isset($local_singulier_ou_pluriel[$langue])) {
4329
+        $local_singulier_ou_pluriel[$langue] = false;
4330
+        if (
4331
+            $f = charger_fonction("singulier_ou_pluriel_{$langue}", 'inc', true)
4332
+            or $f = charger_fonction('singulier_ou_pluriel', 'inc', true)
4333
+        ) {
4334
+            $local_singulier_ou_pluriel[$langue] = $f;
4335
+        }
4336
+    }
4337
+
4338
+    // si on a une surcharge on l'utilise
4339
+    if ($local_singulier_ou_pluriel[$langue]) {
4340
+        return ($local_singulier_ou_pluriel[$langue])($nb, $chaine_un, $chaine_plusieurs, $var, $vars);
4341
+    }
4342
+
4343
+    // sinon traitement par defaut
4344
+    $vars[$var] = $nb;
4345
+    if ($nb >= 2) {
4346
+        return _T($chaine_plusieurs, $vars);
4347
+    } else {
4348
+        return _T($chaine_un, $vars);
4349
+    }
4350 4350
 }
4351 4351
 
4352 4352
 
@@ -4374,73 +4374,73 @@  discard block
 block discarded – undo
4374 4374
  */
4375 4375
 function prepare_icone_base($type, $lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') {
4376 4376
 
4377
-	$class_lien = $class_bouton = $class;
4378
-
4379
-	// Normaliser la fonction et compléter la classe en fonction
4380
-	if (in_array($fonction, ['del', 'supprimer.gif'])) {
4381
-		$class_lien .= ' danger';
4382
-		$class_bouton .= ' btn_danger';
4383
-	} elseif ($fonction == 'rien.gif') {
4384
-		$fonction = '';
4385
-	} elseif ($fonction == 'delsafe') {
4386
-		$fonction = 'del';
4387
-	}
4388
-
4389
-	$fond_origine = $fond;
4390
-	// Remappage des icone : article-24.png+new => article-new-24.png
4391
-	if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
4392
-		[$fond, $fonction] = $icone_renommer($fond, $fonction);
4393
-	}
4394
-
4395
-	// Ajouter le type d'objet dans la classe
4396
-	$objet_type = substr(basename($fond), 0, -4);
4397
-	$class_lien .= " $objet_type";
4398
-	$class_bouton .= " $objet_type";
4399
-
4400
-	// Texte
4401
-	$alt = attribut_html($texte);
4402
-	$title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
4403
-
4404
-	// Liens : préparer les classes ajax
4405
-	$ajax = '';
4406
-	if ($type === 'lien') {
4407
-		if (strpos($class_lien, 'ajax') !== false) {
4408
-			$ajax = 'ajax';
4409
-			if (strpos($class_lien, 'preload') !== false) {
4410
-				$ajax .= ' preload';
4411
-			}
4412
-			if (strpos($class_lien, 'nocache') !== false) {
4413
-				$ajax .= ' nocache';
4414
-			}
4415
-			$ajax = " class='$ajax'";
4416
-		}
4417
-	}
4418
-
4419
-	// Repérer la taille et l'ajouter dans la classe
4420
-	$size = 24;
4421
-	if (
4422
-		preg_match('/-([0-9]{1,3})[.](gif|png|svg)$/i', $fond, $match)
4423
-		or preg_match('/-([0-9]{1,3})([.](gif|png|svg))?$/i', $fond_origine, $match)
4424
-	) {
4425
-		$size = $match[1];
4426
-	}
4427
-	$class_lien .= " s$size";
4428
-	$class_bouton .= " s$size";
4429
-
4430
-	// Icône
4431
-	$icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4432
-	$icone = '<span class="icone-image' . ($fonction ? " icone-fonction icone-fonction-$fonction" : '') . "\">$icone</span>";
4433
-
4434
-	// Markup final
4435
-	if ($type == 'lien') {
4436
-		return "<span class='icone $class_lien'>"
4437
-		. "<a href='$lien'$title$ajax$javascript>"
4438
-		. $icone
4439
-		. "<b>$texte</b>"
4440
-		. "</a></span>\n";
4441
-	} else {
4442
-		return bouton_action("$icone $texte", $lien, $class_bouton, $javascript, $alt);
4443
-	}
4377
+    $class_lien = $class_bouton = $class;
4378
+
4379
+    // Normaliser la fonction et compléter la classe en fonction
4380
+    if (in_array($fonction, ['del', 'supprimer.gif'])) {
4381
+        $class_lien .= ' danger';
4382
+        $class_bouton .= ' btn_danger';
4383
+    } elseif ($fonction == 'rien.gif') {
4384
+        $fonction = '';
4385
+    } elseif ($fonction == 'delsafe') {
4386
+        $fonction = 'del';
4387
+    }
4388
+
4389
+    $fond_origine = $fond;
4390
+    // Remappage des icone : article-24.png+new => article-new-24.png
4391
+    if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
4392
+        [$fond, $fonction] = $icone_renommer($fond, $fonction);
4393
+    }
4394
+
4395
+    // Ajouter le type d'objet dans la classe
4396
+    $objet_type = substr(basename($fond), 0, -4);
4397
+    $class_lien .= " $objet_type";
4398
+    $class_bouton .= " $objet_type";
4399
+
4400
+    // Texte
4401
+    $alt = attribut_html($texte);
4402
+    $title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
4403
+
4404
+    // Liens : préparer les classes ajax
4405
+    $ajax = '';
4406
+    if ($type === 'lien') {
4407
+        if (strpos($class_lien, 'ajax') !== false) {
4408
+            $ajax = 'ajax';
4409
+            if (strpos($class_lien, 'preload') !== false) {
4410
+                $ajax .= ' preload';
4411
+            }
4412
+            if (strpos($class_lien, 'nocache') !== false) {
4413
+                $ajax .= ' nocache';
4414
+            }
4415
+            $ajax = " class='$ajax'";
4416
+        }
4417
+    }
4418
+
4419
+    // Repérer la taille et l'ajouter dans la classe
4420
+    $size = 24;
4421
+    if (
4422
+        preg_match('/-([0-9]{1,3})[.](gif|png|svg)$/i', $fond, $match)
4423
+        or preg_match('/-([0-9]{1,3})([.](gif|png|svg))?$/i', $fond_origine, $match)
4424
+    ) {
4425
+        $size = $match[1];
4426
+    }
4427
+    $class_lien .= " s$size";
4428
+    $class_bouton .= " s$size";
4429
+
4430
+    // Icône
4431
+    $icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4432
+    $icone = '<span class="icone-image' . ($fonction ? " icone-fonction icone-fonction-$fonction" : '') . "\">$icone</span>";
4433
+
4434
+    // Markup final
4435
+    if ($type == 'lien') {
4436
+        return "<span class='icone $class_lien'>"
4437
+        . "<a href='$lien'$title$ajax$javascript>"
4438
+        . $icone
4439
+        . "<b>$texte</b>"
4440
+        . "</a></span>\n";
4441
+    } else {
4442
+        return bouton_action("$icone $texte", $lien, $class_bouton, $javascript, $alt);
4443
+    }
4444 4444
 }
4445 4445
 
4446 4446
 /**
@@ -4464,7 +4464,7 @@  discard block
 block discarded – undo
4464 4464
  *     Code HTML du lien
4465 4465
  **/
4466 4466
 function icone_base($lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') {
4467
-	return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript);
4467
+    return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript);
4468 4468
 }
4469 4469
 
4470 4470
 /**
@@ -4499,7 +4499,7 @@  discard block
 block discarded – undo
4499 4499
  *     Code HTML du lien
4500 4500
  **/
4501 4501
 function filtre_icone_verticale_dist($lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') {
4502
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript);
4502
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript);
4503 4503
 }
4504 4504
 
4505 4505
 /**
@@ -4544,7 +4544,7 @@  discard block
 block discarded – undo
4544 4544
  *     Code HTML du lien
4545 4545
  **/
4546 4546
 function filtre_icone_horizontale_dist($lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') {
4547
-	return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript);
4547
+    return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript);
4548 4548
 }
4549 4549
 
4550 4550
 /**
@@ -4575,7 +4575,7 @@  discard block
 block discarded – undo
4575 4575
  *     Code HTML du lien
4576 4576
  **/
4577 4577
 function filtre_bouton_action_horizontal_dist($lien, $texte, $fond, $fonction = '', $class = '', $confirm = '') {
4578
-	return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, $class, $confirm);
4578
+    return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, $class, $confirm);
4579 4579
 }
4580 4580
 
4581 4581
 /**
@@ -4606,7 +4606,7 @@  discard block
 block discarded – undo
4606 4606
  *     Code HTML du lien
4607 4607
  */
4608 4608
 function filtre_icone_dist($lien, $texte, $fond, $align = '', $fonction = '', $class = '', $javascript = '') {
4609
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript);
4609
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript);
4610 4610
 }
4611 4611
 
4612 4612
 
@@ -4628,7 +4628,7 @@  discard block
 block discarded – undo
4628 4628
  * @return array Liste des éléments
4629 4629
  */
4630 4630
 function filtre_explode_dist($a, $b) {
4631
-	return explode($b, (string) $a);
4631
+    return explode($b, (string) $a);
4632 4632
 }
4633 4633
 
4634 4634
 /**
@@ -4649,7 +4649,7 @@  discard block
 block discarded – undo
4649 4649
  * @return string Texte
4650 4650
  */
4651 4651
 function filtre_implode_dist($a, $b) {
4652
-	return is_array($a) ? implode($b, $a) : $a;
4652
+    return is_array($a) ? implode($b, $a) : $a;
4653 4653
 }
4654 4654
 
4655 4655
 /**
@@ -4658,22 +4658,22 @@  discard block
 block discarded – undo
4658 4658
  * @return string Code CSS
4659 4659
  */
4660 4660
 function bando_images_background() {
4661
-	include_spip('inc/bandeau');
4662
-	// recuperer tous les boutons et leurs images
4663
-	$boutons = definir_barre_boutons(definir_barre_contexte(), true, false);
4661
+    include_spip('inc/bandeau');
4662
+    // recuperer tous les boutons et leurs images
4663
+    $boutons = definir_barre_boutons(definir_barre_contexte(), true, false);
4664 4664
 
4665
-	$res = '';
4666
-	foreach ($boutons as $page => $detail) {
4667
-		$selecteur = (in_array($page, ['outils_rapides', 'outils_collaboratifs']) ? '' : '.navigation_avec_icones ');
4668
-		foreach ($detail->sousmenu as $souspage => $sousdetail) {
4669
-			if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4670
-				$img = http_img_variante_svg_si_possible($sousdetail->icone);
4671
-				$res .= "\n$selecteur.bando2_$souspage {background-image:url($img);}";
4672
-			}
4673
-		}
4674
-	}
4665
+    $res = '';
4666
+    foreach ($boutons as $page => $detail) {
4667
+        $selecteur = (in_array($page, ['outils_rapides', 'outils_collaboratifs']) ? '' : '.navigation_avec_icones ');
4668
+        foreach ($detail->sousmenu as $souspage => $sousdetail) {
4669
+            if ($sousdetail->icone and strlen(trim($sousdetail->icone))) {
4670
+                $img = http_img_variante_svg_si_possible($sousdetail->icone);
4671
+                $res .= "\n$selecteur.bando2_$souspage {background-image:url($img);}";
4672
+            }
4673
+        }
4674
+    }
4675 4675
 
4676
-	return $res;
4676
+    return $res;
4677 4677
 }
4678 4678
 
4679 4679
 /**
@@ -4698,27 +4698,27 @@  discard block
 block discarded – undo
4698 4698
  */
4699 4699
 function bouton_action($libelle, $url, $class = '', $confirm = '', $title = '', $callback = '') {
4700 4700
 
4701
-	// Classes : dispatcher `ajax` sur le formulaire
4702
-	$class_form = '';
4703
-	if (strpos($class, 'ajax') !== false) {
4704
-		$class_form = 'ajax';
4705
-		$class = str_replace('ajax', '', $class);
4706
-	}
4707
-	$class_btn = 'submit ' . trim($class);
4701
+    // Classes : dispatcher `ajax` sur le formulaire
4702
+    $class_form = '';
4703
+    if (strpos($class, 'ajax') !== false) {
4704
+        $class_form = 'ajax';
4705
+        $class = str_replace('ajax', '', $class);
4706
+    }
4707
+    $class_btn = 'submit ' . trim($class);
4708 4708
 
4709
-	if ($confirm) {
4710
-		$confirm = 'confirm("' . attribut_html($confirm) . '")';
4711
-		if ($callback) {
4712
-			$callback = "$confirm?($callback):false";
4713
-		} else {
4714
-			$callback = $confirm;
4715
-		}
4716
-	}
4717
-	$onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : '';
4718
-	$title = $title ? " title='$title'" : '';
4709
+    if ($confirm) {
4710
+        $confirm = 'confirm("' . attribut_html($confirm) . '")';
4711
+        if ($callback) {
4712
+            $callback = "$confirm?($callback):false";
4713
+        } else {
4714
+            $callback = $confirm;
4715
+        }
4716
+    }
4717
+    $onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : '';
4718
+    $title = $title ? " title='$title'" : '';
4719 4719
 
4720
-	return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>" . form_hidden($url)
4721
-	. "<button type='submit' class='$class_btn'$title$onclick>$libelle</button></div></form>";
4720
+    return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>" . form_hidden($url)
4721
+    . "<button type='submit' class='$class_btn'$title$onclick>$libelle</button></div></form>";
4722 4722
 }
4723 4723
 
4724 4724
 /**
@@ -4741,101 +4741,101 @@  discard block
 block discarded – undo
4741 4741
  * @return string
4742 4742
  */
4743 4743
 function generer_objet_info($id_objet, string $type_objet, string $info, string $etoile = '', array $params = []): string {
4744
-	static $trouver_table = null;
4745
-	static $objets;
4746
-
4747
-	// On verifie qu'on a tout ce qu'il faut
4748
-	$id_objet = intval($id_objet);
4749
-	if (!($id_objet and $type_objet and $info)) {
4750
-		return '';
4751
-	}
4752
-
4753
-	// si on a deja note que l'objet n'existe pas, ne pas aller plus loin
4754
-	if (isset($objets[$type_objet]) and $objets[$type_objet] === false) {
4755
-		return '';
4756
-	}
4757
-
4758
-	// Si on demande l'url, on retourne direct la fonction
4759
-	if ($info == 'url') {
4760
-		return generer_objet_url($id_objet, $type_objet, ...$params);
4761
-	}
4762
-
4763
-	// Sinon on va tout chercher dans la table et on garde en memoire
4764
-	$demande_titre = ($info === 'titre');
4765
-	$demande_introduction = ($info === 'introduction');
4766
-
4767
-	// 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
4768
-	if (
4769
-		!isset($objets[$type_objet][$id_objet])
4770
-		or
4771
-		($demande_titre and !isset($objets[$type_objet][$id_objet]['titre']))
4772
-	) {
4773
-		if (!$trouver_table) {
4774
-			$trouver_table = charger_fonction('trouver_table', 'base');
4775
-		}
4776
-		$desc = $trouver_table(table_objet_sql($type_objet));
4777
-		if (!$desc) {
4778
-			return $objets[$type_objet] = false;
4779
-		}
4780
-
4781
-		// Si on demande le titre, on le gere en interne
4782
-		$champ_titre = '';
4783
-		if ($demande_titre) {
4784
-			// si pas de titre declare mais champ titre, il sera peuple par le select *
4785
-			$champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4786
-		}
4787
-		include_spip('base/abstract_sql');
4788
-		include_spip('base/connect_sql');
4789
-		$objets[$type_objet][$id_objet] = sql_fetsel(
4790
-			'*' . $champ_titre,
4791
-			$desc['table_sql'],
4792
-			id_table_objet($type_objet) . ' = ' . intval($id_objet)
4793
-		);
4794
-
4795
-		// Toujours noter la longueur d'introduction, même si pas demandé cette fois-ci
4796
-		$objets[$type_objet]['introduction_longueur'] = $desc['introduction_longueur'] ?? null;
4797
-	}
4798
-
4799
-	// Pour les fonction generer_xxx, si on demande l'introduction,
4800
-	// ajouter la longueur au début des params supplémentaires
4801
-	if ($demande_introduction) {
4802
-		$introduction_longueur = $objets[$type_objet]['introduction_longueur'];
4803
-		array_unshift($params, $introduction_longueur);
4804
-	}
4805
-
4806
-	// Si la fonction generer_TYPE_TRUC existe, on l'utilise pour formater $info_generee
4807
-	if (
4808
-		$generer = charger_fonction("generer_{$type_objet}_{$info}", '', true)
4809
-		// @deprecated 4.1 generer_TRUC_TYPE
4810
-		or $generer = charger_fonction("generer_{$info}_{$type_objet}", '', true)
4811
-	) {
4812
-		$info_generee = $generer($id_objet, $objets[$type_objet][$id_objet], ...$params);
4813
-	}
4814
-	// Si la fonction generer_objet_TRUC existe, on l'utilise pour formater $info_generee
4815
-	elseif (
4816
-		$generer = charger_fonction("generer_objet_{$info}", '', true)
4817
-		// @deprecated 4.1 generer_TRUC_entite
4818
-		or $generer = charger_fonction("generer_{$info}_entite", '', true)
4819
-	) {
4820
-		$info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet], ...$params);
4821
-	} // Sinon on prend directement le champ SQL tel quel
4822
-	else {
4823
-		$info_generee = ($objets[$type_objet][$id_objet][$info] ?? '');
4824
-	}
4825
-
4826
-	// On va ensuite appliquer les traitements automatiques si besoin
4827
-	if (!$etoile) {
4828
-		// FIXME: on fournit un ENV minimum avec id et type et connect=''
4829
-		// mais ce fonctionnement est a ameliorer !
4830
-		$info_generee = appliquer_traitement_champ(
4831
-			$info_generee,
4832
-			$info,
4833
-			table_objet($type_objet),
4834
-			['id_objet' => $id_objet, 'objet' => $type_objet, '']
4835
-		);
4836
-	}
4837
-
4838
-	return $info_generee;
4744
+    static $trouver_table = null;
4745
+    static $objets;
4746
+
4747
+    // On verifie qu'on a tout ce qu'il faut
4748
+    $id_objet = intval($id_objet);
4749
+    if (!($id_objet and $type_objet and $info)) {
4750
+        return '';
4751
+    }
4752
+
4753
+    // si on a deja note que l'objet n'existe pas, ne pas aller plus loin
4754
+    if (isset($objets[$type_objet]) and $objets[$type_objet] === false) {
4755
+        return '';
4756
+    }
4757
+
4758
+    // Si on demande l'url, on retourne direct la fonction
4759
+    if ($info == 'url') {
4760
+        return generer_objet_url($id_objet, $type_objet, ...$params);
4761
+    }
4762
+
4763
+    // Sinon on va tout chercher dans la table et on garde en memoire
4764
+    $demande_titre = ($info === 'titre');
4765
+    $demande_introduction = ($info === 'introduction');
4766
+
4767
+    // 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
4768
+    if (
4769
+        !isset($objets[$type_objet][$id_objet])
4770
+        or
4771
+        ($demande_titre and !isset($objets[$type_objet][$id_objet]['titre']))
4772
+    ) {
4773
+        if (!$trouver_table) {
4774
+            $trouver_table = charger_fonction('trouver_table', 'base');
4775
+        }
4776
+        $desc = $trouver_table(table_objet_sql($type_objet));
4777
+        if (!$desc) {
4778
+            return $objets[$type_objet] = false;
4779
+        }
4780
+
4781
+        // Si on demande le titre, on le gere en interne
4782
+        $champ_titre = '';
4783
+        if ($demande_titre) {
4784
+            // si pas de titre declare mais champ titre, il sera peuple par le select *
4785
+            $champ_titre = (!empty($desc['titre'])) ? ', ' . $desc['titre'] : '';
4786
+        }
4787
+        include_spip('base/abstract_sql');
4788
+        include_spip('base/connect_sql');
4789
+        $objets[$type_objet][$id_objet] = sql_fetsel(
4790
+            '*' . $champ_titre,
4791
+            $desc['table_sql'],
4792
+            id_table_objet($type_objet) . ' = ' . intval($id_objet)
4793
+        );
4794
+
4795
+        // Toujours noter la longueur d'introduction, même si pas demandé cette fois-ci
4796
+        $objets[$type_objet]['introduction_longueur'] = $desc['introduction_longueur'] ?? null;
4797
+    }
4798
+
4799
+    // Pour les fonction generer_xxx, si on demande l'introduction,
4800
+    // ajouter la longueur au début des params supplémentaires
4801
+    if ($demande_introduction) {
4802
+        $introduction_longueur = $objets[$type_objet]['introduction_longueur'];
4803
+        array_unshift($params, $introduction_longueur);
4804
+    }
4805
+
4806
+    // Si la fonction generer_TYPE_TRUC existe, on l'utilise pour formater $info_generee
4807
+    if (
4808
+        $generer = charger_fonction("generer_{$type_objet}_{$info}", '', true)
4809
+        // @deprecated 4.1 generer_TRUC_TYPE
4810
+        or $generer = charger_fonction("generer_{$info}_{$type_objet}", '', true)
4811
+    ) {
4812
+        $info_generee = $generer($id_objet, $objets[$type_objet][$id_objet], ...$params);
4813
+    }
4814
+    // Si la fonction generer_objet_TRUC existe, on l'utilise pour formater $info_generee
4815
+    elseif (
4816
+        $generer = charger_fonction("generer_objet_{$info}", '', true)
4817
+        // @deprecated 4.1 generer_TRUC_entite
4818
+        or $generer = charger_fonction("generer_{$info}_entite", '', true)
4819
+    ) {
4820
+        $info_generee = $generer($id_objet, $type_objet, $objets[$type_objet][$id_objet], ...$params);
4821
+    } // Sinon on prend directement le champ SQL tel quel
4822
+    else {
4823
+        $info_generee = ($objets[$type_objet][$id_objet][$info] ?? '');
4824
+    }
4825
+
4826
+    // On va ensuite appliquer les traitements automatiques si besoin
4827
+    if (!$etoile) {
4828
+        // FIXME: on fournit un ENV minimum avec id et type et connect=''
4829
+        // mais ce fonctionnement est a ameliorer !
4830
+        $info_generee = appliquer_traitement_champ(
4831
+            $info_generee,
4832
+            $info,
4833
+            table_objet($type_objet),
4834
+            ['id_objet' => $id_objet, 'objet' => $type_objet, '']
4835
+        );
4836
+    }
4837
+
4838
+    return $info_generee;
4839 4839
 }
4840 4840
 
4841 4841
 /**
@@ -4843,7 +4843,7 @@  discard block
 block discarded – undo
4843 4843
  * @see generer_objet_info
4844 4844
  */
4845 4845
 function generer_info_entite($id_objet, $type_objet, $info, $etoile = '', $params = []) {
4846
-	return generer_objet_info(intval($id_objet), $type_objet, $info, $etoile, $params);
4846
+    return generer_objet_info(intval($id_objet), $type_objet, $info, $etoile, $params);
4847 4847
 }
4848 4848
 
4849 4849
 /**
@@ -4876,36 +4876,36 @@  discard block
 block discarded – undo
4876 4876
  */
4877 4877
 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 {
4878 4878
 
4879
-	$descriptif = $ligne_sql['descriptif'] ?? '';
4880
-	$texte = $ligne_sql['texte'] ?? '';
4881
-	// En absence de descriptif, on se rabat sur chapo + texte
4882
-	if (isset($ligne_sql['chapo'])) {
4883
-		$chapo = $ligne_sql['chapo'];
4884
-		$texte = strlen($descriptif) ?
4885
-			'' :
4886
-			"$chapo \n\n $texte";
4887
-	}
4879
+    $descriptif = $ligne_sql['descriptif'] ?? '';
4880
+    $texte = $ligne_sql['texte'] ?? '';
4881
+    // En absence de descriptif, on se rabat sur chapo + texte
4882
+    if (isset($ligne_sql['chapo'])) {
4883
+        $chapo = $ligne_sql['chapo'];
4884
+        $texte = strlen($descriptif) ?
4885
+            '' :
4886
+            "$chapo \n\n $texte";
4887
+    }
4888 4888
 
4889
-	// Longueur en paramètre, sinon celle renseignée dans la description de l'objet, sinon valeur en dur
4890
-	if (!intval($longueur_ou_suite)) {
4891
-		$longueur = intval($introduction_longueur ?: 600);
4892
-	} else {
4893
-		$longueur = intval($longueur_ou_suite);
4894
-	}
4889
+    // Longueur en paramètre, sinon celle renseignée dans la description de l'objet, sinon valeur en dur
4890
+    if (!intval($longueur_ou_suite)) {
4891
+        $longueur = intval($introduction_longueur ?: 600);
4892
+    } else {
4893
+        $longueur = intval($longueur_ou_suite);
4894
+    }
4895 4895
 
4896
-	// On peut optionnellement passer la suite en 1er paramètre de la balise
4897
-	// Ex : #INTRODUCTION{...}
4898
-	if (
4899
-		is_null($suite)
4900
-		and !intval($longueur_ou_suite)
4901
-	) {
4902
-		$suite = $longueur_ou_suite;
4903
-	}
4896
+    // On peut optionnellement passer la suite en 1er paramètre de la balise
4897
+    // Ex : #INTRODUCTION{...}
4898
+    if (
4899
+        is_null($suite)
4900
+        and !intval($longueur_ou_suite)
4901
+    ) {
4902
+        $suite = $longueur_ou_suite;
4903
+    }
4904 4904
 
4905
-	$f = chercher_filtre('introduction');
4906
-	$introduction = $f($descriptif, $texte, $longueur, $connect, $suite);
4905
+    $f = chercher_filtre('introduction');
4906
+    $introduction = $f($descriptif, $texte, $longueur, $connect, $suite);
4907 4907
 
4908
-	return $introduction;
4908
+    return $introduction;
4909 4909
 }
4910 4910
 
4911 4911
 /**
@@ -4913,7 +4913,7 @@  discard block
 block discarded – undo
4913 4913
  * @see generer_objet_introduction
4914 4914
  */
4915 4915
 function generer_introduction_entite($id_objet, $type_objet, $ligne_sql, $introduction_longueur = null, $longueur_ou_suite = null, $suite = null, string $connect = '') {
4916
-	return generer_objet_introduction(intval($id_objet), $type_objet, $ligne_sql, $introduction_longueur, $longueur_ou_suite, $suite, $connect);
4916
+    return generer_objet_introduction(intval($id_objet), $type_objet, $ligne_sql, $introduction_longueur, $longueur_ou_suite, $suite, $connect);
4917 4917
 }
4918 4918
 
4919 4919
 /**
@@ -4927,49 +4927,49 @@  discard block
 block discarded – undo
4927 4927
  * @return string
4928 4928
  */
4929 4929
 function appliquer_traitement_champ($texte, $champ, $table_objet = '', $env = [], string $connect = '') {
4930
-	if (!$champ) {
4931
-		return $texte;
4932
-	}
4930
+    if (!$champ) {
4931
+        return $texte;
4932
+    }
4933 4933
 
4934
-	// On charge les définitions des traitements (inc/texte et fichiers de fonctions)
4935
-	// car il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4936
-	include_fichiers_fonctions();
4934
+    // On charge les définitions des traitements (inc/texte et fichiers de fonctions)
4935
+    // car il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4936
+    include_fichiers_fonctions();
4937 4937
 
4938
-	$champ = strtoupper($champ);
4939
-	$traitements = $GLOBALS['table_des_traitements'][$champ] ?? false;
4940
-	if (!$traitements or !is_array($traitements)) {
4941
-		return $texte;
4942
-	}
4938
+    $champ = strtoupper($champ);
4939
+    $traitements = $GLOBALS['table_des_traitements'][$champ] ?? false;
4940
+    if (!$traitements or !is_array($traitements)) {
4941
+        return $texte;
4942
+    }
4943 4943
 
4944
-	$traitement = '';
4945
-	if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) {
4946
-		// necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4947
-		$table_objet = table_objet($table_objet);
4948
-		if (isset($traitements[$table_objet])) {
4949
-			$traitement = $traitements[$table_objet];
4950
-		}
4951
-	}
4952
-	if (!$traitement and isset($traitements[0])) {
4953
-		$traitement = $traitements[0];
4954
-	}
4955
-	// (sinon prendre le premier de la liste par defaut ?)
4944
+    $traitement = '';
4945
+    if ($table_objet and (!isset($traitements[0]) or count($traitements) > 1)) {
4946
+        // necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4947
+        $table_objet = table_objet($table_objet);
4948
+        if (isset($traitements[$table_objet])) {
4949
+            $traitement = $traitements[$table_objet];
4950
+        }
4951
+    }
4952
+    if (!$traitement and isset($traitements[0])) {
4953
+        $traitement = $traitements[0];
4954
+    }
4955
+    // (sinon prendre le premier de la liste par defaut ?)
4956 4956
 
4957
-	if (!$traitement) {
4958
-		return $texte;
4959
-	}
4957
+    if (!$traitement) {
4958
+        return $texte;
4959
+    }
4960 4960
 
4961
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4961
+    $traitement = str_replace('%s', "'" . texte_script($texte) . "'", $traitement);
4962 4962
 
4963
-	// signaler qu'on est dans l'espace prive pour les filtres qui se servent de ce flag
4964
-	if (test_espace_prive()) {
4965
-		$env['espace_prive'] = 1;
4966
-	}
4963
+    // signaler qu'on est dans l'espace prive pour les filtres qui se servent de ce flag
4964
+    if (test_espace_prive()) {
4965
+        $env['espace_prive'] = 1;
4966
+    }
4967 4967
 
4968
-	// Fournir $connect et $Pile[0] au traitement si besoin
4969
-	$Pile = [0 => $env];
4970
-	eval("\$texte = $traitement;");
4968
+    // Fournir $connect et $Pile[0] au traitement si besoin
4969
+    $Pile = [0 => $env];
4970
+    eval("\$texte = $traitement;");
4971 4971
 
4972
-	return $texte;
4972
+    return $texte;
4973 4973
 }
4974 4974
 
4975 4975
 
@@ -4983,21 +4983,21 @@  discard block
 block discarded – undo
4983 4983
  * @return string
4984 4984
  */
4985 4985
 function generer_objet_lien(int $id_objet, string $objet, int $longueur = 80, string $connect = ''): string {
4986
-	include_spip('inc/liens');
4987
-	$titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4988
-	// lorsque l'objet n'est plus declare (plugin desactive par exemple)
4989
-	// le raccourcis n'est plus valide
4990
-	$titre = typo($titre['titre'] ?? '');
4991
-	// on essaye avec generer_info_entite ?
4992
-	if (!strlen($titre) and !$connect) {
4993
-		$titre = generer_objet_info($id_objet, $objet, 'titre');
4994
-	}
4995
-	if (!strlen($titre)) {
4996
-		$titre = _T('info_sans_titre');
4997
-	}
4998
-	$url = generer_objet_url($id_objet, $objet, '', '', null, '', $connect);
4986
+    include_spip('inc/liens');
4987
+    $titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4988
+    // lorsque l'objet n'est plus declare (plugin desactive par exemple)
4989
+    // le raccourcis n'est plus valide
4990
+    $titre = typo($titre['titre'] ?? '');
4991
+    // on essaye avec generer_info_entite ?
4992
+    if (!strlen($titre) and !$connect) {
4993
+        $titre = generer_objet_info($id_objet, $objet, 'titre');
4994
+    }
4995
+    if (!strlen($titre)) {
4996
+        $titre = _T('info_sans_titre');
4997
+    }
4998
+    $url = generer_objet_url($id_objet, $objet, '', '', null, '', $connect);
4999 4999
 
5000
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . '</a>';
5000
+    return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . '</a>';
5001 5001
 }
5002 5002
 
5003 5003
 /**
@@ -5005,7 +5005,7 @@  discard block
 block discarded – undo
5005 5005
  * @see generer_objet_lien
5006 5006
  */
5007 5007
 function generer_lien_entite($id_objet, $objet, $longueur = 80, $connect = null) {
5008
-	return generer_objet_lien(intval($id_objet), $objet, $longueur, $connect ?? '');
5008
+    return generer_objet_lien(intval($id_objet), $objet, $longueur, $connect ?? '');
5009 5009
 }
5010 5010
 
5011 5011
 /**
@@ -5021,15 +5021,15 @@  discard block
 block discarded – undo
5021 5021
  * @return string
5022 5022
  */
5023 5023
 function wrap($texte, $wrap) {
5024
-	$balises = extraire_balises($wrap);
5025
-	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
5026
-		$texte = $wrap . $texte;
5027
-		$regs = array_reverse($regs[1]);
5028
-		$wrap = '</' . implode('></', $regs) . '>';
5029
-		$texte = $texte . $wrap;
5030
-	}
5024
+    $balises = extraire_balises($wrap);
5025
+    if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
5026
+        $texte = $wrap . $texte;
5027
+        $regs = array_reverse($regs[1]);
5028
+        $wrap = '</' . implode('></', $regs) . '>';
5029
+        $texte = $texte . $wrap;
5030
+    }
5031 5031
 
5032
-	return $texte;
5032
+    return $texte;
5033 5033
 }
5034 5034
 
5035 5035
 
@@ -5049,44 +5049,44 @@  discard block
 block discarded – undo
5049 5049
  * @return array|mixed|string
5050 5050
  */
5051 5051
 function filtre_print_dist($u, $join = '<br />', $indent = 0) {
5052
-	if (is_string($u)) {
5053
-		$u = typo($u);
5052
+    if (is_string($u)) {
5053
+        $u = typo($u);
5054 5054
 
5055
-		return $u;
5056
-	}
5055
+        return $u;
5056
+    }
5057 5057
 
5058
-	// caster $u en array si besoin
5059
-	if (is_object($u)) {
5060
-		$u = (array)$u;
5061
-	}
5058
+    // caster $u en array si besoin
5059
+    if (is_object($u)) {
5060
+        $u = (array)$u;
5061
+    }
5062 5062
 
5063
-	if (is_array($u)) {
5064
-		$out = '';
5065
-		// toutes les cles sont numeriques ?
5066
-		// et aucun enfant n'est un tableau
5067
-		// liste simple separee par des virgules
5068
-		$numeric_keys = array_map('is_numeric', array_keys($u));
5069
-		$array_values = array_map('is_array', $u);
5070
-		$object_values = array_map('is_object', $u);
5071
-		if (
5072
-			array_sum($numeric_keys) == count($numeric_keys)
5073
-			and !array_sum($array_values)
5074
-			and !array_sum($object_values)
5075
-		) {
5076
-			return join(', ', array_map('filtre_print_dist', $u));
5077
-		}
5063
+    if (is_array($u)) {
5064
+        $out = '';
5065
+        // toutes les cles sont numeriques ?
5066
+        // et aucun enfant n'est un tableau
5067
+        // liste simple separee par des virgules
5068
+        $numeric_keys = array_map('is_numeric', array_keys($u));
5069
+        $array_values = array_map('is_array', $u);
5070
+        $object_values = array_map('is_object', $u);
5071
+        if (
5072
+            array_sum($numeric_keys) == count($numeric_keys)
5073
+            and !array_sum($array_values)
5074
+            and !array_sum($object_values)
5075
+        ) {
5076
+            return join(', ', array_map('filtre_print_dist', $u));
5077
+        }
5078 5078
 
5079
-		// sinon on passe a la ligne et on indente
5080
-		$i_str = str_pad('', $indent, ' ');
5081
-		foreach ($u as $k => $v) {
5082
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
5083
-		}
5079
+        // sinon on passe a la ligne et on indente
5080
+        $i_str = str_pad('', $indent, ' ');
5081
+        foreach ($u as $k => $v) {
5082
+            $out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
5083
+        }
5084 5084
 
5085
-		return $out;
5086
-	}
5085
+        return $out;
5086
+    }
5087 5087
 
5088
-	// on sait pas quoi faire...
5089
-	return $u;
5088
+    // on sait pas quoi faire...
5089
+    return $u;
5090 5090
 }
5091 5091
 
5092 5092
 
@@ -5099,10 +5099,10 @@  discard block
 block discarded – undo
5099 5099
  * @return string|array
5100 5100
  */
5101 5101
 function objet_info($objet, $info) {
5102
-	$table = table_objet_sql($objet);
5103
-	$infos = lister_tables_objets_sql($table);
5102
+    $table = table_objet_sql($objet);
5103
+    $infos = lister_tables_objets_sql($table);
5104 5104
 
5105
-	return ($infos[$info] ?? '');
5105
+    return ($infos[$info] ?? '');
5106 5106
 }
5107 5107
 
5108 5108
 /**
@@ -5117,11 +5117,11 @@  discard block
 block discarded – undo
5117 5117
  *     Texte traduit du comptage, tel que '3 articles'
5118 5118
  */
5119 5119
 function objet_afficher_nb($nb, $objet) {
5120
-	if (!$nb) {
5121
-		return _T(objet_info($objet, 'info_aucun_objet'));
5122
-	} else {
5123
-		return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), ['nb' => $nb]);
5124
-	}
5120
+    if (!$nb) {
5121
+        return _T(objet_info($objet, 'info_aucun_objet'));
5122
+    } else {
5123
+        return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), ['nb' => $nb]);
5124
+    }
5125 5125
 }
5126 5126
 
5127 5127
 /**
@@ -5133,11 +5133,11 @@  discard block
 block discarded – undo
5133 5133
  * @return string
5134 5134
  */
5135 5135
 function objet_icone($objet, $taille = 24, $class = '') {
5136
-	$icone = objet_info($objet, 'icone_objet') . '-' . $taille . '.png';
5137
-	$icone = chemin_image($icone);
5138
-	$balise_img = charger_filtre('balise_img');
5136
+    $icone = objet_info($objet, 'icone_objet') . '-' . $taille . '.png';
5137
+    $icone = chemin_image($icone);
5138
+    $balise_img = charger_filtre('balise_img');
5139 5139
 
5140
-	return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : '';
5140
+    return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : '';
5141 5141
 }
5142 5142
 
5143 5143
 /**
@@ -5158,12 +5158,12 @@  discard block
 block discarded – undo
5158 5158
  * @return string
5159 5159
  */
5160 5160
 function objet_T($objet, $chaine, $args = [], $options = []) {
5161
-	$chaine = explode(':', $chaine);
5162
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, ['force' => false]))) {
5163
-		return $t;
5164
-	}
5165
-	$chaine = implode(':', $chaine);
5166
-	return _T($chaine, $args, $options);
5161
+    $chaine = explode(':', $chaine);
5162
+    if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, ['force' => false]))) {
5163
+        return $t;
5164
+    }
5165
+    $chaine = implode(':', $chaine);
5166
+    return _T($chaine, $args, $options);
5167 5167
 }
5168 5168
 
5169 5169
 /**
@@ -5177,18 +5177,18 @@  discard block
 block discarded – undo
5177 5177
  * @return string      Code HTML
5178 5178
  */
5179 5179
 function insert_head_css_conditionnel($flux) {
5180
-	if (
5181
-		strpos($flux, '<!-- insert_head_css -->') === false
5182
-		and $p = strpos($flux, '<!-- insert_head -->')
5183
-	) {
5184
-		// plutot avant le premier js externe (jquery) pour etre non bloquant
5185
-		if ($p1 = stripos($flux, '<script src=') and $p1 < $p) {
5186
-			$p = $p1;
5187
-		}
5188
-		$flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
5189
-	}
5180
+    if (
5181
+        strpos($flux, '<!-- insert_head_css -->') === false
5182
+        and $p = strpos($flux, '<!-- insert_head -->')
5183
+    ) {
5184
+        // plutot avant le premier js externe (jquery) pour etre non bloquant
5185
+        if ($p1 = stripos($flux, '<script src=') and $p1 < $p) {
5186
+            $p = $p1;
5187
+        }
5188
+        $flux = substr_replace($flux, pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
5189
+    }
5190 5190
 
5191
-	return $flux;
5191
+    return $flux;
5192 5192
 }
5193 5193
 
5194 5194
 /**
@@ -5211,75 +5211,75 @@  discard block
 block discarded – undo
5211 5211
  * @return string
5212 5212
  */
5213 5213
 function produire_fond_statique($fond, $contexte = [], $options = [], string $connect = '') {
5214
-	if (isset($contexte['format'])) {
5215
-		$extension = $contexte['format'];
5216
-		unset($contexte['format']);
5217
-	} else {
5218
-		$extension = 'html';
5219
-		if (preg_match(',[.](css|js|json|xml|svg)$,', $fond, $m)) {
5220
-			$extension = $m[1];
5221
-		}
5222
-	}
5223
-	// recuperer le contenu produit par le squelette
5224
-	$options['raw'] = true;
5225
-	$cache = recuperer_fond($fond, $contexte, $options, $connect);
5226
-
5227
-	// calculer le nom de la css
5228
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
5229
-	$nom_safe = preg_replace(',\W,', '_', str_replace('.', '_', $fond));
5230
-	$contexte_implicite = calculer_contexte_implicite();
5231
-
5232
-	// par defaut on hash selon les contextes qui sont a priori moins variables
5233
-	// mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
5234
-	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
5235
-	if (isset($options['hash_on_content']) and $options['hash_on_content']) {
5236
-		$hash = md5($contexte_implicite['host'] . '::' . $cache);
5237
-	}
5238
-	else {
5239
-		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
5240
-		ksort($contexte);
5241
-		$hash = md5($fond . json_encode($contexte_implicite, JSON_THROW_ON_ERROR) . json_encode($contexte, JSON_THROW_ON_ERROR) . $connect);
5242
-	}
5243
-	$filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
5244
-
5245
-	// mettre a jour le fichier si il n'existe pas
5246
-	// ou trop ancien
5247
-	// le dernier fichier produit est toujours suffixe par .last
5248
-	// et recopie sur le fichier cible uniquement si il change
5249
-	if (
5250
-		!file_exists($filename)
5251
-		or !file_exists($filename . '.last')
5252
-		or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . '.last') < $cache['lastmodified'])
5253
-		or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
5254
-	) {
5255
-		$contenu = $cache['texte'];
5256
-		// passer les urls en absolu si c'est une css
5257
-		if ($extension == 'css') {
5258
-			$contenu = urls_absolues_css(
5259
-				$contenu,
5260
-				test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond)
5261
-			);
5262
-		}
5263
-
5264
-		$comment = '';
5265
-		// ne pas insérer de commentaire sur certains formats
5266
-		if (!in_array($extension, ['json', 'xml', 'svg'])) {
5267
-			$comment = "/* #PRODUIRE{fond=$fond";
5268
-			foreach ($contexte as $k => $v) {
5269
-				if (is_array($v)) {
5270
-					$v = var_export($v, true);
5271
-				}
5272
-				$comment .= ",$k=$v";
5273
-			}
5274
-			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
5275
-			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
5276
-			$comment .= "}\n   md5:" . md5($contenu) . " */\n";
5277
-		}
5278
-		// et ecrire le fichier si il change
5279
-		ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
5280
-	}
5281
-
5282
-	return timestamp($filename);
5214
+    if (isset($contexte['format'])) {
5215
+        $extension = $contexte['format'];
5216
+        unset($contexte['format']);
5217
+    } else {
5218
+        $extension = 'html';
5219
+        if (preg_match(',[.](css|js|json|xml|svg)$,', $fond, $m)) {
5220
+            $extension = $m[1];
5221
+        }
5222
+    }
5223
+    // recuperer le contenu produit par le squelette
5224
+    $options['raw'] = true;
5225
+    $cache = recuperer_fond($fond, $contexte, $options, $connect);
5226
+
5227
+    // calculer le nom de la css
5228
+    $dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
5229
+    $nom_safe = preg_replace(',\W,', '_', str_replace('.', '_', $fond));
5230
+    $contexte_implicite = calculer_contexte_implicite();
5231
+
5232
+    // par defaut on hash selon les contextes qui sont a priori moins variables
5233
+    // mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
5234
+    // reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
5235
+    if (isset($options['hash_on_content']) and $options['hash_on_content']) {
5236
+        $hash = md5($contexte_implicite['host'] . '::' . $cache);
5237
+    }
5238
+    else {
5239
+        unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
5240
+        ksort($contexte);
5241
+        $hash = md5($fond . json_encode($contexte_implicite, JSON_THROW_ON_ERROR) . json_encode($contexte, JSON_THROW_ON_ERROR) . $connect);
5242
+    }
5243
+    $filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
5244
+
5245
+    // mettre a jour le fichier si il n'existe pas
5246
+    // ou trop ancien
5247
+    // le dernier fichier produit est toujours suffixe par .last
5248
+    // et recopie sur le fichier cible uniquement si il change
5249
+    if (
5250
+        !file_exists($filename)
5251
+        or !file_exists($filename . '.last')
5252
+        or (isset($cache['lastmodified']) and $cache['lastmodified'] and filemtime($filename . '.last') < $cache['lastmodified'])
5253
+        or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')
5254
+    ) {
5255
+        $contenu = $cache['texte'];
5256
+        // passer les urls en absolu si c'est une css
5257
+        if ($extension == 'css') {
5258
+            $contenu = urls_absolues_css(
5259
+                $contenu,
5260
+                test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond)
5261
+            );
5262
+        }
5263
+
5264
+        $comment = '';
5265
+        // ne pas insérer de commentaire sur certains formats
5266
+        if (!in_array($extension, ['json', 'xml', 'svg'])) {
5267
+            $comment = "/* #PRODUIRE{fond=$fond";
5268
+            foreach ($contexte as $k => $v) {
5269
+                if (is_array($v)) {
5270
+                    $v = var_export($v, true);
5271
+                }
5272
+                $comment .= ",$k=$v";
5273
+            }
5274
+            // pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
5275
+            // mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
5276
+            $comment .= "}\n   md5:" . md5($contenu) . " */\n";
5277
+        }
5278
+        // et ecrire le fichier si il change
5279
+        ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
5280
+    }
5281
+
5282
+    return timestamp($filename);
5283 5283
 }
5284 5284
 
5285 5285
 /**
@@ -5292,15 +5292,15 @@  discard block
 block discarded – undo
5292 5292
  *    $fichier auquel on a ajouté le timestamp
5293 5293
  */
5294 5294
 function timestamp($fichier) {
5295
-	if (
5296
-		!$fichier
5297
-		or !file_exists($fichier)
5298
-		or !$m = filemtime($fichier)
5299
-	) {
5300
-		return $fichier;
5301
-	}
5295
+    if (
5296
+        !$fichier
5297
+        or !file_exists($fichier)
5298
+        or !$m = filemtime($fichier)
5299
+    ) {
5300
+        return $fichier;
5301
+    }
5302 5302
 
5303
-	return "$fichier?$m";
5303
+    return "$fichier?$m";
5304 5304
 }
5305 5305
 
5306 5306
 /**
@@ -5310,11 +5310,11 @@  discard block
 block discarded – undo
5310 5310
  * @return string
5311 5311
  */
5312 5312
 function supprimer_timestamp($url) {
5313
-	if (strpos($url, '?') === false) {
5314
-		return $url;
5315
-	}
5313
+    if (strpos($url, '?') === false) {
5314
+        return $url;
5315
+    }
5316 5316
 
5317
-	return preg_replace(',\?[[:digit:]]+$,', '', $url);
5317
+    return preg_replace(',\?[[:digit:]]+$,', '', $url);
5318 5318
 }
5319 5319
 
5320 5320
 /**
@@ -5329,15 +5329,15 @@  discard block
 block discarded – undo
5329 5329
  * @return string
5330 5330
  */
5331 5331
 function filtre_nettoyer_titre_email_dist($titre) {
5332
-	include_spip('inc/envoyer_mail');
5332
+    include_spip('inc/envoyer_mail');
5333 5333
 
5334
-	$titre = nettoyer_titre_email($titre);
5335
-	// on est dans un squelette : securiser le retour
5336
-	if (strpos($titre, '<') !== false) {
5337
-		$titre = interdire_scripts($titre);
5338
-	}
5334
+    $titre = nettoyer_titre_email($titre);
5335
+    // on est dans un squelette : securiser le retour
5336
+    if (strpos($titre, '<') !== false) {
5337
+        $titre = interdire_scripts($titre);
5338
+    }
5339 5339
 
5340
-	return $titre;
5340
+    return $titre;
5341 5341
 }
5342 5342
 
5343 5343
 /**
@@ -5359,27 +5359,27 @@  discard block
 block discarded – undo
5359 5359
  * @return string
5360 5360
  */
5361 5361
 function filtre_chercher_rubrique_dist(
5362
-	$titre,
5363
-	$id_objet,
5364
-	$id_parent,
5365
-	$objet,
5366
-	$id_secteur,
5367
-	$restreint,
5368
-	$actionable = false,
5369
-	$retour_sans_cadre = false
5362
+    $titre,
5363
+    $id_objet,
5364
+    $id_parent,
5365
+    $objet,
5366
+    $id_secteur,
5367
+    $restreint,
5368
+    $actionable = false,
5369
+    $retour_sans_cadre = false
5370 5370
 ) {
5371
-	include_spip('inc/filtres_ecrire');
5371
+    include_spip('inc/filtres_ecrire');
5372 5372
 
5373
-	return chercher_rubrique(
5374
-		$titre,
5375
-		$id_objet,
5376
-		$id_parent,
5377
-		$objet,
5378
-		$id_secteur,
5379
-		$restreint,
5380
-		$actionable,
5381
-		$retour_sans_cadre
5382
-	);
5373
+    return chercher_rubrique(
5374
+        $titre,
5375
+        $id_objet,
5376
+        $id_parent,
5377
+        $objet,
5378
+        $id_secteur,
5379
+        $restreint,
5380
+        $actionable,
5381
+        $retour_sans_cadre
5382
+    );
5383 5383
 }
5384 5384
 
5385 5385
 /**
@@ -5408,56 +5408,56 @@  discard block
 block discarded – undo
5408 5408
  *     Chaîne vide si l'accès est autorisé
5409 5409
  */
5410 5410
 function sinon_interdire_acces($ok = false, $url = '', $statut = 0, $message = null) {
5411
-	if ($ok) {
5412
-		return '';
5413
-	}
5414
-
5415
-	// Vider tous les tampons
5416
-	$level = @ob_get_level();
5417
-	while ($level--) {
5418
-		@ob_end_clean();
5419
-	}
5420
-
5421
-	include_spip('inc/headers');
5422
-
5423
-	// S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
5424
-	if ($url) {
5425
-		redirige_par_entete($url, '', $statut);
5426
-	}
5427
-
5428
-	// ecriture simplifiee avec message en 3eme argument (= statut 403)
5429
-	if (!is_numeric($statut) and is_null($message)) {
5430
-		$message = $statut;
5431
-		$statut = 0;
5432
-	}
5433
-	if (!$message) {
5434
-		$message = '';
5435
-	}
5436
-	$statut = intval($statut);
5437
-
5438
-	// Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
5439
-	if (test_espace_prive()) {
5440
-		if (!$statut or !in_array($statut, [404, 403])) {
5441
-			$statut = 403;
5442
-		}
5443
-		http_response_code(403);
5444
-		$echec = charger_fonction('403', 'exec');
5445
-		$echec($message);
5446
-	} else {
5447
-		// Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
5448
-		if (!$statut) {
5449
-			$statut = 404;
5450
-		}
5451
-		// Dans tous les cas on modifie l'entité avec ce qui est demandé
5452
-		http_response_code($statut);
5453
-		// Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
5454
-		if ($statut >= 400) {
5455
-			echo recuperer_fond("$statut", ['erreur' => $message]);
5456
-		}
5457
-	}
5458
-
5459
-
5460
-	exit;
5411
+    if ($ok) {
5412
+        return '';
5413
+    }
5414
+
5415
+    // Vider tous les tampons
5416
+    $level = @ob_get_level();
5417
+    while ($level--) {
5418
+        @ob_end_clean();
5419
+    }
5420
+
5421
+    include_spip('inc/headers');
5422
+
5423
+    // S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
5424
+    if ($url) {
5425
+        redirige_par_entete($url, '', $statut);
5426
+    }
5427
+
5428
+    // ecriture simplifiee avec message en 3eme argument (= statut 403)
5429
+    if (!is_numeric($statut) and is_null($message)) {
5430
+        $message = $statut;
5431
+        $statut = 0;
5432
+    }
5433
+    if (!$message) {
5434
+        $message = '';
5435
+    }
5436
+    $statut = intval($statut);
5437
+
5438
+    // Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
5439
+    if (test_espace_prive()) {
5440
+        if (!$statut or !in_array($statut, [404, 403])) {
5441
+            $statut = 403;
5442
+        }
5443
+        http_response_code(403);
5444
+        $echec = charger_fonction('403', 'exec');
5445
+        $echec($message);
5446
+    } else {
5447
+        // Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
5448
+        if (!$statut) {
5449
+            $statut = 404;
5450
+        }
5451
+        // Dans tous les cas on modifie l'entité avec ce qui est demandé
5452
+        http_response_code($statut);
5453
+        // Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
5454
+        if ($statut >= 400) {
5455
+            echo recuperer_fond("$statut", ['erreur' => $message]);
5456
+        }
5457
+    }
5458
+
5459
+
5460
+    exit;
5461 5461
 }
5462 5462
 
5463 5463
 /**
@@ -5468,11 +5468,11 @@  discard block
 block discarded – undo
5468 5468
  * @return string
5469 5469
  */
5470 5470
 function filtre_compacte_dist($source, $format = null) {
5471
-	if (function_exists('minifier')) {
5472
-		return minifier($source, $format);
5473
-	}
5471
+    if (function_exists('minifier')) {
5472
+        return minifier($source, $format);
5473
+    }
5474 5474
 
5475
-	return $source;
5475
+    return $source;
5476 5476
 }
5477 5477
 
5478 5478
 
@@ -5484,32 +5484,32 @@  discard block
 block discarded – undo
5484 5484
  * @return string
5485 5485
  */
5486 5486
 function spip_affiche_mot_de_passe_masque(?string $passe, bool $afficher_partiellement = false, ?int $portion_pourcent = null): string {
5487
-	$passe ??= '';
5488
-	$l = strlen($passe);
5489
-
5490
-	if ($l <= 8 or !$afficher_partiellement) {
5491
-		if (!$l) {
5492
-			return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
5493
-		}
5494
-		return str_pad('', $afficher_partiellement ? $l : 16, '*');
5495
-	}
5496
-
5497
-	if (is_null($portion_pourcent)) {
5498
-		if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) {
5499
-			define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20%
5500
-		}
5501
-		$portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT;
5502
-	}
5503
-	if ($portion_pourcent >= 100) {
5504
-		return $passe;
5505
-	}
5506
-	$e = intval(ceil($l * $portion_pourcent / 100 / 2));
5507
-	$e = max($e, 0);
5508
-	$mid = str_pad('', $l - 2 * $e, '*');
5509
-	if ($e > 0 and strlen($mid) > 8) {
5510
-		$mid = '***...***';
5511
-	}
5512
-	return substr($passe, 0, $e) . $mid . ($e > 0 ? substr($passe, -$e) : '');
5487
+    $passe ??= '';
5488
+    $l = strlen($passe);
5489
+
5490
+    if ($l <= 8 or !$afficher_partiellement) {
5491
+        if (!$l) {
5492
+            return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
5493
+        }
5494
+        return str_pad('', $afficher_partiellement ? $l : 16, '*');
5495
+    }
5496
+
5497
+    if (is_null($portion_pourcent)) {
5498
+        if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) {
5499
+            define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20%
5500
+        }
5501
+        $portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT;
5502
+    }
5503
+    if ($portion_pourcent >= 100) {
5504
+        return $passe;
5505
+    }
5506
+    $e = intval(ceil($l * $portion_pourcent / 100 / 2));
5507
+    $e = max($e, 0);
5508
+    $mid = str_pad('', $l - 2 * $e, '*');
5509
+    if ($e > 0 and strlen($mid) > 8) {
5510
+        $mid = '***...***';
5511
+    }
5512
+    return substr($passe, 0, $e) . $mid . ($e > 0 ? substr($passe, -$e) : '');
5513 5513
 }
5514 5514
 
5515 5515
 
@@ -5530,64 +5530,64 @@  discard block
 block discarded – undo
5530 5530
  */
5531 5531
 function identifiant_slug($texte, $type = '', $options = []) {
5532 5532
 
5533
-	$original = $texte;
5534
-	$separateur = ($options['separateur'] ?? '_');
5535
-	$longueur_maxi = ($options['longueur_maxi'] ?? 60);
5536
-	$longueur_mini = ($options['longueur_mini'] ?? 0);
5533
+    $original = $texte;
5534
+    $separateur = ($options['separateur'] ?? '_');
5535
+    $longueur_maxi = ($options['longueur_maxi'] ?? 60);
5536
+    $longueur_mini = ($options['longueur_mini'] ?? 0);
5537 5537
 
5538
-	if (!function_exists('translitteration')) {
5539
-		include_spip('inc/charsets');
5540
-	}
5538
+    if (!function_exists('translitteration')) {
5539
+        include_spip('inc/charsets');
5540
+    }
5541 5541
 
5542
-	// pas de balise html
5543
-	if (strpos($texte, '<') !== false) {
5544
-		$texte = strip_tags($texte);
5545
-	}
5546
-	if (strpos($texte, '&') !== false) {
5547
-		$texte = unicode2charset($texte);
5548
-	}
5549
-	// On enlève les espaces indésirables
5550
-	$texte = trim($texte);
5542
+    // pas de balise html
5543
+    if (strpos($texte, '<') !== false) {
5544
+        $texte = strip_tags($texte);
5545
+    }
5546
+    if (strpos($texte, '&') !== false) {
5547
+        $texte = unicode2charset($texte);
5548
+    }
5549
+    // On enlève les espaces indésirables
5550
+    $texte = trim($texte);
5551 5551
 
5552
-	// On enlève les accents et cie
5553
-	$texte = translitteration($texte);
5552
+    // On enlève les accents et cie
5553
+    $texte = translitteration($texte);
5554 5554
 
5555
-	// On remplace tout ce qui n'est pas un mot par un séparateur
5556
-	$texte = preg_replace(',[\W_]+,ms', $separateur, $texte);
5555
+    // On remplace tout ce qui n'est pas un mot par un séparateur
5556
+    $texte = preg_replace(',[\W_]+,ms', $separateur, $texte);
5557 5557
 
5558
-	// nettoyer les doubles occurences du separateur si besoin
5559
-	while (strpos($texte, (string) "$separateur$separateur") !== false) {
5560
-		$texte = str_replace("$separateur$separateur", $separateur, $texte);
5561
-	}
5558
+    // nettoyer les doubles occurences du separateur si besoin
5559
+    while (strpos($texte, (string) "$separateur$separateur") !== false) {
5560
+        $texte = str_replace("$separateur$separateur", $separateur, $texte);
5561
+    }
5562 5562
 
5563
-	// pas de separateur au debut ni a la fin
5564
-	$texte = trim($texte, $separateur);
5563
+    // pas de separateur au debut ni a la fin
5564
+    $texte = trim($texte, $separateur);
5565 5565
 
5566
-	// en minuscules
5567
-	$texte = strtolower($texte);
5566
+    // en minuscules
5567
+    $texte = strtolower($texte);
5568 5568
 
5569
-	switch ($type) {
5570
-		case 'class':
5571
-		case 'id':
5572
-		case 'anchor':
5573
-			if (preg_match(',^\d,', $texte)) {
5574
-				$texte = substr($type, 0, 1) . $texte;
5575
-			}
5576
-	}
5569
+    switch ($type) {
5570
+        case 'class':
5571
+        case 'id':
5572
+        case 'anchor':
5573
+            if (preg_match(',^\d,', $texte)) {
5574
+                $texte = substr($type, 0, 1) . $texte;
5575
+            }
5576
+    }
5577 5577
 
5578
-	if (strlen($texte) > $longueur_maxi) {
5579
-		$texte = substr($texte, 0, $longueur_maxi);
5580
-	}
5578
+    if (strlen($texte) > $longueur_maxi) {
5579
+        $texte = substr($texte, 0, $longueur_maxi);
5580
+    }
5581 5581
 
5582
-	if (strlen($texte) < $longueur_mini and $longueur_mini < $longueur_maxi) {
5583
-		if (preg_match(',^\d,', $texte)) {
5584
-			$texte = ($type ? substr($type, 0, 1) : 's') . $texte;
5585
-		}
5586
-		$texte .= $separateur . md5($original);
5587
-		$texte = substr($texte, 0, $longueur_mini);
5588
-	}
5582
+    if (strlen($texte) < $longueur_mini and $longueur_mini < $longueur_maxi) {
5583
+        if (preg_match(',^\d,', $texte)) {
5584
+            $texte = ($type ? substr($type, 0, 1) : 's') . $texte;
5585
+        }
5586
+        $texte .= $separateur . md5($original);
5587
+        $texte = substr($texte, 0, $longueur_mini);
5588
+    }
5589 5589
 
5590
-	return $texte;
5590
+    return $texte;
5591 5591
 }
5592 5592
 
5593 5593
 
@@ -5608,11 +5608,11 @@  discard block
 block discarded – undo
5608 5608
  * @exemple `<:info_maximum|label_nettoyer:>`
5609 5609
  */
5610 5610
 function label_nettoyer(string $text, bool $ucfirst = true): string {
5611
-	$label = preg_replace('#([\s:]|\&nbsp;)+$#u', '', $text);
5612
-	if ($ucfirst) {
5613
-		$label = spip_ucfirst($label);
5614
-	}
5615
-	return $label;
5611
+    $label = preg_replace('#([\s:]|\&nbsp;)+$#u', '', $text);
5612
+    if ($ucfirst) {
5613
+        $label = spip_ucfirst($label);
5614
+    }
5615
+    return $label;
5616 5616
 }
5617 5617
 
5618 5618
 /**
@@ -5625,8 +5625,8 @@  discard block
 block discarded – undo
5625 5625
  * @exemple `<:info_maximum|label_ponctuer:>`
5626 5626
  */
5627 5627
 function label_ponctuer(string $text, bool $ucfirst = true): string {
5628
-	$label = label_nettoyer($text, $ucfirst);
5629
-	return _T('label_ponctuer', ['label' => $label]);
5628
+    $label = label_nettoyer($text, $ucfirst);
5629
+    return _T('label_ponctuer', ['label' => $label]);
5630 5630
 }
5631 5631
 
5632 5632
 
@@ -5639,19 +5639,19 @@  discard block
 block discarded – undo
5639 5639
  * @return array
5640 5640
  */
5641 5641
 function helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, $fonction) {
5642
-	if (!in_array($fonction, ['objet_lister_parents', 'objet_lister_enfants', 'objet_lister_parents_par_type', 'objet_lister_enfants_par_type'])) {
5643
-		return [];
5644
-	}
5642
+    if (!in_array($fonction, ['objet_lister_parents', 'objet_lister_enfants', 'objet_lister_parents_par_type', 'objet_lister_enfants_par_type'])) {
5643
+        return [];
5644
+    }
5645 5645
 
5646
-	// compatibilite signature inversee
5647
-	if (is_numeric($objet) and !is_numeric($id_objet)) {
5648
-		[$objet, $id_objet] = [$id_objet, $objet];
5649
-	}
5646
+    // compatibilite signature inversee
5647
+    if (is_numeric($objet) and !is_numeric($id_objet)) {
5648
+        [$objet, $id_objet] = [$id_objet, $objet];
5649
+    }
5650 5650
 
5651
-	if (!function_exists($fonction)) {
5652
-		include_spip('base/objets');
5653
-	}
5654
-	return $fonction($objet, $id_objet);
5651
+    if (!function_exists($fonction)) {
5652
+        include_spip('base/objets');
5653
+    }
5654
+    return $fonction($objet, $id_objet);
5655 5655
 }
5656 5656
 
5657 5657
 
@@ -5666,7 +5666,7 @@  discard block
 block discarded – undo
5666 5666
  * @return array
5667 5667
  */
5668 5668
 function filtre_objet_lister_parents_dist($objet, $id_objet) {
5669
-	return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents');
5669
+    return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents');
5670 5670
 }
5671 5671
 
5672 5672
 /**
@@ -5680,7 +5680,7 @@  discard block
 block discarded – undo
5680 5680
  * @return array
5681 5681
  */
5682 5682
 function filtre_objet_lister_parents_par_type_dist($objet, $id_objet) {
5683
-	return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents_par_type');
5683
+    return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents_par_type');
5684 5684
 }
5685 5685
 
5686 5686
 /**
@@ -5694,7 +5694,7 @@  discard block
 block discarded – undo
5694 5694
  * @return array
5695 5695
  */
5696 5696
 function filtre_objet_lister_enfants_dist($objet, $id_objet) {
5697
-	return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants');
5697
+    return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants');
5698 5698
 }
5699 5699
 
5700 5700
 /**
@@ -5708,5 +5708,5 @@  discard block
 block discarded – undo
5708 5708
  * @return array
5709 5709
  */
5710 5710
 function filtre_objet_lister_enfants_par_type_dist($objet, $id_objet) {
5711
-	return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants_par_type');
5711
+    return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants_par_type');
5712 5712
 }
Please login to merge, or discard this patch.