Completed
Push — master ( 09834f...75dce3 )
by cam
02:05
created
ecrire/inc/autoriser.php 3 patches
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -267,8 +267,7 @@  discard block
 block discarded – undo
267 267
 		if ($id === '*') {
268 268
 			unset($GLOBALS['autoriser_exception'][$faire][$type]);
269 269
 			unset($autorisation[$faire][$type]);
270
-		}
271
-		else {
270
+		} else {
272 271
 			unset($GLOBALS['autoriser_exception'][$faire][$type][$id]);
273 272
 			unset($autorisation[$faire][$type][$id]);
274 273
 		}
@@ -635,8 +634,7 @@  discard block
 block discarded – undo
635 634
 function autoriser_rubrique_creer_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
636 635
 	if (!empty($opt['id_parent'])) {
637 636
 		return autoriser('creerrubriquedans', 'rubrique', $opt['id_parent'], $qui);
638
-	}
639
-	else {
637
+	} else {
640 638
 		return autoriser('defaut', null, 0, $qui, $opt);
641 639
 	}
642 640
 }
@@ -791,8 +789,7 @@  discard block
 block discarded – undo
791 789
 	if (!empty($opt['id_parent'])) {
792 790
 		// creerarticledans rappelle autoriser(creer,article) sans id, donc on verifiera condition du else aussi
793 791
 		return autoriser('creerarticledans', 'rubrique', $opt['id_parent'], $qui);
794
-	}
795
-	else {
792
+	} else {
796 793
 		return (sql_countsel('spip_rubriques') > 0 && in_array($qui['statut'], ['0minirezo', '1comite']));
797 794
 	}
798 795
 }
Please login to merge, or discard this patch.
Indentation   +626 added lines, -626 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
  * @package SPIP\Core\Autorisations
16 16
  **/
17 17
 if (!defined('_ECRIRE_INC_VERSION')) {
18
-	return;
18
+    return;
19 19
 }
20 20
 
21 21
 include_spip('base/abstract_sql');
@@ -37,89 +37,89 @@  discard block
 block discarded – undo
37 37
 
38 38
 
39 39
 if (!function_exists('autoriser')) {
40
-	/**
41
-	 * Autoriser une action
42
-	 *
43
-	 * Teste si une personne (par défaut le visiteur en cours) peut effectuer
44
-	 * une certaine action. Cette fonction est le point d'entrée de toutes
45
-	 * les autorisations.
46
-	 *
47
-	 * La fonction se charge d'appeler des fonctions d'autorisations spécifiques
48
-	 * aux actions demandées si elles existent. Elle cherche donc les fonctions
49
-	 * dans cet ordre :
50
-	 *
51
-	 * - autoriser_{type}_{faire}, sinon avec _dist
52
-	 * - autoriser_{type}, sinon avec _dist
53
-	 * - autoriser_{faire}, sinon avec _dist
54
-	 * - autoriser_{defaut}, sinon avec _dist
55
-	 *
56
-	 * Seul le premier argument est obligatoire.
57
-	 *
58
-	 * @note
59
-	 *     Le paramètre `$type` attend par défaut un type d'objet éditorial, et à ce titre,
60
-	 *     la valeur transmise se verra appliquer la fonction 'objet_type' pour uniformiser
61
-	 *     cette valeur.
62
-	 *
63
-	 *     Si ce paramètre n'a rien n'a voir avec un objet éditorial, par exemple
64
-	 *     'statistiques', un souligné avant le terme est ajouté afin d'indiquer
65
-	 *     explicitement à la fonction autoriser de ne pas transformer la chaîne en type
66
-	 *     d'objet. Cela donne pour cet exemple : `autoriser('detruire', '_statistiques')`
67
-	 *
68
-	 * @note
69
-	 *     Le paramètre `$type`, en plus de l'uniformisation en type d'objet, se voit retirer
70
-	 *     tous les soulignés du terme. Ainsi le type d'objet `livre_art` deviendra `livreart`
71
-	 *     et SPIP cherchera une fonction `autoriser_livreart_{faire}`. Ceci permet
72
-	 *     d'éviter une possible confusion si une fonction `autoriser_livre_art` existait :
73
-	 *     quel serait le type, quel serait l'action ?
74
-	 *
75
-	 *     Pour résumer, si le type d'objet éditorial a un souligné, tel que 'livre_art',
76
-	 *     la fonction d'autorisation correspondante ne l'aura pas.
77
-	 *     Exemple : `function autoriser_livreart_modifier_dist(...){...}`
78
-	 *
79
-	 * @api
80
-	 * @see autoriser_dist()
81
-	 * @see objet_type()
82
-	 *
83
-	 * @param string $faire
84
-	 *   une action ('modifier', 'publier'...)
85
-	 * @param string|null $type
86
-	 *   Type d’objet ou élément sur lequel appliquer l’action.
87
-	 *   - null: indifférent à tout type d’élément ou objet éditorial
88
-	 *   - string: objet éditorial (objet_type() est appliqué pour homogénéiser l’entrée)
89
-	 *   - _string: autre élément (avec un souligné en premier caractère, désactive objet_type()).
90
-	 *   Les soulignés seront retirés (cf. la note).
91
-	 * @param string|int|null $id
92
-	 *   id de l'objet ou élément sur lequel on veut agir, si pertinent.
93
-	 *   - null: non utile pour l’autorisation
94
-	 *   - int: identifiant numérique (cas de tous les objets éditoriaux de SPIP)
95
-	 *   - string: identifiant textuel
96
-	 * @param null|int|array $qui
97
-	 *   - si null on prend alors visiteur_session
98
-	 *   - un id_auteur (on regarde dans la base)
99
-	 *   - un tableau auteur complet, y compris [restreint]
100
-	 * @param array $opt
101
-	 *   options sous forme de tableau associatif
102
-	 * @return bool
103
-	 *   true si la personne peut effectuer l'action
104
-	 */
105
-	function autoriser(string $faire, ?string $type = '', $id = null, $qui = null, array $opt = []): bool {
106
-		// Charger les fonctions d'autorisation supplementaires
107
-		static $pipe;
108
-		if (!isset($pipe)) {
109
-			$pipe = 1;
110
-			pipeline('autoriser');
111
-		}
112
-
113
-		return autoriser_dist($faire, $type, $id, $qui, $opt);
114
-	}
40
+    /**
41
+     * Autoriser une action
42
+     *
43
+     * Teste si une personne (par défaut le visiteur en cours) peut effectuer
44
+     * une certaine action. Cette fonction est le point d'entrée de toutes
45
+     * les autorisations.
46
+     *
47
+     * La fonction se charge d'appeler des fonctions d'autorisations spécifiques
48
+     * aux actions demandées si elles existent. Elle cherche donc les fonctions
49
+     * dans cet ordre :
50
+     *
51
+     * - autoriser_{type}_{faire}, sinon avec _dist
52
+     * - autoriser_{type}, sinon avec _dist
53
+     * - autoriser_{faire}, sinon avec _dist
54
+     * - autoriser_{defaut}, sinon avec _dist
55
+     *
56
+     * Seul le premier argument est obligatoire.
57
+     *
58
+     * @note
59
+     *     Le paramètre `$type` attend par défaut un type d'objet éditorial, et à ce titre,
60
+     *     la valeur transmise se verra appliquer la fonction 'objet_type' pour uniformiser
61
+     *     cette valeur.
62
+     *
63
+     *     Si ce paramètre n'a rien n'a voir avec un objet éditorial, par exemple
64
+     *     'statistiques', un souligné avant le terme est ajouté afin d'indiquer
65
+     *     explicitement à la fonction autoriser de ne pas transformer la chaîne en type
66
+     *     d'objet. Cela donne pour cet exemple : `autoriser('detruire', '_statistiques')`
67
+     *
68
+     * @note
69
+     *     Le paramètre `$type`, en plus de l'uniformisation en type d'objet, se voit retirer
70
+     *     tous les soulignés du terme. Ainsi le type d'objet `livre_art` deviendra `livreart`
71
+     *     et SPIP cherchera une fonction `autoriser_livreart_{faire}`. Ceci permet
72
+     *     d'éviter une possible confusion si une fonction `autoriser_livre_art` existait :
73
+     *     quel serait le type, quel serait l'action ?
74
+     *
75
+     *     Pour résumer, si le type d'objet éditorial a un souligné, tel que 'livre_art',
76
+     *     la fonction d'autorisation correspondante ne l'aura pas.
77
+     *     Exemple : `function autoriser_livreart_modifier_dist(...){...}`
78
+     *
79
+     * @api
80
+     * @see autoriser_dist()
81
+     * @see objet_type()
82
+     *
83
+     * @param string $faire
84
+     *   une action ('modifier', 'publier'...)
85
+     * @param string|null $type
86
+     *   Type d’objet ou élément sur lequel appliquer l’action.
87
+     *   - null: indifférent à tout type d’élément ou objet éditorial
88
+     *   - string: objet éditorial (objet_type() est appliqué pour homogénéiser l’entrée)
89
+     *   - _string: autre élément (avec un souligné en premier caractère, désactive objet_type()).
90
+     *   Les soulignés seront retirés (cf. la note).
91
+     * @param string|int|null $id
92
+     *   id de l'objet ou élément sur lequel on veut agir, si pertinent.
93
+     *   - null: non utile pour l’autorisation
94
+     *   - int: identifiant numérique (cas de tous les objets éditoriaux de SPIP)
95
+     *   - string: identifiant textuel
96
+     * @param null|int|array $qui
97
+     *   - si null on prend alors visiteur_session
98
+     *   - un id_auteur (on regarde dans la base)
99
+     *   - un tableau auteur complet, y compris [restreint]
100
+     * @param array $opt
101
+     *   options sous forme de tableau associatif
102
+     * @return bool
103
+     *   true si la personne peut effectuer l'action
104
+     */
105
+    function autoriser(string $faire, ?string $type = '', $id = null, $qui = null, array $opt = []): bool {
106
+        // Charger les fonctions d'autorisation supplementaires
107
+        static $pipe;
108
+        if (!isset($pipe)) {
109
+            $pipe = 1;
110
+            pipeline('autoriser');
111
+        }
112
+
113
+        return autoriser_dist($faire, $type, $id, $qui, $opt);
114
+    }
115 115
 }
116 116
 
117 117
 
118 118
 // mes_fonctions peut aussi declarer des autorisations, il faut donc le charger
119 119
 // mais apres la fonction autoriser()
120 120
 if ($f = find_in_path('mes_fonctions.php')) {
121
-	global $dossier_squelettes;
122
-	include_once(_ROOT_CWD . $f);
121
+    global $dossier_squelettes;
122
+    include_once(_ROOT_CWD . $f);
123 123
 }
124 124
 
125 125
 
@@ -150,83 +150,83 @@  discard block
 block discarded – undo
150 150
  */
151 151
 function autoriser_dist(string $faire, ?string $type = '', $id = null, $qui = null, array $opt = []): bool {
152 152
 
153
-	if ($type === null) {
154
-		$type = '';
155
-	}
156
-
157
-	// Qui ? visiteur_session ?
158
-	// si null ou '' (appel depuis #AUTORISER) on prend l'auteur loge
159
-	if ($qui === null || $qui === '') {
160
-		$qui = $GLOBALS['visiteur_session'] ?: [];
161
-		$qui = array_merge(['statut' => '', 'id_auteur' => 0, 'webmestre' => 'non'], $qui);
162
-	} elseif (is_numeric($qui)) {
163
-		$qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . $qui);
164
-		if (!$qui) {
165
-			return false;
166
-		}
167
-	}
168
-
169
-	// Admins restreints, on construit ici (pas generique mais...)
170
-	// le tableau de toutes leurs rubriques (y compris les sous-rubriques)
171
-	if (_ADMINS_RESTREINTS && is_array($qui)) {
172
-		$qui['restreint'] = isset($qui['id_auteur']) ? liste_rubriques_auteur($qui['id_auteur']) : [];
173
-	}
174
-
175
-	$logger = spip_logger('autoriser');
176
-	$logger->debug(
177
-		"autoriser $faire $type $id (" . ($qui['nom'] ?? '') . ') ?',
178
-	);
179
-
180
-	$type = autoriser_type($type);
181
-
182
-	// Si une exception a ete decretee plus haut dans le code, l'appliquer
183
-	if (
184
-		isset($GLOBALS['autoriser_exception'][$faire][$type][$id])
185
-		&& autoriser_exception($faire, $type, $id, 'verifier') || isset($GLOBALS['autoriser_exception'][$faire][$type]['*']) && autoriser_exception($faire, $type, '*', 'verifier')
186
-	) {
187
-		$logger->debug("autoriser ($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : OK Exception');
188
-		return true;
189
-	}
190
-
191
-	// Chercher une fonction d'autorisation
192
-	// Dans l'ordre on va chercher autoriser_type_faire[_dist], autoriser_type[_dist],
193
-	// autoriser_faire[_dist], autoriser_defaut[_dist]
194
-	$fonctions = $type
195
-		? [
196
-			'autoriser_' . $type . '_' . $faire,
197
-			'autoriser_' . $type . '_' . $faire . '_dist',
198
-			'autoriser_' . $type,
199
-			'autoriser_' . $type . '_dist',
200
-			'autoriser_' . $faire,
201
-			'autoriser_' . $faire . '_dist',
202
-			'autoriser_defaut',
203
-			'autoriser_defaut_dist'
204
-		]
205
-		: [
206
-			'autoriser_' . $faire,
207
-			'autoriser_' . $faire . '_dist',
208
-			'autoriser_defaut',
209
-			'autoriser_defaut_dist'
210
-		];
211
-
212
-	$a = false;
213
-	foreach ($fonctions as $f) {
214
-		if (function_exists($f)) {
215
-			$a = $f($faire, $type, $id, $qui, $opt);
216
-			break;
217
-		}
218
-	}
219
-
220
-	$logger->debug(
221
-		"$f($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : ' . ($a ? 'OK' : 'niet'),
222
-	);
223
-
224
-	if (!is_bool($a)) {
225
-		 trigger_error(sprintf('Function %s should returns a boolean instead of %s (casts as boolean). This will trigger fatal error in future versions.', $f, gettype($a)), \E_USER_DEPRECATED);
226
-		 $a = (bool) $a;
227
-	}
228
-
229
-	return $a;
153
+    if ($type === null) {
154
+        $type = '';
155
+    }
156
+
157
+    // Qui ? visiteur_session ?
158
+    // si null ou '' (appel depuis #AUTORISER) on prend l'auteur loge
159
+    if ($qui === null || $qui === '') {
160
+        $qui = $GLOBALS['visiteur_session'] ?: [];
161
+        $qui = array_merge(['statut' => '', 'id_auteur' => 0, 'webmestre' => 'non'], $qui);
162
+    } elseif (is_numeric($qui)) {
163
+        $qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . $qui);
164
+        if (!$qui) {
165
+            return false;
166
+        }
167
+    }
168
+
169
+    // Admins restreints, on construit ici (pas generique mais...)
170
+    // le tableau de toutes leurs rubriques (y compris les sous-rubriques)
171
+    if (_ADMINS_RESTREINTS && is_array($qui)) {
172
+        $qui['restreint'] = isset($qui['id_auteur']) ? liste_rubriques_auteur($qui['id_auteur']) : [];
173
+    }
174
+
175
+    $logger = spip_logger('autoriser');
176
+    $logger->debug(
177
+        "autoriser $faire $type $id (" . ($qui['nom'] ?? '') . ') ?',
178
+    );
179
+
180
+    $type = autoriser_type($type);
181
+
182
+    // Si une exception a ete decretee plus haut dans le code, l'appliquer
183
+    if (
184
+        isset($GLOBALS['autoriser_exception'][$faire][$type][$id])
185
+        && autoriser_exception($faire, $type, $id, 'verifier') || isset($GLOBALS['autoriser_exception'][$faire][$type]['*']) && autoriser_exception($faire, $type, '*', 'verifier')
186
+    ) {
187
+        $logger->debug("autoriser ($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : OK Exception');
188
+        return true;
189
+    }
190
+
191
+    // Chercher une fonction d'autorisation
192
+    // Dans l'ordre on va chercher autoriser_type_faire[_dist], autoriser_type[_dist],
193
+    // autoriser_faire[_dist], autoriser_defaut[_dist]
194
+    $fonctions = $type
195
+        ? [
196
+            'autoriser_' . $type . '_' . $faire,
197
+            'autoriser_' . $type . '_' . $faire . '_dist',
198
+            'autoriser_' . $type,
199
+            'autoriser_' . $type . '_dist',
200
+            'autoriser_' . $faire,
201
+            'autoriser_' . $faire . '_dist',
202
+            'autoriser_defaut',
203
+            'autoriser_defaut_dist'
204
+        ]
205
+        : [
206
+            'autoriser_' . $faire,
207
+            'autoriser_' . $faire . '_dist',
208
+            'autoriser_defaut',
209
+            'autoriser_defaut_dist'
210
+        ];
211
+
212
+    $a = false;
213
+    foreach ($fonctions as $f) {
214
+        if (function_exists($f)) {
215
+            $a = $f($faire, $type, $id, $qui, $opt);
216
+            break;
217
+        }
218
+    }
219
+
220
+    $logger->debug(
221
+        "$f($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : ' . ($a ? 'OK' : 'niet'),
222
+    );
223
+
224
+    if (!is_bool($a)) {
225
+            trigger_error(sprintf('Function %s should returns a boolean instead of %s (casts as boolean). This will trigger fatal error in future versions.', $f, gettype($a)), \E_USER_DEPRECATED);
226
+            $a = (bool) $a;
227
+    }
228
+
229
+    return $a;
230 230
 }
231 231
 
232 232
 // une globale pour aller au plus vite dans la fonction generique ci dessus
@@ -246,31 +246,31 @@  discard block
 block discarded – undo
246 246
  * @return bool
247 247
  */
248 248
 function autoriser_exception(string $faire, ?string $type = '', $id = null, $autoriser = true): bool {
249
-	// une static innaccessible par url pour verifier que la globale est positionnee a bon escient
250
-	static $autorisation;
251
-	// Tolérance avec certains appels
252
-	if ($id === null) {
253
-		$id = 0;
254
-	}
255
-	$type = autoriser_type($type);
256
-	if ($autoriser === 'verifier') {
257
-		return isset($autorisation[$faire][$type][$id]);
258
-	}
259
-	if ($autoriser === true) {
260
-		$GLOBALS['autoriser_exception'][$faire][$type][$id] = $autorisation[$faire][$type][$id] = true;
261
-	}
262
-	if ($autoriser === false) {
263
-		if ($id === '*') {
264
-			unset($GLOBALS['autoriser_exception'][$faire][$type]);
265
-			unset($autorisation[$faire][$type]);
266
-		}
267
-		else {
268
-			unset($GLOBALS['autoriser_exception'][$faire][$type][$id]);
269
-			unset($autorisation[$faire][$type][$id]);
270
-		}
271
-	}
272
-
273
-	return false;
249
+    // une static innaccessible par url pour verifier que la globale est positionnee a bon escient
250
+    static $autorisation;
251
+    // Tolérance avec certains appels
252
+    if ($id === null) {
253
+        $id = 0;
254
+    }
255
+    $type = autoriser_type($type);
256
+    if ($autoriser === 'verifier') {
257
+        return isset($autorisation[$faire][$type][$id]);
258
+    }
259
+    if ($autoriser === true) {
260
+        $GLOBALS['autoriser_exception'][$faire][$type][$id] = $autorisation[$faire][$type][$id] = true;
261
+    }
262
+    if ($autoriser === false) {
263
+        if ($id === '*') {
264
+            unset($GLOBALS['autoriser_exception'][$faire][$type]);
265
+            unset($autorisation[$faire][$type]);
266
+        }
267
+        else {
268
+            unset($GLOBALS['autoriser_exception'][$faire][$type][$id]);
269
+            unset($autorisation[$faire][$type][$id]);
270
+        }
271
+    }
272
+
273
+    return false;
274 274
 }
275 275
 
276 276
 /**
@@ -283,13 +283,13 @@  discard block
 block discarded – undo
283 283
  * - Les _ sont supprimés
284 284
  */
285 285
 function autoriser_type(?string $type = ''): string {
286
-	// passer par objet_type pour avoir les alias
287
-	// sauf si _ est le premier caractère.
288
-	if ($type && $type[0] !== '_') {
289
-		$type = objet_type($type, false);
290
-	}
291
-	// et supprimer les _
292
-	return str_replace('_', '', (string) $type);
286
+    // passer par objet_type pour avoir les alias
287
+    // sauf si _ est le premier caractère.
288
+    if ($type && $type[0] !== '_') {
289
+        $type = objet_type($type, false);
290
+    }
291
+    // et supprimer les _
292
+    return str_replace('_', '', (string) $type);
293 293
 }
294 294
 
295 295
 
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
  * @return bool true s'il a le droit, false sinon
309 309
  **/
310 310
 function autoriser_defaut_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
311
-	return $qui['statut'] === '0minirezo' && !$qui['restreint'];
311
+    return $qui['statut'] === '0minirezo' && !$qui['restreint'];
312 312
 }
313 313
 
314 314
 /**
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
  * @return bool true s'il a le droit, false sinon
329 329
  */
330 330
 function autoriser_loger_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
331
-	return $qui['statut'] !== '5poubelle';
331
+    return $qui['statut'] !== '5poubelle';
332 332
 }
333 333
 
334 334
 /**
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
  * @return bool true s'il a le droit, false sinon
345 345
  **/
346 346
 function autoriser_ecrire_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
347
-	return isset($qui['statut']) && in_array($qui['statut'], ['0minirezo', '1comite']);
347
+    return isset($qui['statut']) && in_array($qui['statut'], ['0minirezo', '1comite']);
348 348
 }
349 349
 
350 350
 /**
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
  * @return bool true s'il a le droit, false sinon
364 364
  **/
365 365
 function autoriser_creer_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
366
-	return in_array($qui['statut'], ['0minirezo', '1comite']);
366
+    return in_array($qui['statut'], ['0minirezo', '1comite']);
367 367
 }
368 368
 
369 369
 /**
@@ -383,14 +383,14 @@  discard block
 block discarded – undo
383 383
  **/
384 384
 function autoriser_previsualiser_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
385 385
 
386
-	// Le visiteur a-t-il un statut prevu par la config ?
387
-	if (str_contains((string) $GLOBALS['meta']['preview'], ',' . $qui['statut'] . ',')) {
388
-		return test_previsualiser_objet_champ($type, $id, $qui, $opt);
389
-	}
386
+    // Le visiteur a-t-il un statut prevu par la config ?
387
+    if (str_contains((string) $GLOBALS['meta']['preview'], ',' . $qui['statut'] . ',')) {
388
+        return test_previsualiser_objet_champ($type, $id, $qui, $opt);
389
+    }
390 390
 
391
-	// A-t-on un token de prévisualisation valable ?
392
-	include_spip('inc/securiser_action');
393
-	return (bool) decrire_token_previsu();
391
+    // A-t-on un token de prévisualisation valable ?
392
+    include_spip('inc/securiser_action');
393
+    return (bool) decrire_token_previsu();
394 394
 }
395 395
 
396 396
 /**
@@ -419,58 +419,58 @@  discard block
 block discarded – undo
419 419
  */
420 420
 function test_previsualiser_objet_champ(string $type = '', $id = null, array $qui = [], array $opt = []): bool {
421 421
 
422
-	// si pas de type et statut fourni, c'est une autorisation generale => OK
423
-	if (!$type) {
424
-		return true;
425
-	}
426
-
427
-	include_spip('base/objets');
428
-	$infos = lister_tables_objets_sql(table_objet_sql($type));
429
-	if (isset($infos['statut'])) {
430
-		foreach ($infos['statut'] as $c) {
431
-			if (isset($c['publie'])) {
432
-				if (!isset($c['previsu'])) {
433
-					return false;
434
-				} // pas de previsu definie => NIET
435
-				$champ = $c['champ'];
436
-				if (!isset($opt[$champ])) {
437
-					return false;
438
-				} // pas de champ passe a la demande => NIET
439
-				$previsu = explode(',', (string) $c['previsu']);
440
-				// regarder si ce statut est autorise pour l'auteur
441
-				if (in_array($opt[$champ] . '/auteur', $previsu)) {
442
-					// retrouver l’id_auteur qui a filé un lien de prévisu éventuellement,
443
-					// sinon l’auteur en session
444
-					include_spip('inc/securiser_action');
445
-					if ($desc = decrire_token_previsu()) {
446
-						$id_auteur = $desc['id_auteur'];
447
-					} elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) {
448
-						$id_auteur = (int) $GLOBALS['visiteur_session']['id_auteur'];
449
-					} else {
450
-						$id_auteur = null;
451
-					}
452
-
453
-					if (!$id_auteur) {
454
-						return false;
455
-					} elseif (autoriser('previsualiser' . $opt[$champ], $type, 0, $id_auteur)) {
456
-						// dans ce cas (admin en general), pas de filtrage sur ce statut
457
-					} elseif (
458
-						!sql_countsel(
459
-							'spip_auteurs_liens',
460
-							'id_auteur=' . (int) $id_auteur . ' AND objet=' . sql_quote($type) . ' AND id_objet=' . (int) $id
461
-						)
462
-					) {
463
-						return false;
464
-					} // pas auteur de cet objet => NIET
465
-				} elseif (!in_array($opt[$champ], $previsu)) {
466
-					// le statut n'est pas dans ceux definis par la previsu => NIET
467
-					return false;
468
-				}
469
-			}
470
-		}
471
-	}
472
-
473
-	return true;
422
+    // si pas de type et statut fourni, c'est une autorisation generale => OK
423
+    if (!$type) {
424
+        return true;
425
+    }
426
+
427
+    include_spip('base/objets');
428
+    $infos = lister_tables_objets_sql(table_objet_sql($type));
429
+    if (isset($infos['statut'])) {
430
+        foreach ($infos['statut'] as $c) {
431
+            if (isset($c['publie'])) {
432
+                if (!isset($c['previsu'])) {
433
+                    return false;
434
+                } // pas de previsu definie => NIET
435
+                $champ = $c['champ'];
436
+                if (!isset($opt[$champ])) {
437
+                    return false;
438
+                } // pas de champ passe a la demande => NIET
439
+                $previsu = explode(',', (string) $c['previsu']);
440
+                // regarder si ce statut est autorise pour l'auteur
441
+                if (in_array($opt[$champ] . '/auteur', $previsu)) {
442
+                    // retrouver l’id_auteur qui a filé un lien de prévisu éventuellement,
443
+                    // sinon l’auteur en session
444
+                    include_spip('inc/securiser_action');
445
+                    if ($desc = decrire_token_previsu()) {
446
+                        $id_auteur = $desc['id_auteur'];
447
+                    } elseif (isset($GLOBALS['visiteur_session']['id_auteur'])) {
448
+                        $id_auteur = (int) $GLOBALS['visiteur_session']['id_auteur'];
449
+                    } else {
450
+                        $id_auteur = null;
451
+                    }
452
+
453
+                    if (!$id_auteur) {
454
+                        return false;
455
+                    } elseif (autoriser('previsualiser' . $opt[$champ], $type, 0, $id_auteur)) {
456
+                        // dans ce cas (admin en general), pas de filtrage sur ce statut
457
+                    } elseif (
458
+                        !sql_countsel(
459
+                            'spip_auteurs_liens',
460
+                            'id_auteur=' . (int) $id_auteur . ' AND objet=' . sql_quote($type) . ' AND id_objet=' . (int) $id
461
+                        )
462
+                    ) {
463
+                        return false;
464
+                    } // pas auteur de cet objet => NIET
465
+                } elseif (!in_array($opt[$champ], $previsu)) {
466
+                    // le statut n'est pas dans ceux definis par la previsu => NIET
467
+                    return false;
468
+                }
469
+            }
470
+        }
471
+    }
472
+
473
+    return true;
474 474
 }
475 475
 
476 476
 /**
@@ -486,49 +486,49 @@  discard block
 block discarded – undo
486 486
  * @return bool true s'il a le droit, false sinon
487 487
  **/
488 488
 function autoriser_changerlangue_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
489
-	$multi_objets = explode(',', (string) lire_config('multi_objets'));
490
-	$gerer_trad_objets = explode(',', (string) lire_config('gerer_trad_objets'));
491
-	$table = table_objet_sql($type);
492
-	if (
493
-		in_array($table, $multi_objets)
494
-		|| in_array($table, $gerer_trad_objets)
495
-	) { // affichage du formulaire si la configuration l'accepte
496
-		$multi_secteurs = lire_config('multi_secteurs');
497
-		$champs = objet_info($type, 'field');
498
-		if (
499
-			$multi_secteurs === 'oui'
500
-			&& array_key_exists('id_rubrique', $champs)
501
-		) {
502
-			// multilinguisme par secteur et objet rattaché à une rubrique
503
-			$primary = id_table_objet($type);
504
-			$id_rubrique = $table != 'spip_rubriques'
505
-				? sql_getfetsel('id_rubrique', "$table", "$primary=" . (int) $id)
506
-				: $id;
507
-			$id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . (int) $id_rubrique);
508
-			if (!$id_secteur > 0) {
509
-				$id_secteur = $id_rubrique;
510
-			}
511
-			$langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . (int) $id_secteur);
512
-			$langue_objet = sql_getfetsel('lang', "$table", "$primary=" . (int) $id);
513
-			if ($langue_secteur != $langue_objet) {
514
-				// configuration incohérente, on laisse l'utilisateur corriger la situation
515
-				return true;
516
-			}
517
-			if ($table != 'spip_rubriques') { // le choix de la langue se fait seulement sur les rubriques
518
-				return false;
519
-			} else {
520
-				$id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . (int) $id);
521
-				if ($id_parent != 0) {
522
-					// sous-rubriques : pas de choix de langue
523
-					return false;
524
-				}
525
-			}
526
-		}
527
-	} else {
528
-		return false;
529
-	}
530
-
531
-	return autoriser('modifier', $type, $id, $qui, $opt);
489
+    $multi_objets = explode(',', (string) lire_config('multi_objets'));
490
+    $gerer_trad_objets = explode(',', (string) lire_config('gerer_trad_objets'));
491
+    $table = table_objet_sql($type);
492
+    if (
493
+        in_array($table, $multi_objets)
494
+        || in_array($table, $gerer_trad_objets)
495
+    ) { // affichage du formulaire si la configuration l'accepte
496
+        $multi_secteurs = lire_config('multi_secteurs');
497
+        $champs = objet_info($type, 'field');
498
+        if (
499
+            $multi_secteurs === 'oui'
500
+            && array_key_exists('id_rubrique', $champs)
501
+        ) {
502
+            // multilinguisme par secteur et objet rattaché à une rubrique
503
+            $primary = id_table_objet($type);
504
+            $id_rubrique = $table != 'spip_rubriques'
505
+                ? sql_getfetsel('id_rubrique', "$table", "$primary=" . (int) $id)
506
+                : $id;
507
+            $id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . (int) $id_rubrique);
508
+            if (!$id_secteur > 0) {
509
+                $id_secteur = $id_rubrique;
510
+            }
511
+            $langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . (int) $id_secteur);
512
+            $langue_objet = sql_getfetsel('lang', "$table", "$primary=" . (int) $id);
513
+            if ($langue_secteur != $langue_objet) {
514
+                // configuration incohérente, on laisse l'utilisateur corriger la situation
515
+                return true;
516
+            }
517
+            if ($table != 'spip_rubriques') { // le choix de la langue se fait seulement sur les rubriques
518
+                return false;
519
+            } else {
520
+                $id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . (int) $id);
521
+                if ($id_parent != 0) {
522
+                    // sous-rubriques : pas de choix de langue
523
+                    return false;
524
+                }
525
+            }
526
+        }
527
+    } else {
528
+        return false;
529
+    }
530
+
531
+    return autoriser('modifier', $type, $id, $qui, $opt);
532 532
 }
533 533
 
534 534
 /**
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
  * @return bool true s'il a le droit, false sinon
545 545
  **/
546 546
 function autoriser_changertraduction_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
547
-	return autoriser('modifier', $type, $id, $qui, $opt);
547
+    return autoriser('modifier', $type, $id, $qui, $opt);
548 548
 }
549 549
 
550 550
 /**
@@ -560,38 +560,38 @@  discard block
 block discarded – undo
560 560
  * @return bool true s'il a le droit, false sinon
561 561
  **/
562 562
 function autoriser_dater_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
563
-	$table = table_objet($type);
564
-	$trouver_table = charger_fonction('trouver_table', 'base');
565
-	$desc = $trouver_table($table);
566
-	if (!$desc) {
567
-		return false;
568
-	}
569
-
570
-	if (!isset($opt['statut'])) {
571
-		if (isset($desc['field']['statut'])) {
572
-			$statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type) . '=' . (int) $id);
573
-		} else {
574
-			$statut = 'publie';
575
-		} // pas de statut => publie
576
-	} else {
577
-		$statut = $opt['statut'];
578
-	}
579
-
580
-	// Liste des statuts publiés pour cet objet
581
-	// Sinon en dur le statut "publie"
582
-	$statuts_publies = isset($desc['statut'][0]['publie'])
583
-		? explode(',', (string) $desc['statut'][0]['publie'])
584
-		: ['publie'];
585
-
586
-	if (
587
-		in_array($statut, $statuts_publies)
588
-		// Ou cas particulier géré en dur ici pour les articles
589
-		|| $statut === 'prop' && $type === 'article' && $GLOBALS['meta']['post_dates'] === 'non'
590
-	) {
591
-		return autoriser('modifier', $type, $id);
592
-	}
593
-
594
-	return false;
563
+    $table = table_objet($type);
564
+    $trouver_table = charger_fonction('trouver_table', 'base');
565
+    $desc = $trouver_table($table);
566
+    if (!$desc) {
567
+        return false;
568
+    }
569
+
570
+    if (!isset($opt['statut'])) {
571
+        if (isset($desc['field']['statut'])) {
572
+            $statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type) . '=' . (int) $id);
573
+        } else {
574
+            $statut = 'publie';
575
+        } // pas de statut => publie
576
+    } else {
577
+        $statut = $opt['statut'];
578
+    }
579
+
580
+    // Liste des statuts publiés pour cet objet
581
+    // Sinon en dur le statut "publie"
582
+    $statuts_publies = isset($desc['statut'][0]['publie'])
583
+        ? explode(',', (string) $desc['statut'][0]['publie'])
584
+        : ['publie'];
585
+
586
+    if (
587
+        in_array($statut, $statuts_publies)
588
+        // Ou cas particulier géré en dur ici pour les articles
589
+        || $statut === 'prop' && $type === 'article' && $GLOBALS['meta']['post_dates'] === 'non'
590
+    ) {
591
+        return autoriser('modifier', $type, $id);
592
+    }
593
+
594
+    return false;
595 595
 }
596 596
 
597 597
 /**
@@ -610,7 +610,7 @@  discard block
 block discarded – undo
610 610
  * @return bool true s'il a le droit, false sinon
611 611
  **/
612 612
 function autoriser_instituer_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
613
-	return autoriser('modifier', $type, $id, $qui, $opt);
613
+    return autoriser('modifier', $type, $id, $qui, $opt);
614 614
 }
615 615
 
616 616
 /**
@@ -628,9 +628,9 @@  discard block
 block discarded – undo
628 628
  * @return bool true s'il a le droit, false sinon
629 629
  **/
630 630
 function autoriser_rubrique_publierdans_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
631
-	return
632
-		$qui['statut'] === '0minirezo'
633
-		&& (!$qui['restreint'] || !$id || in_array($id, $qui['restreint']));
631
+    return
632
+        $qui['statut'] === '0minirezo'
633
+        && (!$qui['restreint'] || !$id || in_array($id, $qui['restreint']));
634 634
 }
635 635
 
636 636
 /**
@@ -648,12 +648,12 @@  discard block
 block discarded – undo
648 648
  * @return bool true s'il a le droit, false sinon
649 649
  **/
650 650
 function autoriser_rubrique_creer_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
651
-	if (!empty($opt['id_parent'])) {
652
-		return autoriser('creerrubriquedans', 'rubrique', $opt['id_parent'], $qui);
653
-	}
654
-	else {
655
-		return autoriser('defaut', null, 0, $qui, $opt);
656
-	}
651
+    if (!empty($opt['id_parent'])) {
652
+        return autoriser('creerrubriquedans', 'rubrique', $opt['id_parent'], $qui);
653
+    }
654
+    else {
655
+        return autoriser('defaut', null, 0, $qui, $opt);
656
+    }
657 657
 }
658 658
 
659 659
 /**
@@ -671,8 +671,8 @@  discard block
 block discarded – undo
671 671
  * @return bool true s'il a le droit, false sinon
672 672
  **/
673 673
 function autoriser_rubrique_creerrubriquedans_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
674
-	return
675
-		($id || $qui['statut'] === '0minirezo' && !$qui['restreint']) && autoriser('voir', 'rubrique', $id) && autoriser('publierdans', 'rubrique', $id);
674
+    return
675
+        ($id || $qui['statut'] === '0minirezo' && !$qui['restreint']) && autoriser('voir', 'rubrique', $id) && autoriser('publierdans', 'rubrique', $id);
676 676
 }
677 677
 
678 678
 /**
@@ -690,10 +690,10 @@  discard block
 block discarded – undo
690 690
  * @return bool true s'il a le droit, false sinon
691 691
  **/
692 692
 function autoriser_rubrique_creerarticledans_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
693
-	return
694
-		$id
695
-		&& autoriser('voir', 'rubrique', $id)
696
-		&& autoriser('creer', 'article');
693
+    return
694
+        $id
695
+        && autoriser('voir', 'rubrique', $id)
696
+        && autoriser('creer', 'article');
697 697
 }
698 698
 
699 699
 
@@ -712,7 +712,7 @@  discard block
 block discarded – undo
712 712
  * @return bool true s'il a le droit, false sinon
713 713
  **/
714 714
 function autoriser_rubrique_modifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
715
-	return autoriser('publierdans', 'rubrique', $id, $qui, $opt);
715
+    return autoriser('publierdans', 'rubrique', $id, $qui, $opt);
716 716
 }
717 717
 
718 718
 /**
@@ -730,29 +730,29 @@  discard block
 block discarded – undo
730 730
  * @return bool true s'il a le droit, false sinon
731 731
  **/
732 732
 function autoriser_rubrique_supprimer_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
733
-	if (!$id = (int) $id) {
734
-		return false;
735
-	}
733
+    if (!$id = (int) $id) {
734
+        return false;
735
+    }
736 736
 
737
-	if (sql_countsel('spip_rubriques', 'id_parent=' . (int) $id)) {
738
-		return false;
739
-	}
737
+    if (sql_countsel('spip_rubriques', 'id_parent=' . (int) $id)) {
738
+        return false;
739
+    }
740 740
 
741
-	if (sql_countsel('spip_articles', 'id_rubrique=' . (int) $id . " AND (statut<>'poubelle')")) {
742
-		return false;
743
-	}
741
+    if (sql_countsel('spip_articles', 'id_rubrique=' . (int) $id . " AND (statut<>'poubelle')")) {
742
+        return false;
743
+    }
744 744
 
745
-	$compte = pipeline(
746
-		'objet_compte_enfants',
747
-		['args' => ['objet' => 'rubrique', 'id_objet' => $id], 'data' => []]
748
-	);
749
-	foreach ($compte as $objet => $n) {
750
-		if ($n) {
751
-			return false;
752
-		}
753
-	}
745
+    $compte = pipeline(
746
+        'objet_compte_enfants',
747
+        ['args' => ['objet' => 'rubrique', 'id_objet' => $id], 'data' => []]
748
+    );
749
+    foreach ($compte as $objet => $n) {
750
+        if ($n) {
751
+            return false;
752
+        }
753
+    }
754 754
 
755
-	return autoriser('modifier', 'rubrique', $id);
755
+    return autoriser('modifier', 'rubrique', $id);
756 756
 }
757 757
 
758 758
 
@@ -772,20 +772,20 @@  discard block
 block discarded – undo
772 772
  * @return bool true s'il a le droit, false sinon
773 773
  **/
774 774
 function autoriser_article_modifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
775
-	if (!$id) {
776
-		return false;
777
-	}
778
-	$r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article=' . sql_quote($id));
775
+    if (!$id) {
776
+        return false;
777
+    }
778
+    $r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article=' . sql_quote($id));
779 779
 
780
-	return $r && (
781
-		autoriser('publierdans', 'rubrique', $r['id_rubrique'], $qui, $opt)
782
-		|| (
783
-			(!isset($opt['statut']) || !in_array($opt['statut'], ['publie', 'refuse'], true))
784
-			&& in_array($qui['statut'], ['0minirezo', '1comite'])
785
-			&& in_array($r['statut'], ['prop', 'prepa', 'poubelle'])
786
-			&& auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur'])
787
-		)
788
-	);
780
+    return $r && (
781
+        autoriser('publierdans', 'rubrique', $r['id_rubrique'], $qui, $opt)
782
+        || (
783
+            (!isset($opt['statut']) || !in_array($opt['statut'], ['publie', 'refuse'], true))
784
+            && in_array($qui['statut'], ['0minirezo', '1comite'])
785
+            && in_array($r['statut'], ['prop', 'prepa', 'poubelle'])
786
+            && auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur'])
787
+        )
788
+    );
789 789
 }
790 790
 
791 791
 /**
@@ -803,13 +803,13 @@  discard block
 block discarded – undo
803 803
  * @return bool true s'il a le droit, false sinon
804 804
  **/
805 805
 function autoriser_article_creer_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
806
-	if (!empty($opt['id_parent'])) {
807
-		// creerarticledans rappelle autoriser(creer,article) sans id, donc on verifiera condition du else aussi
808
-		return autoriser('creerarticledans', 'rubrique', $opt['id_parent'], $qui);
809
-	}
810
-	else {
811
-		return (sql_countsel('spip_rubriques') > 0 && in_array($qui['statut'], ['0minirezo', '1comite']));
812
-	}
806
+    if (!empty($opt['id_parent'])) {
807
+        // creerarticledans rappelle autoriser(creer,article) sans id, donc on verifiera condition du else aussi
808
+        return autoriser('creerarticledans', 'rubrique', $opt['id_parent'], $qui);
809
+    }
810
+    else {
811
+        return (sql_countsel('spip_rubriques') > 0 && in_array($qui['statut'], ['0minirezo', '1comite']));
812
+    }
813 813
 }
814 814
 
815 815
 /**
@@ -831,26 +831,26 @@  discard block
 block discarded – undo
831 831
  * @return bool true s'il a le droit, false sinon
832 832
  */
833 833
 function autoriser_article_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
834
-	if ($qui['statut'] === '0minirezo') {
835
-		return true;
836
-	}
837
-	// cas des articles : depend du statut de l'article et de l'auteur
838
-	if (isset($opt['statut'])) {
839
-		$statut = $opt['statut'];
840
-	} else {
841
-		if (!$id) {
842
-			return false;
843
-		}
844
-		$statut = sql_getfetsel('statut', 'spip_articles', 'id_article=' . (int) $id);
845
-	}
834
+    if ($qui['statut'] === '0minirezo') {
835
+        return true;
836
+    }
837
+    // cas des articles : depend du statut de l'article et de l'auteur
838
+    if (isset($opt['statut'])) {
839
+        $statut = $opt['statut'];
840
+    } else {
841
+        if (!$id) {
842
+            return false;
843
+        }
844
+        $statut = sql_getfetsel('statut', 'spip_articles', 'id_article=' . (int) $id);
845
+    }
846 846
 
847
-	return
848
-		// si on est pas auteur de l'article,
849
-		// seuls les propose et publies sont visibles
850
-		in_array($statut, ['prop', 'publie'])
851
-		// sinon si on est auteur, on a le droit de le voir, evidemment !
847
+    return
848
+        // si on est pas auteur de l'article,
849
+        // seuls les propose et publies sont visibles
850
+        in_array($statut, ['prop', 'publie'])
851
+        // sinon si on est auteur, on a le droit de le voir, evidemment !
852 852
 
853
-		|| $id && $qui['id_auteur'] && auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur']);
853
+        || $id && $qui['id_auteur'] && auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur']);
854 854
 }
855 855
 
856 856
 
@@ -869,24 +869,24 @@  discard block
 block discarded – undo
869 869
  * @return bool true s'il a le droit, false sinon
870 870
  **/
871 871
 function autoriser_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
872
-	# securite, mais on aurait pas du arriver ici !
873
-	if (
874
-		function_exists($f = 'autoriser_' . $type . '_voir')
875
-		|| function_exists($f = 'autoriser_' . $type . '_voir_dist')
876
-	) {
877
-		return $f($faire, $type, $id, $qui, $opt);
878
-	}
872
+    # securite, mais on aurait pas du arriver ici !
873
+    if (
874
+        function_exists($f = 'autoriser_' . $type . '_voir')
875
+        || function_exists($f = 'autoriser_' . $type . '_voir_dist')
876
+    ) {
877
+        return $f($faire, $type, $id, $qui, $opt);
878
+    }
879 879
 
880
-	if ($qui['statut'] === '0minirezo') {
881
-		return true;
882
-	}
883
-	// admins et redacteurs peuvent voir un auteur
884
-	if ($type === 'auteur') {
885
-		return in_array($qui['statut'], ['0minirezo', '1comite']);
886
-	}
887
-	// sinon par defaut tout est visible
888
-	// sauf cas particuliers traites separemment (ie article)
889
-	return true;
880
+    if ($qui['statut'] === '0minirezo') {
881
+        return true;
882
+    }
883
+    // admins et redacteurs peuvent voir un auteur
884
+    if ($type === 'auteur') {
885
+        return in_array($qui['statut'], ['0minirezo', '1comite']);
886
+    }
887
+    // sinon par defaut tout est visible
888
+    // sauf cas particuliers traites separemment (ie article)
889
+    return true;
890 890
 }
891 891
 
892 892
 
@@ -908,10 +908,10 @@  discard block
 block discarded – undo
908 908
  * @return bool true s'il a le droit, false sinon
909 909
  **/
910 910
 function autoriser_webmestre_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
911
-	return
912
-		$qui['webmestre'] === 'oui'
913
-		&& $qui['statut'] === '0minirezo'
914
-		&& !$qui['restreint'];
911
+    return
912
+        $qui['webmestre'] === 'oui'
913
+        && $qui['statut'] === '0minirezo'
914
+        && !$qui['restreint'];
915 915
 }
916 916
 
917 917
 /**
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
  * @return bool true s'il a le droit, false sinon
930 930
  **/
931 931
 function autoriser_configurer_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
932
-	return $qui['statut'] === '0minirezo' && !$qui['restreint'];
932
+    return $qui['statut'] === '0minirezo' && !$qui['restreint'];
933 933
 }
934 934
 
935 935
 /**
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
  * @return bool true s'il a le droit, false sinon
948 948
  **/
949 949
 function autoriser_sauvegarder_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
950
-	return $qui['statut'] === '0minirezo';
950
+    return $qui['statut'] === '0minirezo';
951 951
 }
952 952
 
953 953
 /**
@@ -965,7 +965,7 @@  discard block
 block discarded – undo
965 965
  * @return bool true s'il a le droit, false sinon
966 966
  **/
967 967
 function autoriser_detruire_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
968
-	return autoriser('webmestre', null, 0, $qui, $opt);
968
+    return autoriser('webmestre', null, 0, $qui, $opt);
969 969
 }
970 970
 
971 971
 /**
@@ -984,23 +984,23 @@  discard block
 block discarded – undo
984 984
  * @return bool true s'il a le droit, false sinon
985 985
  **/
986 986
 function autoriser_auteur_previsualiser_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
987
-	// les admins peuvent "previsualiser" une page auteur
988
-	if (
989
-		$qui['statut'] === '0minirezo'
990
-		&& !$qui['restreint']
991
-	) {
992
-		return true;
993
-	} elseif ($id === 0) {
994
-		return false;
995
-	}
996
-	// "Voir en ligne" si l'auteur a un article publie
997
-	$n = sql_fetsel(
998
-		'A.id_article',
999
-		'spip_auteurs_liens AS L LEFT JOIN spip_articles AS A ON (L.objet=\'article\' AND L.id_objet=A.id_article)',
1000
-		"A.statut='publie' AND L.id_auteur=" . sql_quote($id)
1001
-	);
987
+    // les admins peuvent "previsualiser" une page auteur
988
+    if (
989
+        $qui['statut'] === '0minirezo'
990
+        && !$qui['restreint']
991
+    ) {
992
+        return true;
993
+    } elseif ($id === 0) {
994
+        return false;
995
+    }
996
+    // "Voir en ligne" si l'auteur a un article publie
997
+    $n = sql_fetsel(
998
+        'A.id_article',
999
+        'spip_auteurs_liens AS L LEFT JOIN spip_articles AS A ON (L.objet=\'article\' AND L.id_objet=A.id_article)',
1000
+        "A.statut='publie' AND L.id_auteur=" . sql_quote($id)
1001
+    );
1002 1002
 
1003
-	return (bool) $n;
1003
+    return (bool) $n;
1004 1004
 }
1005 1005
 
1006 1006
 
@@ -1029,7 +1029,7 @@  discard block
 block discarded – undo
1029 1029
  * @return bool true s'il a le droit, false sinon
1030 1030
  **/
1031 1031
 function autoriser_auteur_creer_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1032
-	return ($qui['statut'] === '0minirezo');
1032
+    return ($qui['statut'] === '0minirezo');
1033 1033
 }
1034 1034
 
1035 1035
 
@@ -1050,62 +1050,62 @@  discard block
 block discarded – undo
1050 1050
  * @return bool true s'il a le droit, false sinon
1051 1051
  **/
1052 1052
 function autoriser_auteur_modifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1053
-	$id = (int) $id;
1054
-
1055
-	// Si pas admin : seulement le droit de modifier ses donnees perso, mais pas statut ni login
1056
-	// la modif de l'email doit etre verifiee ou notifiee si possible, mais c'est a l'interface de gerer ca
1057
-	if ($qui['statut'] != '0minirezo') {
1058
-		return $id == $qui['id_auteur']
1059
-			&& empty($opt['statut'])
1060
-			&& empty($opt['webmestre'])
1061
-			&& empty($opt['restreintes'])
1062
-			&& empty($opt['login']);
1063
-	}
1064
-
1065
-	// Un admin restreint peut modifier/creer un auteur non-admin mais il
1066
-	// n'a le droit ni de le promouvoir admin, ni de changer les rubriques
1067
-	if ($qui['restreint']) {
1068
-		if (isset($opt['webmestre']) && $opt['webmestre']) {
1069
-			return false;
1070
-		} elseif (
1071
-			isset($opt['statut']) && $opt['statut'] === '0minirezo' || isset($opt['restreintes']) && $opt['restreintes']
1072
-		) {
1073
-			return false;
1074
-		} else {
1075
-			if ($id == $qui['id_auteur']) {
1076
-				if (isset($opt['statut']) && $opt['statut']) {
1077
-					return false;
1078
-				} else {
1079
-					return true;
1080
-				}
1081
-			} else {
1082
-				if ($id_auteur = (int) $id) {
1083
-					$t = sql_fetsel('statut', 'spip_auteurs', "id_auteur=$id_auteur");
1084
-					if ($t && $t['statut'] != '0minirezo') {
1085
-						return true;
1086
-					} else {
1087
-						return false;
1088
-					}
1089
-				} else {
1090
-					// id = 0 => creation
1091
-					return true;
1092
-				}
1093
-			}
1094
-		}
1095
-	}
1096
-
1097
-	// Un admin complet fait ce qu'il veut, sauf se degrader
1098
-	if ($id == $qui['id_auteur'] && (isset($opt['statut']) && $opt['statut'])) {
1099
-		return false;
1100
-	} elseif (isset($opt['webmestre']) && $opt['webmestre'] && !autoriser('webmestre')) {
1101
-		// et toucher au statut webmestre si il ne l'est pas lui même
1102
-		return false;
1103
-	} elseif ((int) $id && !autoriser('webmestre') && autoriser('webmestre', '', 0, $id)) {
1104
-		// et modifier un webmestre si il ne l'est pas lui meme
1105
-		return false;
1106
-	}
1107
-
1108
-	return true;
1053
+    $id = (int) $id;
1054
+
1055
+    // Si pas admin : seulement le droit de modifier ses donnees perso, mais pas statut ni login
1056
+    // la modif de l'email doit etre verifiee ou notifiee si possible, mais c'est a l'interface de gerer ca
1057
+    if ($qui['statut'] != '0minirezo') {
1058
+        return $id == $qui['id_auteur']
1059
+            && empty($opt['statut'])
1060
+            && empty($opt['webmestre'])
1061
+            && empty($opt['restreintes'])
1062
+            && empty($opt['login']);
1063
+    }
1064
+
1065
+    // Un admin restreint peut modifier/creer un auteur non-admin mais il
1066
+    // n'a le droit ni de le promouvoir admin, ni de changer les rubriques
1067
+    if ($qui['restreint']) {
1068
+        if (isset($opt['webmestre']) && $opt['webmestre']) {
1069
+            return false;
1070
+        } elseif (
1071
+            isset($opt['statut']) && $opt['statut'] === '0minirezo' || isset($opt['restreintes']) && $opt['restreintes']
1072
+        ) {
1073
+            return false;
1074
+        } else {
1075
+            if ($id == $qui['id_auteur']) {
1076
+                if (isset($opt['statut']) && $opt['statut']) {
1077
+                    return false;
1078
+                } else {
1079
+                    return true;
1080
+                }
1081
+            } else {
1082
+                if ($id_auteur = (int) $id) {
1083
+                    $t = sql_fetsel('statut', 'spip_auteurs', "id_auteur=$id_auteur");
1084
+                    if ($t && $t['statut'] != '0minirezo') {
1085
+                        return true;
1086
+                    } else {
1087
+                        return false;
1088
+                    }
1089
+                } else {
1090
+                    // id = 0 => creation
1091
+                    return true;
1092
+                }
1093
+            }
1094
+        }
1095
+    }
1096
+
1097
+    // Un admin complet fait ce qu'il veut, sauf se degrader
1098
+    if ($id == $qui['id_auteur'] && (isset($opt['statut']) && $opt['statut'])) {
1099
+        return false;
1100
+    } elseif (isset($opt['webmestre']) && $opt['webmestre'] && !autoriser('webmestre')) {
1101
+        // et toucher au statut webmestre si il ne l'est pas lui même
1102
+        return false;
1103
+    } elseif ((int) $id && !autoriser('webmestre') && autoriser('webmestre', '', 0, $id)) {
1104
+        // et modifier un webmestre si il ne l'est pas lui meme
1105
+        return false;
1106
+    }
1107
+
1108
+    return true;
1109 1109
 }
1110 1110
 
1111 1111
 
@@ -1124,7 +1124,7 @@  discard block
 block discarded – undo
1124 1124
  * @return bool true s'il a le droit, false sinon
1125 1125
  **/
1126 1126
 function autoriser_associerauteurs_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1127
-	return autoriser('modifier', $type, $id, $qui, $opt);
1127
+    return autoriser('modifier', $type, $id, $qui, $opt);
1128 1128
 }
1129 1129
 
1130 1130
 
@@ -1143,7 +1143,7 @@  discard block
 block discarded – undo
1143 1143
  * @return bool true s'il a le droit, false sinon
1144 1144
  **/
1145 1145
 function autoriser_chargerftp_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1146
-	return $qui['statut'] === '0minirezo';
1146
+    return $qui['statut'] === '0minirezo';
1147 1147
 }
1148 1148
 
1149 1149
 /**
@@ -1161,7 +1161,7 @@  discard block
 block discarded – undo
1161 1161
  * @return bool true s'il a le droit, false sinon
1162 1162
  **/
1163 1163
 function autoriser_debug_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1164
-	return $qui['statut'] === '0minirezo';
1164
+    return $qui['statut'] === '0minirezo';
1165 1165
 }
1166 1166
 
1167 1167
 /**
@@ -1178,53 +1178,53 @@  discard block
 block discarded – undo
1178 1178
  * @return array          Liste des rubriques
1179 1179
  **/
1180 1180
 function liste_rubriques_auteur($id_auteur, $raz = false) {
1181
-	static $restreint = [];
1182
-
1183
-	if (!$id_auteur = (int) $id_auteur) {
1184
-		return [];
1185
-	}
1186
-	if ($raz) {
1187
-		unset($restreint[$id_auteur]);
1188
-	} elseif (isset($restreint[$id_auteur])) {
1189
-		return $restreint[$id_auteur];
1190
-	}
1191
-
1192
-	$rubriques = [];
1193
-	if (
1194
-		(!isset($GLOBALS['meta']['version_installee']) || $GLOBALS['meta']['version_installee'] > 16428)
1195
-		&& ($r = sql_allfetsel(
1196
-			'id_objet',
1197
-			'spip_auteurs_liens',
1198
-			'id_auteur=' . (int) $id_auteur . " AND objet='rubrique' AND id_objet!=0"
1199
-		))
1200
-		&& (is_countable($r) ? count($r) : 0)
1201
-	) {
1202
-		$r = array_column($r, 'id_objet');
1203
-
1204
-		// recuperer toute la branche, au format chaine enumeration
1205
-		include_spip('inc/rubriques');
1206
-		$r = calcul_branche_in($r);
1207
-		$r = explode(',', (string) $r);
1208
-
1209
-		// passer les rubriques en index, elimine les doublons
1210
-		$r = array_flip($r);
1211
-		// recuperer les index seuls
1212
-		$r = array_keys($r);
1213
-		// combiner pour avoir un tableau id_rubrique=>id_rubrique
1214
-		// est-ce vraiment utile ? (on preserve la forme donnee par le code precedent)
1215
-		$rubriques = array_combine($r, $r);
1216
-	}
1217
-
1218
-	// Affecter l'auteur session le cas echeant
1219
-	if (
1220
-		isset($GLOBALS['visiteur_session']['id_auteur'])
1221
-		&& $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur
1222
-	) {
1223
-		$GLOBALS['visiteur_session']['restreint'] = $rubriques;
1224
-	}
1225
-
1226
-
1227
-	return $restreint[$id_auteur] = $rubriques;
1181
+    static $restreint = [];
1182
+
1183
+    if (!$id_auteur = (int) $id_auteur) {
1184
+        return [];
1185
+    }
1186
+    if ($raz) {
1187
+        unset($restreint[$id_auteur]);
1188
+    } elseif (isset($restreint[$id_auteur])) {
1189
+        return $restreint[$id_auteur];
1190
+    }
1191
+
1192
+    $rubriques = [];
1193
+    if (
1194
+        (!isset($GLOBALS['meta']['version_installee']) || $GLOBALS['meta']['version_installee'] > 16428)
1195
+        && ($r = sql_allfetsel(
1196
+            'id_objet',
1197
+            'spip_auteurs_liens',
1198
+            'id_auteur=' . (int) $id_auteur . " AND objet='rubrique' AND id_objet!=0"
1199
+        ))
1200
+        && (is_countable($r) ? count($r) : 0)
1201
+    ) {
1202
+        $r = array_column($r, 'id_objet');
1203
+
1204
+        // recuperer toute la branche, au format chaine enumeration
1205
+        include_spip('inc/rubriques');
1206
+        $r = calcul_branche_in($r);
1207
+        $r = explode(',', (string) $r);
1208
+
1209
+        // passer les rubriques en index, elimine les doublons
1210
+        $r = array_flip($r);
1211
+        // recuperer les index seuls
1212
+        $r = array_keys($r);
1213
+        // combiner pour avoir un tableau id_rubrique=>id_rubrique
1214
+        // est-ce vraiment utile ? (on preserve la forme donnee par le code precedent)
1215
+        $rubriques = array_combine($r, $r);
1216
+    }
1217
+
1218
+    // Affecter l'auteur session le cas echeant
1219
+    if (
1220
+        isset($GLOBALS['visiteur_session']['id_auteur'])
1221
+        && $GLOBALS['visiteur_session']['id_auteur'] == $id_auteur
1222
+    ) {
1223
+        $GLOBALS['visiteur_session']['restreint'] = $rubriques;
1224
+    }
1225
+
1226
+
1227
+    return $restreint[$id_auteur] = $rubriques;
1228 1228
 }
1229 1229
 
1230 1230
 /**
@@ -1242,7 +1242,7 @@  discard block
 block discarded – undo
1242 1242
  * @return bool true s'il a le droit, false sinon
1243 1243
  **/
1244 1244
 function autoriser_rubrique_previsualiser_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1245
-	return autoriser('previsualiser');
1245
+    return autoriser('previsualiser');
1246 1246
 }
1247 1247
 
1248 1248
 /**
@@ -1260,7 +1260,7 @@  discard block
 block discarded – undo
1260 1260
  * @return bool true s'il a le droit, false sinon
1261 1261
  **/
1262 1262
 function autoriser_rubrique_iconifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1263
-	return autoriser('publierdans', 'rubrique', $id, $qui, $opt);
1263
+    return autoriser('publierdans', 'rubrique', $id, $qui, $opt);
1264 1264
 }
1265 1265
 
1266 1266
 /**
@@ -1278,8 +1278,8 @@  discard block
 block discarded – undo
1278 1278
  * @return bool true s'il a le droit, false sinon
1279 1279
  **/
1280 1280
 function autoriser_auteur_iconifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1281
-	$id = (int) $id;
1282
-	return ($id == $qui['id_auteur'] || $qui['statut'] === '0minirezo' && !$qui['restreint']);
1281
+    $id = (int) $id;
1282
+    return ($id == $qui['id_auteur'] || $qui['statut'] === '0minirezo' && !$qui['restreint']);
1283 1283
 }
1284 1284
 
1285 1285
 /**
@@ -1297,8 +1297,8 @@  discard block
 block discarded – undo
1297 1297
  * @return bool true s'il a le droit, false sinon
1298 1298
  **/
1299 1299
 function autoriser_iconifier_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1300
-	// par defaut, on a le droit d'iconifier si on a le droit de modifier
1301
-	return autoriser('modifier', $type, $id, $qui, $opt);
1300
+    // par defaut, on a le droit d'iconifier si on a le droit de modifier
1301
+    return autoriser('modifier', $type, $id, $qui, $opt);
1302 1302
 }
1303 1303
 
1304 1304
 
@@ -1318,7 +1318,7 @@  discard block
 block discarded – undo
1318 1318
  * @return true
1319 1319
  **/
1320 1320
 function autoriser_ok_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1321
-	return true;
1321
+    return true;
1322 1322
 }
1323 1323
 
1324 1324
 /**
@@ -1337,7 +1337,7 @@  discard block
 block discarded – undo
1337 1337
  * @return false
1338 1338
  **/
1339 1339
 function autoriser_niet_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1340
-	return false;
1340
+    return false;
1341 1341
 }
1342 1342
 
1343 1343
 /**
@@ -1355,7 +1355,7 @@  discard block
 block discarded – undo
1355 1355
  * @return bool true s'il a le droit, false sinon
1356 1356
  **/
1357 1357
 function autoriser_base_reparer_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1358
-	return autoriser('detruire') && !_request('reinstall');
1358
+    return autoriser('detruire') && !_request('reinstall');
1359 1359
 }
1360 1360
 
1361 1361
 /**
@@ -1373,7 +1373,7 @@  discard block
 block discarded – undo
1373 1373
  * @return true
1374 1374
  **/
1375 1375
 function autoriser_infosperso_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1376
-	return true;
1376
+    return true;
1377 1377
 }
1378 1378
 
1379 1379
 /**
@@ -1391,7 +1391,7 @@  discard block
 block discarded – undo
1391 1391
  * @return true
1392 1392
  **/
1393 1393
 function autoriser_langage_configurer_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1394
-	return true;
1394
+    return true;
1395 1395
 }
1396 1396
 
1397 1397
 /**
@@ -1409,7 +1409,7 @@  discard block
 block discarded – undo
1409 1409
  * @return bool true s'il a le droit, false sinon
1410 1410
  **/
1411 1411
 function autoriser_configurerlangage_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1412
-	return autoriser('configurer', '_langage', $id, $qui, $opt);
1412
+    return autoriser('configurer', '_langage', $id, $qui, $opt);
1413 1413
 }
1414 1414
 
1415 1415
 /**
@@ -1427,7 +1427,7 @@  discard block
 block discarded – undo
1427 1427
  * @return true
1428 1428
  **/
1429 1429
 function autoriser_preferences_configurer_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1430
-	return true;
1430
+    return true;
1431 1431
 }
1432 1432
 
1433 1433
 /**
@@ -1445,7 +1445,7 @@  discard block
 block discarded – undo
1445 1445
  * @return bool true s'il a le droit, false sinon
1446 1446
  **/
1447 1447
 function autoriser_configurerpreferences_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1448
-	return autoriser('configurer', '_preferences', $id, $qui, $opt);
1448
+    return autoriser('configurer', '_preferences', $id, $qui, $opt);
1449 1449
 }
1450 1450
 
1451 1451
 /**
@@ -1463,7 +1463,7 @@  discard block
 block discarded – undo
1463 1463
  * @return bool true s'il a le droit, false sinon
1464 1464
  **/
1465 1465
 function autoriser_menudeveloppement_menugrandeentree_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1466
-	return (isset($GLOBALS['visiteur_session']['prefs']['activer_menudev']) && $GLOBALS['visiteur_session']['prefs']['activer_menudev'] === 'oui');
1466
+    return (isset($GLOBALS['visiteur_session']['prefs']['activer_menudev']) && $GLOBALS['visiteur_session']['prefs']['activer_menudev'] === 'oui');
1467 1467
 }
1468 1468
 
1469 1469
 /**
@@ -1482,7 +1482,7 @@  discard block
 block discarded – undo
1482 1482
  * @return true
1483 1483
  **/
1484 1484
 function autoriser_menugrandeentree_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1485
-	return true;
1485
+    return true;
1486 1486
 }
1487 1487
 
1488 1488
 /**
@@ -1500,7 +1500,7 @@  discard block
 block discarded – undo
1500 1500
  * @return true
1501 1501
  **/
1502 1502
 function autoriser_auteurs_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1503
-	return true;
1503
+    return true;
1504 1504
 }
1505 1505
 
1506 1506
 /**
@@ -1518,7 +1518,7 @@  discard block
 block discarded – undo
1518 1518
  * @return bool true s'il a le droit, false sinon
1519 1519
  **/
1520 1520
 function autoriser_auteurs_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1521
-	return autoriser('voir', '_auteurs', $id, $qui, $opt);
1521
+    return autoriser('voir', '_auteurs', $id, $qui, $opt);
1522 1522
 }
1523 1523
 
1524 1524
 /**
@@ -1536,7 +1536,7 @@  discard block
 block discarded – undo
1536 1536
  * @return true
1537 1537
  **/
1538 1538
 function autoriser_articles_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1539
-	return true;
1539
+    return true;
1540 1540
 }
1541 1541
 
1542 1542
 /**
@@ -1554,7 +1554,7 @@  discard block
 block discarded – undo
1554 1554
  * @return bool true s'il a le droit, false sinon
1555 1555
  **/
1556 1556
 function autoriser_articles_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1557
-	return autoriser('voir', '_articles', $id, $qui, $opt);
1557
+    return autoriser('voir', '_articles', $id, $qui, $opt);
1558 1558
 }
1559 1559
 
1560 1560
 /**
@@ -1572,7 +1572,7 @@  discard block
 block discarded – undo
1572 1572
  * @return true
1573 1573
  **/
1574 1574
 function autoriser_rubriques_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1575
-	return true;
1575
+    return true;
1576 1576
 }
1577 1577
 
1578 1578
 /**
@@ -1590,7 +1590,7 @@  discard block
 block discarded – undo
1590 1590
  * @return bool true s'il a le droit, false sinon
1591 1591
  **/
1592 1592
 function autoriser_rubriques_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1593
-	return autoriser('voir', '_rubriques', $id, $qui, $opt);
1593
+    return autoriser('voir', '_rubriques', $id, $qui, $opt);
1594 1594
 }
1595 1595
 
1596 1596
 /**
@@ -1608,7 +1608,7 @@  discard block
 block discarded – undo
1608 1608
  * @return bool true s'il a le droit, false sinon
1609 1609
  **/
1610 1610
 function autoriser_articlecreer_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1611
-	return verifier_table_non_vide();
1611
+    return verifier_table_non_vide();
1612 1612
 }
1613 1613
 
1614 1614
 
@@ -1629,7 +1629,7 @@  discard block
 block discarded – undo
1629 1629
  * @return bool true s'il a le droit, false sinon
1630 1630
  **/
1631 1631
 function autoriser_auteurcreer_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1632
-	return autoriser('creer', 'auteur', $id, $qui, $opt);
1632
+    return autoriser('creer', 'auteur', $id, $qui, $opt);
1633 1633
 }
1634 1634
 
1635 1635
 /**
@@ -1647,11 +1647,11 @@  discard block
 block discarded – undo
1647 1647
  * @return bool true s'il a le droit, false sinon
1648 1648
  **/
1649 1649
 function autoriser_visiteurs_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1650
-	include_spip('base/abstract_sql');
1651
-	return
1652
-		$qui['statut'] === '0minirezo'
1653
-		&& !$qui['restreint']
1654
-		&& ($GLOBALS['meta']['accepter_visiteurs'] != 'non' || sql_countsel('spip_auteurs', 'statut in ("6forum", "nouveau")') > 0);
1650
+    include_spip('base/abstract_sql');
1651
+    return
1652
+        $qui['statut'] === '0minirezo'
1653
+        && !$qui['restreint']
1654
+        && ($GLOBALS['meta']['accepter_visiteurs'] != 'non' || sql_countsel('spip_auteurs', 'statut in ("6forum", "nouveau")') > 0);
1655 1655
 }
1656 1656
 
1657 1657
 /**
@@ -1669,7 +1669,7 @@  discard block
 block discarded – undo
1669 1669
  * @return bool true s'il a le droit, false sinon
1670 1670
  **/
1671 1671
 function autoriser_suiviedito_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1672
-	return $qui['statut'] === '0minirezo';
1672
+    return $qui['statut'] === '0minirezo';
1673 1673
 }
1674 1674
 
1675 1675
 /**
@@ -1687,7 +1687,7 @@  discard block
 block discarded – undo
1687 1687
  * @return bool true s'il a le droit, false sinon
1688 1688
  **/
1689 1689
 function autoriser_synchro_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1690
-	return $qui['statut'] === '0minirezo';
1690
+    return $qui['statut'] === '0minirezo';
1691 1691
 }
1692 1692
 
1693 1693
 /**
@@ -1705,7 +1705,7 @@  discard block
 block discarded – undo
1705 1705
  * @return bool true s'il a le droit, false sinon
1706 1706
  **/
1707 1707
 function autoriser_configurerinteractions_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1708
-	return autoriser('configurer', '_interactions', $id, $qui, $opt);
1708
+    return autoriser('configurer', '_interactions', $id, $qui, $opt);
1709 1709
 }
1710 1710
 
1711 1711
 /**
@@ -1723,7 +1723,7 @@  discard block
 block discarded – undo
1723 1723
  * @return bool true s'il a le droit, false sinon
1724 1724
  **/
1725 1725
 function autoriser_configurerlangue_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1726
-	return autoriser('configurer', '_langue', $id, $qui, $opt);
1726
+    return autoriser('configurer', '_langue', $id, $qui, $opt);
1727 1727
 }
1728 1728
 
1729 1729
 /**
@@ -1741,7 +1741,7 @@  discard block
 block discarded – undo
1741 1741
  * @return bool true s'il a le droit, false sinon
1742 1742
  **/
1743 1743
 function autoriser_configurermultilinguisme_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1744
-	return autoriser('configurer', '_multilinguisme', $id, $qui, $opt);
1744
+    return autoriser('configurer', '_multilinguisme', $id, $qui, $opt);
1745 1745
 }
1746 1746
 
1747 1747
 /**
@@ -1759,7 +1759,7 @@  discard block
 block discarded – undo
1759 1759
  * @return bool true s'il a le droit, false sinon
1760 1760
  **/
1761 1761
 function autoriser_configurercontenu_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1762
-	return autoriser('configurer', '_contenu', $id, $qui, $opt);
1762
+    return autoriser('configurer', '_contenu', $id, $qui, $opt);
1763 1763
 }
1764 1764
 
1765 1765
 /**
@@ -1777,7 +1777,7 @@  discard block
 block discarded – undo
1777 1777
  * @return bool true s'il a le droit, false sinon
1778 1778
  **/
1779 1779
 function autoriser_configureravancees_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1780
-	return autoriser('configurer', '_avancees', $id, $qui, $opt);
1780
+    return autoriser('configurer', '_avancees', $id, $qui, $opt);
1781 1781
 }
1782 1782
 
1783 1783
 /**
@@ -1795,7 +1795,7 @@  discard block
 block discarded – undo
1795 1795
  * @return bool true s'il a le droit, false sinon
1796 1796
  **/
1797 1797
 function autoriser_adminplugin_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1798
-	return autoriser('configurer', '_plugins', $id, $qui, $opt);
1798
+    return autoriser('configurer', '_plugins', $id, $qui, $opt);
1799 1799
 }
1800 1800
 
1801 1801
 /**
@@ -1813,7 +1813,7 @@  discard block
 block discarded – undo
1813 1813
  * @return bool true s'il a le droit, false sinon
1814 1814
  **/
1815 1815
 function autoriser_admintech_menu_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1816
-	return autoriser('detruire', $type, $id, $qui, $opt);
1816
+    return autoriser('detruire', $type, $id, $qui, $opt);
1817 1817
 }
1818 1818
 
1819 1819
 /**
@@ -1831,7 +1831,7 @@  discard block
 block discarded – undo
1831 1831
  * @return bool true s'il a le droit, false sinon
1832 1832
  **/
1833 1833
 function autoriser_queue_purger_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1834
-	return autoriser('webmestre');
1834
+    return autoriser('webmestre');
1835 1835
 }
1836 1836
 
1837 1837
 
@@ -1851,11 +1851,11 @@  discard block
 block discarded – undo
1851 1851
  * @return bool true s'il a le droit, false sinon
1852 1852
  **/
1853 1853
 function autoriser_echafauder_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1854
-	if (test_espace_prive()) {
1855
-		return (bool) (int) $qui['id_auteur'];
1856
-	} else {
1857
-		return autoriser('webmestre', '', $id, $qui, $opt);
1858
-	}
1854
+    if (test_espace_prive()) {
1855
+        return (bool) (int) $qui['id_auteur'];
1856
+    } else {
1857
+        return autoriser('webmestre', '', $id, $qui, $opt);
1858
+    }
1859 1859
 }
1860 1860
 
1861 1861
 
@@ -1870,27 +1870,27 @@  discard block
 block discarded – undo
1870 1870
  *     Identifiants d'auteurs
1871 1871
  */
1872 1872
 function auteurs_objet($objet, $id_objet, $cond = '') {
1873
-	$objet = objet_type($objet);
1874
-	$where = [
1875
-		'objet=' . sql_quote($objet),
1876
-		'id_objet=' . (int) $id_objet
1877
-	];
1878
-	if (!empty($cond)) {
1879
-		if (is_array($cond)) {
1880
-			$where = array_merge($where, $cond);
1881
-		} else {
1882
-			$where[] = $cond;
1883
-		}
1884
-	}
1885
-	$auteurs = sql_allfetsel(
1886
-		'id_auteur',
1887
-		'spip_auteurs_liens',
1888
-		$where
1889
-	);
1890
-	if (is_array($auteurs)) {
1891
-		return array_column($auteurs, 'id_auteur');
1892
-	}
1893
-	return [];
1873
+    $objet = objet_type($objet);
1874
+    $where = [
1875
+        'objet=' . sql_quote($objet),
1876
+        'id_objet=' . (int) $id_objet
1877
+    ];
1878
+    if (!empty($cond)) {
1879
+        if (is_array($cond)) {
1880
+            $where = array_merge($where, $cond);
1881
+        } else {
1882
+            $where[] = $cond;
1883
+        }
1884
+    }
1885
+    $auteurs = sql_allfetsel(
1886
+        'id_auteur',
1887
+        'spip_auteurs_liens',
1888
+        $where
1889
+    );
1890
+    if (is_array($auteurs)) {
1891
+        return array_column($auteurs, 'id_auteur');
1892
+    }
1893
+    return [];
1894 1894
 }
1895 1895
 
1896 1896
 /**
@@ -1903,7 +1903,7 @@  discard block
 block discarded – undo
1903 1903
  */
1904 1904
 function acces_restreint_rubrique($id_rubrique) {
1905 1905
 
1906
-	return (isset($GLOBALS['connect_id_rubrique'][$id_rubrique]));
1906
+    return (isset($GLOBALS['connect_id_rubrique'][$id_rubrique]));
1907 1907
 }
1908 1908
 
1909 1909
 
@@ -1916,12 +1916,12 @@  discard block
 block discarded – undo
1916 1916
  * @return bool             true si un parent existe
1917 1917
  */
1918 1918
 function verifier_table_non_vide($table = 'spip_rubriques') {
1919
-	static $done = [];
1920
-	if (!isset($done[$table])) {
1921
-		$done[$table] = sql_countsel($table) > 0;
1922
-	}
1919
+    static $done = [];
1920
+    if (!isset($done[$table])) {
1921
+        $done[$table] = sql_countsel($table) > 0;
1922
+    }
1923 1923
 
1924
-	return $done[$table];
1924
+    return $done[$table];
1925 1925
 }
1926 1926
 
1927 1927
 /**
@@ -1948,12 +1948,12 @@  discard block
 block discarded – undo
1948 1948
  */
1949 1949
 function autoriser_inscrireauteur_dist($faire, $quoi, $id, $qui, $opt) {
1950 1950
 
1951
-	$s = array_search($quoi, $GLOBALS['liste_des_statuts']);
1952
-	return match ($s) {
1953
-		'info_redacteurs' => $GLOBALS['meta']['accepter_inscriptions'] === 'oui',
1954
-		'info_visiteurs' => $GLOBALS['meta']['accepter_visiteurs'] === 'oui' || $GLOBALS['meta']['forums_publics'] === 'abo',
1955
-		default => false,
1956
-	};
1951
+    $s = array_search($quoi, $GLOBALS['liste_des_statuts']);
1952
+    return match ($s) {
1953
+        'info_redacteurs' => $GLOBALS['meta']['accepter_inscriptions'] === 'oui',
1954
+        'info_visiteurs' => $GLOBALS['meta']['accepter_visiteurs'] === 'oui' || $GLOBALS['meta']['forums_publics'] === 'abo',
1955
+        default => false,
1956
+    };
1957 1957
 }
1958 1958
 
1959 1959
 /**
@@ -1971,7 +1971,7 @@  discard block
 block discarded – undo
1971 1971
  * @return bool true s'il a le droit, false sinon
1972 1972
  **/
1973 1973
 function autoriser_inscription_relancer_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1974
-	return $qui['statut'] === '0minirezo' && !$qui['restreint'];
1974
+    return $qui['statut'] === '0minirezo' && !$qui['restreint'];
1975 1975
 }
1976 1976
 
1977 1977
 /**
@@ -1989,5 +1989,5 @@  discard block
 block discarded – undo
1989 1989
  * @return bool true s'il a le droit, false sinon
1990 1990
  **/
1991 1991
 function autoriser_phpinfos_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
1992
-	return autoriser('webmestre');
1992
+    return autoriser('webmestre');
1993 1993
 }
Please login to merge, or discard this patch.
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 // mais apres la fonction autoriser()
120 120
 if ($f = find_in_path('mes_fonctions.php')) {
121 121
 	global $dossier_squelettes;
122
-	include_once(_ROOT_CWD . $f);
122
+	include_once(_ROOT_CWD.$f);
123 123
 }
124 124
 
125 125
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 		$qui = $GLOBALS['visiteur_session'] ?: [];
161 161
 		$qui = array_merge(['statut' => '', 'id_auteur' => 0, 'webmestre' => 'non'], $qui);
162 162
 	} elseif (is_numeric($qui)) {
163
-		$qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . $qui);
163
+		$qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur='.$qui);
164 164
 		if (!$qui) {
165 165
 			return false;
166 166
 		}
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 
175 175
 	$logger = spip_logger('autoriser');
176 176
 	$logger->debug(
177
-		"autoriser $faire $type $id (" . ($qui['nom'] ?? '') . ') ?',
177
+		"autoriser $faire $type $id (".($qui['nom'] ?? '').') ?',
178 178
 	);
179 179
 
180 180
 	$type = autoriser_type($type);
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
 		isset($GLOBALS['autoriser_exception'][$faire][$type][$id])
185 185
 		&& autoriser_exception($faire, $type, $id, 'verifier') || isset($GLOBALS['autoriser_exception'][$faire][$type]['*']) && autoriser_exception($faire, $type, '*', 'verifier')
186 186
 	) {
187
-		$logger->debug("autoriser ($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : OK Exception');
187
+		$logger->debug("autoriser ($faire, $type, $id, ".($qui['nom'] ?? '').') : OK Exception');
188 188
 		return true;
189 189
 	}
190 190
 
@@ -193,18 +193,18 @@  discard block
 block discarded – undo
193 193
 	// autoriser_faire[_dist], autoriser_defaut[_dist]
194 194
 	$fonctions = $type
195 195
 		? [
196
-			'autoriser_' . $type . '_' . $faire,
197
-			'autoriser_' . $type . '_' . $faire . '_dist',
198
-			'autoriser_' . $type,
199
-			'autoriser_' . $type . '_dist',
200
-			'autoriser_' . $faire,
201
-			'autoriser_' . $faire . '_dist',
196
+			'autoriser_'.$type.'_'.$faire,
197
+			'autoriser_'.$type.'_'.$faire.'_dist',
198
+			'autoriser_'.$type,
199
+			'autoriser_'.$type.'_dist',
200
+			'autoriser_'.$faire,
201
+			'autoriser_'.$faire.'_dist',
202 202
 			'autoriser_defaut',
203 203
 			'autoriser_defaut_dist'
204 204
 		]
205 205
 		: [
206
-			'autoriser_' . $faire,
207
-			'autoriser_' . $faire . '_dist',
206
+			'autoriser_'.$faire,
207
+			'autoriser_'.$faire.'_dist',
208 208
 			'autoriser_defaut',
209 209
 			'autoriser_defaut_dist'
210 210
 		];
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 	}
219 219
 
220 220
 	$logger->debug(
221
-		"$f($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : ' . ($a ? 'OK' : 'niet'),
221
+		"$f($faire, $type, $id, ".($qui['nom'] ?? '').') : '.($a ? 'OK' : 'niet'),
222 222
 	);
223 223
 
224 224
 	if (!is_bool($a)) {
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
 function autoriser_previsualiser_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
385 385
 
386 386
 	// Le visiteur a-t-il un statut prevu par la config ?
387
-	if (str_contains((string) $GLOBALS['meta']['preview'], ',' . $qui['statut'] . ',')) {
387
+	if (str_contains((string) $GLOBALS['meta']['preview'], ','.$qui['statut'].',')) {
388 388
 		return test_previsualiser_objet_champ($type, $id, $qui, $opt);
389 389
 	}
390 390
 
@@ -438,7 +438,7 @@  discard block
 block discarded – undo
438 438
 				} // pas de champ passe a la demande => NIET
439 439
 				$previsu = explode(',', (string) $c['previsu']);
440 440
 				// regarder si ce statut est autorise pour l'auteur
441
-				if (in_array($opt[$champ] . '/auteur', $previsu)) {
441
+				if (in_array($opt[$champ].'/auteur', $previsu)) {
442 442
 					// retrouver l’id_auteur qui a filé un lien de prévisu éventuellement,
443 443
 					// sinon l’auteur en session
444 444
 					include_spip('inc/securiser_action');
@@ -452,12 +452,12 @@  discard block
 block discarded – undo
452 452
 
453 453
 					if (!$id_auteur) {
454 454
 						return false;
455
-					} elseif (autoriser('previsualiser' . $opt[$champ], $type, 0, $id_auteur)) {
455
+					} elseif (autoriser('previsualiser'.$opt[$champ], $type, 0, $id_auteur)) {
456 456
 						// dans ce cas (admin en general), pas de filtrage sur ce statut
457 457
 					} elseif (
458 458
 						!sql_countsel(
459 459
 							'spip_auteurs_liens',
460
-							'id_auteur=' . (int) $id_auteur . ' AND objet=' . sql_quote($type) . ' AND id_objet=' . (int) $id
460
+							'id_auteur='.(int) $id_auteur.' AND objet='.sql_quote($type).' AND id_objet='.(int) $id
461 461
 						)
462 462
 					) {
463 463
 						return false;
@@ -502,14 +502,14 @@  discard block
 block discarded – undo
502 502
 			// multilinguisme par secteur et objet rattaché à une rubrique
503 503
 			$primary = id_table_objet($type);
504 504
 			$id_rubrique = $table != 'spip_rubriques'
505
-				? sql_getfetsel('id_rubrique', "$table", "$primary=" . (int) $id)
505
+				? sql_getfetsel('id_rubrique', "$table", "$primary=".(int) $id)
506 506
 				: $id;
507
-			$id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . (int) $id_rubrique);
507
+			$id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique='.(int) $id_rubrique);
508 508
 			if (!$id_secteur > 0) {
509 509
 				$id_secteur = $id_rubrique;
510 510
 			}
511
-			$langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . (int) $id_secteur);
512
-			$langue_objet = sql_getfetsel('lang', "$table", "$primary=" . (int) $id);
511
+			$langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique='.(int) $id_secteur);
512
+			$langue_objet = sql_getfetsel('lang', "$table", "$primary=".(int) $id);
513 513
 			if ($langue_secteur != $langue_objet) {
514 514
 				// configuration incohérente, on laisse l'utilisateur corriger la situation
515 515
 				return true;
@@ -517,7 +517,7 @@  discard block
 block discarded – undo
517 517
 			if ($table != 'spip_rubriques') { // le choix de la langue se fait seulement sur les rubriques
518 518
 				return false;
519 519
 			} else {
520
-				$id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . (int) $id);
520
+				$id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique='.(int) $id);
521 521
 				if ($id_parent != 0) {
522 522
 					// sous-rubriques : pas de choix de langue
523 523
 					return false;
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
 
570 570
 	if (!isset($opt['statut'])) {
571 571
 		if (isset($desc['field']['statut'])) {
572
-			$statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type) . '=' . (int) $id);
572
+			$statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type).'='.(int) $id);
573 573
 		} else {
574 574
 			$statut = 'publie';
575 575
 		} // pas de statut => publie
@@ -734,11 +734,11 @@  discard block
 block discarded – undo
734 734
 		return false;
735 735
 	}
736 736
 
737
-	if (sql_countsel('spip_rubriques', 'id_parent=' . (int) $id)) {
737
+	if (sql_countsel('spip_rubriques', 'id_parent='.(int) $id)) {
738 738
 		return false;
739 739
 	}
740 740
 
741
-	if (sql_countsel('spip_articles', 'id_rubrique=' . (int) $id . " AND (statut<>'poubelle')")) {
741
+	if (sql_countsel('spip_articles', 'id_rubrique='.(int) $id." AND (statut<>'poubelle')")) {
742 742
 		return false;
743 743
 	}
744 744
 
@@ -775,7 +775,7 @@  discard block
 block discarded – undo
775 775
 	if (!$id) {
776 776
 		return false;
777 777
 	}
778
-	$r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article=' . sql_quote($id));
778
+	$r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article='.sql_quote($id));
779 779
 
780 780
 	return $r && (
781 781
 		autoriser('publierdans', 'rubrique', $r['id_rubrique'], $qui, $opt)
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
 			(!isset($opt['statut']) || !in_array($opt['statut'], ['publie', 'refuse'], true))
784 784
 			&& in_array($qui['statut'], ['0minirezo', '1comite'])
785 785
 			&& in_array($r['statut'], ['prop', 'prepa', 'poubelle'])
786
-			&& auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur'])
786
+			&& auteurs_objet('article', $id, 'id_auteur='.$qui['id_auteur'])
787 787
 		)
788 788
 	);
789 789
 }
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 		if (!$id) {
842 842
 			return false;
843 843
 		}
844
-		$statut = sql_getfetsel('statut', 'spip_articles', 'id_article=' . (int) $id);
844
+		$statut = sql_getfetsel('statut', 'spip_articles', 'id_article='.(int) $id);
845 845
 	}
846 846
 
847 847
 	return
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
 		in_array($statut, ['prop', 'publie'])
851 851
 		// sinon si on est auteur, on a le droit de le voir, evidemment !
852 852
 
853
-		|| $id && $qui['id_auteur'] && auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur']);
853
+		|| $id && $qui['id_auteur'] && auteurs_objet('article', $id, 'id_auteur='.$qui['id_auteur']);
854 854
 }
855 855
 
856 856
 
@@ -871,8 +871,8 @@  discard block
 block discarded – undo
871 871
 function autoriser_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
872 872
 	# securite, mais on aurait pas du arriver ici !
873 873
 	if (
874
-		function_exists($f = 'autoriser_' . $type . '_voir')
875
-		|| function_exists($f = 'autoriser_' . $type . '_voir_dist')
874
+		function_exists($f = 'autoriser_'.$type.'_voir')
875
+		|| function_exists($f = 'autoriser_'.$type.'_voir_dist')
876 876
 	) {
877 877
 		return $f($faire, $type, $id, $qui, $opt);
878 878
 	}
@@ -997,7 +997,7 @@  discard block
 block discarded – undo
997 997
 	$n = sql_fetsel(
998 998
 		'A.id_article',
999 999
 		'spip_auteurs_liens AS L LEFT JOIN spip_articles AS A ON (L.objet=\'article\' AND L.id_objet=A.id_article)',
1000
-		"A.statut='publie' AND L.id_auteur=" . sql_quote($id)
1000
+		"A.statut='publie' AND L.id_auteur=".sql_quote($id)
1001 1001
 	);
1002 1002
 
1003 1003
 	return (bool) $n;
@@ -1195,7 +1195,7 @@  discard block
 block discarded – undo
1195 1195
 		&& ($r = sql_allfetsel(
1196 1196
 			'id_objet',
1197 1197
 			'spip_auteurs_liens',
1198
-			'id_auteur=' . (int) $id_auteur . " AND objet='rubrique' AND id_objet!=0"
1198
+			'id_auteur='.(int) $id_auteur." AND objet='rubrique' AND id_objet!=0"
1199 1199
 		))
1200 1200
 		&& (is_countable($r) ? count($r) : 0)
1201 1201
 	) {
@@ -1872,8 +1872,8 @@  discard block
 block discarded – undo
1872 1872
 function auteurs_objet($objet, $id_objet, $cond = '') {
1873 1873
 	$objet = objet_type($objet);
1874 1874
 	$where = [
1875
-		'objet=' . sql_quote($objet),
1876
-		'id_objet=' . (int) $id_objet
1875
+		'objet='.sql_quote($objet),
1876
+		'id_objet='.(int) $id_objet
1877 1877
 	];
1878 1878
 	if (!empty($cond)) {
1879 1879
 		if (is_array($cond)) {
Please login to merge, or discard this patch.
ecrire/inc/layer.php 2 patches
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 		$class = ' blocreplie';
53 53
 	}
54 54
 
55
-	return '<div ' . ($id ? "id='$id' " : '') . "class='bloc_depliable$class'>";
55
+	return '<div '.($id ? "id='$id' " : '')."class='bloc_depliable$class'>";
56 56
 }
57 57
 
58 58
 function fin_block() {
@@ -63,12 +63,12 @@  discard block
 block discarded – undo
63 63
 // $deplie : true (deplie) ou false (plie) ou -1 (inactif) ou 'incertain' pour que le bouton s'auto init au chargement de la page
64 64
 // $ids : id des div lies au bouton (facultatif, par defaut c'est le div.bloc_depliable qui suit)
65 65
 function bouton_block_depliable($texte, $deplie, $ids = '') {
66
-	$bouton_id = 'b' . substr(md5($texte . microtime()), 0, 8);
66
+	$bouton_id = 'b'.substr(md5($texte.microtime()), 0, 8);
67 67
 
68 68
 	$class = ($deplie === true) ? ' deplie' : (($deplie == -1) ? ' impliable' : ' replie');
69 69
 	if (strlen((string) $ids)) {
70 70
 		$cible = explode(',', (string) $ids);
71
-		$cible = '#' . implode(',#', $cible);
71
+		$cible = '#'.implode(',#', $cible);
72 72
 	} else {
73 73
 		$cible = "#$bouton_id + div.bloc_depliable";
74 74
 	}
Please login to merge, or discard this patch.
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 \***************************************************************************/
11 11
 
12 12
 if (!defined('_ECRIRE_INC_VERSION')) {
13
-	return;
13
+    return;
14 14
 }
15 15
 
16 16
 /**
@@ -25,68 +25,68 @@  discard block
 block discarded – undo
25 25
  * @return string Code HTML du cadre dépliable
26 26
  **/
27 27
 function cadre_depliable($icone, $titre, $deplie, $contenu, $ids = '', $style_cadre = 'r') {
28
-	$bouton = bouton_block_depliable($titre, $deplie, $ids);
28
+    $bouton = bouton_block_depliable($titre, $deplie, $ids);
29 29
 
30
-	return
31
-		debut_cadre($style_cadre, $icone, '', $bouton, '', '', false)
32
-		. debut_block_depliable($deplie, $ids)
33
-		. "<div class='cadre_padding'>\n"
34
-		. $contenu
35
-		. "</div>\n"
36
-		. fin_block()
37
-		. fin_cadre();
30
+    return
31
+        debut_cadre($style_cadre, $icone, '', $bouton, '', '', false)
32
+        . debut_block_depliable($deplie, $ids)
33
+        . "<div class='cadre_padding'>\n"
34
+        . $contenu
35
+        . "</div>\n"
36
+        . fin_block()
37
+        . fin_cadre();
38 38
 }
39 39
 
40 40
 function block_parfois_visible($nom, $invite, $masque, $style = '', $visible = false) {
41
-	return "\n"
42
-	. bouton_block_depliable($invite, $visible, $nom)
43
-	. debut_block_depliable($visible, $nom)
44
-	. $masque
45
-	. fin_block();
41
+    return "\n"
42
+    . bouton_block_depliable($invite, $visible, $nom)
43
+    . debut_block_depliable($visible, $nom)
44
+    . $masque
45
+    . fin_block();
46 46
 }
47 47
 
48 48
 function debut_block_depliable($deplie, $id = '') {
49
-	$class = ' blocdeplie';
50
-	// si on n'accepte pas js, ne pas fermer
51
-	if (!$deplie) {
52
-		$class = ' blocreplie';
53
-	}
49
+    $class = ' blocdeplie';
50
+    // si on n'accepte pas js, ne pas fermer
51
+    if (!$deplie) {
52
+        $class = ' blocreplie';
53
+    }
54 54
 
55
-	return '<div ' . ($id ? "id='$id' " : '') . "class='bloc_depliable$class'>";
55
+    return '<div ' . ($id ? "id='$id' " : '') . "class='bloc_depliable$class'>";
56 56
 }
57 57
 
58 58
 function fin_block() {
59
-	return "<div class='nettoyeur'></div>\n</div>";
59
+    return "<div class='nettoyeur'></div>\n</div>";
60 60
 }
61 61
 
62 62
 // $texte : texte du bouton
63 63
 // $deplie : true (deplie) ou false (plie) ou -1 (inactif) ou 'incertain' pour que le bouton s'auto init au chargement de la page
64 64
 // $ids : id des div lies au bouton (facultatif, par defaut c'est le div.bloc_depliable qui suit)
65 65
 function bouton_block_depliable($texte, $deplie, $ids = '') {
66
-	$bouton_id = 'b' . substr(md5($texte . microtime()), 0, 8);
66
+    $bouton_id = 'b' . substr(md5($texte . microtime()), 0, 8);
67 67
 
68
-	$class = ($deplie === true) ? ' deplie' : (($deplie == -1) ? ' impliable' : ' replie');
69
-	if (strlen((string) $ids)) {
70
-		$cible = explode(',', (string) $ids);
71
-		$cible = '#' . implode(',#', $cible);
72
-	} else {
73
-		$cible = "#$bouton_id + div.bloc_depliable";
74
-	}
68
+    $class = ($deplie === true) ? ' deplie' : (($deplie == -1) ? ' impliable' : ' replie');
69
+    if (strlen((string) $ids)) {
70
+        $cible = explode(',', (string) $ids);
71
+        $cible = '#' . implode(',#', $cible);
72
+    } else {
73
+        $cible = "#$bouton_id + div.bloc_depliable";
74
+    }
75 75
 
76
-	$b = (str_contains((string) $texte, '<h') ? 'div' : 'h3');
76
+    $b = (str_contains((string) $texte, '<h') ? 'div' : 'h3');
77 77
 
78
-	return "<$b "
79
-	. ($bouton_id ? "id='$bouton_id' " : '')
80
-	. "class='titrem$class'"
81
-	. (($deplie === -1)
82
-		? ''
83
-		: " onmouseover=\"jQuery(this).depliant('$cible');\""
84
-	)
85
-	. '>'
86
-	// une ancre pour rendre accessible au clavier le depliage du sous bloc
87
-	. "<a href='#' onclick=\"return jQuery(this).depliant_clicancre('$cible');\" class='titremancre'></a>"
88
-	. "$texte</$b>"
89
-	. http_script(($deplie === 'incertain')
90
-		? "jQuery(function($){if ($('$cible').is(':visible')) { $('#$bouton_id').addClass('deplie').removeClass('replie'); }});"
91
-		: '');
78
+    return "<$b "
79
+    . ($bouton_id ? "id='$bouton_id' " : '')
80
+    . "class='titrem$class'"
81
+    . (($deplie === -1)
82
+        ? ''
83
+        : " onmouseover=\"jQuery(this).depliant('$cible');\""
84
+    )
85
+    . '>'
86
+    // une ancre pour rendre accessible au clavier le depliage du sous bloc
87
+    . "<a href='#' onclick=\"return jQuery(this).depliant_clicancre('$cible');\" class='titremancre'></a>"
88
+    . "$texte</$b>"
89
+    . http_script(($deplie === 'incertain')
90
+        ? "jQuery(function($){if ($('$cible').is(':visible')) { $('#$bouton_id').addClass('deplie').removeClass('replie'); }});"
91
+        : '');
92 92
 }
Please login to merge, or discard this patch.
ecrire/inc/couleurs.php 2 patches
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  */
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -37,70 +37,70 @@  discard block
 block discarded – undo
37 37
  * @return array|string
38 38
  */
39 39
 function inc_couleurs_dist($choix = null, $ajouter = false) {
40
-	static $couleurs_spip = [
41
-		// Violet soutenu
42
-		9 => ['couleur_theme' => '#9a6ef2'],
43
-		// Violet rosé
44
-		4 => ['couleur_theme' => '#c464cb'],
45
-		// Rose interface SPIP
46
-		2 => ['couleur_theme' =>  '#F02364'],
47
-		// Rouge
48
-		8 => ['couleur_theme' => '#ff4524'],
49
-		// Orange
50
-		3 => ['couleur_theme' => '#c97500'],
51
-		// Vert SPIP
52
-		1 => ['couleur_theme' => '#9dba00'],
53
-		// Vert Troglo
54
-		7 => ['couleur_theme' => '#419a2c'],
55
-		// Bleu-vert
56
-		12 => ['couleur_theme' => '#269681'],
57
-		//  Bleu pastel
58
-		5 => ['couleur_theme' => '#3190ae'],
59
-		//  Bleu Kermesse
60
-		11 => ['couleur_theme' => '#288bdd'],
61
-		//  Gris bleuté
62
-		6 => ['couleur_theme' => '#7d90a2'],
63
-		//  Gris
64
-		10 => ['couleur_theme' => '#909090'],
65
-	];
40
+    static $couleurs_spip = [
41
+        // Violet soutenu
42
+        9 => ['couleur_theme' => '#9a6ef2'],
43
+        // Violet rosé
44
+        4 => ['couleur_theme' => '#c464cb'],
45
+        // Rose interface SPIP
46
+        2 => ['couleur_theme' =>  '#F02364'],
47
+        // Rouge
48
+        8 => ['couleur_theme' => '#ff4524'],
49
+        // Orange
50
+        3 => ['couleur_theme' => '#c97500'],
51
+        // Vert SPIP
52
+        1 => ['couleur_theme' => '#9dba00'],
53
+        // Vert Troglo
54
+        7 => ['couleur_theme' => '#419a2c'],
55
+        // Bleu-vert
56
+        12 => ['couleur_theme' => '#269681'],
57
+        //  Bleu pastel
58
+        5 => ['couleur_theme' => '#3190ae'],
59
+        //  Bleu Kermesse
60
+        11 => ['couleur_theme' => '#288bdd'],
61
+        //  Gris bleuté
62
+        6 => ['couleur_theme' => '#7d90a2'],
63
+        //  Gris
64
+        10 => ['couleur_theme' => '#909090'],
65
+    ];
66 66
 
67
-	if (is_numeric($choix)) {
68
-		$c = $couleurs_spip[$choix];
69
-		// compat < SPIP 3.3
70
-		include_spip('inc/filtres_images_mini');
71
-		$c['couleur_foncee'] = $c['couleur_theme'];
72
-		$c['couleur_claire'] = '#' . couleur_eclaircir($c['couleur_theme'], .5);
67
+    if (is_numeric($choix)) {
68
+        $c = $couleurs_spip[$choix];
69
+        // compat < SPIP 3.3
70
+        include_spip('inc/filtres_images_mini');
71
+        $c['couleur_foncee'] = $c['couleur_theme'];
72
+        $c['couleur_claire'] = '#' . couleur_eclaircir($c['couleur_theme'], .5);
73 73
 
74
-		return
75
-			'couleur_theme=' . substr((string) $c['couleur_theme'], 1)
76
-			// compat < SPIP 3.3
77
-			. '&couleur_claire=' . substr($c['couleur_claire'], 1)
78
-			. '&couleur_foncee=' . substr((string) $c['couleur_foncee'], 1);
79
-	} else {
80
-		if (is_array($choix)) {
81
-			// compat < SPIP 3.3
82
-			$compat_spip_33 = function ($c) {
83
-				if (!isset($c['couleur_theme'])) {
84
-					$c['couleur_theme'] = $c['couleur_foncee'];
85
-					unset($c['couleur_foncee']);
86
-					unset($c['couleur_claire']);
87
-					unset($c['couleur_lien']);
88
-					unset($c['couleur_lien_off']);
89
-				}
90
-				return $c;
91
-			};
92
-			if ($ajouter) {
93
-				foreach ($choix as $c) {
94
-					$couleurs_spip[] = $compat_spip_33($c);
95
-				}
74
+        return
75
+            'couleur_theme=' . substr((string) $c['couleur_theme'], 1)
76
+            // compat < SPIP 3.3
77
+            . '&couleur_claire=' . substr($c['couleur_claire'], 1)
78
+            . '&couleur_foncee=' . substr((string) $c['couleur_foncee'], 1);
79
+    } else {
80
+        if (is_array($choix)) {
81
+            // compat < SPIP 3.3
82
+            $compat_spip_33 = function ($c) {
83
+                if (!isset($c['couleur_theme'])) {
84
+                    $c['couleur_theme'] = $c['couleur_foncee'];
85
+                    unset($c['couleur_foncee']);
86
+                    unset($c['couleur_claire']);
87
+                    unset($c['couleur_lien']);
88
+                    unset($c['couleur_lien_off']);
89
+                }
90
+                return $c;
91
+            };
92
+            if ($ajouter) {
93
+                foreach ($choix as $c) {
94
+                    $couleurs_spip[] = $compat_spip_33($c);
95
+                }
96 96
 
97
-				return $couleurs_spip;
98
-			} else {
99
-				$choix = array_map($compat_spip_33, $choix);
100
-				return $couleurs_spip = $choix;
101
-			}
102
-		}
103
-	}
97
+                return $couleurs_spip;
98
+            } else {
99
+                $choix = array_map($compat_spip_33, $choix);
100
+                return $couleurs_spip = $choix;
101
+            }
102
+        }
103
+    }
104 104
 
105
-	return $couleurs_spip;
105
+    return $couleurs_spip;
106 106
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -69,17 +69,17 @@
 block discarded – undo
69 69
 		// compat < SPIP 3.3
70 70
 		include_spip('inc/filtres_images_mini');
71 71
 		$c['couleur_foncee'] = $c['couleur_theme'];
72
-		$c['couleur_claire'] = '#' . couleur_eclaircir($c['couleur_theme'], .5);
72
+		$c['couleur_claire'] = '#'.couleur_eclaircir($c['couleur_theme'], .5);
73 73
 
74 74
 		return
75
-			'couleur_theme=' . substr((string) $c['couleur_theme'], 1)
75
+			'couleur_theme='.substr((string) $c['couleur_theme'], 1)
76 76
 			// compat < SPIP 3.3
77
-			. '&couleur_claire=' . substr($c['couleur_claire'], 1)
78
-			. '&couleur_foncee=' . substr((string) $c['couleur_foncee'], 1);
77
+			. '&couleur_claire='.substr($c['couleur_claire'], 1)
78
+			. '&couleur_foncee='.substr((string) $c['couleur_foncee'], 1);
79 79
 	} else {
80 80
 		if (is_array($choix)) {
81 81
 			// compat < SPIP 3.3
82
-			$compat_spip_33 = function ($c) {
82
+			$compat_spip_33 = function($c) {
83 83
 				if (!isset($c['couleur_theme'])) {
84 84
 					$c['couleur_theme'] = $c['couleur_foncee'];
85 85
 					unset($c['couleur_foncee']);
Please login to merge, or discard this patch.
ecrire/inc/actions.php 2 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  **/
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -42,9 +42,9 @@  discard block
 block discarded – undo
42 42
  *     URL, code HTML du formulaire ou tableau (action, arg, hash)
43 43
  */
44 44
 function generer_action_auteur($action, $arg = '', $redirect = '', $mode = false, $att = '', $public = false) {
45
-	$securiser_action = charger_fonction('securiser_action', 'inc');
45
+    $securiser_action = charger_fonction('securiser_action', 'inc');
46 46
 
47
-	return $securiser_action($action, $arg, $redirect, $mode, $att, $public);
47
+    return $securiser_action($action, $arg, $redirect, $mode, $att, $public);
48 48
 }
49 49
 
50 50
 /**
@@ -77,9 +77,9 @@  discard block
 block discarded – undo
77 77
  *     Code HTML du formulaire
78 78
  */
79 79
 function redirige_action_auteur($action, $arg, $ret, $gra = '', $mode = false, $atts = '', $public = false) {
80
-	$r = ($public ? _DIR_RESTREINT_ABS : _DIR_RESTREINT) . generer_url_ecrire($ret, $gra, true, true);
80
+    $r = ($public ? _DIR_RESTREINT_ABS : _DIR_RESTREINT) . generer_url_ecrire($ret, $gra, true, true);
81 81
 
82
-	return generer_action_auteur($action, $arg, $r, $mode, $atts, $public);
82
+    return generer_action_auteur($action, $arg, $r, $mode, $atts, $public);
83 83
 }
84 84
 
85 85
 /**
@@ -104,9 +104,9 @@  discard block
 block discarded – undo
104 104
  *     URL, code HTML du formulaire ou tableau (action, arg, hash)
105 105
  */
106 106
 function redirige_action_post($action, $arg, $ret, $gra, $corps, $att = '') {
107
-	$r = _DIR_RESTREINT . generer_url_ecrire($ret, $gra, false, true);
107
+    $r = _DIR_RESTREINT . generer_url_ecrire($ret, $gra, false, true);
108 108
 
109
-	return generer_action_auteur($action, $arg, $r, $corps, $att . " method='post'");
109
+    return generer_action_auteur($action, $arg, $r, $corps, $att . " method='post'");
110 110
 }
111 111
 
112 112
 
@@ -123,26 +123,26 @@  discard block
 block discarded – undo
123 123
  *   passer "text/html" comme $content_type
124 124
  */
125 125
 function ajax_retour($corps, $content_type = null): void {
126
-	$xml = false;
127
-	if (is_null($content_type) || $content_type === true) {
128
-		$xml = true;
129
-		$content_type = 'text/html';
130
-	} elseif (!$content_type || !is_string($content_type) || !str_contains($content_type, '/')) {
131
-		$content_type = 'text/html';
132
-	}
126
+    $xml = false;
127
+    if (is_null($content_type) || $content_type === true) {
128
+        $xml = true;
129
+        $content_type = 'text/html';
130
+    } elseif (!$content_type || !is_string($content_type) || !str_contains($content_type, '/')) {
131
+        $content_type = 'text/html';
132
+    }
133 133
 
134
-	$e = '';
135
-	if (
136
-		isset($_COOKIE['spip_admin'])
137
-		&& (_request('var_mode') == 'debug' || !empty($GLOBALS['tableau_des_temps']))
138
-	) {
139
-		$e = erreur_squelette();
140
-	}
134
+    $e = '';
135
+    if (
136
+        isset($_COOKIE['spip_admin'])
137
+        && (_request('var_mode') == 'debug' || !empty($GLOBALS['tableau_des_temps']))
138
+    ) {
139
+        $e = erreur_squelette();
140
+    }
141 141
 
142
-	$c = $GLOBALS['meta']['charset'];
143
-	header('Content-Type: ' . $content_type . '; charset=' . $c);
144
-	$debut = (($xml && strlen(trim($corps))) ? '<' . "?xml version='1.0' encoding='" . $c . "'?" . ">\n" : '');
145
-	$fin = '';
142
+    $c = $GLOBALS['meta']['charset'];
143
+    header('Content-Type: ' . $content_type . '; charset=' . $c);
144
+    $debut = (($xml && strlen(trim($corps))) ? '<' . "?xml version='1.0' encoding='" . $c . "'?" . ">\n" : '');
145
+    $fin = '';
146 146
 
147
-	echo $debut, $corps, $fin, $e;
147
+    echo $debut, $corps, $fin, $e;
148 148
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
  *     Code HTML du formulaire
78 78
  */
79 79
 function redirige_action_auteur($action, $arg, $ret, $gra = '', $mode = false, $atts = '', $public = false) {
80
-	$r = ($public ? _DIR_RESTREINT_ABS : _DIR_RESTREINT) . generer_url_ecrire($ret, $gra, true, true);
80
+	$r = ($public ? _DIR_RESTREINT_ABS : _DIR_RESTREINT).generer_url_ecrire($ret, $gra, true, true);
81 81
 
82 82
 	return generer_action_auteur($action, $arg, $r, $mode, $atts, $public);
83 83
 }
@@ -104,9 +104,9 @@  discard block
 block discarded – undo
104 104
  *     URL, code HTML du formulaire ou tableau (action, arg, hash)
105 105
  */
106 106
 function redirige_action_post($action, $arg, $ret, $gra, $corps, $att = '') {
107
-	$r = _DIR_RESTREINT . generer_url_ecrire($ret, $gra, false, true);
107
+	$r = _DIR_RESTREINT.generer_url_ecrire($ret, $gra, false, true);
108 108
 
109
-	return generer_action_auteur($action, $arg, $r, $corps, $att . " method='post'");
109
+	return generer_action_auteur($action, $arg, $r, $corps, $att." method='post'");
110 110
 }
111 111
 
112 112
 
@@ -140,8 +140,8 @@  discard block
 block discarded – undo
140 140
 	}
141 141
 
142 142
 	$c = $GLOBALS['meta']['charset'];
143
-	header('Content-Type: ' . $content_type . '; charset=' . $c);
144
-	$debut = (($xml && strlen(trim($corps))) ? '<' . "?xml version='1.0' encoding='" . $c . "'?" . ">\n" : '');
143
+	header('Content-Type: '.$content_type.'; charset='.$c);
144
+	$debut = (($xml && strlen(trim($corps))) ? '<'."?xml version='1.0' encoding='".$c."'?".">\n" : '');
145 145
 	$fin = '';
146 146
 
147 147
 	echo $debut, $corps, $fin, $e;
Please login to merge, or discard this patch.
ecrire/inc/cvt_autosave.php 2 patches
Indentation   +73 added lines, -73 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  */
17 17
 
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
  * @return string
27 27
  */
28 28
 function autosave_clean_value($val) {
29
-	return stripslashes(urldecode((string) $val));
29
+    return stripslashes(urldecode((string) $val));
30 30
 }
31 31
 
32 32
 /**
@@ -37,58 +37,58 @@  discard block
 block discarded – undo
37 37
  * @return array
38 38
  */
39 39
 function cvtautosave_formulaire_charger($flux) {
40
-	if (
41
-		is_array($flux['data'])
42
-		&& isset($flux['data']['_autosave_id'])
43
-		&& ($cle_autosave = $flux['data']['_autosave_id'])
44
-	) {
45
-		$form = $flux['args']['form'];
46
-		$je_suis_poste = $flux['args']['je_suis_poste'];
40
+    if (
41
+        is_array($flux['data'])
42
+        && isset($flux['data']['_autosave_id'])
43
+        && ($cle_autosave = $flux['data']['_autosave_id'])
44
+    ) {
45
+        $form = $flux['args']['form'];
46
+        $je_suis_poste = $flux['args']['je_suis_poste'];
47 47
 
48
-		$cle_autosave = serialize($cle_autosave);
49
-		$cle_autosave = $form . '_' . md5($cle_autosave);
48
+        $cle_autosave = serialize($cle_autosave);
49
+        $cle_autosave = $form . '_' . md5($cle_autosave);
50 50
 
51
-		// si on a un backup en session et qu'on est au premier chargement, non poste
52
-		// on restitue les donnees
53
-		if (
54
-			isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])
55
-			&& !$je_suis_poste
56
-		) {
57
-			parse_str((string) $GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave], $vars);
58
-			foreach ($vars as $key => $val) {
59
-				if (isset($flux['data'][$key])) {
60
-					$flux['data'][$key] = (is_string($val) ? autosave_clean_value($val) : array_map(
61
-						'autosave_clean_value',
62
-						$val
63
-					));
64
-				}
65
-			}
66
-		}
51
+        // si on a un backup en session et qu'on est au premier chargement, non poste
52
+        // on restitue les donnees
53
+        if (
54
+            isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])
55
+            && !$je_suis_poste
56
+        ) {
57
+            parse_str((string) $GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave], $vars);
58
+            foreach ($vars as $key => $val) {
59
+                if (isset($flux['data'][$key])) {
60
+                    $flux['data'][$key] = (is_string($val) ? autosave_clean_value($val) : array_map(
61
+                        'autosave_clean_value',
62
+                        $val
63
+                    ));
64
+                }
65
+            }
66
+        }
67 67
 
68
-		// si on est dans le charger() qui suit le traiter(), l'autosave a normalement ete vide
69
-		// mais si il y a plusieurs sessions il peut y avoir concurrence et un retour de l'autosave
70
-		if ($je_suis_poste && _request('autosave') === $cle_autosave && function_exists('terminer_actualiser_sessions')) {
71
-			terminer_actualiser_sessions();
72
-			// et verifions si jamais l'autosave a fait un come back, dans ce cas on le revide
73
-			if (isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])) {
74
-				session_set('session_autosave_' . $cle_autosave, null);
75
-				// en court sleep pour etre certain que la concurrence est finie
76
-				sleep(1);
77
-				terminer_actualiser_sessions();
78
-			}
79
-		}
68
+        // si on est dans le charger() qui suit le traiter(), l'autosave a normalement ete vide
69
+        // mais si il y a plusieurs sessions il peut y avoir concurrence et un retour de l'autosave
70
+        if ($je_suis_poste && _request('autosave') === $cle_autosave && function_exists('terminer_actualiser_sessions')) {
71
+            terminer_actualiser_sessions();
72
+            // et verifions si jamais l'autosave a fait un come back, dans ce cas on le revide
73
+            if (isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])) {
74
+                session_set('session_autosave_' . $cle_autosave, null);
75
+                // en court sleep pour etre certain que la concurrence est finie
76
+                sleep(1);
77
+                terminer_actualiser_sessions();
78
+            }
79
+        }
80 80
 
81 81
 
82
-		/**
83
-		 * Envoyer le input hidden et le bout de js qui l'utilisera
84
-		 */
85
-		$flux['data']['_hidden'] .= "<input type='hidden' name='autosave' class='autosaveactive' value='$cle_autosave' />"
86
-			. '<script type="text/javascript">/*<![CDATA[*/if (window.jQuery) jQuery(function(){
82
+        /**
83
+         * Envoyer le input hidden et le bout de js qui l'utilisera
84
+         */
85
+        $flux['data']['_hidden'] .= "<input type='hidden' name='autosave' class='autosaveactive' value='$cle_autosave' />"
86
+            . '<script type="text/javascript">/*<![CDATA[*/if (window.jQuery) jQuery(function(){
87 87
 		  $("input.autosaveactive").closest("form:not(.autosaveon)").autosave({url:"' . $GLOBALS['meta']['adresse_site'] . '/"}).addClass("autosaveon");
88 88
 			});/*]]>*/</script>';
89
-	}
89
+    }
90 90
 
91
-	return $flux;
91
+    return $flux;
92 92
 }
93 93
 
94 94
 /**
@@ -102,33 +102,33 @@  discard block
 block discarded – undo
102 102
  * @return array
103 103
  */
104 104
 function cvtautosave_formulaire_traiter($flux) {
105
-	// si on poste 'autosave' c'est qu'on n'a plus besoin de sauvegarder :
106
-	// on elimine les donnees de la session
107
-	if ($cle_autosave = _request('autosave')) {
108
-		include_spip('inc/session');
109
-		session_set('session_autosave_' . $cle_autosave, null);
110
-	}
105
+    // si on poste 'autosave' c'est qu'on n'a plus besoin de sauvegarder :
106
+    // on elimine les donnees de la session
107
+    if ($cle_autosave = _request('autosave')) {
108
+        include_spip('inc/session');
109
+        session_set('session_autosave_' . $cle_autosave, null);
110
+    }
111 111
 
112
-	if (isset($GLOBALS['visiteur_session']) && $GLOBALS['visiteur_session']) {
113
-		// delai par defaut avant purge d'un backup de form : 72H
114
-		if (!defined('_AUTOSAVE_GB_DELAY')) {
115
-			define('_AUTOSAVE_GB_DELAY', 72 * 3600);
116
-		}
117
-		$time_too_old = time() - _AUTOSAVE_GB_DELAY;
118
-		// purger aussi toutes les vieilles autosave
119
-		$session = $GLOBALS['visiteur_session'];
120
-		foreach ($session as $k => $v) {
121
-			if (str_starts_with((string) $k, 'session_autosave_')) {
122
-				$timestamp = 0;
123
-				if (preg_match(',&__timestamp=(\d+)$,', (string) $v, $m)) {
124
-					$timestamp = (int) $m[1];
125
-				}
126
-				if ($timestamp < $time_too_old) {
127
-					session_set($k, null);
128
-				}
129
-			}
130
-		}
131
-	}
112
+    if (isset($GLOBALS['visiteur_session']) && $GLOBALS['visiteur_session']) {
113
+        // delai par defaut avant purge d'un backup de form : 72H
114
+        if (!defined('_AUTOSAVE_GB_DELAY')) {
115
+            define('_AUTOSAVE_GB_DELAY', 72 * 3600);
116
+        }
117
+        $time_too_old = time() - _AUTOSAVE_GB_DELAY;
118
+        // purger aussi toutes les vieilles autosave
119
+        $session = $GLOBALS['visiteur_session'];
120
+        foreach ($session as $k => $v) {
121
+            if (str_starts_with((string) $k, 'session_autosave_')) {
122
+                $timestamp = 0;
123
+                if (preg_match(',&__timestamp=(\d+)$,', (string) $v, $m)) {
124
+                    $timestamp = (int) $m[1];
125
+                }
126
+                if ($timestamp < $time_too_old) {
127
+                    session_set($k, null);
128
+                }
129
+            }
130
+        }
131
+    }
132 132
 
133
-	return $flux;
133
+    return $flux;
134 134
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -46,15 +46,15 @@  discard block
 block discarded – undo
46 46
 		$je_suis_poste = $flux['args']['je_suis_poste'];
47 47
 
48 48
 		$cle_autosave = serialize($cle_autosave);
49
-		$cle_autosave = $form . '_' . md5($cle_autosave);
49
+		$cle_autosave = $form.'_'.md5($cle_autosave);
50 50
 
51 51
 		// si on a un backup en session et qu'on est au premier chargement, non poste
52 52
 		// on restitue les donnees
53 53
 		if (
54
-			isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])
54
+			isset($GLOBALS['visiteur_session']['session_autosave_'.$cle_autosave])
55 55
 			&& !$je_suis_poste
56 56
 		) {
57
-			parse_str((string) $GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave], $vars);
57
+			parse_str((string) $GLOBALS['visiteur_session']['session_autosave_'.$cle_autosave], $vars);
58 58
 			foreach ($vars as $key => $val) {
59 59
 				if (isset($flux['data'][$key])) {
60 60
 					$flux['data'][$key] = (is_string($val) ? autosave_clean_value($val) : array_map(
@@ -70,8 +70,8 @@  discard block
 block discarded – undo
70 70
 		if ($je_suis_poste && _request('autosave') === $cle_autosave && function_exists('terminer_actualiser_sessions')) {
71 71
 			terminer_actualiser_sessions();
72 72
 			// et verifions si jamais l'autosave a fait un come back, dans ce cas on le revide
73
-			if (isset($GLOBALS['visiteur_session']['session_autosave_' . $cle_autosave])) {
74
-				session_set('session_autosave_' . $cle_autosave, null);
73
+			if (isset($GLOBALS['visiteur_session']['session_autosave_'.$cle_autosave])) {
74
+				session_set('session_autosave_'.$cle_autosave, null);
75 75
 				// en court sleep pour etre certain que la concurrence est finie
76 76
 				sleep(1);
77 77
 				terminer_actualiser_sessions();
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 		 */
85 85
 		$flux['data']['_hidden'] .= "<input type='hidden' name='autosave' class='autosaveactive' value='$cle_autosave' />"
86 86
 			. '<script type="text/javascript">/*<![CDATA[*/if (window.jQuery) jQuery(function(){
87
-		  $("input.autosaveactive").closest("form:not(.autosaveon)").autosave({url:"' . $GLOBALS['meta']['adresse_site'] . '/"}).addClass("autosaveon");
87
+		  $("input.autosaveactive").closest("form:not(.autosaveon)").autosave({url:"' . $GLOBALS['meta']['adresse_site'].'/"}).addClass("autosaveon");
88 88
 			});/*]]>*/</script>';
89 89
 	}
90 90
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	// on elimine les donnees de la session
107 107
 	if ($cle_autosave = _request('autosave')) {
108 108
 		include_spip('inc/session');
109
-		session_set('session_autosave_' . $cle_autosave, null);
109
+		session_set('session_autosave_'.$cle_autosave, null);
110 110
 	}
111 111
 
112 112
 	if (isset($GLOBALS['visiteur_session']) && $GLOBALS['visiteur_session']) {
Please login to merge, or discard this patch.
ecrire/inc/filtres.php 3 patches
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -615,8 +615,7 @@  discard block
 block discarded – undo
615 615
 			if (!$srcSize) {
616 616
 				$poids_img[$src] = filesize($src);
617 617
 			}
618
-		}
619
-		elseif (str_contains($src, '<svg')) {
618
+		} elseif (str_contains($src, '<svg')) {
620 619
 			include_spip('inc/svg');
621 620
 			if ($attrs = svg_lire_attributs($src)) {
622 621
 				[$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs);
@@ -3421,8 +3420,7 @@  discard block
 block discarded – undo
3421 3420
 	}
3422 3421
 	if (!isset($options['chemin_image']) || $options['chemin_image'] == true) {
3423 3422
 		$img_file = chemin_image($img);
3424
-	}
3425
-	else {
3423
+	} else {
3426 3424
 		if (!isset($options['variante_svg_si_possible']) || $options['variante_svg_si_possible'] == true) {
3427 3425
 			$img_file = http_img_variante_svg_si_possible($img_file);
3428 3426
 		}
@@ -3449,11 +3447,9 @@  discard block
 block discarded – undo
3449 3447
 	}
3450 3448
 	if ($alt === false) {
3451 3449
 		$alt = '';
3452
-	}
3453
-	elseif ($alt || $alt === '') {
3450
+	} elseif ($alt || $alt === '') {
3454 3451
 		$alt = " alt='" . attribut_html($alt) . "'";
3455
-	}
3456
-	else {
3452
+	} else {
3457 3453
 		$alt = " alt='" . attribut_html($title) . "'";
3458 3454
 	}
3459 3455
 	return "<img src='" . attribut_html($img_file) . "'$alt"
@@ -3580,8 +3576,7 @@  discard block
 block discarded – undo
3580 3576
 		if (!is_null($class)) {
3581 3577
 			$img = strlen((string) $class) ? inserer_attribut($img, 'class', $class) : vider_attribut($img, 'class');
3582 3578
 		}
3583
-	}
3584
-	else {
3579
+	} else {
3585 3580
 		$img = http_img_pack(
3586 3581
 			$img,
3587 3582
 			$alt,
@@ -3689,8 +3684,7 @@  discard block
 block discarded – undo
3689 3684
 		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3690 3685
 		$title = "<title id=\"$id\">" . entites_html($alt) . "</title>\n";
3691 3686
 		$balise_svg .= $title;
3692
-	}
3693
-	else {
3687
+	} else {
3694 3688
 		$balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3695 3689
 	}
3696 3690
 
@@ -5081,8 +5075,7 @@  discard block
 block discarded – undo
5081 5075
 	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
5082 5076
 	if (isset($options['hash_on_content']) && $options['hash_on_content']) {
5083 5077
 		$hash = md5((string) ($contexte_implicite['host'] . '::' . $cache));
5084
-	}
5085
-	else {
5078
+	} else {
5086 5079
 		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
5087 5080
 		ksort($contexte);
5088 5081
 		$hash = md5($fond . json_encode($contexte_implicite, JSON_THROW_ON_ERROR) . json_encode($contexte, JSON_THROW_ON_ERROR) . $connect);
Please login to merge, or discard this patch.
Spacing   +118 added lines, -119 removed lines patch added patch discarded remove patch
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
 	}
101 101
 
102 102
 	include_fichiers_fonctions();
103
-	foreach (['filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc] as $f) {
103
+	foreach (['filtre_'.$fonc, 'filtre_'.$fonc.'_dist', $fonc] as $f) {
104 104
 		trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels
105 105
 		if (is_callable($f)) {
106 106
 			return $f;
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 	// affichage "GIT [master: abcdef]"
236 236
 	$commit = $desc['commit_short'] ?? $desc['commit'];
237 237
 	if ($desc['branch']) {
238
-		$commit = $desc['branch'] . ': ' . $commit;
238
+		$commit = $desc['branch'].': '.$commit;
239 239
 	}
240 240
 	return "{$desc['vcs']} [$commit]";
241 241
 }
@@ -256,9 +256,9 @@  discard block
 block discarded – undo
256 256
 	}
257 257
 
258 258
 	// version installee par GIT
259
-	if (lire_fichier($dir . '/.git/HEAD', $c)) {
259
+	if (lire_fichier($dir.'/.git/HEAD', $c)) {
260 260
 		$currentHead = trim(substr((string) $c, 4));
261
-		if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
261
+		if (lire_fichier($dir.'/.git/'.$currentHead, $hash)) {
262 262
 			return [
263 263
 				'vcs' => 'GIT',
264 264
 				'branch' => basename($currentHead),
@@ -273,12 +273,12 @@  discard block
 block discarded – undo
273 273
 
274 274
 // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images
275 275
 // et laisser passer les fonctions personnelles baptisees image_...
276
-$GLOBALS['spip_matrice']['image_graver'] = true;//'inc/filtres_images_mini.php';
277
-$GLOBALS['spip_matrice']['image_select'] = true;//'inc/filtres_images_mini.php';
278
-$GLOBALS['spip_matrice']['image_reduire'] = true;//'inc/filtres_images_mini.php';
279
-$GLOBALS['spip_matrice']['image_reduire_par'] = true;//'inc/filtres_images_mini.php';
280
-$GLOBALS['spip_matrice']['image_passe_partout'] = true;//'inc/filtres_images_mini.php';
281
-$GLOBALS['spip_matrice']['image_recadre_avec_fallback'] = true;//'inc/filtres_images_mini.php';
276
+$GLOBALS['spip_matrice']['image_graver'] = true; //'inc/filtres_images_mini.php';
277
+$GLOBALS['spip_matrice']['image_select'] = true; //'inc/filtres_images_mini.php';
278
+$GLOBALS['spip_matrice']['image_reduire'] = true; //'inc/filtres_images_mini.php';
279
+$GLOBALS['spip_matrice']['image_reduire_par'] = true; //'inc/filtres_images_mini.php';
280
+$GLOBALS['spip_matrice']['image_passe_partout'] = true; //'inc/filtres_images_mini.php';
281
+$GLOBALS['spip_matrice']['image_recadre_avec_fallback'] = true; //'inc/filtres_images_mini.php';
282 282
 
283 283
 $GLOBALS['spip_matrice']['couleur_html_to_hex'] = 'inc/filtres_images_mini.php';
284 284
 $GLOBALS['spip_matrice']['couleur_hex_to_hsl'] = 'inc/filtres_images_mini.php';
@@ -437,8 +437,8 @@  discard block
 block discarded – undo
437 437
  */
438 438
 function filtre_debug(mixed $val, $key = null) {
439 439
 	$debug = (
440
-		is_null($key) ? '' : (var_export($key, true) . ' = ')
441
-		) . var_export($val, true);
440
+		is_null($key) ? '' : (var_export($key, true).' = ')
441
+		).var_export($val, true);
442 442
 
443 443
 	include_spip('inc/autoriser');
444 444
 	if (autoriser('webmestre')) {
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 		$is_file = false;
495 495
 	}
496 496
 	if ($is_file) {
497
-		$is_local_file = function ($path) {
497
+		$is_local_file = function($path) {
498 498
 			if (str_contains($path, '?')) {
499 499
 				$path = supprimer_timestamp($path);
500 500
 				// remove ?24px added by find_in_theme on .svg files
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
 					&& preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)
543 543
 				) {
544 544
 					$srcover = $match[1];
545
-					$srcover_filter = $filtre("<img src='" . $match[1] . "' />", ...$args);
545
+					$srcover_filter = $filtre("<img src='".$match[1]."' />", ...$args);
546 546
 					$srcover_filter = extraire_attribut($srcover_filter, 'src');
547 547
 					$reduit = str_replace($srcover, $srcover_filter, (string) $reduit);
548 548
 				}
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
 	// " -> &quot; et tout ce genre de choses
944 944
 	$u = $GLOBALS['meta']['pcre_u'];
945 945
 	$texte = str_replace('&nbsp;', ' ', $texte);
946
-	$texte = preg_replace('/\s{2,}/S' . $u, ' ', $texte);
946
+	$texte = preg_replace('/\s{2,}/S'.$u, ' ', $texte);
947 947
 	// ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
948 948
 	$texte = entites_html($texte, false, false);
949 949
 	// mais bien echapper les double quotes !
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
 		return '';
1006 1006
 	}
1007 1007
 	return preg_replace(
1008
-		',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1008
+		',^[[:space:]]*([0-9]+)([.)]|'.chr(194).'?'.chr(176).')[[:space:]]+,S',
1009 1009
 		'',
1010 1010
 		$texte
1011 1011
 	);
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
 		return '';
1036 1036
 	}
1037 1037
 	if (preg_match(
1038
-			',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1038
+			',^[[:space:]]*([0-9]+)([.)]|'.chr(194).'?'.chr(176).')[[:space:]]+,S',
1039 1039
 			$texte,
1040 1040
 			$regs
1041 1041
 		)
@@ -1127,7 +1127,7 @@  discard block
 block discarded – undo
1127 1127
 		return '';
1128 1128
 	}
1129 1129
 	$u = $GLOBALS['meta']['pcre_u'];
1130
-	$texte = preg_replace('/\s+/S' . $u, ' ', $texte);
1130
+	$texte = preg_replace('/\s+/S'.$u, ' ', $texte);
1131 1131
 	$texte = preg_replace('/<(p|br)( [^>]*)?>/iS', "\n\n", $texte);
1132 1132
 	$texte = preg_replace("/^\n+/", '', $texte);
1133 1133
 	$texte = preg_replace("/\n+$/", '', $texte);
@@ -1165,7 +1165,7 @@  discard block
 block discarded – undo
1165 1165
 		)
1166 1166
 	) {
1167 1167
 		foreach ($liens[0] as $a) {
1168
-			$rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1168
+			$rel = 'noopener noreferrer '.extraire_attribut($a, 'rel');
1169 1169
 			$ablank = inserer_attribut($a, 'rel', $rel);
1170 1170
 			$ablank = inserer_attribut($ablank, 'target', '_blank');
1171 1171
 			$texte = str_replace($a, $ablank, $texte);
@@ -1193,7 +1193,7 @@  discard block
 block discarded – undo
1193 1193
 		foreach ($regs[0] as $a) {
1194 1194
 			$rel = extraire_attribut($a, 'rel') ?? '';
1195 1195
 			if (!str_contains($rel, 'nofollow')) {
1196
-				$rel = 'nofollow' . ($rel ? " $rel" : '');
1196
+				$rel = 'nofollow'.($rel ? " $rel" : '');
1197 1197
 				$anofollow = inserer_attribut($a, 'rel', $rel);
1198 1198
 				$texte = str_replace($a, $anofollow, $texte);
1199 1199
 			}
@@ -1226,7 +1226,7 @@  discard block
 block discarded – undo
1226 1226
 	$texte = preg_replace('@</p>@iS', "\n", $texte);
1227 1227
 	$texte = preg_replace("@<p\b.*>@UiS", '<br />', $texte);
1228 1228
 
1229
-	return preg_replace('@^\s*<br />@S' . $u, '', $texte);
1229
+	return preg_replace('@^\s*<br />@S'.$u, '', $texte);
1230 1230
 }
1231 1231
 
1232 1232
 /**
@@ -1314,7 +1314,7 @@  discard block
 block discarded – undo
1314 1314
 
1315 1315
 		// Calcul de la taille et choix de l'unité
1316 1316
 		$affichage = _T(
1317
-			'spip:taille_' . $unites[$puissance] . $suffixe_item,
1317
+			'spip:taille_'.$unites[$puissance].$suffixe_item,
1318 1318
 			[
1319 1319
 				'taille' => round($octets / $kilo ** $puissance, $precisions[$puissance])
1320 1320
 			]
@@ -1348,7 +1348,7 @@  discard block
 block discarded – undo
1348 1348
 	}
1349 1349
 	$u = $GLOBALS['meta']['pcre_u'];
1350 1350
 	if ($textebrut) {
1351
-		$texte = preg_replace([",\n,", ',\s(?=\s),msS' . $u], [' ', ''], textebrut($texte));
1351
+		$texte = preg_replace([",\n,", ',\s(?=\s),msS'.$u], [' ', ''], textebrut($texte));
1352 1352
 	}
1353 1353
 	$texte = texte_backend($texte);
1354 1354
 	$texte = str_replace(["'", '"'], ['&#039;', '&#034;'], $texte);
@@ -1383,7 +1383,7 @@  discard block
 block discarded – undo
1383 1383
 	# un message pour abs_url
1384 1384
 	$GLOBALS['mode_abs_url'] = 'url';
1385 1385
 	$url = trim($url);
1386
-	$r = ',^(?:' . _PROTOCOLES_STD . '):?/?/?$,iS';
1386
+	$r = ',^(?:'._PROTOCOLES_STD.'):?/?/?$,iS';
1387 1387
 
1388 1388
 	return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1389 1389
 }
@@ -1589,7 +1589,7 @@  discard block
 block discarded – undo
1589 1589
 
1590 1590
 	$debut = '';
1591 1591
 	$suite = $texte;
1592
-	while ($t = strpos((string) ('-' . $suite), "\n", 1)) {
1592
+	while ($t = strpos((string) ('-'.$suite), "\n", 1)) {
1593 1593
 		$debut .= substr($suite, 0, $t - 1);
1594 1594
 		$suite = substr($suite, $t);
1595 1595
 		$car = substr($suite, 0, 1);
@@ -1607,7 +1607,7 @@  discard block
 block discarded – undo
1607 1607
 			$suite = substr($suite, strlen($regs[0]));
1608 1608
 		}
1609 1609
 	}
1610
-	$texte = $debut . $suite;
1610
+	$texte = $debut.$suite;
1611 1611
 
1612 1612
 	if ($collecteurModeles) {
1613 1613
 		$texte = $collecteurModeles->retablir($texte);
@@ -1615,7 +1615,7 @@  discard block
 block discarded – undo
1615 1615
 
1616 1616
 	$texte = CollecteurHtmlTag::retablir_depuisHtmlBase64($texte);
1617 1617
 
1618
-	return $texte . $fin;
1618
+	return $texte.$fin;
1619 1619
 }
1620 1620
 
1621 1621
 
@@ -1654,7 +1654,7 @@  discard block
 block discarded – undo
1654 1654
 		}
1655 1655
 		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1656 1656
 		if (is_bool($options)) {
1657
-			trigger_deprecation('spip', '5.0', 'Using boolean $options parameter in "%s()" function is deprecated. Use %s array parameter instead.', __FUNCTION__, '[\'echappe_span\' => ' . var_export($options, true) . ']');
1657
+			trigger_deprecation('spip', '5.0', 'Using boolean $options parameter in "%s()" function is deprecated. Use %s array parameter instead.', __FUNCTION__, '[\'echappe_span\' => '.var_export($options, true).']');
1658 1658
 			$options = ['echappe_span' => $options];
1659 1659
 		}
1660 1660
 		if (!isset($options['echappe_span'])) {
@@ -1711,7 +1711,7 @@  discard block
 block discarded – undo
1711 1711
 
1712 1712
 		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1713 1713
 		if (is_bool($options)) {
1714
-			trigger_deprecation('spip', '5.0', 'Using boolean $options parameter in "%s()" function is deprecated. Use %s array parameter instead.', __FUNCTION__, '[\'echappe_span\' => ' . var_export($options, true) . ']');
1714
+			trigger_deprecation('spip', '5.0', 'Using boolean $options parameter in "%s()" function is deprecated. Use %s array parameter instead.', __FUNCTION__, '[\'echappe_span\' => '.var_export($options, true).']');
1715 1715
 			$options = ['echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT];
1716 1716
 		}
1717 1717
 		if (!isset($options['echappe_span'])) {
@@ -1880,7 +1880,7 @@  discard block
 block discarded – undo
1880 1880
 	if (is_array($balise)) {
1881 1881
 		array_walk(
1882 1882
 			$balise,
1883
-			function (&$a, $key, $t) {
1883
+			function(&$a, $key, $t) {
1884 1884
 				$a = extraire_attribut($a, $t);
1885 1885
 			},
1886 1886
 			$attribut
@@ -1974,14 +1974,14 @@  discard block
 block discarded – undo
1974 1974
 
1975 1975
 	if ($old !== null) {
1976 1976
 		// Remplacer l'ancien attribut du meme nom
1977
-		$balise = $r[1] . $insert . $r[5];
1977
+		$balise = $r[1].$insert.$r[5];
1978 1978
 	} else {
1979 1979
 		// preferer une balise " />" (comme <img />)
1980 1980
 		if (preg_match(',/>,', $balise)) {
1981
-			$balise = preg_replace(',\s?/>,S', $insert . ' />', $balise, 1);
1981
+			$balise = preg_replace(',\s?/>,S', $insert.' />', $balise, 1);
1982 1982
 		} // sinon une balise <a ...> ... </a>
1983 1983
 		else {
1984
-			$balise = preg_replace(',\s?>,S', $insert . '>', $balise, 1);
1984
+			$balise = preg_replace(',\s?>,S', $insert.'>', $balise, 1);
1985 1985
 		}
1986 1986
 	}
1987 1987
 
@@ -2039,7 +2039,7 @@  discard block
 block discarded – undo
2039 2039
 			in_array($operation, ['ajouter', 'commuter'])
2040 2040
 			&& !$is_class_presente
2041 2041
 		) {
2042
-			$class_new = ltrim(rtrim($class_new ?? '') . ' ' . $c);
2042
+			$class_new = ltrim(rtrim($class_new ?? '').' '.$c);
2043 2043
 		} elseif (
2044 2044
 			in_array($operation, ['supprimer', 'commuter'])
2045 2045
 			&& $is_class_presente
@@ -2109,7 +2109,7 @@  discard block
 block discarded – undo
2109 2109
 // Quelques fonctions de calcul arithmetique
2110 2110
 //
2111 2111
 function floatstr($a) {
2112
-	return str_replace(',', '.', (string)(float) $a);
2112
+	return str_replace(',', '.', (string) (float) $a);
2113 2113
 }
2114 2114
 function strize($f, $a, $b) {
2115 2115
 	return floatstr($f(floatstr($a), floatstr($b)));
@@ -2250,13 +2250,13 @@  discard block
 block discarded – undo
2250 2250
 	if (!defined('_TAGS_NOM_AUTEUR')) {
2251 2251
 		define('_TAGS_NOM_AUTEUR', '');
2252 2252
 	}
2253
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2253
+	$tags_acceptes = array_unique(explode(',', 'multi,'._TAGS_NOM_AUTEUR));
2254 2254
 	foreach ($tags_acceptes as $tag) {
2255 2255
 		if (strlen($tag)) {
2256
-			$remp1[] = '<' . trim($tag) . '>';
2257
-			$remp1[] = '</' . trim($tag) . '>';
2258
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2259
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2256
+			$remp1[] = '<'.trim($tag).'>';
2257
+			$remp1[] = '</'.trim($tag).'>';
2258
+			$remp2[] = '\x60'.trim($tag).'\x61';
2259
+			$remp2[] = '\x60/'.trim($tag).'\x61';
2260 2260
 		}
2261 2261
 	}
2262 2262
 	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
@@ -2375,10 +2375,10 @@  discard block
 block discarded – undo
2375 2375
 	$fichier = basename($url);
2376 2376
 
2377 2377
 	return '<a rel="enclosure"'
2378
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2379
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2380
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2381
-	. '>' . $fichier . '</a>';
2378
+	. ($url ? ' href="'.spip_htmlspecialchars($url).'"' : '')
2379
+	. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2380
+	. ($length ? ' title="'.spip_htmlspecialchars($length).'"' : '')
2381
+	. '>'.$fichier.'</a>';
2382 2382
 }
2383 2383
 
2384 2384
 /**
@@ -2406,9 +2406,9 @@  discard block
 block discarded – undo
2406 2406
 			} # vieux data
2407 2407
 			$fichier = basename($url);
2408 2408
 			$enclosures[] = '<enclosure'
2409
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2410
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2411
-				. ($length ? ' length="' . $length . '"' : '')
2409
+				. ($url ? ' url="'.spip_htmlspecialchars($url).'"' : '')
2410
+				. ($type ? ' type="'.spip_htmlspecialchars($type).'"' : '')
2411
+				. ($length ? ' length="'.$length.'"' : '')
2412 2412
 				. ' />';
2413 2413
 		}
2414 2414
 	}
@@ -2434,7 +2434,7 @@  discard block
 block discarded – undo
2434 2434
 		if (extraire_attribut($e, 'rel') == 'tag') {
2435 2435
 			$subjects .= '<dc:subject>'
2436 2436
 				. texte_backend(textebrut($e))
2437
-				. '</dc:subject>' . "\n";
2437
+				. '</dc:subject>'."\n";
2438 2438
 		}
2439 2439
 	}
2440 2440
 
@@ -2503,7 +2503,7 @@  discard block
 block discarded – undo
2503 2503
 	if (is_array($texte)) {
2504 2504
 		array_walk(
2505 2505
 			$texte,
2506
-			function (&$a, $key, $t) {
2506
+			function(&$a, $key, $t) {
2507 2507
 				$a = extraire_balises($a, $t);
2508 2508
 			},
2509 2509
 			$tag
@@ -2631,7 +2631,7 @@  discard block
 block discarded – undo
2631 2631
 		if ($fond != '404') {
2632 2632
 			$contexte = array_shift($p);
2633 2633
 			$contexte['page'] = $fond;
2634
-			$action = preg_replace('/([?]' . preg_quote((string) $fond, '/') . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2634
+			$action = preg_replace('/([?]'.preg_quote((string) $fond, '/').'[^&=]*[0-9]+)(&|$)/', '?&', $action);
2635 2635
 		}
2636 2636
 	}
2637 2637
 	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
@@ -2686,9 +2686,9 @@  discard block
 block discarded – undo
2686 2686
 			. '"'
2687 2687
 			. (is_null($val)
2688 2688
 				? ''
2689
-				: ' value="' . entites_html($val) . '"'
2689
+				: ' value="'.entites_html($val).'"'
2690 2690
 			)
2691
-			. ' type="hidden"' . "\n/>";
2691
+			. ' type="hidden"'."\n/>";
2692 2692
 	}
2693 2693
 
2694 2694
 	return implode('', $hidden);
@@ -2798,7 +2798,7 @@  discard block
 block discarded – undo
2798 2798
 
2799 2799
 	return preg_replace_callback(
2800 2800
 		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2801
-		fn($x) => "url('" . suivre_lien($path, $x[1]) . "')",
2801
+		fn($x) => "url('".suivre_lien($path, $x[1])."')",
2802 2802
 		$contenu
2803 2803
 	);
2804 2804
 }
@@ -2862,14 +2862,14 @@  discard block
 block discarded – undo
2862 2862
 	) {
2863 2863
 		$distant = true;
2864 2864
 		$cssf = parse_url($css);
2865
-		$cssf = $cssf['path'] . ($cssf['query'] ? '?' . $cssf['query'] : '');
2865
+		$cssf = $cssf['path'].($cssf['query'] ? '?'.$cssf['query'] : '');
2866 2866
 		$cssf = preg_replace(',[?:&=],', '_', $cssf);
2867 2867
 	} else {
2868 2868
 		$distant = false;
2869 2869
 		$cssf = $css;
2870 2870
 		// 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2871 2871
 		//propose (rien a faire dans ce cas)
2872
-		$f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2872
+		$f = preg_replace(',(_rtl)?\.css$,i', '_'.$ndir.'.css', $css);
2873 2873
 		if (@file_exists($f)) {
2874 2874
 			return $f;
2875 2875
 		}
@@ -2879,7 +2879,7 @@  discard block
 block discarded – undo
2879 2879
 	$dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2880 2880
 	$f = $dir_var
2881 2881
 		. preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2882
-		. '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2882
+		. '.'.substr(md5($cssf), 0, 4).'_'.$ndir.'.css';
2883 2883
 
2884 2884
 	// la css peut etre distante (url absolue !)
2885 2885
 	$contenu = null;
@@ -2926,8 +2926,8 @@  discard block
 block discarded – undo
2926 2926
 		} // si la css_direction commence par $dir_var on la fait passer pour une absolue
2927 2927
 		elseif (str_starts_with($css_direction, $dir_var)) {
2928 2928
 			$css_direction = substr($css_direction, strlen($dir_var));
2929
-			$src_faux_abs['/@@@@@@/' . $css_direction] = $css_direction;
2930
-			$css_direction = '/@@@@@@/' . $css_direction;
2929
+			$src_faux_abs['/@@@@@@/'.$css_direction] = $css_direction;
2930
+			$css_direction = '/@@@@@@/'.$css_direction;
2931 2931
 		}
2932 2932
 		$src[] = $regs[0][$k];
2933 2933
 		$src_direction_css[] = str_replace($import_css, $css_direction, (string) $regs[0][$k]);
@@ -2976,7 +2976,7 @@  discard block
 block discarded – undo
2976 2976
 
2977 2977
 	$f = basename($css, '.css');
2978 2978
 	$f = sous_repertoire(_DIR_VAR, 'cache-css')
2979
-		. preg_replace(',(.*?)(_rtl|_ltr)?$,', "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
2979
+		. preg_replace(',(.*?)(_rtl|_ltr)?$,', "\\1-urlabs-".substr(md5("$css-urlabs"), 0, 4)."\\2", $f)
2980 2980
 		. '.css';
2981 2981
 
2982 2982
 	if (@filemtime($f) > @filemtime($css) && _VAR_MODE != 'recalcul') {
@@ -2987,7 +2987,7 @@  discard block
 block discarded – undo
2987 2987
 	if ($url_absolue_css == $css) {
2988 2988
 		if (
2989 2989
 			strncmp((string) $GLOBALS['meta']['adresse_site'], $css, $l = strlen((string) $GLOBALS['meta']['adresse_site'])) != 0
2990
-			|| !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
2990
+			|| !lire_fichier(_DIR_RACINE.substr($css, $l), $contenu)
2991 2991
 		) {
2992 2992
 			include_spip('inc/distant');
2993 2993
 			$contenu = recuperer_url($css);
@@ -3099,7 +3099,7 @@  discard block
 block discarded – undo
3099 3099
 	$expression = str_replace('\/', '/', $expression);
3100 3100
 	$expression = str_replace('/', '\/', $expression);
3101 3101
 
3102
-	if (preg_match('/' . $expression . '/' . $modif, $texte ?? '', $r)) {
3102
+	if (preg_match('/'.$expression.'/'.$modif, $texte ?? '', $r)) {
3103 3103
 		if (isset($r[$capte])) {
3104 3104
 			return $r[$capte];
3105 3105
 		} else {
@@ -3141,7 +3141,7 @@  discard block
 block discarded – undo
3141 3141
 	$expression = str_replace('\/', '/', $expression);
3142 3142
 	$expression = str_replace('/', '\/', $expression);
3143 3143
 
3144
-	return (string) preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3144
+	return (string) preg_replace('/'.$expression.'/'.$modif, $replace, $texte);
3145 3145
 }
3146 3146
 
3147 3147
 
@@ -3160,7 +3160,7 @@  discard block
 block discarded – undo
3160 3160
 function traiter_doublons_documents(&$doublons, $letexte) {
3161 3161
 
3162 3162
 	// Verifier dans le texte & les notes (pas beau, helas)
3163
-	$t = $letexte . $GLOBALS['les_notes'];
3163
+	$t = $letexte.$GLOBALS['les_notes'];
3164 3164
 
3165 3165
 	if (
3166 3166
 		strstr($t, 'spip_document_')
@@ -3174,7 +3174,7 @@  discard block
 block discarded – undo
3174 3174
 		if (!isset($doublons['documents'])) {
3175 3175
 			$doublons['documents'] = '';
3176 3176
 		}
3177
-		$doublons['documents'] .= ',' . implode(',', $matches[1]);
3177
+		$doublons['documents'] .= ','.implode(',', $matches[1]);
3178 3178
 	}
3179 3179
 
3180 3180
 	return $letexte;
@@ -3231,7 +3231,7 @@  discard block
 block discarded – undo
3231 3231
 	if ($env) {
3232 3232
 		foreach ($env as $i => $j) {
3233 3233
 			if (is_string($j) && !in_array($i, $ignore_params)) {
3234
-				$texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3234
+				$texte .= "<param name='".attribut_html($i)."'\n\tvalue='".attribut_html($j)."' />";
3235 3235
 			}
3236 3236
 		}
3237 3237
 	}
@@ -3270,7 +3270,7 @@  discard block
 block discarded – undo
3270 3270
 	if ($env) {
3271 3271
 		foreach ($env as $i => $j) {
3272 3272
 			if (is_string($j) && !in_array($i, $ignore_params)) {
3273
-				$texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3273
+				$texte .= attribut_html($i)."='".attribut_html($j)."' ";
3274 3274
 			}
3275 3275
 		}
3276 3276
 	}
@@ -3344,11 +3344,11 @@  discard block
 block discarded – undo
3344 3344
 	// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3345 3345
 	if (
3346 3346
 		preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3347
-		&& ($variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . '-xx.svg')
3347
+		&& ($variante_svg_generique = substr($img_file, 0, -strlen($m[0])).'-xx.svg')
3348 3348
 		&& file_exists($variante_svg_generique)
3349 3349
 	) {
3350 3350
 		if (
3351
-			($variante_svg_size = substr($variante_svg_generique, 0, -6) . $m[1] . '.svg')
3351
+			($variante_svg_size = substr($variante_svg_generique, 0, -6).$m[1].'.svg')
3352 3352
 			&& file_exists($variante_svg_size)
3353 3353
 		) {
3354 3354
 			$img_file = $variante_svg_size;
@@ -3404,7 +3404,7 @@  discard block
 block discarded – undo
3404 3404
 				return '';
3405 3405
 			}
3406 3406
 		}
3407
-		$atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3407
+		$atts .= " width='".$largeur."' height='".$hauteur."'";
3408 3408
 	}
3409 3409
 
3410 3410
 	if (file_exists($img_file)) {
@@ -3414,14 +3414,14 @@  discard block
 block discarded – undo
3414 3414
 		$alt = '';
3415 3415
 	}
3416 3416
 	elseif ($alt || $alt === '') {
3417
-		$alt = " alt='" . attribut_html($alt) . "'";
3417
+		$alt = " alt='".attribut_html($alt)."'";
3418 3418
 	}
3419 3419
 	else {
3420
-		$alt = " alt='" . attribut_html($title) . "'";
3420
+		$alt = " alt='".attribut_html($title)."'";
3421 3421
 	}
3422
-	return "<img src='" . attribut_html($img_file) . "'$alt"
3423
-	. ($title ? ' title="' . attribut_html($title) . '"' : '')
3424
-	. ' ' . ltrim($atts)
3422
+	return "<img src='".attribut_html($img_file)."'$alt"
3423
+	. ($title ? ' title="'.attribut_html($title).'"' : '')
3424
+	. ' '.ltrim($atts)
3425 3425
 	. ' />';
3426 3426
 }
3427 3427
 
@@ -3435,10 +3435,10 @@  discard block
 block discarded – undo
3435 3435
  */
3436 3436
 function http_style_background($img, $att = '', $size = null) {
3437 3437
 	if ($size && is_numeric($size)) {
3438
-		$size = trim($size) . 'px';
3438
+		$size = trim($size).'px';
3439 3439
 	}
3440
-	return " style='background" .
3441
-		($att ? '' : '-image') . ': url("' . chemin_image($img) . '")' . ($att ? (' ' . $att) : '') . ';'
3440
+	return " style='background".
3441
+		($att ? '' : '-image').': url("'.chemin_image($img).'")'.($att ? (' '.$att) : '').';'
3442 3442
 		. ($size ? "background-size:{$size};" : '')
3443 3443
 		. "'";
3444 3444
 }
@@ -3548,7 +3548,7 @@  discard block
 block discarded – undo
3548 3548
 		$img = http_img_pack(
3549 3549
 			$img,
3550 3550
 			$alt,
3551
-			$class ? " class='" . attribut_html($class) . "'" : '',
3551
+			$class ? " class='".attribut_html($class)."'" : '',
3552 3552
 			'',
3553 3553
 			['chemin_image' => false, 'utiliser_suffixe_size' => false]
3554 3554
 		);
@@ -3648,9 +3648,9 @@  discard block
 block discarded – undo
3648 3648
 	// regler le alt
3649 3649
 	if ($alt) {
3650 3650
 		$balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3651
-		$id = 'img-svg-title-' . substr(md5("$img_file:$svg:$alt"), 0, 4);
3651
+		$id = 'img-svg-title-'.substr(md5("$img_file:$svg:$alt"), 0, 4);
3652 3652
 		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3653
-		$title = "<title id=\"$id\">" . entites_html($alt) . "</title>\n";
3653
+		$title = "<title id=\"$id\">".entites_html($alt)."</title>\n";
3654 3654
 		$balise_svg .= $title;
3655 3655
 	}
3656 3656
 	else {
@@ -3842,7 +3842,7 @@  discard block
 block discarded – undo
3842 3842
 	}
3843 3843
 
3844 3844
 	$c = serialize($c);
3845
-	$cle = calculer_cle_action($form . $c);
3845
+	$cle = calculer_cle_action($form.$c);
3846 3846
 	$c = "$cle:$c";
3847 3847
 
3848 3848
 	// on ne stocke pas les contextes dans des fichiers en cache
@@ -3900,15 +3900,15 @@  discard block
 block discarded – undo
3900 3900
 	}
3901 3901
 	// toujours encoder l'url source dans le bloc ajax
3902 3902
 	$r = self();
3903
-	$r = ' data-origin="' . $r . '"';
3903
+	$r = ' data-origin="'.$r.'"';
3904 3904
 	$class = 'ajaxbloc';
3905 3905
 	if ($ajaxid && is_string($ajaxid)) {
3906 3906
 		// ajaxid est normalement conforme a un nom de classe css
3907 3907
 		// on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3908
-		$class .= ' ajax-id-' . entites_html($ajaxid);
3908
+		$class .= ' ajax-id-'.entites_html($ajaxid);
3909 3909
 	}
3910 3910
 
3911
-	return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3911
+	return "<div class='$class' "."data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3912 3912
 }
3913 3913
 
3914 3914
 /**
@@ -3953,7 +3953,7 @@  discard block
 block discarded – undo
3953 3953
 		$cle = substr((string) $c, 0, $p);
3954 3954
 		$c = substr((string) $c, $p + 1);
3955 3955
 
3956
-		if ($cle === calculer_cle_action($form . $c)) {
3956
+		if ($cle === calculer_cle_action($form.$c)) {
3957 3957
 			return @unserialize($c);
3958 3958
 		}
3959 3959
 	}
@@ -4073,13 +4073,13 @@  discard block
 block discarded – undo
4073 4073
 				}
4074 4074
 			}
4075 4075
 		}
4076
-		$att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"';
4076
+		$att .= 'class="'.($class ? attribut_html($class).' ' : '').(defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on').'"';
4077 4077
 	} else {
4078 4078
 		$bal = 'a';
4079 4079
 		$att = "href='$url'"
4080
-			. ($title ? " title='" . attribut_html($title) . "'" : '')
4081
-			. ($class ? " class='" . attribut_html($class) . "'" : '')
4082
-			. ($rel ? " rel='" . attribut_html($rel) . "'" : '')
4080
+			. ($title ? " title='".attribut_html($title)."'" : '')
4081
+			. ($class ? " class='".attribut_html($class)."'" : '')
4082
+			. ($rel ? " rel='".attribut_html($rel)."'" : '')
4083 4083
 			. $evt;
4084 4084
 	}
4085 4085
 	if ($libelle === null) {
@@ -4216,7 +4216,7 @@  discard block
 block discarded – undo
4216 4216
 
4217 4217
 	// Icône
4218 4218
 	$icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4219
-	$icone = '<span class="icone-image' . ($fonction ? " icone-fonction icone-fonction-$fonction" : '') . "\">$icone</span>";
4219
+	$icone = '<span class="icone-image'.($fonction ? " icone-fonction icone-fonction-$fonction" : '')."\">$icone</span>";
4220 4220
 
4221 4221
 	// Markup final
4222 4222
 	if ($type == 'lien') {
@@ -4491,16 +4491,16 @@  discard block
 block discarded – undo
4491 4491
 		$class_form = 'ajax';
4492 4492
 		$class = str_replace('ajax', '', $class);
4493 4493
 	}
4494
-	$class_btn = 'submit ' . trim($class);
4494
+	$class_btn = 'submit '.trim($class);
4495 4495
 
4496 4496
 	if ($confirm) {
4497
-		$confirm = 'confirm("' . attribut_html($confirm) . '")';
4497
+		$confirm = 'confirm("'.attribut_html($confirm).'")';
4498 4498
 		$callback = $callback ? "$confirm?($callback):false" : $confirm;
4499 4499
 	}
4500
-	$onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : '';
4500
+	$onclick = $callback ? " onclick='return ".addcslashes($callback, "'")."'" : '';
4501 4501
 	$title = $title ? " title='$title'" : '';
4502 4502
 
4503
-	return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>" . form_hidden($url)
4503
+	return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>".form_hidden($url)
4504 4504
 	. "<button type='submit' class='$class_btn'$title$onclick>$libelle</button></div></form>";
4505 4505
 }
4506 4506
 
@@ -4564,14 +4564,14 @@  discard block
 block discarded – undo
4564 4564
 		$champ_titre = '';
4565 4565
 		if ($demande_titre) {
4566 4566
 			// si pas de titre declare mais champ titre, il sera peuple par le select *
4567
-			$champ_titre = (empty($desc['titre'])) ? '' : ', ' . $desc['titre'];
4567
+			$champ_titre = (empty($desc['titre'])) ? '' : ', '.$desc['titre'];
4568 4568
 		}
4569 4569
 		include_spip('base/abstract_sql');
4570 4570
 		include_spip('base/connect_sql');
4571 4571
 		$objets[$type_objet][$id_objet] = sql_fetsel(
4572
-			'*' . $champ_titre,
4572
+			'*'.$champ_titre,
4573 4573
 			$desc['table_sql'],
4574
-			id_table_objet($type_objet) . ' = ' . (int) $id_objet
4574
+			id_table_objet($type_objet).' = '.(int) $id_objet
4575 4575
 		);
4576 4576
 
4577 4577
 		// Toujours noter la longueur d'introduction, même si pas demandé cette fois-ci
@@ -4660,8 +4660,7 @@  discard block
 block discarded – undo
4660 4660
 	if (isset($ligne_sql['chapo'])) {
4661 4661
 		$chapo = $ligne_sql['chapo'];
4662 4662
 		$texte = strlen((string) $descriptif) ?
4663
-			'' :
4664
-			"$chapo \n\n $texte";
4663
+			'' : "$chapo \n\n $texte";
4665 4664
 	}
4666 4665
 
4667 4666
 	// Longueur en paramètre, sinon celle renseignée dans la description de l'objet, sinon valeur en dur
@@ -4725,7 +4724,7 @@  discard block
 block discarded – undo
4725 4724
 		return $texte;
4726 4725
 	}
4727 4726
 
4728
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", (string) $traitement);
4727
+	$traitement = str_replace('%s', "'".texte_script($texte)."'", (string) $traitement);
4729 4728
 
4730 4729
 	// signaler qu'on est dans l'espace prive pour les filtres qui se servent de ce flag
4731 4730
 	if (test_espace_prive()) {
@@ -4761,7 +4760,7 @@  discard block
 block discarded – undo
4761 4760
 	}
4762 4761
 	$url = generer_objet_url($id_objet, $objet, '', '', null, '', $connect);
4763 4762
 
4764
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . '</a>';
4763
+	return "<a href='$url' class='$objet'>".couper($titre, $longueur).'</a>';
4765 4764
 }
4766 4765
 
4767 4766
 /**
@@ -4779,9 +4778,9 @@  discard block
 block discarded – undo
4779 4778
 function wrap($texte, $wrap) {
4780 4779
 	$balises = extraire_balises($wrap);
4781 4780
 	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4782
-		$texte = $wrap . $texte;
4781
+		$texte = $wrap.$texte;
4783 4782
 		$regs = array_reverse($regs[1]);
4784
-		$wrap = '</' . implode('></', $regs) . '>';
4783
+		$wrap = '</'.implode('></', $regs).'>';
4785 4784
 		$texte .= $wrap;
4786 4785
 	}
4787 4786
 
@@ -4811,7 +4810,7 @@  discard block
 block discarded – undo
4811 4810
 
4812 4811
 	// caster $u en array si besoin
4813 4812
 	if (is_object($u)) {
4814
-		$u = (array)$u;
4813
+		$u = (array) $u;
4815 4814
 	}
4816 4815
 
4817 4816
 	if (is_array($u)) {
@@ -4833,7 +4832,7 @@  discard block
 block discarded – undo
4833 4832
 		// sinon on passe a la ligne et on indente
4834 4833
 		$i_str = str_pad('', $indent, ' ');
4835 4834
 		foreach ($u as $k => $v) {
4836
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4835
+			$out .= $join.$i_str."$k: ".filtre_print_dist($v, $join, $indent + 2);
4837 4836
 		}
4838 4837
 
4839 4838
 		return $out;
@@ -4887,7 +4886,7 @@  discard block
 block discarded – undo
4887 4886
  * @return string
4888 4887
  */
4889 4888
 function objet_icone($objet, $taille = 24, $class = '') {
4890
-	$icone = objet_info($objet, 'icone_objet') . '-' . $taille . '.png';
4889
+	$icone = objet_info($objet, 'icone_objet').'-'.$taille.'.png';
4891 4890
 	$icone = chemin_image($icone);
4892 4891
 	$balise_img = charger_filtre('balise_img');
4893 4892
 
@@ -4913,7 +4912,7 @@  discard block
 block discarded – undo
4913 4912
  */
4914 4913
 function objet_T($objet, $chaine, $args = [], $options = []) {
4915 4914
 	$chaine = explode(':', $chaine);
4916
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, ['force' => false]))) {
4915
+	if ($t = _T($objet.':'.end($chaine), $args, array_merge($options, ['force' => false]))) {
4917 4916
 		return $t;
4918 4917
 	}
4919 4918
 	$chaine = implode(':', $chaine);
@@ -4979,7 +4978,7 @@  discard block
 block discarded – undo
4979 4978
 	$cache = recuperer_fond($fond, $contexte, $options, $connect);
4980 4979
 
4981 4980
 	// calculer le nom de la css
4982
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4981
+	$dir_var = sous_repertoire(_DIR_VAR, 'cache-'.$extension);
4983 4982
 	$nom_safe = preg_replace(',\W,', '_', str_replace('.', '_', $fond));
4984 4983
 	$contexte_implicite = calculer_contexte_implicite();
4985 4984
 
@@ -4987,14 +4986,14 @@  discard block
 block discarded – undo
4987 4986
 	// mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
4988 4987
 	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4989 4988
 	if (isset($options['hash_on_content']) && $options['hash_on_content']) {
4990
-		$hash = md5((string) ($contexte_implicite['host'] . '::' . $cache));
4989
+		$hash = md5((string) ($contexte_implicite['host'].'::'.$cache));
4991 4990
 	}
4992 4991
 	else {
4993 4992
 		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4994 4993
 		ksort($contexte);
4995
-		$hash = md5($fond . json_encode($contexte_implicite, JSON_THROW_ON_ERROR) . json_encode($contexte, JSON_THROW_ON_ERROR) . $connect);
4994
+		$hash = md5($fond.json_encode($contexte_implicite, JSON_THROW_ON_ERROR).json_encode($contexte, JSON_THROW_ON_ERROR).$connect);
4996 4995
 	}
4997
-	$filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
4996
+	$filename = $dir_var.$extension."dyn-$nom_safe-".substr($hash, 0, 8).".$extension";
4998 4997
 
4999 4998
 	// mettre a jour le fichier si il n'existe pas
5000 4999
 	// ou trop ancien
@@ -5002,8 +5001,8 @@  discard block
 block discarded – undo
5002 5001
 	// et recopie sur le fichier cible uniquement si il change
5003 5002
 	if (
5004 5003
 		!file_exists($filename)
5005
-		|| !file_exists($filename . '.last')
5006
-		|| isset($cache['lastmodified']) && $cache['lastmodified'] && filemtime($filename . '.last') < $cache['lastmodified']
5004
+		|| !file_exists($filename.'.last')
5005
+		|| isset($cache['lastmodified']) && $cache['lastmodified'] && filemtime($filename.'.last') < $cache['lastmodified']
5007 5006
 		|| defined('_VAR_MODE') && _VAR_MODE == 'recalcul'
5008 5007
 	) {
5009 5008
 		$contenu = $cache['texte'];
@@ -5027,10 +5026,10 @@  discard block
 block discarded – undo
5027 5026
 			}
5028 5027
 			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
5029 5028
 			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
5030
-			$comment .= "}\n   md5:" . md5((string) $contenu) . " */\n";
5029
+			$comment .= "}\n   md5:".md5((string) $contenu)." */\n";
5031 5030
 		}
5032 5031
 		// et ecrire le fichier si il change
5033
-		ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
5032
+		ecrire_fichier_calcule_si_modifie($filename, $comment.$contenu, false, true);
5034 5033
 	}
5035 5034
 
5036 5035
 	return timestamp($filename);
@@ -5257,7 +5256,7 @@  discard block
 block discarded – undo
5257 5256
 	if ($e > 0 && strlen($mid) > 8) {
5258 5257
 		$mid = '***...***';
5259 5258
 	}
5260
-	return substr($passe, 0, $e) . $mid . ($e > 0 ? substr($passe, -$e) : '');
5259
+	return substr($passe, 0, $e).$mid.($e > 0 ? substr($passe, -$e) : '');
5261 5260
 }
5262 5261
 
5263 5262
 
@@ -5319,7 +5318,7 @@  discard block
 block discarded – undo
5319 5318
 		case 'id':
5320 5319
 		case 'anchor':
5321 5320
 			if (preg_match(',^\d,', $texte)) {
5322
-				$texte = substr($type, 0, 1) . $texte;
5321
+				$texte = substr($type, 0, 1).$texte;
5323 5322
 			}
5324 5323
 	}
5325 5324
 
@@ -5329,9 +5328,9 @@  discard block
 block discarded – undo
5329 5328
 
5330 5329
 	if (strlen($texte) < $longueur_mini && $longueur_mini < $longueur_maxi) {
5331 5330
 		if (preg_match(',^\d,', $texte)) {
5332
-			$texte = ($type ? substr($type, 0, 1) : 's') . $texte;
5331
+			$texte = ($type ? substr($type, 0, 1) : 's').$texte;
5333 5332
 		}
5334
-		$texte .= $separateur . md5($original);
5333
+		$texte .= $separateur.md5($original);
5335 5334
 		$texte = substr($texte, 0, $longueur_mini);
5336 5335
 	}
5337 5336
 
Please login to merge, or discard this patch.
Indentation   +2343 added lines, -2343 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
  * @package SPIP\Core\Filtres
21 21
  **/
22 22
 if (!defined('_ECRIRE_INC_VERSION')) {
23
-	return;
23
+    return;
24 24
 }
25 25
 
26 26
 include_spip('inc/charsets');
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
  * @return string Fonction PHP correspondante du filtre
47 47
  */
48 48
 function charger_filtre($fonc, $default = 'filtre_identite_dist') {
49
-	include_fichiers_fonctions(); // inclure les fichiers fonctions
50
-	return chercher_filtre($fonc, $default);
49
+    include_fichiers_fonctions(); // inclure les fichiers fonctions
50
+    return chercher_filtre($fonc, $default);
51 51
 }
52 52
 
53 53
 /**
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
  * @return string texte
58 58
  **/
59 59
 function filtre_identite_dist($texte) {
60
- return $texte;
60
+    return $texte;
61 61
 }
62 62
 
63 63
 /**
@@ -81,33 +81,33 @@  discard block
 block discarded – undo
81 81
  *     Fonction PHP correspondante du filtre demandé
82 82
  */
83 83
 function chercher_filtre($fonc, $default = null) {
84
-	if (!$fonc) {
85
-		return $default;
86
-	}
87
-	// Cas des types mime, sans confondre avec les appels de fonction de classe
88
-	// Foo::Bar
89
-	// qui peuvent etre avec un namespace : space\Foo::Bar
90
-	if (preg_match(',^[\w]+/,', $fonc)) {
91
-		$nom = preg_replace(',\W,', '_', $fonc);
92
-		$f = chercher_filtre($nom);
93
-		// cas du sous-type MIME sans filtre associe, passer au type:
94
-		// si filtre_text_plain pas defini, passe a filtre_text
95
-		if (!$f && $nom !== $fonc) {
96
-			$f = chercher_filtre(preg_replace(',\W.*$,', '', $fonc));
97
-		}
98
-
99
-		return $f;
100
-	}
101
-
102
-	include_fichiers_fonctions();
103
-	foreach (['filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc] as $f) {
104
-		trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels
105
-		if (is_callable($f)) {
106
-			return $f;
107
-		}
108
-	}
109
-
110
-	return $default;
84
+    if (!$fonc) {
85
+        return $default;
86
+    }
87
+    // Cas des types mime, sans confondre avec les appels de fonction de classe
88
+    // Foo::Bar
89
+    // qui peuvent etre avec un namespace : space\Foo::Bar
90
+    if (preg_match(',^[\w]+/,', $fonc)) {
91
+        $nom = preg_replace(',\W,', '_', $fonc);
92
+        $f = chercher_filtre($nom);
93
+        // cas du sous-type MIME sans filtre associe, passer au type:
94
+        // si filtre_text_plain pas defini, passe a filtre_text
95
+        if (!$f && $nom !== $fonc) {
96
+            $f = chercher_filtre(preg_replace(',\W.*$,', '', $fonc));
97
+        }
98
+
99
+        return $f;
100
+    }
101
+
102
+    include_fichiers_fonctions();
103
+    foreach (['filtre_' . $fonc, 'filtre_' . $fonc . '_dist', $fonc] as $f) {
104
+        trouver_filtre_matrice($f); // charge des fichiers spécifiques éventuels
105
+        if (is_callable($f)) {
106
+            return $f;
107
+        }
108
+    }
109
+
110
+    return $default;
111 111
 }
112 112
 
113 113
 /**
@@ -151,8 +151,8 @@  discard block
 block discarded – undo
151 151
  *     Chaîne vide sinon.
152 152
  **/
153 153
 function appliquer_filtre(mixed $arg, $filtre) {
154
-	$args = func_get_args();
155
-	return appliquer_filtre_sinon($arg, $filtre, $args, '');
154
+    $args = func_get_args();
155
+    return appliquer_filtre_sinon($arg, $filtre, $args, '');
156 156
 }
157 157
 
158 158
 /**
@@ -177,8 +177,8 @@  discard block
 block discarded – undo
177 177
  *     texte d'origine sinon
178 178
  **/
179 179
 function appliquer_si_filtre(mixed $arg, $filtre) {
180
-	$args = func_get_args();
181
-	return appliquer_filtre_sinon($arg, $filtre, $args, $arg);
180
+    $args = func_get_args();
181
+    return appliquer_filtre_sinon($arg, $filtre, $args, $arg);
182 182
 }
183 183
 
184 184
 /**
@@ -194,12 +194,12 @@  discard block
 block discarded – undo
194 194
  *     Version de SPIP
195 195
  **/
196 196
 function spip_version() {
197
-	$version = $GLOBALS['spip_version_affichee'];
198
-	if ($vcs_version = version_vcs_courante(_DIR_RACINE)) {
199
-		$version .= " $vcs_version";
200
-	}
197
+    $version = $GLOBALS['spip_version_affichee'];
198
+    if ($vcs_version = version_vcs_courante(_DIR_RACINE)) {
199
+        $version .= " $vcs_version";
200
+    }
201 201
 
202
-	return $version;
202
+    return $version;
203 203
 }
204 204
 
205 205
 /**
@@ -211,11 +211,11 @@  discard block
 block discarded – undo
211 211
  * @return string
212 212
  */
213 213
 function header_silencieux($version): string {
214
-	if (isset($GLOBALS['spip_header_silencieux']) && (bool) $GLOBALS['spip_header_silencieux']) {
215
-		$version = '';
216
-	}
214
+    if (isset($GLOBALS['spip_header_silencieux']) && (bool) $GLOBALS['spip_header_silencieux']) {
215
+        $version = '';
216
+    }
217 217
 
218
-	return (string) $version;
218
+    return (string) $version;
219 219
 }
220 220
 
221 221
 /**
@@ -228,16 +228,16 @@  discard block
 block discarded – undo
228 228
  *    - string|null si $raw = false
229 229
  */
230 230
 function version_vcs_courante($dir, $raw = false) {
231
-	$desc = decrire_version_git($dir);
232
-	if ($desc === null || $raw) {
233
-		return $desc;
234
-	}
235
-	// affichage "GIT [master: abcdef]"
236
-	$commit = $desc['commit_short'] ?? $desc['commit'];
237
-	if ($desc['branch']) {
238
-		$commit = $desc['branch'] . ': ' . $commit;
239
-	}
240
-	return "{$desc['vcs']} [$commit]";
231
+    $desc = decrire_version_git($dir);
232
+    if ($desc === null || $raw) {
233
+        return $desc;
234
+    }
235
+    // affichage "GIT [master: abcdef]"
236
+    $commit = $desc['commit_short'] ?? $desc['commit'];
237
+    if ($desc['branch']) {
238
+        $commit = $desc['branch'] . ': ' . $commit;
239
+    }
240
+    return "{$desc['vcs']} [$commit]";
241 241
 }
242 242
 
243 243
 /**
@@ -249,26 +249,26 @@  discard block
 block discarded – undo
249 249
  *      array ['branch' => xx, 'commit' => yy] sinon.
250 250
  **/
251 251
 function decrire_version_git($dir) {
252
-	$c = null;
253
-	$hash = null;
254
-	if (!$dir) {
255
-		$dir = '.';
256
-	}
257
-
258
-	// version installee par GIT
259
-	if (lire_fichier($dir . '/.git/HEAD', $c)) {
260
-		$currentHead = trim(substr((string) $c, 4));
261
-		if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
262
-			return [
263
-				'vcs' => 'GIT',
264
-				'branch' => basename($currentHead),
265
-				'commit' => trim((string) $hash),
266
-				'commit_short' => substr(trim((string) $hash), 0, 8),
267
-			];
268
-		}
269
-	}
270
-
271
-	return null;
252
+    $c = null;
253
+    $hash = null;
254
+    if (!$dir) {
255
+        $dir = '.';
256
+    }
257
+
258
+    // version installee par GIT
259
+    if (lire_fichier($dir . '/.git/HEAD', $c)) {
260
+        $currentHead = trim(substr((string) $c, 4));
261
+        if (lire_fichier($dir . '/.git/' . $currentHead, $hash)) {
262
+            return [
263
+                'vcs' => 'GIT',
264
+                'branch' => basename($currentHead),
265
+                'commit' => trim((string) $hash),
266
+                'commit_short' => substr(trim((string) $hash), 0, 8),
267
+            ];
268
+        }
269
+    }
270
+
271
+    return null;
272 272
 }
273 273
 
274 274
 // La matrice est necessaire pour ne filtrer _que_ des fonctions definies dans filtres_images
@@ -315,18 +315,18 @@  discard block
 block discarded – undo
315 315
  *     Code HTML retourné par le filtre
316 316
  **/
317 317
 function filtrer($filtre) {
318
-	$tous = func_get_args();
319
-	if (trouver_filtre_matrice($filtre) && str_starts_with($filtre, 'image_')) {
320
-		return image_filtrer($tous);
321
-	} elseif ($f = chercher_filtre($filtre)) {
322
-		array_shift($tous);
323
-		return $f(...$tous);
324
-	} else {
325
-		// le filtre n'existe pas, on provoque une erreur
326
-		$msg = ['zbug_erreur_filtre', ['filtre' => texte_script($filtre)]];
327
-		erreur_squelette($msg);
328
-		return '';
329
-	}
318
+    $tous = func_get_args();
319
+    if (trouver_filtre_matrice($filtre) && str_starts_with($filtre, 'image_')) {
320
+        return image_filtrer($tous);
321
+    } elseif ($f = chercher_filtre($filtre)) {
322
+        array_shift($tous);
323
+        return $f(...$tous);
324
+    } else {
325
+        // le filtre n'existe pas, on provoque une erreur
326
+        $msg = ['zbug_erreur_filtre', ['filtre' => texte_script($filtre)]];
327
+        erreur_squelette($msg);
328
+        return '';
329
+    }
330 330
 }
331 331
 
332 332
 /**
@@ -343,11 +343,11 @@  discard block
 block discarded – undo
343 343
  * @return bool true si on trouve le filtre dans la matrice, false sinon.
344 344
  */
345 345
 function trouver_filtre_matrice($filtre) {
346
-	if (isset($GLOBALS['spip_matrice'][$filtre]) && is_string($f = $GLOBALS['spip_matrice'][$filtre])) {
347
-		find_in_path($f, '', true);
348
-		$GLOBALS['spip_matrice'][$filtre] = true;
349
-	}
350
-	return !empty($GLOBALS['spip_matrice'][$filtre]);
346
+    if (isset($GLOBALS['spip_matrice'][$filtre]) && is_string($f = $GLOBALS['spip_matrice'][$filtre])) {
347
+        find_in_path($f, '', true);
348
+        $GLOBALS['spip_matrice'][$filtre] = true;
349
+    }
350
+    return !empty($GLOBALS['spip_matrice'][$filtre]);
351 351
 }
352 352
 
353 353
 
@@ -375,8 +375,8 @@  discard block
 block discarded – undo
375 375
  * @return mixed
376 376
  */
377 377
 function filtre_set(&$Pile, mixed $val, $key, $continue = null) {
378
-	$Pile['vars'][$key] = $val;
379
-	return $continue ? $val : '';
378
+    $Pile['vars'][$key] = $val;
379
+    return $continue ? $val : '';
380 380
 }
381 381
 
382 382
 /**
@@ -402,8 +402,8 @@  discard block
 block discarded – undo
402 402
  * @return string|mixed Retourne `$val` si `$continue` présent, sinon ''.
403 403
  */
404 404
 function filtre_setenv(&$Pile, mixed $val, mixed $key, $continue = null) {
405
-	$Pile[0][$key] = $val;
406
-	return $continue ? $val : '';
405
+    $Pile[0][$key] = $val;
406
+    return $continue ? $val : '';
407 407
 }
408 408
 
409 409
 /**
@@ -412,8 +412,8 @@  discard block
 block discarded – undo
412 412
  * @return string
413 413
  */
414 414
 function filtre_sanitize_env(&$Pile, $keys) {
415
-	$Pile[0] = spip_sanitize_from_request($Pile[0], $keys);
416
-	return '';
415
+    $Pile[0] = spip_sanitize_from_request($Pile[0], $keys);
416
+    return '';
417 417
 }
418 418
 
419 419
 
@@ -436,18 +436,18 @@  discard block
 block discarded – undo
436 436
  * @return mixed Retourne la valeur (sans la modifier).
437 437
  */
438 438
 function filtre_debug(mixed $val, $key = null) {
439
-	$debug = (
440
-		is_null($key) ? '' : (var_export($key, true) . ' = ')
441
-		) . var_export($val, true);
439
+    $debug = (
440
+        is_null($key) ? '' : (var_export($key, true) . ' = ')
441
+        ) . var_export($val, true);
442 442
 
443
-	include_spip('inc/autoriser');
444
-	if (autoriser('webmestre')) {
445
-		echo "<div class='spip_debug'>\n", $debug, "</div>\n";
446
-	}
443
+    include_spip('inc/autoriser');
444
+    if (autoriser('webmestre')) {
445
+        echo "<div class='spip_debug'>\n", $debug, "</div>\n";
446
+    }
447 447
 
448
-	spip_logger('debug')->info($debug);
448
+    spip_logger('debug')->info($debug);
449 449
 
450
-	return $val;
450
+    return $val;
451 451
 }
452 452
 
453 453
 
@@ -477,81 +477,81 @@  discard block
 block discarded – undo
477 477
  *     texte qui a reçu les filtres
478 478
  **/
479 479
 function image_filtrer($args) {
480
-	$filtre = array_shift($args); # enlever $filtre
481
-	$texte = array_shift($args);
482
-	if ($texte === null || !strlen((string) $texte)) {
483
-		return '';
484
-	}
485
-	find_in_path('filtres_images_mini.php', 'inc/', true);
486
-	statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver
487
-	// Cas du nom de fichier local
488
-	$is_file = trim((string) $texte);
489
-	if (
490
-		str_contains(substr($is_file, strlen(_DIR_RACINE)), '..')
491
-		|| strpbrk($is_file, "<>\n\r\t") !== false
492
-		|| str_starts_with($is_file, '/')
493
-	) {
494
-		$is_file = false;
495
-	}
496
-	if ($is_file) {
497
-		$is_local_file = function ($path) {
498
-			if (str_contains($path, '?')) {
499
-				$path = supprimer_timestamp($path);
500
-				// remove ?24px added by find_in_theme on .svg files
501
-				$path = preg_replace(',\?[[:digit:]]+(px)$,', '', $path);
502
-			}
503
-			return file_exists($path);
504
-		};
505
-		if ($is_local_file($is_file) || tester_url_absolue($is_file)) {
506
-			$res = $filtre("<img src='$is_file' />", ...$args);
507
-			statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
508
-			return $res;
509
-		}
510
-	}
511
-
512
-	// Cas general : trier toutes les images, avec eventuellement leur <span>
513
-	if (
514
-		preg_match_all(
515
-			',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS',
516
-			(string) $texte,
517
-			$tags,
518
-			PREG_SET_ORDER
519
-		)
520
-	) {
521
-		foreach ($tags as $tag) {
522
-			$class = extraire_attribut($tag[3], 'class');
523
-			if (
524
-				(!$class || !str_contains($class, 'filtre_inactif'))
525
-				&& ($reduit = $filtre($tag[3], ...$args))
526
-			) {
527
-				// En cas de span spip_documents, modifier le style=...width:
528
-				if ($tag[1]) {
529
-					$w = extraire_attribut($reduit, 'width');
530
-					if (!$w && preg_match(',width:\s*(\d+)px,S', extraire_attribut($reduit, 'style'), $regs)) {
531
-						$w = $regs[1];
532
-					}
533
-					if ($w && ($style = extraire_attribut($tag[1], 'style'))) {
534
-						$style = preg_replace(',width:\s*\d+px,S', "width:{$w}px", $style);
535
-						$replace = inserer_attribut($tag[1], 'style', $style);
536
-						$texte = str_replace($tag[1], $replace, (string) $texte);
537
-					}
538
-				}
539
-				// traiter aussi un eventuel mouseover
540
-				if (
541
-					($mouseover = extraire_attribut($reduit, 'onmouseover'))
542
-					&& preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)
543
-				) {
544
-					$srcover = $match[1];
545
-					$srcover_filter = $filtre("<img src='" . $match[1] . "' />", ...$args);
546
-					$srcover_filter = extraire_attribut($srcover_filter, 'src');
547
-					$reduit = str_replace($srcover, $srcover_filter, (string) $reduit);
548
-				}
549
-				$texte = str_replace($tag[3], $reduit, (string) $texte);
550
-			}
551
-		}
552
-	}
553
-	statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
554
-	return $texte;
480
+    $filtre = array_shift($args); # enlever $filtre
481
+    $texte = array_shift($args);
482
+    if ($texte === null || !strlen((string) $texte)) {
483
+        return '';
484
+    }
485
+    find_in_path('filtres_images_mini.php', 'inc/', true);
486
+    statut_effacer_images_temporaires(true); // activer la suppression des images temporaires car le compilo finit la chaine par un image_graver
487
+    // Cas du nom de fichier local
488
+    $is_file = trim((string) $texte);
489
+    if (
490
+        str_contains(substr($is_file, strlen(_DIR_RACINE)), '..')
491
+        || strpbrk($is_file, "<>\n\r\t") !== false
492
+        || str_starts_with($is_file, '/')
493
+    ) {
494
+        $is_file = false;
495
+    }
496
+    if ($is_file) {
497
+        $is_local_file = function ($path) {
498
+            if (str_contains($path, '?')) {
499
+                $path = supprimer_timestamp($path);
500
+                // remove ?24px added by find_in_theme on .svg files
501
+                $path = preg_replace(',\?[[:digit:]]+(px)$,', '', $path);
502
+            }
503
+            return file_exists($path);
504
+        };
505
+        if ($is_local_file($is_file) || tester_url_absolue($is_file)) {
506
+            $res = $filtre("<img src='$is_file' />", ...$args);
507
+            statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
508
+            return $res;
509
+        }
510
+    }
511
+
512
+    // Cas general : trier toutes les images, avec eventuellement leur <span>
513
+    if (
514
+        preg_match_all(
515
+            ',(<([a-z]+) [^<>]*spip_documents[^<>]*>)?\s*(<img\s.*>),UimsS',
516
+            (string) $texte,
517
+            $tags,
518
+            PREG_SET_ORDER
519
+        )
520
+    ) {
521
+        foreach ($tags as $tag) {
522
+            $class = extraire_attribut($tag[3], 'class');
523
+            if (
524
+                (!$class || !str_contains($class, 'filtre_inactif'))
525
+                && ($reduit = $filtre($tag[3], ...$args))
526
+            ) {
527
+                // En cas de span spip_documents, modifier le style=...width:
528
+                if ($tag[1]) {
529
+                    $w = extraire_attribut($reduit, 'width');
530
+                    if (!$w && preg_match(',width:\s*(\d+)px,S', extraire_attribut($reduit, 'style'), $regs)) {
531
+                        $w = $regs[1];
532
+                    }
533
+                    if ($w && ($style = extraire_attribut($tag[1], 'style'))) {
534
+                        $style = preg_replace(',width:\s*\d+px,S', "width:{$w}px", $style);
535
+                        $replace = inserer_attribut($tag[1], 'style', $style);
536
+                        $texte = str_replace($tag[1], $replace, (string) $texte);
537
+                    }
538
+                }
539
+                // traiter aussi un eventuel mouseover
540
+                if (
541
+                    ($mouseover = extraire_attribut($reduit, 'onmouseover'))
542
+                    && preg_match(",this[.]src=['\"]([^'\"]+)['\"],ims", $mouseover, $match)
543
+                ) {
544
+                    $srcover = $match[1];
545
+                    $srcover_filter = $filtre("<img src='" . $match[1] . "' />", ...$args);
546
+                    $srcover_filter = extraire_attribut($srcover_filter, 'src');
547
+                    $reduit = str_replace($srcover, $srcover_filter, (string) $reduit);
548
+                }
549
+                $texte = str_replace($tag[3], $reduit, (string) $texte);
550
+            }
551
+        }
552
+    }
553
+    statut_effacer_images_temporaires(false); // desactiver pour les appels hors compilo
554
+    return $texte;
555 555
 }
556 556
 
557 557
 /**
@@ -568,94 +568,94 @@  discard block
 block discarded – undo
568 568
  **/
569 569
 function infos_image($img, $force_refresh = false) {
570 570
 
571
-	static $largeur_img = [], $hauteur_img = [], $poids_img = [];
572
-	$srcWidth = 0;
573
-	$srcHeight = 0;
574
-	$srcSize = null;
575
-	$valeurs = null;
576
-
577
-	$src = extraire_attribut($img, 'src');
578
-
579
-	if (!$src) {
580
-		$src = $img;
581
-	} else {
582
-		$srcWidth = extraire_attribut($img, 'width');
583
-		$srcHeight = extraire_attribut($img, 'height');
584
-		if (!ctype_digit((string) $srcWidth) || !ctype_digit((string) $srcHeight)) {
585
-			$srcWidth = $srcHeight = 0;
586
-		}
587
-	}
588
-
589
-	// ne jamais operer directement sur une image distante pour des raisons de perfo
590
-	// la copie locale a toutes les chances d'etre la ou de resservir
591
-	if (tester_url_absolue($src)) {
592
-		include_spip('inc/distant');
593
-		$fichier = copie_locale($src);
594
-		$src = $fichier ? _DIR_RACINE . $fichier : $src;
595
-	}
596
-	if (($p = strpos($src, '?')) !== false) {
597
-		$src = substr($src, 0, $p);
598
-	}
599
-
600
-	$imagesize = false;
601
-	if (isset($largeur_img[$src]) && !$force_refresh) {
602
-		$srcWidth = $largeur_img[$src];
603
-	}
604
-	if (isset($hauteur_img[$src]) && !$force_refresh) {
605
-		$srcHeight = $hauteur_img[$src];
606
-	}
607
-	if (isset($poids_img[$src]) && !$force_refresh) {
608
-		$srcSize = $poids_img[$src];
609
-	}
610
-	if (!$srcWidth || !$srcHeight || is_null($srcSize)) {
611
-		if (
612
-			file_exists($src) && ($imagesize = spip_getimagesize($src))
613
-		) {
614
-			if (!$srcWidth) {
615
-				$largeur_img[$src] = $srcWidth = $imagesize[0];
616
-			}
617
-			if (!$srcHeight) {
618
-				$hauteur_img[$src] = $srcHeight = $imagesize[1];
619
-			}
620
-			if (!$srcSize) {
621
-				$poids_img[$src] = filesize($src);
622
-			}
623
-		}
624
-		elseif (str_contains($src, '<svg')) {
625
-			include_spip('inc/svg');
626
-			if ($attrs = svg_lire_attributs($src)) {
627
-				[$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs);
628
-				if (!$srcWidth) {
629
-					$largeur_img[$src] = $srcWidth = $width;
630
-				}
631
-				if (!$srcHeight) {
632
-					$hauteur_img[$src] = $srcHeight = $height;
633
-				}
634
-				if (!$srcSize) {
635
-					$poids_img[$src] = $srcSize = strlen($src);
636
-				}
637
-			}
638
-		}
639
-		// $src peut etre une reference a une image temporaire dont a n'a que le log .src
640
-		// on s'y refere, l'image sera reconstruite en temps utile si necessaire
641
-		elseif (
642
-			@file_exists($f = "$src.src")
643
-			&& lire_fichier($f, $valeurs)
644
-			&& ($valeurs = unserialize($valeurs))
645
-		) {
646
-			if (!$srcWidth) {
647
-				$largeur_img[$src] = $srcWidth = $valeurs['largeur_dest'];
648
-			}
649
-			if (!$srcHeight) {
650
-				$hauteur_img[$src] = $srcHeight = $valeurs['hauteur_dest'];
651
-			}
652
-			if (!$srcSize) {
653
-				$poids_img[$src] = $srcSize = 0;
654
-			}
655
-		}
656
-	}
657
-
658
-	return ['hauteur' => $srcHeight, 'largeur' => $srcWidth, 'poids' => $srcSize];
571
+    static $largeur_img = [], $hauteur_img = [], $poids_img = [];
572
+    $srcWidth = 0;
573
+    $srcHeight = 0;
574
+    $srcSize = null;
575
+    $valeurs = null;
576
+
577
+    $src = extraire_attribut($img, 'src');
578
+
579
+    if (!$src) {
580
+        $src = $img;
581
+    } else {
582
+        $srcWidth = extraire_attribut($img, 'width');
583
+        $srcHeight = extraire_attribut($img, 'height');
584
+        if (!ctype_digit((string) $srcWidth) || !ctype_digit((string) $srcHeight)) {
585
+            $srcWidth = $srcHeight = 0;
586
+        }
587
+    }
588
+
589
+    // ne jamais operer directement sur une image distante pour des raisons de perfo
590
+    // la copie locale a toutes les chances d'etre la ou de resservir
591
+    if (tester_url_absolue($src)) {
592
+        include_spip('inc/distant');
593
+        $fichier = copie_locale($src);
594
+        $src = $fichier ? _DIR_RACINE . $fichier : $src;
595
+    }
596
+    if (($p = strpos($src, '?')) !== false) {
597
+        $src = substr($src, 0, $p);
598
+    }
599
+
600
+    $imagesize = false;
601
+    if (isset($largeur_img[$src]) && !$force_refresh) {
602
+        $srcWidth = $largeur_img[$src];
603
+    }
604
+    if (isset($hauteur_img[$src]) && !$force_refresh) {
605
+        $srcHeight = $hauteur_img[$src];
606
+    }
607
+    if (isset($poids_img[$src]) && !$force_refresh) {
608
+        $srcSize = $poids_img[$src];
609
+    }
610
+    if (!$srcWidth || !$srcHeight || is_null($srcSize)) {
611
+        if (
612
+            file_exists($src) && ($imagesize = spip_getimagesize($src))
613
+        ) {
614
+            if (!$srcWidth) {
615
+                $largeur_img[$src] = $srcWidth = $imagesize[0];
616
+            }
617
+            if (!$srcHeight) {
618
+                $hauteur_img[$src] = $srcHeight = $imagesize[1];
619
+            }
620
+            if (!$srcSize) {
621
+                $poids_img[$src] = filesize($src);
622
+            }
623
+        }
624
+        elseif (str_contains($src, '<svg')) {
625
+            include_spip('inc/svg');
626
+            if ($attrs = svg_lire_attributs($src)) {
627
+                [$width, $height, $viewbox] = svg_getimagesize_from_attr($attrs);
628
+                if (!$srcWidth) {
629
+                    $largeur_img[$src] = $srcWidth = $width;
630
+                }
631
+                if (!$srcHeight) {
632
+                    $hauteur_img[$src] = $srcHeight = $height;
633
+                }
634
+                if (!$srcSize) {
635
+                    $poids_img[$src] = $srcSize = strlen($src);
636
+                }
637
+            }
638
+        }
639
+        // $src peut etre une reference a une image temporaire dont a n'a que le log .src
640
+        // on s'y refere, l'image sera reconstruite en temps utile si necessaire
641
+        elseif (
642
+            @file_exists($f = "$src.src")
643
+            && lire_fichier($f, $valeurs)
644
+            && ($valeurs = unserialize($valeurs))
645
+        ) {
646
+            if (!$srcWidth) {
647
+                $largeur_img[$src] = $srcWidth = $valeurs['largeur_dest'];
648
+            }
649
+            if (!$srcHeight) {
650
+                $hauteur_img[$src] = $srcHeight = $valeurs['hauteur_dest'];
651
+            }
652
+            if (!$srcSize) {
653
+                $poids_img[$src] = $srcSize = 0;
654
+            }
655
+        }
656
+    }
657
+
658
+    return ['hauteur' => $srcHeight, 'largeur' => $srcWidth, 'poids' => $srcSize];
659 659
 }
660 660
 
661 661
 /**
@@ -671,13 +671,13 @@  discard block
 block discarded – undo
671 671
  *     poids
672 672
  **/
673 673
 function poids_image($img, $force_refresh = false) {
674
-	$infos = infos_image($img, $force_refresh);
675
-	return $infos['poids'];
674
+    $infos = infos_image($img, $force_refresh);
675
+    return $infos['poids'];
676 676
 }
677 677
 
678 678
 function taille_image($img, $force_refresh = false) {
679
-	$infos = infos_image($img, $force_refresh);
680
-	return [$infos['hauteur'], $infos['largeur']];
679
+    $infos = infos_image($img, $force_refresh);
680
+    return [$infos['hauteur'], $infos['largeur']];
681 681
 }
682 682
 
683 683
 /**
@@ -694,12 +694,12 @@  discard block
 block discarded – undo
694 694
  *     Largeur en pixels, NULL ou 0 si aucune image.
695 695
  **/
696 696
 function largeur($img) {
697
-	if (!$img) {
698
-		return;
699
-	}
700
-	[$h, $l] = taille_image($img);
697
+    if (!$img) {
698
+        return;
699
+    }
700
+    [$h, $l] = taille_image($img);
701 701
 
702
-	return $l;
702
+    return $l;
703 703
 }
704 704
 
705 705
 /**
@@ -716,12 +716,12 @@  discard block
 block discarded – undo
716 716
  *     Hauteur en pixels, NULL ou 0 si aucune image.
717 717
  **/
718 718
 function hauteur($img) {
719
-	if (!$img) {
720
-		return;
721
-	}
722
-	[$h, $l] = taille_image($img);
719
+    if (!$img) {
720
+        return;
721
+    }
722
+    [$h, $l] = taille_image($img);
723 723
 
724
-	return $h;
724
+    return $h;
725 725
 }
726 726
 
727 727
 
@@ -741,11 +741,11 @@  discard block
 block discarded – undo
741 741
  * @return string
742 742
  **/
743 743
 function corriger_entites_html($texte) {
744
-	if (!str_contains($texte, '&amp;')) {
745
-		return $texte;
746
-	}
744
+    if (!str_contains($texte, '&amp;')) {
745
+        return $texte;
746
+    }
747 747
 
748
-	return preg_replace(',&amp;(#\d\d\d+;|amp;),iS', '&\1', $texte);
748
+    return preg_replace(',&amp;(#\d\d\d+;|amp;),iS', '&\1', $texte);
749 749
 }
750 750
 
751 751
 /**
@@ -760,11 +760,11 @@  discard block
 block discarded – undo
760 760
  * @return string
761 761
  **/
762 762
 function corriger_toutes_entites_html($texte) {
763
-	if (!str_contains($texte, '&amp;')) {
764
-		return $texte;
765
-	}
763
+    if (!str_contains($texte, '&amp;')) {
764
+        return $texte;
765
+    }
766 766
 
767
-	return preg_replace(',&amp;(#?[a-z0-9]+;),iS', '&\1', $texte);
767
+    return preg_replace(',&amp;(#?[a-z0-9]+;),iS', '&\1', $texte);
768 768
 }
769 769
 
770 770
 /**
@@ -774,7 +774,7 @@  discard block
 block discarded – undo
774 774
  * @return string
775 775
  **/
776 776
 function proteger_amp($texte) {
777
-	return str_replace('&', '&amp;', $texte);
777
+    return str_replace('&', '&amp;', $texte);
778 778
 }
779 779
 
780 780
 
@@ -805,20 +805,20 @@  discard block
 block discarded – undo
805 805
  * @return mixed|string
806 806
  */
807 807
 function entites_html($texte, $tout = false, $quote = true) {
808
-	if (!is_string($texte) || !$texte || strpbrk($texte, "&\"'<>") == false) {
809
-		return $texte;
810
-	}
811
-	include_spip('inc/texte');
812
-	$flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES);
813
-	$flags |= ENT_HTML401;
814
-	$texte = CollecteurHtmlTag::proteger_balisesHtml($texte);
815
-	$texte = CollecteurHtmlTag::retablir_depuisHtmlBase64($texte, '', 'proteger_amp');
816
-	$texte = spip_htmlspecialchars($texte, $flags);
817
-	if ($tout) {
818
-		return corriger_toutes_entites_html($texte);
819
-	} else {
820
-		return corriger_entites_html($texte);
821
-	}
808
+    if (!is_string($texte) || !$texte || strpbrk($texte, "&\"'<>") == false) {
809
+        return $texte;
810
+    }
811
+    include_spip('inc/texte');
812
+    $flags = ($quote ? ENT_QUOTES : ENT_NOQUOTES);
813
+    $flags |= ENT_HTML401;
814
+    $texte = CollecteurHtmlTag::proteger_balisesHtml($texte);
815
+    $texte = CollecteurHtmlTag::retablir_depuisHtmlBase64($texte, '', 'proteger_amp');
816
+    $texte = spip_htmlspecialchars($texte, $flags);
817
+    if ($tout) {
818
+        return corriger_toutes_entites_html($texte);
819
+    } else {
820
+        return corriger_entites_html($texte);
821
+    }
822 822
 }
823 823
 
824 824
 /**
@@ -837,38 +837,38 @@  discard block
 block discarded – undo
837 837
  *     texte converti
838 838
  **/
839 839
 function filtrer_entites(?string $texte): string {
840
-	$texte ??= '';
841
-	if (!str_contains($texte, '&')) {
842
-		return $texte;
843
-	}
844
-	// filtrer
845
-	$texte = html2unicode($texte);
846
-	// remettre le tout dans le charset cible
847
-	$texte = unicode2charset($texte);
848
-	// cas particulier des " et ' qu'il faut filtrer aussi
849
-	// (on le faisait deja avec un &quot;)
850
-	if (str_contains($texte, '&#')) {
851
-		$texte = str_replace(['&#039;', '&#39;', '&#034;', '&#34;'], ["'", "'", '"', '"'], $texte);
852
-	}
840
+    $texte ??= '';
841
+    if (!str_contains($texte, '&')) {
842
+        return $texte;
843
+    }
844
+    // filtrer
845
+    $texte = html2unicode($texte);
846
+    // remettre le tout dans le charset cible
847
+    $texte = unicode2charset($texte);
848
+    // cas particulier des " et ' qu'il faut filtrer aussi
849
+    // (on le faisait deja avec un &quot;)
850
+    if (str_contains($texte, '&#')) {
851
+        $texte = str_replace(['&#039;', '&#39;', '&#034;', '&#34;'], ["'", "'", '"', '"'], $texte);
852
+    }
853 853
 
854
-	return $texte;
854
+    return $texte;
855 855
 }
856 856
 
857 857
 
858 858
 if (!function_exists('filtre_filtrer_entites_dist')) {
859
-	/**
860
-	 * Version sécurisée de filtrer_entites
861
-	 *
862
-	 * @uses interdire_scripts()
863
-	 * @uses filtrer_entites()
864
-	 *
865
-	 * @param string $t
866
-	 * @return string
867
-	 */
868
-	function filtre_filtrer_entites_dist($t) {
869
-		include_spip('inc/texte');
870
-		return interdire_scripts(filtrer_entites($t));
871
-	}
859
+    /**
860
+     * Version sécurisée de filtrer_entites
861
+     *
862
+     * @uses interdire_scripts()
863
+     * @uses filtrer_entites()
864
+     *
865
+     * @param string $t
866
+     * @return string
867
+     */
868
+    function filtre_filtrer_entites_dist($t) {
869
+        include_spip('inc/texte');
870
+        return interdire_scripts(filtrer_entites($t));
871
+    }
872 872
 }
873 873
 
874 874
 
@@ -883,18 +883,18 @@  discard block
 block discarded – undo
883 883
  * @return string|array
884 884
  **/
885 885
 function supprimer_caracteres_illegaux($texte) {
886
-	static $from = "\x0\x1\x2\x3\x4\x5\x6\x7\x8\xB\xC\xE\xF\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F";
887
-	static $to = null;
886
+    static $from = "\x0\x1\x2\x3\x4\x5\x6\x7\x8\xB\xC\xE\xF\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\x1B\x1C\x1D\x1E\x1F";
887
+    static $to = null;
888 888
 
889
-	if (is_array($texte)) {
890
-		return array_map('supprimer_caracteres_illegaux', $texte);
891
-	}
889
+    if (is_array($texte)) {
890
+        return array_map('supprimer_caracteres_illegaux', $texte);
891
+    }
892 892
 
893
-	if (!$to) {
894
-		$to = str_repeat('-', strlen((string) $from));
895
-	}
893
+    if (!$to) {
894
+        $to = str_repeat('-', strlen((string) $from));
895
+    }
896 896
 
897
-	return strtr($texte, $from, $to);
897
+    return strtr($texte, $from, $to);
898 898
 }
899 899
 
900 900
 /**
@@ -906,9 +906,9 @@  discard block
 block discarded – undo
906 906
  * @return string|array
907 907
  **/
908 908
 function corriger_caracteres($texte) {
909
-	$texte = corriger_caracteres_windows($texte);
909
+    $texte = corriger_caracteres_windows($texte);
910 910
 
911
-	return supprimer_caracteres_illegaux($texte);
911
+    return supprimer_caracteres_illegaux($texte);
912 912
 }
913 913
 
914 914
 /**
@@ -925,44 +925,44 @@  discard block
 block discarded – undo
925 925
  *     texte encodé pour XML
926 926
  */
927 927
 function texte_backend(?string $texte): string {
928
-	if ($texte === null || $texte === '') {
929
-		return '';
930
-	}
928
+    if ($texte === null || $texte === '') {
929
+        return '';
930
+    }
931 931
 
932
-	static $apostrophe = ['&#8217;', "'"]; # n'allouer qu'une fois
932
+    static $apostrophe = ['&#8217;', "'"]; # n'allouer qu'une fois
933 933
 
934
-	// si on a des liens ou des images, les passer en absolu
935
-	$texte = liens_absolus($texte);
934
+    // si on a des liens ou des images, les passer en absolu
935
+    $texte = liens_absolus($texte);
936 936
 
937
-	// echapper les tags &gt; &lt;
938
-	$texte = preg_replace(',&(gt|lt);,S', '&amp;\1;', $texte);
937
+    // echapper les tags &gt; &lt;
938
+    $texte = preg_replace(',&(gt|lt);,S', '&amp;\1;', $texte);
939 939
 
940
-	// importer les &eacute;
941
-	$texte = filtrer_entites($texte);
940
+    // importer les &eacute;
941
+    $texte = filtrer_entites($texte);
942 942
 
943
-	// " -> &quot; et tout ce genre de choses
944
-	$u = $GLOBALS['meta']['pcre_u'];
945
-	$texte = str_replace('&nbsp;', ' ', $texte);
946
-	$texte = preg_replace('/\s{2,}/S' . $u, ' ', $texte);
947
-	// ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
948
-	$texte = entites_html($texte, false, false);
949
-	// mais bien echapper les double quotes !
950
-	$texte = str_replace('"', '&#034;', (string) $texte);
943
+    // " -> &quot; et tout ce genre de choses
944
+    $u = $GLOBALS['meta']['pcre_u'];
945
+    $texte = str_replace('&nbsp;', ' ', $texte);
946
+    $texte = preg_replace('/\s{2,}/S' . $u, ' ', $texte);
947
+    // ne pas echapper les sinqle quotes car certains outils de syndication gerent mal
948
+    $texte = entites_html($texte, false, false);
949
+    // mais bien echapper les double quotes !
950
+    $texte = str_replace('"', '&#034;', (string) $texte);
951 951
 
952
-	// verifier le charset
953
-	$texte = charset2unicode($texte);
952
+    // verifier le charset
953
+    $texte = charset2unicode($texte);
954 954
 
955
-	// Caracteres problematiques en iso-latin 1
956
-	if (isset($GLOBALS['meta']['charset']) && $GLOBALS['meta']['charset'] == 'iso-8859-1') {
957
-		$texte = str_replace(chr(156), '&#156;', $texte);
958
-		$texte = str_replace(chr(140), '&#140;', $texte);
959
-		$texte = str_replace(chr(159), '&#159;', $texte);
960
-	}
955
+    // Caracteres problematiques en iso-latin 1
956
+    if (isset($GLOBALS['meta']['charset']) && $GLOBALS['meta']['charset'] == 'iso-8859-1') {
957
+        $texte = str_replace(chr(156), '&#156;', $texte);
958
+        $texte = str_replace(chr(140), '&#140;', $texte);
959
+        $texte = str_replace(chr(159), '&#159;', $texte);
960
+    }
961 961
 
962
-	// l'apostrophe curly pose probleme a certains lecteure de RSS
963
-	// et le caractere apostrophe alourdit les squelettes avec PHP
964
-	// ==> on les remplace par l'entite HTML
965
-	return str_replace($apostrophe, "'", $texte);
962
+    // l'apostrophe curly pose probleme a certains lecteure de RSS
963
+    // et le caractere apostrophe alourdit les squelettes avec PHP
964
+    // ==> on les remplace par l'entite HTML
965
+    return str_replace($apostrophe, "'", $texte);
966 966
 }
967 967
 
968 968
 /**
@@ -979,7 +979,7 @@  discard block
 block discarded – undo
979 979
  *     texte encodé et quote pour XML
980 980
  */
981 981
 function texte_backendq(?string $texte): string {
982
-	return addslashes(texte_backend($texte));
982
+    return addslashes(texte_backend($texte));
983 983
 }
984 984
 
985 985
 
@@ -1001,14 +1001,14 @@  discard block
 block discarded – undo
1001 1001
  *     Texte sans son numéro éventuel
1002 1002
  **/
1003 1003
 function supprimer_numero(?string $texte): string {
1004
-	if ($texte === null || $texte === '') {
1005
-		return '';
1006
-	}
1007
-	return preg_replace(
1008
-		',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1009
-		'',
1010
-		$texte
1011
-	);
1004
+    if ($texte === null || $texte === '') {
1005
+        return '';
1006
+    }
1007
+    return preg_replace(
1008
+        ',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1009
+        '',
1010
+        $texte
1011
+    );
1012 1012
 }
1013 1013
 
1014 1014
 /**
@@ -1031,19 +1031,19 @@  discard block
 block discarded – undo
1031 1031
  *     Numéro de titre, sinon chaîne vide
1032 1032
  **/
1033 1033
 function recuperer_numero(?string $texte): string {
1034
-	if ($texte === null || $texte === '') {
1035
-		return '';
1036
-	}
1037
-	if (preg_match(
1038
-			',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1039
-			$texte,
1040
-			$regs
1041
-		)
1042
-	) {
1043
-		return (string) $regs[1];
1044
-	}
1034
+    if ($texte === null || $texte === '') {
1035
+        return '';
1036
+    }
1037
+    if (preg_match(
1038
+            ',^[[:space:]]*([0-9]+)([.)]|' . chr(194) . '?' . chr(176) . ')[[:space:]]+,S',
1039
+            $texte,
1040
+            $regs
1041
+        )
1042
+    ) {
1043
+        return (string) $regs[1];
1044
+    }
1045 1045
 
1046
-	return '';
1046
+    return '';
1047 1047
 }
1048 1048
 
1049 1049
 /**
@@ -1070,16 +1070,16 @@  discard block
 block discarded – undo
1070 1070
  *     texte ou tableau de textes converti
1071 1071
  **/
1072 1072
 function supprimer_tags($texte, $rempl = '') {
1073
-	if ($texte === null || $texte === '') {
1074
-		return '';
1075
-	}
1076
-	$texte = preg_replace(',<(!--|\w|/|!\[endif|!\[if)[^>]*>,US', $rempl, $texte);
1077
-	// ne pas oublier un < final non ferme car coupe
1078
-	$texte = preg_replace(',<(!--|\w|/).*$,US', $rempl, $texte);
1079
-	// mais qui peut aussi etre un simple signe plus petit que
1080
-	$texte = str_replace('<', '&lt;', $texte);
1073
+    if ($texte === null || $texte === '') {
1074
+        return '';
1075
+    }
1076
+    $texte = preg_replace(',<(!--|\w|/|!\[endif|!\[if)[^>]*>,US', $rempl, $texte);
1077
+    // ne pas oublier un < final non ferme car coupe
1078
+    $texte = preg_replace(',<(!--|\w|/).*$,US', $rempl, $texte);
1079
+    // mais qui peut aussi etre un simple signe plus petit que
1080
+    $texte = str_replace('<', '&lt;', $texte);
1081 1081
 
1082
-	return $texte;
1082
+    return $texte;
1083 1083
 }
1084 1084
 
1085 1085
 /**
@@ -1102,7 +1102,7 @@  discard block
 block discarded – undo
1102 1102
  *     texte converti
1103 1103
  **/
1104 1104
 function echapper_tags($texte, $rempl = '') {
1105
-	return preg_replace('/<([^>]*)>/', "&lt;\\1&gt;", $texte);
1105
+    return preg_replace('/<([^>]*)>/', "&lt;\\1&gt;", $texte);
1106 1106
 }
1107 1107
 
1108 1108
 /**
@@ -1123,21 +1123,21 @@  discard block
 block discarded – undo
1123 1123
  *     texte converti
1124 1124
  **/
1125 1125
 function textebrut($texte) {
1126
-	if ($texte === null || $texte === '') {
1127
-		return '';
1128
-	}
1129
-	$u = $GLOBALS['meta']['pcre_u'];
1130
-	$texte = preg_replace('/\s+/S' . $u, ' ', $texte);
1131
-	$texte = preg_replace('/<(p|br)( [^>]*)?>/iS', "\n\n", $texte);
1132
-	$texte = preg_replace("/^\n+/", '', $texte);
1133
-	$texte = preg_replace("/\n+$/", '', $texte);
1134
-	$texte = preg_replace("/\n +/", "\n", $texte);
1135
-	$texte = supprimer_tags($texte);
1136
-	$texte = preg_replace('/(&nbsp;| )+/S', ' ', $texte);
1137
-	// nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail...
1138
-	$texte = str_replace('&#8217;', "'", $texte);
1126
+    if ($texte === null || $texte === '') {
1127
+        return '';
1128
+    }
1129
+    $u = $GLOBALS['meta']['pcre_u'];
1130
+    $texte = preg_replace('/\s+/S' . $u, ' ', $texte);
1131
+    $texte = preg_replace('/<(p|br)( [^>]*)?>/iS', "\n\n", $texte);
1132
+    $texte = preg_replace("/^\n+/", '', $texte);
1133
+    $texte = preg_replace("/\n+$/", '', $texte);
1134
+    $texte = preg_replace("/\n +/", "\n", $texte);
1135
+    $texte = supprimer_tags($texte);
1136
+    $texte = preg_replace('/(&nbsp;| )+/S', ' ', $texte);
1137
+    // nettoyer l'apostrophe curly qui pose probleme a certains rss-readers, lecteurs de mail...
1138
+    $texte = str_replace('&#8217;', "'", $texte);
1139 1139
 
1140
-	return $texte;
1140
+    return $texte;
1141 1141
 }
1142 1142
 
1143 1143
 
@@ -1153,26 +1153,26 @@  discard block
 block discarded – undo
1153 1153
  *     texte avec liens ouvrants
1154 1154
  **/
1155 1155
 function liens_ouvrants($texte) {
1156
-	if ($texte === null || $texte === '') {
1157
-		return '';
1158
-	}
1159
-	if (
1160
-		preg_match_all(
1161
-			",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1162
-			$texte,
1163
-			$liens,
1164
-			PREG_PATTERN_ORDER
1165
-		)
1166
-	) {
1167
-		foreach ($liens[0] as $a) {
1168
-			$rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1169
-			$ablank = inserer_attribut($a, 'rel', $rel);
1170
-			$ablank = inserer_attribut($ablank, 'target', '_blank');
1171
-			$texte = str_replace($a, $ablank, $texte);
1172
-		}
1173
-	}
1174
-
1175
-	return $texte;
1156
+    if ($texte === null || $texte === '') {
1157
+        return '';
1158
+    }
1159
+    if (
1160
+        preg_match_all(
1161
+            ",(<a\s+[^>]*https?://[^>]*class=[\"']spip_(out|url)\b[^>]+>),imsS",
1162
+            $texte,
1163
+            $liens,
1164
+            PREG_PATTERN_ORDER
1165
+        )
1166
+    ) {
1167
+        foreach ($liens[0] as $a) {
1168
+            $rel = 'noopener noreferrer ' . extraire_attribut($a, 'rel');
1169
+            $ablank = inserer_attribut($a, 'rel', $rel);
1170
+            $ablank = inserer_attribut($ablank, 'target', '_blank');
1171
+            $texte = str_replace($a, $ablank, $texte);
1172
+        }
1173
+    }
1174
+
1175
+    return $texte;
1176 1176
 }
1177 1177
 
1178 1178
 /**
@@ -1182,25 +1182,25 @@  discard block
 block discarded – undo
1182 1182
  * @return string
1183 1183
  */
1184 1184
 function liens_nofollow($texte) {
1185
-	if ($texte === null || $texte === '') {
1186
-		return '';
1187
-	}
1188
-	if (stripos($texte, '<a') === false) {
1189
-		return $texte;
1190
-	}
1185
+    if ($texte === null || $texte === '') {
1186
+        return '';
1187
+    }
1188
+    if (stripos($texte, '<a') === false) {
1189
+        return $texte;
1190
+    }
1191 1191
 
1192
-	if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) {
1193
-		foreach ($regs[0] as $a) {
1194
-			$rel = extraire_attribut($a, 'rel') ?? '';
1195
-			if (!str_contains($rel, 'nofollow')) {
1196
-				$rel = 'nofollow' . ($rel ? " $rel" : '');
1197
-				$anofollow = inserer_attribut($a, 'rel', $rel);
1198
-				$texte = str_replace($a, $anofollow, $texte);
1199
-			}
1200
-		}
1201
-	}
1192
+    if (preg_match_all(",<a\b[^>]*>,UimsS", $texte, $regs, PREG_PATTERN_ORDER)) {
1193
+        foreach ($regs[0] as $a) {
1194
+            $rel = extraire_attribut($a, 'rel') ?? '';
1195
+            if (!str_contains($rel, 'nofollow')) {
1196
+                $rel = 'nofollow' . ($rel ? " $rel" : '');
1197
+                $anofollow = inserer_attribut($a, 'rel', $rel);
1198
+                $texte = str_replace($a, $anofollow, $texte);
1199
+            }
1200
+        }
1201
+    }
1202 1202
 
1203
-	return $texte;
1203
+    return $texte;
1204 1204
 }
1205 1205
 
1206 1206
 /**
@@ -1219,14 +1219,14 @@  discard block
 block discarded – undo
1219 1219
  *     texte sans paraghaphes
1220 1220
  **/
1221 1221
 function PtoBR($texte) {
1222
-	if ($texte === null || $texte === '') {
1223
-		return '';
1224
-	}
1225
-	$u = $GLOBALS['meta']['pcre_u'];
1226
-	$texte = preg_replace('@</p>@iS', "\n", $texte);
1227
-	$texte = preg_replace("@<p\b.*>@UiS", '<br />', $texte);
1222
+    if ($texte === null || $texte === '') {
1223
+        return '';
1224
+    }
1225
+    $u = $GLOBALS['meta']['pcre_u'];
1226
+    $texte = preg_replace('@</p>@iS', "\n", $texte);
1227
+    $texte = preg_replace("@<p\b.*>@UiS", '<br />', $texte);
1228 1228
 
1229
-	return preg_replace('@^\s*<br />@S' . $u, '', $texte);
1229
+    return preg_replace('@^\s*<br />@S' . $u, '', $texte);
1230 1230
 }
1231 1231
 
1232 1232
 /**
@@ -1245,30 +1245,30 @@  discard block
 block discarded – undo
1245 1245
  * @return string texte en majuscule
1246 1246
  */
1247 1247
 function majuscules($texte) {
1248
-	if ($texte === null || $texte === '') {
1249
-		return '';
1250
-	}
1248
+    if ($texte === null || $texte === '') {
1249
+        return '';
1250
+    }
1251 1251
 
1252
-	// Cas du turc
1253
-	if ($GLOBALS['spip_lang'] == 'tr') {
1254
-		# remplacer hors des tags et des entites
1255
-		if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) {
1256
-			foreach ($regs as $n => $match) {
1257
-				$texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte);
1258
-			}
1259
-		}
1252
+    // Cas du turc
1253
+    if ($GLOBALS['spip_lang'] == 'tr') {
1254
+        # remplacer hors des tags et des entites
1255
+        if (preg_match_all(',<[^<>]+>|&[^;]+;,S', $texte, $regs, PREG_SET_ORDER)) {
1256
+            foreach ($regs as $n => $match) {
1257
+                $texte = str_replace($match[0], "@@SPIP_TURC$n@@", $texte);
1258
+            }
1259
+        }
1260 1260
 
1261
-		$texte = str_replace('i', '&#304;', $texte);
1261
+        $texte = str_replace('i', '&#304;', $texte);
1262 1262
 
1263
-		if ($regs) {
1264
-			foreach ($regs as $n => $match) {
1265
-				$texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte);
1266
-			}
1267
-		}
1268
-	}
1263
+        if ($regs) {
1264
+            foreach ($regs as $n => $match) {
1265
+                $texte = str_replace("@@SPIP_TURC$n@@", $match[0], $texte);
1266
+            }
1267
+        }
1268
+    }
1269 1269
 
1270
-	// Cas general
1271
-	return "<span style='text-transform: uppercase;'>$texte</span>";
1270
+    // Cas general
1271
+    return "<span style='text-transform: uppercase;'>$texte</span>";
1272 1272
 }
1273 1273
 
1274 1274
 /**
@@ -1290,38 +1290,38 @@  discard block
 block discarded – undo
1290 1290
  */
1291 1291
 function taille_en_octets($octets, $systeme = 'BI') {
1292 1292
 
1293
-	// Texte à afficher pour la taille
1294
-	$affichage = '';
1293
+    // Texte à afficher pour la taille
1294
+    $affichage = '';
1295 1295
 
1296
-	static $unites = ['octets', 'ko', 'mo', 'go'];
1297
-	static $precisions = [0, 1, 1, 2];
1296
+    static $unites = ['octets', 'ko', 'mo', 'go'];
1297
+    static $precisions = [0, 1, 1, 2];
1298 1298
 
1299
-	if ($octets >= 1) {
1300
-		// Déterminer le nombre d'octets représentant le kilo en fonction du système choisi
1301
-		$systeme = strtolower($systeme);
1302
-		if ($systeme === 'bi') {
1303
-			$kilo = 1024;
1304
-			$suffixe_item = "_$systeme";
1305
-		} elseif ($systeme === 'si') {
1306
-			$kilo = 1000;
1307
-			$suffixe_item = '';
1308
-		} else {
1309
-			return $affichage;
1310
-		}
1299
+    if ($octets >= 1) {
1300
+        // Déterminer le nombre d'octets représentant le kilo en fonction du système choisi
1301
+        $systeme = strtolower($systeme);
1302
+        if ($systeme === 'bi') {
1303
+            $kilo = 1024;
1304
+            $suffixe_item = "_$systeme";
1305
+        } elseif ($systeme === 'si') {
1306
+            $kilo = 1000;
1307
+            $suffixe_item = '';
1308
+        } else {
1309
+            return $affichage;
1310
+        }
1311 1311
 
1312
-		// Identification de la puissance en "kilo" correspondant à l'unité la plus appropriée
1313
-		$puissance = floor(log($octets, $kilo));
1312
+        // Identification de la puissance en "kilo" correspondant à l'unité la plus appropriée
1313
+        $puissance = floor(log($octets, $kilo));
1314 1314
 
1315
-		// Calcul de la taille et choix de l'unité
1316
-		$affichage = _T(
1317
-			'spip:taille_' . $unites[$puissance] . $suffixe_item,
1318
-			[
1319
-				'taille' => round($octets / $kilo ** $puissance, $precisions[$puissance])
1320
-			]
1321
-		);
1322
-	}
1315
+        // Calcul de la taille et choix de l'unité
1316
+        $affichage = _T(
1317
+            'spip:taille_' . $unites[$puissance] . $suffixe_item,
1318
+            [
1319
+                'taille' => round($octets / $kilo ** $puissance, $precisions[$puissance])
1320
+            ]
1321
+        );
1322
+    }
1323 1323
 
1324
-	return $affichage;
1324
+    return $affichage;
1325 1325
 }
1326 1326
 
1327 1327
 
@@ -1343,21 +1343,21 @@  discard block
 block discarded – undo
1343 1343
  *     texte prêt pour être utilisé en attribut HTML
1344 1344
  **/
1345 1345
 function attribut_html(?string $texte, $textebrut = true): string {
1346
-	if ($texte === null || $texte === '') {
1347
-		return '';
1348
-	}
1349
-	$u = $GLOBALS['meta']['pcre_u'];
1350
-	if ($textebrut) {
1351
-		$texte = preg_replace([",\n,", ',\s(?=\s),msS' . $u], [' ', ''], textebrut($texte));
1352
-	}
1353
-	$texte = texte_backend($texte);
1354
-	$texte = str_replace(["'", '"'], ['&#039;', '&#034;'], $texte);
1346
+    if ($texte === null || $texte === '') {
1347
+        return '';
1348
+    }
1349
+    $u = $GLOBALS['meta']['pcre_u'];
1350
+    if ($textebrut) {
1351
+        $texte = preg_replace([",\n,", ',\s(?=\s),msS' . $u], [' ', ''], textebrut($texte));
1352
+    }
1353
+    $texte = texte_backend($texte);
1354
+    $texte = str_replace(["'", '"'], ['&#039;', '&#034;'], $texte);
1355 1355
 
1356
-	return preg_replace(
1357
-		['/&(amp;|#38;)/', '/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/'],
1358
-		['&', '&#38;'],
1359
-		$texte
1360
-	);
1356
+    return preg_replace(
1357
+        ['/&(amp;|#38;)/', '/&(?![A-Za-z]{0,4}\w{2,3};|#[0-9]{2,5};)/'],
1358
+        ['&', '&#38;'],
1359
+        $texte
1360
+    );
1361 1361
 }
1362 1362
 
1363 1363
 
@@ -1377,15 +1377,15 @@  discard block
 block discarded – undo
1377 1377
  *     URL ou chaîne vide
1378 1378
  **/
1379 1379
 function vider_url(?string $url, $entites = true): string {
1380
-	if ($url === null || $url === '') {
1381
-		return '';
1382
-	}
1383
-	# un message pour abs_url
1384
-	$GLOBALS['mode_abs_url'] = 'url';
1385
-	$url = trim($url);
1386
-	$r = ',^(?:' . _PROTOCOLES_STD . '):?/?/?$,iS';
1380
+    if ($url === null || $url === '') {
1381
+        return '';
1382
+    }
1383
+    # un message pour abs_url
1384
+    $GLOBALS['mode_abs_url'] = 'url';
1385
+    $url = trim($url);
1386
+    $r = ',^(?:' . _PROTOCOLES_STD . '):?/?/?$,iS';
1387 1387
 
1388
-	return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1388
+    return preg_match($r, $url) ? '' : ($entites ? entites_html($url) : $url);
1389 1389
 }
1390 1390
 
1391 1391
 
@@ -1400,10 +1400,10 @@  discard block
 block discarded – undo
1400 1400
  * @return string Adresse email maquillée
1401 1401
  **/
1402 1402
 function antispam($texte) {
1403
-	include_spip('inc/acces');
1404
-	$masque = creer_pass_aleatoire(3);
1403
+    include_spip('inc/acces');
1404
+    $masque = creer_pass_aleatoire(3);
1405 1405
 
1406
-	return preg_replace('/@/', " $masque ", $texte);
1406
+    return preg_replace('/@/', " $masque ", $texte);
1407 1407
 }
1408 1408
 
1409 1409
 /**
@@ -1435,8 +1435,8 @@  discard block
 block discarded – undo
1435 1435
  *     True si on a le droit d'accès, false sinon.
1436 1436
  **/
1437 1437
 function filtre_securiser_acces_dist($id_auteur, $cle, $dir, $op = '', $args = '') {
1438
-	include_spip('inc/acces');
1439
-	return securiser_acces_low_sec($id_auteur, $cle, $op ? "$dir $op $args" : $dir);
1438
+    include_spip('inc/acces');
1439
+    return securiser_acces_low_sec($id_auteur, $cle, $op ? "$dir $op $args" : $dir);
1440 1440
 }
1441 1441
 
1442 1442
 /**
@@ -1460,13 +1460,13 @@  discard block
 block discarded – undo
1460 1460
  *     Retourne $texte, sinon $sinon.
1461 1461
  **/
1462 1462
 function sinon(mixed $texte, mixed $sinon = '') {
1463
-	if ($texte) {
1464
-		return $texte;
1465
-	} elseif (is_scalar($texte) && strlen($texte)) {
1466
-		return $texte;
1467
-	}
1463
+    if ($texte) {
1464
+        return $texte;
1465
+    } elseif (is_scalar($texte) && strlen($texte)) {
1466
+        return $texte;
1467
+    }
1468 1468
 
1469
-	return $sinon;
1469
+    return $sinon;
1470 1470
 }
1471 1471
 
1472 1472
 /**
@@ -1490,7 +1490,7 @@  discard block
 block discarded – undo
1490 1490
  * @return mixed
1491 1491
  **/
1492 1492
 function choixsivide(mixed $a, mixed $vide, mixed $pasvide) {
1493
-	return $a ? $pasvide : $vide;
1493
+    return $a ? $pasvide : $vide;
1494 1494
 }
1495 1495
 
1496 1496
 /**
@@ -1514,7 +1514,7 @@  discard block
 block discarded – undo
1514 1514
  * @return mixed
1515 1515
  **/
1516 1516
 function choixsiegal(mixed $a1, mixed $a2, mixed $v, mixed $f) {
1517
-	return ($a1 == $a2) ? $v : $f;
1517
+    return ($a1 == $a2) ? $v : $f;
1518 1518
 }
1519 1519
 
1520 1520
 //
@@ -1533,15 +1533,15 @@  discard block
 block discarded – undo
1533 1533
  * @return string
1534 1534
  **/
1535 1535
 function filtrer_ical($texte) {
1536
-	if ($texte === null || $texte === '') {
1537
-		return '';
1538
-	}
1539
-	#include_spip('inc/charsets');
1540
-	$texte = html2unicode($texte);
1541
-	$texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset']), 'utf-8');
1542
-	$texte = preg_replace("/\n/", ' ', $texte);
1536
+    if ($texte === null || $texte === '') {
1537
+        return '';
1538
+    }
1539
+    #include_spip('inc/charsets');
1540
+    $texte = html2unicode($texte);
1541
+    $texte = unicode2charset(charset2unicode($texte, $GLOBALS['meta']['charset']), 'utf-8');
1542
+    $texte = preg_replace("/\n/", ' ', $texte);
1543 1543
 
1544
-	return preg_replace('/,/', '\,', $texte);
1544
+    return preg_replace('/,/', '\,', $texte);
1545 1545
 }
1546 1546
 
1547 1547
 
@@ -1566,56 +1566,56 @@  discard block
 block discarded – undo
1566 1566
  * @return string
1567 1567
  **/
1568 1568
 function post_autobr($texte, $delim = "\n_ ") {
1569
-	if (!function_exists('echappe_html')) {
1570
-		include_spip('inc/texte_mini');
1571
-	}
1572
-	$texte = str_replace("\r\n", "\r", $texte);
1573
-	$texte = str_replace("\r", "\n", $texte);
1574
-
1575
-	if (preg_match(",\n+$,", $texte, $fin)) {
1576
-		$texte = substr($texte, 0, -strlen($fin = $fin[0]));
1577
-	} else {
1578
-		$fin = '';
1579
-	}
1580
-
1581
-	$texte = CollecteurHtmlTag::proteger_balisesHtml($texte);
1582
-
1583
-	// echapper les modeles
1584
-	$collecteurModeles = null;
1585
-	if (str_contains($texte, '<')) {
1586
-		$collecteurModeles = new CollecteurModeles();
1587
-		$texte = $collecteurModeles->echapper($texte);
1588
-	}
1589
-
1590
-	$debut = '';
1591
-	$suite = $texte;
1592
-	while ($t = strpos((string) ('-' . $suite), "\n", 1)) {
1593
-		$debut .= substr($suite, 0, $t - 1);
1594
-		$suite = substr($suite, $t);
1595
-		$car = substr($suite, 0, 1);
1596
-		if (
1597
-			$car != '-' && $car != '_' && $car != "\n" && $car != '|' && $car != '}'
1598
-			&& !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite))
1599
-			&& !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut)
1600
-		) {
1601
-			$debut .= $delim;
1602
-		} else {
1603
-			$debut .= "\n";
1604
-		}
1605
-		if (preg_match(",^\n+,", $suite, $regs)) {
1606
-			$debut .= $regs[0];
1607
-			$suite = substr($suite, strlen($regs[0]));
1608
-		}
1609
-	}
1610
-	$texte = $debut . $suite;
1611
-
1612
-	if ($collecteurModeles) {
1613
-		$texte = $collecteurModeles->retablir($texte);
1614
-	}
1615
-
1616
-	$texte = CollecteurHtmlTag::retablir_depuisHtmlBase64($texte);
1617
-
1618
-	return $texte . $fin;
1569
+    if (!function_exists('echappe_html')) {
1570
+        include_spip('inc/texte_mini');
1571
+    }
1572
+    $texte = str_replace("\r\n", "\r", $texte);
1573
+    $texte = str_replace("\r", "\n", $texte);
1574
+
1575
+    if (preg_match(",\n+$,", $texte, $fin)) {
1576
+        $texte = substr($texte, 0, -strlen($fin = $fin[0]));
1577
+    } else {
1578
+        $fin = '';
1579
+    }
1580
+
1581
+    $texte = CollecteurHtmlTag::proteger_balisesHtml($texte);
1582
+
1583
+    // echapper les modeles
1584
+    $collecteurModeles = null;
1585
+    if (str_contains($texte, '<')) {
1586
+        $collecteurModeles = new CollecteurModeles();
1587
+        $texte = $collecteurModeles->echapper($texte);
1588
+    }
1589
+
1590
+    $debut = '';
1591
+    $suite = $texte;
1592
+    while ($t = strpos((string) ('-' . $suite), "\n", 1)) {
1593
+        $debut .= substr($suite, 0, $t - 1);
1594
+        $suite = substr($suite, $t);
1595
+        $car = substr($suite, 0, 1);
1596
+        if (
1597
+            $car != '-' && $car != '_' && $car != "\n" && $car != '|' && $car != '}'
1598
+            && !preg_match(',^\s*(\n|</?(quote|div|dl|dt|dd)|$),S', ($suite))
1599
+            && !preg_match(',</?(quote|div|dl|dt|dd)> *$,iS', $debut)
1600
+        ) {
1601
+            $debut .= $delim;
1602
+        } else {
1603
+            $debut .= "\n";
1604
+        }
1605
+        if (preg_match(",^\n+,", $suite, $regs)) {
1606
+            $debut .= $regs[0];
1607
+            $suite = substr($suite, strlen($regs[0]));
1608
+        }
1609
+    }
1610
+    $texte = $debut . $suite;
1611
+
1612
+    if ($collecteurModeles) {
1613
+        $texte = $collecteurModeles->retablir($texte);
1614
+    }
1615
+
1616
+    $texte = CollecteurHtmlTag::retablir_depuisHtmlBase64($texte);
1617
+
1618
+    return $texte . $fin;
1619 1619
 }
1620 1620
 
1621 1621
 
@@ -1648,25 +1648,25 @@  discard block
 block discarded – undo
1648 1648
  **/
1649 1649
 function extraire_idiome($letexte, $lang = null, $options = []) {
1650 1650
 
1651
-	if ($letexte && str_contains($letexte, '<:')) {
1652
-		if (!$lang) {
1653
-			$lang = $GLOBALS['spip_lang'];
1654
-		}
1655
-		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1656
-		if (is_bool($options)) {
1657
-			trigger_deprecation('spip', '5.0', 'Using boolean $options parameter in "%s()" function is deprecated. Use %s array parameter instead.', __FUNCTION__, '[\'echappe_span\' => ' . var_export($options, true) . ']');
1658
-			$options = ['echappe_span' => $options];
1659
-		}
1660
-		if (!isset($options['echappe_span'])) {
1661
-			$options = array_merge($options, ['echappe_span' => false]);
1662
-		}
1663
-		$options['lang'] = $lang;
1651
+    if ($letexte && str_contains($letexte, '<:')) {
1652
+        if (!$lang) {
1653
+            $lang = $GLOBALS['spip_lang'];
1654
+        }
1655
+        // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1656
+        if (is_bool($options)) {
1657
+            trigger_deprecation('spip', '5.0', 'Using boolean $options parameter in "%s()" function is deprecated. Use %s array parameter instead.', __FUNCTION__, '[\'echappe_span\' => ' . var_export($options, true) . ']');
1658
+            $options = ['echappe_span' => $options];
1659
+        }
1660
+        if (!isset($options['echappe_span'])) {
1661
+            $options = array_merge($options, ['echappe_span' => false]);
1662
+        }
1663
+        $options['lang'] = $lang;
1664 1664
 
1665
-		$collecteurIdiomes = new CollecteurIdiomes();
1665
+        $collecteurIdiomes = new CollecteurIdiomes();
1666 1666
 
1667
-		$letexte = $collecteurIdiomes->traiter($letexte, $options);
1668
-	}
1669
-	return $letexte;
1667
+        $letexte = $collecteurIdiomes->traiter($letexte, $options);
1668
+    }
1669
+    return $letexte;
1670 1670
 }
1671 1671
 
1672 1672
 /**
@@ -1704,30 +1704,30 @@  discard block
 block discarded – undo
1704 1704
  **/
1705 1705
 function extraire_multi($letexte, $lang = null, $options = []) {
1706 1706
 
1707
-	if ($letexte && stripos($letexte, '<multi') !== false) {
1708
-		if (!$lang) {
1709
-			$lang = $GLOBALS['spip_lang'];
1710
-		}
1707
+    if ($letexte && stripos($letexte, '<multi') !== false) {
1708
+        if (!$lang) {
1709
+            $lang = $GLOBALS['spip_lang'];
1710
+        }
1711 1711
 
1712
-		// Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1713
-		if (is_bool($options)) {
1714
-			trigger_deprecation('spip', '5.0', 'Using boolean $options parameter in "%s()" function is deprecated. Use %s array parameter instead.', __FUNCTION__, '[\'echappe_span\' => ' . var_export($options, true) . ']');
1715
-			$options = ['echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT];
1716
-		}
1717
-		if (!isset($options['echappe_span'])) {
1718
-			$options = array_merge($options, ['echappe_span' => false]);
1719
-		}
1720
-		if (!isset($options['lang_defaut'])) {
1721
-			$options = array_merge($options, ['lang_defaut' => _LANGUE_PAR_DEFAUT]);
1722
-		}
1723
-		$options['lang'] = $lang;
1712
+        // Compatibilité avec le prototype de fonction précédente qui utilisait un boolean
1713
+        if (is_bool($options)) {
1714
+            trigger_deprecation('spip', '5.0', 'Using boolean $options parameter in "%s()" function is deprecated. Use %s array parameter instead.', __FUNCTION__, '[\'echappe_span\' => ' . var_export($options, true) . ']');
1715
+            $options = ['echappe_span' => $options, 'lang_defaut' => _LANGUE_PAR_DEFAUT];
1716
+        }
1717
+        if (!isset($options['echappe_span'])) {
1718
+            $options = array_merge($options, ['echappe_span' => false]);
1719
+        }
1720
+        if (!isset($options['lang_defaut'])) {
1721
+            $options = array_merge($options, ['lang_defaut' => _LANGUE_PAR_DEFAUT]);
1722
+        }
1723
+        $options['lang'] = $lang;
1724 1724
 
1725
-		$collecteurMultis = new CollecteurMultis();
1725
+        $collecteurMultis = new CollecteurMultis();
1726 1726
 
1727
-		$letexte = $collecteurMultis->traiter($letexte, $options);
1728
-	}
1727
+        $letexte = $collecteurMultis->traiter($letexte, $options);
1728
+    }
1729 1729
 
1730
-	return $letexte;
1730
+    return $letexte;
1731 1731
 }
1732 1732
 
1733 1733
 /**
@@ -1737,7 +1737,7 @@  discard block
 block discarded – undo
1737 1737
  * @return string L'initiale en majuscule
1738 1738
  */
1739 1739
 function filtre_initiale($nom) {
1740
-	return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1);
1740
+    return spip_substr(trim(strtoupper(extraire_multi($nom))), 0, 1);
1741 1741
 }
1742 1742
 
1743 1743
 
@@ -1782,33 +1782,33 @@  discard block
 block discarded – undo
1782 1782
  *      - null (interne) : si on empile
1783 1783
  **/
1784 1784
 function unique($donnee, $famille = '', $cpt = false) {
1785
-	static $mem = [];
1786
-	// permettre de vider la pile et de la restaurer
1787
-	// pour le calcul de introduction...
1788
-	if ($famille == '_spip_raz_') {
1789
-		$tmp = $mem;
1790
-		$mem = [];
1791
-
1792
-		return $tmp;
1793
-	} elseif ($famille == '_spip_set_') {
1794
-		$mem = $donnee;
1795
-
1796
-		return;
1797
-	}
1798
-	// eviter une notice
1799
-	if (!isset($mem[$famille])) {
1800
-		$mem[$famille] = [];
1801
-	}
1802
-	if ($cpt) {
1803
-		return is_countable($mem[$famille]) ? count($mem[$famille]) : 0;
1804
-	}
1805
-	// eviter une notice
1806
-	if (!isset($mem[$famille][$donnee])) {
1807
-		$mem[$famille][$donnee] = 0;
1808
-	}
1809
-	if (!($mem[$famille][$donnee]++)) {
1810
-		return $donnee;
1811
-	}
1785
+    static $mem = [];
1786
+    // permettre de vider la pile et de la restaurer
1787
+    // pour le calcul de introduction...
1788
+    if ($famille == '_spip_raz_') {
1789
+        $tmp = $mem;
1790
+        $mem = [];
1791
+
1792
+        return $tmp;
1793
+    } elseif ($famille == '_spip_set_') {
1794
+        $mem = $donnee;
1795
+
1796
+        return;
1797
+    }
1798
+    // eviter une notice
1799
+    if (!isset($mem[$famille])) {
1800
+        $mem[$famille] = [];
1801
+    }
1802
+    if ($cpt) {
1803
+        return is_countable($mem[$famille]) ? count($mem[$famille]) : 0;
1804
+    }
1805
+    // eviter une notice
1806
+    if (!isset($mem[$famille][$donnee])) {
1807
+        $mem[$famille][$donnee] = 0;
1808
+    }
1809
+    if (!($mem[$famille][$donnee]++)) {
1810
+        return $donnee;
1811
+    }
1812 1812
 }
1813 1813
 
1814 1814
 
@@ -1838,20 +1838,20 @@  discard block
 block discarded – undo
1838 1838
  *     Une des valeurs en fonction du compteur.
1839 1839
  **/
1840 1840
 function alterner($i, ...$args) {
1841
-	// recuperer les arguments (attention fonctions un peu space)
1842
-	$num = count($args);
1841
+    // recuperer les arguments (attention fonctions un peu space)
1842
+    $num = count($args);
1843 1843
 
1844
-	if ($num === 1 && is_array($args[0])) {
1845
-		// un tableau de valeur dont les cles sont numerotees de 0 a num
1846
-		$args = array_values($args[0]);
1847
-		$num = count($args);
1848
-	}
1844
+    if ($num === 1 && is_array($args[0])) {
1845
+        // un tableau de valeur dont les cles sont numerotees de 0 a num
1846
+        $args = array_values($args[0]);
1847
+        $num = count($args);
1848
+    }
1849 1849
 
1850
-	// un index compris entre 0 et num exclus
1851
-	$i = (((int) $i - 1) % $num); // dans ]-$num;$num[
1852
-	$i = ($i + $num) % $num; // dans [0;$num[
1853
-	// renvoyer le i-ieme argument, modulo le nombre d'arguments
1854
-	return $args[$i];
1850
+    // un index compris entre 0 et num exclus
1851
+    $i = (((int) $i - 1) % $num); // dans ]-$num;$num[
1852
+    $i = ($i + $num) % $num; // dans [0;$num[
1853
+    // renvoyer le i-ieme argument, modulo le nombre d'arguments
1854
+    return $args[$i];
1855 1855
 }
1856 1856
 
1857 1857
 
@@ -1877,52 +1877,52 @@  discard block
 block discarded – undo
1877 1877
  *     - null lorsque l’attribut n’existe pas.
1878 1878
  **/
1879 1879
 function extraire_attribut($balise, $attribut, $complet = false) {
1880
-	if (is_array($balise)) {
1881
-		array_walk(
1882
-			$balise,
1883
-			function (&$a, $key, $t) {
1884
-				$a = extraire_attribut($a, $t);
1885
-			},
1886
-			$attribut
1887
-		);
1888
-
1889
-		return $balise;
1890
-	}
1891
-	if (
1892
-		$balise
1893
-		&& stripos($balise, $attribut) !== false
1894
-		&& preg_match(
1895
-			',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
1896
-			. $attribut
1897
-			. '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
1898
-			$balise,
1899
-			$r
1900
-		)
1901
-	) {
1902
-		if (isset($r[3][0]) && ($r[3][0] == '"' || $r[3][0] == "'")) {
1903
-			$r[4] = substr($r[3], 1, -1);
1904
-			$r[3] = $r[3][0];
1905
-		} elseif ($r[3] !== '') {
1906
-			$r[4] = $r[3];
1907
-			$r[3] = '';
1908
-		} else {
1909
-			$r[4] = trim($r[2]);
1910
-		}
1911
-		$att = $r[4];
1912
-		if (str_contains($att, '&#')) {
1913
-			$att = str_replace(['&#039;', '&#39;', '&#034;', '&#34;'], ["'", "'", '"', '"'], $att);
1914
-		}
1915
-		$att = filtrer_entites($att);
1916
-	} else {
1917
-		$att = null;
1918
-		$r = [];
1919
-	}
1920
-
1921
-	if ($complet) {
1922
-		return [$att, $r];
1923
-	} else {
1924
-		return $att;
1925
-	}
1880
+    if (is_array($balise)) {
1881
+        array_walk(
1882
+            $balise,
1883
+            function (&$a, $key, $t) {
1884
+                $a = extraire_attribut($a, $t);
1885
+            },
1886
+            $attribut
1887
+        );
1888
+
1889
+        return $balise;
1890
+    }
1891
+    if (
1892
+        $balise
1893
+        && stripos($balise, $attribut) !== false
1894
+        && preg_match(
1895
+            ',(^.*?<(?:(?>\s*)(?>[\w:.-]+)(?>(?:=(?:"[^"]*"|\'[^\']*\'|[^\'"]\S*))?))*?)(\s+'
1896
+            . $attribut
1897
+            . '(?:=\s*("[^"]*"|\'[^\']*\'|[^\'"]\S*))?)()((?:[\s/][^>]*)?>.*),isS',
1898
+            $balise,
1899
+            $r
1900
+        )
1901
+    ) {
1902
+        if (isset($r[3][0]) && ($r[3][0] == '"' || $r[3][0] == "'")) {
1903
+            $r[4] = substr($r[3], 1, -1);
1904
+            $r[3] = $r[3][0];
1905
+        } elseif ($r[3] !== '') {
1906
+            $r[4] = $r[3];
1907
+            $r[3] = '';
1908
+        } else {
1909
+            $r[4] = trim($r[2]);
1910
+        }
1911
+        $att = $r[4];
1912
+        if (str_contains($att, '&#')) {
1913
+            $att = str_replace(['&#039;', '&#39;', '&#034;', '&#34;'], ["'", "'", '"', '"'], $att);
1914
+        }
1915
+        $att = filtrer_entites($att);
1916
+    } else {
1917
+        $att = null;
1918
+        $r = [];
1919
+    }
1920
+
1921
+    if ($complet) {
1922
+        return [$att, $r];
1923
+    } else {
1924
+        return $att;
1925
+    }
1926 1926
 }
1927 1927
 
1928 1928
 /**
@@ -1955,37 +1955,37 @@  discard block
 block discarded – undo
1955 1955
  **/
1956 1956
 function inserer_attribut(?string $balise, string $attribut, ?string $val, bool $proteger = true, bool $vider = false): string {
1957 1957
 
1958
-	if ($balise === null || $balise === '') {
1959
-		return '';
1960
-	}
1958
+    if ($balise === null || $balise === '') {
1959
+        return '';
1960
+    }
1961 1961
 
1962
-	// preparer l'attribut
1963
-	// supprimer les &nbsp; etc mais pas les balises html
1964
-	// qui ont un sens dans un attribut value d'un input
1965
-	if ($proteger) {
1966
-		$val = attribut_html($val, false);
1967
-	}
1962
+    // preparer l'attribut
1963
+    // supprimer les &nbsp; etc mais pas les balises html
1964
+    // qui ont un sens dans un attribut value d'un input
1965
+    if ($proteger) {
1966
+        $val = attribut_html($val, false);
1967
+    }
1968 1968
 
1969
-	// echapper les ' pour eviter tout bug
1970
-	$val = str_replace("'", '&#039;', $val ?? '');
1971
-	$insert = $vider && (string) $val === '' ? '' : " $attribut='$val'";
1969
+    // echapper les ' pour eviter tout bug
1970
+    $val = str_replace("'", '&#039;', $val ?? '');
1971
+    $insert = $vider && (string) $val === '' ? '' : " $attribut='$val'";
1972 1972
 
1973
-	[$old, $r] = extraire_attribut($balise, $attribut, true);
1973
+    [$old, $r] = extraire_attribut($balise, $attribut, true);
1974 1974
 
1975
-	if ($old !== null) {
1976
-		// Remplacer l'ancien attribut du meme nom
1977
-		$balise = $r[1] . $insert . $r[5];
1978
-	} else {
1979
-		// preferer une balise " />" (comme <img />)
1980
-		if (preg_match(',/>,', $balise)) {
1981
-			$balise = preg_replace(',\s?/>,S', $insert . ' />', $balise, 1);
1982
-		} // sinon une balise <a ...> ... </a>
1983
-		else {
1984
-			$balise = preg_replace(',\s?>,S', $insert . '>', $balise, 1);
1985
-		}
1986
-	}
1975
+    if ($old !== null) {
1976
+        // Remplacer l'ancien attribut du meme nom
1977
+        $balise = $r[1] . $insert . $r[5];
1978
+    } else {
1979
+        // preferer une balise " />" (comme <img />)
1980
+        if (preg_match(',/>,', $balise)) {
1981
+            $balise = preg_replace(',\s?/>,S', $insert . ' />', $balise, 1);
1982
+        } // sinon une balise <a ...> ... </a>
1983
+        else {
1984
+            $balise = preg_replace(',\s?>,S', $insert . '>', $balise, 1);
1985
+        }
1986
+    }
1987 1987
 
1988
-	return $balise;
1988
+    return $balise;
1989 1989
 }
1990 1990
 
1991 1991
 /**
@@ -2003,7 +2003,7 @@  discard block
 block discarded – undo
2003 2003
  * @return string Code HTML sans l'attribut
2004 2004
  **/
2005 2005
 function vider_attribut(?string $balise, string $attribut): string {
2006
-	return inserer_attribut($balise, $attribut, '', false, true);
2006
+    return inserer_attribut($balise, $attribut, '', false, true);
2007 2007
 }
2008 2008
 
2009 2009
 /**
@@ -2015,50 +2015,50 @@  discard block
 block discarded – undo
2015 2015
  * @return string
2016 2016
  */
2017 2017
 function modifier_class($balise, $class, $operation = 'ajouter') {
2018
-	if (is_string($class)) {
2019
-		$class = explode(' ', trim($class));
2020
-	}
2021
-	$class = array_filter($class);
2022
-	$class = array_unique($class);
2023
-	if (!$class) {
2024
-		return $balise;
2025
-	}
2026
-
2027
-	$class_courante = extraire_attribut($balise, 'class');
2028
-	$class_new = $class_courante;
2029
-	foreach ($class as $c) {
2030
-		$is_class_presente = false;
2031
-		if (
2032
-			$class_courante
2033
-			&& str_contains($class_courante, (string) $c)
2034
-			&& in_array($c, preg_split(',\s+,', $class_courante))
2035
-		) {
2036
-			$is_class_presente = true;
2037
-		}
2038
-		if (
2039
-			in_array($operation, ['ajouter', 'commuter'])
2040
-			&& !$is_class_presente
2041
-		) {
2042
-			$class_new = ltrim(rtrim($class_new ?? '') . ' ' . $c);
2043
-		} elseif (
2044
-			in_array($operation, ['supprimer', 'commuter'])
2045
-			&& $is_class_presente
2046
-		) {
2047
-			$class_new = preg_split(',\s+,', $class_new);
2048
-			$class_new = array_diff($class_new, [$c]);
2049
-			$class_new = implode(' ', $class_new);
2050
-		}
2051
-	}
2052
-
2053
-	if ($class_new !== $class_courante) {
2054
-		if (strlen($class_new)) {
2055
-			$balise = inserer_attribut($balise, 'class', $class_new);
2056
-		} elseif ($class_courante) {
2057
-			$balise = vider_attribut($balise, 'class');
2058
-		}
2059
-	}
2060
-
2061
-	return $balise;
2018
+    if (is_string($class)) {
2019
+        $class = explode(' ', trim($class));
2020
+    }
2021
+    $class = array_filter($class);
2022
+    $class = array_unique($class);
2023
+    if (!$class) {
2024
+        return $balise;
2025
+    }
2026
+
2027
+    $class_courante = extraire_attribut($balise, 'class');
2028
+    $class_new = $class_courante;
2029
+    foreach ($class as $c) {
2030
+        $is_class_presente = false;
2031
+        if (
2032
+            $class_courante
2033
+            && str_contains($class_courante, (string) $c)
2034
+            && in_array($c, preg_split(',\s+,', $class_courante))
2035
+        ) {
2036
+            $is_class_presente = true;
2037
+        }
2038
+        if (
2039
+            in_array($operation, ['ajouter', 'commuter'])
2040
+            && !$is_class_presente
2041
+        ) {
2042
+            $class_new = ltrim(rtrim($class_new ?? '') . ' ' . $c);
2043
+        } elseif (
2044
+            in_array($operation, ['supprimer', 'commuter'])
2045
+            && $is_class_presente
2046
+        ) {
2047
+            $class_new = preg_split(',\s+,', $class_new);
2048
+            $class_new = array_diff($class_new, [$c]);
2049
+            $class_new = implode(' ', $class_new);
2050
+        }
2051
+    }
2052
+
2053
+    if ($class_new !== $class_courante) {
2054
+        if (strlen($class_new)) {
2055
+            $balise = inserer_attribut($balise, 'class', $class_new);
2056
+        } elseif ($class_courante) {
2057
+            $balise = vider_attribut($balise, 'class');
2058
+        }
2059
+    }
2060
+
2061
+    return $balise;
2062 2062
 }
2063 2063
 
2064 2064
 /**
@@ -2068,7 +2068,7 @@  discard block
 block discarded – undo
2068 2068
  * @return string
2069 2069
  */
2070 2070
 function ajouter_class($balise, $class) {
2071
-	return modifier_class($balise, $class, 'ajouter');
2071
+    return modifier_class($balise, $class, 'ajouter');
2072 2072
 }
2073 2073
 
2074 2074
 /**
@@ -2078,7 +2078,7 @@  discard block
 block discarded – undo
2078 2078
  * @return string
2079 2079
  */
2080 2080
 function supprimer_class($balise, $class) {
2081
-	return modifier_class($balise, $class, 'supprimer');
2081
+    return modifier_class($balise, $class, 'supprimer');
2082 2082
 }
2083 2083
 
2084 2084
 /**
@@ -2089,7 +2089,7 @@  discard block
 block discarded – undo
2089 2089
  * @return string
2090 2090
  */
2091 2091
 function commuter_class($balise, $class) {
2092
-	return modifier_class($balise, $class, 'commuter');
2092
+    return modifier_class($balise, $class, 'commuter');
2093 2093
 }
2094 2094
 
2095 2095
 /**
@@ -2100,19 +2100,19 @@  discard block
 block discarded – undo
2100 2100
  * @return string
2101 2101
  */
2102 2102
 function tester_config($id, $mode = '') {
2103
-	include_spip('action/inscrire_auteur');
2103
+    include_spip('action/inscrire_auteur');
2104 2104
 
2105
-	return tester_statut_inscription($mode, $id);
2105
+    return tester_statut_inscription($mode, $id);
2106 2106
 }
2107 2107
 
2108 2108
 //
2109 2109
 // Quelques fonctions de calcul arithmetique
2110 2110
 //
2111 2111
 function floatstr($a) {
2112
-	return str_replace(',', '.', (string)(float) $a);
2112
+    return str_replace(',', '.', (string)(float) $a);
2113 2113
 }
2114 2114
 function strize($f, $a, $b) {
2115
-	return floatstr($f(floatstr($a), floatstr($b)));
2115
+    return floatstr($f(floatstr($a), floatstr($b)));
2116 2116
 }
2117 2117
 
2118 2118
 /**
@@ -2131,11 +2131,11 @@  discard block
 block discarded – undo
2131 2131
  * @return int $a+$b
2132 2132
  **/
2133 2133
 function plus($a, $b) {
2134
-	return $a + $b;
2134
+    return $a + $b;
2135 2135
 }
2136 2136
 
2137 2137
 function strplus($a, $b) {
2138
-	return strize('plus', $a, $b);
2138
+    return strize('plus', $a, $b);
2139 2139
 }
2140 2140
 
2141 2141
 /**
@@ -2154,11 +2154,11 @@  discard block
 block discarded – undo
2154 2154
  * @return int $a-$b
2155 2155
  **/
2156 2156
 function moins($a, $b) {
2157
-	return $a - $b;
2157
+    return $a - $b;
2158 2158
 }
2159 2159
 
2160 2160
 function strmoins($a, $b) {
2161
-	return strize('moins', $a, $b);
2161
+    return strize('moins', $a, $b);
2162 2162
 }
2163 2163
 
2164 2164
 /**
@@ -2178,11 +2178,11 @@  discard block
 block discarded – undo
2178 2178
  * @return int $a*$b
2179 2179
  **/
2180 2180
 function mult($a, $b) {
2181
-	return $a * $b;
2181
+    return $a * $b;
2182 2182
 }
2183 2183
 
2184 2184
 function strmult($a, $b) {
2185
-	return strize('mult', $a, $b);
2185
+    return strize('mult', $a, $b);
2186 2186
 }
2187 2187
 
2188 2188
 /**
@@ -2202,11 +2202,11 @@  discard block
 block discarded – undo
2202 2202
  * @return int $a/$b (ou 0 si $b est nul)
2203 2203
  **/
2204 2204
 function div($a, $b) {
2205
-	return $b ? $a / $b : 0;
2205
+    return $b ? $a / $b : 0;
2206 2206
 }
2207 2207
 
2208 2208
 function strdiv($a, $b) {
2209
-	return strize('div', $a, $b);
2209
+    return strize('div', $a, $b);
2210 2210
 }
2211 2211
 
2212 2212
 /**
@@ -2227,7 +2227,7 @@  discard block
 block discarded – undo
2227 2227
  * @return int ($nb % $mod) + $add
2228 2228
  **/
2229 2229
 function modulo($nb, $mod, $add = 0) {
2230
-	return ($mod ? $nb % $mod : 0) + $add;
2230
+    return ($mod ? $nb % $mod : 0) + $add;
2231 2231
 }
2232 2232
 
2233 2233
 
@@ -2242,26 +2242,26 @@  discard block
 block discarded – undo
2242 2242
  *      - true sinon
2243 2243
  **/
2244 2244
 function nom_acceptable($nom) {
2245
-	$remp2 = [];
2246
-	$remp1 = [];
2247
-	if (!is_string($nom)) {
2248
-		return false;
2249
-	}
2250
-	if (!defined('_TAGS_NOM_AUTEUR')) {
2251
-		define('_TAGS_NOM_AUTEUR', '');
2252
-	}
2253
-	$tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2254
-	foreach ($tags_acceptes as $tag) {
2255
-		if (strlen($tag)) {
2256
-			$remp1[] = '<' . trim($tag) . '>';
2257
-			$remp1[] = '</' . trim($tag) . '>';
2258
-			$remp2[] = '\x60' . trim($tag) . '\x61';
2259
-			$remp2[] = '\x60/' . trim($tag) . '\x61';
2260
-		}
2261
-	}
2262
-	$v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2263
-
2264
-	return str_replace('&lt;', '<', $v_nom) == $nom;
2245
+    $remp2 = [];
2246
+    $remp1 = [];
2247
+    if (!is_string($nom)) {
2248
+        return false;
2249
+    }
2250
+    if (!defined('_TAGS_NOM_AUTEUR')) {
2251
+        define('_TAGS_NOM_AUTEUR', '');
2252
+    }
2253
+    $tags_acceptes = array_unique(explode(',', 'multi,' . _TAGS_NOM_AUTEUR));
2254
+    foreach ($tags_acceptes as $tag) {
2255
+        if (strlen($tag)) {
2256
+            $remp1[] = '<' . trim($tag) . '>';
2257
+            $remp1[] = '</' . trim($tag) . '>';
2258
+            $remp2[] = '\x60' . trim($tag) . '\x61';
2259
+            $remp2[] = '\x60/' . trim($tag) . '\x61';
2260
+        }
2261
+    }
2262
+    $v_nom = str_replace($remp2, $remp1, supprimer_tags(str_replace($remp1, $remp2, $nom)));
2263
+
2264
+    return str_replace('&lt;', '<', $v_nom) == $nom;
2265 2265
 }
2266 2266
 
2267 2267
 
@@ -2277,13 +2277,13 @@  discard block
 block discarded – undo
2277 2277
  *      - renvoie un tableau si l'entree est un tableau
2278 2278
  **/
2279 2279
 function email_valide($adresses) {
2280
-	if (is_array($adresses)) {
2281
-		$adresses = array_map('email_valide', $adresses);
2282
-		return array_filter($adresses);
2283
-	}
2280
+    if (is_array($adresses)) {
2281
+        $adresses = array_map('email_valide', $adresses);
2282
+        return array_filter($adresses);
2283
+    }
2284 2284
 
2285
-	$email_valide = charger_fonction('email_valide', 'inc');
2286
-	return $email_valide($adresses);
2285
+    $email_valide = charger_fonction('email_valide', 'inc');
2286
+    return $email_valide($adresses);
2287 2287
 }
2288 2288
 
2289 2289
 /**
@@ -2297,29 +2297,29 @@  discard block
 block discarded – undo
2297 2297
  * @return string texte
2298 2298
  **/
2299 2299
 function afficher_enclosures($tags) {
2300
-	$s = [];
2301
-	foreach (extraire_balises($tags, 'a') as $tag) {
2302
-		if (
2303
-			extraire_attribut($tag, 'rel') == 'enclosure'
2304
-			&& ($t = extraire_attribut($tag, 'href'))
2305
-		) {
2306
-			$s[] = preg_replace(
2307
-				',>[^<]+</a>,S',
2308
-				'>'
2309
-				. http_img_pack(
2310
-					'attachment-16.png',
2311
-					$t,
2312
-					'',
2313
-					$t,
2314
-					['utiliser_suffixe_size' => true]
2315
-				)
2316
-				. '</a>',
2317
-				(string) $tag
2318
-			);
2319
-		}
2320
-	}
2321
-
2322
-	return implode('&nbsp;', $s);
2300
+    $s = [];
2301
+    foreach (extraire_balises($tags, 'a') as $tag) {
2302
+        if (
2303
+            extraire_attribut($tag, 'rel') == 'enclosure'
2304
+            && ($t = extraire_attribut($tag, 'href'))
2305
+        ) {
2306
+            $s[] = preg_replace(
2307
+                ',>[^<]+</a>,S',
2308
+                '>'
2309
+                . http_img_pack(
2310
+                    'attachment-16.png',
2311
+                    $t,
2312
+                    '',
2313
+                    $t,
2314
+                    ['utiliser_suffixe_size' => true]
2315
+                )
2316
+                . '</a>',
2317
+                (string) $tag
2318
+            );
2319
+        }
2320
+    }
2321
+
2322
+    return implode('&nbsp;', $s);
2323 2323
 }
2324 2324
 
2325 2325
 /**
@@ -2334,15 +2334,15 @@  discard block
 block discarded – undo
2334 2334
  * @return string Liens trouvés
2335 2335
  **/
2336 2336
 function afficher_tags($tags, $rels = 'tag,directory') {
2337
-	$s = [];
2338
-	foreach (extraire_balises($tags, 'a') as $tag) {
2339
-		$rel = extraire_attribut($tag, 'rel');
2340
-		if (strstr(",$rels,", (string) ",$rel,")) {
2341
-			$s[] = $tag;
2342
-		}
2343
-	}
2337
+    $s = [];
2338
+    foreach (extraire_balises($tags, 'a') as $tag) {
2339
+        $rel = extraire_attribut($tag, 'rel');
2340
+        if (strstr(",$rels,", (string) ",$rel,")) {
2341
+            $s[] = $tag;
2342
+        }
2343
+    }
2344 2344
 
2345
-	return implode(', ', $s);
2345
+    return implode(', ', $s);
2346 2346
 }
2347 2347
 
2348 2348
 
@@ -2364,21 +2364,21 @@  discard block
 block discarded – undo
2364 2364
  * @return string Tag HTML `<a>` avec microformat.
2365 2365
  **/
2366 2366
 function enclosure2microformat($e) {
2367
-	if (!$url = filtrer_entites(extraire_attribut($e, 'url') ?? '')) {
2368
-		$url = filtrer_entites(extraire_attribut($e, 'href') ?? '');
2369
-	}
2370
-	$type = extraire_attribut($e, 'type');
2371
-	if (!$length = extraire_attribut($e, 'length')) {
2372
-		# <media:content : longeur dans fileSize. On tente.
2373
-		$length = extraire_attribut($e, 'fileSize');
2374
-	}
2375
-	$fichier = basename($url);
2367
+    if (!$url = filtrer_entites(extraire_attribut($e, 'url') ?? '')) {
2368
+        $url = filtrer_entites(extraire_attribut($e, 'href') ?? '');
2369
+    }
2370
+    $type = extraire_attribut($e, 'type');
2371
+    if (!$length = extraire_attribut($e, 'length')) {
2372
+        # <media:content : longeur dans fileSize. On tente.
2373
+        $length = extraire_attribut($e, 'fileSize');
2374
+    }
2375
+    $fichier = basename($url);
2376 2376
 
2377
-	return '<a rel="enclosure"'
2378
-	. ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2379
-	. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2380
-	. ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2381
-	. '>' . $fichier . '</a>';
2377
+    return '<a rel="enclosure"'
2378
+    . ($url ? ' href="' . spip_htmlspecialchars($url) . '"' : '')
2379
+    . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2380
+    . ($length ? ' title="' . spip_htmlspecialchars($length) . '"' : '')
2381
+    . '>' . $fichier . '</a>';
2382 2382
 }
2383 2383
 
2384 2384
 /**
@@ -2396,24 +2396,24 @@  discard block
 block discarded – undo
2396 2396
  * @return string Tags RSS `<enclosure>`.
2397 2397
  **/
2398 2398
 function microformat2enclosure($tags) {
2399
-	$enclosures = [];
2400
-	foreach (extraire_balises($tags, 'a') as $e) {
2401
-		if (extraire_attribut($e, 'rel') == 'enclosure') {
2402
-			$url = filtrer_entites(extraire_attribut($e, 'href'));
2403
-			$type = extraire_attribut($e, 'type');
2404
-			if (!$length = (int) extraire_attribut($e, 'title')) {
2405
-				$length = (int) extraire_attribut($e, 'length');
2406
-			} # vieux data
2407
-			$fichier = basename($url);
2408
-			$enclosures[] = '<enclosure'
2409
-				. ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2410
-				. ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2411
-				. ($length ? ' length="' . $length . '"' : '')
2412
-				. ' />';
2413
-		}
2414
-	}
2399
+    $enclosures = [];
2400
+    foreach (extraire_balises($tags, 'a') as $e) {
2401
+        if (extraire_attribut($e, 'rel') == 'enclosure') {
2402
+            $url = filtrer_entites(extraire_attribut($e, 'href'));
2403
+            $type = extraire_attribut($e, 'type');
2404
+            if (!$length = (int) extraire_attribut($e, 'title')) {
2405
+                $length = (int) extraire_attribut($e, 'length');
2406
+            } # vieux data
2407
+            $fichier = basename($url);
2408
+            $enclosures[] = '<enclosure'
2409
+                . ($url ? ' url="' . spip_htmlspecialchars($url) . '"' : '')
2410
+                . ($type ? ' type="' . spip_htmlspecialchars($type) . '"' : '')
2411
+                . ($length ? ' length="' . $length . '"' : '')
2412
+                . ' />';
2413
+        }
2414
+    }
2415 2415
 
2416
-	return implode("\n", $enclosures);
2416
+    return implode("\n", $enclosures);
2417 2417
 }
2418 2418
 
2419 2419
 
@@ -2429,16 +2429,16 @@  discard block
 block discarded – undo
2429 2429
  * @return string Tags RSS Atom `<dc:subject>`.
2430 2430
  **/
2431 2431
 function tags2dcsubject($tags) {
2432
-	$subjects = '';
2433
-	foreach (extraire_balises($tags, 'a') as $e) {
2434
-		if (extraire_attribut($e, 'rel') == 'tag') {
2435
-			$subjects .= '<dc:subject>'
2436
-				. texte_backend(textebrut($e))
2437
-				. '</dc:subject>' . "\n";
2438
-		}
2439
-	}
2432
+    $subjects = '';
2433
+    foreach (extraire_balises($tags, 'a') as $e) {
2434
+        if (extraire_attribut($e, 'rel') == 'tag') {
2435
+            $subjects .= '<dc:subject>'
2436
+                . texte_backend(textebrut($e))
2437
+                . '</dc:subject>' . "\n";
2438
+        }
2439
+    }
2440 2440
 
2441
-	return $subjects;
2441
+    return $subjects;
2442 2442
 }
2443 2443
 
2444 2444
 /**
@@ -2467,12 +2467,12 @@  discard block
 block discarded – undo
2467 2467
  *     - Tableau de résultats, si tableau en entrée.
2468 2468
  **/
2469 2469
 function extraire_balise($texte, $tag = 'a', $profondeur = 1) {
2470
-	$balises = extraire_balises($texte, $tag, ['nb_max' => 1, 'profondeur' => $profondeur]);
2471
-	if (is_array($texte)) {
2472
-		return array_map(fn (array $a) => empty($a) ? '' : reset($a), $balises);
2473
-	}
2470
+    $balises = extraire_balises($texte, $tag, ['nb_max' => 1, 'profondeur' => $profondeur]);
2471
+    if (is_array($texte)) {
2472
+        return array_map(fn (array $a) => empty($a) ? '' : reset($a), $balises);
2473
+    }
2474 2474
 
2475
-	return (empty($balises) ? '' : reset($balises));
2475
+    return (empty($balises) ? '' : reset($balises));
2476 2476
 }
2477 2477
 
2478 2478
 /**
@@ -2500,25 +2500,25 @@  discard block
 block discarded – undo
2500 2500
  *     - Tableau de résultats, si tableau en entrée.
2501 2501
  **/
2502 2502
 function extraire_balises($texte, $tag = 'a', $options = []) {
2503
-	if (is_array($texte)) {
2504
-		array_walk(
2505
-			$texte,
2506
-			function (&$a, $key, $t) {
2507
-				$a = extraire_balises($a, $t);
2508
-			},
2509
-			$tag
2510
-		);
2503
+    if (is_array($texte)) {
2504
+        array_walk(
2505
+            $texte,
2506
+            function (&$a, $key, $t) {
2507
+                $a = extraire_balises($a, $t);
2508
+            },
2509
+            $tag
2510
+        );
2511 2511
 
2512
-		return $texte;
2513
-	}
2512
+        return $texte;
2513
+    }
2514 2514
 
2515
-	$htmlTagCollecteur = new CollecteurHtmlTag($tag);
2516
-	$collection = $htmlTagCollecteur->collecter($texte, $options);
2517
-	if (!empty($collection)) {
2518
-		return array_column($collection, 'raw');
2519
-	}
2515
+    $htmlTagCollecteur = new CollecteurHtmlTag($tag);
2516
+    $collection = $htmlTagCollecteur->collecter($texte, $options);
2517
+    if (!empty($collection)) {
2518
+        return array_column($collection, 'raw');
2519
+    }
2520 2520
 
2521
-	return [];
2521
+    return [];
2522 2522
 }
2523 2523
 
2524 2524
 /**
@@ -2547,11 +2547,11 @@  discard block
 block discarded – undo
2547 2547
  *     - `$def` si on n'a pas transmis de tableau
2548 2548
  **/
2549 2549
 function in_any($val, $vals, $def = '') {
2550
-	if (!is_array($vals) && $vals && ($v = unserialize($vals))) {
2551
-		$vals = $v;
2552
-	}
2550
+    if (!is_array($vals) && $vals && ($v = unserialize($vals))) {
2551
+        $vals = $v;
2552
+    }
2553 2553
 
2554
-	return (is_array($vals) ? (in_array($val, $vals) ? ' ' : '') : ($def));
2554
+    return (is_array($vals) ? (in_array($val, $vals) ? ' ' : '') : ($def));
2555 2555
 }
2556 2556
 
2557 2557
 
@@ -2572,12 +2572,12 @@  discard block
 block discarded – undo
2572 2572
  *     Résultat du calcul
2573 2573
  **/
2574 2574
 function valeur_numerique($expr) {
2575
-	$a = 0;
2576
-	if (preg_match(',^\d+(\s*[+*-]\s*\d+)*$,S', trim($expr))) {
2577
-		eval("\$a = $expr;");
2578
-	}
2575
+    $a = 0;
2576
+    if (preg_match(',^\d+(\s*[+*-]\s*\d+)*$,S', trim($expr))) {
2577
+        eval("\$a = $expr;");
2578
+    }
2579 2579
 
2580
-	return (int) $a;
2580
+    return (int) $a;
2581 2581
 }
2582 2582
 
2583 2583
 /**
@@ -2596,7 +2596,7 @@  discard block
 block discarded – undo
2596 2596
  *      Retourne `$a*$b/$c`
2597 2597
  **/
2598 2598
 function regledetrois($a, $b, $c) {
2599
-	return round($a * $b / $c);
2599
+    return round($a * $b / $c);
2600 2600
 }
2601 2601
 
2602 2602
 
@@ -2619,79 +2619,79 @@  discard block
 block discarded – undo
2619 2619
  * @return string Suite de champs input hidden
2620 2620
  **/
2621 2621
 function form_hidden(?string $action = ''): string {
2622
-	$action ??= '';
2623
-
2624
-	$contexte = [];
2625
-	include_spip('inc/urls');
2626
-	if (
2627
-		($p = urls_decoder_url($action, ''))
2628
-		&& reset($p)
2629
-	) {
2630
-		$fond = array_shift($p);
2631
-		if ($fond != '404') {
2632
-			$contexte = array_shift($p);
2633
-			$contexte['page'] = $fond;
2634
-			$action = preg_replace('/([?]' . preg_quote((string) $fond, '/') . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2635
-		}
2636
-	}
2637
-	// defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2638
-	if (defined('_DEFINIR_CONTEXTE_TYPE') && _DEFINIR_CONTEXTE_TYPE) {
2639
-		unset($contexte['type']);
2640
-	}
2641
-	if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') || _DEFINIR_CONTEXTE_TYPE_PAGE) {
2642
-		unset($contexte['type-page']);
2643
-	}
2644
-
2645
-	// on va remplir un tableau de valeurs en prenant bien soin de ne pas
2646
-	// ecraser les elements de la forme mots[]=1&mots[]=2
2647
-	$values = [];
2648
-
2649
-	// d'abord avec celles de l'url
2650
-	if (false !== ($p = strpos($action, '?'))) {
2651
-		foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2652
-			$c = explode('=', (string) $c, 2);
2653
-			$var = array_shift($c);
2654
-			$val = array_shift($c) ?? '';
2655
-			if ($var) {
2656
-				$val = rawurldecode($val);
2657
-				$var = rawurldecode($var); // decoder les [] eventuels
2658
-				if (preg_match(',\[\]$,S', $var)) {
2659
-					$values[] = [$var, $val];
2660
-				} else {
2661
-					if (!isset($values[$var])) {
2662
-						$values[$var] = [$var, $val];
2663
-					}
2664
-				}
2665
-			}
2666
-		}
2667
-	}
2668
-
2669
-	// ensuite avec celles du contexte, sans doublonner !
2670
-	foreach ($contexte as $var => $val) {
2671
-		if (preg_match(',\[\]$,S', (string) $var)) {
2672
-			$values[] = [$var, $val];
2673
-		} else {
2674
-			if (!isset($values[$var])) {
2675
-				$values[$var] = [$var, $val];
2676
-			}
2677
-		}
2678
-	}
2679
-
2680
-	// puis on rassemble le tout
2681
-	$hidden = [];
2682
-	foreach ($values as $value) {
2683
-		[$var, $val] = $value;
2684
-		$hidden[] = '<input name="'
2685
-			. entites_html($var)
2686
-			. '"'
2687
-			. (is_null($val)
2688
-				? ''
2689
-				: ' value="' . entites_html($val) . '"'
2690
-			)
2691
-			. ' type="hidden"' . "\n/>";
2692
-	}
2693
-
2694
-	return implode('', $hidden);
2622
+    $action ??= '';
2623
+
2624
+    $contexte = [];
2625
+    include_spip('inc/urls');
2626
+    if (
2627
+        ($p = urls_decoder_url($action, ''))
2628
+        && reset($p)
2629
+    ) {
2630
+        $fond = array_shift($p);
2631
+        if ($fond != '404') {
2632
+            $contexte = array_shift($p);
2633
+            $contexte['page'] = $fond;
2634
+            $action = preg_replace('/([?]' . preg_quote((string) $fond, '/') . '[^&=]*[0-9]+)(&|$)/', '?&', $action);
2635
+        }
2636
+    }
2637
+    // defaire ce qu'a injecte urls_decoder_url : a revoir en modifiant la signature de urls_decoder_url
2638
+    if (defined('_DEFINIR_CONTEXTE_TYPE') && _DEFINIR_CONTEXTE_TYPE) {
2639
+        unset($contexte['type']);
2640
+    }
2641
+    if (!defined('_DEFINIR_CONTEXTE_TYPE_PAGE') || _DEFINIR_CONTEXTE_TYPE_PAGE) {
2642
+        unset($contexte['type-page']);
2643
+    }
2644
+
2645
+    // on va remplir un tableau de valeurs en prenant bien soin de ne pas
2646
+    // ecraser les elements de la forme mots[]=1&mots[]=2
2647
+    $values = [];
2648
+
2649
+    // d'abord avec celles de l'url
2650
+    if (false !== ($p = strpos($action, '?'))) {
2651
+        foreach (preg_split('/&(amp;)?/S', substr($action, $p + 1)) as $c) {
2652
+            $c = explode('=', (string) $c, 2);
2653
+            $var = array_shift($c);
2654
+            $val = array_shift($c) ?? '';
2655
+            if ($var) {
2656
+                $val = rawurldecode($val);
2657
+                $var = rawurldecode($var); // decoder les [] eventuels
2658
+                if (preg_match(',\[\]$,S', $var)) {
2659
+                    $values[] = [$var, $val];
2660
+                } else {
2661
+                    if (!isset($values[$var])) {
2662
+                        $values[$var] = [$var, $val];
2663
+                    }
2664
+                }
2665
+            }
2666
+        }
2667
+    }
2668
+
2669
+    // ensuite avec celles du contexte, sans doublonner !
2670
+    foreach ($contexte as $var => $val) {
2671
+        if (preg_match(',\[\]$,S', (string) $var)) {
2672
+            $values[] = [$var, $val];
2673
+        } else {
2674
+            if (!isset($values[$var])) {
2675
+                $values[$var] = [$var, $val];
2676
+            }
2677
+        }
2678
+    }
2679
+
2680
+    // puis on rassemble le tout
2681
+    $hidden = [];
2682
+    foreach ($values as $value) {
2683
+        [$var, $val] = $value;
2684
+        $hidden[] = '<input name="'
2685
+            . entites_html($var)
2686
+            . '"'
2687
+            . (is_null($val)
2688
+                ? ''
2689
+                : ' value="' . entites_html($val) . '"'
2690
+            )
2691
+            . ' type="hidden"' . "\n/>";
2692
+    }
2693
+
2694
+    return implode('', $hidden);
2695 2695
 }
2696 2696
 
2697 2697
 
@@ -2713,7 +2713,7 @@  discard block
 block discarded – undo
2713 2713
  *    - la première valeur du tableau sinon.
2714 2714
  **/
2715 2715
 function filtre_reset($array) {
2716
-	return is_array($array) ? reset($array) : null;
2716
+    return is_array($array) ? reset($array) : null;
2717 2717
 }
2718 2718
 
2719 2719
 /**
@@ -2734,7 +2734,7 @@  discard block
 block discarded – undo
2734 2734
  *    - la dernière valeur du tableau sinon.
2735 2735
  **/
2736 2736
 function filtre_end($array) {
2737
-	return is_array($array) ? end($array) : null;
2737
+    return is_array($array) ? end($array) : null;
2738 2738
 }
2739 2739
 
2740 2740
 /**
@@ -2754,11 +2754,11 @@  discard block
 block discarded – undo
2754 2754
  *
2755 2755
  **/
2756 2756
 function filtre_push($array, mixed $val) {
2757
-	if (!is_array($array) || !array_push($array, $val)) {
2758
-		return '';
2759
-	}
2757
+    if (!is_array($array) || !array_push($array, $val)) {
2758
+        return '';
2759
+    }
2760 2760
 
2761
-	return $array;
2761
+    return $array;
2762 2762
 }
2763 2763
 
2764 2764
 /**
@@ -2777,7 +2777,7 @@  discard block
 block discarded – undo
2777 2777
  *     - `true` si la valeur existe dans le tableau, `false` sinon.
2778 2778
  **/
2779 2779
 function filtre_find($array, mixed $val) {
2780
-	return (is_array($array) && in_array($val, $array));
2780
+    return (is_array($array) && in_array($val, $array));
2781 2781
 }
2782 2782
 
2783 2783
 
@@ -2794,13 +2794,13 @@  discard block
 block discarded – undo
2794 2794
  *     Contenu avec urls en absolus
2795 2795
  **/
2796 2796
 function urls_absolues_css($contenu, $source) {
2797
-	$path = suivre_lien(url_absolue($source), './');
2797
+    $path = suivre_lien(url_absolue($source), './');
2798 2798
 
2799
-	return preg_replace_callback(
2800
-		",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2801
-		fn($x) => "url('" . suivre_lien($path, $x[1]) . "')",
2802
-		$contenu
2803
-	);
2799
+    return preg_replace_callback(
2800
+        ",url\s*\(\s*['\"]?([^'\"/#\s][^:]*)['\"]?\s*\),Uims",
2801
+        fn($x) => "url('" . suivre_lien($path, $x[1]) . "')",
2802
+        $contenu
2803
+    );
2804 2804
 }
2805 2805
 
2806 2806
 
@@ -2829,123 +2829,123 @@  discard block
 block discarded – undo
2829 2829
  *     Chemin du fichier CSS inversé
2830 2830
  **/
2831 2831
 function direction_css($css, $voulue = '') {
2832
-	if (!$css) {
2833
-		return '';
2834
-	}
2835
-	if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) {
2836
-		return $css;
2837
-	}
2838
-	include_spip('inc/lang');
2839
-	// si on a precise le sens voulu en argument, le prendre en compte
2840
-	if ($voulue = strtolower($voulue)) {
2841
-		if ($voulue != 'rtl' && $voulue != 'ltr') {
2842
-			$voulue = lang_dir($voulue);
2843
-		}
2844
-	} else {
2845
-		$voulue = lang_dir();
2846
-	}
2847
-
2848
-	$r = count($r) > 1;
2849
-	$right = $r ? 'left' : 'right'; // 'right' de la css lue en entree
2850
-	$dir = $r ? 'rtl' : 'ltr';
2851
-	$ndir = $r ? 'ltr' : 'rtl';
2852
-
2853
-	if ($voulue == $dir) {
2854
-		return $css;
2855
-	}
2856
-
2857
-	if (
2858
-		// url absolue
2859
-		preg_match(',^https?:,i', $css)
2860
-		// ou qui contient un ?
2861
-		|| ($p = strpos($css, '?')) !== false
2862
-	) {
2863
-		$distant = true;
2864
-		$cssf = parse_url($css);
2865
-		$cssf = $cssf['path'] . ($cssf['query'] ? '?' . $cssf['query'] : '');
2866
-		$cssf = preg_replace(',[?:&=],', '_', $cssf);
2867
-	} else {
2868
-		$distant = false;
2869
-		$cssf = $css;
2870
-		// 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2871
-		//propose (rien a faire dans ce cas)
2872
-		$f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2873
-		if (@file_exists($f)) {
2874
-			return $f;
2875
-		}
2876
-	}
2877
-
2878
-	// 2.
2879
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2880
-	$f = $dir_var
2881
-		. preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2882
-		. '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2883
-
2884
-	// la css peut etre distante (url absolue !)
2885
-	$contenu = null;
2886
-	if ($distant) {
2887
-		include_spip('inc/distant');
2888
-		$res = recuperer_url($css);
2889
-		if (!$res || !($contenu = $res['page'])) {
2890
-			return $css;
2891
-		}
2892
-	} else {
2893
-		if (
2894
-			@filemtime($f) > @filemtime($css)
2895
-			&& _VAR_MODE != 'recalcul'
2896
-		) {
2897
-			return $f;
2898
-		}
2899
-		if (!lire_fichier($css, $contenu)) {
2900
-			return $css;
2901
-		}
2902
-	}
2903
-
2904
-
2905
-	// Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands
2906
-	include_spip('lib/csstidy/class.csstidy');
2907
-	$parser = new csstidy();
2908
-	$parser->set_cfg('optimise_shorthands', 0);
2909
-	$parser->set_cfg('reverse_left_and_right', true);
2910
-	$parser->parse($contenu);
2911
-
2912
-	$contenu = $parser->print->plain();
2913
-
2914
-
2915
-	// reperer les @import auxquels il faut propager le direction_css
2916
-	preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", (string) $contenu, $regs);
2917
-	$src = [];
2918
-	$src_direction_css = [];
2919
-	$src_faux_abs = [];
2920
-	$d = dirname($css);
2921
-	foreach ($regs[1] as $k => $import_css) {
2922
-		$css_direction = direction_css("$d/$import_css", $voulue);
2923
-		// si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue
2924
-		if (substr($css_direction, 0, strlen($d) + 1) == "$d/") {
2925
-			$css_direction = substr($css_direction, strlen($d) + 1);
2926
-		} // si la css_direction commence par $dir_var on la fait passer pour une absolue
2927
-		elseif (str_starts_with($css_direction, $dir_var)) {
2928
-			$css_direction = substr($css_direction, strlen($dir_var));
2929
-			$src_faux_abs['/@@@@@@/' . $css_direction] = $css_direction;
2930
-			$css_direction = '/@@@@@@/' . $css_direction;
2931
-		}
2932
-		$src[] = $regs[0][$k];
2933
-		$src_direction_css[] = str_replace($import_css, $css_direction, (string) $regs[0][$k]);
2934
-	}
2935
-	$contenu = str_replace($src, $src_direction_css, (string) $contenu);
2936
-
2937
-	$contenu = urls_absolues_css($contenu, $css);
2938
-
2939
-	// virer les fausses url absolues que l'on a mis dans les import
2940
-	if ($src_faux_abs !== []) {
2941
-		$contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu);
2942
-	}
2943
-
2944
-	if (!ecrire_fichier($f, $contenu)) {
2945
-		return $css;
2946
-	}
2947
-
2948
-	return $f;
2832
+    if (!$css) {
2833
+        return '';
2834
+    }
2835
+    if (!preg_match(',(_rtl)?\.css$,i', $css, $r)) {
2836
+        return $css;
2837
+    }
2838
+    include_spip('inc/lang');
2839
+    // si on a precise le sens voulu en argument, le prendre en compte
2840
+    if ($voulue = strtolower($voulue)) {
2841
+        if ($voulue != 'rtl' && $voulue != 'ltr') {
2842
+            $voulue = lang_dir($voulue);
2843
+        }
2844
+    } else {
2845
+        $voulue = lang_dir();
2846
+    }
2847
+
2848
+    $r = count($r) > 1;
2849
+    $right = $r ? 'left' : 'right'; // 'right' de la css lue en entree
2850
+    $dir = $r ? 'rtl' : 'ltr';
2851
+    $ndir = $r ? 'ltr' : 'rtl';
2852
+
2853
+    if ($voulue == $dir) {
2854
+        return $css;
2855
+    }
2856
+
2857
+    if (
2858
+        // url absolue
2859
+        preg_match(',^https?:,i', $css)
2860
+        // ou qui contient un ?
2861
+        || ($p = strpos($css, '?')) !== false
2862
+    ) {
2863
+        $distant = true;
2864
+        $cssf = parse_url($css);
2865
+        $cssf = $cssf['path'] . ($cssf['query'] ? '?' . $cssf['query'] : '');
2866
+        $cssf = preg_replace(',[?:&=],', '_', $cssf);
2867
+    } else {
2868
+        $distant = false;
2869
+        $cssf = $css;
2870
+        // 1. regarder d'abord si un fichier avec la bonne direction n'est pas aussi
2871
+        //propose (rien a faire dans ce cas)
2872
+        $f = preg_replace(',(_rtl)?\.css$,i', '_' . $ndir . '.css', $css);
2873
+        if (@file_exists($f)) {
2874
+            return $f;
2875
+        }
2876
+    }
2877
+
2878
+    // 2.
2879
+    $dir_var = sous_repertoire(_DIR_VAR, 'cache-css');
2880
+    $f = $dir_var
2881
+        . preg_replace(',.*/(.*?)(_rtl)?\.css,', '\1', $cssf)
2882
+        . '.' . substr(md5($cssf), 0, 4) . '_' . $ndir . '.css';
2883
+
2884
+    // la css peut etre distante (url absolue !)
2885
+    $contenu = null;
2886
+    if ($distant) {
2887
+        include_spip('inc/distant');
2888
+        $res = recuperer_url($css);
2889
+        if (!$res || !($contenu = $res['page'])) {
2890
+            return $css;
2891
+        }
2892
+    } else {
2893
+        if (
2894
+            @filemtime($f) > @filemtime($css)
2895
+            && _VAR_MODE != 'recalcul'
2896
+        ) {
2897
+            return $f;
2898
+        }
2899
+        if (!lire_fichier($css, $contenu)) {
2900
+            return $css;
2901
+        }
2902
+    }
2903
+
2904
+
2905
+    // Inverser la direction gauche-droite en utilisant CSSTidy qui gere aussi les shorthands
2906
+    include_spip('lib/csstidy/class.csstidy');
2907
+    $parser = new csstidy();
2908
+    $parser->set_cfg('optimise_shorthands', 0);
2909
+    $parser->set_cfg('reverse_left_and_right', true);
2910
+    $parser->parse($contenu);
2911
+
2912
+    $contenu = $parser->print->plain();
2913
+
2914
+
2915
+    // reperer les @import auxquels il faut propager le direction_css
2916
+    preg_match_all(",\@import\s*url\s*\(\s*['\"]?([^'\"/][^:]*)['\"]?\s*\),Uims", (string) $contenu, $regs);
2917
+    $src = [];
2918
+    $src_direction_css = [];
2919
+    $src_faux_abs = [];
2920
+    $d = dirname($css);
2921
+    foreach ($regs[1] as $k => $import_css) {
2922
+        $css_direction = direction_css("$d/$import_css", $voulue);
2923
+        // si la css_direction est dans le meme path que la css d'origine, on tronque le path, elle sera passee en absolue
2924
+        if (substr($css_direction, 0, strlen($d) + 1) == "$d/") {
2925
+            $css_direction = substr($css_direction, strlen($d) + 1);
2926
+        } // si la css_direction commence par $dir_var on la fait passer pour une absolue
2927
+        elseif (str_starts_with($css_direction, $dir_var)) {
2928
+            $css_direction = substr($css_direction, strlen($dir_var));
2929
+            $src_faux_abs['/@@@@@@/' . $css_direction] = $css_direction;
2930
+            $css_direction = '/@@@@@@/' . $css_direction;
2931
+        }
2932
+        $src[] = $regs[0][$k];
2933
+        $src_direction_css[] = str_replace($import_css, $css_direction, (string) $regs[0][$k]);
2934
+    }
2935
+    $contenu = str_replace($src, $src_direction_css, (string) $contenu);
2936
+
2937
+    $contenu = urls_absolues_css($contenu, $css);
2938
+
2939
+    // virer les fausses url absolues que l'on a mis dans les import
2940
+    if ($src_faux_abs !== []) {
2941
+        $contenu = str_replace(array_keys($src_faux_abs), $src_faux_abs, $contenu);
2942
+    }
2943
+
2944
+    if (!ecrire_fichier($f, $contenu)) {
2945
+        return $css;
2946
+    }
2947
+
2948
+    return $f;
2949 2949
 }
2950 2950
 
2951 2951
 
@@ -2968,47 +2968,47 @@  discard block
 block discarded – undo
2968 2968
  *     - Chemin ou URL du fichier CSS source sinon.
2969 2969
  **/
2970 2970
 function url_absolue_css($css) {
2971
-	if (!preg_match(',\.css$,i', $css, $r)) {
2972
-		return $css;
2973
-	}
2971
+    if (!preg_match(',\.css$,i', $css, $r)) {
2972
+        return $css;
2973
+    }
2974 2974
 
2975
-	$url_absolue_css = url_absolue($css);
2975
+    $url_absolue_css = url_absolue($css);
2976 2976
 
2977
-	$f = basename($css, '.css');
2978
-	$f = sous_repertoire(_DIR_VAR, 'cache-css')
2979
-		. preg_replace(',(.*?)(_rtl|_ltr)?$,', "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
2980
-		. '.css';
2977
+    $f = basename($css, '.css');
2978
+    $f = sous_repertoire(_DIR_VAR, 'cache-css')
2979
+        . preg_replace(',(.*?)(_rtl|_ltr)?$,', "\\1-urlabs-" . substr(md5("$css-urlabs"), 0, 4) . "\\2", $f)
2980
+        . '.css';
2981 2981
 
2982
-	if (@filemtime($f) > @filemtime($css) && _VAR_MODE != 'recalcul') {
2983
-		return $f;
2984
-	}
2982
+    if (@filemtime($f) > @filemtime($css) && _VAR_MODE != 'recalcul') {
2983
+        return $f;
2984
+    }
2985 2985
 
2986
-	$contenu = null;
2987
-	if ($url_absolue_css == $css) {
2988
-		if (
2989
-			strncmp((string) $GLOBALS['meta']['adresse_site'], $css, $l = strlen((string) $GLOBALS['meta']['adresse_site'])) != 0
2990
-			|| !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
2991
-		) {
2992
-			include_spip('inc/distant');
2993
-			$contenu = recuperer_url($css);
2994
-			$contenu = $contenu['page'] ?? '';
2995
-			if (!$contenu) {
2996
-				return $css;
2997
-			}
2998
-		}
2999
-	} elseif (!lire_fichier($css, $contenu)) {
3000
-		return $css;
3001
-	}
2986
+    $contenu = null;
2987
+    if ($url_absolue_css == $css) {
2988
+        if (
2989
+            strncmp((string) $GLOBALS['meta']['adresse_site'], $css, $l = strlen((string) $GLOBALS['meta']['adresse_site'])) != 0
2990
+            || !lire_fichier(_DIR_RACINE . substr($css, $l), $contenu)
2991
+        ) {
2992
+            include_spip('inc/distant');
2993
+            $contenu = recuperer_url($css);
2994
+            $contenu = $contenu['page'] ?? '';
2995
+            if (!$contenu) {
2996
+                return $css;
2997
+            }
2998
+        }
2999
+    } elseif (!lire_fichier($css, $contenu)) {
3000
+        return $css;
3001
+    }
3002 3002
 
3003
-	// passer les url relatives a la css d'origine en url absolues
3004
-	$contenu = urls_absolues_css($contenu, $css);
3003
+    // passer les url relatives a la css d'origine en url absolues
3004
+    $contenu = urls_absolues_css($contenu, $css);
3005 3005
 
3006
-	// ecrire la css
3007
-	if (!ecrire_fichier($f, $contenu)) {
3008
-		return $css;
3009
-	}
3006
+    // ecrire la css
3007
+    if (!ecrire_fichier($f, $contenu)) {
3008
+        return $css;
3009
+    }
3010 3010
 
3011
-	return $f;
3011
+    return $f;
3012 3012
 }
3013 3013
 
3014 3014
 
@@ -3042,24 +3042,24 @@  discard block
 block discarded – undo
3042 3042
  *     Valeur trouvée ou valeur par défaut.
3043 3043
  **/
3044 3044
 function table_valeur(mixed $table, $cle, mixed $defaut = '', $conserver_null = false) {
3045
-	foreach (explode('/', $cle) as $k) {
3046
-		$table = (is_string($table) ? @unserialize($table) : $table);
3045
+    foreach (explode('/', $cle) as $k) {
3046
+        $table = (is_string($table) ? @unserialize($table) : $table);
3047 3047
 
3048
-		if (is_object($table)) {
3049
-			$table = ($k !== '' && isset($table->$k)) ? $table->$k : $defaut;
3050
-		} elseif (is_array($table)) {
3051
-			if ($conserver_null) {
3052
-				$table = array_key_exists($k, $table) ? $table[$k] : $defaut;
3053
-			} else {
3054
-				$table = ($table[$k] ?? $defaut);
3055
-			}
3056
-		} else {
3057
-			$table = $defaut;
3058
-			break;
3059
-		}
3060
-	}
3048
+        if (is_object($table)) {
3049
+            $table = ($k !== '' && isset($table->$k)) ? $table->$k : $defaut;
3050
+        } elseif (is_array($table)) {
3051
+            if ($conserver_null) {
3052
+                $table = array_key_exists($k, $table) ? $table[$k] : $defaut;
3053
+            } else {
3054
+                $table = ($table[$k] ?? $defaut);
3055
+            }
3056
+        } else {
3057
+            $table = $defaut;
3058
+            break;
3059
+        }
3060
+    }
3061 3061
 
3062
-	return $table;
3062
+    return $table;
3063 3063
 }
3064 3064
 
3065 3065
 /**
@@ -3092,22 +3092,22 @@  discard block
 block discarded – undo
3092 3092
  *     - string : expression trouvée.
3093 3093
  **/
3094 3094
 function filtre_match_dist(?string $texte, $expression, $modif = 'UuimsS', $capte = 0) {
3095
-	if ((int) $modif && $capte == 0) {
3096
-		$capte = $modif;
3097
-		$modif = 'UuimsS';
3098
-	}
3099
-	$expression = str_replace('\/', '/', $expression);
3100
-	$expression = str_replace('/', '\/', $expression);
3095
+    if ((int) $modif && $capte == 0) {
3096
+        $capte = $modif;
3097
+        $modif = 'UuimsS';
3098
+    }
3099
+    $expression = str_replace('\/', '/', $expression);
3100
+    $expression = str_replace('/', '\/', $expression);
3101 3101
 
3102
-	if (preg_match('/' . $expression . '/' . $modif, $texte ?? '', $r)) {
3103
-		if (isset($r[$capte])) {
3104
-			return $r[$capte];
3105
-		} else {
3106
-			return true;
3107
-		}
3108
-	}
3102
+    if (preg_match('/' . $expression . '/' . $modif, $texte ?? '', $r)) {
3103
+        if (isset($r[$capte])) {
3104
+            return $r[$capte];
3105
+        } else {
3106
+            return true;
3107
+        }
3108
+    }
3109 3109
 
3110
-	return false;
3110
+    return false;
3111 3111
 }
3112 3112
 
3113 3113
 
@@ -3134,14 +3134,14 @@  discard block
 block discarded – undo
3134 3134
  *     Texte
3135 3135
  **/
3136 3136
 function replace(?string $texte, string $expression, string $replace = '', string $modif = 'UimsS'): string {
3137
-	if (null === $texte) {
3138
-		return '';
3139
-	}
3137
+    if (null === $texte) {
3138
+        return '';
3139
+    }
3140 3140
 
3141
-	$expression = str_replace('\/', '/', $expression);
3142
-	$expression = str_replace('/', '\/', $expression);
3141
+    $expression = str_replace('\/', '/', $expression);
3142
+    $expression = str_replace('/', '\/', $expression);
3143 3143
 
3144
-	return (string) preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3144
+    return (string) preg_replace('/' . $expression . '/' . $modif, $replace, $texte);
3145 3145
 }
3146 3146
 
3147 3147
 
@@ -3159,25 +3159,25 @@  discard block
 block discarded – undo
3159 3159
  **/
3160 3160
 function traiter_doublons_documents(&$doublons, $letexte) {
3161 3161
 
3162
-	// Verifier dans le texte & les notes (pas beau, helas)
3163
-	$t = $letexte . $GLOBALS['les_notes'];
3162
+    // Verifier dans le texte & les notes (pas beau, helas)
3163
+    $t = $letexte . $GLOBALS['les_notes'];
3164 3164
 
3165
-	if (
3166
-		strstr($t, 'spip_document_')
3167
-		&& preg_match_all(
3168
-			',<[^>]+\sclass=["\']spip_document_(\d+)[\s"\'],imsS',
3169
-			$t,
3170
-			$matches,
3171
-			PREG_PATTERN_ORDER
3172
-		)
3173
-	) {
3174
-		if (!isset($doublons['documents'])) {
3175
-			$doublons['documents'] = '';
3176
-		}
3177
-		$doublons['documents'] .= ',' . implode(',', $matches[1]);
3178
-	}
3165
+    if (
3166
+        strstr($t, 'spip_document_')
3167
+        && preg_match_all(
3168
+            ',<[^>]+\sclass=["\']spip_document_(\d+)[\s"\'],imsS',
3169
+            $t,
3170
+            $matches,
3171
+            PREG_PATTERN_ORDER
3172
+        )
3173
+    ) {
3174
+        if (!isset($doublons['documents'])) {
3175
+            $doublons['documents'] = '';
3176
+        }
3177
+        $doublons['documents'] .= ',' . implode(',', $matches[1]);
3178
+    }
3179 3179
 
3180
-	return $letexte;
3180
+    return $letexte;
3181 3181
 }
3182 3182
 
3183 3183
 /**
@@ -3191,7 +3191,7 @@  discard block
 block discarded – undo
3191 3191
  * @return string Chaîne vide
3192 3192
  **/
3193 3193
 function vide(mixed $texte) {
3194
-	return '';
3194
+    return '';
3195 3195
 }
3196 3196
 
3197 3197
 //
@@ -3220,23 +3220,23 @@  discard block
 block discarded – undo
3220 3220
  *      Code HTML résultant
3221 3221
  **/
3222 3222
 function env_to_params($env, $ignore_params = []) {
3223
-	$ignore_params = array_merge(
3224
-		['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'],
3225
-		$ignore_params
3226
-	);
3227
-	if (!is_array($env)) {
3228
-		$env = unserialize($env);
3229
-	}
3230
-	$texte = '';
3231
-	if ($env) {
3232
-		foreach ($env as $i => $j) {
3233
-			if (is_string($j) && !in_array($i, $ignore_params)) {
3234
-				$texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3235
-			}
3236
-		}
3237
-	}
3238
-
3239
-	return $texte;
3223
+    $ignore_params = array_merge(
3224
+        ['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'],
3225
+        $ignore_params
3226
+    );
3227
+    if (!is_array($env)) {
3228
+        $env = unserialize($env);
3229
+    }
3230
+    $texte = '';
3231
+    if ($env) {
3232
+        foreach ($env as $i => $j) {
3233
+            if (is_string($j) && !in_array($i, $ignore_params)) {
3234
+                $texte .= "<param name='" . attribut_html($i) . "'\n\tvalue='" . attribut_html($j) . "' />";
3235
+            }
3236
+        }
3237
+    }
3238
+
3239
+    return $texte;
3240 3240
 }
3241 3241
 
3242 3242
 /**
@@ -3259,23 +3259,23 @@  discard block
 block discarded – undo
3259 3259
  *      Code HTML résultant
3260 3260
  **/
3261 3261
 function env_to_attributs($env, $ignore_params = []) {
3262
-	$ignore_params = array_merge(
3263
-		['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'],
3264
-		$ignore_params
3265
-	);
3266
-	if (!is_array($env)) {
3267
-		$env = unserialize($env);
3268
-	}
3269
-	$texte = '';
3270
-	if ($env) {
3271
-		foreach ($env as $i => $j) {
3272
-			if (is_string($j) && !in_array($i, $ignore_params)) {
3273
-				$texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3274
-			}
3275
-		}
3276
-	}
3262
+    $ignore_params = array_merge(
3263
+        ['id', 'lang', 'id_document', 'date', 'date_redac', 'align', 'fond', '', 'recurs', 'emb', 'dir_racine'],
3264
+        $ignore_params
3265
+    );
3266
+    if (!is_array($env)) {
3267
+        $env = unserialize($env);
3268
+    }
3269
+    $texte = '';
3270
+    if ($env) {
3271
+        foreach ($env as $i => $j) {
3272
+            if (is_string($j) && !in_array($i, $ignore_params)) {
3273
+                $texte .= attribut_html($i) . "='" . attribut_html($j) . "' ";
3274
+            }
3275
+        }
3276
+    }
3277 3277
 
3278
-	return $texte;
3278
+    return $texte;
3279 3279
 }
3280 3280
 
3281 3281
 
@@ -3293,7 +3293,7 @@  discard block
 block discarded – undo
3293 3293
  * @return string Chaînes concaténés
3294 3294
  **/
3295 3295
 function concat(...$args): string {
3296
-	return implode('', $args);
3296
+    return implode('', $args);
3297 3297
 }
3298 3298
 
3299 3299
 
@@ -3313,23 +3313,23 @@  discard block
 block discarded – undo
3313 3313
  *     Contenu du ou des fichiers, concaténé
3314 3314
  **/
3315 3315
 function charge_scripts($files, $script = true) {
3316
-	$flux = '';
3317
-	foreach (is_array($files) ? $files : explode('|', $files) as $file) {
3318
-		if (!is_string($file)) {
3319
-			continue;
3320
-		}
3321
-		if ($script) {
3322
-			$file = preg_match(',^\w+$,', $file) ? "javascript/$file.js" : '';
3323
-		}
3324
-		if ($file) {
3325
-			$path = find_in_path($file);
3326
-			if ($path) {
3327
-				$flux .= spip_file_get_contents($path);
3328
-			}
3329
-		}
3330
-	}
3331
-
3332
-	return $flux;
3316
+    $flux = '';
3317
+    foreach (is_array($files) ? $files : explode('|', $files) as $file) {
3318
+        if (!is_string($file)) {
3319
+            continue;
3320
+        }
3321
+        if ($script) {
3322
+            $file = preg_match(',^\w+$,', $file) ? "javascript/$file.js" : '';
3323
+        }
3324
+        if ($file) {
3325
+            $path = find_in_path($file);
3326
+            if ($path) {
3327
+                $flux .= spip_file_get_contents($path);
3328
+            }
3329
+        }
3330
+    }
3331
+
3332
+    return $flux;
3333 3333
 }
3334 3334
 
3335 3335
 /**
@@ -3340,24 +3340,24 @@  discard block
 block discarded – undo
3340 3340
  * @return string
3341 3341
  */
3342 3342
 function http_img_variante_svg_si_possible($img_file) {
3343
-	// on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3344
-	// si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3345
-	if (
3346
-		preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3347
-		&& ($variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . '-xx.svg')
3348
-		&& file_exists($variante_svg_generique)
3349
-	) {
3350
-		if (
3351
-			($variante_svg_size = substr($variante_svg_generique, 0, -6) . $m[1] . '.svg')
3352
-			&& file_exists($variante_svg_size)
3353
-		) {
3354
-			$img_file = $variante_svg_size;
3355
-		} else {
3356
-			$img_file = $variante_svg_generique;
3357
-		}
3358
-	}
3359
-
3360
-	return $img_file;
3343
+    // on peut fournir une icone generique -xx.svg qui fera le job dans toutes les tailles, et qui est prioritaire sur le png
3344
+    // si il y a un .svg a la bonne taille (-16.svg) a cote, on l'utilise en remplacement du -16.png
3345
+    if (
3346
+        preg_match(',-(\d+)[.](png|gif|svg)$,', $img_file, $m)
3347
+        && ($variante_svg_generique = substr($img_file, 0, -strlen($m[0])) . '-xx.svg')
3348
+        && file_exists($variante_svg_generique)
3349
+    ) {
3350
+        if (
3351
+            ($variante_svg_size = substr($variante_svg_generique, 0, -6) . $m[1] . '.svg')
3352
+            && file_exists($variante_svg_size)
3353
+        ) {
3354
+            $img_file = $variante_svg_size;
3355
+        } else {
3356
+            $img_file = $variante_svg_generique;
3357
+        }
3358
+    }
3359
+
3360
+    return $img_file;
3361 3361
 }
3362 3362
 
3363 3363
 /**
@@ -3378,51 +3378,51 @@  discard block
 block discarded – undo
3378 3378
  */
3379 3379
 function http_img_pack($img, $alt, $atts = '', $title = '', $options = []) {
3380 3380
 
3381
-	$img_file = $img;
3382
-	if ($p = strpos($img_file, '?')) {
3383
-		$img_file = substr($img_file, 0, $p);
3384
-	}
3385
-	if (!isset($options['chemin_image']) || $options['chemin_image'] == true) {
3386
-		$img_file = chemin_image($img);
3387
-	}
3388
-	else {
3389
-		if (!isset($options['variante_svg_si_possible']) || $options['variante_svg_si_possible'] == true) {
3390
-			$img_file = http_img_variante_svg_si_possible($img_file);
3391
-		}
3392
-	}
3393
-	if (stripos($atts, 'width') === false) {
3394
-		// utiliser directement l'info de taille presente dans le nom
3395
-		if (
3396
-			(!isset($options['utiliser_suffixe_size']) || $options['utiliser_suffixe_size'] == true || str_contains($img_file, '-xx.svg'))
3397
-			&& (preg_match(',-(\d+)[.](png|gif|svg)$,', $img, $regs) || preg_match(',\?(\d+)px$,', $img, $regs))
3398
-		) {
3399
-			$largeur = $hauteur = (int) $regs[1];
3400
-		} else {
3401
-			$taille = taille_image($img_file);
3402
-			[$hauteur, $largeur] = $taille;
3403
-			if (!$hauteur || !$largeur) {
3404
-				return '';
3405
-			}
3406
-		}
3407
-		$atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3408
-	}
3409
-
3410
-	if (file_exists($img_file)) {
3411
-		$img_file = timestamp($img_file);
3412
-	}
3413
-	if ($alt === false) {
3414
-		$alt = '';
3415
-	}
3416
-	elseif ($alt || $alt === '') {
3417
-		$alt = " alt='" . attribut_html($alt) . "'";
3418
-	}
3419
-	else {
3420
-		$alt = " alt='" . attribut_html($title) . "'";
3421
-	}
3422
-	return "<img src='" . attribut_html($img_file) . "'$alt"
3423
-	. ($title ? ' title="' . attribut_html($title) . '"' : '')
3424
-	. ' ' . ltrim($atts)
3425
-	. ' />';
3381
+    $img_file = $img;
3382
+    if ($p = strpos($img_file, '?')) {
3383
+        $img_file = substr($img_file, 0, $p);
3384
+    }
3385
+    if (!isset($options['chemin_image']) || $options['chemin_image'] == true) {
3386
+        $img_file = chemin_image($img);
3387
+    }
3388
+    else {
3389
+        if (!isset($options['variante_svg_si_possible']) || $options['variante_svg_si_possible'] == true) {
3390
+            $img_file = http_img_variante_svg_si_possible($img_file);
3391
+        }
3392
+    }
3393
+    if (stripos($atts, 'width') === false) {
3394
+        // utiliser directement l'info de taille presente dans le nom
3395
+        if (
3396
+            (!isset($options['utiliser_suffixe_size']) || $options['utiliser_suffixe_size'] == true || str_contains($img_file, '-xx.svg'))
3397
+            && (preg_match(',-(\d+)[.](png|gif|svg)$,', $img, $regs) || preg_match(',\?(\d+)px$,', $img, $regs))
3398
+        ) {
3399
+            $largeur = $hauteur = (int) $regs[1];
3400
+        } else {
3401
+            $taille = taille_image($img_file);
3402
+            [$hauteur, $largeur] = $taille;
3403
+            if (!$hauteur || !$largeur) {
3404
+                return '';
3405
+            }
3406
+        }
3407
+        $atts .= " width='" . $largeur . "' height='" . $hauteur . "'";
3408
+    }
3409
+
3410
+    if (file_exists($img_file)) {
3411
+        $img_file = timestamp($img_file);
3412
+    }
3413
+    if ($alt === false) {
3414
+        $alt = '';
3415
+    }
3416
+    elseif ($alt || $alt === '') {
3417
+        $alt = " alt='" . attribut_html($alt) . "'";
3418
+    }
3419
+    else {
3420
+        $alt = " alt='" . attribut_html($title) . "'";
3421
+    }
3422
+    return "<img src='" . attribut_html($img_file) . "'$alt"
3423
+    . ($title ? ' title="' . attribut_html($title) . '"' : '')
3424
+    . ' ' . ltrim($atts)
3425
+    . ' />';
3426 3426
 }
3427 3427
 
3428 3428
 /**
@@ -3434,70 +3434,70 @@  discard block
 block discarded – undo
3434 3434
  * @return string
3435 3435
  */
3436 3436
 function http_style_background($img, $att = '', $size = null) {
3437
-	if ($size && is_numeric($size)) {
3438
-		$size = trim($size) . 'px';
3439
-	}
3440
-	return " style='background" .
3441
-		($att ? '' : '-image') . ': url("' . chemin_image($img) . '")' . ($att ? (' ' . $att) : '') . ';'
3442
-		. ($size ? "background-size:{$size};" : '')
3443
-		. "'";
3437
+    if ($size && is_numeric($size)) {
3438
+        $size = trim($size) . 'px';
3439
+    }
3440
+    return " style='background" .
3441
+        ($att ? '' : '-image') . ': url("' . chemin_image($img) . '")' . ($att ? (' ' . $att) : '') . ';'
3442
+        . ($size ? "background-size:{$size};" : '')
3443
+        . "'";
3444 3444
 }
3445 3445
 
3446 3446
 
3447 3447
 function helper_filtre_balise_img_svg_arguments($alt_or_size, $class_or_size, $size) {
3448
-	$args = [$alt_or_size, $class_or_size, $size];
3449
-	while (is_null(end($args)) && count($args)) {
3450
-		array_pop($args);
3451
-	}
3452
-	if ($args === []) {
3453
-		return [null, null, null];
3454
-	}
3455
-	if (count($args) < 3) {
3456
-		$maybe_size = array_pop($args);
3457
-		// @2x
3458
-		// @1.5x
3459
-		// 512
3460
-		// 512x*
3461
-		// 512x300
3462
-		if (
3463
-			!strlen((string) $maybe_size)
3464
-			|| !preg_match(',^(@\d+(\.\d+)?x|\d+(x\*)?|\d+x\d+)$,', trim((string) $maybe_size))
3465
-		) {
3466
-			$args[] = $maybe_size;
3467
-			$maybe_size = null;
3468
-		}
3469
-		while (count($args) < 2) {
3470
-			$args[] = null; // default alt or class
3471
-		}
3472
-		$args[] = $maybe_size;
3473
-	}
3474
-	return $args;
3448
+    $args = [$alt_or_size, $class_or_size, $size];
3449
+    while (is_null(end($args)) && count($args)) {
3450
+        array_pop($args);
3451
+    }
3452
+    if ($args === []) {
3453
+        return [null, null, null];
3454
+    }
3455
+    if (count($args) < 3) {
3456
+        $maybe_size = array_pop($args);
3457
+        // @2x
3458
+        // @1.5x
3459
+        // 512
3460
+        // 512x*
3461
+        // 512x300
3462
+        if (
3463
+            !strlen((string) $maybe_size)
3464
+            || !preg_match(',^(@\d+(\.\d+)?x|\d+(x\*)?|\d+x\d+)$,', trim((string) $maybe_size))
3465
+        ) {
3466
+            $args[] = $maybe_size;
3467
+            $maybe_size = null;
3468
+        }
3469
+        while (count($args) < 2) {
3470
+            $args[] = null; // default alt or class
3471
+        }
3472
+        $args[] = $maybe_size;
3473
+    }
3474
+    return $args;
3475 3475
 }
3476 3476
 
3477 3477
 function helper_filtre_balise_img_svg_size($img, $size) {
3478
-	// si size est de la forme '@2x' c'est un coeff multiplicateur sur la densite
3479
-	if (str_starts_with((string) $size, '@') && str_ends_with((string) $size, 'x')) {
3480
-		$coef = (float) substr((string) $size, 1, -1);
3481
-		[$h, $w] = taille_image($img);
3482
-		$height = (int) round($h / $coef);
3483
-		$width = (int) round($w / $coef);
3484
-	}
3485
-	// sinon c'est une valeur seule si image caree ou largeurxhauteur
3486
-	else {
3487
-		$size = explode('x', (string) $size, 2);
3488
-		$size = array_map('trim', $size);
3489
-		$height = $width = (int) array_shift($size);
3490
-
3491
-		if (count($size) && reset($size)) {
3492
-			$height = array_shift($size);
3493
-			if ($height === '*') {
3494
-				[$h, $w] = taille_image($img);
3495
-				$height = (int) round($h * $width / $w);
3496
-			}
3497
-		}
3498
-	}
3499
-
3500
-	return [$width, $height];
3478
+    // si size est de la forme '@2x' c'est un coeff multiplicateur sur la densite
3479
+    if (str_starts_with((string) $size, '@') && str_ends_with((string) $size, 'x')) {
3480
+        $coef = (float) substr((string) $size, 1, -1);
3481
+        [$h, $w] = taille_image($img);
3482
+        $height = (int) round($h / $coef);
3483
+        $width = (int) round($w / $coef);
3484
+    }
3485
+    // sinon c'est une valeur seule si image caree ou largeurxhauteur
3486
+    else {
3487
+        $size = explode('x', (string) $size, 2);
3488
+        $size = array_map('trim', $size);
3489
+        $height = $width = (int) array_shift($size);
3490
+
3491
+        if (count($size) && reset($size)) {
3492
+            $height = array_shift($size);
3493
+            if ($height === '*') {
3494
+                [$h, $w] = taille_image($img);
3495
+                $height = (int) round($h * $width / $w);
3496
+            }
3497
+        }
3498
+    }
3499
+
3500
+    return [$width, $height];
3501 3501
 }
3502 3502
 
3503 3503
 /**
@@ -3533,38 +3533,38 @@  discard block
 block discarded – undo
3533 3533
  */
3534 3534
 function filtre_balise_img_dist($img, $alt = '', $class = null, $size = null) {
3535 3535
 
3536
-	[$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3536
+    [$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3537 3537
 
3538
-	$img = trim((string) $img);
3539
-	if (str_starts_with($img, '<img')) {
3540
-		if (!is_null($alt)) {
3541
-			$img = inserer_attribut($img, 'alt', $alt);
3542
-		}
3543
-		if (!is_null($class)) {
3544
-			$img = strlen((string) $class) ? inserer_attribut($img, 'class', $class) : vider_attribut($img, 'class');
3545
-		}
3546
-	}
3547
-	else {
3548
-		$img = http_img_pack(
3549
-			$img,
3550
-			$alt,
3551
-			$class ? " class='" . attribut_html($class) . "'" : '',
3552
-			'',
3553
-			['chemin_image' => false, 'utiliser_suffixe_size' => false]
3554
-		);
3555
-		if (is_null($alt)) {
3556
-			$img = vider_attribut($img, 'alt');
3557
-		}
3558
-	}
3538
+    $img = trim((string) $img);
3539
+    if (str_starts_with($img, '<img')) {
3540
+        if (!is_null($alt)) {
3541
+            $img = inserer_attribut($img, 'alt', $alt);
3542
+        }
3543
+        if (!is_null($class)) {
3544
+            $img = strlen((string) $class) ? inserer_attribut($img, 'class', $class) : vider_attribut($img, 'class');
3545
+        }
3546
+    }
3547
+    else {
3548
+        $img = http_img_pack(
3549
+            $img,
3550
+            $alt,
3551
+            $class ? " class='" . attribut_html($class) . "'" : '',
3552
+            '',
3553
+            ['chemin_image' => false, 'utiliser_suffixe_size' => false]
3554
+        );
3555
+        if (is_null($alt)) {
3556
+            $img = vider_attribut($img, 'alt');
3557
+        }
3558
+    }
3559 3559
 
3560
-	if ($img && !is_null($size) && strlen($size = trim((string) $size))) {
3561
-		[$width, $height] = helper_filtre_balise_img_svg_size($img, $size);
3560
+    if ($img && !is_null($size) && strlen($size = trim((string) $size))) {
3561
+        [$width, $height] = helper_filtre_balise_img_svg_size($img, $size);
3562 3562
 
3563
-		$img = inserer_attribut($img, 'width', $width);
3564
-		$img = inserer_attribut($img, 'height', $height);
3565
-	}
3563
+        $img = inserer_attribut($img, 'width', $width);
3564
+        $img = inserer_attribut($img, 'height', $height);
3565
+    }
3566 3566
 
3567
-	return $img;
3567
+    return $img;
3568 3568
 }
3569 3569
 
3570 3570
 
@@ -3598,77 +3598,77 @@  discard block
 block discarded – undo
3598 3598
  */
3599 3599
 function filtre_balise_svg_dist($img, $alt = '', $class = null, $size = null) {
3600 3600
 
3601
-	$svg = null;
3602
-	$img = trim($img);
3603
-	$img_file = $img;
3604
-	if (!str_contains($img, '<svg')) {
3605
-		if ($p = strpos($img_file, '?')) {
3606
-			$img_file = substr($img_file, 0, $p);
3607
-		}
3608
-
3609
-		// ne jamais operer directement sur une image distante pour des raisons de perfo
3610
-		// la copie locale a toutes les chances d'etre la ou de resservir
3611
-		if (tester_url_absolue($img_file)) {
3612
-			include_spip('inc/distant');
3613
-			$fichier = copie_locale($img_file);
3614
-			$img_file = ($fichier ? _DIR_RACINE . $fichier : $img_file);
3615
-		}
3616
-
3617
-		if (
3618
-			!$img_file
3619
-			|| !file_exists($img_file)
3620
-			|| !$svg = file_get_contents($img_file)
3621
-		) {
3622
-			return '';
3623
-		}
3624
-	}
3625
-
3626
-	if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) {
3627
-		return '';
3628
-	}
3629
-
3630
-	[$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3631
-
3632
-	$balise_svg = $match[0];
3633
-	$balise_svg_source = $balise_svg;
3634
-
3635
-	// entete XML à supprimer
3636
-	$svg = preg_replace(',^\s*<\?xml[^>]*\?>,', '', $svg);
3637
-
3638
-	// IE est toujours mon ami
3639
-	$balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3640
-
3641
-	// regler la classe
3642
-	if (!is_null($class)) {
3643
-		$balise_svg = strlen((string) $class)
3644
-			? inserer_attribut($balise_svg, 'class', $class)
3645
-			: vider_attribut($balise_svg, 'class');
3646
-	}
3647
-
3648
-	// regler le alt
3649
-	if ($alt) {
3650
-		$balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3651
-		$id = 'img-svg-title-' . substr(md5("$img_file:$svg:$alt"), 0, 4);
3652
-		$balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3653
-		$title = "<title id=\"$id\">" . entites_html($alt) . "</title>\n";
3654
-		$balise_svg .= $title;
3655
-	}
3656
-	else {
3657
-		$balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3658
-	}
3659
-
3660
-	$svg = str_replace($balise_svg_source, $balise_svg, $svg);
3661
-
3662
-	if (!is_null($size) && strlen($size = trim((string) $size))) {
3663
-		[$width, $height] = helper_filtre_balise_img_svg_size($svg, $size);
3664
-
3665
-		if (!function_exists('svg_redimensionner')) {
3666
-			include_spip('inc/svg');
3667
-		}
3668
-		$svg = svg_redimensionner($svg, $width, $height);
3669
-	}
3670
-
3671
-	return $svg;
3601
+    $svg = null;
3602
+    $img = trim($img);
3603
+    $img_file = $img;
3604
+    if (!str_contains($img, '<svg')) {
3605
+        if ($p = strpos($img_file, '?')) {
3606
+            $img_file = substr($img_file, 0, $p);
3607
+        }
3608
+
3609
+        // ne jamais operer directement sur une image distante pour des raisons de perfo
3610
+        // la copie locale a toutes les chances d'etre la ou de resservir
3611
+        if (tester_url_absolue($img_file)) {
3612
+            include_spip('inc/distant');
3613
+            $fichier = copie_locale($img_file);
3614
+            $img_file = ($fichier ? _DIR_RACINE . $fichier : $img_file);
3615
+        }
3616
+
3617
+        if (
3618
+            !$img_file
3619
+            || !file_exists($img_file)
3620
+            || !$svg = file_get_contents($img_file)
3621
+        ) {
3622
+            return '';
3623
+        }
3624
+    }
3625
+
3626
+    if (!preg_match(",<svg\b[^>]*>,UimsS", $svg, $match)) {
3627
+        return '';
3628
+    }
3629
+
3630
+    [$alt, $class, $size] = helper_filtre_balise_img_svg_arguments($alt, $class, $size);
3631
+
3632
+    $balise_svg = $match[0];
3633
+    $balise_svg_source = $balise_svg;
3634
+
3635
+    // entete XML à supprimer
3636
+    $svg = preg_replace(',^\s*<\?xml[^>]*\?>,', '', $svg);
3637
+
3638
+    // IE est toujours mon ami
3639
+    $balise_svg = inserer_attribut($balise_svg, 'focusable', 'false');
3640
+
3641
+    // regler la classe
3642
+    if (!is_null($class)) {
3643
+        $balise_svg = strlen((string) $class)
3644
+            ? inserer_attribut($balise_svg, 'class', $class)
3645
+            : vider_attribut($balise_svg, 'class');
3646
+    }
3647
+
3648
+    // regler le alt
3649
+    if ($alt) {
3650
+        $balise_svg = inserer_attribut($balise_svg, 'role', 'img');
3651
+        $id = 'img-svg-title-' . substr(md5("$img_file:$svg:$alt"), 0, 4);
3652
+        $balise_svg = inserer_attribut($balise_svg, 'aria-labelledby', $id);
3653
+        $title = "<title id=\"$id\">" . entites_html($alt) . "</title>\n";
3654
+        $balise_svg .= $title;
3655
+    }
3656
+    else {
3657
+        $balise_svg = inserer_attribut($balise_svg, 'aria-hidden', 'true');
3658
+    }
3659
+
3660
+    $svg = str_replace($balise_svg_source, $balise_svg, $svg);
3661
+
3662
+    if (!is_null($size) && strlen($size = trim((string) $size))) {
3663
+        [$width, $height] = helper_filtre_balise_img_svg_size($svg, $size);
3664
+
3665
+        if (!function_exists('svg_redimensionner')) {
3666
+            include_spip('inc/svg');
3667
+        }
3668
+        $svg = svg_redimensionner($svg, $width, $height);
3669
+    }
3670
+
3671
+    return $svg;
3672 3672
 }
3673 3673
 
3674 3674
 /**
@@ -3692,37 +3692,37 @@  discard block
 block discarded – undo
3692 3692
  *         - tout : retourne toutes les informations du plugin actif
3693 3693
  **/
3694 3694
 function filtre_info_plugin_dist($plugin, $type_info, $reload = false) {
3695
-	include_spip('inc/plugin');
3696
-	$plugin = strtoupper($plugin);
3697
-	$plugins_actifs = liste_plugin_actifs();
3698
-
3699
-	if (!$plugin) {
3700
-		return serialize(array_keys($plugins_actifs));
3701
-	} elseif (empty($plugins_actifs[$plugin]) && !$reload) {
3702
-		return '';
3703
-	} elseif ($type_info == 'est_actif' && !$reload) {
3704
-		return $plugins_actifs[$plugin] ? 1 : 0;
3705
-	} elseif (isset($plugins_actifs[$plugin][$type_info]) && !$reload) {
3706
-		return $plugins_actifs[$plugin][$type_info];
3707
-	} else {
3708
-		$get_infos = charger_fonction('get_infos', 'plugins');
3709
-		// On prend en compte les extensions
3710
-		if (!is_dir($plugins_actifs[$plugin]['dir_type'])) {
3711
-			$dir_plugins = constant($plugins_actifs[$plugin]['dir_type']);
3712
-		} else {
3713
-			$dir_plugins = $plugins_actifs[$plugin]['dir_type'];
3714
-		}
3715
-		if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) {
3716
-			return '';
3717
-		}
3718
-		if ($type_info == 'tout') {
3719
-			return $infos;
3720
-		} elseif ($type_info == 'est_actif') {
3721
-			return $infos ? 1 : 0;
3722
-		} else {
3723
-			return (string) $infos[$type_info];
3724
-		}
3725
-	}
3695
+    include_spip('inc/plugin');
3696
+    $plugin = strtoupper($plugin);
3697
+    $plugins_actifs = liste_plugin_actifs();
3698
+
3699
+    if (!$plugin) {
3700
+        return serialize(array_keys($plugins_actifs));
3701
+    } elseif (empty($plugins_actifs[$plugin]) && !$reload) {
3702
+        return '';
3703
+    } elseif ($type_info == 'est_actif' && !$reload) {
3704
+        return $plugins_actifs[$plugin] ? 1 : 0;
3705
+    } elseif (isset($plugins_actifs[$plugin][$type_info]) && !$reload) {
3706
+        return $plugins_actifs[$plugin][$type_info];
3707
+    } else {
3708
+        $get_infos = charger_fonction('get_infos', 'plugins');
3709
+        // On prend en compte les extensions
3710
+        if (!is_dir($plugins_actifs[$plugin]['dir_type'])) {
3711
+            $dir_plugins = constant($plugins_actifs[$plugin]['dir_type']);
3712
+        } else {
3713
+            $dir_plugins = $plugins_actifs[$plugin]['dir_type'];
3714
+        }
3715
+        if (!$infos = $get_infos($plugins_actifs[$plugin]['dir'], $reload, $dir_plugins)) {
3716
+            return '';
3717
+        }
3718
+        if ($type_info == 'tout') {
3719
+            return $infos;
3720
+        } elseif ($type_info == 'est_actif') {
3721
+            return $infos ? 1 : 0;
3722
+        } else {
3723
+            return (string) $infos[$type_info];
3724
+        }
3725
+    }
3726 3726
 }
3727 3727
 
3728 3728
 
@@ -3749,9 +3749,9 @@  discard block
 block discarded – undo
3749 3749
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
3750 3750
  */
3751 3751
 function puce_changement_statut($id_objet, $statut, $id_rubrique, $type, $ajax = false) {
3752
-	$puce_statut = charger_fonction('puce_statut', 'inc');
3752
+    $puce_statut = charger_fonction('puce_statut', 'inc');
3753 3753
 
3754
-	return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax);
3754
+    return $puce_statut($id_objet, $statut, $id_rubrique, $type, $ajax);
3755 3755
 }
3756 3756
 
3757 3757
 
@@ -3781,19 +3781,19 @@  discard block
 block discarded – undo
3781 3781
  *     Code HTML de l'image de puce de statut à insérer (et du menu de changement si présent)
3782 3782
  */
3783 3783
 function filtre_puce_statut_dist($statut, $objet, $id_objet = 0, $id_parent = 0) {
3784
-	static $puce_statut = null;
3785
-	if (!$puce_statut) {
3786
-		$puce_statut = charger_fonction('puce_statut', 'inc');
3787
-	}
3784
+    static $puce_statut = null;
3785
+    if (!$puce_statut) {
3786
+        $puce_statut = charger_fonction('puce_statut', 'inc');
3787
+    }
3788 3788
 
3789
-	return $puce_statut(
3790
-		$id_objet,
3791
-		$statut,
3792
-		$id_parent,
3793
-		$objet,
3794
-		false,
3795
-		objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false
3796
-	);
3789
+    return $puce_statut(
3790
+        $id_objet,
3791
+        $statut,
3792
+        $id_parent,
3793
+        $objet,
3794
+        false,
3795
+        objet_info($objet, 'editable') ? _ACTIVER_PUCE_RAPIDE : false
3796
+    );
3797 3797
 }
3798 3798
 
3799 3799
 
@@ -3820,94 +3820,94 @@  discard block
 block discarded – undo
3820 3820
  *   hash du contexte
3821 3821
  */
3822 3822
 function encoder_contexte_ajax($c, $form = '', $emboite = null, $ajaxid = '') {
3823
-	$env = null;
3824
-	if (is_string($c) && @unserialize($c) !== false) {
3825
-		$c = unserialize($c);
3826
-	}
3827
-
3828
-	// supprimer les parametres debut_x
3829
-	// pour que la pagination ajax ne soit pas plantee
3830
-	// si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0,
3831
-	// le debut_x=0 n'existe pas, et on resterait sur 1
3832
-	if (is_array($c)) {
3833
-		foreach (array_keys($c) as $k) {
3834
-			if (str_starts_with($k, 'debut_')) {
3835
-				unset($c[$k]);
3836
-			}
3837
-		}
3838
-	}
3839
-
3840
-	if (!function_exists('calculer_cle_action')) {
3841
-		include_spip('inc/securiser_action');
3842
-	}
3843
-
3844
-	$c = serialize($c);
3845
-	$cle = calculer_cle_action($form . $c);
3846
-	$c = "$cle:$c";
3847
-
3848
-	// on ne stocke pas les contextes dans des fichiers en cache
3849
-	// par defaut, sauf si cette configuration a été forcée
3850
-	// OU que la longueur de l’argument géneré est plus long
3851
-	// que ce qui est toléré.
3852
-	$cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') && _CACHE_CONTEXTES_AJAX);
3853
-	if (!$cache_contextes_ajax) {
3854
-		$env = $c;
3855
-		if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3856
-			$env = gzdeflate($env);
3857
-		}
3858
-		$env = _xor($env);
3859
-		$env = base64_encode($env);
3860
-		$len = strlen($env);
3861
-		// Si l’url est trop longue pour le navigateur
3862
-		$max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR;
3863
-		if ($len > $max_len) {
3864
-			$cache_contextes_ajax = true;
3865
-			spip_logger()->warning(
3866
-				'Contextes AJAX forces en fichiers !'
3867
-				. ' Cela arrive lorsque la valeur du contexte'
3868
-				. " depasse la longueur maximale autorisee ($max_len). Ici : $len.",
3869
-			);
3870
-		}
3871
-		// Sinon si Suhosin est actif et a une la valeur maximale des variables en GET...
3872
-		elseif (
3873
-			($max_len = @ini_get('suhosin.get.max_value_length'))
3874
-			&& $max_len < $len
3875
-		) {
3876
-			$cache_contextes_ajax = true;
3877
-			spip_logger()->warning('Contextes AJAX forces en fichiers !'
3878
-				. ' Cela arrive lorsque la valeur du contexte'
3879
-				. ' depasse la longueur maximale autorisee par Suhosin'
3880
-				. " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len."
3881
-				. ' Vous devriez modifier les parametres de Suhosin'
3882
-				. ' pour accepter au moins 1024 caracteres.');
3883
-		}
3884
-	}
3885
-
3886
-	if ($cache_contextes_ajax) {
3887
-		$dir = sous_repertoire(_DIR_CACHE, 'contextes');
3888
-		// stocker les contextes sur disque et ne passer qu'un hash dans l'url
3889
-		$md5 = md5($c);
3890
-		ecrire_fichier("$dir/c$md5", $c);
3891
-		$env = $md5;
3892
-	}
3893
-
3894
-	if ($emboite === null) {
3895
-		return $env;
3896
-	}
3897
-	if (!trim($emboite)) {
3898
-		return '';
3899
-	}
3900
-	// toujours encoder l'url source dans le bloc ajax
3901
-	$r = self();
3902
-	$r = ' data-origin="' . $r . '"';
3903
-	$class = 'ajaxbloc';
3904
-	if ($ajaxid && is_string($ajaxid)) {
3905
-		// ajaxid est normalement conforme a un nom de classe css
3906
-		// on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3907
-		$class .= ' ajax-id-' . entites_html($ajaxid);
3908
-	}
3909
-
3910
-	return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3823
+    $env = null;
3824
+    if (is_string($c) && @unserialize($c) !== false) {
3825
+        $c = unserialize($c);
3826
+    }
3827
+
3828
+    // supprimer les parametres debut_x
3829
+    // pour que la pagination ajax ne soit pas plantee
3830
+    // si on charge la page &debut_x=1 : car alors en cliquant sur l'item 0,
3831
+    // le debut_x=0 n'existe pas, et on resterait sur 1
3832
+    if (is_array($c)) {
3833
+        foreach (array_keys($c) as $k) {
3834
+            if (str_starts_with($k, 'debut_')) {
3835
+                unset($c[$k]);
3836
+            }
3837
+        }
3838
+    }
3839
+
3840
+    if (!function_exists('calculer_cle_action')) {
3841
+        include_spip('inc/securiser_action');
3842
+    }
3843
+
3844
+    $c = serialize($c);
3845
+    $cle = calculer_cle_action($form . $c);
3846
+    $c = "$cle:$c";
3847
+
3848
+    // on ne stocke pas les contextes dans des fichiers en cache
3849
+    // par defaut, sauf si cette configuration a été forcée
3850
+    // OU que la longueur de l’argument géneré est plus long
3851
+    // que ce qui est toléré.
3852
+    $cache_contextes_ajax = (defined('_CACHE_CONTEXTES_AJAX') && _CACHE_CONTEXTES_AJAX);
3853
+    if (!$cache_contextes_ajax) {
3854
+        $env = $c;
3855
+        if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3856
+            $env = gzdeflate($env);
3857
+        }
3858
+        $env = _xor($env);
3859
+        $env = base64_encode($env);
3860
+        $len = strlen($env);
3861
+        // Si l’url est trop longue pour le navigateur
3862
+        $max_len = _CACHE_CONTEXTES_AJAX_SUR_LONGUEUR;
3863
+        if ($len > $max_len) {
3864
+            $cache_contextes_ajax = true;
3865
+            spip_logger()->warning(
3866
+                'Contextes AJAX forces en fichiers !'
3867
+                . ' Cela arrive lorsque la valeur du contexte'
3868
+                . " depasse la longueur maximale autorisee ($max_len). Ici : $len.",
3869
+            );
3870
+        }
3871
+        // Sinon si Suhosin est actif et a une la valeur maximale des variables en GET...
3872
+        elseif (
3873
+            ($max_len = @ini_get('suhosin.get.max_value_length'))
3874
+            && $max_len < $len
3875
+        ) {
3876
+            $cache_contextes_ajax = true;
3877
+            spip_logger()->warning('Contextes AJAX forces en fichiers !'
3878
+                . ' Cela arrive lorsque la valeur du contexte'
3879
+                . ' depasse la longueur maximale autorisee par Suhosin'
3880
+                . " ($max_len) dans 'suhosin.get.max_value_length'. Ici : $len."
3881
+                . ' Vous devriez modifier les parametres de Suhosin'
3882
+                . ' pour accepter au moins 1024 caracteres.');
3883
+        }
3884
+    }
3885
+
3886
+    if ($cache_contextes_ajax) {
3887
+        $dir = sous_repertoire(_DIR_CACHE, 'contextes');
3888
+        // stocker les contextes sur disque et ne passer qu'un hash dans l'url
3889
+        $md5 = md5($c);
3890
+        ecrire_fichier("$dir/c$md5", $c);
3891
+        $env = $md5;
3892
+    }
3893
+
3894
+    if ($emboite === null) {
3895
+        return $env;
3896
+    }
3897
+    if (!trim($emboite)) {
3898
+        return '';
3899
+    }
3900
+    // toujours encoder l'url source dans le bloc ajax
3901
+    $r = self();
3902
+    $r = ' data-origin="' . $r . '"';
3903
+    $class = 'ajaxbloc';
3904
+    if ($ajaxid && is_string($ajaxid)) {
3905
+        // ajaxid est normalement conforme a un nom de classe css
3906
+        // on ne verifie pas la conformite, mais on passe entites_html par dessus par precaution
3907
+        $class .= ' ajax-id-' . entites_html($ajaxid);
3908
+    }
3909
+
3910
+    return "<div class='$class' " . "data-ajax-env='$env'$r>\n$emboite</div><!--ajaxbloc-->\n";
3911 3911
 }
3912 3912
 
3913 3913
 /**
@@ -3927,37 +3927,37 @@  discard block
 block discarded – undo
3927 3927
  *   - false : erreur de décodage
3928 3928
  */
3929 3929
 function decoder_contexte_ajax($c, $form = '') {
3930
-	$contexte = null;
3931
-	if (!function_exists('calculer_cle_action')) {
3932
-		include_spip('inc/securiser_action');
3933
-	}
3934
-	if (
3935
-		(defined('_CACHE_CONTEXTES_AJAX') && _CACHE_CONTEXTES_AJAX || strlen($c) == 32)
3936
-		&& ($dir = sous_repertoire(_DIR_CACHE, 'contextes'))
3937
-		&& lire_fichier("$dir/c$c", $contexte)
3938
-	) {
3939
-		$c = $contexte;
3940
-	} else {
3941
-		$c = @base64_decode($c);
3942
-		$c = _xor($c);
3943
-		if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3944
-			$c = @gzinflate($c);
3945
-		}
3946
-	}
3947
-
3948
-	// extraire la signature en debut de contexte
3949
-	// et la verifier avant de deserializer
3950
-	// format : signature:donneesserializees
3951
-	if ($p = strpos((string) $c, ':')) {
3952
-		$cle = substr((string) $c, 0, $p);
3953
-		$c = substr((string) $c, $p + 1);
3954
-
3955
-		if ($cle === calculer_cle_action($form . $c)) {
3956
-			return @unserialize($c);
3957
-		}
3958
-	}
3959
-
3960
-	return false;
3930
+    $contexte = null;
3931
+    if (!function_exists('calculer_cle_action')) {
3932
+        include_spip('inc/securiser_action');
3933
+    }
3934
+    if (
3935
+        (defined('_CACHE_CONTEXTES_AJAX') && _CACHE_CONTEXTES_AJAX || strlen($c) == 32)
3936
+        && ($dir = sous_repertoire(_DIR_CACHE, 'contextes'))
3937
+        && lire_fichier("$dir/c$c", $contexte)
3938
+    ) {
3939
+        $c = $contexte;
3940
+    } else {
3941
+        $c = @base64_decode($c);
3942
+        $c = _xor($c);
3943
+        if (function_exists('gzdeflate') && function_exists('gzinflate')) {
3944
+            $c = @gzinflate($c);
3945
+        }
3946
+    }
3947
+
3948
+    // extraire la signature en debut de contexte
3949
+    // et la verifier avant de deserializer
3950
+    // format : signature:donneesserializees
3951
+    if ($p = strpos((string) $c, ':')) {
3952
+        $cle = substr((string) $c, 0, $p);
3953
+        $c = substr((string) $c, $p + 1);
3954
+
3955
+        if ($cle === calculer_cle_action($form . $c)) {
3956
+            return @unserialize($c);
3957
+        }
3958
+    }
3959
+
3960
+    return false;
3961 3961
 }
3962 3962
 
3963 3963
 
@@ -3975,20 +3975,20 @@  discard block
 block discarded – undo
3975 3975
  *    Message décrypté ou encrypté
3976 3976
  **/
3977 3977
 function _xor($message, $key = null) {
3978
-	if (is_null($key)) {
3979
-		if (!function_exists('calculer_cle_action')) {
3980
-			include_spip('inc/securiser_action');
3981
-		}
3982
-		$key = pack('H*', calculer_cle_action('_xor'));
3983
-	}
3978
+    if (is_null($key)) {
3979
+        if (!function_exists('calculer_cle_action')) {
3980
+            include_spip('inc/securiser_action');
3981
+        }
3982
+        $key = pack('H*', calculer_cle_action('_xor'));
3983
+    }
3984 3984
 
3985
-	$keylen = strlen($key);
3986
-	$messagelen = strlen($message);
3987
-	for ($i = 0; $i < $messagelen; $i++) {
3988
-		$message[$i] = ~($message[$i] ^ $key[$i % $keylen]);
3989
-	}
3985
+    $keylen = strlen($key);
3986
+    $messagelen = strlen($message);
3987
+    for ($i = 0; $i < $messagelen; $i++) {
3988
+        $message[$i] = ~($message[$i] ^ $key[$i % $keylen]);
3989
+    }
3990 3990
 
3991
-	return $message;
3991
+    return $message;
3992 3992
 }
3993 3993
 
3994 3994
 /**
@@ -4002,7 +4002,7 @@  discard block
 block discarded – undo
4002 4002
  * @return string
4003 4003
  */
4004 4004
 function url_reponse_forum($texte) {
4005
- return $texte;
4005
+    return $texte;
4006 4006
 }
4007 4007
 
4008 4008
 /**
@@ -4016,7 +4016,7 @@  discard block
 block discarded – undo
4016 4016
  * @return string
4017 4017
  */
4018 4018
 function url_rss_forum($texte) {
4019
- return $texte;
4019
+    return $texte;
4020 4020
 }
4021 4021
 
4022 4022
 
@@ -4055,37 +4055,37 @@  discard block
 block discarded – undo
4055 4055
  *   Code HTML
4056 4056
  */
4057 4057
 function lien_ou_expose($url, $libelle = null, $on = false, $class = '', $title = '', $rel = '', $evt = '') {
4058
-	if ($on) {
4059
-		$bal = 'strong';
4060
-		$class = '';
4061
-		$att = '';
4062
-		// si $on passe la balise et optionnelement une ou ++classe
4063
-		// a.active span.selected.active etc....
4064
-		if (is_string($on) && (str_starts_with($on, 'a') || str_starts_with($on, 'span') || str_starts_with($on, 'strong'))) {
4065
-			$on = explode('.', $on);
4066
-			// on verifie que c'est exactement une des 3 balises a, span ou strong
4067
-			if (in_array(reset($on), ['a', 'span', 'strong'])) {
4068
-				$bal = array_shift($on);
4069
-				$class = implode(' ', $on);
4070
-				if ($bal == 'a') {
4071
-					$att = 'href="#" ';
4072
-				}
4073
-			}
4074
-		}
4075
-		$att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"';
4076
-	} else {
4077
-		$bal = 'a';
4078
-		$att = "href='$url'"
4079
-			. ($title ? " title='" . attribut_html($title) . "'" : '')
4080
-			. ($class ? " class='" . attribut_html($class) . "'" : '')
4081
-			. ($rel ? " rel='" . attribut_html($rel) . "'" : '')
4082
-			. $evt;
4083
-	}
4084
-	if ($libelle === null) {
4085
-		$libelle = $url;
4086
-	}
4087
-
4088
-	return "<$bal $att>$libelle</$bal>";
4058
+    if ($on) {
4059
+        $bal = 'strong';
4060
+        $class = '';
4061
+        $att = '';
4062
+        // si $on passe la balise et optionnelement une ou ++classe
4063
+        // a.active span.selected.active etc....
4064
+        if (is_string($on) && (str_starts_with($on, 'a') || str_starts_with($on, 'span') || str_starts_with($on, 'strong'))) {
4065
+            $on = explode('.', $on);
4066
+            // on verifie que c'est exactement une des 3 balises a, span ou strong
4067
+            if (in_array(reset($on), ['a', 'span', 'strong'])) {
4068
+                $bal = array_shift($on);
4069
+                $class = implode(' ', $on);
4070
+                if ($bal == 'a') {
4071
+                    $att = 'href="#" ';
4072
+                }
4073
+            }
4074
+        }
4075
+        $att .= 'class="' . ($class ? attribut_html($class) . ' ' : '') . (defined('_LIEN_OU_EXPOSE_CLASS_ON') ? _LIEN_OU_EXPOSE_CLASS_ON : 'on') . '"';
4076
+    } else {
4077
+        $bal = 'a';
4078
+        $att = "href='$url'"
4079
+            . ($title ? " title='" . attribut_html($title) . "'" : '')
4080
+            . ($class ? " class='" . attribut_html($class) . "'" : '')
4081
+            . ($rel ? " rel='" . attribut_html($rel) . "'" : '')
4082
+            . $evt;
4083
+    }
4084
+    if ($libelle === null) {
4085
+        $libelle = $url;
4086
+    }
4087
+
4088
+    return "<$bal $att>$libelle</$bal>";
4089 4089
 }
4090 4090
 
4091 4091
 
@@ -4102,39 +4102,39 @@  discard block
 block discarded – undo
4102 4102
  * @return string : la chaine de langue finale en utilisant la fonction _T()
4103 4103
  */
4104 4104
 function singulier_ou_pluriel($nb, $chaine_un, $chaine_plusieurs, $var = 'nb', $vars = []) {
4105
-	static $local_singulier_ou_pluriel = [];
4106
-
4107
-	// si nb=0 ou pas de $vars valide on retourne une chaine vide, a traiter par un |sinon
4108
-	if (!is_numeric($nb) || $nb == 0) {
4109
-		return '';
4110
-	}
4111
-	if (!is_array($vars)) {
4112
-		return '';
4113
-	}
4114
-
4115
-	$langue = $GLOBALS['spip_lang'];
4116
-	if (!isset($local_singulier_ou_pluriel[$langue])) {
4117
-		$local_singulier_ou_pluriel[$langue] = false;
4118
-		if (
4119
-			($f = charger_fonction("singulier_ou_pluriel_{$langue}", 'inc', true))
4120
-			|| ($f = charger_fonction('singulier_ou_pluriel', 'inc', true))
4121
-		) {
4122
-			$local_singulier_ou_pluriel[$langue] = $f;
4123
-		}
4124
-	}
4125
-
4126
-	// si on a une surcharge on l'utilise
4127
-	if ($local_singulier_ou_pluriel[$langue]) {
4128
-		return ($local_singulier_ou_pluriel[$langue])($nb, $chaine_un, $chaine_plusieurs, $var, $vars);
4129
-	}
4130
-
4131
-	// sinon traitement par defaut
4132
-	$vars[$var] = $nb;
4133
-	if ($nb >= 2) {
4134
-		return _T($chaine_plusieurs, $vars);
4135
-	} else {
4136
-		return _T($chaine_un, $vars);
4137
-	}
4105
+    static $local_singulier_ou_pluriel = [];
4106
+
4107
+    // si nb=0 ou pas de $vars valide on retourne une chaine vide, a traiter par un |sinon
4108
+    if (!is_numeric($nb) || $nb == 0) {
4109
+        return '';
4110
+    }
4111
+    if (!is_array($vars)) {
4112
+        return '';
4113
+    }
4114
+
4115
+    $langue = $GLOBALS['spip_lang'];
4116
+    if (!isset($local_singulier_ou_pluriel[$langue])) {
4117
+        $local_singulier_ou_pluriel[$langue] = false;
4118
+        if (
4119
+            ($f = charger_fonction("singulier_ou_pluriel_{$langue}", 'inc', true))
4120
+            || ($f = charger_fonction('singulier_ou_pluriel', 'inc', true))
4121
+        ) {
4122
+            $local_singulier_ou_pluriel[$langue] = $f;
4123
+        }
4124
+    }
4125
+
4126
+    // si on a une surcharge on l'utilise
4127
+    if ($local_singulier_ou_pluriel[$langue]) {
4128
+        return ($local_singulier_ou_pluriel[$langue])($nb, $chaine_un, $chaine_plusieurs, $var, $vars);
4129
+    }
4130
+
4131
+    // sinon traitement par defaut
4132
+    $vars[$var] = $nb;
4133
+    if ($nb >= 2) {
4134
+        return _T($chaine_plusieurs, $vars);
4135
+    } else {
4136
+        return _T($chaine_un, $vars);
4137
+    }
4138 4138
 }
4139 4139
 
4140 4140
 
@@ -4162,71 +4162,71 @@  discard block
 block discarded – undo
4162 4162
  */
4163 4163
 function prepare_icone_base($type, $lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') {
4164 4164
 
4165
-	$class_lien = $class_bouton = $class;
4166
-
4167
-	// Normaliser la fonction et compléter la classe en fonction
4168
-	if (in_array($fonction, ['del', 'supprimer.gif'])) {
4169
-		$class_lien .= ' danger';
4170
-		$class_bouton .= ' btn_danger';
4171
-	} elseif ($fonction == 'rien.gif') {
4172
-		$fonction = '';
4173
-	} elseif ($fonction == 'delsafe') {
4174
-		$fonction = 'del';
4175
-	}
4176
-
4177
-	$fond_origine = $fond;
4178
-	// Remappage des icone : article-24.png+new => article-new-24.png
4179
-	if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
4180
-		[$fond, $fonction] = $icone_renommer($fond, $fonction);
4181
-	}
4182
-
4183
-	// Ajouter le type d'objet dans la classe
4184
-	$objet_type = substr(basename((string) $fond), 0, -4);
4185
-	$class_lien .= " $objet_type";
4186
-	$class_bouton .= " $objet_type";
4187
-
4188
-	// texte
4189
-	$alt = attribut_html($texte);
4190
-	$title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
4191
-
4192
-	// Liens : préparer les classes ajax
4193
-	$ajax = '';
4194
-	if ($type === 'lien' && str_contains($class_lien, 'ajax')) {
4195
-		$ajax = 'ajax';
4196
-		if (str_contains($class_lien, 'preload')) {
4197
-			$ajax .= ' preload';
4198
-		}
4199
-		if (str_contains($class_lien, 'nocache')) {
4200
-			$ajax .= ' nocache';
4201
-		}
4202
-		$ajax = " class='$ajax'";
4203
-	}
4204
-
4205
-	// Repérer la taille et l'ajouter dans la classe
4206
-	$size = 24;
4207
-	if (
4208
-		preg_match('/-(\d{1,3})[.](gif|png|svg)$/i', (string) $fond, $match)
4209
-		|| preg_match('/-(\d{1,3})([.](gif|png|svg))?$/i', $fond_origine, $match)
4210
-	) {
4211
-		$size = $match[1];
4212
-	}
4213
-	$class_lien .= " s$size";
4214
-	$class_bouton .= " s$size";
4215
-
4216
-	// Icône
4217
-	$icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4218
-	$icone = '<span class="icone-image' . ($fonction ? " icone-fonction icone-fonction-$fonction" : '') . "\">$icone</span>";
4219
-
4220
-	// Markup final
4221
-	if ($type == 'lien') {
4222
-		return "<span class='icone $class_lien'>"
4223
-		. "<a href='$lien'$title$ajax$javascript>"
4224
-		. $icone
4225
-		. "<b>$texte</b>"
4226
-		. "</a></span>\n";
4227
-	} else {
4228
-		return bouton_action("$icone $texte", $lien, $class_bouton, $javascript, $alt);
4229
-	}
4165
+    $class_lien = $class_bouton = $class;
4166
+
4167
+    // Normaliser la fonction et compléter la classe en fonction
4168
+    if (in_array($fonction, ['del', 'supprimer.gif'])) {
4169
+        $class_lien .= ' danger';
4170
+        $class_bouton .= ' btn_danger';
4171
+    } elseif ($fonction == 'rien.gif') {
4172
+        $fonction = '';
4173
+    } elseif ($fonction == 'delsafe') {
4174
+        $fonction = 'del';
4175
+    }
4176
+
4177
+    $fond_origine = $fond;
4178
+    // Remappage des icone : article-24.png+new => article-new-24.png
4179
+    if ($icone_renommer = charger_fonction('icone_renommer', 'inc', true)) {
4180
+        [$fond, $fonction] = $icone_renommer($fond, $fonction);
4181
+    }
4182
+
4183
+    // Ajouter le type d'objet dans la classe
4184
+    $objet_type = substr(basename((string) $fond), 0, -4);
4185
+    $class_lien .= " $objet_type";
4186
+    $class_bouton .= " $objet_type";
4187
+
4188
+    // texte
4189
+    $alt = attribut_html($texte);
4190
+    $title = " title=\"$alt\""; // est-ce pertinent de doubler le alt par un title ?
4191
+
4192
+    // Liens : préparer les classes ajax
4193
+    $ajax = '';
4194
+    if ($type === 'lien' && str_contains($class_lien, 'ajax')) {
4195
+        $ajax = 'ajax';
4196
+        if (str_contains($class_lien, 'preload')) {
4197
+            $ajax .= ' preload';
4198
+        }
4199
+        if (str_contains($class_lien, 'nocache')) {
4200
+            $ajax .= ' nocache';
4201
+        }
4202
+        $ajax = " class='$ajax'";
4203
+    }
4204
+
4205
+    // Repérer la taille et l'ajouter dans la classe
4206
+    $size = 24;
4207
+    if (
4208
+        preg_match('/-(\d{1,3})[.](gif|png|svg)$/i', (string) $fond, $match)
4209
+        || preg_match('/-(\d{1,3})([.](gif|png|svg))?$/i', $fond_origine, $match)
4210
+    ) {
4211
+        $size = $match[1];
4212
+    }
4213
+    $class_lien .= " s$size";
4214
+    $class_bouton .= " s$size";
4215
+
4216
+    // Icône
4217
+    $icone = http_img_pack($fond, $alt, "width='$size' height='$size'");
4218
+    $icone = '<span class="icone-image' . ($fonction ? " icone-fonction icone-fonction-$fonction" : '') . "\">$icone</span>";
4219
+
4220
+    // Markup final
4221
+    if ($type == 'lien') {
4222
+        return "<span class='icone $class_lien'>"
4223
+        . "<a href='$lien'$title$ajax$javascript>"
4224
+        . $icone
4225
+        . "<b>$texte</b>"
4226
+        . "</a></span>\n";
4227
+    } else {
4228
+        return bouton_action("$icone $texte", $lien, $class_bouton, $javascript, $alt);
4229
+    }
4230 4230
 }
4231 4231
 
4232 4232
 /**
@@ -4250,7 +4250,7 @@  discard block
 block discarded – undo
4250 4250
  *     Code HTML du lien
4251 4251
  **/
4252 4252
 function icone_base($lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') {
4253
-	return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript);
4253
+    return prepare_icone_base('lien', $lien, $texte, $fond, $fonction, $class, $javascript);
4254 4254
 }
4255 4255
 
4256 4256
 /**
@@ -4285,7 +4285,7 @@  discard block
 block discarded – undo
4285 4285
  *     Code HTML du lien
4286 4286
  **/
4287 4287
 function filtre_icone_verticale_dist($lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') {
4288
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript);
4288
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $class", $javascript);
4289 4289
 }
4290 4290
 
4291 4291
 /**
@@ -4330,7 +4330,7 @@  discard block
 block discarded – undo
4330 4330
  *     Code HTML du lien
4331 4331
  **/
4332 4332
 function filtre_icone_horizontale_dist($lien, $texte, $fond, $fonction = '', $class = '', $javascript = '') {
4333
-	return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript);
4333
+    return icone_base($lien, $texte, $fond, $fonction, "horizontale $class", $javascript);
4334 4334
 }
4335 4335
 
4336 4336
 /**
@@ -4361,7 +4361,7 @@  discard block
 block discarded – undo
4361 4361
  *     Code HTML du lien
4362 4362
  **/
4363 4363
 function filtre_bouton_action_horizontal_dist($lien, $texte, $fond, $fonction = '', $class = '', $confirm = '') {
4364
-	return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, $class, $confirm);
4364
+    return prepare_icone_base('bouton', $lien, $texte, $fond, $fonction, $class, $confirm);
4365 4365
 }
4366 4366
 
4367 4367
 /**
@@ -4392,7 +4392,7 @@  discard block
 block discarded – undo
4392 4392
  *     Code HTML du lien
4393 4393
  */
4394 4394
 function filtre_icone_dist($lien, $texte, $fond, $align = '', $fonction = '', $class = '', $javascript = '') {
4395
-	return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript);
4395
+    return icone_base($lien, $texte, $fond, $fonction, "verticale $align $class", $javascript);
4396 4396
 }
4397 4397
 
4398 4398
 
@@ -4414,7 +4414,7 @@  discard block
 block discarded – undo
4414 4414
  * @return array Liste des éléments
4415 4415
  */
4416 4416
 function filtre_explode_dist($a, $b) {
4417
-	return explode($b, (string) $a);
4417
+    return explode($b, (string) $a);
4418 4418
 }
4419 4419
 
4420 4420
 /**
@@ -4435,7 +4435,7 @@  discard block
 block discarded – undo
4435 4435
  * @return string texte
4436 4436
  */
4437 4437
 function filtre_implode_dist($a, $b) {
4438
-	return is_array($a) ? implode($b, $a) : $a;
4438
+    return is_array($a) ? implode($b, $a) : $a;
4439 4439
 }
4440 4440
 
4441 4441
 /**
@@ -4444,22 +4444,22 @@  discard block
 block discarded – undo
4444 4444
  * @return string Code CSS
4445 4445
  */
4446 4446
 function bando_images_background() {
4447
-	include_spip('inc/bandeau');
4448
-	// recuperer tous les boutons et leurs images
4449
-	$boutons = definir_barre_boutons(definir_barre_contexte(), true, false);
4447
+    include_spip('inc/bandeau');
4448
+    // recuperer tous les boutons et leurs images
4449
+    $boutons = definir_barre_boutons(definir_barre_contexte(), true, false);
4450 4450
 
4451
-	$res = '';
4452
-	foreach ($boutons as $page => $detail) {
4453
-		$selecteur = (in_array($page, ['outils_rapides', 'outils_collaboratifs']) ? '' : '.navigation_avec_icones ');
4454
-		foreach ($detail->sousmenu as $souspage => $sousdetail) {
4455
-			if ($sousdetail->icone && strlen(trim((string) $sousdetail->icone))) {
4456
-				$img = http_img_variante_svg_si_possible($sousdetail->icone);
4457
-				$res .= "\n$selecteur.bando2_$souspage {background-image:url($img);}";
4458
-			}
4459
-		}
4460
-	}
4451
+    $res = '';
4452
+    foreach ($boutons as $page => $detail) {
4453
+        $selecteur = (in_array($page, ['outils_rapides', 'outils_collaboratifs']) ? '' : '.navigation_avec_icones ');
4454
+        foreach ($detail->sousmenu as $souspage => $sousdetail) {
4455
+            if ($sousdetail->icone && strlen(trim((string) $sousdetail->icone))) {
4456
+                $img = http_img_variante_svg_si_possible($sousdetail->icone);
4457
+                $res .= "\n$selecteur.bando2_$souspage {background-image:url($img);}";
4458
+            }
4459
+        }
4460
+    }
4461 4461
 
4462
-	return $res;
4462
+    return $res;
4463 4463
 }
4464 4464
 
4465 4465
 /**
@@ -4484,23 +4484,23 @@  discard block
 block discarded – undo
4484 4484
  */
4485 4485
 function bouton_action($libelle, $url, $class = '', $confirm = '', $title = '', $callback = '') {
4486 4486
 
4487
-	// Classes : dispatcher `ajax` sur le formulaire
4488
-	$class_form = '';
4489
-	if (str_contains($class, 'ajax')) {
4490
-		$class_form = 'ajax';
4491
-		$class = str_replace('ajax', '', $class);
4492
-	}
4493
-	$class_btn = 'submit ' . trim($class);
4487
+    // Classes : dispatcher `ajax` sur le formulaire
4488
+    $class_form = '';
4489
+    if (str_contains($class, 'ajax')) {
4490
+        $class_form = 'ajax';
4491
+        $class = str_replace('ajax', '', $class);
4492
+    }
4493
+    $class_btn = 'submit ' . trim($class);
4494 4494
 
4495
-	if ($confirm) {
4496
-		$confirm = 'confirm("' . attribut_html($confirm) . '")';
4497
-		$callback = $callback ? "$confirm?($callback):false" : $confirm;
4498
-	}
4499
-	$onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : '';
4500
-	$title = $title ? " title='$title'" : '';
4495
+    if ($confirm) {
4496
+        $confirm = 'confirm("' . attribut_html($confirm) . '")';
4497
+        $callback = $callback ? "$confirm?($callback):false" : $confirm;
4498
+    }
4499
+    $onclick = $callback ? " onclick='return " . addcslashes($callback, "'") . "'" : '';
4500
+    $title = $title ? " title='$title'" : '';
4501 4501
 
4502
-	return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>" . form_hidden($url)
4503
-	. "<button type='submit' class='$class_btn'$title$onclick>$libelle</button></div></form>";
4502
+    return "<form class='bouton_action_post $class_form' method='post' action='$url'><div>" . form_hidden($url)
4503
+    . "<button type='submit' class='$class_btn'$title$onclick>$libelle</button></div></form>";
4504 4504
 }
4505 4505
 
4506 4506
 /**
@@ -4523,104 +4523,104 @@  discard block
 block discarded – undo
4523 4523
  * @return string
4524 4524
  */
4525 4525
 function generer_objet_info($id_objet, string $type_objet, string $info, string $etoile = '', array $params = []): string {
4526
-	static $trouver_table = null;
4527
-	static $objets;
4528
-
4529
-	// On verifie qu'on a tout ce qu'il faut
4530
-	$id_objet = (int) $id_objet;
4531
-	if (!($id_objet && $type_objet && $info)) {
4532
-		return '';
4533
-	}
4534
-
4535
-	// si on a deja note que l'objet n'existe pas, ne pas aller plus loin
4536
-	if (isset($objets[$type_objet]) && $objets[$type_objet] === false) {
4537
-		return '';
4538
-	}
4539
-
4540
-	// Si on demande l'url, on retourne direct la fonction
4541
-	if ($info == 'url') {
4542
-		return generer_objet_url($id_objet, $type_objet, ...$params);
4543
-	}
4544
-
4545
-	// Sinon on va tout chercher dans la table et on garde en memoire
4546
-	$demande_titre = ($info === 'titre');
4547
-	$demande_introduction = ($info === 'introduction');
4548
-
4549
-	// 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
4550
-	if (
4551
-		!isset($objets[$type_objet][$id_objet])
4552
-		|| $demande_titre && !isset($objets[$type_objet][$id_objet]['titre'])
4553
-	) {
4554
-		if (!$trouver_table) {
4555
-			$trouver_table = charger_fonction('trouver_table', 'base');
4556
-		}
4557
-		$desc = $trouver_table(table_objet_sql($type_objet));
4558
-		if (!$desc) {
4559
-			return $objets[$type_objet] = false;
4560
-		}
4561
-
4562
-		// Si on demande le titre, on le gere en interne
4563
-		$champ_titre = '';
4564
-		if ($demande_titre) {
4565
-			// si pas de titre declare mais champ titre, il sera peuple par le select *
4566
-			$champ_titre = (empty($desc['titre'])) ? '' : ', ' . $desc['titre'];
4567
-		}
4568
-		include_spip('base/abstract_sql');
4569
-		include_spip('base/connect_sql');
4570
-		$objets[$type_objet][$id_objet] = sql_fetsel(
4571
-			'*' . $champ_titre,
4572
-			$desc['table_sql'],
4573
-			id_table_objet($type_objet) . ' = ' . (int) $id_objet
4574
-		);
4575
-
4576
-		// Toujours noter la longueur d'introduction, même si pas demandé cette fois-ci
4577
-		$objets[$type_objet]['introduction_longueur'] = $desc['introduction_longueur'] ?? null;
4578
-	}
4579
-
4580
-	// Pour les fonction generer_xxx, si on demande l'introduction,
4581
-	// ajouter la longueur au début des params supplémentaires
4582
-	if ($demande_introduction) {
4583
-		$introduction_longueur = $objets[$type_objet]['introduction_longueur'];
4584
-		array_unshift($params, $introduction_longueur);
4585
-	}
4586
-
4587
-	$row = ($objets[$type_objet][$id_objet] ?? []) ?: [];
4588
-	// Si la fonction generer_TYPE_TRUC existe, on l'utilise pour formater $info_generee
4589
-	if ($generer = charger_fonction("generer_{$type_objet}_{$info}", '', true)) {
4590
-		$info_generee = $generer($id_objet, $row, ...$params);
4591
-	}
4592
-	// @deprecated 4.1 generer_TRUC_TYPE
4593
-	elseif ($generer = charger_fonction("generer_{$info}_{$type_objet}", '', true)) {
4594
-		trigger_deprecation('spip', '4.1', 'Using "%s" function naming is deprecated, rename "%s" instead', "generer_{$info}_{$type_objet}", "generer_{$type_objet}_{$info}");
4595
-		$info_generee = $generer($id_objet, $row, ...$params);
4596
-	}
4597
-	// Si la fonction generer_objet_TRUC existe, on l'utilise pour formater $info_generee
4598
-	elseif ($generer = charger_fonction("generer_objet_{$info}", '', true)) {
4599
-		$info_generee = $generer($id_objet, $type_objet, $row, ...$params);
4600
-	}
4601
-	// @deprecated 4.1 generer_TRUC_entite
4602
-	elseif ($generer = charger_fonction("generer_{$info}_entite", '', true)) {
4603
-		trigger_deprecation('spip', '4.1', 'Using "%s" function naming is deprecated, rename "%s" instead', "generer_{$info}_entite", "generer_objet_{$info}");
4604
-		$info_generee = $generer($id_objet, $type_objet, $row, ...$params);
4605
-	}
4606
-	// Sinon on prend directement le champ SQL tel quel
4607
-	else {
4608
-		$info_generee = ($objets[$type_objet][$id_objet][$info] ?? '');
4609
-	}
4610
-
4611
-	// On va ensuite appliquer les traitements automatiques si besoin
4612
-	if (!$etoile) {
4613
-		// FIXME: on fournit un ENV minimum avec id et type et connect=''
4614
-		// mais ce fonctionnement est a ameliorer !
4615
-		$info_generee = appliquer_traitement_champ(
4616
-			$info_generee,
4617
-			$info,
4618
-			table_objet($type_objet),
4619
-			['id_objet' => $id_objet, 'objet' => $type_objet, '']
4620
-		);
4621
-	}
4622
-
4623
-	return $info_generee;
4526
+    static $trouver_table = null;
4527
+    static $objets;
4528
+
4529
+    // On verifie qu'on a tout ce qu'il faut
4530
+    $id_objet = (int) $id_objet;
4531
+    if (!($id_objet && $type_objet && $info)) {
4532
+        return '';
4533
+    }
4534
+
4535
+    // si on a deja note que l'objet n'existe pas, ne pas aller plus loin
4536
+    if (isset($objets[$type_objet]) && $objets[$type_objet] === false) {
4537
+        return '';
4538
+    }
4539
+
4540
+    // Si on demande l'url, on retourne direct la fonction
4541
+    if ($info == 'url') {
4542
+        return generer_objet_url($id_objet, $type_objet, ...$params);
4543
+    }
4544
+
4545
+    // Sinon on va tout chercher dans la table et on garde en memoire
4546
+    $demande_titre = ($info === 'titre');
4547
+    $demande_introduction = ($info === 'introduction');
4548
+
4549
+    // 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
4550
+    if (
4551
+        !isset($objets[$type_objet][$id_objet])
4552
+        || $demande_titre && !isset($objets[$type_objet][$id_objet]['titre'])
4553
+    ) {
4554
+        if (!$trouver_table) {
4555
+            $trouver_table = charger_fonction('trouver_table', 'base');
4556
+        }
4557
+        $desc = $trouver_table(table_objet_sql($type_objet));
4558
+        if (!$desc) {
4559
+            return $objets[$type_objet] = false;
4560
+        }
4561
+
4562
+        // Si on demande le titre, on le gere en interne
4563
+        $champ_titre = '';
4564
+        if ($demande_titre) {
4565
+            // si pas de titre declare mais champ titre, il sera peuple par le select *
4566
+            $champ_titre = (empty($desc['titre'])) ? '' : ', ' . $desc['titre'];
4567
+        }
4568
+        include_spip('base/abstract_sql');
4569
+        include_spip('base/connect_sql');
4570
+        $objets[$type_objet][$id_objet] = sql_fetsel(
4571
+            '*' . $champ_titre,
4572
+            $desc['table_sql'],
4573
+            id_table_objet($type_objet) . ' = ' . (int) $id_objet
4574
+        );
4575
+
4576
+        // Toujours noter la longueur d'introduction, même si pas demandé cette fois-ci
4577
+        $objets[$type_objet]['introduction_longueur'] = $desc['introduction_longueur'] ?? null;
4578
+    }
4579
+
4580
+    // Pour les fonction generer_xxx, si on demande l'introduction,
4581
+    // ajouter la longueur au début des params supplémentaires
4582
+    if ($demande_introduction) {
4583
+        $introduction_longueur = $objets[$type_objet]['introduction_longueur'];
4584
+        array_unshift($params, $introduction_longueur);
4585
+    }
4586
+
4587
+    $row = ($objets[$type_objet][$id_objet] ?? []) ?: [];
4588
+    // Si la fonction generer_TYPE_TRUC existe, on l'utilise pour formater $info_generee
4589
+    if ($generer = charger_fonction("generer_{$type_objet}_{$info}", '', true)) {
4590
+        $info_generee = $generer($id_objet, $row, ...$params);
4591
+    }
4592
+    // @deprecated 4.1 generer_TRUC_TYPE
4593
+    elseif ($generer = charger_fonction("generer_{$info}_{$type_objet}", '', true)) {
4594
+        trigger_deprecation('spip', '4.1', 'Using "%s" function naming is deprecated, rename "%s" instead', "generer_{$info}_{$type_objet}", "generer_{$type_objet}_{$info}");
4595
+        $info_generee = $generer($id_objet, $row, ...$params);
4596
+    }
4597
+    // Si la fonction generer_objet_TRUC existe, on l'utilise pour formater $info_generee
4598
+    elseif ($generer = charger_fonction("generer_objet_{$info}", '', true)) {
4599
+        $info_generee = $generer($id_objet, $type_objet, $row, ...$params);
4600
+    }
4601
+    // @deprecated 4.1 generer_TRUC_entite
4602
+    elseif ($generer = charger_fonction("generer_{$info}_entite", '', true)) {
4603
+        trigger_deprecation('spip', '4.1', 'Using "%s" function naming is deprecated, rename "%s" instead', "generer_{$info}_entite", "generer_objet_{$info}");
4604
+        $info_generee = $generer($id_objet, $type_objet, $row, ...$params);
4605
+    }
4606
+    // Sinon on prend directement le champ SQL tel quel
4607
+    else {
4608
+        $info_generee = ($objets[$type_objet][$id_objet][$info] ?? '');
4609
+    }
4610
+
4611
+    // On va ensuite appliquer les traitements automatiques si besoin
4612
+    if (!$etoile) {
4613
+        // FIXME: on fournit un ENV minimum avec id et type et connect=''
4614
+        // mais ce fonctionnement est a ameliorer !
4615
+        $info_generee = appliquer_traitement_champ(
4616
+            $info_generee,
4617
+            $info,
4618
+            table_objet($type_objet),
4619
+            ['id_objet' => $id_objet, 'objet' => $type_objet, '']
4620
+        );
4621
+    }
4622
+
4623
+    return $info_generee;
4624 4624
 }
4625 4625
 
4626 4626
 /**
@@ -4653,34 +4653,34 @@  discard block
 block discarded – undo
4653 4653
  */
4654 4654
 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 {
4655 4655
 
4656
-	$descriptif = $ligne_sql['descriptif'] ?? '';
4657
-	$texte = $ligne_sql['texte'] ?? '';
4658
-	// En absence de descriptif, on se rabat sur chapo + texte
4659
-	if (isset($ligne_sql['chapo'])) {
4660
-		$chapo = $ligne_sql['chapo'];
4661
-		$texte = strlen((string) $descriptif) ?
4662
-			'' :
4663
-			"$chapo \n\n $texte";
4664
-	}
4656
+    $descriptif = $ligne_sql['descriptif'] ?? '';
4657
+    $texte = $ligne_sql['texte'] ?? '';
4658
+    // En absence de descriptif, on se rabat sur chapo + texte
4659
+    if (isset($ligne_sql['chapo'])) {
4660
+        $chapo = $ligne_sql['chapo'];
4661
+        $texte = strlen((string) $descriptif) ?
4662
+            '' :
4663
+            "$chapo \n\n $texte";
4664
+    }
4665 4665
 
4666
-	// Longueur en paramètre, sinon celle renseignée dans la description de l'objet, sinon valeur en dur
4667
-	if (!(int) $longueur_ou_suite) {
4668
-		$longueur = (int) ($introduction_longueur ?: 600);
4669
-	} else {
4670
-		$longueur = (int) $longueur_ou_suite;
4671
-	}
4666
+    // Longueur en paramètre, sinon celle renseignée dans la description de l'objet, sinon valeur en dur
4667
+    if (!(int) $longueur_ou_suite) {
4668
+        $longueur = (int) ($introduction_longueur ?: 600);
4669
+    } else {
4670
+        $longueur = (int) $longueur_ou_suite;
4671
+    }
4672 4672
 
4673
-	// On peut optionnellement passer la suite en 1er paramètre de la balise
4674
-	// Ex : #INTRODUCTION{...}
4675
-	if (
4676
-		is_null($suite) && !(int) $longueur_ou_suite
4677
-	) {
4678
-		$suite = $longueur_ou_suite;
4679
-	}
4673
+    // On peut optionnellement passer la suite en 1er paramètre de la balise
4674
+    // Ex : #INTRODUCTION{...}
4675
+    if (
4676
+        is_null($suite) && !(int) $longueur_ou_suite
4677
+    ) {
4678
+        $suite = $longueur_ou_suite;
4679
+    }
4680 4680
 
4681
-	$f = chercher_filtre('introduction');
4681
+    $f = chercher_filtre('introduction');
4682 4682
 
4683
-	return $f($descriptif, $texte, $longueur, $connect, $suite);
4683
+    return $f($descriptif, $texte, $longueur, $connect, $suite);
4684 4684
 }
4685 4685
 
4686 4686
 /**
@@ -4693,49 +4693,49 @@  discard block
 block discarded – undo
4693 4693
  * @return string
4694 4694
  */
4695 4695
 function appliquer_traitement_champ($texte, $champ, $table_objet = '', $env = [], string $connect = '') {
4696
-	if (!$champ) {
4697
-		return $texte;
4698
-	}
4696
+    if (!$champ) {
4697
+        return $texte;
4698
+    }
4699 4699
 
4700
-	// On charge les définitions des traitements (inc/texte et fichiers de fonctions)
4701
-	// car il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4702
-	include_fichiers_fonctions();
4700
+    // On charge les définitions des traitements (inc/texte et fichiers de fonctions)
4701
+    // car il ne faut pas partir du principe que c'est déjà chargé (form ajax, etc)
4702
+    include_fichiers_fonctions();
4703 4703
 
4704
-	$champ = strtoupper($champ);
4705
-	$traitements = $GLOBALS['table_des_traitements'][$champ] ?? false;
4706
-	if (!$traitements || !is_array($traitements)) {
4707
-		return $texte;
4708
-	}
4704
+    $champ = strtoupper($champ);
4705
+    $traitements = $GLOBALS['table_des_traitements'][$champ] ?? false;
4706
+    if (!$traitements || !is_array($traitements)) {
4707
+        return $texte;
4708
+    }
4709 4709
 
4710
-	$traitement = '';
4711
-	if ($table_objet && (!isset($traitements[0]) || count($traitements) > 1)) {
4712
-		// necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4713
-		$table_objet = table_objet($table_objet);
4714
-		if (isset($traitements[$table_objet])) {
4715
-			$traitement = $traitements[$table_objet];
4716
-		}
4717
-	}
4718
-	if (!$traitement && isset($traitements[0])) {
4719
-		$traitement = $traitements[0];
4720
-	}
4721
-	// (sinon prendre le premier de la liste par defaut ?)
4710
+    $traitement = '';
4711
+    if ($table_objet && (!isset($traitements[0]) || count($traitements) > 1)) {
4712
+        // necessaire pour prendre en charge les vieux appels avec un table_objet_sql en 3e arg
4713
+        $table_objet = table_objet($table_objet);
4714
+        if (isset($traitements[$table_objet])) {
4715
+            $traitement = $traitements[$table_objet];
4716
+        }
4717
+    }
4718
+    if (!$traitement && isset($traitements[0])) {
4719
+        $traitement = $traitements[0];
4720
+    }
4721
+    // (sinon prendre le premier de la liste par defaut ?)
4722 4722
 
4723
-	if (!$traitement) {
4724
-		return $texte;
4725
-	}
4723
+    if (!$traitement) {
4724
+        return $texte;
4725
+    }
4726 4726
 
4727
-	$traitement = str_replace('%s', "'" . texte_script($texte) . "'", (string) $traitement);
4727
+    $traitement = str_replace('%s', "'" . texte_script($texte) . "'", (string) $traitement);
4728 4728
 
4729
-	// signaler qu'on est dans l'espace prive pour les filtres qui se servent de ce flag
4730
-	if (test_espace_prive()) {
4731
-		$env['espace_prive'] = 1;
4732
-	}
4729
+    // signaler qu'on est dans l'espace prive pour les filtres qui se servent de ce flag
4730
+    if (test_espace_prive()) {
4731
+        $env['espace_prive'] = 1;
4732
+    }
4733 4733
 
4734
-	// Fournir $connect et $Pile[0] au traitement si besoin
4735
-	$Pile = [0 => $env];
4736
-	eval("\$texte = $traitement;");
4734
+    // Fournir $connect et $Pile[0] au traitement si besoin
4735
+    $Pile = [0 => $env];
4736
+    eval("\$texte = $traitement;");
4737 4737
 
4738
-	return $texte;
4738
+    return $texte;
4739 4739
 }
4740 4740
 
4741 4741
 
@@ -4746,21 +4746,21 @@  discard block
 block discarded – undo
4746 4746
  * @return string
4747 4747
  */
4748 4748
 function generer_objet_lien(int $id_objet, string $objet, int $longueur = 80, string $connect = ''): string {
4749
-	include_spip('inc/liens');
4750
-	$titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4751
-	// lorsque l'objet n'est plus declare (plugin desactive par exemple)
4752
-	// le raccourcis n'est plus valide
4753
-	$titre = typo($titre['titre'] ?? '');
4754
-	// on essaye avec generer_objet_info ?
4755
-	if (!strlen($titre) && !$connect) {
4756
-		$titre = generer_objet_info($id_objet, $objet, 'titre');
4757
-	}
4758
-	if (!strlen($titre)) {
4759
-		$titre = _T('info_sans_titre');
4760
-	}
4761
-	$url = generer_objet_url($id_objet, $objet, '', '', null, '', $connect);
4749
+    include_spip('inc/liens');
4750
+    $titre = traiter_raccourci_titre($id_objet, $objet, $connect);
4751
+    // lorsque l'objet n'est plus declare (plugin desactive par exemple)
4752
+    // le raccourcis n'est plus valide
4753
+    $titre = typo($titre['titre'] ?? '');
4754
+    // on essaye avec generer_objet_info ?
4755
+    if (!strlen($titre) && !$connect) {
4756
+        $titre = generer_objet_info($id_objet, $objet, 'titre');
4757
+    }
4758
+    if (!strlen($titre)) {
4759
+        $titre = _T('info_sans_titre');
4760
+    }
4761
+    $url = generer_objet_url($id_objet, $objet, '', '', null, '', $connect);
4762 4762
 
4763
-	return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . '</a>';
4763
+    return "<a href='$url' class='$objet'>" . couper($titre, $longueur) . '</a>';
4764 4764
 }
4765 4765
 
4766 4766
 /**
@@ -4776,15 +4776,15 @@  discard block
 block discarded – undo
4776 4776
  * @return string
4777 4777
  */
4778 4778
 function wrap($texte, $wrap) {
4779
-	$balises = extraire_balises($wrap);
4780
-	if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4781
-		$texte = $wrap . $texte;
4782
-		$regs = array_reverse($regs[1]);
4783
-		$wrap = '</' . implode('></', $regs) . '>';
4784
-		$texte .= $wrap;
4785
-	}
4779
+    $balises = extraire_balises($wrap);
4780
+    if (preg_match_all(",<([a-z]\w*)\b[^>]*>,UimsS", $wrap, $regs, PREG_PATTERN_ORDER)) {
4781
+        $texte = $wrap . $texte;
4782
+        $regs = array_reverse($regs[1]);
4783
+        $wrap = '</' . implode('></', $regs) . '>';
4784
+        $texte .= $wrap;
4785
+    }
4786 4786
 
4787
-	return $texte;
4787
+    return $texte;
4788 4788
 }
4789 4789
 
4790 4790
 
@@ -4804,42 +4804,42 @@  discard block
 block discarded – undo
4804 4804
  * @return array|mixed|string
4805 4805
  */
4806 4806
 function filtre_print_dist($u, $join = '<br />', $indent = 0) {
4807
-	if (is_string($u)) {
4808
-		return typo($u);
4809
-	}
4810
-
4811
-	// caster $u en array si besoin
4812
-	if (is_object($u)) {
4813
-		$u = (array)$u;
4814
-	}
4815
-
4816
-	if (is_array($u)) {
4817
-		$out = '';
4818
-		// toutes les cles sont numeriques ?
4819
-		// et aucun enfant n'est un tableau
4820
-		// liste simple separee par des virgules
4821
-		$numeric_keys = array_map('is_numeric', array_keys($u));
4822
-		$array_values = array_map('is_array', $u);
4823
-		$object_values = array_map('is_object', $u);
4824
-		if (
4825
-			array_sum($numeric_keys) == count($numeric_keys)
4826
-			&& !array_sum($array_values)
4827
-			&& !array_sum($object_values)
4828
-		) {
4829
-			return implode(', ', array_map('filtre_print_dist', $u));
4830
-		}
4831
-
4832
-		// sinon on passe a la ligne et on indente
4833
-		$i_str = str_pad('', $indent, ' ');
4834
-		foreach ($u as $k => $v) {
4835
-			$out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4836
-		}
4837
-
4838
-		return $out;
4839
-	}
4840
-
4841
-	// on sait pas quoi faire...
4842
-	return $u;
4807
+    if (is_string($u)) {
4808
+        return typo($u);
4809
+    }
4810
+
4811
+    // caster $u en array si besoin
4812
+    if (is_object($u)) {
4813
+        $u = (array)$u;
4814
+    }
4815
+
4816
+    if (is_array($u)) {
4817
+        $out = '';
4818
+        // toutes les cles sont numeriques ?
4819
+        // et aucun enfant n'est un tableau
4820
+        // liste simple separee par des virgules
4821
+        $numeric_keys = array_map('is_numeric', array_keys($u));
4822
+        $array_values = array_map('is_array', $u);
4823
+        $object_values = array_map('is_object', $u);
4824
+        if (
4825
+            array_sum($numeric_keys) == count($numeric_keys)
4826
+            && !array_sum($array_values)
4827
+            && !array_sum($object_values)
4828
+        ) {
4829
+            return implode(', ', array_map('filtre_print_dist', $u));
4830
+        }
4831
+
4832
+        // sinon on passe a la ligne et on indente
4833
+        $i_str = str_pad('', $indent, ' ');
4834
+        foreach ($u as $k => $v) {
4835
+            $out .= $join . $i_str . "$k: " . filtre_print_dist($v, $join, $indent + 2);
4836
+        }
4837
+
4838
+        return $out;
4839
+    }
4840
+
4841
+    // on sait pas quoi faire...
4842
+    return $u;
4843 4843
 }
4844 4844
 
4845 4845
 
@@ -4852,10 +4852,10 @@  discard block
 block discarded – undo
4852 4852
  * @return string|array
4853 4853
  */
4854 4854
 function objet_info($objet, $info) {
4855
-	$table = table_objet_sql($objet);
4856
-	$infos = lister_tables_objets_sql($table);
4855
+    $table = table_objet_sql($objet);
4856
+    $infos = lister_tables_objets_sql($table);
4857 4857
 
4858
-	return ($infos[$info] ?? '');
4858
+    return ($infos[$info] ?? '');
4859 4859
 }
4860 4860
 
4861 4861
 /**
@@ -4870,11 +4870,11 @@  discard block
 block discarded – undo
4870 4870
  *     texte traduit du comptage, tel que '3 articles'
4871 4871
  */
4872 4872
 function objet_afficher_nb($nb, $objet) {
4873
-	if (!$nb) {
4874
-		return _T(objet_info($objet, 'info_aucun_objet'));
4875
-	} else {
4876
-		return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), ['nb' => $nb]);
4877
-	}
4873
+    if (!$nb) {
4874
+        return _T(objet_info($objet, 'info_aucun_objet'));
4875
+    } else {
4876
+        return _T(objet_info($objet, $nb == 1 ? 'info_1_objet' : 'info_nb_objets'), ['nb' => $nb]);
4877
+    }
4878 4878
 }
4879 4879
 
4880 4880
 /**
@@ -4886,11 +4886,11 @@  discard block
 block discarded – undo
4886 4886
  * @return string
4887 4887
  */
4888 4888
 function objet_icone($objet, $taille = 24, $class = '') {
4889
-	$icone = objet_info($objet, 'icone_objet') . '-' . $taille . '.png';
4890
-	$icone = chemin_image($icone);
4891
-	$balise_img = charger_filtre('balise_img');
4889
+    $icone = objet_info($objet, 'icone_objet') . '-' . $taille . '.png';
4890
+    $icone = chemin_image($icone);
4891
+    $balise_img = charger_filtre('balise_img');
4892 4892
 
4893
-	return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : '';
4893
+    return $icone ? $balise_img($icone, _T(objet_info($objet, 'texte_objet')), $class, $taille) : '';
4894 4894
 }
4895 4895
 
4896 4896
 /**
@@ -4911,12 +4911,12 @@  discard block
 block discarded – undo
4911 4911
  * @return string
4912 4912
  */
4913 4913
 function objet_T($objet, $chaine, $args = [], $options = []) {
4914
-	$chaine = explode(':', $chaine);
4915
-	if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, ['force' => false]))) {
4916
-		return $t;
4917
-	}
4918
-	$chaine = implode(':', $chaine);
4919
-	return _T($chaine, $args, $options);
4914
+    $chaine = explode(':', $chaine);
4915
+    if ($t = _T($objet . ':' . end($chaine), $args, array_merge($options, ['force' => false]))) {
4916
+        return $t;
4917
+    }
4918
+    $chaine = implode(':', $chaine);
4919
+    return _T($chaine, $args, $options);
4920 4920
 }
4921 4921
 
4922 4922
 /**
@@ -4930,18 +4930,18 @@  discard block
 block discarded – undo
4930 4930
  * @return string      Code HTML
4931 4931
  */
4932 4932
 function insert_head_css_conditionnel($flux) {
4933
-	if (
4934
-		!str_contains($flux, '<!-- insert_head_css -->')
4935
-		&& ($p = strpos($flux, '<!-- insert_head -->'))
4936
-	) {
4937
-		// plutot avant le premier js externe (jquery) pour etre non bloquant
4938
-		if (($p1 = stripos($flux, '<script src=')) && $p1 < $p) {
4939
-			$p = $p1;
4940
-		}
4941
-		$flux = substr_replace($flux, (string) pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
4942
-	}
4933
+    if (
4934
+        !str_contains($flux, '<!-- insert_head_css -->')
4935
+        && ($p = strpos($flux, '<!-- insert_head -->'))
4936
+    ) {
4937
+        // plutot avant le premier js externe (jquery) pour etre non bloquant
4938
+        if (($p1 = stripos($flux, '<script src=')) && $p1 < $p) {
4939
+            $p = $p1;
4940
+        }
4941
+        $flux = substr_replace($flux, (string) pipeline('insert_head_css', '<!-- insert_head_css -->'), $p, 0);
4942
+    }
4943 4943
 
4944
-	return $flux;
4944
+    return $flux;
4945 4945
 }
4946 4946
 
4947 4947
 /**
@@ -4964,75 +4964,75 @@  discard block
 block discarded – undo
4964 4964
  * @return string
4965 4965
  */
4966 4966
 function produire_fond_statique($fond, $contexte = [], $options = [], string $connect = '') {
4967
-	if (isset($contexte['format'])) {
4968
-		$extension = $contexte['format'];
4969
-		unset($contexte['format']);
4970
-	} else {
4971
-		$extension = 'html';
4972
-		if (preg_match(',[.](css|js|json|xml|svg)$,', $fond, $m)) {
4973
-			$extension = $m[1];
4974
-		}
4975
-	}
4976
-	// recuperer le contenu produit par le squelette
4977
-	$options['raw'] = true;
4978
-	$cache = recuperer_fond($fond, $contexte, $options, $connect);
4979
-
4980
-	// calculer le nom de la css
4981
-	$dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4982
-	$nom_safe = preg_replace(',\W,', '_', str_replace('.', '_', $fond));
4983
-	$contexte_implicite = calculer_contexte_implicite();
4984
-
4985
-	// par defaut on hash selon les contextes qui sont a priori moins variables
4986
-	// mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
4987
-	// reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4988
-	if (isset($options['hash_on_content']) && $options['hash_on_content']) {
4989
-		$hash = md5((string) ($contexte_implicite['host'] . '::' . $cache));
4990
-	}
4991
-	else {
4992
-		unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4993
-		ksort($contexte);
4994
-		$hash = md5($fond . json_encode($contexte_implicite, JSON_THROW_ON_ERROR) . json_encode($contexte, JSON_THROW_ON_ERROR) . $connect);
4995
-	}
4996
-	$filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
4997
-
4998
-	// mettre a jour le fichier si il n'existe pas
4999
-	// ou trop ancien
5000
-	// le dernier fichier produit est toujours suffixe par .last
5001
-	// et recopie sur le fichier cible uniquement si il change
5002
-	if (
5003
-		!file_exists($filename)
5004
-		|| !file_exists($filename . '.last')
5005
-		|| isset($cache['lastmodified']) && $cache['lastmodified'] && filemtime($filename . '.last') < $cache['lastmodified']
5006
-		|| defined('_VAR_MODE') && _VAR_MODE == 'recalcul'
5007
-	) {
5008
-		$contenu = $cache['texte'];
5009
-		// passer les urls en absolu si c'est une css
5010
-		if ($extension == 'css') {
5011
-			$contenu = urls_absolues_css(
5012
-				$contenu,
5013
-				test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond)
5014
-			);
5015
-		}
5016
-
5017
-		$comment = '';
5018
-		// ne pas insérer de commentaire sur certains formats
5019
-		if (!in_array($extension, ['json', 'xml', 'svg'])) {
5020
-			$comment = "/* #PRODUIRE{fond=$fond";
5021
-			foreach ($contexte as $k => $v) {
5022
-				if (is_array($v)) {
5023
-					$v = var_export($v, true);
5024
-				}
5025
-				$comment .= ",$k=$v";
5026
-			}
5027
-			// pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
5028
-			// mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
5029
-			$comment .= "}\n   md5:" . md5((string) $contenu) . " */\n";
5030
-		}
5031
-		// et ecrire le fichier si il change
5032
-		ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
5033
-	}
5034
-
5035
-	return timestamp($filename);
4967
+    if (isset($contexte['format'])) {
4968
+        $extension = $contexte['format'];
4969
+        unset($contexte['format']);
4970
+    } else {
4971
+        $extension = 'html';
4972
+        if (preg_match(',[.](css|js|json|xml|svg)$,', $fond, $m)) {
4973
+            $extension = $m[1];
4974
+        }
4975
+    }
4976
+    // recuperer le contenu produit par le squelette
4977
+    $options['raw'] = true;
4978
+    $cache = recuperer_fond($fond, $contexte, $options, $connect);
4979
+
4980
+    // calculer le nom de la css
4981
+    $dir_var = sous_repertoire(_DIR_VAR, 'cache-' . $extension);
4982
+    $nom_safe = preg_replace(',\W,', '_', str_replace('.', '_', $fond));
4983
+    $contexte_implicite = calculer_contexte_implicite();
4984
+
4985
+    // par defaut on hash selon les contextes qui sont a priori moins variables
4986
+    // mais on peut hasher selon le contenu a la demande, si plusieurs contextes produisent un meme contenu
4987
+    // reduit la variabilite du nom et donc le nombre de css concatenees possibles in fine
4988
+    if (isset($options['hash_on_content']) && $options['hash_on_content']) {
4989
+        $hash = md5((string) ($contexte_implicite['host'] . '::' . $cache));
4990
+    }
4991
+    else {
4992
+        unset($contexte_implicite['notes']); // pas pertinent pour signaler un changeemnt de contenu pour des css/js
4993
+        ksort($contexte);
4994
+        $hash = md5($fond . json_encode($contexte_implicite, JSON_THROW_ON_ERROR) . json_encode($contexte, JSON_THROW_ON_ERROR) . $connect);
4995
+    }
4996
+    $filename = $dir_var . $extension . "dyn-$nom_safe-" . substr($hash, 0, 8) . ".$extension";
4997
+
4998
+    // mettre a jour le fichier si il n'existe pas
4999
+    // ou trop ancien
5000
+    // le dernier fichier produit est toujours suffixe par .last
5001
+    // et recopie sur le fichier cible uniquement si il change
5002
+    if (
5003
+        !file_exists($filename)
5004
+        || !file_exists($filename . '.last')
5005
+        || isset($cache['lastmodified']) && $cache['lastmodified'] && filemtime($filename . '.last') < $cache['lastmodified']
5006
+        || defined('_VAR_MODE') && _VAR_MODE == 'recalcul'
5007
+    ) {
5008
+        $contenu = $cache['texte'];
5009
+        // passer les urls en absolu si c'est une css
5010
+        if ($extension == 'css') {
5011
+            $contenu = urls_absolues_css(
5012
+                $contenu,
5013
+                test_espace_prive() ? generer_url_ecrire('accueil') : generer_url_public($fond)
5014
+            );
5015
+        }
5016
+
5017
+        $comment = '';
5018
+        // ne pas insérer de commentaire sur certains formats
5019
+        if (!in_array($extension, ['json', 'xml', 'svg'])) {
5020
+            $comment = "/* #PRODUIRE{fond=$fond";
5021
+            foreach ($contexte as $k => $v) {
5022
+                if (is_array($v)) {
5023
+                    $v = var_export($v, true);
5024
+                }
5025
+                $comment .= ",$k=$v";
5026
+            }
5027
+            // pas de date dans le commentaire car sinon ca invalide le md5 et force la maj
5028
+            // mais on peut mettre un md5 du contenu, ce qui donne un aperu rapide si la feuille a change ou non
5029
+            $comment .= "}\n   md5:" . md5((string) $contenu) . " */\n";
5030
+        }
5031
+        // et ecrire le fichier si il change
5032
+        ecrire_fichier_calcule_si_modifie($filename, $comment . $contenu, false, true);
5033
+    }
5034
+
5035
+    return timestamp($filename);
5036 5036
 }
5037 5037
 
5038 5038
 /**
@@ -5045,11 +5045,11 @@  discard block
 block discarded – undo
5045 5045
  *    $fichier auquel on a ajouté le timestamp
5046 5046
  */
5047 5047
 function timestamp($fichier) {
5048
-	if (!$fichier || !file_exists($fichier) || !$m = filemtime($fichier)) {
5049
-		return $fichier;
5050
-	}
5048
+    if (!$fichier || !file_exists($fichier) || !$m = filemtime($fichier)) {
5049
+        return $fichier;
5050
+    }
5051 5051
 
5052
-	return "$fichier?$m";
5052
+    return "$fichier?$m";
5053 5053
 }
5054 5054
 
5055 5055
 /**
@@ -5059,11 +5059,11 @@  discard block
 block discarded – undo
5059 5059
  * @return string
5060 5060
  */
5061 5061
 function supprimer_timestamp($url) {
5062
-	if (!str_contains($url, '?')) {
5063
-		return $url;
5064
-	}
5062
+    if (!str_contains($url, '?')) {
5063
+        return $url;
5064
+    }
5065 5065
 
5066
-	return preg_replace(',\?[[:digit:]]+$,', '', $url);
5066
+    return preg_replace(',\?[[:digit:]]+$,', '', $url);
5067 5067
 }
5068 5068
 
5069 5069
 /**
@@ -5078,15 +5078,15 @@  discard block
 block discarded – undo
5078 5078
  * @return string
5079 5079
  */
5080 5080
 function filtre_nettoyer_titre_email_dist($titre) {
5081
-	include_spip('inc/envoyer_mail');
5081
+    include_spip('inc/envoyer_mail');
5082 5082
 
5083
-	$titre = nettoyer_titre_email($titre);
5084
-	// on est dans un squelette : securiser le retour
5085
-	if (str_contains($titre, '<')) {
5086
-		$titre = interdire_scripts($titre);
5087
-	}
5083
+    $titre = nettoyer_titre_email($titre);
5084
+    // on est dans un squelette : securiser le retour
5085
+    if (str_contains($titre, '<')) {
5086
+        $titre = interdire_scripts($titre);
5087
+    }
5088 5088
 
5089
-	return $titre;
5089
+    return $titre;
5090 5090
 }
5091 5091
 
5092 5092
 /**
@@ -5108,27 +5108,27 @@  discard block
 block discarded – undo
5108 5108
  * @return string
5109 5109
  */
5110 5110
 function filtre_chercher_rubrique_dist(
5111
-	$titre,
5112
-	$id_objet,
5113
-	$id_parent,
5114
-	$objet,
5115
-	$id_secteur,
5116
-	$restreint,
5117
-	$actionable = false,
5118
-	$retour_sans_cadre = false
5111
+    $titre,
5112
+    $id_objet,
5113
+    $id_parent,
5114
+    $objet,
5115
+    $id_secteur,
5116
+    $restreint,
5117
+    $actionable = false,
5118
+    $retour_sans_cadre = false
5119 5119
 ) {
5120
-	include_spip('inc/filtres_ecrire');
5120
+    include_spip('inc/filtres_ecrire');
5121 5121
 
5122
-	return chercher_rubrique(
5123
-		$titre,
5124
-		$id_objet,
5125
-		$id_parent,
5126
-		$objet,
5127
-		$id_secteur,
5128
-		$restreint,
5129
-		$actionable,
5130
-		$retour_sans_cadre
5131
-	);
5122
+    return chercher_rubrique(
5123
+        $titre,
5124
+        $id_objet,
5125
+        $id_parent,
5126
+        $objet,
5127
+        $id_secteur,
5128
+        $restreint,
5129
+        $actionable,
5130
+        $retour_sans_cadre
5131
+    );
5132 5132
 }
5133 5133
 
5134 5134
 /**
@@ -5157,56 +5157,56 @@  discard block
 block discarded – undo
5157 5157
  *     Chaîne vide si l'accès est autorisé
5158 5158
  */
5159 5159
 function sinon_interdire_acces($ok = false, $url = '', $statut = 0, $message = null) {
5160
-	if ($ok) {
5161
-		return '';
5162
-	}
5163
-
5164
-	// Vider tous les tampons
5165
-	$level = @ob_get_level();
5166
-	while ($level--) {
5167
-		@ob_end_clean();
5168
-	}
5169
-
5170
-	include_spip('inc/headers');
5171
-
5172
-	// S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
5173
-	if ($url) {
5174
-		redirige_par_entete($url, '', $statut);
5175
-	}
5176
-
5177
-	// ecriture simplifiee avec message en 3eme argument (= statut 403)
5178
-	if (!is_numeric($statut) && is_null($message)) {
5179
-		$message = $statut;
5180
-		$statut = 0;
5181
-	}
5182
-	if (!$message) {
5183
-		$message = '';
5184
-	}
5185
-	$statut = (int) $statut;
5186
-
5187
-	// Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
5188
-	if (test_espace_prive()) {
5189
-		if (!$statut || !in_array($statut, [404, 403])) {
5190
-			$statut = 403;
5191
-		}
5192
-		http_response_code(403);
5193
-		$echec = charger_fonction('403', 'exec');
5194
-		$echec($message);
5195
-	} else {
5196
-		// Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
5197
-		if (!$statut) {
5198
-			$statut = 404;
5199
-		}
5200
-		// Dans tous les cas on modifie l'entité avec ce qui est demandé
5201
-		http_response_code($statut);
5202
-		// Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
5203
-		if ($statut >= 400) {
5204
-			echo recuperer_fond("$statut", ['erreur' => $message]);
5205
-		}
5206
-	}
5207
-
5208
-
5209
-	exit;
5160
+    if ($ok) {
5161
+        return '';
5162
+    }
5163
+
5164
+    // Vider tous les tampons
5165
+    $level = @ob_get_level();
5166
+    while ($level--) {
5167
+        @ob_end_clean();
5168
+    }
5169
+
5170
+    include_spip('inc/headers');
5171
+
5172
+    // S'il y a une URL, on redirige (si pas de statut, la fonction mettra 302 par défaut)
5173
+    if ($url) {
5174
+        redirige_par_entete($url, '', $statut);
5175
+    }
5176
+
5177
+    // ecriture simplifiee avec message en 3eme argument (= statut 403)
5178
+    if (!is_numeric($statut) && is_null($message)) {
5179
+        $message = $statut;
5180
+        $statut = 0;
5181
+    }
5182
+    if (!$message) {
5183
+        $message = '';
5184
+    }
5185
+    $statut = (int) $statut;
5186
+
5187
+    // Si on est dans l'espace privé, on génère du 403 Forbidden par defaut ou du 404
5188
+    if (test_espace_prive()) {
5189
+        if (!$statut || !in_array($statut, [404, 403])) {
5190
+            $statut = 403;
5191
+        }
5192
+        http_response_code(403);
5193
+        $echec = charger_fonction('403', 'exec');
5194
+        $echec($message);
5195
+    } else {
5196
+        // Sinon dans l'espace public on redirige vers une 404 par défaut, car elle toujours présente normalement
5197
+        if (!$statut) {
5198
+            $statut = 404;
5199
+        }
5200
+        // Dans tous les cas on modifie l'entité avec ce qui est demandé
5201
+        http_response_code($statut);
5202
+        // Si le statut est une erreur et qu'il n'y a pas de redirection on va chercher le squelette du même nom
5203
+        if ($statut >= 400) {
5204
+            echo recuperer_fond("$statut", ['erreur' => $message]);
5205
+        }
5206
+    }
5207
+
5208
+
5209
+    exit;
5210 5210
 }
5211 5211
 
5212 5212
 /**
@@ -5217,11 +5217,11 @@  discard block
 block discarded – undo
5217 5217
  * @return string
5218 5218
  */
5219 5219
 function filtre_compacte_dist($source, $format = null) {
5220
-	if (function_exists('minifier')) {
5221
-		return minifier($source, $format);
5222
-	}
5220
+    if (function_exists('minifier')) {
5221
+        return minifier($source, $format);
5222
+    }
5223 5223
 
5224
-	return $source;
5224
+    return $source;
5225 5225
 }
5226 5226
 
5227 5227
 
@@ -5231,32 +5231,32 @@  discard block
 block discarded – undo
5231 5231
  * @return string
5232 5232
  */
5233 5233
 function spip_affiche_mot_de_passe_masque(#[\SensitiveParameter] ?string $passe, bool $afficher_partiellement = false, ?int $portion_pourcent = null): string {
5234
-	$passe ??= '';
5235
-	$l = strlen($passe);
5236
-
5237
-	if ($l <= 8 || !$afficher_partiellement) {
5238
-		if (!$l) {
5239
-			return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
5240
-		}
5241
-		return str_pad('', $afficher_partiellement ? $l : 16, '*');
5242
-	}
5243
-
5244
-	if (is_null($portion_pourcent)) {
5245
-		if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) {
5246
-			define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20%
5247
-		}
5248
-		$portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT;
5249
-	}
5250
-	if ($portion_pourcent >= 100) {
5251
-		return $passe;
5252
-	}
5253
-	$e = (int) ceil($l * $portion_pourcent / 100 / 2);
5254
-	$e = max($e, 0);
5255
-	$mid = str_pad('', $l - 2 * $e, '*');
5256
-	if ($e > 0 && strlen($mid) > 8) {
5257
-		$mid = '***...***';
5258
-	}
5259
-	return substr($passe, 0, $e) . $mid . ($e > 0 ? substr($passe, -$e) : '');
5234
+    $passe ??= '';
5235
+    $l = strlen($passe);
5236
+
5237
+    if ($l <= 8 || !$afficher_partiellement) {
5238
+        if (!$l) {
5239
+            return ''; // montrer qu'il y a pas de mot de passe si il y en a pas
5240
+        }
5241
+        return str_pad('', $afficher_partiellement ? $l : 16, '*');
5242
+    }
5243
+
5244
+    if (is_null($portion_pourcent)) {
5245
+        if (!defined('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT')) {
5246
+            define('_SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT', 20); // 20%
5247
+        }
5248
+        $portion_pourcent = _SPIP_AFFICHE_MOT_DE_PASSE_MASQUE_PERCENT;
5249
+    }
5250
+    if ($portion_pourcent >= 100) {
5251
+        return $passe;
5252
+    }
5253
+    $e = (int) ceil($l * $portion_pourcent / 100 / 2);
5254
+    $e = max($e, 0);
5255
+    $mid = str_pad('', $l - 2 * $e, '*');
5256
+    if ($e > 0 && strlen($mid) > 8) {
5257
+        $mid = '***...***';
5258
+    }
5259
+    return substr($passe, 0, $e) . $mid . ($e > 0 ? substr($passe, -$e) : '');
5260 5260
 }
5261 5261
 
5262 5262
 
@@ -5277,66 +5277,66 @@  discard block
 block discarded – undo
5277 5277
  */
5278 5278
 function identifiant_slug($texte, $type = '', $options = []) {
5279 5279
 
5280
-	$original = $texte;
5281
-	$separateur = ($options['separateur'] ?? '_');
5282
-	$longueur_maxi = ($options['longueur_maxi'] ?? 60);
5283
-	$longueur_mini = ($options['longueur_mini'] ?? 0);
5280
+    $original = $texte;
5281
+    $separateur = ($options['separateur'] ?? '_');
5282
+    $longueur_maxi = ($options['longueur_maxi'] ?? 60);
5283
+    $longueur_mini = ($options['longueur_mini'] ?? 0);
5284 5284
 
5285
-	if (!function_exists('translitteration')) {
5286
-		include_spip('inc/charsets');
5287
-	}
5285
+    if (!function_exists('translitteration')) {
5286
+        include_spip('inc/charsets');
5287
+    }
5288 5288
 
5289
-	// pas de balise html
5290
-	if (str_contains($texte, '<')) {
5291
-		$texte = strip_tags($texte);
5292
-	}
5293
-	if (str_contains($texte, '&')) {
5294
-		$texte = unicode2charset($texte);
5295
-	}
5296
-	// On enlève les espaces indésirables
5297
-	$texte = trim($texte);
5289
+    // pas de balise html
5290
+    if (str_contains($texte, '<')) {
5291
+        $texte = strip_tags($texte);
5292
+    }
5293
+    if (str_contains($texte, '&')) {
5294
+        $texte = unicode2charset($texte);
5295
+    }
5296
+    // On enlève les espaces indésirables
5297
+    $texte = trim($texte);
5298 5298
 
5299
-	// On enlève les accents et cie
5300
-	$texte = translitteration($texte);
5299
+    // On enlève les accents et cie
5300
+    $texte = translitteration($texte);
5301 5301
 
5302
-	// On remplace tout ce qui n'est pas un mot par un séparateur
5303
-	$texte = preg_replace(',[\W_]+,ms', (string) $separateur, $texte);
5302
+    // On remplace tout ce qui n'est pas un mot par un séparateur
5303
+    $texte = preg_replace(',[\W_]+,ms', (string) $separateur, $texte);
5304 5304
 
5305
-	if ($separateur) {
5306
-		// nettoyer les doubles occurences du separateur si besoin
5307
-		while (str_contains($texte, (string) "$separateur$separateur")) {
5308
-			$texte = str_replace("$separateur$separateur", $separateur, $texte);
5309
-		}
5305
+    if ($separateur) {
5306
+        // nettoyer les doubles occurences du separateur si besoin
5307
+        while (str_contains($texte, (string) "$separateur$separateur")) {
5308
+            $texte = str_replace("$separateur$separateur", $separateur, $texte);
5309
+        }
5310 5310
 
5311
-		// pas de separateur au debut ni a la fin
5312
-		$texte = trim($texte, $separateur);
5313
-	}
5311
+        // pas de separateur au debut ni a la fin
5312
+        $texte = trim($texte, $separateur);
5313
+    }
5314 5314
 
5315
-	// en minuscules
5316
-	$texte = strtolower($texte);
5315
+    // en minuscules
5316
+    $texte = strtolower($texte);
5317 5317
 
5318
-	switch ($type) {
5319
-		case 'class':
5320
-		case 'id':
5321
-		case 'anchor':
5322
-			if (preg_match(',^\d,', $texte)) {
5323
-				$texte = substr($type, 0, 1) . $texte;
5324
-			}
5325
-	}
5318
+    switch ($type) {
5319
+        case 'class':
5320
+        case 'id':
5321
+        case 'anchor':
5322
+            if (preg_match(',^\d,', $texte)) {
5323
+                $texte = substr($type, 0, 1) . $texte;
5324
+            }
5325
+    }
5326 5326
 
5327
-	if (strlen($texte) > $longueur_maxi) {
5328
-		$texte = substr($texte, 0, $longueur_maxi);
5329
-	}
5327
+    if (strlen($texte) > $longueur_maxi) {
5328
+        $texte = substr($texte, 0, $longueur_maxi);
5329
+    }
5330 5330
 
5331
-	if (strlen($texte) < $longueur_mini && $longueur_mini < $longueur_maxi) {
5332
-		if (preg_match(',^\d,', $texte)) {
5333
-			$texte = ($type ? substr($type, 0, 1) : 's') . $texte;
5334
-		}
5335
-		$texte .= $separateur . md5($original);
5336
-		$texte = substr($texte, 0, $longueur_mini);
5337
-	}
5331
+    if (strlen($texte) < $longueur_mini && $longueur_mini < $longueur_maxi) {
5332
+        if (preg_match(',^\d,', $texte)) {
5333
+            $texte = ($type ? substr($type, 0, 1) : 's') . $texte;
5334
+        }
5335
+        $texte .= $separateur . md5($original);
5336
+        $texte = substr($texte, 0, $longueur_mini);
5337
+    }
5338 5338
 
5339
-	return $texte;
5339
+    return $texte;
5340 5340
 }
5341 5341
 
5342 5342
 
@@ -5357,11 +5357,11 @@  discard block
 block discarded – undo
5357 5357
  * @exemple `<:info_maximum|label_nettoyer:>`
5358 5358
  */
5359 5359
 function label_nettoyer(string $text, bool $ucfirst = true): string {
5360
-	$label = preg_replace('#([\s:]|\&nbsp;)+$#u', '', $text);
5361
-	if ($ucfirst) {
5362
-		$label = spip_ucfirst($label);
5363
-	}
5364
-	return $label;
5360
+    $label = preg_replace('#([\s:]|\&nbsp;)+$#u', '', $text);
5361
+    if ($ucfirst) {
5362
+        $label = spip_ucfirst($label);
5363
+    }
5364
+    return $label;
5365 5365
 }
5366 5366
 
5367 5367
 /**
@@ -5374,8 +5374,8 @@  discard block
 block discarded – undo
5374 5374
  * @exemple `<:info_maximum|label_ponctuer:>`
5375 5375
  */
5376 5376
 function label_ponctuer(string $text, bool $ucfirst = true): string {
5377
-	$label = label_nettoyer($text, $ucfirst);
5378
-	return _T('label_ponctuer', ['label' => $label]);
5377
+    $label = label_nettoyer($text, $ucfirst);
5378
+    return _T('label_ponctuer', ['label' => $label]);
5379 5379
 }
5380 5380
 
5381 5381
 
@@ -5388,19 +5388,19 @@  discard block
 block discarded – undo
5388 5388
  * @return array
5389 5389
  */
5390 5390
 function helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, $fonction) {
5391
-	if (!in_array($fonction, ['objet_lister_parents', 'objet_lister_enfants', 'objet_lister_parents_par_type', 'objet_lister_enfants_par_type'])) {
5392
-		return [];
5393
-	}
5391
+    if (!in_array($fonction, ['objet_lister_parents', 'objet_lister_enfants', 'objet_lister_parents_par_type', 'objet_lister_enfants_par_type'])) {
5392
+        return [];
5393
+    }
5394 5394
 
5395
-	// compatibilite signature inversee
5396
-	if (is_numeric($objet) && !is_numeric($id_objet)) {
5397
-		[$objet, $id_objet] = [$id_objet, $objet];
5398
-	}
5395
+    // compatibilite signature inversee
5396
+    if (is_numeric($objet) && !is_numeric($id_objet)) {
5397
+        [$objet, $id_objet] = [$id_objet, $objet];
5398
+    }
5399 5399
 
5400
-	if (!function_exists($fonction)) {
5401
-		include_spip('base/objets');
5402
-	}
5403
-	return $fonction($objet, $id_objet);
5400
+    if (!function_exists($fonction)) {
5401
+        include_spip('base/objets');
5402
+    }
5403
+    return $fonction($objet, $id_objet);
5404 5404
 }
5405 5405
 
5406 5406
 
@@ -5415,7 +5415,7 @@  discard block
 block discarded – undo
5415 5415
  * @return array
5416 5416
  */
5417 5417
 function filtre_objet_lister_parents_dist($objet, $id_objet) {
5418
-	return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents');
5418
+    return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents');
5419 5419
 }
5420 5420
 
5421 5421
 /**
@@ -5429,7 +5429,7 @@  discard block
 block discarded – undo
5429 5429
  * @return array
5430 5430
  */
5431 5431
 function filtre_objet_lister_parents_par_type_dist($objet, $id_objet) {
5432
-	return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents_par_type');
5432
+    return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_parents_par_type');
5433 5433
 }
5434 5434
 
5435 5435
 /**
@@ -5443,7 +5443,7 @@  discard block
 block discarded – undo
5443 5443
  * @return array
5444 5444
  */
5445 5445
 function filtre_objet_lister_enfants_dist($objet, $id_objet) {
5446
-	return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants');
5446
+    return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants');
5447 5447
 }
5448 5448
 
5449 5449
 /**
@@ -5457,5 +5457,5 @@  discard block
 block discarded – undo
5457 5457
  * @return array
5458 5458
  */
5459 5459
 function filtre_objet_lister_enfants_par_type_dist($objet, $id_objet) {
5460
-	return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants_par_type');
5460
+    return helper_filtre_objet_lister_enfants_ou_parents($objet, $id_objet, 'objet_lister_enfants_par_type');
5461 5461
 }
Please login to merge, or discard this patch.
ecrire/inc/plonger.php 2 patches
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -10,111 +10,111 @@
 block discarded – undo
10 10
 \***************************************************************************/
11 11
 
12 12
 if (!defined('_ECRIRE_INC_VERSION')) {
13
-	return;
13
+    return;
14 14
 }
15 15
 
16 16
 include_spip('inc/texte');
17 17
 
18 18
 function inc_plonger_dist($id_rubrique, $idom = '', $list = [], $col = 1, $exclu = 0, $do = 'aff') {
19 19
 
20
-	if ($list) {
21
-		$id_rubrique = $list[$col - 1];
22
-	}
20
+    if ($list) {
21
+        $id_rubrique = $list[$col - 1];
22
+    }
23 23
 
24
-	$ret = '';
24
+    $ret = '';
25 25
 
26
-	# recherche les filles et petites-filles de la rubrique donnee
27
-	# en excluant une eventuelle rubrique interdite (par exemple, lorsqu'on
28
-	# deplace une rubrique, on peut la deplacer partout a partir de la
29
-	# racine... sauf vers elle-meme ou sa propre branche)
30
-	$ordre = [];
31
-	$rub = [];
26
+    # recherche les filles et petites-filles de la rubrique donnee
27
+    # en excluant une eventuelle rubrique interdite (par exemple, lorsqu'on
28
+    # deplace une rubrique, on peut la deplacer partout a partir de la
29
+    # racine... sauf vers elle-meme ou sa propre branche)
30
+    $ordre = [];
31
+    $rub = [];
32 32
 
33
-	$res = sql_select(
34
-		'rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie, rub2.id_rubrique AS id_enfant',
35
-		'spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)',
36
-		'rub1.id_parent = ' . sql_quote($id_rubrique) . '
33
+    $res = sql_select(
34
+        'rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie, rub2.id_rubrique AS id_enfant',
35
+        'spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)',
36
+        'rub1.id_parent = ' . sql_quote($id_rubrique) . '
37 37
 			AND rub1.id_rubrique!=' . sql_quote($exclu) . '
38 38
 			AND (rub2.id_rubrique IS NULL OR rub2.id_rubrique!=' . sql_quote($exclu) . ')',
39
-		'',
40
-		'0+rub1.titre,rub1.titre'
41
-	);
39
+        '',
40
+        '0+rub1.titre,rub1.titre'
41
+    );
42 42
 
43
-	while ($row = sql_fetch($res)) {
44
-		if (autoriser('voir', 'rubrique', $row['id_rubrique'])) {
45
-			$rub[$row['id_rubrique']]['enfants'] = $row['id_enfant'];
46
-			if ($row['id_parent'] == $id_rubrique) {
47
-				$t = trim((string) typo(supprimer_numero($row['titre'])));
48
-				if ($row['langue_choisie'] != 'oui') {
49
-					$t .= ' <small title="'
50
-						. traduire_nom_langue($row['lang'])
51
-						. '">[' . $row['lang'] . ']</small>';
52
-				}
53
-				$ordre[$row['id_rubrique']] = $t;
54
-			}
55
-		}
56
-	}
57
-	$next = $list[$col] ?? 0;
58
-	if ($ordre) {
59
-		$rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=" . ($col + 1));
60
-		$info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
61
-		$args = "'$idom',this,$col,'" . $GLOBALS['spip_lang_left'] . "','$info',event";
43
+    while ($row = sql_fetch($res)) {
44
+        if (autoriser('voir', 'rubrique', $row['id_rubrique'])) {
45
+            $rub[$row['id_rubrique']]['enfants'] = $row['id_enfant'];
46
+            if ($row['id_parent'] == $id_rubrique) {
47
+                $t = trim((string) typo(supprimer_numero($row['titre'])));
48
+                if ($row['langue_choisie'] != 'oui') {
49
+                    $t .= ' <small title="'
50
+                        . traduire_nom_langue($row['lang'])
51
+                        . '">[' . $row['lang'] . ']</small>';
52
+                }
53
+                $ordre[$row['id_rubrique']] = $t;
54
+            }
55
+        }
56
+    }
57
+    $next = $list[$col] ?? 0;
58
+    if ($ordre) {
59
+        $rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=" . ($col + 1));
60
+        $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
61
+        $args = "'$idom',this,$col,'" . $GLOBALS['spip_lang_left'] . "','$info',event";
62 62
 
63
-		foreach ($ordre as $id => $titrebrut) {
64
-			$titre = supprimer_numero($titrebrut);
63
+        foreach ($ordre as $id => $titrebrut) {
64
+            $titre = supprimer_numero($titrebrut);
65 65
 
66
-			$classe1 = 'petit-item ' . ($id_rubrique ? 'petite-rubrique' : 'petit-secteur');
67
-			if (isset($rub[$id]['enfants'])) {
68
-				$classe2 = " class='rub-ouverte'";
69
-				$url = "\nhref='$rec&amp;id=$id'";
70
-			} else {
71
-				$classe2 = $url = '';
72
-				$url = "\nhref='javascript:void(0)'";
73
-			}
66
+            $classe1 = 'petit-item ' . ($id_rubrique ? 'petite-rubrique' : 'petit-secteur');
67
+            if (isset($rub[$id]['enfants'])) {
68
+                $classe2 = " class='rub-ouverte'";
69
+                $url = "\nhref='$rec&amp;id=$id'";
70
+            } else {
71
+                $classe2 = $url = '';
72
+                $url = "\nhref='javascript:void(0)'";
73
+            }
74 74
 
75
-			$js_func = $do . '_selection_titre';
76
-			$click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn "
77
-				. (is_array($list) ? "aff_selection_provisoire($id,$args)" : ' false')
75
+            $js_func = $do . '_selection_titre';
76
+            $click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn "
77
+                . (is_array($list) ? "aff_selection_provisoire($id,$args)" : ' false')
78 78
 # ce lien provoque la selection (directe) de la rubrique cliquee
79 79
 # et l'affichage de son titre dans le bandeau
80
-				. "\"\nondblclick=\""
81
-				. "$js_func(this."
82
-				. 'firstChild.nodeValue,'
83
-				. $id
84
-				. ",'selection_rubrique','id_parent');"
85
-				. "\nreturn aff_selection_provisoire($id,$args);"
86
-				. '"';
80
+                . "\"\nondblclick=\""
81
+                . "$js_func(this."
82
+                . 'firstChild.nodeValue,'
83
+                . $id
84
+                . ",'selection_rubrique','id_parent');"
85
+                . "\nreturn aff_selection_provisoire($id,$args);"
86
+                . '"';
87 87
 
88
-			$ret .= "<div class='"
89
-				. (($id == $next) ? 'item on' : 'item')
90
-				. "'><div class='"
91
-				. $classe1
92
-				. "'><div$classe2><a"
93
-				. $url
94
-				. $click
95
-				. '>'
96
-				. $titre
97
-				. '</a></div></div></div>';
98
-		}
99
-	}
88
+            $ret .= "<div class='"
89
+                . (($id == $next) ? 'item on' : 'item')
90
+                . "'><div class='"
91
+                . $classe1
92
+                . "'><div$classe2><a"
93
+                . $url
94
+                . $click
95
+                . '>'
96
+                . $titre
97
+                . '</a></div></div></div>';
98
+        }
99
+    }
100 100
 
101
-	$idom2 = $idom . '_col_' . ($col + 1);
102
-	$left = ($col * 250);
101
+    $idom2 = $idom . '_col_' . ($col + 1);
102
+    $left = ($col * 250);
103 103
 
104
-	return http_img_pack(
105
-		'loader.svg',
106
-		'',
107
-		"class='loader' style='visibility: hidden; position: absolute; " . $GLOBALS['spip_lang_left'] . ': '
108
-		. ($left - 30)
109
-		. "px; top: 2px; z-index: 2;' id='img_$idom2'"
110
-	)
111
-	. "<div style='width: 250px; height: 100%; overflow: auto; position: absolute; top: 0px; " . $GLOBALS['spip_lang_left'] . ': '
112
-	. ($left - 250)
113
-	. "px;'>"
114
-	. $ret
115
-	. "\n</div>\n<div id='$idom2'>"
116
-	. ($next
117
-		? inc_plonger_dist($id_rubrique, $idom, $list, $col + 1, $exclu)
118
-		: '')
119
-	. "\n</div>";
104
+    return http_img_pack(
105
+        'loader.svg',
106
+        '',
107
+        "class='loader' style='visibility: hidden; position: absolute; " . $GLOBALS['spip_lang_left'] . ': '
108
+        . ($left - 30)
109
+        . "px; top: 2px; z-index: 2;' id='img_$idom2'"
110
+    )
111
+    . "<div style='width: 250px; height: 100%; overflow: auto; position: absolute; top: 0px; " . $GLOBALS['spip_lang_left'] . ': '
112
+    . ($left - 250)
113
+    . "px;'>"
114
+    . $ret
115
+    . "\n</div>\n<div id='$idom2'>"
116
+    . ($next
117
+        ? inc_plonger_dist($id_rubrique, $idom, $list, $col + 1, $exclu)
118
+        : '')
119
+    . "\n</div>";
120 120
 }
Please login to merge, or discard this patch.
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -33,9 +33,9 @@  discard block
 block discarded – undo
33 33
 	$res = sql_select(
34 34
 		'rub1.id_rubrique, rub1.titre, rub1.id_parent, rub1.lang, rub1.langue_choisie, rub2.id_rubrique AS id_enfant',
35 35
 		'spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)',
36
-		'rub1.id_parent = ' . sql_quote($id_rubrique) . '
37
-			AND rub1.id_rubrique!=' . sql_quote($exclu) . '
38
-			AND (rub2.id_rubrique IS NULL OR rub2.id_rubrique!=' . sql_quote($exclu) . ')',
36
+		'rub1.id_parent = '.sql_quote($id_rubrique).'
37
+			AND rub1.id_rubrique!=' . sql_quote($exclu).'
38
+			AND (rub2.id_rubrique IS NULL OR rub2.id_rubrique!=' . sql_quote($exclu).')',
39 39
 		'',
40 40
 		'0+rub1.titre,rub1.titre'
41 41
 	);
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
 				if ($row['langue_choisie'] != 'oui') {
49 49
 					$t .= ' <small title="'
50 50
 						. traduire_nom_langue($row['lang'])
51
-						. '">[' . $row['lang'] . ']</small>';
51
+						. '">['.$row['lang'].']</small>';
52 52
 				}
53 53
 				$ordre[$row['id_rubrique']] = $t;
54 54
 			}
@@ -56,14 +56,14 @@  discard block
 block discarded – undo
56 56
 	}
57 57
 	$next = $list[$col] ?? 0;
58 58
 	if ($ordre) {
59
-		$rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=" . ($col + 1));
59
+		$rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=".($col + 1));
60 60
 		$info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
61
-		$args = "'$idom',this,$col,'" . $GLOBALS['spip_lang_left'] . "','$info',event";
61
+		$args = "'$idom',this,$col,'".$GLOBALS['spip_lang_left']."','$info',event";
62 62
 
63 63
 		foreach ($ordre as $id => $titrebrut) {
64 64
 			$titre = supprimer_numero($titrebrut);
65 65
 
66
-			$classe1 = 'petit-item ' . ($id_rubrique ? 'petite-rubrique' : 'petit-secteur');
66
+			$classe1 = 'petit-item '.($id_rubrique ? 'petite-rubrique' : 'petit-secteur');
67 67
 			if (isset($rub[$id]['enfants'])) {
68 68
 				$classe2 = " class='rub-ouverte'";
69 69
 				$url = "\nhref='$rec&amp;id=$id'";
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 				$url = "\nhref='javascript:void(0)'";
73 73
 			}
74 74
 
75
-			$js_func = $do . '_selection_titre';
75
+			$js_func = $do.'_selection_titre';
76 76
 			$click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn "
77 77
 				. (is_array($list) ? "aff_selection_provisoire($id,$args)" : ' false')
78 78
 # ce lien provoque la selection (directe) de la rubrique cliquee
@@ -98,17 +98,17 @@  discard block
 block discarded – undo
98 98
 		}
99 99
 	}
100 100
 
101
-	$idom2 = $idom . '_col_' . ($col + 1);
101
+	$idom2 = $idom.'_col_'.($col + 1);
102 102
 	$left = ($col * 250);
103 103
 
104 104
 	return http_img_pack(
105 105
 		'loader.svg',
106 106
 		'',
107
-		"class='loader' style='visibility: hidden; position: absolute; " . $GLOBALS['spip_lang_left'] . ': '
107
+		"class='loader' style='visibility: hidden; position: absolute; ".$GLOBALS['spip_lang_left'].': '
108 108
 		. ($left - 30)
109 109
 		. "px; top: 2px; z-index: 2;' id='img_$idom2'"
110 110
 	)
111
-	. "<div style='width: 250px; height: 100%; overflow: auto; position: absolute; top: 0px; " . $GLOBALS['spip_lang_left'] . ': '
111
+	. "<div style='width: 250px; height: 100%; overflow: auto; position: absolute; top: 0px; ".$GLOBALS['spip_lang_left'].': '
112 112
 	. ($left - 250)
113 113
 	. "px;'>"
114 114
 	. $ret
Please login to merge, or discard this patch.
ecrire/inc/icone_renommer.php 2 patches
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -10,71 +10,71 @@
 block discarded – undo
10 10
 \***************************************************************************/
11 11
 
12 12
 if (!defined('_ECRIRE_INC_VERSION')) {
13
-	return;
13
+    return;
14 14
 }
15 15
 
16 16
 include_spip('inc/boutons');
17 17
 include_spip('base/objets');
18 18
 
19 19
 function inc_icone_renommer_dist($fond, $fonction) {
20
-	$size = 24;
21
-	if (
22
-		preg_match('/(?:-(\d{1,3}))?([.](gif|png|svg))?$/i', (string) $fond, $match)
23
-		&& (isset($match[0]) && $match[0] || isset($match[1]) && $match[1])
24
-	) {
25
-		if (isset($match[1]) && $match[1]) {
26
-			$size = $match[1];
27
-		}
28
-		$type = substr((string) $fond, 0, -strlen($match[0]));
29
-		if (!isset($match[2]) || !$match[2]) {
30
-			$fond .= '.png';
31
-		}
32
-	} else {
33
-		$type = $fond;
34
-		$fond .= '.png';
35
-	}
20
+    $size = 24;
21
+    if (
22
+        preg_match('/(?:-(\d{1,3}))?([.](gif|png|svg))?$/i', (string) $fond, $match)
23
+        && (isset($match[0]) && $match[0] || isset($match[1]) && $match[1])
24
+    ) {
25
+        if (isset($match[1]) && $match[1]) {
26
+            $size = $match[1];
27
+        }
28
+        $type = substr((string) $fond, 0, -strlen($match[0]));
29
+        if (!isset($match[2]) || !$match[2]) {
30
+            $fond .= '.png';
31
+        }
32
+    } else {
33
+        $type = $fond;
34
+        $fond .= '.png';
35
+    }
36 36
 
37
-	$rtl = false;
38
-	if (preg_match(',[-_]rtl$,i', (string) $type, $match)) {
39
-		$rtl = true;
40
-		$type = substr((string) $type, 0, -strlen($match[0]));
41
-	}
37
+    $rtl = false;
38
+    if (preg_match(',[-_]rtl$,i', (string) $type, $match)) {
39
+        $rtl = true;
40
+        $type = substr((string) $type, 0, -strlen($match[0]));
41
+    }
42 42
 
43
-	// objet_type garde invariant tout ce qui ne commence par par id_, spip_
44
-	// et ne finit pas par un s, sauf si c'est une exception declaree
45
-	$type = objet_type($type, false);
43
+    // objet_type garde invariant tout ce qui ne commence par par id_, spip_
44
+    // et ne finit pas par un s, sauf si c'est une exception declaree
45
+    $type = objet_type($type, false);
46 46
 
47
-	$dir = 'images/';
48
-	$f = "$type-$size.png";
49
-	if ($icone = find_in_theme($dir . $f)) {
50
-		$dir = dirname((string) $icone);
51
-		$fond = $icone;
47
+    $dir = 'images/';
48
+    $f = "$type-$size.png";
49
+    if ($icone = find_in_theme($dir . $f)) {
50
+        $dir = dirname((string) $icone);
51
+        $fond = $icone;
52 52
 
53
-		if (
54
-			$rtl
55
-			&& ($fr = $dir . '/' . str_replace("$type-", "$type-rtl-", basename((string) $icone)))
56
-			&& file_exists($fr)
57
-		) {
58
-			$fond = $fr;
59
-		}
53
+        if (
54
+            $rtl
55
+            && ($fr = $dir . '/' . str_replace("$type-", "$type-rtl-", basename((string) $icone)))
56
+            && file_exists($fr)
57
+        ) {
58
+            $fond = $fr;
59
+        }
60 60
 
61
-		$action = $fonction;
62
-		if ($action == 'supprimer.gif') {
63
-			$action = 'del';
64
-		} elseif ($action == 'creer.gif') {
65
-			$action = 'new';
66
-		} elseif ($action == 'edit.gif') {
67
-			$action = 'edit';
68
-		}
61
+        $action = $fonction;
62
+        if ($action == 'supprimer.gif') {
63
+            $action = 'del';
64
+        } elseif ($action == 'creer.gif') {
65
+            $action = 'new';
66
+        } elseif ($action == 'edit.gif') {
67
+            $action = 'edit';
68
+        }
69 69
 
70
-		$fonction = '';
71
-		if (in_array($action, ['add','del', 'new', 'edit', 'config'])) {
72
-			$fonction = $action;
73
-		}
70
+        $fonction = '';
71
+        if (in_array($action, ['add','del', 'new', 'edit', 'config'])) {
72
+            $fonction = $action;
73
+        }
74 74
 
75
-		// c'est bon !
76
-		return [$fond, $fonction];
77
-	}
75
+        // c'est bon !
76
+        return [$fond, $fonction];
77
+    }
78 78
 
79
-	return [$fond, $fonction];
79
+    return [$fond, $fonction];
80 80
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -46,13 +46,13 @@  discard block
 block discarded – undo
46 46
 
47 47
 	$dir = 'images/';
48 48
 	$f = "$type-$size.png";
49
-	if ($icone = find_in_theme($dir . $f)) {
49
+	if ($icone = find_in_theme($dir.$f)) {
50 50
 		$dir = dirname((string) $icone);
51 51
 		$fond = $icone;
52 52
 
53 53
 		if (
54 54
 			$rtl
55
-			&& ($fr = $dir . '/' . str_replace("$type-", "$type-rtl-", basename((string) $icone)))
55
+			&& ($fr = $dir.'/'.str_replace("$type-", "$type-rtl-", basename((string) $icone)))
56 56
 			&& file_exists($fr)
57 57
 		) {
58 58
 			$fond = $fr;
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
 		}
69 69
 
70 70
 		$fonction = '';
71
-		if (in_array($action, ['add','del', 'new', 'edit', 'config'])) {
71
+		if (in_array($action, ['add', 'del', 'new', 'edit', 'config'])) {
72 72
 			$fonction = $action;
73 73
 		}
74 74
 
Please login to merge, or discard this patch.
ecrire/inc/envoyer_mail.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 
132 132
 	// ceci est la RegExp NO_REAL_NAME faisant hurler SpamAssassin
133 133
 	if (preg_match('/^["\s]*\<?\S+\@\S+\>?\s*$/', (string) $from)) {
134
-		$from .= ' (' . str_replace(')', '', translitteration(str_replace('@', ' at ', (string) $from))) . ')';
134
+		$from .= ' ('.str_replace(')', '', translitteration(str_replace('@', ' at ', (string) $from))).')';
135 135
 	}
136 136
 
137 137
 	// nettoyer les &eacute; &#8217, &emdash; etc...
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
 		if (!_TEST_EMAIL_DEST) {
170 170
 			return false;
171 171
 		} else {
172
-			$texte = "Dest : $destinataire\r\n" . $texte;
172
+			$texte = "Dest : $destinataire\r\n".$texte;
173 173
 			$destinataire = _TEST_EMAIL_DEST;
174 174
 		}
175 175
 	}
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
 	// Ajouter le Content-Type et consort s'il n'y est pas deja
194 194
 	if (!str_contains($headers, 'Content-Type: ')) {
195 195
 		$type =
196
-			"Content-Type: text/plain;charset=\"$charset\";\n" .
196
+			"Content-Type: text/plain;charset=\"$charset\";\n".
197 197
 			"Content-Transfer-Encoding: 8bit\n";
198 198
 	} else {
199 199
 		$type = '';
@@ -201,16 +201,16 @@  discard block
 block discarded – undo
201 201
 
202 202
 	// calculer un identifiant unique
203 203
 	// Marie Toto <[email protected]> => @toto.com
204
-	$domain = preg_match('/@[^\s>]+/', $from, $domain) ? $domain[0] : '@unknown-' . md5($from) . '.org';
205
-	$uniq = random_int(0, mt_getrandmax()) . '_' . md5($to . $texte) . $domain;
204
+	$domain = preg_match('/@[^\s>]+/', $from, $domain) ? $domain[0] : '@unknown-'.md5($from).'.org';
205
+	$uniq = random_int(0, mt_getrandmax()).'_'.md5($to.$texte).$domain;
206 206
 
207 207
 	// Si multi-part, s'en servir comme borne ...
208 208
 	if ($parts) {
209
-		$texte = "--$uniq\n$type\n" . $texte . "\n";
209
+		$texte = "--$uniq\n$type\n".$texte."\n";
210 210
 		foreach ($parts as $part) {
211
-			$n = strlen((string) $part[1]) . ($part[0] ? "\n" : '');
211
+			$n = strlen((string) $part[1]).($part[0] ? "\n" : '');
212 212
 			$e = implode("\n", $part[0]);
213
-			$texte .= "\n--$uniq\nContent-Length: $n$e\n\n" . $part[1];
213
+			$texte .= "\n--$uniq\nContent-Length: $n$e\n\n".$part[1];
214 214
 		}
215 215
 		$texte .= "\n\n--$uniq--\n";
216 216
 		// Si boundary n'est pas entre guillemets,
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 
221 221
 	// .. et s'en servir pour plaire a SpamAssassin
222 222
 
223
-	$mid = 'Message-Id: <' . $uniq . '>';
223
+	$mid = 'Message-Id: <'.$uniq.'>';
224 224
 
225 225
 	// indispensable pour les sites qui collent d'office From: serveur-http
226 226
 	// sauf si deja mis par l'envoyeur
Please login to merge, or discard this patch.
Indentation   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
  * @package SPIP\Core\Mail
16 16
  **/
17 17
 if (!defined('_ECRIRE_INC_VERSION')) {
18
-	return;
18
+    return;
19 19
 }
20 20
 
21 21
 include_spip('inc/charsets');
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
  * @return string
32 32
  */
33 33
 function nettoyer_titre_email($titre) {
34
-	return str_replace("\n", ' ', nettoyer_caracteres_mail(textebrut(corriger_typo($titre))));
34
+    return str_replace("\n", ' ', nettoyer_caracteres_mail(textebrut(corriger_typo($titre))));
35 35
 }
36 36
 
37 37
 /**
@@ -47,21 +47,21 @@  discard block
 block discarded – undo
47 47
  */
48 48
 function nettoyer_caracteres_mail($t) {
49 49
 
50
-	$t = filtrer_entites($t);
51
-
52
-	if ($GLOBALS['meta']['charset'] != 'utf-8') {
53
-		$t = str_replace(
54
-			['&#8217;', '&#8220;', '&#8221;'],
55
-			["'", '"', '"'],
56
-			$t
57
-		);
58
-	}
59
-
60
-	return str_replace(
61
-		['&mdash;', '&endash;'],
62
-		['--', '-'],
63
-		$t
64
-	);
50
+    $t = filtrer_entites($t);
51
+
52
+    if ($GLOBALS['meta']['charset'] != 'utf-8') {
53
+        $t = str_replace(
54
+            ['&#8217;', '&#8220;', '&#8221;'],
55
+            ["'", '"', '"'],
56
+            $t
57
+        );
58
+    }
59
+
60
+    return str_replace(
61
+        ['&mdash;', '&endash;'],
62
+        ['--', '-'],
63
+        $t
64
+    );
65 65
 }
66 66
 
67 67
 /**
@@ -94,87 +94,87 @@  discard block
 block discarded – undo
94 94
  */
95 95
 function inc_envoyer_mail_dist($destinataire, $sujet, $corps, $from = '', $headers = '') {
96 96
 
97
-	if (!email_valide($destinataire)) {
98
-		return false;
99
-	}
100
-	if ($destinataire == _T('info_mail_fournisseur')) {
101
-		return false;
102
-	} // tres fort
103
-
104
-	// Fournir si possible un Message-Id: conforme au RFC1036,
105
-	// sinon SpamAssassin denoncera un MSGID_FROM_MTA_HEADER
106
-
107
-	$email_envoi = $GLOBALS['meta']['email_envoi'];
108
-	if (!email_valide($email_envoi)) {
109
-		spip_logger()->info('Meta email_envoi invalide. Le mail sera probablement vu comme spam.');
110
-		$email_envoi = $destinataire;
111
-	}
112
-
113
-	$parts = '';
114
-	if (is_array($corps)) {
115
-		$texte = $corps['texte'];
116
-		$from = ($corps['from'] ?? $from);
117
-		$headers = ($corps['headers'] ?? $headers);
118
-		if (is_array($headers)) {
119
-			$headers = implode("\n", $headers);
120
-		}
121
-		if (isset($corps['pieces_jointes']) && function_exists('mail_embarquer_pieces_jointes')) {
122
-			$parts = mail_embarquer_pieces_jointes($corps['pieces_jointes']);
123
-		}
124
-	} else {
125
-		$texte = $corps;
126
-	}
127
-
128
-	if (!$from) {
129
-		$from = $email_envoi;
130
-	}
131
-
132
-	// ceci est la RegExp NO_REAL_NAME faisant hurler SpamAssassin
133
-	if (preg_match('/^["\s]*\<?\S+\@\S+\>?\s*$/', (string) $from)) {
134
-		$from .= ' (' . str_replace(')', '', translitteration(str_replace('@', ' at ', (string) $from))) . ')';
135
-	}
136
-
137
-	// nettoyer les &eacute; &#8217, &emdash; etc...
138
-	// les 'cliquer ici' etc sont a eviter;  voir:
139
-	// http://mta.org.ua/spamassassin-2.55/stuff/wiki.CustomRulesets/20050914/rules/french_rules.cf
140
-	$texte = nettoyer_caracteres_mail($texte);
141
-	$sujet = nettoyer_caracteres_mail($sujet);
142
-
143
-	// encoder le sujet si possible selon la RFC
144
-	if (init_mb_string()) {
145
-		# un bug de mb_string casse mb_encode_mimeheader si l'encoding interne
146
-		# est UTF-8 et le charset iso-8859-1 (constate php5-mac ; php4.3-debian)
147
-		$charset = $GLOBALS['meta']['charset'];
148
-		mb_internal_encoding($charset);
149
-		$sujet = mb_encode_mimeheader($sujet, $charset, 'Q', "\n");
150
-		mb_internal_encoding('utf-8');
151
-	}
152
-
153
-	$headers ??= '';
154
-	if (function_exists('wordwrap') && (preg_match(',multipart/mixed,', (string) $headers) == 0)) {
155
-		$texte = wordwrap($texte);
156
-	}
157
-
158
-	[$headers, $texte] = mail_normaliser_headers($headers, $from, $destinataire, $texte, $parts);
159
-
160
-	if (_OS_SERVEUR == 'windows') {
161
-		$texte = preg_replace("@\r*\n@", "\r\n", (string) $texte);
162
-		$headers = preg_replace("@\r*\n@", "\r\n", (string) $headers);
163
-		$sujet = preg_replace("@\r*\n@", "\r\n", $sujet);
164
-	}
165
-
166
-	spip_logger('mails')->info("mail $destinataire\n$sujet\n$headers");
167
-	// mode TEST : forcer l'email
168
-	if (defined('_TEST_EMAIL_DEST')) {
169
-		if (!_TEST_EMAIL_DEST) {
170
-			return false;
171
-		} else {
172
-			$texte = "Dest : $destinataire\r\n" . $texte;
173
-			$destinataire = _TEST_EMAIL_DEST;
174
-		}
175
-	}
176
-
177
-	return @mail((string) $destinataire, $sujet, (string) $texte, $headers);
97
+    if (!email_valide($destinataire)) {
98
+        return false;
99
+    }
100
+    if ($destinataire == _T('info_mail_fournisseur')) {
101
+        return false;
102
+    } // tres fort
103
+
104
+    // Fournir si possible un Message-Id: conforme au RFC1036,
105
+    // sinon SpamAssassin denoncera un MSGID_FROM_MTA_HEADER
106
+
107
+    $email_envoi = $GLOBALS['meta']['email_envoi'];
108
+    if (!email_valide($email_envoi)) {
109
+        spip_logger()->info('Meta email_envoi invalide. Le mail sera probablement vu comme spam.');
110
+        $email_envoi = $destinataire;
111
+    }
112
+
113
+    $parts = '';
114
+    if (is_array($corps)) {
115
+        $texte = $corps['texte'];
116
+        $from = ($corps['from'] ?? $from);
117
+        $headers = ($corps['headers'] ?? $headers);
118
+        if (is_array($headers)) {
119
+            $headers = implode("\n", $headers);
120
+        }
121
+        if (isset($corps['pieces_jointes']) && function_exists('mail_embarquer_pieces_jointes')) {
122
+            $parts = mail_embarquer_pieces_jointes($corps['pieces_jointes']);
123
+        }
124
+    } else {
125
+        $texte = $corps;
126
+    }
127
+
128
+    if (!$from) {
129
+        $from = $email_envoi;
130
+    }
131
+
132
+    // ceci est la RegExp NO_REAL_NAME faisant hurler SpamAssassin
133
+    if (preg_match('/^["\s]*\<?\S+\@\S+\>?\s*$/', (string) $from)) {
134
+        $from .= ' (' . str_replace(')', '', translitteration(str_replace('@', ' at ', (string) $from))) . ')';
135
+    }
136
+
137
+    // nettoyer les &eacute; &#8217, &emdash; etc...
138
+    // les 'cliquer ici' etc sont a eviter;  voir:
139
+    // http://mta.org.ua/spamassassin-2.55/stuff/wiki.CustomRulesets/20050914/rules/french_rules.cf
140
+    $texte = nettoyer_caracteres_mail($texte);
141
+    $sujet = nettoyer_caracteres_mail($sujet);
142
+
143
+    // encoder le sujet si possible selon la RFC
144
+    if (init_mb_string()) {
145
+        # un bug de mb_string casse mb_encode_mimeheader si l'encoding interne
146
+        # est UTF-8 et le charset iso-8859-1 (constate php5-mac ; php4.3-debian)
147
+        $charset = $GLOBALS['meta']['charset'];
148
+        mb_internal_encoding($charset);
149
+        $sujet = mb_encode_mimeheader($sujet, $charset, 'Q', "\n");
150
+        mb_internal_encoding('utf-8');
151
+    }
152
+
153
+    $headers ??= '';
154
+    if (function_exists('wordwrap') && (preg_match(',multipart/mixed,', (string) $headers) == 0)) {
155
+        $texte = wordwrap($texte);
156
+    }
157
+
158
+    [$headers, $texte] = mail_normaliser_headers($headers, $from, $destinataire, $texte, $parts);
159
+
160
+    if (_OS_SERVEUR == 'windows') {
161
+        $texte = preg_replace("@\r*\n@", "\r\n", (string) $texte);
162
+        $headers = preg_replace("@\r*\n@", "\r\n", (string) $headers);
163
+        $sujet = preg_replace("@\r*\n@", "\r\n", $sujet);
164
+    }
165
+
166
+    spip_logger('mails')->info("mail $destinataire\n$sujet\n$headers");
167
+    // mode TEST : forcer l'email
168
+    if (defined('_TEST_EMAIL_DEST')) {
169
+        if (!_TEST_EMAIL_DEST) {
170
+            return false;
171
+        } else {
172
+            $texte = "Dest : $destinataire\r\n" . $texte;
173
+            $destinataire = _TEST_EMAIL_DEST;
174
+        }
175
+    }
176
+
177
+    return @mail((string) $destinataire, $sujet, (string) $texte, $headers);
178 178
 }
179 179
 
180 180
 /**
@@ -188,53 +188,53 @@  discard block
 block discarded – undo
188 188
  * @return array
189 189
  */
190 190
 function mail_normaliser_headers($headers, $from, $to, $texte, $parts = '') {
191
-	$charset = $GLOBALS['meta']['charset'];
192
-
193
-	// Ajouter le Content-Type et consort s'il n'y est pas deja
194
-	if (!str_contains($headers, 'Content-Type: ')) {
195
-		$type =
196
-			"Content-Type: text/plain;charset=\"$charset\";\n" .
197
-			"Content-Transfer-Encoding: 8bit\n";
198
-	} else {
199
-		$type = '';
200
-	}
201
-
202
-	// calculer un identifiant unique
203
-	// Marie Toto <[email protected]> => @toto.com
204
-	$domain = preg_match('/@[^\s>]+/', $from, $domain) ? $domain[0] : '@unknown-' . md5($from) . '.org';
205
-	$uniq = random_int(0, mt_getrandmax()) . '_' . md5($to . $texte) . $domain;
206
-
207
-	// Si multi-part, s'en servir comme borne ...
208
-	if ($parts) {
209
-		$texte = "--$uniq\n$type\n" . $texte . "\n";
210
-		foreach ($parts as $part) {
211
-			$n = strlen((string) $part[1]) . ($part[0] ? "\n" : '');
212
-			$e = implode("\n", $part[0]);
213
-			$texte .= "\n--$uniq\nContent-Length: $n$e\n\n" . $part[1];
214
-		}
215
-		$texte .= "\n\n--$uniq--\n";
216
-		// Si boundary n'est pas entre guillemets,
217
-		// elle est comprise mais le charset est ignoree !
218
-		$type = "Content-Type: multipart/mixed; boundary=\"$uniq\"\n";
219
-	}
220
-
221
-	// .. et s'en servir pour plaire a SpamAssassin
222
-
223
-	$mid = 'Message-Id: <' . $uniq . '>';
224
-
225
-	// indispensable pour les sites qui collent d'office From: serveur-http
226
-	// sauf si deja mis par l'envoyeur
227
-	$rep = (str_contains($headers, 'Reply-To:')) ? '' : "Reply-To: $from\n";
228
-
229
-	// Nettoyer les en-tetes envoyees
230
-	// Ajouter le \n final
231
-	if (strlen($headers = trim($headers))) {
232
-		$headers .= "\n";
233
-	}
234
-
235
-	// Et mentionner l'indeboulonable nomenclature ratee
236
-
237
-	$headers .= "From: $from\n$type$rep$mid\nMIME-Version: 1.0\n";
238
-
239
-	return [$headers, $texte];
191
+    $charset = $GLOBALS['meta']['charset'];
192
+
193
+    // Ajouter le Content-Type et consort s'il n'y est pas deja
194
+    if (!str_contains($headers, 'Content-Type: ')) {
195
+        $type =
196
+            "Content-Type: text/plain;charset=\"$charset\";\n" .
197
+            "Content-Transfer-Encoding: 8bit\n";
198
+    } else {
199
+        $type = '';
200
+    }
201
+
202
+    // calculer un identifiant unique
203
+    // Marie Toto <[email protected]> => @toto.com
204
+    $domain = preg_match('/@[^\s>]+/', $from, $domain) ? $domain[0] : '@unknown-' . md5($from) . '.org';
205
+    $uniq = random_int(0, mt_getrandmax()) . '_' . md5($to . $texte) . $domain;
206
+
207
+    // Si multi-part, s'en servir comme borne ...
208
+    if ($parts) {
209
+        $texte = "--$uniq\n$type\n" . $texte . "\n";
210
+        foreach ($parts as $part) {
211
+            $n = strlen((string) $part[1]) . ($part[0] ? "\n" : '');
212
+            $e = implode("\n", $part[0]);
213
+            $texte .= "\n--$uniq\nContent-Length: $n$e\n\n" . $part[1];
214
+        }
215
+        $texte .= "\n\n--$uniq--\n";
216
+        // Si boundary n'est pas entre guillemets,
217
+        // elle est comprise mais le charset est ignoree !
218
+        $type = "Content-Type: multipart/mixed; boundary=\"$uniq\"\n";
219
+    }
220
+
221
+    // .. et s'en servir pour plaire a SpamAssassin
222
+
223
+    $mid = 'Message-Id: <' . $uniq . '>';
224
+
225
+    // indispensable pour les sites qui collent d'office From: serveur-http
226
+    // sauf si deja mis par l'envoyeur
227
+    $rep = (str_contains($headers, 'Reply-To:')) ? '' : "Reply-To: $from\n";
228
+
229
+    // Nettoyer les en-tetes envoyees
230
+    // Ajouter le \n final
231
+    if (strlen($headers = trim($headers))) {
232
+        $headers .= "\n";
233
+    }
234
+
235
+    // Et mentionner l'indeboulonable nomenclature ratee
236
+
237
+    $headers .= "From: $from\n$type$rep$mid\nMIME-Version: 1.0\n";
238
+
239
+    return [$headers, $texte];
240 240
 }
Please login to merge, or discard this patch.